From 3bd6da8e8357ba5cdd994e285164461bf4541cf2 Mon Sep 17 00:00:00 2001 From: negativeExponent <54053706+negativeExponent@users.noreply.github.com> Date: Sun, 6 Mar 2022 09:39:17 -0800 Subject: [PATCH] FDS: Improve IRQ emulation (#469) Fix https://github.com/TASEmulators/fceux/issues/468 Co-authored-by: negative --- src/fds.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fds.cpp b/src/fds.cpp index 3fc4ee92..35924a4a 100644 --- a/src/fds.cpp +++ b/src/fds.cpp @@ -223,16 +223,18 @@ 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) + static void FDSFix(int a) { - if ((IRQa & 2) && IRQCount) { + if ((IRQa & IRQ_Enabled) && IRQCount) { IRQCount -= a; if (IRQCount <= 0) { - if (!(IRQa & 1)) { - IRQa &= ~2; - IRQCount = IRQLatch = 0; - } else - IRQCount = IRQLatch; + IRQCount = IRQLatch; X6502_IRQBegin(FCEU_IQEXT); + if (!(IRQa & IRQ_Repeat)) { + IRQa &= ~IRQ_Enabled; + } } } if (DiskSeekIRQ > 0) {