| 92 | } |
| 93 | |
| 94 | void V_Core::AutoDMAReadBuffer(int mode) //mode: 0= split stereo; 1 = do not split stereo |
| 95 | { |
| 96 | u32 spos = InputPosWrite & 0x100; // Starting position passed by TSA |
| 97 | bool leftbuffer = !(InputPosWrite & 0x80); |
| 98 | |
| 99 | if (InputPosWrite == 0xFFFF) // Data request not made yet |
| 100 | return; |
| 101 | |
| 102 | AutoDMACtrl &= 0x3; |
| 103 | |
| 104 | int size = std::min(InputDataLeft, (u32)0x200); |
| 105 | if (!leftbuffer) |
| 106 | size = std::min(size, 0x100); |
| 107 | #ifdef PCSX2_DEVBUILD |
| 108 | LogAutoDMA(Index ? ADMA7LogFile : ADMA4LogFile); |
| 109 | #endif |
| 110 | //ConLog("Refilling ADMA buffer at %x OutPos %x with %x\n", spos, OutPos, size); |
| 111 | // HACKFIX!! DMAPtr can be invalid after a savestate load, so the savestate just forces it |
| 112 | // to nullptr and we ignore it here. (used to work in old VM editions of PCSX2 with fixed |
| 113 | // addressing, but new PCSX2s have dynamic memory addressing). |
| 114 | if (DMAPtr == nullptr) |
| 115 | { |
| 116 | DMAPtr = (u16*)iopPhysMem(MADR); |
| 117 | InputDataProgress = 0; |
| 118 | } |
| 119 | |
| 120 | if (mode) |
| 121 | { |
| 122 | if (DMAPtr != nullptr) |
| 123 | memcpy(GetMemPtr(0x2000 + (Index << 10) + spos), DMAPtr + InputDataProgress, size); |
| 124 | MADR += size; |
| 125 | InputDataLeft -= 0x200; |
| 126 | InputDataProgress += 0x200; |
| 127 | } |
| 128 | else |
| 129 | { |
| 130 | while (size) |
| 131 | { |
| 132 | if (!leftbuffer) |
| 133 | spos |= 0x200; |
| 134 | else |
| 135 | spos &= ~0x200; |
| 136 | |
| 137 | if (DMAPtr != nullptr) |
| 138 | memcpy(GetMemPtr(0x2000 + (Index << 10) + spos), DMAPtr + InputDataProgress, 0x200); |
| 139 | InputDataTransferred += 0x200; |
| 140 | InputDataLeft -= 0x100; |
| 141 | InputDataProgress += 0x100; |
| 142 | leftbuffer = !leftbuffer; |
| 143 | size -= 0x100; |
| 144 | InputPosWrite += 0x80; |
| 145 | } |
| 146 | } |
| 147 | if (!(InputPosWrite & 0x80)) |
| 148 | InputPosWrite = 0xFFFF; |
| 149 | } |
| 150 | |
| 151 | void V_Core::StartADMAWrite(u16* pMem, u32 sz) |
nothing calls this directly
no test coverage detected