diff sms.c @ 2604:c768bbd912f1

Give sega 8-bit consoles separate system_type enum values and allow selecting them from the command line
author Michael Pavone <pavone@retrodev.com>
date Thu, 13 Feb 2025 23:07:31 -0800
parents 251cc75574af
children
line wrap: on
line diff
--- a/sms.c	Thu Feb 13 21:04:28 2025 -0800
+++ b/sms.c	Thu Feb 13 23:07:31 2025 -0800
@@ -1530,7 +1530,7 @@
 	load_cassette(sms, media);
 }
 
-sms_context *alloc_configure_sms(system_media *media, uint32_t opts, uint8_t force_region)
+sms_context *alloc_configure_sms(system_media *media, system_type stype, uint32_t opts, uint8_t force_region)
 {
 	sms_context *sms = calloc(1, sizeof(sms_context));
 	tern_node *rom_db = get_rom_db();
@@ -1541,19 +1541,26 @@
 	uint32_t rom_size = sms->header.info.rom_size;
 	z80_options *zopts = malloc(sizeof(z80_options));
 	tern_node *model_def;
-	uint8_t is_gamegear = !strcasecmp(media->extension, "gg");
-	uint8_t is_sc3000 = !strcasecmp(media->extension, "sc");
-	if (is_gamegear) {
+	uint8_t vdp_type = VDP_SMS2;
+	switch (stype)
+	{
+	case SYSTEM_GAME_GEAR:
 		model_def = tern_find_node(get_systems_config(), "gg");
-	} else if (!strcasecmp(media->extension, "sg")) {
+		vdp_type = VDP_GAMEGEAR;
+		break;
+	case SYSTEM_SG1000:
 		model_def = tern_find_node(get_systems_config(), "sg1000");
-	} else if (is_sc3000) {
+		vdp_type = VDP_TMS9918A;
+		break;
+	case SYSTEM_SC3000:
 		model_def = tern_find_node(get_systems_config(), "sc3000");
-	} else {
+		vdp_type = VDP_TMS9918A;
+		break;
+	default:
 		model_def = get_model(config, SYSTEM_SMS);
+		break;
 	}
 	char *vdp_str = tern_find_ptr(model_def, "vdp");
-	uint8_t vdp_type = is_gamegear ? VDP_GAMEGEAR : is_sc3000 ? VDP_TMS9918A : VDP_SMS2;
 	if (vdp_str) {
 		if (!strcmp(vdp_str, "sms1")) {
 			vdp_type = VDP_SMS;
@@ -1576,6 +1583,7 @@
 			chunk->buffer = sms->ram + ((chunk->start - 0xC000) & 0x1FFF);
 		}
 	}
+	uint8_t is_gamegear = stype == SYSTEM_GAME_GEAR, is_sc3000 = stype == SYSTEM_SC3000;
 	char *io_type = tern_find_ptr(model_def, "io");
 	if (io_type) {
 		if (!strcmp(io_type, "gamegear")) {
@@ -1672,7 +1680,7 @@
 	sms->header.stop_vgm_log = stop_vgm_log;
 	sms->header.toggle_debug_view = toggle_debug_view;
 	sms->header.cassette_action = cassette_action;
-	sms->header.type = SYSTEM_SMS;
+	sms->header.type = stype;
 	if (is_sc3000) {
 		sms->header.lockon_change = lockon_change;
 	}