From 313f69daaf4c60de1f294949fa6e8a8bd55bcf49 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Thu, 1 Aug 2019 20:02:17 +0800 Subject: [PATCH 1/3] Silence warning and fix missing NULL terminators on core option struct - silence warning: missing braces around initializer [-Wmissing-braces] --- src/drivers/libretro/libretro_core_options.h | 4 +- src/drivers/libretro/libretro_dipswitch.c | 88 +++++++++++--------- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/src/drivers/libretro/libretro_core_options.h b/src/drivers/libretro/libretro_core_options.h index 1d160ae..39760bd 100644 --- a/src/drivers/libretro/libretro_core_options.h +++ b/src/drivers/libretro/libretro_core_options.h @@ -318,11 +318,11 @@ struct retro_core_option_definition option_defs_common[] = { }, #endif - { NULL, NULL, NULL, { NULL, NULL }, NULL }, + { NULL, NULL, NULL, { {0} }, NULL }, }; struct retro_core_option_definition option_defs_empty = { - NULL, NULL, NULL, { NULL, NULL }, NULL + NULL, NULL, NULL, { {0} }, NULL }; struct retro_core_option_definition option_defs_us[MAX_CORE_OPTIONS]; diff --git a/src/drivers/libretro/libretro_dipswitch.c b/src/drivers/libretro/libretro_dipswitch.c index 5f5f099..4e3e148 100644 --- a/src/drivers/libretro/libretro_dipswitch.c +++ b/src/drivers/libretro/libretro_dipswitch.c @@ -54,7 +54,7 @@ static VSUNIGAME dipswitch_battlecity = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } }, }; @@ -77,8 +77,8 @@ static VSUNIGAME dipswitch_castlevania = { { "Lives", 0x08, { { "3", 0x00 }, - { "2", 0x08 } - + { "2", 0x08 }, + { NULL, 0 }, } }, { "Bonus", 0x30, @@ -98,7 +98,7 @@ static VSUNIGAME dipswitch_castlevania = { }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -127,7 +127,7 @@ static VSUNIGAME dipswitch_clucluland = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -139,7 +139,8 @@ static VSUNIGAME dipswitch_drmario = { { "7 Pills", 0x00 }, { "8 Pills", 0x01 }, { "9 Pills", 0x02 }, - { "10 Pills", 0x03 } + { "10 Pills", 0x03 }, + { NULL, 0 }, }, }, { "Virus Level", 0x0c, @@ -147,7 +148,8 @@ static VSUNIGAME dipswitch_drmario = { { "1", 0x00 }, { "3", 0x04 }, { "5", 0x08 }, - { "7", 0x0c } + { "7", 0x0c }, + { NULL, 0 }, }, }, { "Drop Speed Up", 0x30, @@ -155,13 +157,15 @@ static VSUNIGAME dipswitch_drmario = { { "Slow", 0x00 }, { "Medium", 0x10 }, { "Fast", 0x20 }, - { "Fastest", 0x30 } + { "Fastest", 0x30 }, + { NULL, 0 }, }, }, { "Free Play", 0x40, { { "disabled", 0x00 }, - { "enabled", 0x40 } + { "enabled", 0x40 }, + { NULL, 0 }, }, }, { "Demo Sounds", 0x80, @@ -171,7 +175,7 @@ static VSUNIGAME dipswitch_drmario = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -216,7 +220,7 @@ static VSUNIGAME dipswitch_duckhunt = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -259,7 +263,7 @@ static VSUNIGAME dipswitch_excitebike = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -304,7 +308,7 @@ static VSUNIGAME dipswitch_freedomforce = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -354,7 +358,7 @@ static VSUNIGAME dipswitch_goonies = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -404,7 +408,7 @@ static VSUNIGAME dipswitch_gradius = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -454,7 +458,7 @@ static VSUNIGAME dipswitch_gumshoe = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -499,7 +503,7 @@ static VSUNIGAME dipswitch_hogansalley = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -542,7 +546,7 @@ static VSUNIGAME dipswitch_iceclimber = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -577,7 +581,7 @@ static VSUNIGAME dipswitch_jajamaru = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -613,7 +617,7 @@ static VSUNIGAME dipswitch_machrider = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -639,9 +643,10 @@ static VSUNIGAME dipswitch_mightybj = { { "4", 0x08 }, { "5", 0x18 }, { "2", 0x10 }, + { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -681,6 +686,7 @@ static VSUNIGAME dipswitch_pinball = { { "4", 0x40 }, { "5", 0x20 }, { "2", 0x60 }, + { NULL, 0 }, } }, { "Ball Speed", 0x80, @@ -690,7 +696,7 @@ static VSUNIGAME dipswitch_pinball = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -710,6 +716,7 @@ static VSUNIGAME dipswitch_platoon = { { "Medium", 0x10 }, { "Hard", 0x18 }, { "Easy", 0x00 }, + { NULL, 0 }, } }, { "Coinage", 0xe0, @@ -725,7 +732,7 @@ static VSUNIGAME dipswitch_platoon = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -747,6 +754,7 @@ static VSUNIGAME dipswitch_rbibaseball = { { "3 2 6", 0x00 }, { "4 3 7", 0x08 }, { "2 1 3", 0x04 }, + { NULL, 0 }, } }, { "Demo Sounds", 0x10, @@ -756,7 +764,7 @@ static VSUNIGAME dipswitch_rbibaseball = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -806,7 +814,7 @@ static VSUNIGAME dipswitch_slalom = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -856,7 +864,7 @@ static VSUNIGAME dipswitch_smb = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -894,7 +902,7 @@ static VSUNIGAME dipswitch_soccer = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -910,7 +918,7 @@ static VSUNIGAME dipswitch_starluster = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -924,6 +932,7 @@ static VSUNIGAME dipswitch_superskykid = { { "Medium", 0x02 }, { "Hard", 0x03 }, { "Easy", 0x00 }, + { NULL, 0 }, } }, { "Lives", 0x04, @@ -942,7 +951,7 @@ static VSUNIGAME dipswitch_superskykid = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -958,7 +967,7 @@ static VSUNIGAME dipswitch_superxevious = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -971,9 +980,10 @@ static VSUNIGAME dipswitch_tetris = { { "Medium", 0x08 }, { "Hard", 0x0c }, { "Easy", 0x00 }, + { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -995,9 +1005,10 @@ static VSUNIGAME dipswitch_tkoboxing = { { "Hard", 0x08 }, { "Very Hard", 0x0c }, { "Easy", 0x00 }, + { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -1047,7 +1058,7 @@ static VSUNIGAME dipswitch_topgun = { { NULL, 0 }, }, }, - { NULL, 0, { NULL, 0 } } + { NULL, 0, { {0} } } } }; @@ -1060,7 +1071,7 @@ enum { }; static struct retro_core_option_definition option_defs_empty = { - NULL, NULL, NULL, { NULL, NULL }, NULL + NULL, NULL, NULL, { {0} }, NULL }; static struct retro_core_option_definition vscoreopt[DPSW_MAX]; @@ -1094,12 +1105,11 @@ static void make_core_options(struct retro_core_option_definition *opt) 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; - unsigned num_values = 0, len = 0; char key[100] = {0}; /* Set core key and sanitize string */ - len = sprintf(key, "fceumm_dipswitch_%s-%s", romname_short, option_name); - core_key[i] = calloc(len + 1, sizeof(char)); + sprintf(key, "fceumm_dipswitch_%s-%s", romname_short, 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]); @@ -1279,7 +1289,7 @@ static struct retro_core_option_definition dipswitch_nwc[] = { "disabled", }, - { NULL, NULL, NULL, { NULL, NULL }, NULL }, + { NULL, NULL, NULL, { {0} }, NULL }, }; static void update_dipswitch_nwc(void) @@ -1320,7 +1330,7 @@ size_t set_dipswitch_variables(unsigned current_index, struct retro_core_option_ vsgame = get_vsuni_dipswitch(GameInfo->gameid); if (vsgame) { - unsigned i, j; + unsigned i; num_core_options = 0; dipswitch_type = DPSW_VSUNI; From d807bac15b433b849aa2a3c49cec45453448d339 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Thu, 1 Aug 2019 20:31:42 +0800 Subject: [PATCH 2/3] Remove unused variables --- src/boards/411120-c.c | 2 +- src/boards/69.c | 1 - src/boards/8157.c | 1 - src/boards/KS7032.c | 2 +- src/boards/bmc80013b.c | 2 +- src/boards/mmc3.c | 3 --- src/boards/resettxrom.c | 2 -- src/boards/t-262.c | 1 - src/boards/vrc2and4.c | 12 ++---------- src/vsuni.c | 11 ++++------- 10 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/boards/411120-c.c b/src/boards/411120-c.c index 765ce19..a21a898 100644 --- a/src/boards/411120-c.c +++ b/src/boards/411120-c.c @@ -32,7 +32,7 @@ #include "mmc3.h" static uint8 reset_flag = 0; -static uint8 chip, isK3088; +static uint8 isK3088; static void BMC411120CCW(uint32 A, uint8 V) { uint32 mask = isK3088 ? 0x07 : 0x03; diff --git a/src/boards/69.c b/src/boards/69.c index 2a7093b..3117106 100644 --- a/src/boards/69.c +++ b/src/boards/69.c @@ -135,7 +135,6 @@ static DECLFW(M69SWrite0) { } static DECLFW(M69SWrite1) { - int x; GameExpSound.Fill = AYSound; GameExpSound.HiFill = AYSoundHQ; switch (sndcmd) { diff --git a/src/boards/8157.c b/src/boards/8157.c index b81c05f..eb9224f 100644 --- a/src/boards/8157.c +++ b/src/boards/8157.c @@ -23,7 +23,6 @@ #include "mapinc.h" -static uint8 chip; static uint16 cmdreg; static uint8 reset; static SFORMAT StateRegs[] = diff --git a/src/boards/KS7032.c b/src/boards/KS7032.c index 41739af..8e123e5 100644 --- a/src/boards/KS7032.c +++ b/src/boards/KS7032.c @@ -31,7 +31,7 @@ #include "mapinc.h" -static uint8 reg[8], creg[8], mirr, cmd, IRQa = 0, isirqused = 0; +static uint8 reg[8], creg[8], mirr, cmd, IRQa = 0; static int32 IRQCount, IRQLatch; static uint8 KS7032; static uint8 *WRAM = NULL; diff --git a/src/boards/bmc80013b.c b/src/boards/bmc80013b.c index ddf413e..2966bde 100644 --- a/src/boards/bmc80013b.c +++ b/src/boards/bmc80013b.c @@ -37,7 +37,7 @@ static void Sync(void) { if (mode & 0x02) setprg16(0x8000, (regs[0] & 0x0F) | (regs[1] & 0x70)); else - setprg16(0x8000, regs[0] & 0x0F | 0x80); + setprg16(0x8000, (regs[0] & 0x0F) | 0x80); setprg16(0xC000, regs[1]); setmirror(((regs[0] >> 4) & 1) ^ 1); } diff --git a/src/boards/mmc3.c b/src/boards/mmc3.c index 3c9d42a..5c498fc 100644 --- a/src/boards/mmc3.c +++ b/src/boards/mmc3.c @@ -44,8 +44,6 @@ uint8 mmc3opts = 0; uint8 IRQCount, IRQLatch, IRQa; uint8 IRQReload; -static uint8 chip; - static SFORMAT MMC3_StateRegs[] = { { DRegBuf, 8, "REGS" }, @@ -1198,7 +1196,6 @@ void Mapper198_Init(CartInfo *info) { /* ---------------------------- Mapper 205 ------------------------------ */ /* UNIF boardname BMC-JC-016-2 https://wiki.nesdev.com/w/index.php/INES_Mapper_205 */ -static uint8 block[] = {0, 0, 1, 2}; static void M205PW(uint32 A, uint8 V) { uint8 bank = V & ((EXPREGS[0] & 0x02) ? 0x0F : 0x1F); diff --git a/src/boards/resettxrom.c b/src/boards/resettxrom.c index 8bef280..910c8a2 100644 --- a/src/boards/resettxrom.c +++ b/src/boards/resettxrom.c @@ -27,8 +27,6 @@ #include "mapinc.h" #include "mmc3.h" -static uint8 chip; - static void M313CW(uint32 A, uint8 V) { setchr1(A, (EXPREGS[0] << 7) | (V & 0x7F)); } diff --git a/src/boards/t-262.c b/src/boards/t-262.c index 5aaa515..ae8c818 100644 --- a/src/boards/t-262.c +++ b/src/boards/t-262.c @@ -20,7 +20,6 @@ #include "mapinc.h" -static uint8 chip; static uint8 bank, base, lock, mirr, mode; static SFORMAT StateRegs[] = { diff --git a/src/boards/vrc2and4.c b/src/boards/vrc2and4.c index b26d804..9749d48 100644 --- a/src/boards/vrc2and4.c +++ b/src/boards/vrc2and4.c @@ -31,7 +31,6 @@ static uint8 prgreg[2], chrreg[8]; static uint16 chrhi[8]; static uint8 regcmd, irqcmd, mirr, big_bank; static uint16 acount = 0; -static uint16 weirdo = 0; static uint8 *WRAM = NULL; static uint32 WRAMSIZE; @@ -65,15 +64,8 @@ static void Sync(void) { setchr8(0); else { uint8 i; - /* if (!weirdo) */ - for (i = 0; i < 8; i++) - setchr1(i << 10, (chrhi[i] | chrreg[i]) >> is22); - /* else { - setchr1(0x0000, 0xFC); - setchr1(0x0400, 0xFD); - setchr1(0x0800, 0xFF); - weirdo--; - } */ + for (i = 0; i < 8; i++) + setchr1(i << 10, (chrhi[i] | chrreg[i]) >> is22); } switch (mirr & 0x3) { case 0: setmirror(MI_V); break; diff --git a/src/vsuni.c b/src/vsuni.c index 6c7dc1c..6645046 100644 --- a/src/vsuni.c +++ b/src/vsuni.c @@ -309,13 +309,10 @@ void FCEU_VSUniCheck(uint64 md5partial, int *MapperNo, uint8 *Mirroring) { secptr = 0; - { - static int64 tko = 0x6e1ee06171d8ce3aULL, rbi = 0x6a02d345812938afULL; - if (vs->gameid & VS_TKOBOXING) - secptr = secdata[0]; - if (md5partial == rbi) - secptr = secdata[1]; - } + if (vs->gameid & VS_TKOBOXING) + secptr = secdata[0]; + if (vs->gameid & VS_RBIBASEBALL) + secptr = secdata[1]; vsdip = 0x0; if (vs->ioption & IOPTION_PREDIP) { From 878b0937f570788905577f93362d1b1ce558b228 Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Thu, 1 Aug 2019 22:25:58 +0800 Subject: [PATCH 3/3] 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