From c86926a895e7f8ade8e16bb8817487d2bb6794c6 Mon Sep 17 00:00:00 2001 From: Arignir Date: Fri, 8 Mar 2024 01:59:38 +0100 Subject: [PATCH] Rename the `Unbounded Speed` option to `Fast Forward`. --- accuracy/check.py | 10 +++++----- include/app/app.h | 8 ++++---- source/app/bindings.c | 23 +++++++++++++---------- source/app/config.c | 12 ++++++------ source/app/emulator.c | 2 +- source/app/main.c | 2 +- source/app/path.c | 1 - source/app/windows/menubar.c | 26 ++++++++++++++++---------- source/app/windows/settings.c | 20 ++++++++++---------- 9 files changed, 56 insertions(+), 48 deletions(-) diff --git a/accuracy/check.py b/accuracy/check.py index 57e37d5..90b0f85 100755 --- a/accuracy/check.py +++ b/accuracy/check.py @@ -103,9 +103,9 @@ def main(): exit(1) for test in TESTS_SUITE: - if not test.skip and not (rom_directory / test.rom).exists(): - print(f"Error: ROM {test.rom} is missing from the ROM directory.") - exit(1) + if not (rom_directory / test.rom).exists(): + print(f"Skipping test \"{test.name}\" because ROM {test.rom} is missing from the ROM directory.") + test.skip = True # Ensure Hades is built with the debugger try: @@ -131,8 +131,8 @@ def main(): "emulation": {{ "skip_bios": true, "pause_on_reset": true, - "speed": 0, - "unbounded": false, + "speed": 1, + "fast_forward": true, "backup_storage": {{ "autodetect": true, "type": 0 diff --git a/include/app/app.h b/include/app/app.h index 9f7741f..c2004e0 100644 --- a/include/app/app.h +++ b/include/app/app.h @@ -82,13 +82,13 @@ enum bind_actions { BIND_GBA_START, BIND_GBA_SELECT, - BIND_EMULATOR_SPEED_MAX, BIND_EMULATOR_SPEED_X1, BIND_EMULATOR_SPEED_X2, BIND_EMULATOR_SPEED_X3, BIND_EMULATOR_SPEED_X4, BIND_EMULATOR_SPEED_X5, - BIND_EMULATOR_SPEED_MAX_HOLD, + BIND_EMULATOR_FAST_FORWARD_TOGGLE, + BIND_EMULATOR_FAST_FORWARD_HOLD, BIND_EMULATOR_SCREENSHOT, BIND_EMULATOR_QUICKSAVE, BIND_EMULATOR_QUICKLOAD, @@ -100,7 +100,7 @@ enum bind_actions { BIND_GBA_MIN = BIND_GBA_A, BIND_GBA_MAX = BIND_GBA_SELECT, - BIND_EMULATOR_MIN = BIND_EMULATOR_SPEED_MAX, + BIND_EMULATOR_MIN = BIND_EMULATOR_SPEED_X1, BIND_EMULATOR_MAX = BIND_EMULATOR_RESET, }; @@ -157,7 +157,7 @@ struct app { // Speed uint32_t speed; - bool unbounded; + bool fast_forward; // Skip BIOS bool skip_bios; diff --git a/source/app/bindings.c b/source/app/bindings.c index b747d26..8c971dd 100644 --- a/source/app/bindings.c +++ b/source/app/bindings.c @@ -11,7 +11,6 @@ #include #include #include "hades.h" -#include "gba/event.h" #include "app/app.h" void @@ -42,8 +41,8 @@ app_bindings_setup_default( app->binds.keyboard[BIND_EMULATOR_SPEED_X3] = SDL_GetKeyFromName("3"); app->binds.keyboard[BIND_EMULATOR_SPEED_X4] = SDL_GetKeyFromName("4"); app->binds.keyboard[BIND_EMULATOR_SPEED_X5] = SDL_GetKeyFromName("5"); - app->binds.keyboard[BIND_EMULATOR_SPEED_MAX] = SDL_GetKeyFromName("0"); - app->binds.keyboard[BIND_EMULATOR_SPEED_MAX_HOLD] = SDL_GetKeyFromName("Space"); + app->binds.keyboard[BIND_EMULATOR_FAST_FORWARD_TOGGLE] = SDL_GetKeyFromName("0"); + app->binds.keyboard[BIND_EMULATOR_FAST_FORWARD_HOLD] = SDL_GetKeyFromName("Space"); app->binds.keyboard[BIND_EMULATOR_SCREENSHOT] = SDL_GetKeyFromName("F2"); app->binds.keyboard[BIND_EMULATOR_QUICKSAVE] = SDL_GetKeyFromName("F5"); app->binds.keyboard[BIND_EMULATOR_QUICKLOAD] = SDL_GetKeyFromName("F8"); @@ -68,7 +67,7 @@ app_bindings_setup_default( app->binds.controller[BIND_EMULATOR_SPEED_X1] = SDL_CONTROLLER_BUTTON_LEFTSTICK; app->binds.controller[BIND_EMULATOR_SPEED_X2] = SDL_CONTROLLER_BUTTON_RIGHTSTICK; #if SDL_VERSION_ATLEAST(2, 0, 14) - app->binds.controller[BIND_EMULATOR_SPEED_MAX_HOLD] = SDL_CONTROLLER_BUTTON_TOUCHPAD; + app->binds.controller[BIND_EMULATOR_FAST_FORWARD_HOLD] = SDL_CONTROLLER_BUTTON_TOUCHPAD; #endif app->binds.controller_alt[BIND_GBA_A] = SDL_CONTROLLER_BUTTON_Y; @@ -137,9 +136,9 @@ app_bindings_handle( case BIND_GBA_R: app_emulator_key(app, KEY_R, pressed); break; case BIND_GBA_SELECT: app_emulator_key(app, KEY_SELECT, pressed); break; case BIND_GBA_START: app_emulator_key(app, KEY_START, pressed); break; - case BIND_EMULATOR_SPEED_MAX_HOLD: { - app->emulation.unbounded = pressed; - app_emulator_speed(app, app->emulation.speed * !app->emulation.unbounded); + case BIND_EMULATOR_FAST_FORWARD_HOLD: { + app->emulation.fast_forward = pressed; + app_emulator_speed(app, app->emulation.fast_forward ? 0 : app->emulation.speed); break; }; default: break; @@ -151,17 +150,21 @@ app_bindings_handle( } switch (bind) { - case BIND_EMULATOR_SPEED_MAX: case BIND_EMULATOR_SPEED_X1: case BIND_EMULATOR_SPEED_X2: case BIND_EMULATOR_SPEED_X3: case BIND_EMULATOR_SPEED_X4: case BIND_EMULATOR_SPEED_X5: { - app->emulation.unbounded = false; - app->emulation.speed = bind - BIND_EMULATOR_SPEED_MAX; + app->emulation.fast_forward = false; + app->emulation.speed = 1 + (bind - BIND_EMULATOR_SPEED_X1); app_emulator_speed(app, app->emulation.speed); break; }; + case BIND_EMULATOR_FAST_FORWARD_TOGGLE: { + app->emulation.fast_forward ^= true; + app_emulator_speed(app, app->emulation.fast_forward ? 0 : app->emulation.speed); + break; + } case BIND_EMULATOR_SCREENSHOT: app_emulator_screenshot(app); break; case BIND_EMULATOR_QUICKSAVE: app_emulator_quicksave(app, 0); break; case BIND_EMULATOR_QUICKLOAD: app_emulator_quickload(app, 0); break; diff --git a/source/app/config.c b/source/app/config.c index f0e8227..8b16640 100644 --- a/source/app/config.c +++ b/source/app/config.c @@ -66,15 +66,15 @@ app_config_load( int b; double d; - if (mjson_get_bool(data, data_len, "$.emulation.unbounded", &b)) { - app->emulation.unbounded = b; - } - if (mjson_get_number(data, data_len, "$.emulation.speed", &d)) { app->emulation.speed = (int)d; app->emulation.speed = max(0, min(app->emulation.speed, 5)); } + if (mjson_get_bool(data, data_len, "$.emulation.fast_forward", &b)) { + app->emulation.fast_forward = b; + } + if (mjson_get_bool(data, data_len, "$.emulation.backup_storage.autodetect", &b)) { app->emulation.backup_storage.autodetect = b; } @@ -251,7 +251,7 @@ app_config_save( "emulation": { "skip_bios": %B, "speed": %d, - "unbounded": %B, + "fast_forward": %B, "backup_storage": { "autodetect": %B, "type": %d @@ -288,7 +288,7 @@ app_config_save( app->file.recent_roms[4], (int)app->emulation.skip_bios, (int)app->emulation.speed, - (int)app->emulation.unbounded, + (int)app->emulation.fast_forward, (int)app->emulation.backup_storage.autodetect, (int)app->emulation.backup_storage.type, (int)app->emulation.gpio_device.autodetect, diff --git a/source/app/emulator.c b/source/app/emulator.c index 71c4e6b..ac00085 100644 --- a/source/app/emulator.c +++ b/source/app/emulator.c @@ -559,7 +559,7 @@ app_emulator_configure_and_run( app->emulation.game_path = strdup(rom_path); app->emulation.launch_config->skip_bios = app->emulation.skip_bios; - app->emulation.launch_config->speed = app->emulation.speed; + app->emulation.launch_config->speed = app->emulation.fast_forward ? 0 : app->emulation.speed; app->emulation.launch_config->audio_frequency = GBA_CYCLES_PER_SECOND / app->audio.resample_frequency; if (app->emulation.backup_storage.autodetect) { diff --git a/source/app/main.c b/source/app/main.c index d6cddec..4f6905c 100644 --- a/source/app/main.c +++ b/source/app/main.c @@ -62,7 +62,7 @@ main( app.emulation.is_started = false; app.emulation.is_running = false; app.emulation.speed = 1; - app.emulation.unbounded = false; + app.emulation.fast_forward = false; app.emulation.backup_storage.autodetect = true; app.emulation.backup_storage.type = BACKUP_NONE; app.emulation.gpio_device.autodetect = true; diff --git a/source/app/path.c b/source/app/path.c index 8884461..79ba445 100644 --- a/source/app/path.c +++ b/source/app/path.c @@ -89,7 +89,6 @@ system_pictures_dir(void) #endif } - void app_paths_update( struct app *app diff --git a/source/app/windows/menubar.c b/source/app/windows/menubar.c index b793d02..eab9464 100644 --- a/source/app/windows/menubar.c +++ b/source/app/windows/menubar.c @@ -100,8 +100,16 @@ app_win_menubar_emulation( if (igBeginMenu("Speed", app->emulation.is_started)) { uint32_t x; + + bind = SDL_GetKeyName(app->binds.keyboard[BIND_EMULATOR_FAST_FORWARD_TOGGLE]); + if (igMenuItem_Bool("Fast Forward", bind ?: "", app->emulation.fast_forward, true)) { + app->emulation.fast_forward ^= true; + app_emulator_speed(app, app->emulation.fast_forward ? 0 : app->emulation.speed); + } + + igSeparator(); + char const *speed[] = { - "Unbounded", "x1", "x2", "x3", @@ -109,20 +117,18 @@ app_win_menubar_emulation( "x5", }; - for (x = 0; x <= 5; ++x) { + igBeginDisabled(app->emulation.fast_forward); + for (x = 0; x < 5; ++x) { char const *bind; - bind = SDL_GetKeyName(app->binds.keyboard[BIND_EMULATOR_SPEED_MAX + x]); - if (igMenuItem_Bool(speed[x], bind ?: "", app->emulation.speed == x, true)) { - app->emulation.unbounded = false; - app->emulation.speed = x; + bind = SDL_GetKeyName(app->binds.keyboard[BIND_EMULATOR_SPEED_X1 + x]); + if (igMenuItem_Bool(speed[x], bind ?: "", app->emulation.speed == x + 1, true)) { + app->emulation.speed = x + 1; + app->emulation.fast_forward = false; app_emulator_speed(app, app->emulation.speed); } - - if (!x) { - igSeparator(); - } } + igEndDisabled(); igEndMenu(); } diff --git a/source/app/windows/settings.c b/source/app/windows/settings.c index 0f2a234..24a6253 100644 --- a/source/app/windows/settings.c +++ b/source/app/windows/settings.c @@ -75,8 +75,8 @@ char const * const binds_pretty_name[] = { [BIND_EMULATOR_SPEED_X3] = "Speed x3", [BIND_EMULATOR_SPEED_X4] = "Speed x4", [BIND_EMULATOR_SPEED_X5] = "Speed x5", - [BIND_EMULATOR_SPEED_MAX] = "Speed Max", - [BIND_EMULATOR_SPEED_MAX_HOLD] = "Speed Max (Hold)", + [BIND_EMULATOR_FAST_FORWARD_TOGGLE] = "Fast Forward (Toggle)", + [BIND_EMULATOR_FAST_FORWARD_HOLD] = "Fast Forward (Hold)", [BIND_EMULATOR_SCREENSHOT] = "Screenshot", [BIND_EMULATOR_QUICKSAVE] = "Quicksave", [BIND_EMULATOR_QUICKLOAD] = "Quickload", @@ -101,8 +101,8 @@ char const * const binds_slug[] = { [BIND_EMULATOR_SPEED_X3] = "speed_x3", [BIND_EMULATOR_SPEED_X4] = "speed_x4", [BIND_EMULATOR_SPEED_X5] = "speed_x5", - [BIND_EMULATOR_SPEED_MAX] = "speed_max", - [BIND_EMULATOR_SPEED_MAX_HOLD] = "speed_max_hold", + [BIND_EMULATOR_FAST_FORWARD_TOGGLE] = "fast_forward_toggle", + [BIND_EMULATOR_FAST_FORWARD_HOLD] = "fast_forward_hold", [BIND_EMULATOR_SCREENSHOT] = "screenshot", [BIND_EMULATOR_QUICKSAVE] = "quicksave", [BIND_EMULATOR_QUICKLOAD] = "quickload", @@ -177,18 +177,18 @@ app_win_settings_emulation( igTableSetupColumn("##EmulationSettingsSpeedLabel", ImGuiTableColumnFlags_WidthFixed, vp->WorkSize.x / 5.f, 0); igTableSetupColumn("##EmulationSettingsSpeedValue", ImGuiTableColumnFlags_WidthStretch, 0.f, 0); - // Unbounded Speed + // Fast Forward igTableNextRow(ImGuiTableRowFlags_None, 0.f); igTableNextColumn(); - igTextWrapped("Unbounded Speed"); + igTextWrapped("Fast Forward"); igTableNextColumn(); - if (igCheckbox("##UnboundedSpeed", &app->emulation.unbounded)) { - app_emulator_speed(app, app->emulation.unbounded ? 0 : app->emulation.speed); + if (igCheckbox("##FastForward", &app->emulation.fast_forward)) { + app_emulator_speed(app, app->emulation.fast_forward ? 0 : app->emulation.speed); } // Speed - igBeginDisabled(app->emulation.unbounded); + igBeginDisabled(app->emulation.fast_forward); igTableNextRow(ImGuiTableRowFlags_None, 0.f); igTableNextColumn(); igTextWrapped("Speed"); @@ -196,7 +196,7 @@ app_win_settings_emulation( igTableNextColumn(); if (igCombo_Str_arr("##Speed", &speed, speed_names, array_length(speed_names), 0)) { app->emulation.speed = speed + 1; - app->emulation.unbounded = false; + app->emulation.fast_forward = false; app_emulator_speed(app, app->emulation.speed); } igEndDisabled();