detect whether we are running the game

This commit is contained in:
Arisotura 2020-02-24 18:31:44 +01:00
parent 8b1caae852
commit 5f99a68151
4 changed files with 31 additions and 9 deletions

View File

@ -231,6 +231,8 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)
PrefetchAbort();
return;
}*/
NDS::MonitorARM9Jump(addr);
}
void ARMv4::JumpTo(u32 addr, bool restorecpsr)

View File

@ -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];

View File

@ -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);

View File

@ -22,8 +22,8 @@
#include <stdio.h>
#include "types.h"
#define SAVESTATE_MAJOR 4
#define SAVESTATE_MINOR 1
#define SAVESTATE_MAJOR 5
#define SAVESTATE_MINOR 0
class Savestate
{