Skip to content

Commit

Permalink
[NES] Check for overrides before loading ROM.
Browse files Browse the repository at this point in the history
  • Loading branch information
OtherCrashOverride committed Sep 16, 2018
1 parent bfa5cee commit 8eafdce
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 59 deletions.
58 changes: 0 additions & 58 deletions nesemu-go/components/nofrendo-esp32/video_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#define DEFAULT_WIDTH 256
#define DEFAULT_HEIGHT NES_VISIBLE_HEIGHT


odroid_volume_level Volume;
odroid_battery_state battery;
int scaling_enabled = 1;
Expand Down Expand Up @@ -531,63 +530,6 @@ int osd_init()
}


// Joystick.
odroid_input_gamepad_init();
odroid_input_battery_level_init();

//printf("osd_init: ili9341_prepare\n");
ili9341_prepare();

switch (esp_sleep_get_wakeup_cause())
{
case ESP_SLEEP_WAKEUP_EXT0:
{
printf("app_main: ESP_SLEEP_WAKEUP_EXT0 deep sleep reset\n");
break;
}

case ESP_SLEEP_WAKEUP_EXT1:
case ESP_SLEEP_WAKEUP_TIMER:
case ESP_SLEEP_WAKEUP_TOUCHPAD:
case ESP_SLEEP_WAKEUP_ULP:
case ESP_SLEEP_WAKEUP_UNDEFINED:
{
printf("app_main: Unexpected deep sleep reset\n");
odroid_gamepad_state bootState = odroid_input_read_raw();

if (bootState.values[ODROID_INPUT_MENU])
{
// Force return to factory app to recover from
// ROM loading crashes

// Set menu application
odroid_system_application_set(0);

// Reset
esp_restart();
}

if (bootState.values[ODROID_INPUT_START])
{
// Reset emulator if button held at startup to
// override save state
forceConsoleReset = true; //emu_reset();
}
}
break;

default:
printf("app_main: Not a deep sleep reset\n");
break;
}

if (odroid_settings_StartAction_get() == ODROID_START_ACTION_RESTART)
{
forceConsoleReset = true;
odroid_settings_StartAction_set(ODROID_START_ACTION_NORMAL);
}


Volume = odroid_settings_Volume_get();

scaling_enabled = odroid_settings_ScaleDisabled_get(ODROID_SCALE_DISABLE_NES) ? false : true;
Expand Down
61 changes: 60 additions & 1 deletion nesemu-go/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
#include "../components/odroid/odroid_system.h"
#include "../components/odroid/odroid_sdcard.h"
#include "../components/odroid/odroid_display.h"
#include "../components/odroid/odroid_input.h"

const char* SD_BASE_PATH = "/sd";
static char* ROM_DATA = (char*)0x3f800000;

extern bool forceConsoleReset;

static char* ROM_DATA = (char*)0x3f800000;;

char *osd_getromdata()
{
Expand Down Expand Up @@ -72,6 +75,62 @@ int app_main(void)

ili9341_init();

// Joystick.
odroid_input_gamepad_init();
odroid_input_battery_level_init();

//printf("osd_init: ili9341_prepare\n");
ili9341_prepare();

switch (esp_sleep_get_wakeup_cause())
{
case ESP_SLEEP_WAKEUP_EXT0:
{
printf("app_main: ESP_SLEEP_WAKEUP_EXT0 deep sleep reset\n");
break;
}

case ESP_SLEEP_WAKEUP_EXT1:
case ESP_SLEEP_WAKEUP_TIMER:
case ESP_SLEEP_WAKEUP_TOUCHPAD:
case ESP_SLEEP_WAKEUP_ULP:
case ESP_SLEEP_WAKEUP_UNDEFINED:
{
printf("app_main: Unexpected deep sleep reset\n");
odroid_gamepad_state bootState = odroid_input_read_raw();

if (bootState.values[ODROID_INPUT_MENU])
{
// Force return to menu to recover from
// ROM loading crashes

// Set menu application
odroid_system_application_set(0);

// Reset
esp_restart();
}

if (bootState.values[ODROID_INPUT_START])
{
// Reset emulator if button held at startup to
// override save state
forceConsoleReset = true; //emu_reset();
}
}
break;

default:
printf("app_main: Not a deep sleep reset\n");
break;
}

if (odroid_settings_StartAction_get() == ODROID_START_ACTION_RESTART)
{
forceConsoleReset = true;
odroid_settings_StartAction_set(ODROID_START_ACTION_NORMAL);
}


// Load ROM
char* romPath = odroid_settings_RomFilePath_get();
Expand Down

0 comments on commit 8eafdce

Please sign in to comment.