Fix palettes (#257)

This commit is contained in:
Bobby Smith 2023-12-04 22:44:52 +01:00 committed by GitHub
parent e3e12814bf
commit 9b232311f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 150 additions and 8 deletions

View File

@ -2723,7 +2723,7 @@ static const GbcPaletteEntry gbcDirPalettes[] = {
{ "TWB64 009 - Neon Pink", twb64_009_neon_pink },
{ "TWB64 010 - Mario Red", twb64_010_mario_red },
{ "TWB64 011 - Nick Orange", twb64_011_nick_orange },
{ "TWB64 012 - Virtual Boy Vision", twb64_012_virtual_vision },
{ "TWB64 012 - Virtual Vision", twb64_012_virtual_vision },
{ "TWB64 013 - Golden Wild", twb64_013_golden_wild },
{ "TWB64 014 - Builder Yellow", twb64_014_builder_yellow },
{ "TWB64 015 - Classic Blurple", twb64_015_classic_blurple },
@ -2864,7 +2864,7 @@ static const GbcPaletteEntry gbcDirPalettes[] = {
{ "TWB64 150 - Olympic Bronze", twb64_150_olympic_bronze },
{ "TWB64 151 - ANA Sky Blue", twb64_151_ana_sky_blue },
{ "TWB64 152 - Nijigasaki Orange", twb64_152_nijigasaki_orange },
{ "TWB64 153 - HoloBlue", twb64_153_holoblue },
{ "TWB64 153 - holoblue", twb64_153_holoblue },
{ "TWB64 154 - Wrestling Red", twb64_154_wrestling_red },
{ "TWB64 155 - Yoshi Egg Green", twb64_155_yoshi_egg_green },
{ "TWB64 156 - Pokedex Red", twb64_156_pokedex_red },
@ -2909,9 +2909,109 @@ static const GbcPaletteEntry gbcDirPalettes[] = {
{ "TWB64 195 - EVA-01", twb64_195_eva_01 },
{ "TWB64 196 - Equestrian Purple", twb64_196_equestrian_purple },
{ "TWB64 197 - Autobot Red", twb64_197_autobot_red },
{ "TWB64 198 - Niconico Sea Green", twb64_198_niconico_sea_green },
{ "TWB64 198 - niconico sea green", twb64_198_niconico_sea_green },
{ "TWB64 199 - Duracell Copper", twb64_199_duracell_copper },
{ "TWB64 200 - TOKYO SKYTREE CLOUDY BLUE", twb64_200_tokyo_skytree_cloudy_blue },
{ "TWB64 201 - DMG-GOLD", twb64_201_dmg_gold },
{ "TWB64 202 - LCD Clock Green", twb64_202_lcd_clock_green },
{ "TWB64 203 - Famicom Frenzy", twb64_203_famicom_frenzy },
{ "TWB64 204 - DK Arcade Blue", twb64_204_dk_arcade_blue },
{ "TWB64 205 - Advanced Indigo", twb64_205_advanced_indigo },
{ "TWB64 206 - Ultra Black", twb64_206_ultra_black },
{ "TWB64 207 - Chaos Emerald Green", twb64_207_chaos_emerald_green },
{ "TWB64 208 - Blue Bomber Azure", twb64_208_blue_bomber_azure },
{ "TWB64 209 - Garry's Blue", twb64_209_garrys_blue },
{ "TWB64 210 - Steam Gray", twb64_210_steam_gray },
{ "TWB64 211 - Dream Land GB Ver.", twb64_211_dream_land_gb_ver },
{ "TWB64 212 - Pokemon Pinball Ver.", twb64_212_pokemon_pinball_ver },
{ "TWB64 213 - Poketch Ver.", twb64_213_poketch_ver },
{ "TWB64 214 - COLLECTION of SaGa Ver.", twb64_214_collection_of_saga_ver },
{ "TWB64 215 - Rocky-Valley Holiday", twb64_215_rocky_valley_holiday },
{ "TWB64 216 - Giga Kiwi DMG", twb64_216_giga_kiwi_dmg },
{ "TWB64 217 - DMG Pea Green", twb64_217_dmg_pea_green },
{ "TWB64 218 - Timing Hero Ver.", twb64_218_timing_hero_ver },
{ "TWB64 219 - Invincible Blue", twb64_219_invincible_blue },
{ "TWB64 220 - Grinchy Green", twb64_220_grinchy_green },
{ "TWB64 221 - Winter Icy Blue", twb64_221_animate_blue },
{ "TWB64 222 - School Idol Mix", twb64_222_school_idol_mix },
{ "TWB64 223 - Green Awakening", twb64_223_green_awakening },
{ "TWB64 224 - Goomba Brown", twb64_224_goomba_brown },
{ "TWB64 225 - Devil Red", twb64_225_devil_red },
{ "TWB64 226 - Simpson Yellow", twb64_226_simpson_yellow },
{ "TWB64 227 - Spooky Purple", twb64_227_spooky_purple },
{ "TWB64 228 - Treasure Gold", twb64_228_treasure_gold },
{ "TWB64 229 - Cherry Blossom Pink", twb64_229_cherry_blossom_pink },
{ "TWB64 230 - Golden Trophy", twb64_230_golden_trophy },
{ "TWB64 231 - Winter Icy Blue", twb64_231_winter_icy_blue },
{ "TWB64 232 - Leprechaun Green", twb64_232_leprechaun_green },
{ "TWB64 233 - SAITAMA SUPER BLUE", twb64_233_saitama_super_blue },
{ "TWB64 234 - SAITAMA SUPER GREEN", twb64_234_saitama_super_green },
{ "TWB64 235 - Duolingo Green", twb64_235_duolingo_green },
{ "TWB64 236 - Super Mushroom Vision", twb64_236_super_mushroom_vision },
{ "TWB64 237 - Ancient Hisuian Brown", twb64_237_ancient_husuian_brown },
{ "TWB64 238 - Sky Pop Ivory", twb64_238_sky_pop_ivory },
{ "TWB64 239 - LAWSON BLUE", twb64_239_lawson_blue },
{ "TWB64 240 - Anime Expo Red", twb64_240_anime_expo_red },
{ "TWB64 241 - Brilliant Diamond Blue", twb64_241_brilliant_diamond_blue },
{ "TWB64 242 - Shining Pearl Pink", twb64_242_shining_pearl_pink },
{ "TWB64 243 - Funimation Melon", twb64_243_funimation_melon },
{ "TWB64 244 - Teyvat Brown", twb64_244_teyvat_brown },
{ "TWB64 245 - Chozo Blue", twb64_245_chozo_blue },
{ "TWB64 246 - Spotify Green", twb64_246_spotify_green },
{ "TWB64 247 - Dr Pepper Red", twb64_247_dr_pepper_red },
{ "TWB64 248 - NHK Silver Gray", twb64_248_nhk_silver_gray },
{ "TWB64 249 - Starbucks Green", twb64_249_starbucks_green },
{ "TWB64 250 - Tokyo Disney Magic", twb64_250_tokyo_disney_magic },
{ "TWB64 251 - Kingdom Key Gold", twb64_251_kingdom_key_gold },
{ "TWB64 252 - Hogwarts Goldius", twb64_252_hogwarts_goldius },
{ "TWB64 253 - Kentucky Fried Red", twb64_253_kentucky_fried_red },
{ "TWB64 254 - Cheeto Orange", twb64_254_cheeto_orange },
{ "TWB64 255 - Namco Idol Pink", twb64_255_namco_idol_pink },
{ "TWB64 256 - Domino's Blue", twb64_256_dominos_blue },
{ "TWB64 257 - Pac-Man Vision", twb64_257_pac_man_vision },
{ "TWB64 258 - Bill's PC Screen", twb64_258_bills_pc_screen },
{ "TWB64 259 - Sonic Mega Blue", twb64_259_ebott_prolouge },
{ "TWB64 260 - Fool's Gold and Silver", twb64_260_fools_gold_and_silver },
{ "TWB64 261 - UTA RED", twb64_261_uta_red },
{ "TWB64 262 - Metallic Paldea Brass", twb64_262_metallic_paldea_brass },
{ "TWB64 263 - Classy Christmas", twb64_263_classy_christmas },
{ "TWB64 264 - Winter Christmas", twb64_264_winter_christmas },
{ "TWB64 265 - IDOL WORLD TRICOLOR!!!", twb64_265_idol_world_tricolor },
{ "TWB64 266 - Inkling Tricolor", twb64_266_inkling_tricolor },
{ "TWB64 267 - 7-Eleven Color Combo", twb64_267_7_eleven_color_combo },
{ "TWB64 268 - PAC-PALETTE", twb64_268_pac_palette },
{ "TWB64 269 - Vulnerable Blue", twb64_269_vulnerable_blue },
{ "TWB64 270 - Nightvision Green", twb64_270_nightvision_green },
{ "TWB64 271 - Bandai Namco Tricolor", twb64_271_bandai_namco_tricolor },
{ "TWB64 272 - Gold, Silver, and Bronze", twb64_272_gold_silver_and_bronze },
{ "TWB64 273 - Arendelle Winter Blue", twb64_273_arendelle_winter_blue },
{ "TWB64 274 - Super Famicom Supreme", twb64_274_super_famicom_supreme },
{ "TWB64 275 - Absorbent and Yellow", twb64_275_absorbent_and_yellow },
{ "TWB64 276 - 765PRO TRICOLOR", twb64_276_765pro_tricolor },
{ "TWB64 277 - GameCube Glimmer", twb64_277_gamecube_glimmer },
{ "TWB64 278 - 1st Vision Pastel", twb64_278_1st_vision_pastel },
{ "TWB64 279 - Perfect Majin Emperor", twb64_279_perfect_majin_emperor },
{ "TWB64 280 - J-Pop Idol Sherbet", twb64_280_j_pop_idol_sherbet },
{ "TWB64 281 - Ryuuguu Sunset", twb64_281_ryuuguu_sunset },
{ "TWB64 282 - Tropical Starfall", twb64_282_tropical_starfall },
{ "TWB64 283 - Colorful Horizons", twb64_283_colorful_horizons },
{ "TWB64 284 - BLACKPINK BLINK PINK", twb64_284_blackpink_blink_pink },
{ "TWB64 285 - DMG-SWITCH", twb64_285_dmg_switch },
{ "TWB64 286 - POCKET SWITCH", twb64_286_pocket_switch },
{ "TWB64 287 - Sunny Passion Paradise", twb64_287_sunny_passion_paradise },
{ "TWB64 288 - Saiyan Beast Silver", twb64_288_saiyan_beast_silver },
{ "TWB64 289 - RADIANT SMILE RAMP", twb64_289_radiant_smile_ramp },
{ "TWB64 290 - A-RISE BLUE", twb64_290_a_rise_blue },
{ "TWB64 291 - TROPICAL TWICE APRICOT", twb64_291_tropical_twice_apricot },
{ "TWB64 292 - Odyssey Boy", twb64_292_odyssey_boy },
{ "TWB64 293 - Frog Coin Green", twb64_293_frog_coin_green },
{ "TWB64 294 - Garfield Vision", twb64_294_garfield_vision },
{ "TWB64 295 - Bedrock Caveman Vision", twb64_295_bedrock_caveman_vision },
{ "TWB64 296 - BANGTAN ARMY PURPLE", twb64_296_bangtan_army_purple },
{ "TWB64 297 - Spider-Verse Red", twb64_297_spider_verse_red },
{ "TWB64 298 - Baja Blast Beach", twb64_298_baja_blast_beach },
{ "TWB64 299 - 3DS Virtual Console Green", twb64_299_3ds_virtual_console_green },
{ "TWB64 300 - Wonder Purple", twb64_300_wonder_purple },
{ "PixelShift 01 - Arctic Green", pixelshift_01_arctic_green },
{ "PixelShift 02 - Arduboy", pixelshift_02_arduboy },
{ "PixelShift 03 - BGB 0.3 Emulator", pixelshift_03_bgb_0_3_emulator },

View File

@ -358,12 +358,15 @@ static unsigned palette_switch_counter = 0;
#define NUM_PALETTES_DEFAULT 51
#define NUM_PALETTES_TWB64_1 100
#define NUM_PALETTES_TWB64_2 100
#define NUM_PALETTES_TWB64_3 100
#define NUM_PALETTES_PIXELSHIFT_1 45
#define NUM_PALETTES_TOTAL (NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 + NUM_PALETTES_PIXELSHIFT_1)
#define NUM_PALETTES_TOTAL (NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 + \
NUM_PALETTES_TWB64_3 + NUM_PALETTES_PIXELSHIFT_1)
struct retro_core_option_value *palettes_default_opt_values = NULL;
struct retro_core_option_value *palettes_twb64_1_opt_values = NULL;
struct retro_core_option_value *palettes_twb64_2_opt_values = NULL;
struct retro_core_option_value *palettes_twb64_3_opt_values = NULL;
struct retro_core_option_value *palettes_pixelshift_1_opt_values = NULL;
static const char *internal_palette_labels[NUM_PALETTES_TOTAL] = {0};
@ -371,6 +374,7 @@ static const char *internal_palette_labels[NUM_PALETTES_TOTAL] = {0};
static size_t *palettes_default_index_map = NULL;
static size_t *palettes_twb64_1_index_map = NULL;
static size_t *palettes_twb64_2_index_map = NULL;
static size_t *palettes_twb64_3_index_map = NULL;
static size_t *palettes_pixelshift_1_index_map = NULL;
static void parse_internal_palette_values(const char *key,
@ -506,10 +510,17 @@ static void init_palette_switch(void)
NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1,
&palettes_twb64_2_opt_values,
&palettes_twb64_2_index_map);
/* > TWB64 Pack 3 palettes */
parse_internal_palette_values("gambatte_gb_palette_twb64_3",
opt_defs_intl, NUM_PALETTES_TWB64_3,
NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2,
&palettes_twb64_3_opt_values,
&palettes_twb64_3_index_map);
/* > PixelShift - Pack 1 palettes */
parse_internal_palette_values("gambatte_gb_palette_pixelshift_1",
opt_defs_intl, NUM_PALETTES_PIXELSHIFT_1,
NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2,
NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 +
NUM_PALETTES_TWB64_3,
&palettes_pixelshift_1_opt_values,
&palettes_pixelshift_1_index_map);
}
@ -524,11 +535,13 @@ static void deinit_palette_switch(void)
palettes_default_opt_values = NULL;
palettes_twb64_1_opt_values = NULL;
palettes_twb64_2_opt_values = NULL;
palettes_twb64_3_opt_values = NULL;
palettes_pixelshift_1_opt_values = NULL;
RHMAP_FREE(palettes_default_index_map);
RHMAP_FREE(palettes_twb64_1_index_map);
RHMAP_FREE(palettes_twb64_2_index_map);
RHMAP_FREE(palettes_twb64_3_index_map);
RHMAP_FREE(palettes_pixelshift_1_index_map);
}
@ -572,13 +585,26 @@ static void palette_switch_set_index(size_t palette_index)
palettes_ext_key = "gambatte_gb_palette_twb64_2";
palettes_ext_value = palettes_twb64_2_opt_values[opt_index].value;
}
else if (palette_index <
NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 +
NUM_PALETTES_TWB64_3)
{
/* This is a palette from the TWB64 Pack 3 group */
palettes_default_value = "TWB64 - Pack 3";
opt_index = palette_index -
(NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2);
palettes_ext_key = "gambatte_gb_palette_twb64_3";
palettes_ext_value = palettes_twb64_3_opt_values[opt_index].value;
}
else
{
/* This is a palette from the PixelShift Pack 1 group */
palettes_default_value = "PixelShift - Pack 1";
opt_index = palette_index -
(NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2);
(NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 +
NUM_PALETTES_TWB64_3);
palettes_ext_key = "gambatte_gb_palette_pixelshift_1";
palettes_ext_value = palettes_pixelshift_1_opt_values[opt_index].value;
}
@ -2007,6 +2033,22 @@ static void find_internal_palette(const unsigned short **palette, bool *is_gbc)
internal_palette_index = NUM_PALETTES_DEFAULT +
NUM_PALETTES_TWB64_1 + index;
}
else if (string_is_equal(var.value, "TWB64 - Pack 3"))
{
var.key = "gambatte_gb_palette_twb64_3";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
palette_title = var.value;
// Determine 'consolidated' palette index
if (palette_title)
index = RHMAP_GET_STR(palettes_twb64_3_index_map, palette_title);
if (index > 0)
index--;
internal_palette_index = NUM_PALETTES_DEFAULT +
NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 + index;
}
// Handle PixelShift packs
else if (string_is_equal(var.value, "PixelShift - Pack 1"))
{
@ -2021,8 +2063,8 @@ static void find_internal_palette(const unsigned short **palette, bool *is_gbc)
index = RHMAP_GET_STR(palettes_pixelshift_1_index_map, palette_title);
if (index > 0)
index--;
internal_palette_index = NUM_PALETTES_DEFAULT +
NUM_PALETTES_TWB64_1 + NUM_PALETTES_TWB64_2 + index;
internal_palette_index = NUM_PALETTES_DEFAULT + NUM_PALETTES_TWB64_1 +
NUM_PALETTES_TWB64_2 + NUM_PALETTES_TWB64_3 + index;
}
else
{