From 15287322f1b072c33e819a23d1b02d17aecf943b Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Mon, 18 Dec 2017 12:01:18 -0800 Subject: [PATCH] Handle zero page wraparound in ($xx),Y * fixes line #3065: D95B C9 12 CMP --- 6502.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/6502.c b/6502.c index 2603795..254c021 100644 --- a/6502.c +++ b/6502.c @@ -541,7 +541,13 @@ uint8_t * get_XIND() uint8_t * get_INDY() { uint16_t ptr; - memcpy(&ptr, get_ZP(), sizeof(ptr)); + ptr = * get_IMM(); + if (ptr == 0xff) { // check for wraparound in zero page + ptr = memory[ptr] + (memory[ptr & 0xff00] << 8); + } + else { + memcpy(&ptr, &memory[ptr], sizeof(ptr)); + } ptr += Y; return &memory[ptr]; }