diff --git a/src/fds.cpp b/src/fds.cpp index 35924a4a..f608436f 100644 --- a/src/fds.cpp +++ b/src/fds.cpp @@ -223,14 +223,23 @@ void FCEU_FDSSelect(void) FCEU_DispMessage("Disk %d Side %c Selected", 0, SelectDisk >> 1, (SelectDisk & 1) ? 'B' : 'A'); } -#define IRQ_Repeat (IRQa & 0x01) -#define IRQ_Enabled (IRQa & 0x02) +#define IRQ_Repeat 0x01 +#define IRQ_Enabled 0x02 static void FDSFix(int a) { - if ((IRQa & IRQ_Enabled) && IRQCount) { + if (IRQa & IRQ_Enabled) { IRQCount -= a; if (IRQCount <= 0) { IRQCount = IRQLatch; + /* Puff Puff Golf notes: + Game freezes while music playing ingame after inserting Disk Side B. + IRQ is usually fired at scanline 169 and 183 for music to work. + + At some point after inserting disk B, an IRQ is fired at scanline 174 which + will just freeze game while music plays. + + If you ignore triggering IRQ altogether, game plays but no music + */ X6502_IRQBegin(FCEU_IQEXT); if (!(IRQa & IRQ_Repeat)) { IRQa &= ~IRQ_Enabled; @@ -574,21 +583,30 @@ void FDSSoundReset(void) { static DECLFW(FDSWrite) { switch (A) { case 0x4020: - X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xFF00; IRQLatch |= V; break; case 0x4021: - X6502_IRQEnd(FCEU_IQEXT); IRQLatch &= 0xFF; IRQLatch |= V << 8; break; case 0x4022: - X6502_IRQEnd(FCEU_IQEXT); - IRQCount = IRQLatch; - IRQa = V & 3; + if (FDSRegs[3] & 1) { + IRQa = V & 0x03; + if (IRQa & IRQ_Enabled) { + IRQCount = IRQLatch; + } else { + X6502_IRQEnd(FCEU_IQEXT); + } + } + break; + case 0x4023: + if (!(V & 0x01)) { + IRQa &= ~IRQ_Enabled; + X6502_IRQEnd(FCEU_IQEXT); + X6502_IRQEnd(FCEU_IQEXT2); + } break; - case 0x4023: break; case 0x4024: if (mapperFDS_diskinsert && ~mapperFDS_control & 0x04) {