changeset 2556:6f1eebc0a90b

Add auto option for fm_dac config variable that bases zero offset on the select MD model
author Michael Pavone <pavone@retrodev.com>
date Sat, 11 Jan 2025 23:21:36 -0800
parents 78e1769efcdb
children 75dd7536c467
files genesis.c nuklear_ui/blastem_nuklear.c
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/genesis.c	Sat Jan 11 23:03:24 2025 -0800
+++ b/genesis.c	Sat Jan 11 23:21:36 2025 -0800
@@ -2448,8 +2448,14 @@
 		config_gain = tern_find_path(config, "audio\0fm_gain\0", TVAL_PTR).ptrval;
 		render_audio_source_gaindb(gen->ym->audio, config_gain ? atof(config_gain) : 0.0f);
 
-		char *config_dac = tern_find_path_default(config, "audio\0fm_dac\0", (tern_val){.ptrval="zero_offset"}, TVAL_PTR).ptrval;
-		ym_enable_zero_offset(gen->ym, !strcmp(config_dac, "zero_offset"));
+		char *config_dac = tern_find_path_default(config, "audio\0fm_dac\0", (tern_val){.ptrval="auto"}, TVAL_PTR).ptrval;
+		uint8_t zero_offset = 0;
+		if (!strcmp(config_dac, "auto")) {
+			zero_offset = gen->ym->status_address_mask != 0;
+		} else if (!strcmp(config_dac, "zero_offset")) {
+			zero_offset = 1;
+		}
+		ym_enable_zero_offset(gen->ym, zero_offset);
 	}
 
 	if (gen->expansion) {
--- a/nuklear_ui/blastem_nuklear.c	Sat Jan 11 23:03:24 2025 -0800
+++ b/nuklear_ui/blastem_nuklear.c	Sat Jan 11 23:21:36 2025 -0800
@@ -2113,10 +2113,12 @@
 		"64"
 	};
 	const char *dac[] = {
+		"auto",
 		"zero_offset",
 		"linear"
 	};
 	const char *dac_desc[] = {
+		"Default for Model",
 		"Zero Offset",
 		"Linear"
 	};
@@ -2129,7 +2131,7 @@
 	if (selected_rate < 0 || selected_size < 0 || selected_dac < 0) {
 		selected_rate = find_match(rates, num_rates, "audio\0rate\0", "48000");
 		selected_size = find_match(sizes, num_sizes, "audio\0buffer\0", "512");
-		selected_dac = find_match(dac, num_dacs, "audio\0fm_dac\0", "zero_offset");
+		selected_dac = find_match(dac, num_dacs, "audio\0fm_dac\0", "auto");
 	}
 	uint32_t width = render_width();
 	uint32_t height = render_height();