From f16cd0249f161b068e5bc4a6f7b4a8002e7f428a Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 23 Nov 2024 11:41:56 +1100 Subject: emu/romload.cpp: Resolve tags for ROM_COPY relative to current device properly. Tags can contain multiple colon-separated parts. Also, we really don't need tag manipulation code proliferating throughout the codebase. --- src/emu/emumem.cpp | 58 ----------------------------------------- src/emu/emumem.h | 1 - src/emu/romload.cpp | 11 ++++---- src/emu/romload.h | 3 ++- src/mame/sega/segaufo.cpp | 3 ++- src/mame/universal/docastle.cpp | 6 ++--- 6 files changed, 13 insertions(+), 69 deletions(-) diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp index 86b1bd8512b..679c2374e78 100644 --- a/src/emu/emumem.cpp +++ b/src/emu/emumem.cpp @@ -1077,64 +1077,6 @@ memory_region::memory_region(running_machine &machine, std::string name, u32 len assert(width == 1 || width == 2 || width == 4 || width == 8); } -std::string memory_region::sibling(std::string_view tag) const -{ - std::string result; - if (!tag.empty() && (tag[0] == ':')) - { - // if the tag begins with a colon, ignore our path and start from the root - tag.remove_prefix(1); - result.assign(":"); - } - else - { - // otherwise, start relative to current path - std::string::size_type lastcolon = m_name.find_last_of(':'); - if (lastcolon != std::string::npos) - result.assign(m_name, 0, lastcolon + 1); - } - - // iterate over the tag, look for special path characters to resolve - std::string_view::size_type delimiter; - while ((delimiter = tag.find_first_of("^:")) != std::string_view::npos) - { - // copy everything up to there - bool const parent = tag[delimiter] == '^'; - result.append(tag, 0, delimiter); - tag.remove_prefix(delimiter + 1); - - if (parent) - { - // strip trailing colons - std::string::size_type len = result.length(); - while ((len > 1) && (result[--len] == ':')) - result.resize(len); - - // remove the last path part, leaving the last colon - if (result != ":") - { - std::string::size_type lastcolon = result.find_last_of(':'); - if (lastcolon != std::string::npos) - result.resize(lastcolon + 1); - } - } - else - { - // collapse successive colons - if (result.back() != ':') - result.append(1, ':'); - delimiter = tag.find_first_not_of(':'); - if (delimiter != std::string_view::npos) - tag.remove_prefix(delimiter); - } - } - - // copy everything else - result.append(tag); - - return result; -} - std::string memory_share::compare(u8 width, size_t bytes, endianness_t endianness) const { if (width != m_bitwidth) diff --git a/src/emu/emumem.h b/src/emu/emumem.h index b6801d9a1ad..0c18ed95834 100644 --- a/src/emu/emumem.h +++ b/src/emu/emumem.h @@ -2589,7 +2589,6 @@ public: u8 *end() { return base() + m_buffer.size(); } u32 bytes() const { return m_buffer.size(); } const std::string &name() const { return m_name; } - std::string sibling(std::string_view tag) const; // flag expansion endianness_t endianness() const { return m_endianness; } diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp index 9ca35ea524f..33541aedce4 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -960,10 +960,10 @@ void rom_load_manager::fill_rom_data(memory_region ®ion, const rom_entry *rom copy_rom_data - copy a region of ROM space -------------------------------------------------*/ -void rom_load_manager::copy_rom_data(memory_region ®ion, const rom_entry *romp) +void rom_load_manager::copy_rom_data(device_t &device, memory_region ®ion, const rom_entry *romp) { u8 *base = region.base() + ROM_GETOFFSET(romp); - const std::string srcrgntag = region.sibling(romp->name()); + const std::string srcrgntag = device.subtag(romp->name()); u32 numbytes = ROM_GETLENGTH(romp); u32 srcoffs = u32(strtol(romp->hashdata().c_str(), nullptr, 0)); /* srcoffset in place of hashdata */ @@ -995,6 +995,7 @@ void rom_load_manager::copy_rom_data(memory_region ®ion, const rom_entry *rom -------------------------------------------------*/ void rom_load_manager::process_rom_entries( + device_t &device, const std::vector &searchpath, u8 bios, memory_region ®ion, @@ -1028,7 +1029,7 @@ void rom_load_manager::process_rom_entries( } else if (ROMENTRY_ISCOPY(romp)) { - copy_rom_data(region, romp++); + copy_rom_data(device, region, romp++); } else if (ROMENTRY_ISFILE(romp)) { @@ -1437,7 +1438,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list // now process the entries in the region if (ROMREGION_ISROMDATA(region)) { - process_rom_entries(swsearch, 0U, *memregion, region, region + 1, true); + process_rom_entries(device, swsearch, 0U, *memregion, region, region + 1, true); } else if (ROMREGION_ISDISKDATA(region)) { @@ -1510,7 +1511,7 @@ void rom_load_manager::process_region_list() if (searchpath.empty()) searchpath = device.searchpath(); assert(!searchpath.empty()); - process_rom_entries(searchpath, device.system_bios(), *memregion, region, region + 1, false); + process_rom_entries(device, searchpath, device.system_bios(), *memregion, region, region + 1, false); } else if (ROMREGION_ISDISKDATA(region)) { diff --git a/src/emu/romload.h b/src/emu/romload.h index 4ad0303a9f6..f655b81bf78 100644 --- a/src/emu/romload.h +++ b/src/emu/romload.h @@ -461,8 +461,9 @@ private: int rom_fread(emu_file *file, u8 *buffer, int length, const rom_entry *parent_region); int read_rom_data(emu_file *file, memory_region ®ion, const rom_entry *parent_region, const rom_entry *romp); void fill_rom_data(memory_region ®ion, const rom_entry *romp); - void copy_rom_data(memory_region ®ion, const rom_entry *romp); + void copy_rom_data(device_t &device, memory_region ®ion, const rom_entry *romp); void process_rom_entries( + device_t &device, const std::vector &searchpath, u8 bios, memory_region ®ion, diff --git a/src/mame/sega/segaufo.cpp b/src/mame/sega/segaufo.cpp index ed98ad9eee7..df14e4a576e 100644 --- a/src/mame/sega/segaufo.cpp +++ b/src/mame/sega/segaufo.cpp @@ -258,9 +258,10 @@ TIMER_CALLBACK_MEMBER(ufo_state::simulate_xyz) #if 0 // show io2 outputs std::ostringstream msg; + msg << std::uppercase << std::hex << std::setfill('0'); for (int i = 0; i < 8; i++) { - msg << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << +m_io[1]->debug_peek_output(i); + msg << std::setw(2) << +m_io[1]->debug_peek_output(i); if (i != 7) msg << " "; } popmessage("%s", std::move(msg).str()); diff --git a/src/mame/universal/docastle.cpp b/src/mame/universal/docastle.cpp index e27400a53cc..0ee3045ae47 100644 --- a/src/mame/universal/docastle.cpp +++ b/src/mame/universal/docastle.cpp @@ -201,8 +201,8 @@ public: m_palette(*this, "palette") { } - void dorunrun(machine_config &config); - void docastle(machine_config &config); + void dorunrun(machine_config &config) ATTR_COLD; + void docastle(machine_config &config) ATTR_COLD; protected: virtual void machine_start() override ATTR_COLD; @@ -266,7 +266,7 @@ public: m_adpcm_rom(*this, "adpcm") { } - void idsoccer(machine_config &config); + void idsoccer(machine_config &config) ATTR_COLD; protected: virtual void machine_start() override ATTR_COLD; -- cgit v1.2.3