diff options
author | Michael Pavone <pavone@retrodev.com> | 2020-02-16 10:33:20 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2020-02-16 10:33:20 -0800 |
commit | c8680028c6fc9570f6b8324285fed925d19f053c (patch) | |
tree | 34ce8d7d7f2fa64ea7231d0032b5f0ef6061cb57 | |
parent | b74dd5f387ebb8e7dc542dd5fd97284b67ba816c (diff) |
Added UI for selecting configured model
-rwxr-xr-x | build_release | 2 | ||||
-rw-r--r-- | config.c | 15 | ||||
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | default.cfg | 2 | ||||
-rw-r--r-- | nuklear_ui/blastem_nuklear.c | 60 | ||||
-rw-r--r-- | systems.cfg | 80 |
6 files changed, 160 insertions, 2 deletions
diff --git a/build_release b/build_release index 95ac07f..b9808a2 100755 --- a/build_release +++ b/build_release @@ -62,7 +62,7 @@ dir="blastem${suffix}-${ver}" echo $dir rm -rf "$dir" mkdir "$dir" -cp -r $binaries shaders images default.cfg rom.db gamecontrollerdb.txt "$dir" +cp -r $binaries shaders images default.cfg rom.db gamecontrollerdb.txt systems.cfg "$dir" for file in README COPYING CHANGELOG; do cp "$file" "$dir"/"$file$txt" done @@ -322,3 +322,18 @@ uint32_t get_lowpass_cutoff(tern_node *config) char * lowpass_cutoff_str = tern_find_path(config, "audio\0lowpass_cutoff\0", TVAL_PTR).ptrval; return lowpass_cutoff_str ? atoi(lowpass_cutoff_str) : DEFAULT_LOWPASS_CUTOFF; } + +tern_node *get_systems_config(void) +{ + static tern_node *systems; + if (!systems) { + systems = parse_bundled_config("systems.cfg"); + } + return systems; +} + +tern_node *get_model(tern_node *config, system_type stype) +{ + char *model = tern_find_path_default(config, "system\0model\0", (tern_val){.ptrval = "md1va3"}, TVAL_PTR); + return tern_find_node(get_systems_config(), model); +} @@ -6,6 +6,7 @@ #ifndef CONFIG_H_ #define CONFIG_H_ #include "tern.h" +#include "system.h" tern_node *parse_config_file(char *config_path); tern_node *parse_bundled_config(char *config_name); @@ -17,6 +18,8 @@ void persist_config_at(tern_node *app_config, tern_node *to_save, char *fname); void persist_config(tern_node *config); char **get_extension_list(tern_node *config, uint32_t *num_exts_out); uint32_t get_lowpass_cutoff(tern_node *config); +tern_node *get_systems_config(void); +tern_node *get_model(tern_node *config, system_type stype); #endif //CONFIG_H_ diff --git a/default.cfg b/default.cfg index f7d382a..47a9abc 100644 --- a/default.cfg +++ b/default.cfg @@ -385,6 +385,8 @@ system { #MegaWiFi allows ROMs to make connections to the internet #so it should only be enabled for ROMs you trust megawifi off + #Model of the emulated Gen/MD system, see systems.cfg for a list of options + model md1va3 } diff --git a/nuklear_ui/blastem_nuklear.c b/nuklear_ui/blastem_nuklear.c index 8773b90..726d6bf 100644 --- a/nuklear_ui/blastem_nuklear.c +++ b/nuklear_ui/blastem_nuklear.c @@ -1831,6 +1831,50 @@ void view_audio_settings(struct nk_context *context) nk_end(context); } } +typedef struct { + const char **models; + const char **names; + uint32_t num_models; + uint32_t storage; +} model_foreach_state; +void model_iter(char *key, tern_val val, uint8_t valtype, void *data) +{ + if (valtype != TVAL_NODE) { + return; + } + model_foreach_state *state = data; + if (state->num_models == state->storage) { + state->storage *= 2; + state->models = realloc(state->models, state->storage * sizeof(char *)); + state->names = realloc(state->names, state->storage * sizeof(char *)); + } + char *def = strdup(key); + state->models[state->num_models] = def; + state->names[state->num_models++] = tern_find_ptr_default(val.ptrval, "name", def); +} + +typedef struct { + const char **models; + const char **names; +} models; + +models get_models(uint32_t *num_out) +{ + tern_node *systems = get_systems_config(); + model_foreach_state state = { + .models = calloc(4, sizeof(char *)), + .names = calloc(4, sizeof(char *)), + .num_models = 0, + .storage = 4 + }; + tern_foreach(systems, model_iter, &state); + *num_out = state.num_models; + return (models){ + .models = state.models, + .names = state.names + }; +} + void view_system_settings(struct nk_context *context) { const char *sync_opts[] = { @@ -1853,12 +1897,25 @@ void view_system_settings(struct nk_context *context) if (selected_region < 0) { selected_region = find_match(region_codes, num_regions, "system\0default_region\0", "U"); } + static const char **model_opts; + static const char **model_names; + static uint32_t num_models; + if (!model_opts) { + models m = get_models(&num_models); + model_opts = m.models; + model_names = m.names; + } + static int32_t selected_model = -1; + if (selected_model < 0) { + selected_model = find_match(model_opts, num_models, "system\0model\0", "md1va3"); + } + const char *formats[] = { "native", "gst" }; const uint32_t num_formats = sizeof(formats)/sizeof(*formats); - int32_t selected_format = -1; + static int32_t selected_format = -1; if (selected_format < 0) { selected_format = find_match(formats, num_formats, "ui\0state_format\0", "native"); } @@ -1908,6 +1965,7 @@ void view_system_settings(struct nk_context *context) settings_toggle(context, "Save config with EXE", "ui\0config_in_exe_dir\0", 0); settings_string(context, "Game Save Path", "ui\0save_path\0", "$USERDATA/blastem/$ROMNAME"); selected_region = settings_dropdown_ex(context, "Default Region", region_codes, regions, num_regions, selected_region, "system\0default_region\0"); + selected_model = settings_dropdown_ex(context, "Model", model_opts, model_names, num_models, selected_model, "system\0model\0"); selected_format = settings_dropdown(context, "Save State Format", formats, num_formats, selected_format, "ui\0state_format\0"); selected_init = settings_dropdown(context, "Initial RAM Value", ram_inits, num_inits, selected_init, "system\0ram_init\0"); selected_io_1 = settings_dropdown_ex(context, "IO Port 1 Device", io_opts_1, device_type_names, num_io, selected_io_1, "io\0devices\0""1\0"); diff --git a/systems.cfg b/systems.cfg new file mode 100644 index 0000000..8dd4656 --- /dev/null +++ b/systems.cfg @@ -0,0 +1,80 @@ +md1va0 { + name Model 1 VA0 + vram 64 + vsram 40 + zram 8 + tas broken + z80_open_bus float + fm discrete 2612 + tmss off +} +md1va3 { + name Model 1 VA3 + vram 64 + vsram 40 + zram 8 + tas broken + z80_open_bus FF + fm discrete 2612 + tmss off +} +md1va6 { + name Model 1 VA6 + vram 64 + vsram 40 + zram 8 + tas broken + z80_open_bus FF + fm discrete 2612 + tmss on +} +md2va1 { + name Model 2 VA1 + vram 64 + vsram 40 + zram 8 + tas broken + z80_open_bus FF + fm integrated 3834 + tmss on +} +md2va2 { + name Model 2 VA2 + vram 64 + vsram 40 + zram 8 + tas broken + z80_open_bus FF + fm discrete 2612 + tmss on +} +md3va1 { + name Model 3 VA1 + vram 64 + vsram 64 + zram 8 + tas broken + z80_open_bus FF + fm integrated 3834 + tmss on +} +md3va2 { + name Model 3 VA2 + vram 64 + vsram 64 + zram 8 + tas works + z80_open_bus FF + fm discrete 2612 + tmss on +} +teradrive { + name Teradrive + vram 128 + vsram 40 + zram 16 + tas broken + z80_open_bus FF + fm discrete 3834 + tmss off +}
\ No newline at end of file |