diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-10-18 04:00:16 +0200 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-10-18 04:00:16 +0200 |
commit | b5c39680a5c6dc8b55ed964f4ae97ab4c8df42ea (patch) | |
tree | b40fe36c2425bf4c641506defbd3a0ffc9a1e069 | |
parent | 20862b7daf137c91552ebb40dad27846e596b1d7 (diff) |
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)
-rw-r--r-- | src/DMA.cpp | 2 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 86 |
2 files changed, 47 insertions, 41 deletions
diff --git a/src/DMA.cpp b/src/DMA.cpp index ba8cc41..f0c22b5 100644 --- a/src/DMA.cpp +++ b/src/DMA.cpp @@ -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); diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 873d95a..2870cd1 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -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")) |