summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcmd.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-08-19 06:57:51 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-08-19 06:57:51 +0000
commitdd19e512c03c58a100ae5025c9fd7624387667fd (patch)
tree28462fd2aa1b3a76b823d5c21ce65678085e6c8f /src/emu/debug/debugcmd.c
parentbf9afe4c4bb2112d706452c7b73bd8ebce16e3e0 (diff)
Massive memory system change. This is another step along the path toward
supporting cleaner implementations of drivers in the explicitly OO world. Expect a follow-on of several more changes to clean up from this one, which deliberately tried to avoid touching much driver code. Converted address_space to a class, and moved most members behind accessor methods, apart from space->machine and space->cpu. Removed external references to 8le/8be/16le/16be/32le/32be/64le/64be. All external access is now done via virtual functions read_byte()/read_word()/etc. Moved differentiation between the endianness and the bus width internal to memory.c, and also added a new axis to support small/large address spaces, which allows for faster lookups on spaces smaller than 18 bits. Provided methods for most global memory operations within the new address_space class. These will be bulk converted in a future update, but for now there are inline wrappers to hide this change from existing callers. Created new module delegate.h which implements C++ delegates in a form that works for MAME. Details are in the opening comment. Delegates allow member functions of certain classes to be used as callbacks, which will hopefully be the beginning of the end of fetching the driver_data field in most callbacks. All classes that host delegates must derive from bindable_object. Today, all devices and driver_data do implicitly via their base class. Defined delegates for read/write handlers. The new delegates are always passed an address_space reference, along with offset, data, and mask. Delegates can refer to methods either in the driver_data class or in a device class. To specify a callback in an address map, just use AM_READ_MEMBER(class, member). In fact, all existing AM_ macros that take read/write handlers can now accept delegates in their place. Delegates that are specified in an address map are proto-delegates which have no object; they are bound to their object when the corresponding address_space is created. Added machine->m_nonspecific_space which can be passed as the required address_space parameter to the new read/write methods in legacy situations where the space is not provided. Eventually this can go away but we will need it for a while yet. Added methods to the new address_space class to dynamically install delegates just like you can dynamically install handlers today. Delegates installed this way must be pre-bound to their object. Moved beathead's read/write handlers into members of beathead_state as an example of using the new delegates. This provides examples of both static (via an address_map) and dynamic (via install_handler calls) mapping using delegates. Added read/write member functions to okim6295_device as an example of using delegates to call devices. Updated audio/williams.c as a single example of calling the device via its member function callbacks. These will be bulk updated in a future update, and the old global callbacks removed. Changed the DIRECT_UPDATE_CALLBACKs into delegates as well. Updated all users to the new function format. Added methods on direct_read_data for configuring the parameters in a standard way to make the implementation clearer. Created a simple_list template container class for managing the common singly-linked lists we use all over in the project. Many other internal changes in memory.c, mostly involving restructuring the code into proper classes.
Diffstat (limited to 'src/emu/debug/debugcmd.c')
-rw-r--r--src/emu/debug/debugcmd.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index f93d40b5d82..c639226240d 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -1438,14 +1438,14 @@ static void execute_wplist(running_machine *machine, int ref, int params, const
{
static const char *const types[] = { "unkn ", "read ", "write", "r/w " };
- debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device->tag(), device->debug()->watchpoint_first(spacenum)->space().name);
+ debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device->tag(), device->debug()->watchpoint_first(spacenum)->space().name());
/* loop over the watchpoints */
for (device_debug::watchpoint *wp = device->debug()->watchpoint_first(spacenum); wp != NULL; wp = wp->next())
{
buffer.printf("%c%4X @ %s-%s %s", wp->enabled() ? ' ' : 'D', wp->index(),
- core_i64_hex_format(memory_byte_to_address(&wp->space(), wp->address()), wp->space().addrchars),
- core_i64_hex_format(memory_byte_to_address_end(&wp->space(), wp->address() + wp->length()) - 1, wp->space().addrchars),
+ core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars()),
+ core_i64_hex_format(wp->space().byte_to_address_end(wp->address() + wp->length()) - 1, wp->space().addrchars()),
types[wp->type() & 3]);
if (wp->condition() != NULL)
buffer.catprintf(" if %s", wp->condition());
@@ -1524,8 +1524,8 @@ static void execute_save(running_machine *machine, int ref, int params, const ch
return;
/* determine the addresses to write */
- endoffset = memory_address_to_byte(space, offset + length - 1) & space->bytemask;
- offset = memory_address_to_byte(space, offset) & space->bytemask;
+ endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
+ offset = space->address_to_byte(offset) & space->bytemask();
/* open the file */
f = fopen(param[0], "wb");
@@ -1573,16 +1573,16 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
/* further validation */
if (width == 0)
- width = space->dbits / 8;
- if (width < memory_address_to_byte(space, 1))
- width = memory_address_to_byte(space, 1);
+ width = space->data_width() / 8;
+ if (width < space->address_to_byte(1))
+ width = space->address_to_byte(1);
if (width != 1 && width != 2 && width != 4 && width != 8)
{
debug_console_printf(machine, "Invalid width! (must be 1,2,4 or 8)\n");
return;
}
- endoffset = memory_address_to_byte(space, offset + length - 1) & space->bytemask;
- offset = memory_address_to_byte(space, offset) & space->bytemask;
+ endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
+ offset = space->address_to_byte(offset) & space->bytemask();
/* open the file */
f = fopen(param[0], "w");
@@ -1599,7 +1599,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch
int outdex = 0;
/* print the address */
- outdex += sprintf(&output[outdex], "%s: ", core_i64_hex_format((UINT32)memory_byte_to_address(space, i), space->logaddrchars));
+ outdex += sprintf(&output[outdex], "%s: ", core_i64_hex_format((UINT32)space->byte_to_address(i), space->logaddrchars()));
/* print the bytes */
for (j = 0; j < 16; j += width)
@@ -1711,19 +1711,19 @@ static void execute_cheatinit(running_machine *machine, int ref, int params, con
if (params <= 1)
{
offset = 0;
- length = space->bytemask + 1;
- for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next)
+ length = space->bytemask() + 1;
+ for (entry = space->map()->m_entrylist.first(); entry != NULL; entry = entry->next())
{
- cheat_region[region_count].offset = memory_address_to_byte(space, entry->m_addrstart) & space->bytemask;
- cheat_region[region_count].endoffset = memory_address_to_byte(space, entry->m_addrend) & space->bytemask;
+ cheat_region[region_count].offset = space->address_to_byte(entry->m_addrstart) & space->bytemask();
+ cheat_region[region_count].endoffset = space->address_to_byte(entry->m_addrend) & space->bytemask();
cheat_region[region_count].share = entry->m_share;
- cheat_region[region_count].disabled = (entry->m_write.type == AMH_RAM) ? FALSE : TRUE;
+ cheat_region[region_count].disabled = (entry->m_write.m_type == AMH_RAM) ? FALSE : TRUE;
/* disable double share regions */
if (entry->m_share != NULL)
for (i = 0; i < region_count; i++)
if (cheat_region[i].share != NULL)
- if (strcmp(cheat_region[i].share, entry->m_share)==0)
+ if (strcmp(cheat_region[i].share, entry->m_share) == 0)
cheat_region[region_count].disabled = TRUE;
region_count++;
@@ -1738,8 +1738,8 @@ static void execute_cheatinit(running_machine *machine, int ref, int params, con
return;
/* force region to the specified range */
- cheat_region[region_count].offset = memory_address_to_byte(space, offset) & space->bytemask;;
- cheat_region[region_count].endoffset = memory_address_to_byte(space, offset + length - 1) & space->bytemask;;
+ cheat_region[region_count].offset = space->address_to_byte(offset) & space->bytemask();
+ cheat_region[region_count].endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
cheat_region[region_count].share = NULL;
cheat_region[region_count].disabled = FALSE;
region_count++;
@@ -2000,7 +2000,7 @@ static void execute_cheatlist(running_machine *machine, int ref, int params, con
if (params > 0)
f = fopen(param[0], "w");
- switch (space->spacenum)
+ switch (space->spacenum())
{
default:
case ADDRESS_SPACE_PROGRAM: spaceletter = 'p'; break;
@@ -2023,19 +2023,19 @@ static void execute_cheatlist(running_machine *machine, int ref, int params, con
if (cheat.cheatmap[cheatindex].state == 1)
{
UINT64 value = cheat_byte_swap(&cheat, cheat_read_extended(&cheat, space, cheat.cheatmap[cheatindex].offset)) & sizemask;
- offs_t address = memory_byte_to_address(space, cheat.cheatmap[cheatindex].offset);
+ offs_t address = space->byte_to_address(cheat.cheatmap[cheatindex].offset);
if (params > 0)
{
active_cheat++;
- fprintf(f, " <cheat desc=\"Possibility %d : %s (%s)\">\n", active_cheat, core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(value, cheat.width * 2));
+ fprintf(f, " <cheat desc=\"Possibility %d : %s (%s)\">\n", active_cheat, core_i64_hex_format(address, space->logaddrchars()), core_i64_hex_format(value, cheat.width * 2));
fprintf(f, " <script state=\"run\">\n");
- fprintf(f, " <action>%s.p%c%c@%s=%s</action>\n", cpu->tag(), spaceletter, sizeletter, core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask, cheat.width * 2));
+ fprintf(f, " <action>%s.p%c%c@%s=%s</action>\n", cpu->tag(), spaceletter, sizeletter, core_i64_hex_format(address, space->logaddrchars()), core_i64_hex_format(cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask, cheat.width * 2));
fprintf(f, " </script>\n");
fprintf(f, " </cheat>\n\n");
}
else
- debug_console_printf(machine, "Address=%s Start=%s Current=%s\n", core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask, cheat.width * 2), core_i64_hex_format(value, cheat.width * 2));
+ debug_console_printf(machine, "Address=%s Start=%s Current=%s\n", core_i64_hex_format(address, space->logaddrchars()), core_i64_hex_format(cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask, cheat.width * 2), core_i64_hex_format(value, cheat.width * 2));
}
}
if (params > 0)
@@ -2096,9 +2096,9 @@ static void execute_find(running_machine *machine, int ref, int params, const ch
return;
/* further validation */
- endoffset = memory_address_to_byte(space, offset + length - 1) & space->bytemask;
- offset = memory_address_to_byte(space, offset) & space->bytemask;
- cur_data_size = memory_address_to_byte(space, 1);
+ endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
+ offset = space->address_to_byte(offset) & space->bytemask();
+ cur_data_size = space->address_to_byte(1);
if (cur_data_size == 0)
cur_data_size = 1;
@@ -2161,7 +2161,7 @@ static void execute_find(running_machine *machine, int ref, int params, const ch
if (match)
{
found++;
- debug_console_printf(machine, "Found at %s\n", core_i64_hex_format((UINT32)memory_byte_to_address(space, i), space->addrchars));
+ debug_console_printf(machine, "Found at %s\n", core_i64_hex_format((UINT32)space->byte_to_address(i), space->addrchars()));
}
}
@@ -2215,7 +2215,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch
/* now write the data out */
for (i = 0; i < length; )
{
- int pcbyte = memory_address_to_byte(space, offset + i) & space->bytemask;
+ int pcbyte = space->address_to_byte(offset + i) & space->bytemask();
char output[200+DEBUG_COMMENT_MAX_LINE_LENGTH], disasm[200];
const char *comment;
offs_t tempaddr;
@@ -2223,7 +2223,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch
int numbytes = 0;
/* print the address */
- outdex += sprintf(&output[outdex], "%s: ", core_i64_hex_format((UINT32)memory_byte_to_address(space, pcbyte), space->logaddrchars));
+ outdex += sprintf(&output[outdex], "%s: ", core_i64_hex_format((UINT32)space->byte_to_address(pcbyte), space->logaddrchars()));
/* make sure we can translate the address */
tempaddr = pcbyte;
@@ -2246,7 +2246,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch
if (bytes)
{
int startdex = outdex;
- numbytes = memory_address_to_byte(space, numbytes);
+ numbytes = space->address_to_byte(numbytes);
for (j = 0; j < numbytes; j += minbytes)
outdex += sprintf(&output[outdex], "%s ", core_i64_hex_format(debug_read_opcode(space, pcbyte + j, minbytes, FALSE), minbytes * 2));
if (outdex - startdex < byteswidth)
@@ -2394,7 +2394,7 @@ static void execute_history(running_machine *machine, int ref, int params, const
offs_t pc = debug->history_pc(-index);
/* fetch the bytes up to the maximum */
- offs_t pcbyte = memory_address_to_byte(space, pc) & space->bytemask;
+ offs_t pcbyte = space->address_to_byte(pc) & space->bytemask();
UINT8 opbuf[64], argbuf[64];
for (int numbytes = 0; numbytes < maxbytes; numbytes++)
{
@@ -2405,7 +2405,7 @@ static void execute_history(running_machine *machine, int ref, int params, const
char buffer[200];
debug->disassemble(buffer, pc, opbuf, argbuf);
- debug_console_printf(machine, "%s: %s\n", core_i64_hex_format(pc, space->logaddrchars), buffer);
+ debug_console_printf(machine, "%s: %s\n", core_i64_hex_format(pc, space->logaddrchars()), buffer);
}
}
@@ -2490,14 +2490,14 @@ static void execute_map(running_machine *machine, int ref, int params, const cha
for (intention = TRANSLATE_READ_DEBUG; intention <= TRANSLATE_FETCH_DEBUG; intention++)
{
static const char *const intnames[] = { "Read", "Write", "Fetch" };
- taddress = memory_address_to_byte(space, address) & space->bytemask;
+ taddress = space->address_to_byte(address) & space->bytemask();
if (debug_cpu_translate(space, intention, &taddress))
{
- const char *mapname = memory_get_handler_string(space, intention == TRANSLATE_WRITE_DEBUG, taddress);
- debug_console_printf(machine, "%7s: %s logical == %s physical -> %s\n", intnames[intention & 3], core_i64_hex_format(address, space->logaddrchars), core_i64_hex_format(memory_byte_to_address(space, taddress), space->addrchars), mapname);
+ const char *mapname = const_cast<address_space *>(space)->get_handler_string((intention == TRANSLATE_WRITE_DEBUG) ? ROW_WRITE : ROW_READ, taddress);
+ debug_console_printf(machine, "%7s: %s logical == %s physical -> %s\n", intnames[intention & 3], core_i64_hex_format(address, space->logaddrchars()), core_i64_hex_format(space->byte_to_address(taddress), space->addrchars()), mapname);
}
else
- debug_console_printf(machine, "%7s: %s logical is unmapped\n", intnames[intention & 3], core_i64_hex_format(address, space->logaddrchars));
+ debug_console_printf(machine, "%7s: %s logical is unmapped\n", intnames[intention & 3], core_i64_hex_format(address, space->logaddrchars()));
}
}