summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2019-07-29 19:26:27 -0400
committer AJR <ajrhacker@users.noreply.github.com>2019-07-29 19:30:18 -0400
commit19925e79ab6655aca8601d58cd652e5390cbe2c3 (patch)
tree940f270d086d587a3cae07e654ad22b8fea1d75d
parent6747ee065f73f51fbb48c5da17210ba9f291c3d6 (diff)
Make debug memory view show correct data when chunks are too small for a space's address shift
-rw-r--r--src/emu/debug/dvmemory.cpp27
-rw-r--r--src/emu/debug/dvmemory.h1
2 files changed, 27 insertions, 1 deletions
diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp
index fd27ca40abd..947c387800b 100644
--- a/src/emu/debug/dvmemory.cpp
+++ b/src/emu/debug/dvmemory.cpp
@@ -305,7 +305,7 @@ void debug_view_memory::view_update()
if (m_data_format <= 8) {
u64 chunkdata;
- bool ismapped = read(m_bytes_per_chunk, address + chunknum * m_steps_per_chunk, chunkdata);
+ bool ismapped = read_chunk(address, chunknum, chunkdata);
dest = destrow + m_section[1].m_pos + 1 + chunkindex * spacing;
for (int ch = 0; ch < posdata.m_spacing; ch++, dest++)
if (dest >= destmin && dest < destmax)
@@ -834,6 +834,31 @@ bool debug_view_memory::read(u8 size, offs_t offs, floatx80 &data)
//-------------------------------------------------
+// read_chunk - memory view data reader helper
+//-------------------------------------------------
+
+bool debug_view_memory::read_chunk(offs_t address, int chunknum, u64 &chunkdata)
+{
+ const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
+ if (source.m_space) {
+ address += source.m_space->byte_to_address(chunknum * m_bytes_per_chunk);
+ if (!source.m_space->byte_to_address(m_bytes_per_chunk)) {
+ // if chunks are too small to be addressable, read a minimal chunk and split it up
+ u8 minbytes = 1 << -source.m_space->addr_shift();
+ bool ismapped = read(minbytes, address, chunkdata);
+ u8 suboffset = (chunknum * m_bytes_per_chunk) & (minbytes - 1);
+ chunkdata >>= 8 * (source.m_space->endianness() == ENDIANNESS_LITTLE ? suboffset : minbytes - m_bytes_per_chunk - suboffset);
+ chunkdata &= ~u64(0) >> (64 - 8 * m_bytes_per_chunk);
+ return ismapped;
+ }
+ }
+ else
+ address += chunknum * m_bytes_per_chunk;
+ return read(m_bytes_per_chunk, address, chunkdata);
+}
+
+
+//-------------------------------------------------
// write - generic memory view data writer
//-------------------------------------------------
diff --git a/src/emu/debug/dvmemory.h b/src/emu/debug/dvmemory.h
index c354b644053..a9341afcf76 100644
--- a/src/emu/debug/dvmemory.h
+++ b/src/emu/debug/dvmemory.h
@@ -102,6 +102,7 @@ private:
bool read(u8 size, offs_t offs, u64 &data);
void write(u8 size, offs_t offs, u64 data);
bool read(u8 size, offs_t offs, floatx80 &data);
+ bool read_chunk(offs_t address, int chunknum, u64 &chunkdata);
// internal state
debug_view_expression m_expression; // expression describing the start address