diff --git a/desmume/src/addons/gbagame.cpp b/desmume/src/addons/gbagame.cpp index fe68b6ba4..f90890d42 100644 --- a/desmume/src/addons/gbagame.cpp +++ b/desmume/src/addons/gbagame.cpp @@ -23,6 +23,7 @@ #include "../addons.h" #include "../mem.h" +#include "../MMU.h" u8 *GBArom = NULL; @@ -68,16 +69,22 @@ void GBAgame_write32(u32 adr, u32 val) {} u8 GBAgame_read08(u32 adr) { //INFO("Read08 at 0x%08X value 0x%02X\n", adr, (u8)T1ReadByte(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return MMU.MMU_MEM[0][0xFF][(adr +0x1C) & MMU.MMU_MASK[0][0xFF]]; return (u8)T1ReadByte(GBArom, (adr - 0x08000000)); } u16 GBAgame_read16(u32 adr) { //INFO("Read16 at 0x%08X value 0x%04X\n", adr, (u16)T1ReadWord(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return T1ReadWord(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); return (u16)T1ReadWord(GBArom, (adr - 0x08000000)); } u32 GBAgame_read32(u32 adr) { //INFO("Read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); return (u32)T1ReadLong(GBArom, (adr - 0x08000000)); } void GBAgame_info(char *info) { strcpy(info, "GBA game in slot"); }; diff --git a/desmume/src/common.h b/desmume/src/common.h index c2b7e755c..d0f121ce5 100644 --- a/desmume/src/common.h +++ b/desmume/src/common.h @@ -51,7 +51,7 @@ extern u8 gba_header_data_0x04[156]; // About GBA game in slot (only for use together with NDS + GBA): // in real BIOS 9 at offset 0x0020 placed compressed logo // for comparing with logo in header GBA cartridge. - // so, GBA game in slot work now if using only real BIOS. + // so, GBA game in slot work now. // Later need make loading this table in BIOS memory (from gba_header_data_0x04) // // in windows ports: