From d5d813efd7305cbf53d6ab008eafcaf59e41ad79 Mon Sep 17 00:00:00 2001 From: LRFLEW Date: Sun, 23 Oct 2022 10:31:33 -0500 Subject: [PATCH] CPU: Clear waiting with disabled interrupt (#434) --- src/cpu/65c02.h | 2 +- src/cpu/fake6502.c | 14 ++++++++------ src/main.c | 6 ++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cpu/65c02.h b/src/cpu/65c02.h index 15e9d6f4..a636d77d 100644 --- a/src/cpu/65c02.h +++ b/src/cpu/65c02.h @@ -131,7 +131,7 @@ static void stp() { // ******************************************************************************************* static void wai() { - if (~status & FLAG_INTERRUPT) waiting = 1; + waiting = 1; } // ******************************************************************************************* diff --git a/src/cpu/fake6502.c b/src/cpu/fake6502.c index 794aa3bc..47a96748 100644 --- a/src/cpu/fake6502.c +++ b/src/cpu/fake6502.c @@ -174,15 +174,17 @@ void nmi6502() { push8(status); status |= FLAG_INTERRUPT; pc = (uint16_t)read6502(0xFFFA) | ((uint16_t)read6502(0xFFFB) << 8); - waiting = 0; + waiting = 0; } void irq6502() { - push16(pc); - push8(status & ~FLAG_BREAK); - status |= FLAG_INTERRUPT; - pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8); - waiting = 0; + if (!(status & FLAG_INTERRUPT)) { + push16(pc); + push8(status & ~FLAG_BREAK); + status |= FLAG_INTERRUPT; + pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8); + } + waiting = 0; } uint8_t callexternal = 0; diff --git a/src/main.c b/src/main.c index 3e2d1f9f..6b0fbb8f 100644 --- a/src/main.c +++ b/src/main.c @@ -1295,10 +1295,8 @@ emulator_loop(void *param) } if (video_get_irq_out() || via2_irq()) { - if (!(status & 4)) { -// printf("IRQ!\n"); - irq6502(); - } +// printf("IRQ!\n"); + irq6502(); } if (pc == 0xffff) {