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
This commit is contained in:
Aaron Giles 2008-12-05 16:02:22 +00:00
parent 12f71dac82
commit e2c9b10241
4 changed files with 45 additions and 30 deletions

View File

@ -2413,6 +2413,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->next = NULL; subview->next = NULL;
subview->index = curindex++; subview->index = curindex++;
subview->space = space; subview->space = space;
subview->endianness = space->endianness;
subview->prefsize = space->dbits / 8; subview->prefsize = space->dbits / 8;
strcpy(subview->name, astring_c(tempstring)); 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->index = curindex++;
subview->base = memory_region(machine, rgntag); subview->base = memory_region(machine, rgntag);
subview->length = memory_region_length(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->endianness = little_endian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
subview->prefsize = MIN(width, 8); subview->prefsize = MIN(width, 8);
strcpy(subview->name, astring_c(tempstring)); 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; memdata->desc = view->machine->debugvw_data->memory_subviews;
/* start out with 16 bytes in a single column and ASCII displayed */ /* start out with 16 bytes in a single column and ASCII displayed */
memdata->chunks_per_row = 16; memdata->bytes_per_chunk = memdata->desc->prefsize;
memdata->bytes_per_chunk = 1; memdata->chunks_per_row = 16 / memdata->desc->prefsize;
memdata->bytes_per_row = 16; memdata->bytes_per_row = memdata->bytes_per_chunk * memdata->chunks_per_row;
memdata->ascii_view = TRUE; memdata->ascii_view = TRUE;
return 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)) if (debug_view_expression_changed_value(view, &memdata->expression, (space != NULL) ? space->cpu : NULL))
{ {
recompute = TRUE; 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); 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) if (chunkbytes != memdata->bytes_per_chunk)
{ {
int endianness = memdata->desc->endianness;
offs_t address; offs_t address;
UINT8 shift; UINT8 shift;
debug_view_begin_update(view); debug_view_begin_update(view);
memory_view_get_cursor_pos(view, &address, &shift); 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->bytes_per_chunk = chunkbytes;
memdata->chunks_per_row = memdata->bytes_per_row / chunkbytes; memdata->chunks_per_row = memdata->bytes_per_row / chunkbytes;
view->recompute = view->update_pending = TRUE; 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; address -= address % memdata->bytes_per_chunk;
memory_view_set_cursor_pos(view, address, shift); memory_view_set_cursor_pos(view, address, shift);
debug_view_end_update(view); debug_view_end_update(view);

View File

@ -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) UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 length, UINT32 flags)
{ {
mame_private *mame = machine->mame_data; 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 */ /* make sure we don't have a region of the same name; also find the end of the list */
for (info = mame->regions; info != NULL; info = info->next) for (infoptr = &mame->regions; *infoptr != NULL; infoptr = &(*infoptr)->next)
if (astring_cmpc(info->name, name) == 0) if (astring_cmpc((*infoptr)->name, name) == 0)
fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name); fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name);
/* allocate the region */ /* allocate the region */
info = malloc_or_die(sizeof(*info) + length); info = malloc_or_die(sizeof(*info) + length);
info->next = mame->regions; info->next = NULL;
info->name = astring_dupc(name); info->name = astring_dupc(name);
info->length = length; info->length = length;
info->flags = flags; info->flags = flags;
/* hook us into the list */ /* hook us into the list */
mame->regions = info; *infoptr = info;
return info->base; 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) for (infoptr = &mame->regions; *infoptr != NULL; infoptr = &(*infoptr)->next)
if (astring_cmpc((*infoptr)->name, name) == 0) if (astring_cmpc((*infoptr)->name, name) == 0)
{ {
region_info *deleteme = *infoptr; region_info *info = *infoptr;
/* remove us from the list */ /* remove us from the list */
*infoptr = deleteme->next; *infoptr = info->next;
/* free the region */ /* free the region */
astring_free(deleteme->name); astring_free(info->name);
free(deleteme); free(info);
break; break;
} }
} }
@ -1596,12 +1596,14 @@ static void init_machine(running_machine *machine)
(*machine->config->video_start)(machine); (*machine->config->video_start)(machine);
/* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */ /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */
for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = nextrgntag) /* but not if the debugger is enabled (so we can look at the data) */
{ if (!options_get_bool(mame_options(), OPTION_DEBUG))
nextrgntag = memory_region_next(machine, rgntag); for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = nextrgntag)
if (memory_region_flags(machine, rgntag) & ROMREGION_DISPOSE) {
memory_region_free(machine, rgntag); nextrgntag = memory_region_next(machine, rgntag);
} if (memory_region_flags(machine, rgntag) & ROMREGION_DISPOSE)
memory_region_free(machine, rgntag);
}
/* initialize miscellaneous systems */ /* initialize miscellaneous systems */
saveload_init(machine); saveload_init(machine);

View File

@ -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 memory_read_qword_8be(const address_space *space, offs_t address)
{ {
UINT64 result = (UINT64)memory_read_dword_8le(space, address + 0) << 32; UINT64 result = (UINT64)memory_read_dword_8be(space, address + 0) << 32;
return result | ((UINT64)memory_read_dword_8le(space, address + 4) << 0); 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) 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 memory_read_qword_16be(const address_space *space, offs_t address)
{ {
UINT64 result = (UINT64)memory_read_dword_16le(space, address + 0) << 32; UINT64 result = (UINT64)memory_read_dword_16be(space, address + 0) << 32;
return result | ((UINT64)memory_read_dword_16le(space, address + 4) << 0); 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) 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 memory_read_qword_32be(const address_space *space, offs_t address)
{ {
UINT64 result = (UINT64)memory_read_dword_32le(space, address + 0) << 32; UINT64 result = (UINT64)memory_read_dword_32be(space, address + 0) << 32;
return result | ((UINT64)memory_read_dword_32le(space, address + 4) << 0); 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) UINT64 memory_read_qword_masked_32be(const address_space *space, offs_t address, UINT64 mask)

View File

@ -1683,7 +1683,7 @@ static void memory_create_window(running_machine *machine)
const memory_subview_item *subview; const memory_subview_item *subview;
debugwin_info *info; debugwin_info *info;
HMENU optionsmenu; HMENU optionsmenu;
int cursel = 0; int cursel = -1;
// create the window // create the window
info = debugwin_window_create(machine, "Memory", NULL); 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); TCHAR *t_name = tstring_from_utf8(subview->name);
int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name); int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
free(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; cursel = item;
} }
if (cursel == -1) cursel = 0;
SendMessage(info->otherwnd[0], CB_SETCURSEL, cursel, 0); SendMessage(info->otherwnd[0], CB_SETCURSEL, cursel, 0);
memory_view_set_subview(info->view[0].view, cursel); memory_view_set_subview(info->view[0].view, cursel);