MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ReadInput

Method ReadInput

pcsx2/SPU2/ReadInput.cpp:87–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87StereoOut32 V_Core::ReadInput()
88{
89 StereoOut32 retval;
90 u16 ReadIndex = OutPos;
91
92 for (int i = 0; i < 2; i++)
93 if (Cores[i].IRQEnable && (0x2000 + (Index << 10) + ReadIndex) == (Cores[i].IRQA & 0xfffffdff))
94 SetIrqCall(i);
95
96 // PlayMode & 2 is Bypass Mode, so it doesn't go through the SPU
97 if ((Index == 1) || !(Index == 0 && (PlayMode & 2) != 0))
98 {
99 retval = StereoOut32(
100 (s32)(*GetMemPtr(0x2000 + (Index << 10) + ReadIndex)),
101 (s32)(*GetMemPtr(0x2200 + (Index << 10) + ReadIndex)));
102 }
103
104#ifdef PCSX2_DEVBUILD
105 DebugCores[Index].admaWaveformL[OutPos % 0x100] = retval.Left;
106 DebugCores[Index].admaWaveformR[OutPos % 0x100] = retval.Right;
107#endif
108
109 // Simulate MADR increase, GTA VC tracks the MADR address for calculating a certain point in the buffer
110 if (InputDataTransferred)
111 {
112 u32 amount = std::min(InputDataTransferred, (u32)0x180);
113
114 InputDataTransferred -= amount;
115 MADR += amount;
116 // Because some games watch the MADR to see when it reaches the end we need to end the DMA here
117 // Tom & Jerry War of the Whiskers is one such game, the music will skip
118 if (!InputDataTransferred && !InputDataLeft)
119 {
120 if (Index == 0)
121 spu2DMA4Irq();
122 else
123 spu2DMA7Irq();
124 }
125 }
126
127 if (PlayMode == 2 && Index == 0) //Bitstream bypass refills twice as quickly (GTA VC)
128 ReadIndex = (ReadIndex * 2) & 0x1FF;
129
130 if (ReadIndex == 0x100 || ReadIndex == 0x0 || ReadIndex == 0x80 || ReadIndex == 0x180)
131 {
132 if (ReadIndex == 0x100)
133 InputPosWrite = 0;
134 else if (ReadIndex == 0)
135 InputPosWrite = 0x100;
136
137 if (InputDataLeft >= 0x100)
138 {
139 AutoDMAReadBuffer(0);
140 AdmaInProgress = 1;
141 if (InputDataLeft < 0x100)
142 {
143 if (IsDevBuild)
144 {

Callers 1

spu2MixFunction · 0.80

Calls 9

SetIrqCallFunction · 0.85
StereoOut32Class · 0.85
GetMemPtrFunction · 0.85
spu2DMA4IrqFunction · 0.85
spu2DMA7IrqFunction · 0.85
FileLogFunction · 0.85
MsgAutoDMAFunction · 0.85
ConLogFunction · 0.85
minFunction · 0.50

Tested by

no test coverage detected