diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 2e0f84129..2dff96241 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -174,6 +174,7 @@ void mmu_log_debug_ARM7(u32 adr, const char *fmt, ...) #define DUP16(x) x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x MMU_struct MMU; +MMU_struct_new MMU_new; u8 * MMU_struct::MMU_MEM[2][256] = { //arm9 @@ -1793,7 +1794,7 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) if (val == 0) //mc_reset_com(&MMU.bupmem); // reset backup memory device communication - MMU.backupDevice.reset_command(); + MMU_new.backupDevice.reset_command(); return; case REG_AUXSPIDATA: @@ -1801,7 +1802,7 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) AUX_SPI_CMD = val & 0xFF; //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU.backupDevice.data_command(val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command(val)); return; case REG_DISPA_BG0CNT : @@ -3086,7 +3087,7 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) if (val == 0) //mc_reset_com(&MMU.bupmem); // reset backup memory device communication - MMU.backupDevice.reset_command(); + MMU_new.backupDevice.reset_command(); return; case REG_AUXSPIDATA: @@ -3094,7 +3095,7 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) AUX_SPI_CMD = val & 0xFF; //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU.backupDevice.data_command(val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command(val)); return; case REG_SPICNT : diff --git a/desmume/src/MMU.h b/desmume/src/MMU.h index 98db5c2d1..a147ea934 100644 --- a/desmume/src/MMU.h +++ b/desmume/src/MMU.h @@ -118,7 +118,6 @@ struct MMU_struct { memory_chip_t fw; memory_chip_t bupmem; - BackupDevice backupDevice; nds_dscard dscard[2]; u32 CheckTimers; @@ -126,7 +125,13 @@ struct MMU_struct { }; +struct MMU_struct_new +{ + BackupDevice backupDevice; +}; + extern MMU_struct MMU; +extern MMU_struct_new MMU_new; struct armcpu_memory_iface { diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index e063f4bee..0ff38f34e 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -834,7 +834,7 @@ int NDS_LoadROM( const char *filename, int bmtype, u32 bmsize, //mc_realloc(&MMU.bupmem, bmtype, bmsize); //mc_load_file(&MMU.bupmem, buf); - MMU.backupDevice.load_rom(buf); + MMU_new.backupDevice.load_rom(buf); memset(buf, 0, MAX_PATH); strcpy(buf, pathFilenameToROMwithoutExt); @@ -904,7 +904,7 @@ void NDS_Reset(BOOL resetBySavestate) currFrameCounter=0; MMU_clearMem(); - MMU.backupDevice.reset(); + MMU_new.backupDevice.reset(); //ARM7 BIOS IRQ HANDLER if(CommonSettings.UseExtBIOS == true) diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 05fe8540a..af6ea2fcf 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -258,7 +258,7 @@ static void mmu_savestate(std::ostream* os) write32le(2,os); //newer savefile system: - MMU.backupDevice.save_state(os); + MMU_new.backupDevice.save_state(os); } static bool mmu_loadstate(std::istream* is, int size) @@ -297,14 +297,14 @@ static bool mmu_loadstate(std::istream* is, int size) u8* temp = new u8[bupmem_size]; is->read((char*)temp,bupmem_size); - MMU.backupDevice.load_old_state(addr_size,temp,bupmem_size); + MMU_new.backupDevice.load_old_state(addr_size,temp,bupmem_size); delete[] temp; if(is->fail()) return false; } else if(version == 2) { //newer savefile system: - MMU.backupDevice.load_state(is); + MMU_new.backupDevice.load_state(is); } return true;