From 4525490beb4d4aa3c4359060db177c06ff09b3a1 Mon Sep 17 00:00:00 2001 From: vin Date: Sun, 30 Jun 2024 15:14:38 -0400 Subject: [PATCH] fix indirect JMP bug where the high byte does not increment out of page https://old.reddit.com/r/EmuDev/comments/15plfes/having_an_issue_with_nestest_on_my_6502_emulator/jvyck7k/ With this, it seems that all official opcodes run as nestest expects. Now, it's the unofficial opcodes that need to be implemented. --- cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpu.c b/cpu.c index 51ab824..a2fea28 100644 --- a/cpu.c +++ b/cpu.c @@ -196,7 +196,7 @@ opcode_mem(enum addressing_mode mode) val = arg + regs.y; break; case AM_IND: - val = peek16(arg); + val = peek(arg) | (peek(((arg + 1) & 0xFF) | (arg & 0xFF00)) << 8); break; case AM_IND_X: val = peek((arg + regs.x) % 256) + peek((arg + regs.x + 1) % 256) * 256; @@ -1308,9 +1308,10 @@ interpret(void) case 0x6c: mode = AM_IND; mem = peek16(regs.pc); - deref = peek(mem); + deref = peek16(mem); arg = opcode_mem(mode); - jmp(deref); + deref = arg; + jmp(arg); cycles += 6; printf("JMP"); break;