all repos — mgba @ 36d726f3c5fa1b520d8e2749e849ed7d020fac49

mGBA Game Boy Advance Emulator

GUI: Add Reset Game menu item
Jeffrey Pfau jeffrey@endrift.com
Wed, 16 Dec 2015 20:36:38 -0800
commit

36d726f3c5fa1b520d8e2749e849ed7d020fac49

parent

3ce129fbb176cd24da437abf9047289365c0efef

3 files changed, 12 insertions(+), 1 deletions(-)

jump to
M src/gba/context/context.csrc/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.hsrc/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.csrc/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);