GUI: Add Reset Game menu item
Jeffrey Pfau jeffrey@endrift.com
Wed, 16 Dec 2015 20:36:38 -0800
3 files changed,
12 insertions(+),
1 deletions(-)
M
src/gba/context/context.c
→
src/gba/context/context.c
@@ -180,8 +180,9 @@ }
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); }@@ -194,6 +195,10 @@ GBAOverrideApply(context->gba, &override);
} GBAConfigFreeOpts(&opts); return true; +} + +void GBAContextReset(struct GBAContext* context) { + ARMReset(context->cpu); } void GBAContextStop(struct GBAContext* context) {
M
src/gba/context/context.h
→
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
M
src/gba/gui/gui-runner.c
→
src/gba/gui/gui-runner.c
@@ -27,6 +27,7 @@ RUNNER_SAVE_STATE,
RUNNER_LOAD_STATE, RUNNER_SCREENSHOT, RUNNER_CONFIG, + RUNNER_RESET, RUNNER_COMMAND_MASK = 0xFFFF, RUNNER_STATE_1 = 0x10000,@@ -181,6 +182,7 @@ *GUIMenuItemListAppend(&stateLoadMenu.items) = (struct GUIMenuItem) { .title = "State 9", .data = (void*) (RUNNER_LOAD_STATE | RUNNER_STATE_9) };
*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) {@@ -302,6 +304,9 @@ switch (((int) item->data) & RUNNER_COMMAND_MASK) {
case RUNNER_EXIT: 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);