summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
authorGravatarGravatar Vas Crabb <vas@vastheman.com>2019-09-26 20:53:06 +1000
committerGravatarGravatar Vas Crabb <vas@vastheman.com>2019-09-26 20:53:06 +1000
commit9a12ab37afb3e43d9d3c296b34348b835bafb2ea (patch)
tree6af7ce1fc5f52b1518100a1be926514cd2f34feb /src/emu
parent9d4b7b02acdb79fac05606f57c3fddd08593cba8 (diff)
Make osd_printf_* use util/strformat semantics.
(nw) This has been a long time coming but it's here at last. It should be easier now that logerror, popmessage and osd_printf_* behave like string_format and stream_format. Remember the differences from printf: * Any object with a stream out operator works with %s * %d, %i, %o, %x, %X, etc. work out the size by magic * No sign extending promotion to int for short/char * No widening/narrowing conversions for characters/strings * Same rules on all platforms, insulated from C runtime library * No format warnings from compiler * Assert in debug builds if number of arguments doesn't match format (nw) Also removed a pile of redundant c_str and string_format, and some workarounds for not being able to portably format 64-bit integers or long long.
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/addrmap.cpp6
-rw-r--r--src/emu/devfind.cpp4
-rw-r--r--src/emu/digfx.cpp2
-rw-r--r--src/emu/diimage.cpp10
-rw-r--r--src/emu/disound.cpp2
-rw-r--r--src/emu/inputdev.cpp4
-rw-r--r--src/emu/ioport.cpp18
-rw-r--r--src/emu/rendlay.cpp4
-rw-r--r--src/emu/rendutil.cpp2
-rw-r--r--src/emu/romload.cpp4
-rw-r--r--src/emu/save.cpp2
-rw-r--r--src/emu/screen.cpp2
-rw-r--r--src/emu/softlist_dev.cpp36
-rw-r--r--src/emu/validity.cpp114
-rw-r--r--src/emu/validity.h6
15 files changed, 105 insertions, 111 deletions
diff --git a/src/emu/addrmap.cpp b/src/emu/addrmap.cpp
index e1398013670..968b32e85c6 100644
--- a/src/emu/addrmap.cpp
+++ b/src/emu/addrmap.cpp
@@ -686,7 +686,7 @@ bool address_map_entry::unitmask_is_appropriate(u8 width, u64 unitmask, const ch
// if map is narrower than 64 bits, check the mask width as well
if (m_map.m_databits < 64 && (unitmask >> m_map.m_databits) != 0)
{
- osd_printf_error("Handler %s specified a mask of %08X%08X, too wide to be used in a %d-bit address map\n", string, (u32)(unitmask >> 32), (u32)unitmask, m_map.m_databits);
+ osd_printf_error("Handler %s specified a mask of %016X, too wide to be used in a %d-bit address map\n", string, unitmask, m_map.m_databits);
return false;
}
@@ -700,7 +700,7 @@ bool address_map_entry::unitmask_is_appropriate(u8 width, u64 unitmask, const ch
count++;
else if ((unitmask & singlemask) != 0)
{
- osd_printf_error("Handler %s specified a mask of %08X%08X; needs to be in even chunks of %X\n", string, (u32)(unitmask >> 32), (u32)unitmask, basemask);
+ osd_printf_error("Handler %s specified a mask of %016X; needs to be in even chunks of %X\n", string, unitmask, basemask);
return false;
}
singlemask <<= width;
@@ -718,7 +718,7 @@ bool address_map_entry::unitmask_is_appropriate(u8 width, u64 unitmask, const ch
|| (unitmask_wh != 0 && unitmask_wl != 0 && unitmask_wh != unitmask_wl)
|| (unitmask_dh != 0 && unitmask_dl != 0 && unitmask_dh != unitmask_dl))
{
- osd_printf_error("Handler %s specified an asymmetrical mask of %08X%08X\n", string, (u32)(unitmask >> 32), (u32)unitmask);
+ osd_printf_error("Handler %s specified an asymmetrical mask of %016X\n", string, unitmask);
return false;
}
#endif
diff --git a/src/emu/devfind.cpp b/src/emu/devfind.cpp
index 4128123e0f2..3cfcd17c223 100644
--- a/src/emu/devfind.cpp
+++ b/src/emu/devfind.cpp
@@ -329,9 +329,9 @@ bool finder_base::report_missing(bool found, const char *objname, bool required)
// otherwise, report
std::string const region_fulltag(m_base.get().subtag(m_tag));
if (required)
- osd_printf_error("Required %s '%s' not found\n", objname, region_fulltag.c_str());
+ osd_printf_error("Required %s '%s' not found\n", objname, region_fulltag);
else if (DUMMY_TAG != m_tag)
- osd_printf_verbose("Optional %s '%s' not found\n", objname, region_fulltag.c_str());
+ osd_printf_verbose("Optional %s '%s' not found\n", objname, region_fulltag);
return !required;
}
}
diff --git a/src/emu/digfx.cpp b/src/emu/digfx.cpp
index 0055421b80c..904efe3759f 100644
--- a/src/emu/digfx.cpp
+++ b/src/emu/digfx.cpp
@@ -316,7 +316,7 @@ void device_gfx_interface::interface_validity_check(validity_checker &valid) con
u32 region_length = valid.region_length(gfxregion.c_str());
if (region_length == 0)
- osd_printf_error("gfx[%d] references nonexistent region '%s'\n", gfxnum, gfxregion.c_str());
+ osd_printf_error("gfx[%d] references nonexistent region '%s'\n", gfxnum, gfxregion);
// if we have a valid region, and we're not using auto-sizing, check the decode against the region length
else if (!IS_FRAC(layout.total))
diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp
index 953e89dc42c..542091471a2 100644
--- a/src/emu/diimage.cpp
+++ b/src/emu/diimage.cpp
@@ -842,8 +842,8 @@ std::vector<u32> device_image_interface::determine_open_plan(bool is_create)
static void dump_wrong_and_correct_checksums(const util::hash_collection &hashes, const util::hash_collection &acthashes)
{
- osd_printf_error(" EXPECTED: %s\n", hashes.macro_string().c_str());
- osd_printf_error(" FOUND: %s\n", acthashes.macro_string().c_str());
+ osd_printf_error(" EXPECTED: %s\n", hashes.macro_string());
+ osd_printf_error(" FOUND: %s\n", acthashes.macro_string());
}
@@ -918,9 +918,9 @@ bool device_image_interface::load_software(software_list_device &swlist, const c
u32 supported = swinfo->supported();
if (supported == SOFTWARE_SUPPORTED_PARTIAL)
- osd_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name().c_str());
+ osd_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name());
if (supported == SOFTWARE_SUPPORTED_NO)
- osd_printf_error("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name().c_str());
+ osd_printf_error("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name());
// attempt reading up the chain through the parents and create a locationtag std::string in the format
// " swlist % clonename % parentname "
@@ -1051,7 +1051,7 @@ done:
if (device().machine().phase() == machine_phase::RUNNING)
device().popmessage("Error: Unable to %s image '%s': %s", is_create ? "create" : "load", path, error());
else
- osd_printf_error("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path.c_str(), error());
+ osd_printf_error("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path, error());
}
clear();
}
diff --git a/src/emu/disound.cpp b/src/emu/disound.cpp
index f4d9b194f8f..f3ab6b236f7 100644
--- a/src/emu/disound.cpp
+++ b/src/emu/disound.cpp
@@ -260,7 +260,7 @@ void device_sound_interface::interface_validity_check(validity_checker &valid) c
// find a device with the requested tag
device_t const *const target = route.m_base.get().subdevice(route.m_target.c_str());
if (!target)
- osd_printf_error("Attempting to route sound to non-existent device '%s'\n", route.m_base.get().subtag(route.m_target.c_str()).c_str());
+ osd_printf_error("Attempting to route sound to non-existent device '%s'\n", route.m_base.get().subtag(route.m_target.c_str()));
// if it's not a speaker or a sound device, error
device_sound_interface const *sound;
diff --git a/src/emu/inputdev.cpp b/src/emu/inputdev.cpp
index a9e8fee7491..66480068a14 100644
--- a/src/emu/inputdev.cpp
+++ b/src/emu/inputdev.cpp
@@ -423,7 +423,7 @@ input_device_joystick::input_device_joystick(input_manager &manager, const char
m_joymap.parse(input_class_joystick::map_8way);
}
else if (mapstring != input_class_joystick::map_8way)
- osd_printf_verbose("Input: Default joystick map = %s\n", m_joymap.to_string().c_str());
+ osd_printf_verbose("Input: Default joystick map = %s\n", m_joymap.to_string());
}
@@ -648,7 +648,7 @@ bool input_class_joystick::set_global_joystick_map(const char *mapstring)
if (!map.parse(mapstring))
return false;
- osd_printf_verbose("Input: Changing default joystick map = %s\n", map.to_string().c_str());
+ osd_printf_verbose("Input: Changing default joystick map = %s\n", map.to_string());
// iterate over joysticks and set the map
for (int joynum = 0; joynum <= maxindex(); joynum++)
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp
index e74502439fe..58161b78a83 100644
--- a/src/emu/ioport.cpp
+++ b/src/emu/ioport.cpp
@@ -1706,7 +1706,7 @@ time_t ioport_manager::initialize()
std::string errors;
m_portlist.append(device, errors);
if (!errors.empty())
- osd_printf_error("Input port errors:\n%s", errors.c_str());
+ osd_printf_error("Input port errors:\n%s", errors);
}
// renumber player numbers for controller ports
@@ -2558,12 +2558,12 @@ time_t ioport_manager::playback_init()
osd_printf_info("INP version %u.%u\n", header.get_majversion(), header.get_minversion());
time_t basetime = header.get_basetime();
osd_printf_info("Created %s\n", ctime(&basetime));
- osd_printf_info("Recorded using %s\n", header.get_appdesc().c_str());
+ osd_printf_info("Recorded using %s\n", header.get_appdesc());
// verify the header against the current game
std::string const sysname = header.get_sysname();
if (sysname != machine().system().name)
- osd_printf_info("Input file is for machine '%s', not for current machine '%s'\n", sysname.c_str(), machine().system().name);
+ osd_printf_info("Input file is for machine '%s', not for current machine '%s'\n", sysname, machine().system().name);
// enable compression
m_playback_file.compress(FCOMPRESS_MEDIUM);
@@ -2907,15 +2907,15 @@ void ioport_manager::record_frame(const attotime &curtime)
timecode_key = string_format("EXTRA_STOP_%03d", (m_timecode_count-4)/2);
}
- osd_printf_info("%s \n", message.c_str());
- machine().popmessage("%s \n", message.c_str());
+ osd_printf_info("%s \n", message);
+ machine().popmessage("%s \n", message);
m_timecode_file.printf(
"%-19s %s %s %s %s %s %s\n",
- timecode_key.c_str(),
- current_time_str.c_str(), elapsed_time_str.c_str(),
- mseconds_start_str.c_str(), mseconds_elapsed_str.c_str(),
- frame_start_str.c_str(), frame_elapsed_str.c_str());
+ timecode_key,
+ current_time_str, elapsed_time_str,
+ mseconds_start_str, mseconds_elapsed_str,
+ frame_start_str, frame_elapsed_str);
machine().video().set_timecode_write(false);
machine().video().set_timecode_text(timecode_text);
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 23a60c57e13..c8c68b84b82 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -1298,9 +1298,9 @@ private:
// log an error
if (m_alphafile.empty())
- osd_printf_warning("Unable to load component bitmap '%s'\n", m_imagefile.c_str());
+ osd_printf_warning("Unable to load component bitmap '%s'\n", m_imagefile);
else
- osd_printf_warning("Unable to load component bitmap '%s'/'%s'\n", m_imagefile.c_str(), m_alphafile.c_str());
+ osd_printf_warning("Unable to load component bitmap '%s'/'%s'\n", m_imagefile, m_alphafile);
}
}
diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp
index ba8e177f93e..ab5770b86e1 100644
--- a/src/emu/rendutil.cpp
+++ b/src/emu/rendutil.cpp
@@ -605,7 +605,7 @@ void render_load_jpeg(bitmap_argb32 &bitmap, emu_file &file, const char *dirname
bitmap.pix32(j, i) = rgb_t(0xFF, buffer[0][i * s], buffer[0][i * s + 1], buffer[0][i * s + 2]);
else
{
- osd_printf_error("Cannot read JPEG data from %s file.\n", fname.c_str());
+ osd_printf_error("Cannot read JPEG data from %s file.\n", fname);
bitmap.reset();
break;
}
diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp
index c5b03607509..d04d0e308a3 100644
--- a/src/emu/romload.cpp
+++ b/src/emu/romload.cpp
@@ -470,7 +470,7 @@ void rom_load_manager::display_rom_load_results(bool from_list)
if (m_errors != 0)
{
/* create the error message and exit fatally */
- osd_printf_error("%s", m_errorstring.c_str());
+ osd_printf_error("%s", m_errorstring);
fatalerror_exitcode(machine(), EMU_ERR_MISSING_FILES, "Required files are missing, the machine cannot be run.");
}
@@ -478,7 +478,7 @@ void rom_load_manager::display_rom_load_results(bool from_list)
if ((m_warnings) || (m_knownbad))
{
m_errorstring.append("WARNING: the machine might not run correctly.");
- osd_printf_warning("%s\n", m_errorstring.c_str());
+ osd_printf_warning("%s\n", m_errorstring);
}
}
diff --git a/src/emu/save.cpp b/src/emu/save.cpp
index a8a59c90817..035235e673d 100644
--- a/src/emu/save.cpp
+++ b/src/emu/save.cpp
@@ -89,7 +89,7 @@ void save_manager::allow_registration(bool allowed)
{
if (m_entry_list[i]->m_name == m_entry_list[i + 1]->m_name)
{
- osd_printf_error("Duplicate save state registration entry (%s)\n", m_entry_list[i]->m_name.c_str());
+ osd_printf_error("Duplicate save state registration entry (%s)\n", m_entry_list[i]->m_name);
dupes_found++;
}
}
diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp
index 103230ba114..835e12995f5 100644
--- a/src/emu/screen.cpp
+++ b/src/emu/screen.cpp
@@ -1707,5 +1707,5 @@ void screen_device::load_effect_overlay(const char *filename)
if (m_screen_overlay_bitmap.valid())
m_container->set_overlay(&m_screen_overlay_bitmap);
else
- osd_printf_warning("Unable to load effect PNG file '%s'\n", fullname.c_str());
+ osd_printf_warning("Unable to load effect PNG file '%s'\n", fullname);
}
diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp
index 831fc3f6734..015c8f13a6a 100644
--- a/src/emu/softlist_dev.cpp
+++ b/src/emu/softlist_dev.cpp
@@ -221,15 +221,15 @@ void software_list_device::display_matches(const machine_config &config, const c
{
// different output depending on original system or compatible
if (swlistdev.list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
- osd_printf_error("* Software list \"%s\" (%s) matches: \n", swlistdev.list_name().c_str(), swlistdev.description().c_str());
+ osd_printf_error("* Software list \"%s\" (%s) matches: \n", swlistdev.list_name(), swlistdev.description());
else
- osd_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlistdev.list_name().c_str(), swlistdev.description().c_str());
+ osd_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlistdev.list_name(), swlistdev.description());
// print them out
for (auto &match : matches)
{
if (match != nullptr)
- osd_printf_error("%-18s%s\n", match->shortname().c_str(), match->longname().c_str());
+ osd_printf_error("%-18s%s\n", match->shortname(), match->longname());
}
osd_printf_error("\n");
@@ -440,28 +440,28 @@ void software_list_device::internal_validity_check(validity_checker &valid)
// Did we lost any description?
if (swinfo.longname().empty())
{
- osd_printf_error("%s: %s has no description\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s has no description\n", filename(), shortname);
break;
}
// Did we lost any year?
if (swinfo.year().empty())
{
- osd_printf_error("%s: %s has no year\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s has no year\n", filename(), shortname);
break;
}
// Did we lost any publisher?
if (swinfo.publisher().empty())
{
- osd_printf_error("%s: %s has no publisher\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s has no publisher\n", filename(), shortname);
break;
}
// Did we lost the software parts?
if (swinfo.parts().empty())
{
- osd_printf_error("%s: %s has no part\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s has no part\n", filename(), shortname);
break;
}
@@ -471,20 +471,20 @@ void software_list_device::internal_validity_check(validity_checker &valid)
if (!names.insert(std::make_pair(shortname, &swinfo)).second)
{
const software_info *match = names.find(shortname)->second;
- osd_printf_error("%s: %s is a duplicate name (%s)\n", filename(), shortname.c_str(), match->shortname().c_str());
+ osd_printf_error("%s: %s is a duplicate name (%s)\n", filename(), shortname, match->shortname());
}
// check for duplicate descriptions
std::string longname(swinfo.longname());
if (!descriptions.insert(std::make_pair(strmakelower(longname), &swinfo)).second)
- osd_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo.longname().c_str(), shortname.c_str());
+ osd_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo.longname(), shortname);
bool const is_clone(!swinfo.parentname().empty());
if (is_clone)
{
if (swinfo.parentname() == shortname)
{
- osd_printf_error("%s: %s is set as a clone of itself\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s is set as a clone of itself\n", filename(), shortname);
break;
}
@@ -492,21 +492,21 @@ void software_list_device::internal_validity_check(validity_checker &valid)
const software_info *swinfo2 = find(swinfo.parentname().c_str());
if (swinfo2 == nullptr)
- osd_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo.parentname().c_str(), shortname.c_str());
+ osd_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo.parentname(), shortname);
else if (!swinfo2->parentname().empty())
- osd_printf_error("%s: %s is a clone of a clone\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s is a clone of a clone\n", filename(), shortname);
}
// make sure the driver name isn't too long
if (shortname.length() > (is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT))
- osd_printf_error("%s: %s %s software name must be %d characters or less\n", filename(), shortname.c_str(),
+ osd_printf_error("%s: %s %s software name must be %d characters or less\n", filename(), shortname,
is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
// make sure the driver name doesn't contain invalid characters
for (char ch : shortname)
if (((ch < '0') || (ch > '9')) && ((ch < 'a') || (ch > 'z')) && (ch != '_'))
{
- osd_printf_error("%s: %s contains invalid characters\n", filename(), shortname.c_str());
+ osd_printf_error("%s: %s contains invalid characters\n", filename(), shortname);
break;
}
@@ -514,7 +514,7 @@ void software_list_device::internal_validity_check(validity_checker &valid)
for (char ch : swinfo.year())
if (!isdigit(u8(ch)) && (ch != '?') && (ch != '+'))
{
- osd_printf_error("%s: %s has an invalid year '%s'\n", filename(), shortname.c_str(), swinfo.year().c_str());
+ osd_printf_error("%s: %s has an invalid year '%s'\n", filename(), shortname, swinfo.year());
break;
}
@@ -522,13 +522,13 @@ void software_list_device::internal_validity_check(validity_checker &valid)
for (const software_part &part : swinfo.parts())
{
if (part.interface().empty())
- osd_printf_error("%s: %s has a part (%s) without interface\n", filename(), shortname.c_str(), part.name().c_str());
+ osd_printf_error("%s: %s has a part (%s) without interface\n", filename(), shortname, part.name());
if (part.romdata().empty())
- osd_printf_error("%s: %s has a part (%s) with no data\n", filename(), shortname.c_str(), part.name().c_str());
+ osd_printf_error("%s: %s has a part (%s) with no data\n", filename(), shortname, part.name());
if (!part_names.insert(std::make_pair(part.name(), &swinfo)).second)
- osd_printf_error("%s: %s has a part (%s) whose name is duplicate\n", filename(), shortname.c_str(), part.name().c_str());
+ osd_printf_error("%s: %s has a part (%s) whose name is duplicate\n", filename(), shortname, part.name());
}
}
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index 8e8519ecffa..882da29c1ff 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -430,32 +430,32 @@ void validity_checker::validate_inlines()
resulti64 = mul_32x32(testi32a, testi32b);
expectedi64 = s64(testi32a) * s64(testi32b);
if (resulti64 != expectedi64)
- osd_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, u32(resulti64 >> 32), u32(resulti64), u32(expectedi64 >> 32), u32(expectedi64));
+ osd_printf_error("Error testing mul_32x32 (%08X x %08X) = %16X (expected %16X)\n", s32(testi32a), s32(testi32b), resulti64, expectedi64);
resultu64 = mulu_32x32(testu32a, testu32b);
expectedu64 = u64(testu32a) * u64(testu32b);
if (resultu64 != expectedu64)
- osd_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, u32(resultu64 >> 32), u32(resultu64), u32(expectedu64 >> 32), u32(expectedu64));
+ osd_printf_error("Error testing mulu_32x32 (%08X x %08X) = %16X (expected %16X)\n", u32(testu32a), u32(testu32b), resultu64, expectedu64);
resulti32 = mul_32x32_hi(testi32a, testi32b);
expectedi32 = (s64(testi32a) * s64(testi32b)) >> 32;
if (resulti32 != expectedi32)
- osd_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32);
+ osd_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", s32(testi32a), s32(testi32b), resulti32, expectedi32);
resultu32 = mulu_32x32_hi(testu32a, testu32b);
expectedu32 = (s64(testu32a) * s64(testu32b)) >> 32;
if (resultu32 != expectedu32)
- osd_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32);
+ osd_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", u32(testu32a), u32(testu32b), resultu32, expectedu32);
resulti32 = mul_32x32_shift(testi32a, testi32b, 7);
expectedi32 = (s64(testi32a) * s64(testi32b)) >> 7;
if (resulti32 != expectedi32)
- osd_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32);
+ osd_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", s32(testi32a), s32(testi32b), resulti32, expectedi32);
resultu32 = mulu_32x32_shift(testu32a, testu32b, 7);
expectedu32 = (s64(testu32a) * s64(testu32b)) >> 7;
if (resultu32 != expectedu32)
- osd_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32);
+ osd_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", u32(testu32a), u32(testu32b), resultu32, expectedu32);
while (s64(testi32a) * s64(0x7fffffff) < testi64a)
testi64a /= 2;
@@ -465,34 +465,34 @@ void validity_checker::validate_inlines()
resulti32 = div_64x32(testi64a, testi32a);
expectedi32 = testi64a / s64(testi32a);
if (resulti32 != expectedi32)
- osd_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testi64a >> 32), u32(testi64a), testi32a, resulti32, expectedi32);
+ osd_printf_error("Error testing div_64x32 (%16X / %08X) = %08X (expected %08X)\n", s64(testi64a), s32(testi32a), resulti32, expectedi32);
resultu32 = divu_64x32(testu64a, testu32a);
expectedu32 = testu64a / u64(testu32a);
if (resultu32 != expectedu32)
- osd_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testu64a >> 32), u32(testu64a), testu32a, resultu32, expectedu32);
+ osd_printf_error("Error testing divu_64x32 (%16X / %08X) = %08X (expected %08X)\n", u64(testu64a), u32(testu32a), resultu32, expectedu32);
resulti32 = div_64x32_rem(testi64a, testi32a, &remainder);
expectedi32 = testi64a / s64(testi32a);
expremainder = testi64a % s64(testi32a);
if (resulti32 != expectedi32 || remainder != expremainder)
- osd_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", u32(testi64a >> 32), u32(testi64a), testi32a, resulti32, remainder, expectedi32, expremainder);
+ osd_printf_error("Error testing div_64x32_rem (%16X / %08X) = %08X,%08X (expected %08X,%08X)\n", s64(testi64a), s32(testi32a), resulti32, remainder, expectedi32, expremainder);
resultu32 = divu_64x32_rem(testu64a, testu32a, &uremainder);
expectedu32 = testu64a / u64(testu32a);
expuremainder = testu64a % u64(testu32a);
if (resultu32 != expectedu32 || uremainder != expuremainder)
- osd_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", u32(testu64a >> 32), u32(testu64a), testu32a, resultu32, uremainder, expectedu32, expuremainder);
+ osd_printf_error("Error testing divu_64x32_rem (%16X / %08X) = %08X,%08X (expected %08X,%08X)\n", u64(testu64a), u32(testu32a), resultu32, uremainder, expectedu32, expuremainder);
resulti32 = mod_64x32(testi64a, testi32a);
expectedi32 = testi64a % s64(testi32a);
if (resulti32 != expectedi32)
- osd_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testi64a >> 32), u32(testi64a), testi32a, resulti32, expectedi32);
+ osd_printf_error("Error testing mod_64x32 (%16X / %08X) = %08X (expected %08X)\n", s64(testi64a), s32(testi32a), resulti32, expectedi32);
resultu32 = modu_64x32(testu64a, testu32a);
expectedu32 = testu64a % u64(testu32a);
if (resultu32 != expectedu32)
- osd_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testu64a >> 32), u32(testu64a), testu32a, resultu32, expectedu32);
+ osd_printf_error("Error testing modu_64x32 (%16X / %08X) = %08X (expected %08X)\n", u64(testu64a), u32(testu32a), resultu32, expectedu32);
while (s64(testi32a) * s64(0x7fffffff) < (s32(testi64a) << 3))
testi64a /= 2;
@@ -502,12 +502,12 @@ void validity_checker::validate_inlines()
resulti32 = div_32x32_shift(s32(testi64a), testi32a, 3);
expectedi32 = (s64(s32(testi64a)) << 3) / s64(testi32a);
if (resulti32 != expectedi32)
- osd_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", s32(testi64a), testi32a, resulti32, expectedi32);
+ osd_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", s32(testi64a), s32(testi32a), resulti32, expectedi32);
resultu32 = divu_32x32_shift(u32(testu64a), testu32a, 3);
expectedu32 = (u64(u32(testu64a)) << 3) / u64(testu32a);
if (resultu32 != expectedu32)
- osd_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", u32(testu64a), testu32a, resultu32, expectedu32);
+ osd_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", u32(testu64a), u32(testu32a), resultu32, expectedu32);
if (fabsf(recip_approx(100.0f) - 0.01f) > 0.0001f)
osd_printf_error("Error testing recip_approx\n");
@@ -582,10 +582,10 @@ void validity_checker::validate_rgb()
const volatile s32 r = rgb.get_r32();
const volatile s32 g = rgb.get_g32();
const volatile s32 b = rgb.get_b32();
- if (a != expected_a) osd_printf_error("Error testing %s get_a32() = %d (expected %d)\n", desc, a, expected_a);
- if (r != expected_r) osd_printf_error("Error testing %s get_r32() = %d (expected %d)\n", desc, r, expected_r);
- if (g != expected_g) osd_printf_error("Error testing %s get_g32() = %d (expected %d)\n", desc, g, expected_g);
- if (b != expected_b) osd_printf_error("Error testing %s get_b32() = %d (expected %d)\n", desc, b, expected_b);
+ if (a != expected_a) osd_printf_error("Error testing %s get_a32() = %d (expected %d)\n", desc, s32(a), s32(expected_a));
+ if (r != expected_r) osd_printf_error("Error testing %s get_r32() = %d (expected %d)\n", desc, s32(r), s32(expected_r));
+ if (g != expected_g) osd_printf_error("Error testing %s get_g32() = %d (expected %d)\n", desc, s32(g), s32(expected_g));
+ if (b != expected_b) osd_printf_error("Error testing %s get_b32() = %d (expected %d)\n", desc, s32(b), s32(expected_b));
};
// check set/get
@@ -901,10 +901,10 @@ void validity_checker::validate_rgb()
actual_r = s32(u32(rgb.get_r()));
actual_g = s32(u32(rgb.get_g()));
actual_b = s32(u32(rgb.get_b()));
- if (actual_a != expected_a) osd_printf_error("Error testing rgbaint_t::get_a() = %d (expected %d)\n", actual_a, expected_a);
- if (actual_r != expected_r) osd_printf_error("Error testing rgbaint_t::get_r() = %d (expected %d)\n", actual_r, expected_r);
- if (actual_g != expected_g) osd_printf_error("Error testing rgbaint_t::get_g() = %d (expected %d)\n", actual_g, expected_g);
- if (actual_b != expected_b) osd_printf_error("Error testing rgbaint_t::get_b() = %d (expected %d)\n", actual_b, expected_b);
+ if (actual_a != expected_a) osd_printf_error("Error testing rgbaint_t::get_a() = %d (expected %d)\n", s32(actual_a), s32(expected_a));
+ if (actual_r != expected_r) osd_printf_error("Error testing rgbaint_t::get_r() = %d (expected %d)\n", s32(actual_r), s32(expected_r));
+ if (actual_g != expected_g) osd_printf_error("Error testing rgbaint_t::get_g() = %d (expected %d)\n", s32(actual_g), s32(expected_g));
+ if (actual_b != expected_b) osd_printf_error("Error testing rgbaint_t::get_b() = %d (expected %d)\n", s32(actual_b), s32(expected_b));
// test set from packed RGBA
imm = random_i32();
@@ -1406,14 +1406,14 @@ void validity_checker::validate_driver()
if (!m_names_map.insert(std::make_pair(m_current_driver->name, m_current_driver)).second)
{
const game_driver *match = m_names_map.find(m_current_driver->name)->second;
- osd_printf_error("Driver name is a duplicate of %s(%s)\n", core_filename_extract_base(match->type.source()).c_str(), match->name);
+ osd_printf_error("Driver name is a duplicate of %s(%s)\n", core_filename_extract_base(match->type.source()), match->name);
}
// check for duplicate descriptions
if (!m_descriptions_map.insert(std::make_pair(m_current_driver->type.fullname(), m_current_driver)).second)
{
const game_driver *match = m_descriptions_map.find(m_current_driver->type.fullname())->second;
- osd_printf_error("Driver description is a duplicate of %s(%s)\n", core_filename_extract_base(match->type.source()).c_str(), match->name);
+ osd_printf_error("Driver description is a duplicate of %s(%s)\n", core_filename_extract_base(match->type.source()), match->name);
}
// determine if we are a clone
@@ -1551,7 +1551,7 @@ void validity_checker::validate_roms(device_t &root)
// attempt to add it to the map, reporting duplicates as errors
current_length = ROMREGION_GETLENGTH(romp);
if (!m_region_map.insert(std::make_pair(fulltag, current_length)).second)
- osd_printf_error("Multiple ROM_REGIONs with the same tag '%s' defined\n", fulltag.c_str());
+ osd_printf_error("Multiple ROM_REGIONs with the same tag '%s' defined\n", fulltag);
}
else if (ROMENTRY_ISSYSTEM_BIOS(romp)) // If this is a system bios, make sure it is using the next available bios number
{
@@ -1579,7 +1579,7 @@ void validity_checker::validate_roms(device_t &root)
osd_printf_error("Duplicate BIOS name %s specified (%d and %d)\n", biosname, nameins.first->second, bios_flags - 1);
auto const descins = bios_descs.emplace(romp->hashdata, biosname);
if (!descins.second)
- osd_printf_error("BIOS %s has duplicate description '%s' (was %s)\n", biosname, romp->hashdata, descins.first->second.c_str());
+ osd_printf_error("BIOS %s has duplicate description '%s' (was %s)\n", biosname, romp->hashdata, descins.first->second);
}
else if (ROMENTRY_ISDEFAULT_BIOS(romp)) // if this is a default BIOS setting, remember it so it to check at the end
{
@@ -1623,7 +1623,7 @@ void validity_checker::validate_roms(device_t &root)
if (defbios && (bios_names.find(defbios) == bios_names.end()))
osd_printf_error("Default BIOS '%s' not found\n", defbios);
if (!device.get_default_bios_tag().empty() && (bios_names.find(device.get_default_bios_tag()) == bios_names.end()))
- osd_printf_error("Configured BIOS '%s' not found\n", device.get_default_bios_tag().c_str());
+ osd_printf_error("Configured BIOS '%s' not found\n", device.get_default_bios_tag());
// check that there aren't ROMs for a non-existent BIOS option
if (max_bios > last_bios)
@@ -1828,7 +1828,7 @@ void validity_checker::validate_inputs()
// report any errors during construction
if (!errorbuf.empty())
- osd_printf_error("I/O port error during construction:\n%s\n", errorbuf.c_str());
+ osd_printf_error("I/O port error during construction:\n%s\n", errorbuf);
// do a first pass over ports to add their names and find duplicates
for (auto &port : portlist)
@@ -2053,7 +2053,7 @@ void validity_checker::validate_device_types()
// ensure shortname exists
if (!dev->shortname() || !*dev->shortname())
{
- osd_printf_error("Device %s does not have short name defined\n", description.c_str());
+ osd_printf_error("Device %s does not have short name defined\n", description);
}
else
{
@@ -2066,7 +2066,7 @@ void validity_checker::validate_device_types()
{
if (((*s < '0') || (*s > '9')) && ((*s < 'a') || (*s > 'z')) && (*s != '_'))
{
- osd_printf_error("Device %s short name contains invalid characters\n", description.c_str());
+ osd_printf_error("Device %s short name contains invalid characters\n", description);
break;
}
}
@@ -2078,12 +2078,12 @@ void validity_checker::validate_device_types()
if (m_names_map.end() != drvname)
{
game_driver const &dup(*drvname->second);
- osd_printf_error("Device %s short name is a duplicate of %s(%s)\n", description.c_str(), core_filename_extract_base(dup.type.source()).c_str(), dup.name);
+ osd_printf_error("Device %s short name is a duplicate of %s(%s)\n", description, core_filename_extract_base(dup.type.source()), dup.name);
}
else if (!devname.second)
{
device_t *const dup = config.device_add("_dup", *devname.first->second, 0);
- osd_printf_error("Device %s short name is a duplicate of %s(%s)\n", description.c_str(), core_filename_extract_base(dup->source()).c_str(), dup->shortname());
+ osd_printf_error("Device %s short name is a duplicate of %s(%s)\n", description, core_filename_extract_base(dup->source()), dup->shortname());
config.device_remove("_dup");
}
}
@@ -2091,7 +2091,7 @@ void validity_checker::validate_device_types()
// ensure name exists
if (!dev->name() || !*dev->name())
{
- osd_printf_error("Device %s does not have name defined\n", description.c_str());
+ osd_printf_error("Device %s does not have name defined\n", description);
}
else
{
@@ -2102,23 +2102,23 @@ void validity_checker::validate_device_types()
if (m_descriptions_map.end() != drvdesc)
{
game_driver const &dup(*drvdesc->second);
- osd_printf_error("Device %s name '%s' is a duplicate of %s(%s)\n", description.c_str(), dev->name(), core_filename_extract_base(dup.type.source()).c_str(), dup.name);
+ osd_printf_error("Device %s name '%s' is a duplicate of %s(%s)\n", description, dev->name(), core_filename_extract_base(dup.type.source()), dup.name);
}
else if (!devdesc.second)
{
device_t *const dup = config.device_add("_dup", *devdesc.first->second, 0);
- osd_printf_error("Device %s name '%s' is a duplicate of %s(%s)\n", description.c_str(), dev->name(), core_filename_extract_base(dup->source()).c_str(), dup->shortname());
+ osd_printf_error("Device %s name '%s' is a duplicate of %s(%s)\n", description, dev->name(), core_filename_extract_base(dup->source()), dup->shortname());
config.device_remove("_dup");
}
}
// ensure source exists
if (!dev->source() || !*dev->source())
- osd_printf_error("Device %s does not have source defined\n", description.c_str());
+ osd_printf_error("Device %s does not have source defined\n", description);
// check that reported type matches supplied type
if (dev->type().type() != type.type())
- osd_printf_error("Device %s reports type '%s' (created with '%s')\n", description.c_str(), dev->type().type().name(), type.type().name());
+ osd_printf_error("Device %s reports type '%s' (created with '%s')\n", description, dev->type().type().name(), type.type().name());
// catch invalid flag combinations
device_t::feature_type const unemulated(dev->type().unemulated_features());
@@ -2154,18 +2154,15 @@ void validity_checker::validate_device_types()
// and device
//-------------------------------------------------
-void validity_checker::build_output_prefix(std::string &str)
+void validity_checker::build_output_prefix(std::ostream &str) const
{
- // start empty
- str.clear();
-
// if we have a current (non-root) device, indicate that
- if (m_current_device != nullptr && m_current_device->owner() != nullptr)
- str.append(m_current_device->name()).append(" device '").append(m_current_device->tag() + 1).append("': ");
+ if (m_current_device && m_current_device->owner())
+ util::stream_format(str, "%s device '%s': ", m_current_device->name(), m_current_device->tag() + 1);
// if we have a current port, indicate that as well
- if (m_current_ioport != nullptr)
- str.append("ioport '").append(m_current_ioport).append("': ");
+ if (m_current_ioport)
+ util::stream_format(str, "ioport '%s': ", m_current_ioport);
}
@@ -2173,9 +2170,9 @@ void validity_checker::build_output_prefix(std::string &str)
// error_output - error message output override
//-------------------------------------------------
-void validity_checker::output_callback(osd_output_channel channel, const char *msg, va_list args)
+void validity_checker::output_callback(osd_output_channel channel, const util::format_argument_pack<std::ostream> &args)
{
- std::string output;
+ std::ostringstream output;
switch (channel)
{
case OSD_OUTPUT_CHANNEL_ERROR:
@@ -2186,8 +2183,8 @@ void validity_checker::output_callback(osd_output_channel channel, const char *m
build_output_prefix(output);
// generate the string
- strcatvprintf(output, msg, args);
- m_error_text.append(output);
+ util::stream_format(output, args);
+ m_error_text.append(output.str());
break;
case OSD_OUTPUT_CHANNEL_WARNING:
@@ -2198,8 +2195,8 @@ void validity_checker::output_callback(osd_output_channel channel, const char *m
build_output_prefix(output);
// generate the string and output to the original target
- strcatvprintf(output, msg, args);
- m_warning_text.append(output);
+ util::stream_format(output, args);
+ m_warning_text.append(output.str());
break;
case OSD_OUTPUT_CHANNEL_VERBOSE:
@@ -2210,12 +2207,12 @@ void validity_checker::output_callback(osd_output_channel channel, const char *m
build_output_prefix(output);
// generate the string and output to the original target
- strcatvprintf(output, msg, args);
- m_verbose_text.append(output);
+ util::stream_format(output, args);
+ m_verbose_text.append(output.str());
break;
default:
- chain_output(channel, msg, args);
+ chain_output(channel, args);
break;
}
}
@@ -2226,14 +2223,11 @@ void validity_checker::output_callback(osd_output_channel channel, const char *m
// can be forwarded onto the given delegate
//-------------------------------------------------
-void validity_checker::output_via_delegate(osd_output_channel channel, const char *format, ...)
+template <typename Format, typename... Params>
+void validity_checker::output_via_delegate(osd_output_channel channel, Format &&fmt, Params &&...args)
{
- va_list argptr;
-
// call through to the delegate with the proper parameters
- va_start(argptr, format);
- chain_output(channel, format, argptr);
- va_end(argptr);
+ chain_output(channel, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
}
//-------------------------------------------------
diff --git a/src/emu/validity.h b/src/emu/validity.h
index 2c8c38e4c8d..c55e4e35334 100644
--- a/src/emu/validity.h
+++ b/src/emu/validity.h
@@ -52,7 +52,7 @@ public:
// osd_output interface
protected:
- virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override;
+ virtual void output_callback(osd_output_channel channel, const util::format_argument_pack<std::ostream> &args) override;
private:
// internal map types
@@ -82,8 +82,8 @@ private:
void validate_device_types();
// output helpers
- void build_output_prefix(std::string &str);
- void output_via_delegate(osd_output_channel channel, const char *format, ...) ATTR_PRINTF(3,4);
+ void build_output_prefix(std::ostream &str) const;
+ template <typename Format, typename... Params> void output_via_delegate(osd_output_channel channel, Format &&fmt, Params &&...args);
void output_indented_errors(std::string &text, const char *header);
// random number generation