diff --git a/src/gba/context/context.c b/src/gba/context/context.c index ffbe38f02..6e0653ff3 100644 --- a/src/gba/context/context.c +++ b/src/gba/context/context.c @@ -180,8 +180,9 @@ bool GBAContextStart(struct GBAContext* context) { context->gba->logLevel = opts.logLevel; context->gba->idleOptimization = opts.idleOptimization; - ARMReset(context->cpu); + GBAContextReset(context); + // TODO: Move this into GBAContextReset if (opts.skipBios) { GBASkipBIOS(context->gba); } @@ -196,6 +197,10 @@ bool GBAContextStart(struct GBAContext* context) { return true; } +void GBAContextReset(struct GBAContext* context) { + ARMReset(context->cpu); +} + void GBAContextStop(struct GBAContext* context) { UNUSED(context); // TODO? diff --git a/src/gba/context/context.h b/src/gba/context/context.h index 0269e90af..3f3268f70 100644 --- a/src/gba/context/context.h +++ b/src/gba/context/context.h @@ -37,6 +37,7 @@ void GBAContextUnloadROM(struct GBAContext* context); bool GBAContextStart(struct GBAContext* context); void GBAContextStop(struct GBAContext* context); +void GBAContextReset(struct GBAContext* context); void GBAContextFrame(struct GBAContext* context, uint16_t keys); #endif diff --git a/src/gba/gui/gui-runner.c b/src/gba/gui/gui-runner.c index 98dcbd31d..ce7c651d7 100644 --- a/src/gba/gui/gui-runner.c +++ b/src/gba/gui/gui-runner.c @@ -27,6 +27,7 @@ enum { RUNNER_LOAD_STATE, RUNNER_SCREENSHOT, RUNNER_CONFIG, + RUNNER_RESET, RUNNER_COMMAND_MASK = 0xFFFF, RUNNER_STATE_1 = 0x10000, @@ -181,6 +182,7 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) { *GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Take screenshot", .data = (void*) RUNNER_SCREENSHOT }; *GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Configure", .data = (void*) RUNNER_CONFIG }; + *GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Reset game", .data = (void*) RUNNER_RESET }; *GUIMenuItemListAppend(&pauseMenu.items) = (struct GUIMenuItem) { .title = "Exit game", .data = (void*) RUNNER_EXIT }; while (true) { @@ -303,6 +305,9 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) { running = false; keys = 0; break; + case RUNNER_RESET: + GBAContextReset(&runner->context); + break; case RUNNER_SAVE_STATE: vf = GBAGetState(runner->context.gba, 0, ((int) item->data) >> 16, true); if (vf) {