diff --git a/src/ARM.cpp b/src/ARM.cpp index 2faffcd6..6248de2c 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -231,6 +231,8 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr) PrefetchAbort(); return; }*/ + + NDS::MonitorARM9Jump(addr); } void ARMv4::JumpTo(u32 addr, bool restorecpsr) diff --git a/src/NDS.cpp b/src/NDS.cpp index 713e8ac4..09d255d3 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -101,6 +101,7 @@ u8 ARM7WRAM[0x10000]; u16 ExMemCnt[2]; +// TODO: these belong in NDSCart! u8 ROMSeed0[2*8]; u8 ROMSeed1[2*8]; @@ -145,6 +146,8 @@ u16 RCnt; bool Running; +bool RunningGame; + void DivDone(u32 param); void SqrtDone(u32 param); @@ -393,6 +396,7 @@ void Reset() FILE* f; u32 i; + RunningGame = false; LastSysClockCycles = 0; f = Platform::OpenLocalFile("bios9.bin", "rb"); @@ -676,21 +680,16 @@ bool DoSavestate(Savestate* file) file->Var16(&KeyCnt); file->Var16(&RCnt); - - for (int i = 0; i < 8; i++) - DMAs[i]->DoSavestate(file); - file->Var8(&WRAMCnt); + file->Var32((u32*)&RunningGame); + if (!file->Saving) { // 'dept of redundancy dept' // but we do need to update the mappings MapSharedWRAM(WRAMCnt); - } - if (!file->Saving) - { InitTimings(); SetGBASlotTimings(); @@ -699,6 +698,9 @@ bool DoSavestate(Savestate* file) SetWifiWaitCnt(tmp); // force timing table update } + for (int i = 0; i < 8; i++) + DMAs[i]->DoSavestate(file); + ARM9->DoSavestate(file); ARM7->DoSavestate(file); @@ -1276,6 +1278,22 @@ void NocashPrint(u32 ncpu, u32 addr) +void MonitorARM9Jump(u32 addr) +{ + // checkme: can the entrypoint addr be THUMB? + + if ((!RunningGame) && NDSCart::CartROM) + { + if (addr == *(u32*)&NDSCart::CartROM[0x24]) + { + printf("Game is now booting\n"); + RunningGame = true; + } + } +} + + + void HandleTimerOverflow(u32 tid) { Timer* timer = &Timers[tid]; diff --git a/src/NDS.h b/src/NDS.h index 4e41520e..c7b455ee 100644 --- a/src/NDS.h +++ b/src/NDS.h @@ -174,6 +174,8 @@ u32 GetPC(u32 cpu); u64 GetSysClockCycles(int num); void NocashPrint(u32 cpu, u32 addr); +void MonitorARM9Jump(u32 addr); + bool DMAsInMode(u32 cpu, u32 mode); bool DMAsRunning(u32 cpu); void CheckDMAs(u32 cpu, u32 mode); diff --git a/src/Savestate.h b/src/Savestate.h index 60d00e75..4793b771 100644 --- a/src/Savestate.h +++ b/src/Savestate.h @@ -22,8 +22,8 @@ #include #include "types.h" -#define SAVESTATE_MAJOR 4 -#define SAVESTATE_MINOR 1 +#define SAVESTATE_MAJOR 5 +#define SAVESTATE_MINOR 0 class Savestate {