diff --git a/emulation.c b/emulation.c index 09d133d..6611a89 100644 --- a/emulation.c +++ b/emulation.c @@ -41,6 +41,10 @@ void emuReset(EmulationContext *emu) { vbReset(emu->sim); } +bool emuIsGameLoaded(EmulationContext *emu) { + return vbGetCartROM(emu->sim, NULL) != NULL; +} + #define MAX_STEP_CLOCKS 20000000 void emuTick(EmulationContext *emu) { uint32_t clocks = MAX_STEP_CLOCKS; diff --git a/emulation.h b/emulation.h index c931146..8721735 100644 --- a/emulation.h +++ b/emulation.h @@ -20,6 +20,7 @@ int emuInit(EmulationContext *emu); void emuDestroy(EmulationContext *emu); void emuLoadGame(EmulationContext *emu, uint8_t *rom, uint32_t romSize); void emuReset(EmulationContext *emu); +bool emuIsGameLoaded(EmulationContext *emu); void emuTick(EmulationContext *emu); bool emuReadPixels(EmulationContext *emu, uint8_t *left, uint8_t *right); diff --git a/ui.c b/ui.c index c863718..c3cb86e 100644 --- a/ui.c +++ b/ui.c @@ -106,9 +106,10 @@ typedef enum status_t { } status_t; int uiRun(UIContext *ui, bool running) { - static uint8_t leftEye[384*224]; - static uint8_t rightEye[384*224]; + static uint8_t leftEye[384*224] = {0}; + static uint8_t rightEye[384*224] = {0}; status_t status = running ? status_running : status_paused; + windowUpdate(&ui->win, leftEye, rightEye); while (1) { struct nk_context *ctx; @@ -163,7 +164,7 @@ int uiRun(UIContext *ui, bool running) { } if (nk_menu_item_label(ctx, "Reset", NK_TEXT_ALIGN_LEFT)) { emuReset(&ui->emu); - status = status_running; + status = emuIsGameLoaded(&ui->emu) ? status_running : status_paused; } nk_menu_end(ctx); }