summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-12-05 16:02:22 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-12-05 16:02:22 +0000
commite2c9b10241a49226c9b1a0f58d3e2f9e81d64236 (patch)
treefcbe12e6d3632196a370b5628104a8cb2642371a
parent12f71dac82ee894f703c630d22625277ebee7821 (diff)
Fixed some memory view-related issues:
* select correct memory region by default when created (should be first address space of visible CPU) * when created, default bytes/chunk is correct * when changing width, cursor no longer moves around * memory regions display more than all 0xff now Also fixed: * qword big-endian memory reads no longer call little-endian handlers * memory regions are tracked in creation order (show up in order in the menu now) * ROMREGION_DISPOSE memory regions are not disposed if the debugger is enabled
-rw-r--r--src/emu/debug/debugvw.c24
-rw-r--r--src/emu/mame.c34
-rw-r--r--src/emu/memory.c12
-rw-r--r--src/osd/windows/debugwin.c5
4 files changed, 45 insertions, 30 deletions
diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c
index 89217b70447..4bf141c962a 100644
--- a/src/emu/debug/debugvw.c
+++ b/src/emu/debug/debugvw.c
@@ -2413,6 +2413,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->next = NULL;
subview->index = curindex++;
subview->space = space;
+ subview->endianness = space->endianness;
subview->prefsize = space->dbits / 8;
strcpy(subview->name, astring_c(tempstring));
@@ -2440,7 +2441,11 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->index = curindex++;
subview->base = memory_region(machine, rgntag);
subview->length = memory_region_length(machine, rgntag);
- subview->offsetxor = memory_region_length(machine, rgntag);
+#ifdef LSB_FIRST
+ subview->offsetxor = width - 1;
+#else
+ subview->offsetxor = 0;
+#endif
subview->endianness = little_endian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
subview->prefsize = MIN(width, 8);
strcpy(subview->name, astring_c(tempstring));
@@ -2530,9 +2535,9 @@ static int memory_view_alloc(debug_view *view)
memdata->desc = view->machine->debugvw_data->memory_subviews;
/* start out with 16 bytes in a single column and ASCII displayed */
- memdata->chunks_per_row = 16;
- memdata->bytes_per_chunk = 1;
- memdata->bytes_per_row = 16;
+ memdata->bytes_per_chunk = memdata->desc->prefsize;
+ memdata->chunks_per_row = 16 / memdata->desc->prefsize;
+ memdata->bytes_per_row = memdata->bytes_per_chunk * memdata->chunks_per_row;
memdata->ascii_view = TRUE;
return TRUE;
@@ -2888,6 +2893,9 @@ static int memory_view_needs_recompute(debug_view *view)
if (debug_view_expression_changed_value(view, &memdata->expression, (space != NULL) ? space->cpu : NULL))
{
recompute = TRUE;
+ view->topleft.y = (memdata->expression.result - memdata->byte_offset) / memdata->bytes_per_row;
+ view->topleft.y = MAX(view->topleft.y, 0);
+ view->topleft.y = MIN(view->topleft.y, view->total.y - 1);
memory_view_set_cursor_pos(view, memdata->expression.result, memdata->bytes_per_chunk * 8 - 4);
}
@@ -3261,16 +3269,20 @@ void memory_view_set_bytes_per_chunk(debug_view *view, UINT8 chunkbytes)
if (chunkbytes != memdata->bytes_per_chunk)
{
+ int endianness = memdata->desc->endianness;
offs_t address;
UINT8 shift;
debug_view_begin_update(view);
memory_view_get_cursor_pos(view, &address, &shift);
+ address += (shift / 8) ^ ((endianness == ENDIANNESS_LITTLE) ? 0 : (memdata->bytes_per_chunk - 1));
+ shift %= 8;
+
memdata->bytes_per_chunk = chunkbytes;
memdata->chunks_per_row = memdata->bytes_per_row / chunkbytes;
view->recompute = view->update_pending = TRUE;
- address += shift / 8;
- shift = (shift % 8) + 8 * (address % memdata->bytes_per_chunk);
+
+ shift += 8 * ((address % memdata->bytes_per_chunk) ^ ((endianness == ENDIANNESS_LITTLE) ? 0 : (memdata->bytes_per_chunk - 1)));
address -= address % memdata->bytes_per_chunk;
memory_view_set_cursor_pos(view, address, shift);
debug_view_end_update(view);
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 8a8f41be2ac..be75dc31cff 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -761,22 +761,22 @@ int mame_is_paused(running_machine *machine)
UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 length, UINT32 flags)
{
mame_private *mame = machine->mame_data;
- region_info *info;
+ region_info **infoptr, *info;
- /* make sure we don't have a region of the same name */
- for (info = mame->regions; info != NULL; info = info->next)
- if (astring_cmpc(info->name, name) == 0)
+ /* make sure we don't have a region of the same name; also find the end of the list */
+ for (infoptr = &mame->regions; *infoptr != NULL; infoptr = &(*infoptr)->next)
+ if (astring_cmpc((*infoptr)->name, name) == 0)
fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name);
/* allocate the region */
info = malloc_or_die(sizeof(*info) + length);
- info->next = mame->regions;
+ info->next = NULL;
info->name = astring_dupc(name);
info->length = length;
info->flags = flags;
/* hook us into the list */
- mame->regions = info;
+ *infoptr = info;
return info->base;
}
@@ -795,14 +795,14 @@ void memory_region_free(running_machine *machine, const char *name)
for (infoptr = &mame->regions; *infoptr != NULL; infoptr = &(*infoptr)->next)
if (astring_cmpc((*infoptr)->name, name) == 0)
{
- region_info *deleteme = *infoptr;
+ region_info *info = *infoptr;
/* remove us from the list */
- *infoptr = deleteme->next;
+ *infoptr = info->next;
/* free the region */
- astring_free(deleteme->name);
- free(deleteme);
+ astring_free(info->name);
+ free(info);
break;
}
}
@@ -1596,12 +1596,14 @@ static void init_machine(running_machine *machine)
(*machine->config->video_start)(machine);
/* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */
- for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = nextrgntag)
- {
- nextrgntag = memory_region_next(machine, rgntag);
- if (memory_region_flags(machine, rgntag) & ROMREGION_DISPOSE)
- memory_region_free(machine, rgntag);
- }
+ /* but not if the debugger is enabled (so we can look at the data) */
+ if (!options_get_bool(mame_options(), OPTION_DEBUG))
+ for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = nextrgntag)
+ {
+ nextrgntag = memory_region_next(machine, rgntag);
+ if (memory_region_flags(machine, rgntag) & ROMREGION_DISPOSE)
+ memory_region_free(machine, rgntag);
+ }
/* initialize miscellaneous systems */
saveload_init(machine);
diff --git a/src/emu/memory.c b/src/emu/memory.c
index 299bd292aaf..e3bbc7f23e4 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -3775,8 +3775,8 @@ UINT64 memory_read_qword_masked_8le(const address_space *space, offs_t address,
UINT64 memory_read_qword_8be(const address_space *space, offs_t address)
{
- UINT64 result = (UINT64)memory_read_dword_8le(space, address + 0) << 32;
- return result | ((UINT64)memory_read_dword_8le(space, address + 4) << 0);
+ UINT64 result = (UINT64)memory_read_dword_8be(space, address + 0) << 32;
+ return result | ((UINT64)memory_read_dword_8be(space, address + 4) << 0);
}
UINT64 memory_read_qword_masked_8be(const address_space *space, offs_t address, UINT64 mask)
@@ -3957,8 +3957,8 @@ UINT64 memory_read_qword_masked_16le(const address_space *space, offs_t address,
UINT64 memory_read_qword_16be(const address_space *space, offs_t address)
{
- UINT64 result = (UINT64)memory_read_dword_16le(space, address + 0) << 32;
- return result | ((UINT64)memory_read_dword_16le(space, address + 4) << 0);
+ UINT64 result = (UINT64)memory_read_dword_16be(space, address + 0) << 32;
+ return result | ((UINT64)memory_read_dword_16be(space, address + 4) << 0);
}
UINT64 memory_read_qword_masked_16be(const address_space *space, offs_t address, UINT64 mask)
@@ -4133,8 +4133,8 @@ UINT64 memory_read_qword_masked_32le(const address_space *space, offs_t address,
UINT64 memory_read_qword_32be(const address_space *space, offs_t address)
{
- UINT64 result = (UINT64)memory_read_dword_32le(space, address + 0) << 32;
- return result | ((UINT64)memory_read_dword_32le(space, address + 4) << 0);
+ UINT64 result = (UINT64)memory_read_dword_32be(space, address + 0) << 32;
+ return result | ((UINT64)memory_read_dword_32be(space, address + 4) << 0);
}
UINT64 memory_read_qword_masked_32be(const address_space *space, offs_t address, UINT64 mask)
diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c
index febf33776cb..a09cb1740ed 100644
--- a/src/osd/windows/debugwin.c
+++ b/src/osd/windows/debugwin.c
@@ -1683,7 +1683,7 @@ static void memory_create_window(running_machine *machine)
const memory_subview_item *subview;
debugwin_info *info;
HMENU optionsmenu;
- int cursel = 0;
+ int cursel = -1;
// create the window
info = debugwin_window_create(machine, "Memory", NULL);
@@ -1738,9 +1738,10 @@ static void memory_create_window(running_machine *machine)
TCHAR *t_name = tstring_from_utf8(subview->name);
int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
free(t_name);
- if (cursel == 0 && subview->space != NULL && subview->space->cpu == curcpu)
+ if (cursel == -1 && subview->space != NULL && subview->space->cpu == curcpu)
cursel = item;
}
+ if (cursel == -1) cursel = 0;
SendMessage(info->otherwnd[0], CB_SETCURSEL, cursel, 0);
memory_view_set_subview(info->view[0].view, cursel);