Fix the memory windows (nw)

This commit is contained in:
Olivier Galibert 2017-12-03 15:03:58 +01:00
parent a203fc9d0c
commit 82d9463dc0
2 changed files with 36 additions and 18 deletions

View File

@ -98,6 +98,7 @@ debug_view_memory::debug_view_memory(running_machine &machine, debug_view_osd_up
m_expression(machine), m_expression(machine),
m_chunks_per_row(16), m_chunks_per_row(16),
m_bytes_per_chunk(1), m_bytes_per_chunk(1),
m_steps_per_chunk(1),
m_data_format(1), m_data_format(1),
m_reverse_view(false), m_reverse_view(false),
m_ascii_view(true), m_ascii_view(true),
@ -197,6 +198,7 @@ void debug_view_memory::view_notify(debug_view_notification type)
if (m_bytes_per_chunk > 8) if (m_bytes_per_chunk > 8)
m_bytes_per_chunk = 8; m_bytes_per_chunk = 8;
m_data_format = m_bytes_per_chunk; m_data_format = m_bytes_per_chunk;
m_steps_per_chunk = source.m_space ? source.m_space->byte_to_address(m_bytes_per_chunk) : m_bytes_per_chunk;
if (source.m_space != nullptr) if (source.m_space != nullptr)
m_expression.set_context(&source.m_space->device().debug()->symtable()); m_expression.set_context(&source.m_space->device().debug()->symtable());
else else
@ -290,7 +292,8 @@ void debug_view_memory::view_update()
if (dest >= destmin && dest < destmax) if (dest >= destmin && dest < destmax)
dest->byte = addrtext[ch]; dest->byte = addrtext[ch];
// generate the data // generate the data and the ascii string
std::string chunkascii;
for (int chunknum = 0; chunknum < m_chunks_per_row; chunknum++) for (int chunknum = 0; chunknum < m_chunks_per_row; chunknum++)
{ {
int chunkindex = m_reverse_view ? (m_chunks_per_row - 1 - chunknum) : chunknum; int chunkindex = m_reverse_view ? (m_chunks_per_row - 1 - chunknum) : chunknum;
@ -298,7 +301,7 @@ void debug_view_memory::view_update()
if (m_data_format <= 8) { if (m_data_format <= 8) {
u64 chunkdata; u64 chunkdata;
bool ismapped = read(m_bytes_per_chunk, addrbyte + chunknum * m_bytes_per_chunk, chunkdata); bool ismapped = read(m_bytes_per_chunk, address + chunknum * m_steps_per_chunk, chunkdata);
dest = destrow + m_section[1].m_pos + 1 + chunkindex * spacing; dest = destrow + m_section[1].m_pos + 1 + chunkindex * spacing;
for (int ch = 0; ch < posdata.m_spacing; ch++, dest++) for (int ch = 0; ch < posdata.m_spacing; ch++, dest++)
if (dest >= destmin && dest < destmax) if (dest >= destmin && dest < destmax)
@ -307,6 +310,10 @@ void debug_view_memory::view_update()
if (shift < 64) if (shift < 64)
dest->byte = ismapped ? "0123456789ABCDEF"[(chunkdata >> shift) & 0x0f] : '*'; dest->byte = ismapped ? "0123456789ABCDEF"[(chunkdata >> shift) & 0x0f] : '*';
} }
for (int i=0; i < m_bytes_per_chunk; i++) {
u8 chval = chunkdata >> (8 * (m_bytes_per_chunk - i - 1));
chunkascii += char((ismapped && isprint(chval)) ? chval : '.');
}
} }
else { else {
int ch; int ch;
@ -316,9 +323,9 @@ void debug_view_memory::view_update()
bool ismapped; bool ismapped;
if (m_data_format != 11) if (m_data_format != 11)
ismapped = read(m_bytes_per_chunk, addrbyte + chunknum * m_bytes_per_chunk, chunkdata); ismapped = read(m_bytes_per_chunk, address + chunknum * m_steps_per_chunk, chunkdata);
else else
ismapped = read(m_bytes_per_chunk, addrbyte + chunknum * m_bytes_per_chunk, chunkdata80); ismapped = read(m_bytes_per_chunk, address + chunknum * m_steps_per_chunk, chunkdata80);
if (ismapped) if (ismapped)
switch (m_data_format) switch (m_data_format)
@ -338,6 +345,7 @@ void debug_view_memory::view_update()
valuetext[0] = '*'; valuetext[0] = '*';
valuetext[1] = 0; valuetext[1] = 0;
} }
dest = destrow + m_section[1].m_pos + 1 + chunkindex * spacing; dest = destrow + m_section[1].m_pos + 1 + chunkindex * spacing;
// first copy the text // first copy the text
for (ch = 0; (ch < spacing) && (valuetext[ch] != 0); ch++, dest++) for (ch = 0; (ch < spacing) && (valuetext[ch] != 0); ch++, dest++)
@ -347,20 +355,23 @@ void debug_view_memory::view_update()
for (; ch < spacing; ch++, dest++) for (; ch < spacing; ch++, dest++)
if (dest >= destmin && dest < destmax) if (dest >= destmin && dest < destmax)
dest->byte = ' '; dest->byte = ' ';
for (int i=0; i < m_bytes_per_chunk; i++) {
u8 chval = chunkdata >> (8 * (m_bytes_per_chunk - i - 1));
chunkascii += char((ismapped && isprint(chval)) ? chval : '.');
}
} }
} }
// generate the ASCII data // generate the ASCII data, but follow the chunks
if (m_section[2].m_width > 0) if (m_section[2].m_width > 0)
{ {
dest = destrow + m_section[2].m_pos + 1; dest = destrow + m_section[2].m_pos + 1;
for (int ch = 0; ch < m_bytes_per_row; ch++, dest++) for (size_t i = 0; i != chunkascii.size(); i++) {
if (dest >= destmin && dest < destmax) if (dest >= destmin && dest < destmax)
{ dest->byte = chunkascii[i];
u64 chval; dest++;
bool ismapped = read(1, addrbyte + ch, chval); }
dest->byte = (ismapped && isprint(chval)) ? chval : '.';
}
} }
} }
} }
@ -563,7 +574,10 @@ void debug_view_memory::recompute()
// recompute the byte offset based on the most recent expression result // recompute the byte offset based on the most recent expression result
m_bytes_per_row = m_bytes_per_chunk * m_chunks_per_row; m_bytes_per_row = m_bytes_per_chunk * m_chunks_per_row;
m_byte_offset = m_expression.value() % m_bytes_per_row; offs_t val = m_expression.value();
if (source.m_space)
val = source.m_space->address_to_byte(val);
m_byte_offset = val % m_bytes_per_row;
// compute the section widths // compute the section widths
m_section[0].m_width = 1 + 8 + 1; m_section[0].m_width = 1 + 8 + 1;
@ -612,17 +626,20 @@ bool debug_view_memory::needs_recompute()
// handle expression changes // handle expression changes
if (m_expression.dirty()) if (m_expression.dirty())
{ {
const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
offs_t val = m_expression.value();
if (source.m_space)
val = source.m_space->address_to_byte(val);
recompute = true; recompute = true;
m_topleft.y = (m_expression.value() - m_byte_offset) / m_bytes_per_row; m_topleft.y = (val - m_byte_offset) / m_bytes_per_row;
m_topleft.y = std::max(m_topleft.y, 0); m_topleft.y = std::max(m_topleft.y, 0);
m_topleft.y = std::min(m_topleft.y, m_total.y - 1); m_topleft.y = std::min(m_topleft.y, m_total.y - 1);
const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
offs_t resultbyte; offs_t resultbyte;
if (source.m_space != nullptr) if (source.m_space != nullptr)
resultbyte = m_expression.value() & source.m_space->logaddrmask(); resultbyte = val & source.m_space->logaddrmask();
else else
resultbyte = m_expression.value(); resultbyte = val;
set_cursor_pos(cursor_pos(resultbyte, m_bytes_per_chunk * 8 - 4)); set_cursor_pos(cursor_pos(resultbyte, m_bytes_per_chunk * 8 - 4));
} }
@ -740,7 +757,7 @@ bool debug_view_memory::read(u8 size, offs_t offs, u64 &data)
const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source); const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
// if no raw data, just use the standard debug routines // if no raw data, just use the standard debug routines
if (source.m_space != nullptr) if (source.m_space)
{ {
auto dis = machine().disable_side_effect(); auto dis = machine().disable_side_effect();
@ -823,7 +840,7 @@ void debug_view_memory::write(u8 size, offs_t offs, u64 data)
const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source); const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
// if no raw data, just use the standard debug routines // if no raw data, just use the standard debug routines
if (source.m_space != nullptr) if (source.m_space)
{ {
auto dis = machine().disable_side_effect(); auto dis = machine().disable_side_effect();

View File

@ -107,6 +107,7 @@ private:
debug_view_expression m_expression; // expression describing the start address debug_view_expression m_expression; // expression describing the start address
u32 m_chunks_per_row; // number of chunks displayed per line u32 m_chunks_per_row; // number of chunks displayed per line
u8 m_bytes_per_chunk; // bytes per chunk u8 m_bytes_per_chunk; // bytes per chunk
u8 m_steps_per_chunk; // bytes per chunk
int m_data_format; // 1-8 current values 9 32bit floating point int m_data_format; // 1-8 current values 9 32bit floating point
bool m_reverse_view; // reverse-endian view? bool m_reverse_view; // reverse-endian view?
bool m_ascii_view; // display ASCII characters? bool m_ascii_view; // display ASCII characters?