diff options
| author | 2024-11-22 01:02:31 +0000 | |
|---|---|---|
| committer | 2024-11-22 07:40:37 +0000 | |
| commit | f7896632443d4947e77832d6fd51196e6dea2371 (patch) | |
| tree | d024948f37b4d41732b5fee5dcff31a72e5f16e7 /src | |
| parent | 3e388b7da7575a0bf3c66ee286782b45dbe050ee (diff) | |
fixed ROM_COPY to use a relative region name, so it can be used in a device. [smf]
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/emumem.cpp | 58 | ||||
| -rw-r--r-- | src/emu/emumem.h | 1 | ||||
| -rw-r--r-- | src/emu/romload.cpp | 2 |
3 files changed, 60 insertions, 1 deletions
diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp index 679c2374e78..86b1bd8512b 100644 --- a/src/emu/emumem.cpp +++ b/src/emu/emumem.cpp @@ -1077,6 +1077,64 @@ 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 0c18ed95834..b6801d9a1ad 100644 --- a/src/emu/emumem.h +++ b/src/emu/emumem.h @@ -2589,6 +2589,7 @@ 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 a429153be3f..9ca35ea524f 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -963,7 +963,7 @@ void rom_load_manager::fill_rom_data(memory_region ®ion, const rom_entry *rom void rom_load_manager::copy_rom_data(memory_region ®ion, const rom_entry *romp) { u8 *base = region.base() + ROM_GETOFFSET(romp); - const std::string &srcrgntag = romp->name(); + const std::string srcrgntag = region.sibling(romp->name()); u32 numbytes = ROM_GETLENGTH(romp); u32 srcoffs = u32(strtol(romp->hashdata().c_str(), nullptr, 0)); /* srcoffset in place of hashdata */ |
