From bae91cdb1d5320d42f3b637c22d026e3cff64248 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 26 Feb 2021 01:04:24 +0200 Subject: [PATCH] Add RTC option to the SDL port, fix a bug where rewind setting didn't update --- SDL/gui.c | 15 +++++++++++++++ SDL/gui.h | 1 + SDL/main.c | 3 +++ 3 files changed, 19 insertions(+) diff --git a/SDL/gui.c b/SDL/gui.c index 92d9479..580a3f6 100644 --- a/SDL/gui.c +++ b/SDL/gui.c @@ -482,11 +482,26 @@ static void toggle_bootrom(unsigned index) } } +static void toggle_rtc_mode(unsigned index) +{ + configuration.rtc_mode = !configuration.rtc_mode; +} + +const char *current_rtc_mode_string(unsigned index) +{ + switch (configuration.rtc_mode) { + case GB_RTC_MODE_SYNC_TO_HOST: return "Sync to System Clock"; + case GB_RTC_MODE_ACCURATE: return "Accurate"; + } + return ""; +} + static const struct menu_item emulation_menu[] = { {"Emulated Model:", cycle_model, current_model_string, cycle_model_backwards}, {"SGB Revision:", cycle_sgb_revision, current_sgb_revision_string, cycle_sgb_revision_backwards}, {"Boot ROMs Folder:", toggle_bootrom, current_bootrom_string, toggle_bootrom}, {"Rewind Length:", cycle_rewind, current_rewind_string, cycle_rewind_backwards}, + {"Real Time Clock:", toggle_rtc_mode, current_rtc_mode_string, toggle_rtc_mode}, {"Back", return_to_root_menu}, {NULL,} }; diff --git a/SDL/gui.h b/SDL/gui.h index 8d69ec3..5db7aff 100644 --- a/SDL/gui.h +++ b/SDL/gui.h @@ -116,6 +116,7 @@ typedef struct { uint8_t color_temperature; char bootrom_path[4096]; uint8_t interference_volume; + GB_rtc_mode_t rtc_mode; } configuration_t; extern configuration_t configuration; diff --git a/SDL/main.c b/SDL/main.c index 4f10ae9..d10590d 100644 --- a/SDL/main.c +++ b/SDL/main.c @@ -125,6 +125,8 @@ static void open_menu(void) GB_set_border_mode(&gb, configuration.border_mode); update_palette(); GB_set_highpass_filter_mode(&gb, configuration.highpass_mode); + GB_set_rewind_length(&gb, configuration.rewind_length); + GB_set_rtc_mode(&gb, configuration.rtc_mode); if (previous_width != GB_get_screen_width(&gb)) { screen_size_changed(); } @@ -513,6 +515,7 @@ restart: } GB_set_highpass_filter_mode(&gb, configuration.highpass_mode); GB_set_rewind_length(&gb, configuration.rewind_length); + GB_set_rtc_mode(&gb, configuration.rtc_mode); GB_set_update_input_hint_callback(&gb, handle_events); GB_apu_set_sample_callback(&gb, gb_audio_callback); }