mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
fix code that would have fucking asploded
This commit is contained in:
@ -156,6 +156,11 @@ void Stop()
|
|||||||
memset(Framebuffer, 0, 256*192*2*4);
|
memset(Framebuffer, 0, 256*192*2*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoSavestate(Savestate* file)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// VRAM mapping notes
|
// VRAM mapping notes
|
||||||
//
|
//
|
||||||
|
@ -72,6 +72,9 @@ void DeInit();
|
|||||||
void Reset();
|
void Reset();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
|
void DoSavestate(Savestate* file);
|
||||||
|
|
||||||
|
|
||||||
void MapVRAM_AB(u32 bank, u8 cnt);
|
void MapVRAM_AB(u32 bank, u8 cnt);
|
||||||
void MapVRAM_CD(u32 bank, u8 cnt);
|
void MapVRAM_CD(u32 bank, u8 cnt);
|
||||||
void MapVRAM_E(u32 bank, u8 cnt);
|
void MapVRAM_E(u32 bank, u8 cnt);
|
||||||
@ -389,6 +392,9 @@ void DisplaySwap(u32 val);
|
|||||||
void StartFrame();
|
void StartFrame();
|
||||||
void FinishFrame(u32 lines);
|
void FinishFrame(u32 lines);
|
||||||
void StartScanline(u32 line);
|
void StartScanline(u32 line);
|
||||||
|
void StartHBlank(u32 line);
|
||||||
|
|
||||||
|
void DisplayFIFO(u32 x);
|
||||||
|
|
||||||
void SetDispStat(u32 cpu, u16 val);
|
void SetDispStat(u32 cpu, u16 val);
|
||||||
|
|
||||||
|
95
src/NDS.cpp
95
src/NDS.cpp
@ -112,6 +112,10 @@ u16 RCnt;
|
|||||||
bool Running;
|
bool Running;
|
||||||
|
|
||||||
|
|
||||||
|
void DivDone(u32 param);
|
||||||
|
void SqrtDone(u32 param);
|
||||||
|
|
||||||
|
|
||||||
bool Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
ARM9 = new ARM(0);
|
ARM9 = new ARM(0);
|
||||||
@ -356,7 +360,91 @@ void Stop()
|
|||||||
SPU::Stop();
|
SPU::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoSavestate(Savestate* file)
|
bool DoSavestate_Scheduler(Savestate* file)
|
||||||
|
{
|
||||||
|
// this is a bit of a hack
|
||||||
|
// but uh, your local coder realized that the scheduler list contains function pointers
|
||||||
|
// and that storing those as-is is not a very good idea
|
||||||
|
// unless you want it to crash and burn
|
||||||
|
|
||||||
|
// this is the solution your local coder came up with.
|
||||||
|
// it's gross but I think it's the best solution for this problem.
|
||||||
|
// just remember to add here if you add more event callbacks, kay?
|
||||||
|
// atleast until we come up with something more elegant.
|
||||||
|
|
||||||
|
void (*eventfuncs[])(u32) =
|
||||||
|
{
|
||||||
|
GPU::StartScanline, GPU::StartHBlank, GPU::FinishFrame,
|
||||||
|
SPU::Mix,
|
||||||
|
Wifi::USTimer,
|
||||||
|
|
||||||
|
GPU::DisplayFIFO,
|
||||||
|
NDSCart::ROMPrepareData, NDSCart::ROMEndTransfer,
|
||||||
|
NDSCart::SPITransferDone,
|
||||||
|
SPI::TransferDone,
|
||||||
|
DivDone,
|
||||||
|
SqrtDone,
|
||||||
|
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
int len = Event_MAX;
|
||||||
|
if (file->Saving)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
SchedEvent* evt = &SchedList[i];
|
||||||
|
|
||||||
|
u32 funcid = -1;
|
||||||
|
for (int j = 0; eventfuncs[j]; j++)
|
||||||
|
{
|
||||||
|
if (evt->Func == eventfuncs[j])
|
||||||
|
{
|
||||||
|
funcid = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (funcid < 0)
|
||||||
|
{
|
||||||
|
printf("savestate: VERY BAD!!!!! FUNCTION POINTER FOR EVENT %d NOT IN HACKY LIST. CANNOT SAVE. SMACK STAPLEBUTTER.\n", i);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
file->Var32(&funcid);
|
||||||
|
file->Var32((u32*)&evt->WaitCycles);
|
||||||
|
file->Var32(&evt->Param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
SchedEvent* evt = &SchedList[i];
|
||||||
|
|
||||||
|
u32 funcid;
|
||||||
|
file->Var32(&funcid);
|
||||||
|
|
||||||
|
for (int j = 0; ; j++)
|
||||||
|
{
|
||||||
|
if (!eventfuncs[j])
|
||||||
|
{
|
||||||
|
printf("savestate: VERY BAD!!!!!! EVENT FUNCTION POINTER ID %d IS OUT OF RANGE. HAX?????\n", j);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (j == funcid) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
evt->Func = eventfuncs[funcid];
|
||||||
|
|
||||||
|
file->Var32((u32*)&evt->WaitCycles);
|
||||||
|
file->Var32(&evt->Param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DoSavestate(Savestate* file)
|
||||||
{
|
{
|
||||||
file->Section("NDSG");
|
file->Section("NDSG");
|
||||||
|
|
||||||
@ -399,7 +487,8 @@ void DoSavestate(Savestate* file)
|
|||||||
|
|
||||||
file->VarArray(DMA9Fill, 4*sizeof(u32));
|
file->VarArray(DMA9Fill, 4*sizeof(u32));
|
||||||
|
|
||||||
file->VarArray(SchedList, sizeof(SchedList));
|
//file->VarArray(SchedList, sizeof(SchedList));
|
||||||
|
if (!DoSavestate_Scheduler(file)) return false;
|
||||||
file->Var32(&SchedListMask);
|
file->Var32(&SchedListMask);
|
||||||
file->Var32((u32*)&CurIterationCycles);
|
file->Var32((u32*)&CurIterationCycles);
|
||||||
file->Var32((u32*)&ARM7Offset);
|
file->Var32((u32*)&ARM7Offset);
|
||||||
@ -420,7 +509,7 @@ void DoSavestate(Savestate* file)
|
|||||||
ARM7->DoSavestate(file);
|
ARM7->DoSavestate(file);
|
||||||
CP15::DoSavestate(file);
|
CP15::DoSavestate(file);
|
||||||
|
|
||||||
// NDSCart
|
NDSCart::DoSavestate(file);
|
||||||
// GPU
|
// GPU
|
||||||
// SPU
|
// SPU
|
||||||
// SPI
|
// SPI
|
||||||
|
@ -109,7 +109,7 @@ void DeInit();
|
|||||||
void Reset();
|
void Reset();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
void DoSavestate(Savestate* file);
|
bool DoSavestate(Savestate* file);
|
||||||
|
|
||||||
bool LoadROM(const char* path, bool direct);
|
bool LoadROM(const char* path, bool direct);
|
||||||
void LoadBIOS();
|
void LoadBIOS();
|
||||||
|
@ -53,6 +53,10 @@ void WriteSPICnt(u16 val);
|
|||||||
u8 ReadSPIData();
|
u8 ReadSPIData();
|
||||||
void WriteSPIData(u8 val);
|
void WriteSPIData(u8 val);
|
||||||
|
|
||||||
|
void ROMPrepareData(u32 param);
|
||||||
|
void ROMEndTransfer(u32 param);
|
||||||
|
void SPITransferDone(u32 param);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user