hax, finally making savestates usable
F1 to save, F2 to load. filename hardcoded for now. shits itself: * when the 3D engine is used * when a debugger is used (heh)
This commit is contained in:
parent
20862b7daf
commit
b5c39680a5
|
@ -120,7 +120,7 @@ void DMA::Reset()
|
|||
|
||||
void DMA::DoSavestate(Savestate* file)
|
||||
{
|
||||
char* magic = "DMAx";
|
||||
char magic[5] = "DMAx";
|
||||
magic[3] = '0' + Num + (CPU*4);
|
||||
file->Section(magic);
|
||||
|
||||
|
|
|
@ -141,6 +141,9 @@ void AudioCallback(void* data, Uint8* stream, int len)
|
|||
}
|
||||
}
|
||||
|
||||
// hax.
|
||||
int savestate_cmd;
|
||||
|
||||
int EmuThreadFunc(void* burp)
|
||||
{
|
||||
NDS::Init();
|
||||
|
@ -153,6 +156,8 @@ int EmuThreadFunc(void* burp)
|
|||
ScreenDrawInited = false;
|
||||
Touching = false;
|
||||
|
||||
savestate_cmd = 0;
|
||||
|
||||
SDL_AudioSpec whatIwant, whatIget;
|
||||
memset(&whatIwant, 0, sizeof(SDL_AudioSpec));
|
||||
whatIwant.freq = 47340;
|
||||
|
@ -192,6 +197,31 @@ int EmuThreadFunc(void* burp)
|
|||
{
|
||||
EmuStatus = 1;
|
||||
|
||||
// HAX!!
|
||||
if (savestate_cmd)
|
||||
{
|
||||
if (savestate_cmd == 1)
|
||||
{
|
||||
Savestate* test = new Savestate("SAVEZORZ.bin", true);
|
||||
if (NDS::DoSavestate(test))
|
||||
printf("savestate saved OK\n");
|
||||
else
|
||||
printf("saving failed\n");
|
||||
delete test;
|
||||
}
|
||||
else if (savestate_cmd == 2)
|
||||
{
|
||||
Savestate* test = new Savestate("SAVEZORZ.bin", false);
|
||||
if (NDS::DoSavestate(test))
|
||||
printf("savestate loaded OK\n");
|
||||
else
|
||||
printf("loading failed\n");
|
||||
delete test;
|
||||
}
|
||||
|
||||
savestate_cmd = 0;
|
||||
}
|
||||
|
||||
// poll input
|
||||
u32 keymask = KeyInputMask;
|
||||
u32 joymask = 0xFFF;
|
||||
|
@ -448,6 +478,22 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
|||
}
|
||||
else if (!evt->Repeat)
|
||||
{
|
||||
// HAX
|
||||
if (evt->Scancode == 0x3B) // F1
|
||||
{
|
||||
// save state.
|
||||
savestate_cmd = 1;
|
||||
printf("saving state\n");
|
||||
return 1;
|
||||
}
|
||||
if (evt->Scancode == 0x3C) // F2
|
||||
{
|
||||
// load state.
|
||||
savestate_cmd = 2;
|
||||
printf("loading state\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
if (evt->Scancode == Config::KeyMapping[i])
|
||||
KeyInputMask &= ~(1<<i);
|
||||
|
@ -1048,46 +1094,6 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// TESTORZ
|
||||
|
||||
u32 zab = 12;
|
||||
u16 zib = 18;
|
||||
u8 zob = 9;
|
||||
u32 zub = 42;
|
||||
|
||||
Savestate* dorp = new Savestate("dorp.zog", true);
|
||||
dorp->Section("BAKA");
|
||||
dorp->Var32(&zab);
|
||||
dorp->Var8(&zob);
|
||||
dorp->Section("SHIT");
|
||||
dorp->Var16(&zib);
|
||||
dorp->Var32(&zub);
|
||||
delete dorp;
|
||||
|
||||
zab = 0; zib = 0; zob = 0; zub = 0;
|
||||
dorp = new Savestate("dorp.zog", false);
|
||||
dorp->Section("BAKA");
|
||||
dorp->Var32(&zab);
|
||||
dorp->Var8(&zob);
|
||||
dorp->Section("SHIT");
|
||||
dorp->Var16(&zib);
|
||||
dorp->Var32(&zub);
|
||||
delete dorp;
|
||||
printf("-> %d %d %d %d\n", zab, zib, zob, zub);
|
||||
|
||||
zab = 0; zib = 0; zob = 0; zub = 0;
|
||||
dorp = new Savestate("dorp.zog", false);
|
||||
dorp->Section("SHIT");
|
||||
dorp->Var16(&zib);
|
||||
dorp->Var32(&zub);
|
||||
dorp->Section("BAKA");
|
||||
dorp->Var32(&zab);
|
||||
dorp->Var8(&zob);
|
||||
delete dorp;
|
||||
printf("-> %d %d %d %d\n", zab, zib, zob, zub);
|
||||
|
||||
// TESTORZ END
|
||||
|
||||
Config::Load();
|
||||
|
||||
if (!Config::HasConfigFile("bios7.bin") || !Config::HasConfigFile("bios9.bin") || !Config::HasConfigFile("firmware.bin"))
|
||||
|
|
Loading…
Reference in New Issue