From e797d009d0da181ba0587927a9da96ef8cf4eef9 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 17 May 2015 15:37:55 -0700 Subject: [PATCH] GBA Memory: Fix ROMs incorrectly being resized --- src/gba/memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gba/memory.c b/src/gba/memory.c index 96115616a..599a94cb6 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -854,7 +854,7 @@ void GBAPatch32(struct ARMCore* cpu, uint32_t address, int32_t value, int32_t* o case REGION_CART2: case REGION_CART2_EX: _pristineCow(gba); - if ((address & (SIZE_CART0 - 1)) < gba->memory.romSize) { + if ((address & (SIZE_CART0 - 1)) >= gba->memory.romSize) { gba->memory.romSize = (address & (SIZE_CART0 - 4)) + 4; } LOAD_32(oldValue, address & (SIZE_CART0 - 1), gba->memory.rom); @@ -921,7 +921,7 @@ void GBAPatch16(struct ARMCore* cpu, uint32_t address, int16_t value, int16_t* o case REGION_CART2: case REGION_CART2_EX: _pristineCow(gba); - if ((address & (SIZE_CART0 - 1)) < gba->memory.romSize) { + if ((address & (SIZE_CART0 - 1)) >= gba->memory.romSize) { gba->memory.romSize = (address & (SIZE_CART0 - 2)) + 2; } LOAD_16(oldValue, address & (SIZE_CART0 - 1), gba->memory.rom); @@ -978,7 +978,7 @@ void GBAPatch8(struct ARMCore* cpu, uint32_t address, int8_t value, int8_t* old) case REGION_CART2: case REGION_CART2_EX: _pristineCow(gba); - if ((address & (SIZE_CART0 - 1)) < gba->memory.romSize) { + if ((address & (SIZE_CART0 - 1)) >= gba->memory.romSize) { gba->memory.romSize = (address & (SIZE_CART0 - 2)) + 2; } oldValue = ((int8_t*) memory->rom)[address & (SIZE_CART0 - 1)];