APU: Move duty cycle swapping during apu writes

This commit is contained in:
negativeExponent
2020-10-25 13:58:06 +08:00
parent 6eccb4401f
commit 2ae14b75de

View File

@@ -195,6 +195,8 @@ static DECLFW(Write_PSG) {
DoSQ1();
EnvUnits[0].Mode = (V & 0x30) >> 4;
EnvUnits[0].Speed = (V & 0xF);
if (swapDuty)
V = (V & 0x3F) | ((V & 0x80) >> 1) | ((V & 0x40) << 1);
break;
case 0x1:
DoSQ1();
@@ -214,6 +216,8 @@ static DECLFW(Write_PSG) {
DoSQ2();
EnvUnits[1].Mode = (V & 0x30) >> 4;
EnvUnits[1].Speed = (V & 0xF);
if (swapDuty)
V = (V & 0x3F) | ((V & 0x80) >> 1) | ((V & 0x40) << 1);
break;
case 0x5:
DoSQ2();
@@ -561,8 +565,6 @@ static INLINE void RDoSQ(int x) {
amp <<= 24;
dutyCycle = (PSG[(x << 2)] & 0xC0) >> 6;
if (swapDuty)
dutyCycle = ((dutyCycle & 2) >> 1) | ((dutyCycle & 1) << 1);
rthresh = RectDuties[dutyCycle];
currdc = RectDutyCount[x];
D = &WaveHi[ChannelBC[x]];
@@ -640,8 +642,6 @@ static void RDoSQLQ(void) {
if (!inie[x]) amp[x] = 0; /* Correct? Buzzing in MM2, others otherwise... */
dutyCycle = (PSG[(x << 2)] & 0xC0) >> 6;
if (swapDuty)
dutyCycle = ((dutyCycle & 2) >> 1) | ((dutyCycle & 1) << 1);
rthresh[x] = RectDuties[dutyCycle];
for (y = 0; y < 8; y++) {