summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2025-09-05 00:24:22 +0200
committer Olivier Galibert <galibert@pobox.com>2025-09-05 00:25:35 +0200
commit049ded9107774c4dd6fecffb747fb0ec70df8444 (patch)
treecb8837b73347a97d440cdc1864a9df4c1614e240
parenta7d0ff167cec3c93735188672d531a47f19aea94 (diff)
emumem_mud: Correct address shift computations. I don't understand
why it was never seen before, I hope it doesn't mean some code in drivers compensated for the bug, because it's going to break.
-rw-r--r--src/emu/emumem_mud.cpp21
-rw-r--r--src/emu/emumem_mud.h2
2 files changed, 15 insertions, 8 deletions
diff --git a/src/emu/emumem_mud.cpp b/src/emu/emumem_mud.cpp
index 4c52b5a1301..45da0a051b2 100644
--- a/src/emu/emumem_mud.cpp
+++ b/src/emu/emumem_mud.cpp
@@ -61,21 +61,28 @@ template<int Width, int AddrShift> memory_units_descriptor<Width, AddrShift>::me
umasks[handler_entry::END] &= emask;
umasks[handler_entry::START|handler_entry::END] &= smask & emask;
+ if(m_addrstart == m_addrend)
+ umasks[0] = umasks[handler_entry::START] = umasks[handler_entry::END] = umasks[handler_entry::START|handler_entry::END];
+
+
for(u32 i=0; i<4; i++)
m_keymap[i] = mask_to_ukey<uX>(umasks[i]);
-
+
// Compute the shift
+ uX umask = umasks[m_addrstart == m_addrend ? handler_entry::START|handler_entry::END : 0];
uX dmask = make_bitmask<uX>(bits_per_access);
u32 active_count = 0;
+ s8 shift_base = -1;
for(u32 i=0; i != 8 << Width; i += bits_per_access)
- if(unitmask & (dmask << i))
+ if(umask & (dmask << i)) {
active_count ++;
+ if(shift_base == -1)
+ shift_base = i;
+ }
u32 active_count_log = active_count == 1 ? 0 : active_count == 2 ? 1 : active_count == 4 ? 2 : active_count == 8 ? 3 : 0xff;
if(active_count_log == 0xff)
abort();
- s8 base_shift = Width - access_width - active_count_log;
- s8 shift = base_shift + access_width + AddrShift;
-
+ s8 shift = active_count_log + AddrShift;
// Build the handler characteristics
m_handler_start = shift < 0 ? addrstart << -shift : addrstart >> shift;
@@ -83,10 +90,10 @@ template<int Width, int AddrShift> memory_units_descriptor<Width, AddrShift>::me
for(u32 i=0; i<4; i++)
if(m_entries_for_key.find(m_keymap[i]) == m_entries_for_key.end())
- generate(m_keymap[i], unitmask, umasks[i], cswidth, bits_per_access, base_shift, shift, active_count);
+ generate(m_keymap[i], unitmask, umasks[i], cswidth, bits_per_access, shift, active_count);
}
-template<int Width, int AddrShift> void memory_units_descriptor<Width, AddrShift>::generate(u8 ukey, emu::detail::handler_entry_size_t<Width> gumask, emu::detail::handler_entry_size_t<Width> umask, u32 cswidth, u32 bits_per_access, u8 base_shift, s8 shift, u32 active_count)
+template<int Width, int AddrShift> void memory_units_descriptor<Width, AddrShift>::generate(u8 ukey, emu::detail::handler_entry_size_t<Width> gumask, emu::detail::handler_entry_size_t<Width> umask, u32 cswidth, u32 bits_per_access, s8 shift, u32 active_count)
{
auto &entries = m_entries_for_key[ukey];
diff --git a/src/emu/emumem_mud.h b/src/emu/emumem_mud.h
index 4a8b6509aa0..be195aa71c6 100644
--- a/src/emu/emumem_mud.h
+++ b/src/emu/emumem_mud.h
@@ -37,5 +37,5 @@ private:
u8 m_access_width;
endianness_t m_access_endian;
- void generate(u8 ukey, uX gumask, uX umask, u32 cswidth, u32 bits_per_access, u8 base_shift, s8 shift, u32 active_count);
+ void generate(u8 ukey, uX gumask, uX umask, u32 cswidth, u32 bits_per_access, s8 shift, u32 active_count);
};