summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/validity.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2026-05-10 03:07:34 +1000
committer Vas Crabb <vas@vastheman.com>2026-05-10 03:34:22 +1000
commitd6dd21e2013c80ecbc97dc3cce3df964e8e4c2aa (patch)
tree8a42e21bf7ed3fe4bad8769fcd8aa52b8469a48c /src/emu/validity.cpp
parent937399619268781d75a0f04edf5b2fd9e247ce38 (diff)
ui: Improved media control experience, cleaned up a lot of bad code.
ui/imgcntrl, ui/floppycntrl.cpp: Completely reworked logic - backtracking through menus is more intuitive, and more context is retained when encountering an error (it should be a bit easier to follow the code as well). ui/floppycntrl.cpp: Don't show the initial content selection menu when opening an image to read from while writing to a separate file. ui/filecreate.cpp: Moved the logic to enumerate floppy formats into the menu, use headings and separators, use callbacks to notify when an item is selected, don't pop menus when an item is selected, avoid actual work in destructors. ui/midiinout.cpp: Fixed infinite growth when repopulating the menu, don't pop the menu when a port is chosen, use a callback to notify that a port is chosen, use headings and separators, and in informative placeholder if no ports are available. ui/filesel.cpp: Don't show the option to write to a floppy diff (it still isn't implemented, it can be re-added if it's ever implemented), don't pop the menus when selecting an item, avoid actual work in destructors. ui/filemngr.cpp: Show more detail in the info box below the menu for software items and presets, substantially simplified the code for walking media devices. ui/info.cpp: Got rid of the media information menu, added media information to the system information menu. ui/menu.cpp: Allow immediately adjusting the hovered item with pen/mouse, saving a click. emu/ioport: Fixed incorrect strings displayed for 4C_5C, 3C_4C, 2C_3C and 3C_5C. The array absolutely must stay in order. Also added an assertion to catch these errors early. emu/ioport.cpp: Use a much less gross method of handling default strings (apparently someone forgot about function overloading). emu/ioport.cpp: Retired the crosshair mapper member macros - they don't serve much purpose. util/zippath.cpp: Actually report a failure to open a plain file rather than looking for files inside non-existent archives, making every error turn into "file not found". formats/flopimg.cpp: Allow matching extensions on string object names, rather than requiring a NUL-terminated string.
Diffstat (limited to 'src/emu/validity.cpp')
-rw-r--r--src/emu/validity.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index b65e1faf3c9..e93ee223be4 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -117,17 +117,6 @@ struct pure_virtual_base
//-------------------------------------------------
-// ioport_string_from_index - return an indexed
-// string from the I/O port system
-//-------------------------------------------------
-
-inline char const *ioport_string_from_index(u32 index)
-{
- return ioport_configurer::string_from_token(reinterpret_cast<char const *>(uintptr_t(index)));
-}
-
-
-//-------------------------------------------------
// random_u64
// random_s64
// random_u32
@@ -1894,13 +1883,13 @@ void validate_delegates_functoid()
// strings
//-------------------------------------------------
-inline int validity_checker::get_defstr_index(const char *string, bool suppress_error)
+inline input_string_index validity_checker::get_defstr_index(const char *string, bool suppress_error)
{
// check for strings that should be DEF_STR
- auto strindex = m_defstr_map.find(string);
- if (!suppress_error && strindex != m_defstr_map.end() && string != ioport_string_from_index(strindex->second))
+ auto const strindex = m_defstr_map.find(string);
+ if (!suppress_error && (strindex != m_defstr_map.end()) && (string != ioport_configurer::string_from_token(strindex->second)))
osd_printf_error("Must use DEF_STR( %s )\n", string);
- return (strindex != m_defstr_map.end()) ? strindex->second : 0;
+ return (strindex != m_defstr_map.end()) ? strindex->second : input_string_index(0);
}
@@ -1978,9 +1967,9 @@ validity_checker::validity_checker(emu_options &options, bool quick)
// pre-populate the defstr map with all the default strings
for (int strnum = 1; strnum < INPUT_STRING_COUNT; strnum++)
{
- const char *string = ioport_string_from_index(strnum);
+ const char *string = ioport_configurer::string_from_token(input_string_index(strnum));
if (string != nullptr)
- m_defstr_map.insert(std::make_pair(string, strnum));
+ m_defstr_map.emplace(string, input_string_index(strnum));
}
}
@@ -2579,8 +2568,8 @@ void validity_checker::validate_analog_input_field(const ioport_field &field)
void validity_checker::validate_dip_settings(const ioport_field &field)
{
- 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 demo_sounds = ioport_configurer::string_from_token(INPUT_STRING_Demo_Sounds);
+ char const *const flipscreen = ioport_configurer::string_from_token(INPUT_STRING_Flip_Screen);
char const *const name = field.specific_name() ? field.specific_name() : "UNNAMED";
u8 coin_list[__input_string_coinage_end + 1 - __input_string_coinage_start] = { 0 };
bool coin_error = false;
@@ -2589,7 +2578,7 @@ void validity_checker::validate_dip_settings(const ioport_field &field)
for (auto setting = field.settings().begin(); field.settings().end() != setting; ++setting)
{
// note any coinage strings
- int strindex = get_defstr_index(setting->name());
+ input_string_index const strindex = get_defstr_index(setting->name());
if (strindex >= __input_string_coinage_start && strindex <= __input_string_coinage_end)
coin_list[strindex - __input_string_coinage_start] = 1;
@@ -2610,7 +2599,7 @@ void validity_checker::validate_dip_settings(const ioport_field &field)
if (field.settings().end() != nextsetting)
{
// check for inverted off/on DIP switch order
- int next_strindex = get_defstr_index(nextsetting->name(), true);
+ input_string_index next_strindex = get_defstr_index(nextsetting->name(), true);
if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off)
osd_printf_error("%s option must have Off/On options in the order: Off, On\n", name);
@@ -2638,7 +2627,7 @@ void validity_checker::validate_dip_settings(const ioport_field &field)
output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, " 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));
+ output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, " %s\n", ioport_configurer::string_from_token(input_string_index(__input_string_coinage_start + entry)));
}
}