From 7947bb32b007a79e0c39daf798d6ef91cc6bb6e3 Mon Sep 17 00:00:00 2001 From: Stefan Arentz Date: Tue, 22 Nov 2016 07:41:47 -0500 Subject: [PATCH] Fixes #36 - Addressing (indirect,X) does not wrap properly --- mem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mem.c b/mem.c index 4f5f47c..da5e52c 100644 --- a/mem.c +++ b/mem.c @@ -102,7 +102,7 @@ uint8_t mem_get_byte_zpgy(struct cpu_t *cpu, uint8_t addr) { } uint8_t mem_get_byte_indx(struct cpu_t *cpu, uint8_t addr) { - return mem_get_byte(cpu, mem_get_word(cpu, addr + cpu->state.x)); // TODO: Does this wrap? + return mem_get_byte(cpu, mem_get_word(cpu, (uint8_t)(addr + cpu->state.x))); } uint8_t mem_get_byte_indy(struct cpu_t *cpu, uint8_t addr) { @@ -141,7 +141,8 @@ void mem_set_byte_absy(struct cpu_t *cpu, uint16_t addr, uint8_t v) { } void mem_set_byte_indx(struct cpu_t *cpu, uint8_t addr, uint8_t v) { - mem_set_byte(cpu, mem_get_word(cpu, addr+cpu->state.x), v); // TODO: Does this wrap? + //uint8_t a = ; + mem_set_byte(cpu, mem_get_word(cpu, (uint8_t)(addr + cpu->state.x)), v); } void mem_set_byte_indy(struct cpu_t *cpu, uint8_t addr, uint8_t v) {