Skip to content

Commit

Permalink
FDS: Update IRQ based on latest hardware notes
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
negativeExponent committed Jun 5, 2022
1 parent dd35f4b commit 78af608
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/fds.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand Down

0 comments on commit 78af608

Please sign in to comment.