From 878b0937f570788905577f93362d1b1ce558b228 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Thu, 1 Aug 2019 22:25:58 +0800 Subject: [PATCH] Update libretro_dipswitch.c --- src/drivers/libretro/libretro_dipswitch.c | 346 +++++++++++----------- src/git.h | 2 +- 2 files changed, 178 insertions(+), 170 deletions(-) diff --git a/src/drivers/libretro/libretro_dipswitch.c b/src/drivers/libretro/libretro_dipswitch.c index 4e3e148..fb778c5 100644 --- a/src/drivers/libretro/libretro_dipswitch.c +++ b/src/drivers/libretro/libretro_dipswitch.c @@ -11,6 +11,9 @@ #include "libretro_dipswitch.h" +#define MAX_CORE_OPTIONS 8 +#define MAX_VALUES 10 + extern CartInfo iNESCart; typedef struct { @@ -20,48 +23,47 @@ typedef struct { typedef struct { const char *option_name; - uint8 mask; - SETTING settings[10]; + SETTING settings[MAX_VALUES]; } DIPSWITCH; typedef struct { - unsigned gameid; - const char *romname_short; - DIPSWITCH dipswitch_core_options[8]; + unsigned game_id; + const char *game_name; + DIPSWITCH core_options[MAX_CORE_OPTIONS]; } VSUNIGAME; static VSUNIGAME dipswitch_battlecity = { VS_BATTLECITY, "battlecity", { - { "Credits for 2 Players", 0x01, + { "Credits for 2 Players", { { "2", 0x01 }, { "1", 0x00 }, { NULL, 0 }, }, }, - { "Lives", 0x02, + { "Lives", { { "5", 0x02 }, { "3", 0x00 }, { NULL, 0 }, }, }, - { "Demo Sounds", 0x04, + { "Demo Sounds", { { "disabled", 0x04 }, { "enabled", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, }, }; static VSUNIGAME dipswitch_castlevania = { VS_CASTLEVANIA, "castlevania", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -74,14 +76,14 @@ static VSUNIGAME dipswitch_castlevania = { { NULL, 0 }, }, }, - { "Lives", 0x08, + { "Lives", { { "3", 0x00 }, { "2", 0x08 }, { NULL, 0 }, } }, - { "Bonus", 0x30, + { "Bonus", { { "100k", 0x00 }, { "200k", 0x20 }, @@ -90,22 +92,21 @@ static VSUNIGAME dipswitch_castlevania = { { NULL, 0 }, }, }, - { "Difficulty", 0x40, + { "Difficulty", { { "Normal", 0x00 }, { "Hard", 0x40 }, { NULL, 0 }, }, }, - - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_clucluland = { VS_CLUCLULAND, "clucluland", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -118,7 +119,7 @@ static VSUNIGAME dipswitch_clucluland = { { NULL, 0 }, }, }, - { "Lives", 0x60, + { "Lives", { { "3", 0x00 }, { "4", 0x40 }, @@ -127,14 +128,14 @@ static VSUNIGAME dipswitch_clucluland = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_drmario = { VS_DRMARIO, "drmario", { - { "Drop Rate Increase After", 0x03, + { "Drop Rate Increase After", { { "7 Pills", 0x00 }, { "8 Pills", 0x01 }, @@ -143,7 +144,7 @@ static VSUNIGAME dipswitch_drmario = { { NULL, 0 }, }, }, - { "Virus Level", 0x0c, + { "Virus Level", { { "1", 0x00 }, { "3", 0x04 }, @@ -152,7 +153,7 @@ static VSUNIGAME dipswitch_drmario = { { NULL, 0 }, }, }, - { "Drop Speed Up", 0x30, + { "Drop Speed Up", { { "Slow", 0x00 }, { "Medium", 0x10 }, @@ -161,28 +162,28 @@ static VSUNIGAME dipswitch_drmario = { { NULL, 0 }, }, }, - { "Free Play", 0x40, + { "Free Play", { { "disabled", 0x00 }, { "enabled", 0x40 }, { NULL, 0 }, }, }, - { "Demo Sounds", 0x80, + { "Demo Sounds", { { "enabled", 0x80 }, { "disabled", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_duckhunt = { VS_DUCKHUNT, "duckhunt", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -195,7 +196,7 @@ static VSUNIGAME dipswitch_duckhunt = { { NULL, 0 }, }, }, - { "Difficulty", 0x18, + { "Difficulty", { { "Normal", 0x08 }, { "Medium", 0x10 }, @@ -204,14 +205,14 @@ static VSUNIGAME dipswitch_duckhunt = { { NULL, 0 }, }, }, - { "Miss per game", 0x20, + { "Miss per game", { { "5", 0x20 }, { "3", 0x00 }, { NULL, 0 }, }, }, - { "Bonus Life", 0xc0, + { "Bonus Life", { { "30000", 0x00 }, { "50000", 0x40 }, @@ -220,14 +221,14 @@ static VSUNIGAME dipswitch_duckhunt = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_excitebike = { VS_EXITEBIKE, "excitebike", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -240,7 +241,7 @@ static VSUNIGAME dipswitch_excitebike = { { NULL, 0 }, }, }, - { "Bonus Bike", 0x18, + { "Bonus Bike", { { "100k and Every 50k", 0x00 }, { "100k Only", 0x08 }, @@ -249,28 +250,28 @@ static VSUNIGAME dipswitch_excitebike = { { NULL, 0 }, }, }, - { "1st Qualifying Time", 0x20, + { "1st Qualifying Time", { { "Easy", 0x00 }, { "Hard", 0x20 }, { NULL, 0 }, }, }, - { "2nd Qualifying Time", 0x40, + { "2nd Qualifying Time", { { "Easy", 0x00 }, { "Hard", 0x40 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_freedomforce = { VS_FREEDOMFORCE, "freedomforce", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -283,7 +284,7 @@ static VSUNIGAME dipswitch_freedomforce = { { NULL, 0 }, }, }, - { "Health Awarded At", 0x18, + { "Health Awarded At", { { "10k 50k", 0x10 }, { "20k 60k", 0x00 }, @@ -292,7 +293,7 @@ static VSUNIGAME dipswitch_freedomforce = { { NULL, 0 }, }, }, - { "Difficulty (Damage)", 0x60, + { "Difficulty (Damage)", { { "Normal", 0x00 }, { "Easy", 0x40 }, @@ -301,21 +302,21 @@ static VSUNIGAME dipswitch_freedomforce = { { NULL, 0 }, }, }, - { "Difficulty (Enemy)", 0x80, + { "Difficulty (Enemy)", { { "Normal", 0x80 }, { "Hard", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_goonies = { VS_GOONIES, "goonies", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -328,14 +329,14 @@ static VSUNIGAME dipswitch_goonies = { { NULL, 0 }, }, }, - { "Lives", 0x08, + { "Lives", { { "3", 0x08 }, { "4", 0x00 }, { NULL, 0 }, }, }, - { "Bonus", 0x30, + { "Bonus", { { "40000", 0x00 }, { "50000", 0x20 }, @@ -344,28 +345,28 @@ static VSUNIGAME dipswitch_goonies = { { NULL, 0 }, }, }, - { "Timer", 0x40, + { "Timer", { { "Slow", 0x00 }, { "Fast", 0x40 }, { NULL, 0 }, }, }, - { "Demo Sounds", 0x80, + { "Demo Sounds", { { "enabled", 0x80 }, { "disabled", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_gradius = { VS_GRADIUS, "gradius", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -378,14 +379,14 @@ static VSUNIGAME dipswitch_gradius = { { NULL, 0 }, }, }, - { "Lives", 0x08, + { "Lives", { { "3", 0x08 }, { "4", 0x00 }, { NULL, 0 }, }, }, - { "Bonus", 0x30, + { "Bonus", { { "100k", 0x00 }, { "200k", 0x20 }, @@ -394,28 +395,28 @@ static VSUNIGAME dipswitch_gradius = { { NULL, 0 }, }, }, - { "Difficulty", 0x40, + { "Difficulty", { { "Normal", 0x00 }, { "Hard", 0x40 }, { NULL, 0 }, }, }, - { "Demo Sounds", 0x80, + { "Demo Sounds", { { "enabled", 0x80 }, { "disabled", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_gumshoe = { VS_GUMSHOE, "gumshoe", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -428,7 +429,7 @@ static VSUNIGAME dipswitch_gumshoe = { { NULL, 0 }, }, }, - { "Difficulty", 0x18, + { "Difficulty", { { "Normal", 0x08 }, { "Easy", 0x00 }, @@ -437,35 +438,35 @@ static VSUNIGAME dipswitch_gumshoe = { { NULL, 0 }, }, }, - { "Lives", 0x20, + { "Lives", { { "3", 0x20 }, { "5", 0x00 }, { NULL, 0 }, }, }, - { "Bullets per Balloon", 0x40, + { "Bullets per Balloon", { { "3", 0x00 }, { "2", 0x40 }, { NULL, 0 }, }, }, - { "Bonus Man Awarded", 0x80, + { "Bonus Man Awarded", { { "At 50000", 0x00 }, { "None", 0x80 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_hogansalley = { VS_HOGANSALLEY, "hogansalley", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -478,7 +479,7 @@ static VSUNIGAME dipswitch_hogansalley = { { NULL, 0 }, }, }, - { "Difficulty", 0x18, + { "Difficulty", { { "Normal", 0x08 }, { "Easy", 0x00 }, @@ -487,14 +488,14 @@ static VSUNIGAME dipswitch_hogansalley = { { NULL, 0 }, }, }, - { "Misses Per Game", 0x20, + { "Misses Per Game", { { "5", 0x20 }, { "3", 0x00 }, { NULL, 0 }, }, }, - { "Bonus Life", 0xc0, + { "Bonus Life", { { "30000", 0x00 }, { "50000", 0x40 }, @@ -503,14 +504,14 @@ static VSUNIGAME dipswitch_hogansalley = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_iceclimber = { VS_ICECLIMBER, "iceclimber", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -523,7 +524,7 @@ static VSUNIGAME dipswitch_iceclimber = { { NULL, 0 }, }, }, - { "Lives", 0x18, + { "Lives", { { "3", 0x00 }, { "4", 0x10 }, @@ -532,28 +533,28 @@ static VSUNIGAME dipswitch_iceclimber = { { NULL, 0 }, }, }, - { "Difficulty", 0x20, + { "Difficulty", { { "Easy", 0x00 }, { "Hard", 0x20 }, { NULL, 0 }, }, }, - { "Time before bear appears", 0x40, + { "Time before bear appears", { { "Long", 0x00 }, { "Short", 0x40 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_jajamaru = { VS_JAJAMARU, "jajamaru", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -566,7 +567,7 @@ static VSUNIGAME dipswitch_jajamaru = { { NULL, 0 }, }, }, - { "Lives", 0x18, + { "Lives", { { "3", 0x00 }, { "4", 0x10 }, @@ -574,21 +575,21 @@ static VSUNIGAME dipswitch_jajamaru = { { NULL, 0 }, }, }, - { "Demo Sounds", 0x80, + { "Demo Sounds", { { "enabled", 0x80 }, { "disabled", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_machrider = { VS_MACHRIDER, "machrider", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -601,7 +602,7 @@ static VSUNIGAME dipswitch_machrider = { { NULL, 0 }, }, }, - { "Time", 0x18, + { "Time", { { "280 (Easy)", 0x00 }, { "250", 0x10 }, @@ -610,21 +611,21 @@ static VSUNIGAME dipswitch_machrider = { { NULL, 0 }, }, }, - { "Enemies", 0x40, + { "Enemies", { { "Less", 0x00 }, { "More", 0x40 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_mightybj = { VS_MIGHTYBOMBJACK, "mightybj", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -637,7 +638,7 @@ static VSUNIGAME dipswitch_mightybj = { { NULL, 0 }, }, }, - { "Lives", 0x18, + { "Lives", { { "3", 0x00 }, { "4", 0x08 }, @@ -646,14 +647,14 @@ static VSUNIGAME dipswitch_mightybj = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_pinball = { VS_PINBALL, "pinball", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x01 }, { "1 Coin 2 Credits", 0x06 }, @@ -666,21 +667,21 @@ static VSUNIGAME dipswitch_pinball = { { NULL, 0 }, }, }, - { "Side Drain Walls", 0x08, + { "Side Drain Walls", { { "High", 0x00 }, { "Low", 0x08 }, { NULL, 0 }, }, }, - { "Bonus Life", 0x10, + { "Bonus Life", { { "50000", 0x00 }, { "70000", 0x10 }, { NULL, 0 }, }, }, - { "Balls", 0x60, + { "Balls", { { "3", 0x00 }, { "4", 0x40 }, @@ -689,28 +690,28 @@ static VSUNIGAME dipswitch_pinball = { { NULL, 0 }, } }, - { "Ball Speed", 0x80, + { "Ball Speed", { { "Slow", 0x00 }, { "Fast", 0x80 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_platoon = { VS_PLATOON, "platoon", { - { "Demo Sounds", 0x04, + { "Demo Sounds", { { "enabled", 0x00 }, { "disabled", 0x04 }, { NULL, 0 }, }, }, - { "Difficulty", 0x18, + { "Difficulty", { { "Normal", 0x08 }, { "Medium", 0x10 }, @@ -719,7 +720,7 @@ static VSUNIGAME dipswitch_platoon = { { NULL, 0 }, } }, - { "Coinage", 0xe0, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x20 }, @@ -732,14 +733,14 @@ static VSUNIGAME dipswitch_platoon = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_rbibaseball = { VS_RBIBASEBALL, "atari_rbibb", { - { "Coinage", 0x03, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x01 }, @@ -748,7 +749,7 @@ static VSUNIGAME dipswitch_rbibaseball = { { NULL, 0 }, }, }, - { "1p-inn 2p-inn time-min", 0x0c, + { "1p-inn 2p-inn time-min", { { "2 2 4", 0x0c }, { "3 2 6", 0x00 }, @@ -757,21 +758,21 @@ static VSUNIGAME dipswitch_rbibaseball = { { NULL, 0 }, } }, - { "Demo Sounds", 0x10, + { "Demo Sounds", { { "enabled", 0x00 }, { "disabled", 0x10 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_slalom = { VS_SLALOM, "slalom", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -784,14 +785,14 @@ static VSUNIGAME dipswitch_slalom = { { NULL, 0 }, }, }, - { "Freestyle Points", 0x08, + { "Freestyle Points", { { "Hold Time", 0x08 }, { "Left Right", 0x00 }, { NULL, 0 }, }, }, - { "Difficulty", 0x30, + { "Difficulty", { { "Normal", 0x10 }, { "Medium", 0x20 }, @@ -800,28 +801,28 @@ static VSUNIGAME dipswitch_slalom = { { NULL, 0 }, }, }, - { "Allow Continue", 0x40, + { "Allow Continue", { { "enabled", 0x00 }, { "disabled", 0x40 }, { NULL, 0 }, }, }, - { "Inverted Input", 0x80, + { "Inverted Input", { { "disabled", 0x00 }, { "enabled", 0x80 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_smb = { VS_SMB, "smb", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x06 }, @@ -834,14 +835,14 @@ static VSUNIGAME dipswitch_smb = { { NULL, 0 }, }, }, - { "Lives", 0x08, + { "Lives", { { "3", 0x00 }, { "2", 0x08 }, { NULL, 0 }, }, }, - { "Bonus Life", 0x30, + { "Bonus Life", { { "100 coins", 0x00 }, { "150 coins", 0x20 }, @@ -850,28 +851,28 @@ static VSUNIGAME dipswitch_smb = { { NULL, 0 }, }, }, - { "Timer", 0x40, + { "Timer", { { "Slow", 0x00 }, { "Fast", 0x40 }, { NULL, 0 }, }, }, - { "Continue Lives", 0x80, + { "Continue Lives", { { "3", 0x80 }, { "4", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_soccer = { VS_SOCCER, "soccer", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -884,7 +885,7 @@ static VSUNIGAME dipswitch_soccer = { { NULL, 0 }, }, }, - { "Points Timer", 0x18, + { "Points Timer", { { "1000 Pts", 0x08 }, { "1200 Pts", 0x18 }, @@ -893,7 +894,7 @@ static VSUNIGAME dipswitch_soccer = { { NULL, 0 }, }, }, - { "Difficulty", 0x60, + { "Difficulty", { { "Normal", 0x40 }, { "Medium", 0x20 }, @@ -902,14 +903,14 @@ static VSUNIGAME dipswitch_soccer = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_starluster = { VS_STARLUSTER, "starluster", { - { "Coinage", 0x03, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x02 }, @@ -918,14 +919,14 @@ static VSUNIGAME dipswitch_starluster = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_superskykid = { VS_SUPERSKYKID, "superskykid", { - { "Difficulty", 0x03, + { "Difficulty", { { "Normal", 0x01 }, @@ -935,14 +936,14 @@ static VSUNIGAME dipswitch_superskykid = { { NULL, 0 }, } }, - { "Lives", 0x04, + { "Lives", { { "3", 0x04 }, { "2", 0x00 }, { NULL, 0 }, }, }, - { "Coinage", 0x18, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x08 }, @@ -951,14 +952,14 @@ static VSUNIGAME dipswitch_superskykid = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_superxevious = { VS_SUPERXEVIOUS, "superxevious", { - { "Coinage", 0x30, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x10 }, @@ -967,14 +968,14 @@ static VSUNIGAME dipswitch_superxevious = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_tetris = { VS_TETRIS, "tetris", { - { "Difficulty", 0x0c, + { "Difficulty", { { "Normal", 0x04 }, { "Medium", 0x08 }, @@ -983,14 +984,14 @@ static VSUNIGAME dipswitch_tetris = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_tkoboxing = { VS_TKOBOXING, "tkoboxing", { - { "Coinage", 0x03, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x01 }, @@ -999,7 +1000,7 @@ static VSUNIGAME dipswitch_tkoboxing = { { NULL, 0 }, }, }, - { "Difficulty", 0x0c, + { "Difficulty", { { "Normal", 0x04 }, { "Hard", 0x08 }, @@ -1008,14 +1009,14 @@ static VSUNIGAME dipswitch_tkoboxing = { { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; static VSUNIGAME dipswitch_topgun = { VS_TOPGUN, "topgun", { - { "Coinage", 0x07, + { "Coinage", { { "1 Coin 1 Credit", 0x00 }, { "1 Coin 2 Credits", 0x04 }, @@ -1028,14 +1029,14 @@ static VSUNIGAME dipswitch_topgun = { { NULL, 0 }, }, }, - { "Lives per Coin", 0x08, + { "Lives per Coin", { { "3-12 Max", 0x00 }, { "2-9 Max", 0x08 }, { NULL, 0 }, }, }, - { "Bonus Life", 0x30, + { "Bonus Life", { { "30k and Every 50k", 0x00 }, { "50k and Every 100k", 0x20 }, @@ -1044,26 +1045,24 @@ static VSUNIGAME dipswitch_topgun = { { NULL, 0 }, }, }, - { "Difficulty", 0x40, + { "Difficulty", { { "Easy", 0x00 }, { "Hard", 0x40 }, { NULL, 0 }, }, }, - { "Demo Sounds", 0x80, + { "Demo Sounds", { { "enabled", 0x80 }, { "disabled", 0x00 }, { NULL, 0 }, }, }, - { NULL, 0, { {0} } } + { NULL, { {0} } }, } }; -#define DPSW_MAX 6 - enum { DPSW_NONE = 0, DPSW_VSUNI, @@ -1074,11 +1073,14 @@ static struct retro_core_option_definition option_defs_empty = { NULL, NULL, NULL, { {0} }, NULL }; -static struct retro_core_option_definition vscoreopt[DPSW_MAX]; +static struct retro_core_option_definition vscoreopt[MAX_CORE_OPTIONS]; static VSUNIGAME *vsgame = NULL; -static char *core_key[DPSW_MAX]; -static unsigned num_core_options; + +static char *core_key[MAX_CORE_OPTIONS]; static unsigned dipswitch_type = DPSW_NONE; +static unsigned numCoreOptions = 0; +static unsigned numValues[MAX_VALUES] = {0}; +static uint8 dipswitchPreset = 0; static const char *str_to_corekey(char *s) { @@ -1096,40 +1098,39 @@ static const char *str_to_corekey(char *s) return str; } -static void make_core_options(struct retro_core_option_definition *opt) +static void make_core_options(struct retro_core_option_definition *vs_core_options) { unsigned i, j; - for (i = 0; i < num_core_options; i++) + for (i = 0; i < numCoreOptions; i++) { struct retro_core_option_value vars_empty = { NULL, NULL }; - const char *romname_short = vsgame->romname_short; - const char *option_name = vsgame->dipswitch_core_options[i].option_name; + const char *game_name = vsgame->game_name; + const char *option_name = vsgame->core_options[i].option_name; char key[100] = {0}; /* Set core key and sanitize string */ - sprintf(key, "fceumm_dipswitch_%s-%s", romname_short, option_name); + sprintf(key, "fceumm_dipswitch_%s-%s", game_name, option_name); core_key[i] = calloc(strlen(key) + 1, sizeof(char)); strcpy(core_key[i], key); - opt[i].key = str_to_corekey(core_key[i]); + vs_core_options[i].key = str_to_corekey(core_key[i]); /* Set desc */ - opt[i].desc = option_name; + vs_core_options[i].desc = option_name; /* Set info */ - opt[i].info = NULL; + vs_core_options[i].info = NULL; - j = 0; /* Set core values */ - while (vsgame->dipswitch_core_options[i].settings[j].name) { - const char *var_value = vsgame->dipswitch_core_options[i].settings[j].name; - opt[i].values[j].value = var_value; - j++; + for (j = 0; j < numValues[i]; j++) { + const char *var_value = vsgame->core_options[i].settings[j].name; + vs_core_options[i].values[j].value = var_value; } - opt[i].values[j] = vars_empty; + + vs_core_options[i].values[j] = vars_empty; /* Set default value. Top entry used as default */ - opt[i].default_value = vsgame->dipswitch_core_options[i].settings[0].name; + vs_core_options[i].default_value = vsgame->core_options[i].settings[0].name; } } @@ -1201,9 +1202,10 @@ static VSUNIGAME *get_vsuni_dipswitch(unsigned id) static void update_dipswitch_vsuni(void) { unsigned index_key; - uint8 vsdip_new = FCEUI_VSUniGetDIPs(); + uint8 vsdip_new = 0; + uint8 last_vsdip = FCEUI_VSUniGetDIPs(); - for (index_key = 0; index_key < num_core_options; index_key++) + for (index_key = 0; index_key < numCoreOptions; index_key++) { struct retro_variable var = { NULL, NULL }; const char *key = vscoreopt[index_key].key; @@ -1213,25 +1215,21 @@ static void update_dipswitch_vsuni(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) == 0) continue; - index_value = 0; - while (vscoreopt[index_key].values[index_value].value) + for (index_value = 0; index_value < numValues[index_key]; index_value++) { const char *var_value = vscoreopt[index_key].values[index_value].value; - uint8 value, mask; + uint8 value = 0; - if (strcmp(var.value, var_value) != 0) { - index_value++; + if (strcmp(var.value, var_value) != 0) continue; - } - value = vsgame->dipswitch_core_options[index_key].settings[index_value].value; - mask = vsgame->dipswitch_core_options[index_key].mask; - vsdip_new &= (~mask); + + value = vsgame->core_options[index_key].settings[index_value].value; vsdip_new |= value; - index_value++; } } - if (FCEUI_VSUniGetDIPs() != vsdip_new) + vsdip_new |= dipswitchPreset; /* Append any default preset to new value */ + if (last_vsdip != vsdip_new) { vsdip = vsdip_new; #ifdef DEBUG @@ -1327,24 +1325,33 @@ size_t set_dipswitch_variables(unsigned current_index, struct retro_core_option_ /* VSUNI Dipswitch */ if (GameInfo->type == GIT_VSUNI) { + dipswitchPreset = FCEUI_VSUniGetDIPs(); vsgame = get_vsuni_dipswitch(GameInfo->gameid); if (vsgame) { - unsigned i; + unsigned i, j; - num_core_options = 0; + numCoreOptions = 0; dipswitch_type = DPSW_VSUNI; - /* Initialize dipswitch struct and count number of core options */ - for (i = 0; i < DPSW_MAX; i++) { + /* Initialize dipswitch struct with empty values */ + for (i = 0; i < MAX_CORE_OPTIONS; i++) vscoreopt[i] = option_defs_empty; - if (vsgame->dipswitch_core_options[i].option_name) - num_core_options++; + + /* Count number of core options and the number of values for each */ + for (i = 0; i < MAX_CORE_OPTIONS; i++) { + if (vsgame->core_options[i].option_name) { + for (j = 0; j < MAX_VALUES; j++) { + if (vsgame->core_options[i].settings[j].name) + numValues[i]++; + } + numCoreOptions++; + } } make_core_options(vscoreopt); - /* Copy dpsw struct to main core option struct */ + /* Append dipswitch struct to main core options struct */ while (vscoreopt[dipsw_size].key) { vars[index] = vscoreopt[dipsw_size]; index++; @@ -1367,7 +1374,8 @@ size_t set_dipswitch_variables(unsigned current_index, struct retro_core_option_ return (dipsw_size); } - return (0); + dipswitch_type = DPSW_NONE; + return (0); } void update_dipswitch(void) @@ -1386,7 +1394,7 @@ void DPSW_Cleanup(void) { unsigned i; - for (i = 0; i < DPSW_MAX; i++) { + for (i = 0; i < MAX_CORE_OPTIONS; i++) { if (core_key[i]) { free(core_key[i]); core_key[i] = NULL; diff --git a/src/git.h b/src/git.h index 913ac60..d14e792 100644 --- a/src/git.h +++ b/src/git.h @@ -25,7 +25,7 @@ typedef struct { uint8 MD5[16]; int soundrate; /* For Ogg Vorbis expansion sound wacky support. 0 for default. */ int soundchan; /* Number of sound channels. */ - int gameid; /* VS game id for per-game settings e.g. dip switches */ + int gameid; /* Currently used for VS game id for per-game dipswitch */ } FCEUGI; #endif