Skip to content

Commit

Permalink
Rename the Unbounded Speed option to Fast Forward.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arignir committed Mar 8, 2024
1 parent 4a4c7a8 commit c86926a
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 48 deletions.
10 changes: 5 additions & 5 deletions accuracy/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions include/app/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};

Expand Down Expand Up @@ -157,7 +157,7 @@ struct app {

// Speed
uint32_t speed;
bool unbounded;
bool fast_forward;

// Skip BIOS
bool skip_bios;
Expand Down
23 changes: 13 additions & 10 deletions source/app/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <cimgui.h>
#include <cimgui_impl.h>
#include "hades.h"
#include "gba/event.h"
#include "app/app.h"

void
Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions source/app/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -251,7 +251,7 @@ app_config_save(
"emulation": {
"skip_bios": %B,
"speed": %d,
"unbounded": %B,
"fast_forward": %B,
"backup_storage": {
"autodetect": %B,
"type": %d
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion source/app/emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion source/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion source/app/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ system_pictures_dir(void)
#endif
}


void
app_paths_update(
struct app *app
Expand Down
26 changes: 16 additions & 10 deletions source/app/windows/menubar.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,35 @@ 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",
"x4",
"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();
}
Expand Down
20 changes: 10 additions & 10 deletions source/app/windows/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -177,26 +177,26 @@ 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");

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();
Expand Down

0 comments on commit c86926a

Please sign in to comment.