From af1c040eb5e0a89ab37480a7c3e7195dd3b20bc2 Mon Sep 17 00:00:00 2001 From: normmatt234 Date: Thu, 7 Jul 2011 04:19:26 +0000 Subject: [PATCH] Fix read below 8000h to support wrapping. --- desmume/src/addons/slot1_retail.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/desmume/src/addons/slot1_retail.cpp b/desmume/src/addons/slot1_retail.cpp index d68239d09..339f7d2d7 100644 --- a/desmume/src/addons/slot1_retail.cpp +++ b/desmume/src/addons/slot1_retail.cpp @@ -108,8 +108,13 @@ static u32 read32_GCDATAIN(u8 PROCNUM) case 0x00: case 0xB7: { + //it seems that etrian odyssey 3 doesnt work unless we mask this to cart size. + //but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision + //but there is no test case yet + u32 address = card.address & (gameInfo.mask); + // Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart - if((card.command[0] == 0xB7) && (card.address < 0x8000)) + if((card.command[0] == 0xB7) && (address < 0x8000)) { //TODO - refactor this to include the PROCNUM, for debugging purposes if nothing else //(can refactor gbaslot also) @@ -117,14 +122,9 @@ static u32 read32_GCDATAIN(u8 PROCNUM) //INFO("Read below 0x8000 (0x%04X) from: ARM%s %08X\n", // card.address, (PROCNUM ? "7":"9"), (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr); - card.address = (0x8000 + (card.address&0x1FF)); + address = (0x8000 + (card.address&0x1FF)); } - //it seems that etrian odyssey 3 doesnt work unless we mask this to cart size. - //but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision - //but there is no test case yet - u32 address = card.address & (gameInfo.mask); - //as a sanity measure for funny-sized roms (homebrew and perhaps truncated retail roms) //we need to protect ourselves by returning 0xFF for things still out of range if(address >= gameInfo.romsize)