From 94aea533a945822a68a1639ae7a42d9ade6e1dd9 Mon Sep 17 00:00:00 2001 From: jborza Date: Tue, 7 May 2019 20:24:16 +0200 Subject: [PATCH] wraparound handling if crossing a page boundary at reading a word --- memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/memory.c b/memory.c index bfbc349..8b69d8f 100644 --- a/memory.c +++ b/memory.c @@ -12,7 +12,13 @@ word fetch_word(State6502* state) { } word read_word(State6502* state, word address) { - return state->memory[address] | state->memory[address + 1] << 8; + if ((address & 0xFF) == 0xFF) + { + return state->memory[address] | state->memory[address - 0xFF] << 8; + } + else { + return state->memory[address] | state->memory[address + 1] << 8; + } } word get_address_zero_page(State6502* state) {