FDS: Update IRQ based on latest hardware notes

- IRQ updates based on latest notes. Verified with test rom.

https://www.nesdev.org/wiki/Family_Computer_Disk_System#IRQ_control_($4022)

Discussion and test rom file:
https://forums.nesdev.org/viewtopic.php?f=3&t=16507
test rom: https://forums.nesdev.org/viewtopic.php?p=205052#p205052

- Puff Puff Golf is still problematic and unplayable. added notes for
  it.

- Fix typo for a previous commit.
This commit is contained in:
negative 2022-06-05 18:57:15 +08:00 committed by zeromus
parent dd35f4b12a
commit 2c85cc53c5
1 changed files with 27 additions and 9 deletions

View File

@ -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);
if (FDSRegs[3] & 1) {
IRQa = V & 0x03;
if (IRQa & IRQ_Enabled) {
IRQCount = IRQLatch;
IRQa = V & 3;
} 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) {