Skip to content

Commit

Permalink
validity.cpp: DIP switch validation updates
Browse files Browse the repository at this point in the history
- Permit DIP switch settings to be actually validated again by not clearing out DEF_STR map in validate_begin
- Allow duplicate settings for coinage DIP switches, at least for now
- Fix incorrect positioning of 5C_2C and 3C_5C in coinage settings list (likely a cut-and-paste error)
  • Loading branch information
ajrhacker committed Dec 29, 2024
1 parent 4c77c1a commit 7133d48
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/emu/ioport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ const struct
{ INPUT_STRING_4C_1C, "4 Coins/1 Credit" },
{ INPUT_STRING_3C_1C, "3 Coins/1 Credit" },
{ INPUT_STRING_8C_3C, "8 Coins/3 Credits" },
{ INPUT_STRING_4C_2C, "4 Coins/2 Credits" },
{ INPUT_STRING_5C_2C, "5 Coins/2 Credits" },
{ INPUT_STRING_4C_2C, "4 Coins/2 Credits" },
{ INPUT_STRING_2C_1C, "2 Coins/1 Credit" },
{ INPUT_STRING_5C_3C, "5 Coins/3 Credits" },
{ INPUT_STRING_3C_2C, "3 Coins/2 Credits" },
Expand All @@ -144,10 +144,10 @@ const struct
{ INPUT_STRING_3C_3C, "3 Coins/3 Credits" },
{ INPUT_STRING_2C_2C, "2 Coins/2 Credits" },
{ INPUT_STRING_1C_1C, "1 Coin/1 Credit" },
{ INPUT_STRING_3C_5C, "3 Coins/5 Credits" },
{ INPUT_STRING_4C_5C, "4 Coins/5 Credits" },
{ INPUT_STRING_3C_4C, "3 Coins/4 Credits" },
{ INPUT_STRING_2C_3C, "2 Coins/3 Credits" },
{ INPUT_STRING_3C_5C, "3 Coins/5 Credits" },
{ INPUT_STRING_4C_7C, "4 Coins/7 Credits" },
{ INPUT_STRING_2C_4C, "2 Coins/4 Credits" },
{ INPUT_STRING_1C_2C, "1 Coin/2 Credits" },
Expand Down
5 changes: 2 additions & 3 deletions src/emu/ioport.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ enum
INPUT_STRING_3C_1C, // 0.333333
INPUT_STRING_8C_3C, // 0.375000
// INPUT_STRING_10C_4C, // 0.400000
INPUT_STRING_5C_2C, // 0.400000
// INPUT_STRING_7C_3C, // 0.428571
// INPUT_STRING_9C_4C, // 0.444444
// INPUT_STRING_10C_5C, // 0.500000
// INPUT_STRING_8C_4C, // 0.500000
// INPUT_STRING_6C_3C, // 0.500000
INPUT_STRING_4C_2C, // 0.500000
INPUT_STRING_5C_2C, // 0.500000
INPUT_STRING_2C_1C, // 0.500000
// INPUT_STRING_9C_5C, // 0.555556
// INPUT_STRING_7C_4C, // 0.571429
Expand Down Expand Up @@ -174,7 +174,6 @@ enum
// INPUT_STRING_6C_7C, // 1.166667
// INPUT_STRING_5C_6C, // 1.200000
// INPUT_STRING_8C_10C, // 1.250000
INPUT_STRING_3C_5C, // 1.250000
INPUT_STRING_4C_5C, // 1.250000
// INPUT_STRING_7C_9C, // 1.285714
// INPUT_STRING_6C_8C, // 1.333333
Expand All @@ -186,7 +185,7 @@ enum
INPUT_STRING_2C_3C, // 1.500000
// INPUT_STRING_5C_8C, // 1.600000
// INPUT_STRING_6C_10C, // 1.666667
// INPUT_STRING_3C_5C, // 1.666667
INPUT_STRING_3C_5C, // 1.666667
INPUT_STRING_4C_7C, // 1.750000
// INPUT_STRING_5C_9C, // 1.800000
// INPUT_STRING_5C_10C, // 2.000000
Expand Down
15 changes: 11 additions & 4 deletions src/emu/validity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <type_traits>
#include <typeinfo>

#define ALLOW_DUPLICATE_DIPSETTINGS 1


namespace {

Expand Down Expand Up @@ -1953,11 +1955,10 @@ void validity_checker::validate_begin()
// take over error and warning outputs
osd_output::push(this);

// reset all our maps
// reset all our maps (except DEF_STRs)
m_names_map.clear();
m_descriptions_map.clear();
m_roms_map.clear();
m_defstr_map.clear();
m_region_map.clear();
m_ioport_set.clear();
m_slotcard_set.clear();
Expand Down Expand Up @@ -2395,6 +2396,8 @@ void validity_checker::validate_analog_input_field(const ioport_field &field)

void validity_checker::validate_dip_settings(const ioport_field &field)
{
assert(!m_defstr_map.empty());

char const *const demo_sounds = ioport_string_from_index(INPUT_STRING_Demo_Sounds);
char const *const flipscreen = ioport_string_from_index(INPUT_STRING_Flip_Screen);
char const *const name = field.specific_name() ? field.specific_name() : "UNNAMED";
Expand Down Expand Up @@ -2440,7 +2443,11 @@ void validity_checker::validate_dip_settings(const ioport_field &field)

// check for proper coin ordering
else if (strindex >= __input_string_coinage_start && strindex <= __input_string_coinage_end && next_strindex >= __input_string_coinage_start && next_strindex <= __input_string_coinage_end &&
#if ALLOW_DUPLICATE_DIPSETTINGS
strindex > next_strindex && setting->condition() == nextsetting->condition())
#else
strindex >= next_strindex && setting->condition() == nextsetting->condition())
#endif
{
osd_printf_error("%s option has unsorted coinage %s > %s\n", name, setting->name(), nextsetting->name());
coin_error = true;
Expand All @@ -2451,10 +2458,10 @@ void validity_checker::validate_dip_settings(const ioport_field &field)
// if we have a coin error, demonstrate the correct way
if (coin_error)
{
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, " Note proper coin sort order should be:\n");
osd_printf_warning("Note proper coin sort order should be:\n");
for (int entry = 0; entry < std::size(coin_list); entry++)
if (coin_list[entry])
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, " %s\n", ioport_string_from_index(__input_string_coinage_start + entry));
osd_printf_warning(" %s\n", ioport_string_from_index(__input_string_coinage_start + entry));
}
}

Expand Down

0 comments on commit 7133d48

Please sign in to comment.