From 4165c1cefc7d440752cc0454d89ed2e4b7c09ff4 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sat, 27 Jan 2018 13:04:19 -0600 Subject: [PATCH] Make idx, idy clearer I'm still not confident this is how it _should_ work, but I have found conflicting accounts online for the behavior of these two modes. The current code is what allows the Apple II to bootstrap as it should. --- src/mos6502.addr.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/mos6502.addr.c b/src/mos6502.addr.c index 01d61c7..c007725 100644 --- a/src/mos6502.addr.c +++ b/src/mos6502.addr.c @@ -168,12 +168,14 @@ DEFINE_ADDR(ind) */ DEFINE_ADDR(idx) { - ADDR_LO(cpu); - EFF_ADDR(addr + cpu->X); + vm_8bit addr; - return mos6502_get( - cpu, - mos6502_get(cpu, eff_addr)); + addr = mos6502_get(cpu, cpu->PC + 1); + addr = mos6502_get(cpu, addr + cpu->X); + + EFF_ADDR(addr); + + return mos6502_get(cpu, eff_addr); } /* @@ -184,8 +186,12 @@ DEFINE_ADDR(idx) */ DEFINE_ADDR(idy) { - ADDR_LO(cpu); - EFF_ADDR(mos6502_get(cpu, addr) + cpu->Y); + vm_8bit addr; + + addr = mos6502_get(cpu, cpu->PC + 1); + addr = mos6502_get(cpu, addr); + + EFF_ADDR(addr + cpu->Y); return mos6502_get(cpu, eff_addr); }