From: kub Date: Sat, 13 Jan 2024 15:31:43 +0000 (+0100) Subject: core+platforms, add SMS option to select TMS palette for gfx modes 0-3 X-Git-Tag: v2.00~137 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=214a6c624cd63ea582e278f0dc32ef0f00f0f5c9;p=picodrive.git core+platforms, add SMS option to select TMS palette for gfx modes 0-3 --- diff --git a/pico/mode4.c b/pico/mode4.c index 78108ec0..b396af66 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -741,6 +741,10 @@ void PicoFrameStartSMS(void) Pico.m.dirtyPal = 1; } + Pico.m.hardware &= ~PMS_HW_TMS; + if (PicoIn.tmsPalette || (PicoIn.AHW & (PAHW_SG|PAHW_SC))) + Pico.m.hardware |= PMS_HW_TMS; + // Copy LCD enable flag for easier handling Pico.m.hardware &= ~PMS_HW_LCD; if ((PicoIn.opt & POPT_EN_GG_LCD) && (PicoIn.AHW & PAHW_GG)) { @@ -886,7 +890,7 @@ void PicoDoHighPal555SMS(void) * hence GG/SMS/TMS can all be handled the same here */ for (j = cnt; j > 0; j--) { if (!(Pico.video.reg[0] & 0x4)) // fixed palette in TMS modes - spal = (u32 *)tmspal + (PicoIn.AHW & (PAHW_SG|PAHW_SC) ? 16/2:0); + spal = (u32 *)tmspal + (Pico.m.hardware & PMS_HW_TMS ? 16/2:0); for (i = 0x20/2; i > 0; i--, spal++, dpal++) { t = *spal; #if defined(USE_BGR555) diff --git a/pico/pico.h b/pico/pico.h index f17d93de..e45540c3 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -116,6 +116,7 @@ typedef struct PicoInterface unsigned short autoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP unsigned int hwSelect; // hardware preselected via option menu unsigned int mapper; // mapper selection for SMS, 0 = auto + unsigned int tmsPalette; // palette used by SMS in TMS graphic modes unsigned short quirks; // game-specific quirks: PQUIRK_* unsigned short overclockM68k; // overclock the emulated 68k, in % diff --git a/pico/pico_int.h b/pico/pico_int.h index 0d336822..9ccfddb7 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -346,7 +346,8 @@ struct PicoMisc #define PMS_HW_LCD 0x2 // GG LCD #define PMS_HW_JAP 0x4 // japanese system #define PMS_HW_FM 0x8 // FM sound -#define PMS_HW_FMUSED 0x10 // FM sound accessed +#define PMS_HW_TMS 0x10 // assume TMS9918 +#define PMS_HW_FMUSED 0x80 // FM sound accessed #define PMS_MAP_AUTO 0 #define PMS_MAP_SEGA 1 diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c index 4312bf87..1492738a 100644 --- a/platform/common/menu_pico.c +++ b/platform/common/menu_pico.c @@ -577,10 +577,13 @@ static int menu_loop_32x_options(int id, int keys) static const char *sms_hardwares[] = { "auto", "Game Gear", "Master System", "SG-1000", "SC-3000", NULL }; static const char *gg_ghosting_opts[] = { "OFF", "weak", "normal", NULL }; static const char *sms_mappers[] = { "auto", "Sega", "Codemasters", "Korea", "Korea MSX", "Korea X-in-1", "Korea 4-Pak", "Korea Janggun", "Korea Nemesis", "Taiwan 8K RAM", "Korea XOR", "Sega 32K RAM", NULL }; +static const char *sms_tmspalette[] = { "SMS", "SG-1000" }; static const char h_smsfm[] = "FM sound is only supported by few games,\n" "some games may crash with FM enabled"; static const char h_ghost[] = "Simulate the inertia of the GG LCD display"; +static const char h_smspal[] = "Selects the color palette used for SMS games\n" + "using the original TMS9918 graphics modes"; static menu_entry e_menu_sms_options[] = { @@ -588,6 +591,7 @@ static menu_entry e_menu_sms_options[] = mee_enum ("Cartridge mapping", MA_SMSOPT_MAPPER, PicoIn.mapper, sms_mappers), mee_enum_h ("Game Gear LCD ghosting", MA_SMSOPT_GHOSTING, currentConfig.ghosting, gg_ghosting_opts, h_ghost), mee_onoff_h ("FM Sound Unit", MA_OPT2_ENABLE_YM2413, PicoIn.opt, POPT_EN_YM2413, h_smsfm), + mee_enum_h ("SMS palette in TMS mode", MA_SMSOPT_TMSPALETTE, PicoIn.tmsPalette, sms_tmspalette, h_smspal), mee_end, }; diff --git a/platform/common/menu_pico.h b/platform/common/menu_pico.h index 1cfae2f1..59e6af80 100644 --- a/platform/common/menu_pico.h +++ b/platform/common/menu_pico.h @@ -99,6 +99,7 @@ typedef enum MA_SMSOPT_HARDWARE, MA_SMSOPT_MAPPER, MA_SMSOPT_GHOSTING, + MA_SMSOPT_TMSPALETTE, MA_CTRL_PLAYER1, MA_CTRL_PLAYER2, MA_CTRL_PLAYER3, diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index adb43993..600c0159 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1814,6 +1814,15 @@ static void update_variables(bool first_run) PicoIn.opt &= ~POPT_EN_YM2413; } + var.value = NULL; + var.key = "picodrive_smstms"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + if (strcmp(var.value, "SG-1000") == 0) + PicoIn.tmsPalette = 1; + else + PicoIn.tmsPalette = 0; + } + var.value = NULL; var.key = "picodrive_smsmapper"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { diff --git a/platform/libretro/libretro_core_options.h b/platform/libretro/libretro_core_options.h index 1e1d4c4b..a5f7cb8c 100644 --- a/platform/libretro/libretro_core_options.h +++ b/platform/libretro/libretro_core_options.h @@ -145,6 +145,20 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "Auto" }, + { + "picodrive_smstms", + "Master System Palette in TMS modes", + NULL, + "Choose which colour palette should be used when an SMS game runs in one of the SG-1000 graphics modes.", + NULL, + "system", + { + { "SMS", NULL }, + { "SG-1000", NULL }, + { NULL, NULL }, + }, + "SMS" + }, { "picodrive_ramcart", "Sega CD RAM Cart",