summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2026-03-22 01:27:52 +1100
committer Vas Crabb <vas@vastheman.com>2026-03-22 01:27:52 +1100
commit237d736a31062763d8d24658a52a1fc52e944dc5 (patch)
tree331503893e9b56df1969e208344191c53c4f3a36 /src/frontend
parent420030e0e672f07b29a0c1b0d46409455f992e6d (diff)
-emu/dislot.cpp: Cleaned up interface.
* Added a helper for the common operation of replacing all options, setting default, and setting whether the slot is fixed (reduced boilerplate in slot devices a bit). * Fixed a bug where slot options copied the supplied name but also required the string to remain valid for their lifetime. * Use std::string_view for strings that should never be null. * Reduced some duplication. -dynax/ddenlovr.cpp: Allow a mahjong panel to be connected for all hanafuda games with slotted control panels. This is how the games were operated most of the time, and all mahjong controls are displayed in input tests. Also cleaned up some DIP switch settings. -emu/inpttype.h: Got rid of IPT_GAMBLE_SERVICE. -bus/bk/parallel.h: Fixed a bug where the supplied options and default weren't actually used. -emu/debug/debugcmd.cpp: Use C++ file stream for dumping address maps. -frontend/mame/clifront.cpp: Use osd_printf_info output for interactive verbs. -jaleco/ms32.cpp: Simplified mahjong panel column permutation. -capcom/cps1bl_5205.cpp, mattel/juicebox.cpp, sun/sun2.cpp, sun/sun3.cpp: Cleaned up logging. -emu/xtal.cpp: Reduced temporary objects and duplicated code.
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/clifront.cpp58
-rw-r--r--src/frontend/mame/infoxml.cpp2
-rw-r--r--src/frontend/mame/luaengine.cpp2
-rw-r--r--src/frontend/mame/luaengine.h3
-rw-r--r--src/frontend/mame/luaengine.ipp12
-rw-r--r--src/frontend/mame/luaengine_debug.cpp2
-rw-r--r--src/frontend/mame/luaengine_input.cpp2
-rw-r--r--src/frontend/mame/luaengine_mem.cpp6
-rw-r--r--src/frontend/mame/ui/devopt.cpp6
-rw-r--r--src/frontend/mame/ui/slotopt.cpp14
10 files changed, 61 insertions, 46 deletions
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp
index da9900ff680..9db3ef61eca 100644
--- a/src/frontend/mame/clifront.cpp
+++ b/src/frontend/mame/clifront.cpp
@@ -662,7 +662,7 @@ void cli_frontend::listbios(const std::vector<std::string> &args)
if (firstsystem)
firstsystem = false;
else
- printf("\n");
+ osd_printf_info("\n");
// print system BIOS options if there are any
bool firstbios = true;
@@ -670,13 +670,13 @@ void cli_frontend::listbios(const std::vector<std::string> &args)
{
if (firstbios)
{
- printf("BIOS options for system %s (%s):\n", root.name(), root.shortname());
+ osd_printf_info("BIOS options for system %s (%s):\n", root.name(), root.shortname());
firstbios = false;
}
- printf(" %-16s %s\n", bios.get_name(), bios.get_description());
+ osd_printf_info(" %-16s %s\n", bios.get_name(), bios.get_description());
}
if (firstbios)
- printf("No BIOS options for system %s (%s)\n", root.name(), root.shortname());
+ osd_printf_info("No BIOS options for system %s (%s)\n", root.name(), root.shortname());
// iterate over slots
for (const device_slot_interface &slot : slot_interface_enumerator(root))
@@ -692,10 +692,10 @@ void cli_frontend::listbios(const std::vector<std::string> &args)
{
if (firstcard)
{
- printf("\n BIOS options for device %s (-%s %s):\n", card->name(), slot.device().tag() + 1, card->basetag());
+ osd_printf_info("\n BIOS options for device %s (-%s %s):\n", card->name(), slot.device().tag() + 1, card->basetag());
firstcard = false;
}
- printf(" %-16s %s\n", bios.get_name(), bios.get_description());
+ osd_printf_info(" %-16s %s\n", bios.get_name(), bios.get_description());
}
}
}
@@ -762,9 +762,9 @@ void cli_frontend::listdevices(const std::vector<std::string> &args)
{
// print a header
if (!first)
- printf("\n");
+ osd_printf_info("\n");
first = false;
- printf("Driver %s (%s):\n", drivlist.driver().name, drivlist.driver().type.fullname());
+ osd_printf_info("Driver %s (%s):\n", drivlist.driver().name, drivlist.driver().type.fullname());
// build a list of devices
std::vector<device_t *> device_list;
@@ -808,20 +808,20 @@ void cli_frontend::listdevices(const std::vector<std::string> &args)
depth++;
}
}
- printf(" %*s%-*s %s", depth * 2, "", 30 - depth * 2, tag, device->name());
+ osd_printf_info(" %*s%-*s %s", depth * 2, "", 30 - depth * 2, tag, device->name());
// add more information
uint32_t clock = device->clock();
if (clock >= 1000000000)
- printf(" @ %d.%02d GHz\n", clock / 1000000000, (clock / 10000000) % 100);
+ osd_printf_info(" @ %d.%02d GHz\n", clock / 1000000000, (clock / 10000000) % 100);
else if (clock >= 1000000)
- printf(" @ %d.%02d MHz\n", clock / 1000000, (clock / 10000) % 100);
+ osd_printf_info(" @ %d.%02d MHz\n", clock / 1000000, (clock / 10000) % 100);
else if (clock >= 1000)
- printf(" @ %d.%02d kHz\n", clock / 1000, (clock / 10) % 100);
+ osd_printf_info(" @ %d.%02d kHz\n", clock / 1000, (clock / 10) % 100);
else if (clock > 0)
- printf(" @ %d Hz\n", clock);
+ osd_printf_info(" @ %d Hz\n", clock);
else
- printf("\n");
+ osd_printf_info("\n");
}
}
}
@@ -842,8 +842,8 @@ void cli_frontend::listslots(const std::vector<std::string> &args)
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching systems found for '%s'", gamename);
// print header
- printf("%-16s %-16s %-16s %s\n", "SYSTEM", "SLOT NAME", "SLOT OPTIONS", "SLOT DEVICE NAME");
- printf("%s %s %s %s\n", std::string(16,'-').c_str(), std::string(16,'-').c_str(), std::string(16,'-').c_str(), std::string(28,'-').c_str());
+ osd_printf_info("%-16s %-16s %-16s %s\n", "SYSTEM", "SLOT NAME", "SLOT OPTIONS", "SLOT DEVICE NAME");
+ osd_printf_info("%s %s %s %s\n", std::string(16,'-'), std::string(16,'-'), std::string(16,'-'), std::string(28,'-'));
// iterate over drivers
while (drivlist.next())
@@ -867,12 +867,12 @@ void cli_frontend::listslots(const std::vector<std::string> &args)
option_list.end(),
[] (device_slot_interface::slot_option const *opt1, device_slot_interface::slot_option const *opt2)
{
- return strcmp(opt1->name(), opt2->name()) < 0;
+ return opt1->name() < opt2->name();
});
// output the line, up to the list of extensions
- printf("%-16s %-16s ", first ? drivlist.driver().name : "", slot.device().tag()+1);
+ osd_printf_info("%-16s %-16s ", first ? drivlist.driver().name : "", slot.device().tag()+1);
bool first_option = true;
@@ -880,22 +880,22 @@ void cli_frontend::listslots(const std::vector<std::string> &args)
for (device_slot_interface::slot_option const *opt : option_list)
{
if (first_option)
- printf("%-16s %s\n", opt->name(), opt->devtype().fullname());
+ osd_printf_info("%-16s %s\n", opt->name(), opt->devtype().fullname());
else
- printf("%-34s%-16s %s\n", "", opt->name(), opt->devtype().fullname());
+ osd_printf_info("%-34s%-16s %s\n", "", opt->name(), opt->devtype().fullname());
first_option = false;
}
if (first_option)
- printf("%-16s %s\n", "[none]","No options available");
+ osd_printf_info("%-16s %s\n", "[none]","No options available");
// end the line
- printf("\n");
+ osd_printf_info("\n");
first = false;
}
// if we didn't get any at all, just print a none line
if (first)
- printf("%-16s (none)\n", drivlist.driver().name);
+ osd_printf_info("%-16s (none)\n", drivlist.driver().name);
}
}
@@ -915,8 +915,8 @@ void cli_frontend::listmedia(const std::vector<std::string> &args)
throw emu_fatalerror(EMU_ERR_NO_SUCH_SYSTEM, "No matching systems found for '%s'", gamename);
// print header
- printf("%-16s %-16s %-10s %s\n", "SYSTEM", "MEDIA NAME", "(brief)", "IMAGE FILE EXTENSIONS SUPPORTED");
- printf("%s %s-%s %s\n", std::string(16,'-').c_str(), std::string(16,'-').c_str(), std::string(10,'-').c_str(), std::string(31,'-').c_str());
+ osd_printf_info("%-16s %-16s %-10s %s\n", "SYSTEM", "MEDIA NAME", "(brief)", "IMAGE FILE EXTENSIONS SUPPORTED");
+ osd_printf_info("%s %s-%s %s\n", std::string(16,'-'), std::string(16,'-'), std::string(10,'-'), std::string(31,'-'));
// iterate over drivers
while (drivlist.next())
@@ -932,26 +932,26 @@ void cli_frontend::listmedia(const std::vector<std::string> &args)
std::string paren_shortname = string_format("(%s)", imagedev.brief_instance_name());
// output the line, up to the list of extensions
- printf("%-16s %-16s %-10s ", drivlist.driver().name, imagedev.instance_name().c_str(), paren_shortname.c_str());
+ osd_printf_info("%-16s %-16s %-10s ", drivlist.driver().name, imagedev.instance_name(), paren_shortname);
// get the extensions and print them
std::string extensions(imagedev.file_extensions());
for (int start = 0, end = extensions.find_first_of(',');; start = end + 1, end = extensions.find_first_of(',', start))
{
std::string curext(extensions, start, (end == -1) ? extensions.length() - start : end - start);
- printf(".%-5s", curext.c_str());
+ osd_printf_info(".%-5s", curext);
if (end == -1)
break;
}
// end the line
- printf("\n");
+ osd_printf_info("\n");
first = false;
}
// if we didn't get any at all, just print a none line
if (first)
- printf("%-16s (none)\n", drivlist.driver().name);
+ osd_printf_info("%-16s (none)\n", drivlist.driver().name);
}
}
diff --git a/src/frontend/mame/infoxml.cpp b/src/frontend/mame/infoxml.cpp
index fec2eebbf47..9da194d36de 100644
--- a/src/frontend/mame/infoxml.cpp
+++ b/src/frontend/mame/infoxml.cpp
@@ -2173,7 +2173,7 @@ void output_slots(std::ostream &out, machine_config &config, device_t &device, c
{
util::stream_format(out, "\t\t\t<slotoption name=\"%s\"", normalize_string(option.second->name()));
util::stream_format(out, " devname=\"%s\"", normalize_string(dev->shortname()));
- if (slot.default_option() && !strcmp(slot.default_option(), option.second->name()))
+ if (slot.default_option() && (slot.default_option() == option.second->name()))
out << " default=\"yes\"";
out << "/>\n";
}
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index d0c01053c55..3e3e848ecc2 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -2146,7 +2146,7 @@ void lua_engine::initialize()
slot_type["fixed"] = sol::property(&device_slot_interface::fixed);
slot_type["has_selectable_options"] = sol::property(&device_slot_interface::has_selectable_options);
slot_type["default_option"] = sol::property(&device_slot_interface::default_option);
- slot_type["options"] = sol::property([] (device_slot_interface const &slot) { return standard_tag_object_ptr_map<device_slot_interface::slot_option>(slot.option_list()); });
+ slot_type["options"] = sol::property([] (device_slot_interface const &slot) { return make_tag_object_ptr_map(slot.option_list()); });
slot_type["device"] = sol::property(static_cast<device_t & (device_slot_interface::*)()>(&device_slot_interface::device));
diff --git a/src/frontend/mame/luaengine.h b/src/frontend/mame/luaengine.h
index ac166974e50..c3acd5501fb 100644
--- a/src/frontend/mame/luaengine.h
+++ b/src/frontend/mame/luaengine.h
@@ -40,7 +40,6 @@ public:
template <typename T> struct devenum;
template <typename T> struct simple_list_wrapper;
template <typename T> struct tag_object_ptr_map;
- template <typename T> using standard_tag_object_ptr_map = tag_object_ptr_map<std::unordered_map<std::string, std::unique_ptr<T> > >;
template <typename T> struct immutable_container_helper;
template <typename T, typename C, typename I = typename C::iterator> struct immutable_collection_helper;
template <typename T, typename C, typename I = typename C::iterator> struct immutable_sequence_helper;
@@ -181,6 +180,8 @@ private:
std::vector<int> m_update_tasks;
std::vector<int> m_frame_tasks;
+ template <typename T>
+ static auto make_tag_object_ptr_map(T &map);
template <typename... T>
auto make_notifier_adder(util::notifier<T...> &notifier, const char *desc);
template <typename T, typename D, typename R, typename... A>
diff --git a/src/frontend/mame/luaengine.ipp b/src/frontend/mame/luaengine.ipp
index e08f267538e..53c4ba1a105 100644
--- a/src/frontend/mame/luaengine.ipp
+++ b/src/frontend/mame/luaengine.ipp
@@ -575,6 +575,18 @@ private:
//-------------------------------------------------
+// make_tag_object_ptr_map - make a wrapper for a
+// tag to object pointer map
+//-------------------------------------------------
+
+template <typename T>
+auto lua_engine::make_tag_object_ptr_map(T &map)
+{
+ return tag_object_ptr_map<std::remove_cv_t<T> >(map);
+}
+
+
+//-------------------------------------------------
// make_notifier_adder - make a function for
// subscribing to a notifier
//-------------------------------------------------
diff --git a/src/frontend/mame/luaengine_debug.cpp b/src/frontend/mame/luaengine_debug.cpp
index 992a9cc791a..994f61adbfb 100644
--- a/src/frontend/mame/luaengine_debug.cpp
+++ b/src/frontend/mame/luaengine_debug.cpp
@@ -339,7 +339,7 @@ void lua_engine::initialize_debug(sol::table &emu)
});
symbol_table_type.set_function("read_memory", &symbol_table_wrapper::read_memory);
symbol_table_type.set_function("write_memory", &symbol_table_wrapper::write_memory);
- symbol_table_type["entries"] = sol::property([] (symbol_table_wrapper const &st) { return standard_tag_object_ptr_map<symbol_entry>(st.table().entries()); });
+ symbol_table_type["entries"] = sol::property([] (symbol_table_wrapper const &st) { return make_tag_object_ptr_map(st.table().entries()); });
symbol_table_type["parent"] = sol::property(&symbol_table_wrapper::parent);
diff --git a/src/frontend/mame/luaengine_input.cpp b/src/frontend/mame/luaengine_input.cpp
index 82d8ad1c2cc..93d0cfff2d7 100644
--- a/src/frontend/mame/luaengine_input.cpp
+++ b/src/frontend/mame/luaengine_input.cpp
@@ -199,7 +199,7 @@ void lua_engine::initialize_input(sol::table &emu)
&ioport_manager::input_type_to_token,
[] (ioport_manager &im, ioport_type type) { return im.input_type_to_token(type, 0); });
ioport_manager_type["types"] = sol::property(&ioport_manager::types);
- ioport_manager_type["ports"] = sol::property([] (ioport_manager &im) { return tag_object_ptr_map<ioport_list>(im.ports()); });
+ ioport_manager_type["ports"] = sol::property([] (ioport_manager &im) { return make_tag_object_ptr_map(im.ports()); });
auto natkeyboard_type = sol().registry().new_usertype<natural_keyboard>("natkeyboard", sol::no_constructor);
diff --git a/src/frontend/mame/luaengine_mem.cpp b/src/frontend/mame/luaengine_mem.cpp
index ff2f406828b..deff4843ba7 100644
--- a/src/frontend/mame/luaengine_mem.cpp
+++ b/src/frontend/mame/luaengine_mem.cpp
@@ -725,9 +725,9 @@ void lua_engine::initialize_memory(sol::table &emu)
auto memory_type = sol().registry().new_usertype<memory_manager>("memory", sol::no_constructor);
- memory_type["banks"] = sol::property([] (memory_manager &mm) { return standard_tag_object_ptr_map<memory_bank>(mm.banks()); });
- memory_type["regions"] = sol::property([] (memory_manager &mm) { return standard_tag_object_ptr_map<memory_region>(mm.regions()); });
- memory_type["shares"] = sol::property([] (memory_manager &mm) { return standard_tag_object_ptr_map<memory_share>(mm.shares()); });
+ memory_type["banks"] = sol::property([] (memory_manager &mm) { return make_tag_object_ptr_map(mm.banks()); });
+ memory_type["regions"] = sol::property([] (memory_manager &mm) { return make_tag_object_ptr_map(mm.regions()); });
+ memory_type["shares"] = sol::property([] (memory_manager &mm) { return make_tag_object_ptr_map(mm.shares()); });
auto bank_type = sol().registry().new_usertype<memory_bank>("membank", sol::no_constructor);
diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp
index 0abba28c592..9ff99ad3bf6 100644
--- a/src/frontend/mame/ui/devopt.cpp
+++ b/src/frontend/mame/ui/devopt.cpp
@@ -54,10 +54,12 @@ void menu_device_config::populate_text(std::optional<text_layout> &layout, float
machine_config &mconfig(const_cast<machine_config &>(machine().config()));
machine_config::token const tok(mconfig.begin_configuration(mconfig.root_device()));
- device_t *const dev = mconfig.device_add(m_option->name(), m_option->devtype(), 0);
+ device_t *const dev = mconfig.device_add(std::string(m_option->name()).c_str(), m_option->devtype(), 0); // TODO: support string_view tags
for (device_t &d : device_enumerator(*dev))
+ {
if (!d.configured())
d.config_complete();
+ }
// get decimal separator
std::string point;
@@ -393,7 +395,7 @@ void menu_device_config::populate_text(std::optional<text_layout> &layout, float
+ input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0)
layout->add_text(_("[None]\n"), color);
- mconfig.device_remove(m_option->name());
+ mconfig.device_remove(std::string(m_option->name()).c_str()); // TODO: support string_view tags
lines = layout->lines();
}
width = layout->actual_width();
diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp
index 10fbeed03c6..8cd38a2e6f9 100644
--- a/src/frontend/mame/ui/slotopt.cpp
+++ b/src/frontend/mame/ui/slotopt.cpp
@@ -68,7 +68,7 @@ device_slot_interface::slot_option const *menu_slot_devices::get_current_option(
if (!slot.fixed())
{
- char const *const slot_option_name = slot.slot_name();
+ auto const slot_option_name = slot.slot_name();
current = machine().options().slot_option(slot_option_name).value();
}
else
@@ -78,7 +78,7 @@ device_slot_interface::slot_option const *menu_slot_devices::get_current_option(
current.assign(slot.default_option());
}
- return slot.option(current.c_str());
+ return slot.option(current);
}
@@ -99,7 +99,7 @@ void menu_slot_devices::set_slot_device(device_slot_interface &slot, std::string
opt.specify(val);
// erase this from our recorded options list - this is the slot we're trying to change!
- m_slot_options.erase(slot.slot_name());
+ m_slot_options.erase(std::string(slot.slot_name())); // TODO: get rid of temporary std::string when we have C++20
// refresh any options that we might have annotated earlier
while (try_refresh_current_options())
@@ -126,7 +126,7 @@ void menu_slot_devices::record_current_options()
const slot_option &opt(machine().options().slot_option(slot.slot_name()));
// and record the value in our local cache
- m_slot_options[slot.slot_name()] = opt.specified_value();
+ m_slot_options[std::string(slot.slot_name())] = opt.specified_value(); // TODO: get rid of temporary std::string if possible when we have C++20
}
}
}
@@ -198,7 +198,7 @@ void menu_slot_devices::populate()
? FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW
: FLAG_DISABLE;
- item_append(slot.slot_name(), opt_name, item_flags, (void *)&slot);
+ item_append(std::string(slot.slot_name()), std::move(opt_name), item_flags, (void *)&slot);
}
item_append(menu_item_type::SEPARATOR);
item_append(_("Reset System"), 0, ITEMREF_RESET);
@@ -293,11 +293,11 @@ void menu_slot_devices::rotate_slot_device(device_slot_interface &slot, menu_slo
std::sort(m_current_option_list.begin(), m_current_option_list.end());
// find the current position
- char const *const target = current ? current->name() : "";
+ std::string_view const target = current ? current->name() : std::string_view();
m_current_option_list_iter = std::find_if(
m_current_option_list.begin(),
m_current_option_list.end(),
- [target] (const std::string &opt_value)
+ [target] (std::string const &opt_value)
{
return opt_value == target;
});