Mercurial > repos > blastem
changeset 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 | acb8f0f70a68 |
children | b63059c1921c |
files | blastem.c nuklear_ui/blastem_nuklear.c sms.c sms.h system.c system.h |
diffstat | 6 files changed, 56 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/blastem.c Thu Feb 13 21:04:28 2025 -0800 +++ b/blastem.c Thu Feb 13 23:07:31 2025 -0800 @@ -431,10 +431,16 @@ case 'm': i++; if (i >= argc) { - fatal_error("-r must be followed by a machine type (sms, gen or jag)\n"); + fatal_error("-r must be followed by a machine type (sms, gg, sg, sc, gen, pico, copera, jag or media)\n"); } if (!strcmp("sms", argv[i])) { stype = force_stype = SYSTEM_SMS; + } else if (!strcmp("gg", argv[i])) { + stype = force_stype = SYSTEM_GAME_GEAR; + } else if (!strcmp("sg", argv[i])) { + stype = force_stype = SYSTEM_SG1000; + } else if (!strcmp("sc", argv[i])) { + stype = force_stype = SYSTEM_SC3000; } else if (!strcmp("gen", argv[i])) { stype = force_stype = SYSTEM_GENESIS; } else if (!strcmp("pico", argv[i])) { @@ -480,10 +486,14 @@ " -h Print this help text\n" " -r (J|U|E) Force region to Japan, US or Europe respectively\n" " -m MACHINE Force emulated machine type to MACHINE. Valid values are:\n" - " sms - Sega Master System/Mark III\n" - " gen - Sega Genesis/Megadrive\n" - " pico - Sega Pico\n" - " media - Media Player\n" + " sms - Sega Master System/Mark III\n" + " gg - Sega Game Gear\n" + " sg - Sega SG-1000\n" + " sc - Sega SC-3000\n" + " gen - Sega Genesis/Megadrive\n" + " pico - Sega Pico\n" + " copera - Yamaha Copera\n" + " media - Media Player\n" " -f Toggles fullscreen mode\n" " -g Disable OpenGL rendering\n" " -s FILE Load a GST format savestate from FILE\n"
--- a/nuklear_ui/blastem_nuklear.c Thu Feb 13 21:04:28 2025 -0800 +++ b/nuklear_ui/blastem_nuklear.c Thu Feb 13 23:07:31 2025 -0800 @@ -22,7 +22,6 @@ #include "../controller_info.h" #include "../bindings.h" #include "../mediaplayer.h" -#include "../sms.h" static struct nk_context *context; static struct rawfb_context *fb_context; @@ -2470,7 +2469,7 @@ }; if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) { - if (current_system->type == SYSTEM_SMS && ((sms_context *)current_system)->i8255) { + if (current_system->type == SYSTEM_SC3000) { menu(context, sizeof(sc3k_items)/sizeof(*sc3k_items), sc3k_items, exit_handler); } else { menu(context, sizeof(items)/sizeof(*items), items, exit_handler); @@ -2485,7 +2484,9 @@ {"Load ROM", view_load}, {"Settings", view_settings}, {"About", view_about}, +#ifndef __EMSCRIPTEN__ {"Exit", NULL} +#endif }; if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) {
--- 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; }
--- a/sms.h Thu Feb 13 21:04:28 2025 -0800 +++ b/sms.h Thu Feb 13 23:07:31 2025 -0800 @@ -45,6 +45,6 @@ wave_header cassette_wave; } sms_context; -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); #endif //SMS_H_
--- a/system.c Thu Feb 13 21:04:28 2025 -0800 +++ b/system.c Thu Feb 13 23:07:31 2025 -0800 @@ -286,7 +286,7 @@ || safe_cmp("TMR SEGA", 0x3FF0, media->buffer, media->size) || safe_cmp("TMR SEGA", 0x7FF0, media->buffer, media->size) ) { - return SYSTEM_SMS; + return strcmp("gg", media->extension) ? SYSTEM_SMS : SYSTEM_GAME_GEAR; } if (media->size > 400) { uint8_t *buffer = media->buffer; @@ -333,10 +333,20 @@ if (!strcmp("md", media->extension) || !strcmp("gen", media->extension)) { return SYSTEM_GENESIS; } - if (!strcmp("sms", media->extension) || !strcmp("sg", media->extension) || !strcmp("gg", media->extension) - || !strcmp("sc", media->extension) || !strcmp("sf7", media->extension)) { + if (!strcmp("sms", media->extension)) { return SYSTEM_SMS; } + if (!strcmp("gg", media->extension)) { + return SYSTEM_GAME_GEAR; + } + if (!strcmp("sg", media->extension) || !strcmp("sg1", media->extension)) { + return SYSTEM_SG1000; + } + if (!strcmp("sc", media->extension) || !strcmp("sf7", media->extension) || + !strcmp("sc3", media->extension) + ) { + return SYSTEM_SC3000; + } if (!strcmp("j64", media->extension)) { return SYSTEM_JAGUAR; } @@ -375,7 +385,10 @@ return &(alloc_config_genesis_cdboot(media, opts, force_region))->header; #ifndef NO_Z80 case SYSTEM_SMS: - return &(alloc_configure_sms(media, opts, force_region))->header; + case SYSTEM_GAME_GEAR: + case SYSTEM_SG1000: + case SYSTEM_SC3000: + return &(alloc_configure_sms(media, stype, opts, force_region))->header; case SYSTEM_COLECOVISION: return &(alloc_configure_coleco(media))->header; #endif