diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index 0dda12cf6c9..80d68a56456 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -377,9 +377,9 @@ int debug_command_parameter_number(running_machine *machine, const char *param, return TRUE; /* print an error pointing to the character that caused it */ - debug_console_printf("Error in expression: %s\n", param); - debug_console_printf(" %*s^", EXPRERR_ERROR_OFFSET(err), ""); - debug_console_printf("%s\n", exprerr_to_string(err)); + debug_console_printf(machine, "Error in expression: %s\n", param); + debug_console_printf(machine, " %*s^", EXPRERR_ERROR_OFFSET(err), ""); + debug_console_printf(machine, "%s\n", exprerr_to_string(err)); return FALSE; } @@ -400,7 +400,7 @@ int debug_command_parameter_cpu(running_machine *machine, const char *param, con *result = debug_cpu_get_visible_cpu(machine); if (*result == NULL) { - debug_console_printf("No valid CPU is currently selected\n"); + debug_console_printf(machine, "No valid CPU is currently selected\n"); return FALSE; } return TRUE; @@ -415,14 +415,14 @@ int debug_command_parameter_cpu(running_machine *machine, const char *param, con err = expression_evaluate(param, debug_cpu_get_visible_symtable(machine), &debug_expression_callbacks, machine, &cpunum); if (err != EXPRERR_NONE) { - debug_console_printf("Unable to find CPU '%s'\n", param); + debug_console_printf(machine, "Unable to find CPU '%s'\n", param); return FALSE; } /* if out of range, complain */ if (cpunum >= ARRAY_LENGTH(machine->cpu) || machine->cpu[cpunum] == NULL) { - debug_console_printf("Invalid CPU index %d\n", (UINT32)cpunum); + debug_console_printf(machine, "Invalid CPU index %d\n", (UINT32)cpunum); return FALSE; } *result = machine->cpu[cpunum]; @@ -448,7 +448,7 @@ int debug_command_parameter_cpu_space(running_machine *machine, const char *para *result = cpu_get_address_space(cpu, spacenum); if (*result == NULL) { - debug_console_printf("No %s memory space found for CPU '%s'\n", address_space_names[spacenum], cpu->tag); + debug_console_printf(machine, "No %s memory space found for CPU '%s'\n", address_space_names[spacenum], cpu->tag); return FALSE; } return TRUE; @@ -477,9 +477,9 @@ static int debug_command_parameter_expression(running_machine *machine, const ch return TRUE; /* output an error */ - debug_console_printf("Error in expression: %s\n", param); - debug_console_printf(" %*s^", EXPRERR_ERROR_OFFSET(err), ""); - debug_console_printf("%s\n", exprerr_to_string(err)); + debug_console_printf(machine, "Error in expression: %s\n", param); + debug_console_printf(machine, " %*s^", EXPRERR_ERROR_OFFSET(err), ""); + debug_console_printf(machine, "%s\n", exprerr_to_string(err)); return FALSE; } @@ -503,9 +503,9 @@ static int debug_command_parameter_command(running_machine *machine, const char return TRUE; /* output an error */ - debug_console_printf("Error in command: %s\n", param); - debug_console_printf(" %*s^", CMDERR_ERROR_OFFSET(err), ""); - debug_console_printf("%s\n", debug_cmderr_to_string(err)); + debug_console_printf(machine, "Error in command: %s\n", param); + debug_console_printf(machine, " %*s^", CMDERR_ERROR_OFFSET(err), ""); + debug_console_printf(machine, "%s\n", debug_cmderr_to_string(err)); return 0; } @@ -522,9 +522,9 @@ static int debug_command_parameter_command(running_machine *machine, const char static void execute_help(running_machine *machine, int ref, int params, const char *param[]) { if (params == 0) - debug_console_printf_wrap(80, "%s\n", debug_get_help("")); + debug_console_printf_wrap(machine, 80, "%s\n", debug_get_help("")); else - debug_console_printf_wrap(80, "%s\n", debug_get_help(param[0])); + debug_console_printf_wrap(machine, 80, "%s\n", debug_get_help(param[0])); } @@ -546,11 +546,11 @@ static void execute_print(running_machine *machine, int ref, int params, const c for (i = 0; i < params; i++) { if ((values[i] >> 32) != 0) - debug_console_printf("%X%08X ", (UINT32)(values[i] >> 32), (UINT32)values[i]); + debug_console_printf(machine, "%X%08X ", (UINT32)(values[i] >> 32), (UINT32)values[i]); else - debug_console_printf("%X ", (UINT32)values[i]); + debug_console_printf(machine, "%X ", (UINT32)values[i]); } - debug_console_printf("\n"); + debug_console_printf(machine, "\n"); } @@ -558,7 +558,7 @@ static void execute_print(running_machine *machine, int ref, int params, const c mini_printf - safe printf to a buffer -------------------------------------------------*/ -static int mini_printf(char *buffer, const char *format, int params, UINT64 *param) +static int mini_printf(running_machine *machine, char *buffer, const char *format, int params, UINT64 *param) { const char *f = format; char *p = buffer; @@ -611,7 +611,7 @@ static int mini_printf(char *buffer, const char *format, int params, UINT64 *par case 'x': if (params == 0) { - debug_console_printf("Not enough parameters for format!\n"); + debug_console_printf(machine, "Not enough parameters for format!\n"); return 0; } if ((UINT32)(*param >> 32) != 0) @@ -627,7 +627,7 @@ static int mini_printf(char *buffer, const char *format, int params, UINT64 *par case 'd': if (params == 0) { - debug_console_printf("Not enough parameters for format!\n"); + debug_console_printf(machine, "Not enough parameters for format!\n"); return 0; } p += sprintf(p, zerofill ? "%0*d" : "%*d", width, (UINT32)*param); @@ -664,8 +664,8 @@ static void execute_printf(running_machine *machine, int ref, int params, const return; /* then do a printf */ - if (mini_printf(buffer, param[0], params - 1, &values[1])) - debug_console_printf("%s\n", buffer); + if (mini_printf(machine, buffer, param[0], params - 1, &values[1])) + debug_console_printf(machine, "%s\n", buffer); } @@ -685,7 +685,7 @@ static void execute_logerror(running_machine *machine, int ref, int params, cons return; /* then do a printf */ - if (mini_printf(buffer, param[0], params - 1, &values[1])) + if (mini_printf(machine, buffer, param[0], params - 1, &values[1])) logerror("%s", buffer); } @@ -711,7 +711,7 @@ static void execute_tracelog(running_machine *machine, int ref, int params, cons return; /* then do a printf */ - if (mini_printf(buffer, param[0], params - 1, &values[1])) + if (mini_printf(machine, buffer, param[0], params - 1, &values[1])) fprintf(file, "%s", buffer); } @@ -869,7 +869,7 @@ static void execute_focus(running_machine *machine, int ref, int params, const c for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) if (machine->cpu[cpunum] != NULL && machine->cpu[cpunum] != cpu) debug_cpu_ignore_cpu(machine->cpu[cpunum], 1); - debug_console_printf("Now focused on CPU '%s'\n", cpu->tag); + debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag); } @@ -906,7 +906,7 @@ static void execute_ignore(running_machine *machine, int ref, int params, const /* special message for none */ if (buflen == 0) sprintf(&buffer[buflen], "Not currently ignoring any CPUs"); - debug_console_printf("%s\n", buffer); + debug_console_printf(machine, "%s\n", buffer); } /* otherwise clear the ignore flag on all requested CPUs */ @@ -927,12 +927,12 @@ static void execute_ignore(running_machine *machine, int ref, int params, const break; if (cpunum == ARRAY_LENGTH(machine->cpu)) { - debug_console_printf("Can't ignore all CPUs!\n"); + debug_console_printf(machine, "Can't ignore all CPUs!\n"); return; } debug_cpu_ignore_cpu(cpuwhich[paramnum], 1); - debug_console_printf("Now ignoring CPU '%s'\n", cpuwhich[paramnum]->tag); + debug_console_printf(machine, "Now ignoring CPU '%s'\n", cpuwhich[paramnum]->tag); } } } @@ -971,7 +971,7 @@ static void execute_observe(running_machine *machine, int ref, int params, const /* special message for none */ if (buflen == 0) buflen += sprintf(&buffer[buflen], "Not currently observing any CPUs"); - debug_console_printf("%s\n", buffer); + debug_console_printf(machine, "%s\n", buffer); } /* otherwise set the ignore flag on all requested CPUs */ @@ -986,7 +986,7 @@ static void execute_observe(running_machine *machine, int ref, int params, const for (paramnum = 0; paramnum < params; paramnum++) { debug_cpu_ignore_cpu(cpuwhich[paramnum], 0); - debug_console_printf("Now observing CPU '%s'\n", cpuwhich[paramnum]->tag); + debug_console_printf(machine, "Now observing CPU '%s'\n", cpuwhich[paramnum]->tag); } } } @@ -1012,13 +1012,13 @@ static void execute_comment(running_machine *machine, int ref, int params, const /* make sure param 2 exists */ if (strlen(param[1]) == 0) { - debug_console_printf("Error : comment text empty\n"); + debug_console_printf(machine, "Error : comment text empty\n"); return; } /* Now try adding the comment */ debug_comment_add(cpu, address, param[1], 0x00ff0000, debug_comment_get_opcode_crc32(cpu, address)); - debug_view_update_type(DVT_DISASSEMBLY); + debug_view_update_type(cpu->machine, DVT_DISASSEMBLY); } @@ -1042,7 +1042,7 @@ static void execute_comment_del(running_machine *machine, int ref, int params, c /* If it's a number, it must be an address */ /* The bankoff and cbn will be pulled from what's currently active */ debug_comment_remove(cpu, address, debug_comment_get_opcode_crc32(cpu, address)); - debug_view_update_type(DVT_DISASSEMBLY); + debug_view_update_type(cpu->machine, DVT_DISASSEMBLY); } @@ -1053,7 +1053,7 @@ static void execute_comment_del(running_machine *machine, int ref, int params, c static void execute_comment_save(running_machine *machine, int ref, int params, const char *param[]) { if (debug_comment_save(machine)) - debug_console_printf("Comments successfully saved\n"); + debug_console_printf(machine, "Comments successfully saved\n"); } @@ -1088,7 +1088,7 @@ static void execute_bpset(running_machine *machine, int ref, int params, const c /* set the breakpoint */ bpnum = debug_cpu_breakpoint_set(cpu, address, condition, action); - debug_console_printf("Breakpoint %X set\n", bpnum); + debug_console_printf(machine, "Breakpoint %X set\n", bpnum); } @@ -1114,7 +1114,7 @@ static void execute_bpclear(running_machine *machine, int ref, int params, const while ((bp = cpuinfo->bplist) != NULL) debug_cpu_breakpoint_clear(machine, bp->index); } - debug_console_printf("Cleared all breakpoints\n"); + debug_console_printf(machine, "Cleared all breakpoints\n"); } /* otherwise, clear the specific one */ @@ -1124,9 +1124,9 @@ static void execute_bpclear(running_machine *machine, int ref, int params, const { int found = debug_cpu_breakpoint_clear(machine, bpindex); if (found) - debug_console_printf("Breakpoint %X cleared\n", (UINT32)bpindex); + debug_console_printf(machine, "Breakpoint %X cleared\n", (UINT32)bpindex); else - debug_console_printf("Invalid breakpoint number %X\n", (UINT32)bpindex); + debug_console_printf(machine, "Invalid breakpoint number %X\n", (UINT32)bpindex); } } @@ -1154,9 +1154,9 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c debug_cpu_breakpoint_enable(machine, bp->index, ref); } if (ref == 0) - debug_console_printf("Disabled all breakpoints\n"); + debug_console_printf(machine, "Disabled all breakpoints\n"); else - debug_console_printf("Enabled all breakpoints\n"); + debug_console_printf(machine, "Enabled all breakpoints\n"); } /* otherwise, clear the specific one */ @@ -1166,9 +1166,9 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c { int found = debug_cpu_breakpoint_enable(machine, bpindex, ref); if (found) - debug_console_printf("Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled"); + debug_console_printf(machine, "Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled"); else - debug_console_printf("Invalid breakpoint number %X\n", (UINT32)bpindex); + debug_console_printf(machine, "Invalid breakpoint number %X\n", (UINT32)bpindex); } } @@ -1193,7 +1193,7 @@ static void execute_bplist(running_machine *machine, int ref, int params, const { debug_cpu_breakpoint *bp; - debug_console_printf("CPU %d breakpoints:\n", cpunum); + debug_console_printf(machine, "CPU %d breakpoints:\n", cpunum); /* loop over the breakpoints */ for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) @@ -1204,14 +1204,14 @@ static void execute_bplist(running_machine *machine, int ref, int params, const buflen += sprintf(&buffer[buflen], " if %s", expression_original_string(bp->condition)); if (bp->action) buflen += sprintf(&buffer[buflen], " do %s", bp->action); - debug_console_printf("%s\n", buffer); + debug_console_printf(machine, "%s\n", buffer); printed++; } } } if (!printed) - debug_console_printf("No breakpoints currently installed\n"); + debug_console_printf(machine, "No breakpoints currently installed\n"); } @@ -1246,7 +1246,7 @@ static void execute_wpset(running_machine *machine, int ref, int params, const c type = WATCHPOINT_READWRITE; else { - debug_console_printf("Invalid watchpoint type: expected r, w, or rw\n"); + debug_console_printf(machine, "Invalid watchpoint type: expected r, w, or rw\n"); return; } @@ -1264,7 +1264,7 @@ static void execute_wpset(running_machine *machine, int ref, int params, const c /* set the watchpoint */ wpnum = debug_cpu_watchpoint_set(space, type, address, length, condition, action); - debug_console_printf("Watchpoint %X set\n", wpnum); + debug_console_printf(machine, "Watchpoint %X set\n", wpnum); } @@ -1295,7 +1295,7 @@ static void execute_wpclear(running_machine *machine, int ref, int params, const debug_cpu_watchpoint_clear(machine, wp->index); } } - debug_console_printf("Cleared all watchpoints\n"); + debug_console_printf(machine, "Cleared all watchpoints\n"); } /* otherwise, clear the specific one */ @@ -1305,9 +1305,9 @@ static void execute_wpclear(running_machine *machine, int ref, int params, const { int found = debug_cpu_watchpoint_clear(machine, wpindex); if (found) - debug_console_printf("Watchpoint %X cleared\n", (UINT32)wpindex); + debug_console_printf(machine, "Watchpoint %X cleared\n", (UINT32)wpindex); else - debug_console_printf("Invalid watchpoint number %X\n", (UINT32)wpindex); + debug_console_printf(machine, "Invalid watchpoint number %X\n", (UINT32)wpindex); } } @@ -1340,9 +1340,9 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c } } if (ref == 0) - debug_console_printf("Disabled all watchpoints\n"); + debug_console_printf(machine, "Disabled all watchpoints\n"); else - debug_console_printf("Enabled all watchpoints\n"); + debug_console_printf(machine, "Enabled all watchpoints\n"); } /* otherwise, clear the specific one */ @@ -1352,9 +1352,9 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c { int found = debug_cpu_watchpoint_enable(machine, wpindex, ref); if (found) - debug_console_printf("Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled"); + debug_console_printf(machine, "Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled"); else - debug_console_printf("Invalid watchpoint number %X\n", (UINT32)wpindex); + debug_console_printf(machine, "Invalid watchpoint number %X\n", (UINT32)wpindex); } } @@ -1383,7 +1383,7 @@ static void execute_wplist(running_machine *machine, int ref, int params, const const address_space *space = cpu_get_address_space(machine->cpu[cpunum], spacenum); debug_cpu_watchpoint *wp; - debug_console_printf("CPU '%s' %s space watchpoints:\n", space->cpu->tag, address_space_names[spacenum]); + debug_console_printf(machine, "CPU '%s' %s space watchpoints:\n", space->cpu->tag, address_space_names[spacenum]); /* loop over the watchpoints */ for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) @@ -1395,14 +1395,14 @@ static void execute_wplist(running_machine *machine, int ref, int params, const buflen += sprintf(&buffer[buflen], " if %s", expression_original_string(wp->condition)); if (wp->action) buflen += sprintf(&buffer[buflen], " do %s", wp->action); - debug_console_printf("%s\n", buffer); + debug_console_printf(machine, "%s\n", buffer); printed++; } } } if (!printed) - debug_console_printf("No watchpoints currently installed\n"); + debug_console_printf(machine, "No watchpoints currently installed\n"); } @@ -1432,7 +1432,7 @@ static void execute_hotspot(running_machine *machine, int ref, int params, const if (cpuinfo->hotspots != NULL) { debug_cpu_hotspot_track(cpuinfo->device, 0, 0); - debug_console_printf("Cleared hotspot tracking on CPU '%s'\n", machine->cpu[cpunum]->tag); + debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", machine->cpu[cpunum]->tag); cleared = TRUE; } } @@ -1454,9 +1454,9 @@ static void execute_hotspot(running_machine *machine, int ref, int params, const /* attempt to install */ if (debug_cpu_hotspot_track(cpu, count, threshhold)) - debug_console_printf("Now tracking hotspots on CPU '%s' using %d slots with a threshhold of %d\n", cpu->tag, (int)count, (int)threshhold); + debug_console_printf(machine, "Now tracking hotspots on CPU '%s' using %d slots with a threshhold of %d\n", cpu->tag, (int)count, (int)threshhold); else - debug_console_printf("Error setting up the hotspot tracking\n"); + debug_console_printf(machine, "Error setting up the hotspot tracking\n"); } @@ -1487,7 +1487,7 @@ static void execute_save(running_machine *machine, int ref, int params, const ch f = fopen(param[0], "wb"); if (!f) { - debug_console_printf("Error opening file '%s'\n", param[0]); + debug_console_printf(machine, "Error opening file '%s'\n", param[0]); return; } @@ -1502,7 +1502,7 @@ static void execute_save(running_machine *machine, int ref, int params, const ch /* close the file */ fclose(f); - debug_console_printf("Data saved successfully\n"); + debug_console_printf(machine, "Data saved successfully\n"); } @@ -1536,7 +1536,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch width = memory_address_to_byte(space, 1); if (width != 1 && width != 2 && width != 4 && width != 8) { - debug_console_printf("Invalid width! (must be 1,2,4 or 8)\n"); + 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; @@ -1546,7 +1546,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch f = fopen(param[0], "w"); if (!f) { - debug_console_printf("Error opening file '%s'\n", param[0]); + debug_console_printf(machine, "Error opening file '%s'\n", param[0]); return; } @@ -1664,7 +1664,7 @@ static void execute_dump(running_machine *machine, int ref, int params, const ch /* close the file */ fclose(f); - debug_console_printf("Data dumped successfully\n"); + debug_console_printf(machine, "Data dumped successfully\n"); } @@ -1758,14 +1758,14 @@ static void execute_find(running_machine *machine, int ref, int params, const ch if (match) { found++; - debug_console_printf("Found at %*X\n", space->logaddrchars, (UINT32)memory_byte_to_address(space, i)); + debug_console_printf(machine, "Found at %*X\n", space->logaddrchars, (UINT32)memory_byte_to_address(space, i)); } } cpu_pop_context(); /* print something if not found */ if (found == 0) - debug_console_printf("Not found\n"); + debug_console_printf(machine, "Not found\n"); } @@ -1805,7 +1805,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch f = fopen(param[0], "w"); if (!f) { - debug_console_printf("Error opening file '%s'\n", param[0]); + debug_console_printf(machine, "Error opening file '%s'\n", param[0]); return; } @@ -1903,7 +1903,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch /* close the file */ fclose(f); - debug_console_printf("Data dumped successfully\n"); + debug_console_printf(machine, "Data dumped successfully\n"); } @@ -1944,7 +1944,7 @@ static void execute_trace_internal(running_machine *machine, int ref, int params f = fopen(filename, mode); if (!f) { - debug_console_printf("Error opening file '%s'\n", param[0]); + debug_console_printf(machine, "Error opening file '%s'\n", param[0]); return; } } @@ -1952,9 +1952,9 @@ static void execute_trace_internal(running_machine *machine, int ref, int params /* do it */ debug_cpu_trace(cpu, f, trace_over, action); if (f) - debug_console_printf("Tracing CPU '%s' to file %s\n", cpu->tag, filename); + debug_console_printf(machine, "Tracing CPU '%s' to file %s\n", cpu->tag, filename); else - debug_console_printf("Stopped tracing on CPU '%s'\n", cpu->tag); + debug_console_printf(machine, "Stopped tracing on CPU '%s'\n", cpu->tag); } @@ -2032,7 +2032,7 @@ static void execute_history(running_machine *machine, int ref, int params, const cpu_dasm(space->cpu, buffer, pc, opbuf, argbuf); - debug_console_printf("%0*X: %s\n", space->logaddrchars, pc, buffer); + debug_console_printf(machine, "%0*X: %s\n", space->logaddrchars, pc, buffer); } cpu_pop_context(); } @@ -2048,7 +2048,7 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch if (params == 0) { video_save_active_screen_snapshots(machine); - debug_console_printf("Saved snapshot\n"); + debug_console_printf(machine, "Saved snapshot\n"); } /* otherwise, we have to open the file ourselves */ @@ -2064,7 +2064,7 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch if ((screen == NULL) || !render_is_live_screen(screen)) { - debug_console_printf("Invalid screen number '%d'\n", scrnum); + debug_console_printf(machine, "Invalid screen number '%d'\n", scrnum); return; } @@ -2076,13 +2076,13 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch if (filerr != FILERR_NONE) { - debug_console_printf("Error creating file '%s'\n", filename); + debug_console_printf(machine, "Error creating file '%s'\n", filename); return; } video_screen_save_snapshot(screen->machine, screen, fp); mame_fclose(fp); - debug_console_printf("Saved screen #%d snapshot as '%s'\n", scrnum, filename); + debug_console_printf(machine, "Saved screen #%d snapshot as '%s'\n", scrnum, filename); } } @@ -2124,10 +2124,10 @@ static void execute_map(running_machine *machine, int ref, int params, const cha if (memory_address_physical(space, intention, &taddress)) { const char *mapname = memory_get_handler_string(space, intention == TRANSLATE_WRITE_DEBUG, taddress); - debug_console_printf("%7s: %08X logical == %08X physical -> %s\n", intnames[intention & 3], (UINT32)address, memory_byte_to_address(space, taddress), mapname); + debug_console_printf(machine, "%7s: %08X logical == %08X physical -> %s\n", intnames[intention & 3], (UINT32)address, memory_byte_to_address(space, taddress), mapname); } else - debug_console_printf("%7s: %08X logical is unmapped\n", intnames[intention & 3], (UINT32)address); + debug_console_printf(machine, "%7s: %08X logical is unmapped\n", intnames[intention & 3], (UINT32)address); } } @@ -2143,7 +2143,7 @@ static void execute_memdump(running_machine *machine, int ref, int params, const filename = (params == 0) ? "memdump.log" : param[0]; - debug_console_printf("Dumping memory to %s\n", filename); + debug_console_printf(machine, "Dumping memory to %s\n", filename); file = fopen(filename, "w"); if (file) @@ -2179,12 +2179,12 @@ static void execute_symlist(running_machine *machine, int ref, int params, const if (cpu != NULL) { symtable = debug_cpu_get_symtable(cpu); - debug_console_printf("CPU '%s' symbols:\n", cpu->tag); + debug_console_printf(machine, "CPU '%s' symbols:\n", cpu->tag); } else { symtable = debug_cpu_get_global_symtable(machine); - debug_console_printf("Global symbols:\n"); + debug_console_printf(machine, "Global symbols:\n"); } /* gather names for all symbols */ @@ -2218,14 +2218,14 @@ static void execute_symlist(running_machine *machine, int ref, int params, const assert(entry != NULL); /* only display "register" type symbols */ - debug_console_printf("%s = ", namelist[symnum]); + debug_console_printf(machine, "%s = ", namelist[symnum]); if ((value >> 32) != 0) - debug_console_printf("%X%08X", (UINT32)(value >> 32), (UINT32)value); + debug_console_printf(machine, "%X%08X", (UINT32)(value >> 32), (UINT32)value); else - debug_console_printf("%X", (UINT32)value); + debug_console_printf(machine, "%X", (UINT32)value); if (entry->info.reg.setter == NULL) - debug_console_printf(" (read-only)"); - debug_console_printf("\n"); + debug_console_printf(machine, " (read-only)"); + debug_console_printf(machine, "\n"); } } diff --git a/src/emu/debug/debugcmt.c b/src/emu/debug/debugcmt.c index b8f49da0a3c..e60d3580e5e 100644 --- a/src/emu/debug/debugcmt.c +++ b/src/emu/debug/debugcmt.c @@ -170,7 +170,7 @@ int debug_comment_add(const device_config *device, offs_t addr, const char *comm debug_comments[cpu_num].change_count++; /* force an update of disassembly views */ - debug_view_update_type(DVT_DISASSEMBLY); + debug_view_update_type(device->machine, DVT_DISASSEMBLY); return 1; } @@ -185,7 +185,7 @@ int debug_comment_add(const device_config *device, offs_t addr, const char *comm debug_comments[cpu_num].change_count++; /* force an update of disassembly views */ - debug_view_update_type(DVT_DISASSEMBLY); + debug_view_update_type(device->machine, DVT_DISASSEMBLY); return 1; } @@ -230,7 +230,7 @@ int debug_comment_remove(const device_config *device, offs_t addr, UINT32 c_crc) debug_comments[cpu_num].change_count++; /* force an update of disassembly views */ - debug_view_update_type(DVT_DISASSEMBLY); + debug_view_update_type(device->machine, DVT_DISASSEMBLY); return 1; } diff --git a/src/emu/debug/debugcon.c b/src/emu/debug/debugcon.c index 0a323a0752a..a52ef07da7f 100644 --- a/src/emu/debug/debugcon.c +++ b/src/emu/debug/debugcon.c @@ -87,8 +87,8 @@ void debug_console_init(running_machine *machine) return; /* print the opening lines */ - debug_console_printf("MAME new debugger version %s\n", build_version); - debug_console_printf("Currently targeting %s (%s)\n", machine->gamedrv->name, machine->gamedrv->description); + debug_console_printf(machine, "MAME new debugger version %s\n", build_version); + debug_console_printf(machine, "Currently targeting %s (%s)\n", machine->gamedrv->name, machine->gamedrv->description); /* request callback upon exiting */ add_exit_callback(machine, debug_console_exit); @@ -357,7 +357,7 @@ CMDERR debug_console_execute_command(running_machine *machine, const char *comma /* echo if requested */ if (echo) - debug_console_printf(">%s\n", command); + debug_console_printf(machine, ">%s\n", command); /* parse and execute */ result = internal_parse_command(machine, command, TRUE); @@ -366,15 +366,15 @@ CMDERR debug_console_execute_command(running_machine *machine, const char *comma if (result != CMDERR_NONE) { if (!echo) - debug_console_printf(">%s\n", command); - debug_console_printf(" %*s^\n", CMDERR_ERROR_OFFSET(result), ""); - debug_console_printf("%s\n", debug_cmderr_to_string(result)); + debug_console_printf(machine, ">%s\n", command); + debug_console_printf(machine, " %*s^\n", CMDERR_ERROR_OFFSET(result), ""); + debug_console_printf(machine, "%s\n", debug_cmderr_to_string(result)); } /* update all views */ if (echo) { - debug_view_update_all(); + debug_view_update_all(machine); debugger_refresh_display(machine); } return result; @@ -462,7 +462,7 @@ const char *debug_cmderr_to_string(CMDERR error) console -------------------------------------------------*/ -void CLIB_DECL debug_console_printf(const char *format, ...) +void CLIB_DECL debug_console_printf(running_machine *machine, const char *format, ...) { va_list arg; @@ -473,7 +473,7 @@ void CLIB_DECL debug_console_printf(const char *format, ...) text_buffer_print(console_textbuf, giant_string_buffer); /* force an update of any console views */ - debug_view_update_type(DVT_CONSOLE); + debug_view_update_type(machine, DVT_CONSOLE); } @@ -483,13 +483,13 @@ void CLIB_DECL debug_console_printf(const char *format, ...) console -------------------------------------------------*/ -void CLIB_DECL debug_console_vprintf(const char *format, va_list args) +void CLIB_DECL debug_console_vprintf(running_machine *machine, const char *format, va_list args) { vsprintf(giant_string_buffer, format, args); text_buffer_print(console_textbuf, giant_string_buffer); /* force an update of any console views */ - debug_view_update_type(DVT_CONSOLE); + debug_view_update_type(machine, DVT_CONSOLE); } @@ -499,7 +499,7 @@ void CLIB_DECL debug_console_vprintf(const char *format, va_list args) console -------------------------------------------------*/ -void CLIB_DECL debug_console_printf_wrap(int wrapcol, const char *format, ...) +void CLIB_DECL debug_console_printf_wrap(running_machine *machine, int wrapcol, const char *format, ...) { va_list arg; @@ -510,7 +510,7 @@ void CLIB_DECL debug_console_printf_wrap(int wrapcol, const char *format, ...) text_buffer_print_wrap(console_textbuf, giant_string_buffer, wrapcol); /* force an update of any console views */ - debug_view_update_type(DVT_CONSOLE); + debug_view_update_type(machine, DVT_CONSOLE); } @@ -536,7 +536,7 @@ void debug_errorlog_write_line(running_machine *machine, const char *line) text_buffer_print(errorlog_textbuf, line); /* force an update of any log views */ - debug_view_update_type(DVT_LOG); + debug_view_update_type(machine, DVT_LOG); } diff --git a/src/emu/debug/debugcon.h b/src/emu/debug/debugcon.h index d62e4b195c6..ab6633df840 100644 --- a/src/emu/debug/debugcon.h +++ b/src/emu/debug/debugcon.h @@ -86,9 +86,9 @@ void debug_console_register_command(running_machine *machine, const char *com const char * debug_cmderr_to_string(CMDERR error); /* console management */ -void CLIB_DECL debug_console_printf(const char *format, ...) ATTR_PRINTF(1,2); -void CLIB_DECL debug_console_vprintf(const char *format, va_list args); -void CLIB_DECL debug_console_printf_wrap(int wrapcol, const char *format, ...) ATTR_PRINTF(2,3); +void CLIB_DECL debug_console_printf(running_machine *machine, const char *format, ...) ATTR_PRINTF(2,3); +void CLIB_DECL debug_console_vprintf(running_machine *machine, const char *format, va_list args); +void CLIB_DECL debug_console_printf_wrap(running_machine *machine, int wrapcol, const char *format, ...) ATTR_PRINTF(3,4); text_buffer * debug_console_get_textbuf(void); /* errorlog management */ diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 71e10d37a3b..b0dad23c158 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -391,7 +391,7 @@ void debug_cpu_start_hook(const device_config *device, attotime endtime) /* check for periodic updates */ if (device == global->visiblecpu && osd_ticks() > global->last_periodic_update_time + osd_ticks_per_second()/4) { - debug_view_update_all(); + debug_view_update_all(device->machine); global->last_periodic_update_time = osd_ticks(); } @@ -411,7 +411,7 @@ void debug_cpu_start_hook(const device_config *device, attotime endtime) if ((info->flags & DEBUG_FLAG_STOP_VBLANK) != 0) { global->execution_state = EXECUTION_STATE_STOPPED; - debug_console_printf("Stopped at VBLANK\n"); + debug_console_printf(device->machine, "Stopped at VBLANK\n"); } /* check for debug keypresses */ @@ -464,7 +464,7 @@ void debug_cpu_interrupt_hook(const device_config *device, int irqline) if (info != NULL && (info->flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (info->stopirq == -1 || info->stopirq == irqline)) { global->execution_state = EXECUTION_STATE_STOPPED; - debug_console_printf("Stopped on interrupt (CPU '%s', IRQ %d)\n", device->tag, irqline); + debug_console_printf(device->machine, "Stopped on interrupt (CPU '%s', IRQ %d)\n", device->tag, irqline); compute_debug_flags(device); } } @@ -484,7 +484,7 @@ void debug_cpu_exception_hook(const device_config *device, int exception) if ((info->flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (info->stopexception == -1 || info->stopexception == exception)) { global->execution_state = EXECUTION_STATE_STOPPED; - debug_console_printf("Stopped on exception (CPU '%s', exception %d)\n", device->tag, exception); + debug_console_printf(device->machine, "Stopped on exception (CPU '%s', exception %d)\n", device->tag, exception); compute_debug_flags(device); } } @@ -531,7 +531,7 @@ void debug_cpu_instruction_hook(const device_config *device, offs_t curpc) /* update every 100 steps until we are within 200 of the end */ else if ((info->flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (info->stepsleft < 200 || info->stepsleft % 100 == 0)) { - debug_view_update_all(); + debug_view_update_all(device->machine); debugger_refresh_display(device->machine); } } @@ -543,14 +543,14 @@ void debug_cpu_instruction_hook(const device_config *device, offs_t curpc) /* see if we hit a target time */ if ((info->flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(device->machine), info->stoptime) >= 0) { - debug_console_printf("Stopped at time interval %.1g\n", attotime_to_double(timer_get_time(device->machine))); + debug_console_printf(device->machine, "Stopped at time interval %.1g\n", attotime_to_double(timer_get_time(device->machine))); global->execution_state = EXECUTION_STATE_STOPPED; } /* check the temp running breakpoint and break if we hit it */ else if ((info->flags & DEBUG_FLAG_STOP_PC) != 0 && info->stopaddr == curpc) { - debug_console_printf("Stopped at temporary breakpoint %X on CPU '%s'\n", info->stopaddr, device->tag); + debug_console_printf(device->machine, "Stopped at temporary breakpoint %X on CPU '%s'\n", info->stopaddr, device->tag); global->execution_state = EXECUTION_STATE_STOPPED; } @@ -568,8 +568,11 @@ void debug_cpu_instruction_hook(const device_config *device, offs_t curpc) reset_transient_flags(device->machine); global->breakcpu = NULL; + /* remember the last visible CPU in the debugger */ + global->visiblecpu = device; + /* update all views */ - debug_view_update_all(); + debug_view_update_all(device->machine); debugger_refresh_display(device->machine); /* wait for the debugger; during this time, disable sound output */ @@ -584,7 +587,7 @@ void debug_cpu_instruction_hook(const device_config *device, offs_t curpc) /* if something modified memory, update the screen */ if (global->memory_modified) { - debug_disasm_update_all(); + debug_view_update_type(device->machine, DVT_DISASSEMBLY); debugger_refresh_display(device->machine); } @@ -663,7 +666,7 @@ void debug_cpu_halt_on_next_instruction(const device_config *device, const char /* output the message to the console */ va_start(arg, fmt); - debug_console_vprintf(fmt, arg); + debug_console_vprintf(device->machine, fmt, arg); va_end(arg); /* if we are live, stop now, otherwise note that we want to break there */ @@ -1135,7 +1138,7 @@ void debug_cpu_source_script(running_machine *machine, const char *file) if (!global->source_file) { if (mame_get_phase(machine) == MAME_PHASE_RUNNING) - debug_console_printf("Cannot open command file '%s'\n", file); + debug_console_printf(machine, "Cannot open command file '%s'\n", file); else fatalerror("Cannot open command file '%s'", file); } @@ -2082,7 +2085,7 @@ static void breakpoint_check(running_machine *machine, cpu_debug_data *info, off /* print a notification, unless the action made us go again */ if (global->execution_state == EXECUTION_STATE_STOPPED) - debug_console_printf("Stopped at breakpoint %X\n", bp->index); + debug_console_printf(machine, "Stopped at breakpoint %X\n", bp->index); break; } } @@ -2202,7 +2205,7 @@ static void watchpoint_check(const address_space *space, int type, offs_t addres } else sprintf(buffer, "Stopped at watchpoint %X reading %s from %08X (PC=%X)", wp->index, sizes[size], memory_byte_to_address(space, address), cpu_get_pc(space->cpu)); - debug_console_printf("%s\n", buffer); + debug_console_printf(space->machine, "%s\n", buffer); compute_debug_flags(space->cpu); } break; @@ -2234,7 +2237,7 @@ static void check_hotspots(const address_space *space, offs_t address) /* if the bottom of the list is over the threshhold, print it */ debug_hotspot_entry *spot = &info->hotspots[info->hotspot_count - 1]; if (spot->count > info->hotspot_threshhold) - debug_console_printf("Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space->name, spot->access, spot->pc, spot->count); + debug_console_printf(space->machine, "Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space->name, spot->access, spot->pc, spot->count); /* move everything else down and insert this one at the top */ memmove(&info->hotspots[1], &info->hotspots[0], sizeof(info->hotspots[0]) * (info->hotspot_count - 1)); diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 3381aa89e7b..73a6430cac7 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -45,11 +45,12 @@ typedef enum _view_notification view_notification; TYPE DEFINITIONS ***************************************************************************/ +/* internal callback function pointers */ typedef int (*view_alloc_func)(debug_view *view); typedef void (*view_free_func)(debug_view *view); typedef void (*view_update_func)(debug_view *view); typedef void (*view_notify_func)(debug_view *view, view_notification type); -typedef void (*view_char_func)(debug_view *view, int ch); +typedef void (*view_char_func)(debug_view *view, int chval); /* debug_view_callbacks contains internal callbacks specific to a given view */ @@ -165,8 +166,7 @@ struct _debug_view_disasm typedef struct _debug_view_memory debug_view_memory; struct _debug_view_memory { - const address_space *space; /* address space whose data we are disassembling */ - memory_view_raw raw; /* raw memory data */ + const memory_subview_item *desc; /* description of our current subview */ debug_view_expression expression; /* expression describing the start address */ UINT32 chunks_per_row; /* number of chunks displayed per line */ UINT8 bytes_per_chunk; /* bytes per chunk */ @@ -200,13 +200,22 @@ struct _memory_view_pos }; +/* debugvw_priate contains internal global data for this module */ +/* In mame.h: typedef struct _debugvw_private debugvw_priate; */ +struct _debugvw_private +{ + debug_view * viewlist; /* list of views */ + const registers_subview_item *registers_subviews;/* linked list of registers subviews */ + const disasm_subview_item *disasm_subviews; /* linked list of disassembly subviews */ + const memory_subview_item *memory_subviews; /* linked list of memory subviews */ +}; + + /*************************************************************************** LOCAL VARIABLES ***************************************************************************/ -static debug_view *first_view; - static const memory_view_pos memory_pos_table[9] = { /* 0 bytes per chunk: */ { 0, { 0 } }, @@ -237,16 +246,19 @@ static int console_view_alloc(debug_view *view); static int log_view_alloc(debug_view *view); +static const registers_subview_item *registers_view_enumerate_subviews(running_machine *machine); static int registers_view_alloc(debug_view *view); static void registers_view_free(debug_view *view); static void registers_view_update(debug_view *view); +static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine *machine); static int disasm_view_alloc(debug_view *view); static void disasm_view_free(debug_view *view); static void disasm_view_notify(debug_view *view, view_notification type); static void disasm_view_update(debug_view *view); static void disasm_view_char(debug_view *view, int chval); +static const memory_subview_item *memory_view_enumerate_subviews(running_machine *machine); static int memory_view_alloc(debug_view *view); static void memory_view_free(debug_view *view); static void memory_view_notify(debug_view *view, view_notification type); @@ -327,9 +339,19 @@ INLINE void adjust_visible_y_for_cursor(debug_view *view) void debug_view_init(running_machine *machine) { - /* reset the initial list */ - first_view = NULL; + debugvw_private *global; + + /* allocate memory for our globals */ + global = machine->debugvw_data = auto_malloc(sizeof(*machine->debugvw_data)); + memset(global, 0, sizeof(*global)); + + /* register for some manual cleanup */ add_exit_callback(machine, debug_view_exit); + + /* build a list of disassembly and memory subviews */ + global->registers_subviews = registers_view_enumerate_subviews(machine); + global->disasm_subviews = disasm_view_enumerate_subviews(machine); + global->memory_subviews = memory_view_enumerate_subviews(machine); } @@ -339,9 +361,11 @@ void debug_view_init(running_machine *machine) static void debug_view_exit(running_machine *machine) { + debugvw_private *global = machine->debugvw_data; + /* kill all the views */ - while (first_view != NULL) - debug_view_free(first_view); + while (global->viewlist != NULL) + debug_view_free(global->viewlist); } @@ -357,6 +381,7 @@ static void debug_view_exit(running_machine *machine) debug_view *debug_view_alloc(running_machine *machine, int type, debug_view_osd_update_func osdupdate, void *osdprivate) { + debugvw_private *global = machine->debugvw_data; debug_view *view; assert(type >= 0 && type < ARRAY_LENGTH(callback_table)); @@ -396,8 +421,8 @@ debug_view *debug_view_alloc(running_machine *machine, int type, debug_view_osd_ } /* link it in */ - view->next = first_view; - first_view = view; + view->next = global->viewlist; + global->viewlist = view; /* require a recomputation on the first update */ view->recompute = TRUE; @@ -413,10 +438,11 @@ debug_view *debug_view_alloc(running_machine *machine, int type, debug_view_osd_ void debug_view_free(debug_view *view) { + debugvw_private *global = view->machine->debugvw_data; debug_view **viewptr; /* find the view */ - for (viewptr = &first_view; *viewptr != NULL; viewptr = &(*viewptr)->next) + for (viewptr = &global->viewlist; *viewptr != NULL; viewptr = &(*viewptr)->next) if (*viewptr == view) { /* unlink */ @@ -495,12 +521,17 @@ void debug_view_end_update(debug_view *view) refresh -------------------------------------------------*/ -void debug_view_update_all(void) +void debug_view_update_all(running_machine *machine) { + debugvw_private *global = machine->debugvw_data; debug_view *view; + /* skip if we're not ready yet */ + if (global == NULL) + return; + /* loop over each view and force an update */ - for (view = first_view; view != NULL; view = view->next) + for (view = global->viewlist; view != NULL; view = view->next) { debug_view_begin_update(view); view->update_pending = TRUE; @@ -514,16 +545,21 @@ void debug_view_update_all(void) a given type to refresh -------------------------------------------------*/ -void debug_view_update_type(int type) +void debug_view_update_type(running_machine *machine, int type) { + debugvw_private *global = machine->debugvw_data; debug_view *view; + /* skip if we're not ready yet */ + if (global == NULL) + return; + /* loop over each view and force an update */ - for (view = first_view; view != NULL; view = view->next) + for (view = global->viewlist; view != NULL; view = view->next) if (view->type == type) { debug_view_begin_update(view); - view->update_pending = TRUE; + view->recompute = view->update_pending = TRUE; debug_view_end_update(view); } } @@ -974,6 +1010,48 @@ static void textbuf_view_notify(debug_view *view, view_notification type) REGISTERS VIEW ***************************************************************************/ +/*------------------------------------------------- + registers_view_enumerate_subviews - enumerate + all possible subviews for a registers view +-------------------------------------------------*/ + +static const registers_subview_item *registers_view_enumerate_subviews(running_machine *machine) +{ + astring *tempstring = astring_alloc(); + registers_subview_item *head = NULL; + registers_subview_item **tailptr = &head; + int curindex = 0; + int cpunum; + + /* iterate over CPUs with program address spaces */ + for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) + if (machine->cpu[cpunum] != NULL) + { + const device_config *device = machine->cpu[cpunum]; + registers_subview_item *subview; + + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "CPU '%s' (%s)", device->tag, cpu_get_name(device)); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); + + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->device = device; + strcpy(subview->name, astring_c(tempstring)); + + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } + + /* free the temporary string */ + astring_free(tempstring); + return head; +} + + /*------------------------------------------------- registers_view_alloc - allocate memory for the registers view @@ -983,11 +1061,18 @@ static int registers_view_alloc(debug_view *view) { debug_view_registers *regdata; + /* fail if no available subviews */ + if (view->machine->debugvw_data->registers_subviews == NULL) + return FALSE; + /* allocate memory */ regdata = malloc(sizeof(*regdata)); if (regdata == NULL) return FALSE; memset(regdata, 0, sizeof(*regdata)); + + /* default to the first subview */ + regdata->device = view->machine->debugvw_data->registers_subviews->device; /* stash the extra data pointer */ view->extra_data = regdata; @@ -1303,33 +1388,62 @@ static void registers_view_update(debug_view *view) /*------------------------------------------------- - registers_view_get_cpu - return the CPU whose - registers are currently displayed + registers_view_get_subview_list - return a + linked list of subviews -------------------------------------------------*/ -const device_config *registers_view_get_cpu(debug_view *view) +const registers_subview_item *registers_view_get_subview_list(debug_view *view) { - debug_view_registers *regdata = view->extra_data; assert(view->type == DVT_REGISTERS); - debug_view_begin_update(view); - debug_view_end_update(view); - return regdata->device; + return view->machine->debugvw_data->registers_subviews; } /*------------------------------------------------- - registers_view_set_cpu - specify the CPU whose - registers are to be displayed + registers_view_get_subview - return the current + subview index -------------------------------------------------*/ -void registers_view_set_cpu(debug_view *view, const device_config *device) +int registers_view_get_subview(debug_view *view) { debug_view_registers *regdata = view->extra_data; + const registers_subview_item *subview; + int index = 0; + assert(view->type == DVT_REGISTERS); - if (device != regdata->device) + debug_view_begin_update(view); + debug_view_end_update(view); + + for (subview = view->machine->debugvw_data->registers_subviews; subview != NULL; subview = subview->next) + { + if (subview->device == regdata->device) + return index; + index++; + } + return 0; +} + + +/*------------------------------------------------- + registers_view_set_subview - select a new + subview by index +-------------------------------------------------*/ + +void registers_view_set_subview(debug_view *view, int index) +{ + const registers_subview_item *subview = registers_view_get_subview_by_index(view->machine->debugvw_data->registers_subviews, index); + debug_view_registers *regdata = view->extra_data; + + assert(view->type == DVT_REGISTERS); + assert(subview != NULL); + if (subview == NULL) + return; + + /* handle a change */ + if (subview->device != regdata->device) { debug_view_begin_update(view); - regdata->device = device; + regdata->device = subview->device; view->recompute = view->update_pending = TRUE; debug_view_end_update(view); } @@ -1341,6 +1455,51 @@ void registers_view_set_cpu(debug_view *view, const device_config *device) DISASSEMBLY VIEW ***************************************************************************/ +/*------------------------------------------------- + disasm_view_enumerate_subviews - enumerate + all possible subviews for a disassembly view +-------------------------------------------------*/ + +static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine *machine) +{ + astring *tempstring = astring_alloc(); + disasm_subview_item *head = NULL; + disasm_subview_item **tailptr = &head; + int curindex = 0; + int cpunum; + + /* iterate over CPUs with program address spaces */ + for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) + if (machine->cpu[cpunum] != NULL) + { + const address_space *space = cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM); + if (space != NULL) + { + disasm_subview_item *subview; + + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "CPU '%s' (%s)", space->cpu->tag, cpu_get_name(space->cpu)); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); + + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->space = space; + strcpy(subview->name, astring_c(tempstring)); + + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } + } + + /* free the temporary string */ + astring_free(tempstring); + return head; +} + + /*------------------------------------------------- disasm_view_alloc - allocate disasm for the disassembly view @@ -1352,12 +1511,19 @@ static int disasm_view_alloc(debug_view *view) int total_comments = 0; int cpunum; + /* fail if no available subviews */ + if (view->machine->debugvw_data->disasm_subviews == NULL) + return FALSE; + /* allocate disasm */ dasmdata = malloc(sizeof(*dasmdata)); if (dasmdata == NULL) return FALSE; memset(dasmdata, 0, sizeof(*dasmdata)); + /* default to the first subview */ + dasmdata->space = view->machine->debugvw_data->disasm_subviews->space; + /* allocate the expression data */ debug_view_expression_alloc(&dasmdata->expression); @@ -1956,18 +2122,39 @@ recompute: /*------------------------------------------------- - disasm_view_get_address_space - return the - address space whose disassembly is being - displayed + disasm_view_get_subview_list - return a linked + list of subviews -------------------------------------------------*/ -const address_space *disasm_view_get_address_space(debug_view *view) +const disasm_subview_item *disasm_view_get_subview_list(debug_view *view) +{ + assert(view->type == DVT_DISASSEMBLY); + return view->machine->debugvw_data->disasm_subviews; +} + + +/*------------------------------------------------- + disasm_view_get_subview - return the current + subview index +-------------------------------------------------*/ + +int disasm_view_get_subview(debug_view *view) { debug_view_disasm *dasmdata = view->extra_data; + const disasm_subview_item *subview; + int index = 0; + assert(view->type == DVT_DISASSEMBLY); debug_view_begin_update(view); debug_view_end_update(view); - return dasmdata->space; + + for (subview = view->machine->debugvw_data->disasm_subviews; subview != NULL; subview = subview->next) + { + if (subview->space == dasmdata->space) + return index; + index++; + } + return 0; } @@ -2050,24 +2237,27 @@ offs_t disasm_view_get_selected_address(debug_view *view) /*------------------------------------------------- - disasm_view_set_address_space - set the - address space whose disassembly is being - displayed + disasm_view_set_subview - select a new subview + by index -------------------------------------------------*/ -void disasm_view_set_address_space(debug_view *view, const address_space *space) +void disasm_view_set_subview(debug_view *view, int index) { + const disasm_subview_item *subview = disasm_view_get_subview_by_index(view->machine->debugvw_data->disasm_subviews, index); debug_view_disasm *dasmdata = view->extra_data; - + assert(view->type == DVT_DISASSEMBLY); - assert(space != NULL); + assert(subview != NULL); + if (subview == NULL) + return; - if (space != dasmdata->space) + /* handle a change */ + if (subview->space != dasmdata->space) { debug_view_begin_update(view); - dasmdata->space = space; + dasmdata->space = subview->space; - /* we need to recompute the expression in the context of the new CPU */ + /* we need to recompute the expression in the context of the new space's CPU */ dasmdata->expression.dirty = TRUE; view->recompute = view->update_pending = TRUE; debug_view_end_update(view); @@ -2184,33 +2374,130 @@ void disasm_view_set_selected_address(debug_view *view, offs_t address) } -/*------------------------------------------------- - debug_disasm_update_all - force all disasm - views to update --------------------------------------------------*/ - -void debug_disasm_update_all(void) -{ - debug_view *view; - - /* this is brute force */ - for (view = first_view; view != NULL; view = view->next) - if (view->type == DVT_DISASSEMBLY) - { - debug_view_disasm *dasmdata = view->extra_data; - debug_view_begin_update(view); - dasmdata->last_pcbyte = ~0; - view->recompute = view->update_pending = TRUE; - debug_view_end_update(view); - } -} - - /*************************************************************************** MEMORY VIEW ***************************************************************************/ +/*------------------------------------------------- + memory_view_enumerate_subviews - enumerate + all possible subviews for a memory view +-------------------------------------------------*/ + +static const memory_subview_item *memory_view_enumerate_subviews(running_machine *machine) +{ + astring *tempstring = astring_alloc(); + memory_subview_item *head = NULL; + memory_subview_item **tailptr = &head; + int cpunum, spacenum; + const char *rgntag; + int curindex = 0; + int itemnum; + + /* first add all the CPUs' address spaces */ + for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) + if (machine->cpu[cpunum] != NULL) + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + { + const address_space *space = cpu_get_address_space(machine->cpu[cpunum], spacenum); + if (space != NULL) + { + memory_subview_item *subview; + + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "CPU '%s' (%s) %s memory", space->cpu->tag, cpu_get_name(space->cpu), space->name); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); + + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->space = space; + subview->prefsize = space->dbits / 8; + strcpy(subview->name, astring_c(tempstring)); + + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } + } + + /* then add all the memory regions */ + for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = memory_region_next(machine, rgntag)) + { + UINT32 flags = memory_region_flags(machine, rgntag); + UINT8 little_endian = ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE); + UINT8 width = 1 << ((flags & ROMREGION_WIDTHMASK) >> 8); + memory_subview_item *subview; + + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "Region '%s'", rgntag); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); + + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->base = memory_region(machine, rgntag); + subview->length = memory_region_length(machine, rgntag); + subview->offsetxor = memory_region_length(machine, rgntag); + subview->endianness = little_endian ? CPU_IS_LE : CPU_IS_BE; + subview->prefsize = MIN(width, 8); + strcpy(subview->name, astring_c(tempstring)); + + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } + + /* finally add all global array symbols */ + for (itemnum = 0; itemnum < 10000; itemnum++) + { + UINT32 valsize, valcount; + const char *name; + void *base; + + /* stop when we run out of items */ + name = state_save_get_indexed_item(itemnum, &base, &valsize, &valcount); + if (name == NULL) + break; + + /* if this is a single-entry global, add it */ + if (valcount > 1 && strstr(name, "/globals/")) + { + memory_subview_item *subview; + + /* determine the string and allocate a subview large enough */ + astring_printf(tempstring, "%s", strrchr(name, '/') + 1); + subview = auto_malloc(sizeof(*subview) + astring_len(tempstring)); + memset(subview, 0, sizeof(*subview)); + + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->base = base; + subview->length = valcount * valsize; + subview->offsetxor = 0; +#ifdef LSB_FIRST + subview->endianness = CPU_IS_LE; +#else + subview->endianness = CPU_IS_BE; +#endif + subview->prefsize = MIN(valsize, 8); + strcpy(subview->name, astring_c(tempstring)); + + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; + } + } + + /* free the temporary string */ + astring_free(tempstring); + return head; +} + + /*------------------------------------------------- memory_view_alloc - allocate memory for the memory view @@ -2219,6 +2506,10 @@ void debug_disasm_update_all(void) static int memory_view_alloc(debug_view *view) { debug_view_memory *memdata; + + /* fail if no available subviews */ + if (view->machine->debugvw_data->memory_subviews == NULL) + return FALSE; /* allocate memory */ memdata = malloc(sizeof(*memdata)); @@ -2235,15 +2526,8 @@ static int memory_view_alloc(debug_view *view) /* we support cursors */ view->supports_cursor = TRUE; - /* dummy up a raw location to start */ - memdata->raw.base = &memdata->raw; - memdata->raw.length = 1; - memdata->raw.offsetxor = 0; -#ifdef LITTLE_ENDIAN - memdata->raw.endianness = CPU_IS_LE; -#else - memdata->raw.endianness = CPU_IS_BE; -#endif + /* default to the first subview */ + 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; @@ -2301,7 +2585,7 @@ static void memory_view_notify(debug_view *view, view_notification type) static void memory_view_update(debug_view *view) { debug_view_memory *memdata = view->extra_data; - const address_space *space = memdata->space; + const address_space *space = memdata->desc->space; const memory_view_pos *posdata; UINT32 row; @@ -2386,7 +2670,7 @@ static void memory_view_update(debug_view *view) } /* restore the context */ - if (memdata->raw.base == NULL) + if (memdata->desc->base == NULL) cpu_pop_context(); } @@ -2517,7 +2801,7 @@ static void memory_view_char(debug_view *view, int chval) static void memory_view_recompute(debug_view *view) { debug_view_memory *memdata = view->extra_data; - const address_space *space = memdata->space; + const address_space *space = memdata->desc->space; offs_t cursoraddr; UINT8 cursorshift; int addrchars; @@ -2533,7 +2817,7 @@ static void memory_view_recompute(debug_view *view) } else { - memdata->maxaddr = memdata->raw.length - 1; + memdata->maxaddr = memdata->desc->length - 1; addrchars = sprintf(memdata->addrformat, "%X", memdata->maxaddr); } @@ -2597,10 +2881,11 @@ static void memory_view_recompute(debug_view *view) static int memory_view_needs_recompute(debug_view *view) { debug_view_memory *memdata = view->extra_data; + const address_space *space = memdata->desc->space; int recompute = view->recompute; /* handle expression changes */ - if (debug_view_expression_changed_value(view, &memdata->expression, (memdata->space != NULL) ? memdata->space->cpu : NULL)) + if (debug_view_expression_changed_value(view, &memdata->expression, (space != NULL) ? space->cpu : NULL)) { recompute = TRUE; memory_view_set_cursor_pos(view, memdata->expression.result, memdata->bytes_per_chunk * 8 - 4); @@ -2698,17 +2983,18 @@ static void memory_view_set_cursor_pos(debug_view *view, offs_t address, UINT8 s static UINT64 memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t offs) { /* if no raw data, just use the standard debug routines */ - if (memdata->space != NULL) + if (memdata->desc->space != NULL) { + const address_space *space = memdata->desc->space; UINT64 result = ~(UINT64)0; - cpu_push_context(memdata->space->cpu); + cpu_push_context(space->cpu); switch (size) { - case 1: result = debug_read_byte(memdata->space, offs, !memdata->no_translation); break; - case 2: result = debug_read_word(memdata->space, offs, !memdata->no_translation); break; - case 4: result = debug_read_dword(memdata->space, offs, !memdata->no_translation); break; - case 8: result = debug_read_qword(memdata->space, offs, !memdata->no_translation); break; + case 1: result = debug_read_byte(space, offs, !memdata->no_translation); break; + case 2: result = debug_read_word(space, offs, !memdata->no_translation); break; + case 4: result = debug_read_dword(space, offs, !memdata->no_translation); break; + case 8: result = debug_read_qword(space, offs, !memdata->no_translation); break; } cpu_pop_context(); return result; @@ -2718,17 +3004,17 @@ static UINT64 memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t of if (size > 1) { size /= 2; - if (memdata->raw.endianness == CPU_IS_LE) + if (memdata->desc->endianness == CPU_IS_LE) return memory_view_read(memdata, size, offs + 0 * size) | ((UINT64)memory_view_read(memdata, size, offs + 1 * size) << (size * 8)); else return memory_view_read(memdata, size, offs + 1 * size) | ((UINT64)memory_view_read(memdata, size, offs + 0 * size) << (size * 8)); } /* all 0xff if out of bounds */ - offs ^= memdata->raw.offsetxor; - if (offs >= memdata->raw.length) + offs ^= memdata->desc->offsetxor; + if (offs >= memdata->desc->length) return 0xff; - return *((UINT8 *)memdata->raw.base + offs); + return *((UINT8 *)memdata->desc->base + offs); } @@ -2740,15 +3026,17 @@ static UINT64 memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t of static void memory_view_write(debug_view_memory *memdata, UINT8 size, offs_t offs, UINT64 data) { /* if no raw data, just use the standard debug routines */ - if (memdata->space != NULL) + if (memdata->desc->space != NULL) { - cpu_push_context(memdata->space->cpu); + const address_space *space = memdata->desc->space; + + cpu_push_context(space->cpu); switch (size) { - case 1: debug_write_byte(memdata->space, offs, data, !memdata->no_translation); break; - case 2: debug_write_word(memdata->space, offs, data, !memdata->no_translation); break; - case 4: debug_write_dword(memdata->space, offs, data, !memdata->no_translation); break; - case 8: debug_write_qword(memdata->space, offs, data, !memdata->no_translation); break; + case 1: debug_write_byte(space, offs, data, !memdata->no_translation); break; + case 2: debug_write_word(space, offs, data, !memdata->no_translation); break; + case 4: debug_write_dword(space, offs, data, !memdata->no_translation); break; + case 8: debug_write_qword(space, offs, data, !memdata->no_translation); break; } cpu_pop_context(); return; @@ -2758,7 +3046,7 @@ static void memory_view_write(debug_view_memory *memdata, UINT8 size, offs_t off if (size > 1) { size /= 2; - if (memdata->raw.endianness == CPU_IS_LE) + if (memdata->desc->endianness == CPU_IS_LE) { memory_view_write(memdata, size, offs + 0 * size, data); memory_view_write(memdata, size, offs + 1 * size, data >> (8 * size)); @@ -2772,14 +3060,14 @@ static void memory_view_write(debug_view_memory *memdata, UINT8 size, offs_t off } /* ignore if out of bounds */ - offs ^= memdata->raw.offsetxor; - if (offs >= memdata->raw.length) + offs ^= memdata->desc->offsetxor; + if (offs >= memdata->desc->length) return; - *((UINT8 *)memdata->raw.base + offs) = data; + *((UINT8 *)memdata->desc->base + offs) = data; /* hack for FD1094 editing */ #ifdef FD1094_HACK - if (memdata->raw.base == memory_region(view->machine, "user2")) + if (memdata->desc->base == memory_region(view->machine, "user2")) { extern void fd1094_regenerate_key(void); fd1094_regenerate_key(); @@ -2789,32 +3077,31 @@ static void memory_view_write(debug_view_memory *memdata, UINT8 size, offs_t off /*------------------------------------------------- - memory_view_get_address_space - return the - address space whose memory is being displayed + memory_view_get_subview_list - return a linked + list of subviews -------------------------------------------------*/ -const address_space *memory_view_get_address_space(debug_view *view) +const memory_subview_item *memory_view_get_subview_list(debug_view *view) { - debug_view_memory *memdata = view->extra_data; assert(view->type == DVT_MEMORY); - debug_view_begin_update(view); - debug_view_end_update(view); - return memdata->space; + return view->machine->debugvw_data->memory_subviews; } /*------------------------------------------------- - memory_view_get_raw - return a raw description - of the memory being displayed + memory_view_get_subview - return the current + subview index -------------------------------------------------*/ -const memory_view_raw *memory_view_get_raw(debug_view *view) +int memory_view_get_subview(debug_view *view) { debug_view_memory *memdata = view->extra_data; + assert(view->type == DVT_MEMORY); debug_view_begin_update(view); debug_view_end_update(view); - return &memdata->raw; + + return memdata->desc->index; } @@ -2911,22 +3198,29 @@ UINT8 memory_view_get_physical(debug_view *view) /*------------------------------------------------- - memory_view_set_address_space - set the - address space whose memory is being displayed + memory_view_set_subview - select a new subview + by index -------------------------------------------------*/ -void memory_view_set_address_space(debug_view *view, const address_space *space) +void memory_view_set_subview(debug_view *view, int index) { + const memory_subview_item *subview = memory_view_get_subview_by_index(view->machine->debugvw_data->memory_subviews, index); debug_view_memory *memdata = view->extra_data; - + assert(view->type == DVT_MEMORY); - assert(space != NULL); + assert(subview != NULL); + if (subview == NULL) + return; - if (space != memdata->space) + /* handle a change */ + if (subview != memdata->desc) { debug_view_begin_update(view); - memdata->space = space; - memdata->raw.base = NULL; + memdata->desc = subview; + memdata->chunks_per_row = memdata->bytes_per_chunk * memdata->chunks_per_row / memdata->desc->prefsize; + memdata->bytes_per_chunk = memdata->desc->prefsize; + + /* we need to recompute the expression in the context of the new space */ memdata->expression.dirty = TRUE; view->recompute = view->update_pending = TRUE; debug_view_end_update(view); @@ -2934,27 +3228,6 @@ void memory_view_set_address_space(debug_view *view, const address_space *space) } -/*------------------------------------------------- - memory_view_set_raw - provide a raw - description of the memory to be displayed --------------------------------------------------*/ - -void memory_view_set_raw(debug_view *view, const memory_view_raw *raw) -{ - debug_view_memory *memdata = view->extra_data; - - assert(view->type == DVT_MEMORY); - assert(raw->base != NULL); - - debug_view_begin_update(view); - memdata->raw = *raw; - memdata->space = NULL; - memdata->expression.dirty = TRUE; - view->recompute = view->update_pending = TRUE; - debug_view_end_update(view); -} - - /*------------------------------------------------- memory_view_set_expression - set the expression string describing the home address @@ -2988,10 +3261,18 @@ void memory_view_set_bytes_per_chunk(debug_view *view, UINT8 chunkbytes) if (chunkbytes != memdata->bytes_per_chunk) { + offs_t address; + UINT8 shift; + debug_view_begin_update(view); + memory_view_get_cursor_pos(view, &address, &shift); 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); + address -= address % memdata->bytes_per_chunk; + memory_view_set_cursor_pos(view, address, shift); debug_view_end_update(view); } } @@ -3011,9 +3292,14 @@ void memory_view_set_chunks_per_row(debug_view *view, UINT32 rowchunks) if (rowchunks != memdata->chunks_per_row) { + offs_t address; + UINT8 shift; + debug_view_begin_update(view); + memory_view_get_cursor_pos(view, &address, &shift); memdata->chunks_per_row = rowchunks; view->recompute = view->update_pending = TRUE; + memory_view_set_cursor_pos(view, address, shift); debug_view_end_update(view); } } @@ -3032,9 +3318,14 @@ void memory_view_set_reverse(debug_view *view, UINT8 reverse) if (reverse != memdata->reverse_view) { + offs_t address; + UINT8 shift; + debug_view_begin_update(view); + memory_view_get_cursor_pos(view, &address, &shift); memdata->reverse_view = reverse; view->recompute = view->update_pending = TRUE; + memory_view_set_cursor_pos(view, address, shift); debug_view_end_update(view); } } @@ -3054,9 +3345,14 @@ void memory_view_set_ascii(debug_view *view, UINT8 ascii) if (ascii != memdata->ascii_view) { + offs_t address; + UINT8 shift; + debug_view_begin_update(view); + memory_view_get_cursor_pos(view, &address, &shift); memdata->ascii_view = ascii; view->recompute = view->update_pending = TRUE; + memory_view_set_cursor_pos(view, address, shift); debug_view_end_update(view); } } diff --git a/src/emu/debug/debugvw.h b/src/emu/debug/debugvw.h index 26e70be9620..56ee9cab8e2 100644 --- a/src/emu/debug/debugvw.h +++ b/src/emu/debug/debugvw.h @@ -100,8 +100,46 @@ typedef void (*debug_view_osd_update_func)(debug_view *view, void *osdprivate); typedef struct _debug_view_xy debug_view_xy; struct _debug_view_xy { - INT32 x; - INT32 y; + INT32 x; + INT32 y; +}; + + +/* a registers subview item */ +typedef struct _registers_subview_item registers_subview_item; +struct _registers_subview_item +{ + registers_subview_item *next; /* link to next item */ + int index; /* index of this item */ + const device_config *device; /* CPU to display */ + char name[1]; /* name of the subview item */ +}; + + +/* a disassembly subview item */ +typedef struct _disasm_subview_item disasm_subview_item; +struct _disasm_subview_item +{ + disasm_subview_item *next; /* link to next item */ + int index; /* index of this item */ + const address_space *space; /* address space to display */ + char name[1]; /* name of the subview item */ +}; + + +/* a memory subview item */ +typedef struct _memory_subview_item memory_subview_item; +struct _memory_subview_item +{ + memory_subview_item *next; /* link to next item */ + int index; /* index of this item */ + const address_space *space; /* address space we reference (if any) */ + void * base; /* pointer to memory base */ + offs_t length; /* length of memory */ + offs_t offsetxor; /* XOR to apply to offsets */ + UINT8 endianness; /* endianness of memory */ + UINT8 prefsize; /* preferred bytes per chunk */ + char name[1]; /* name of the subview item */ }; @@ -109,19 +147,8 @@ struct _debug_view_xy typedef struct _debug_view_char debug_view_char; struct _debug_view_char { - UINT8 byte; - UINT8 attrib; -}; - - -/* description of a raw memory space */ -typedef struct _memory_view_raw memory_view_raw; -struct _memory_view_raw -{ - void * base; - offs_t length; - offs_t offsetxor; - UINT8 endianness; + UINT8 byte; + UINT8 attrib; }; @@ -157,13 +184,10 @@ void debug_view_begin_update(debug_view *view); void debug_view_end_update(debug_view *view); /* force all views to refresh */ -void debug_view_update_all(void); +void debug_view_update_all(running_machine *machine); /* force all views of a given type to refresh */ -void debug_view_update_type(int type); - -/* force all disassembly views to refresh */ -void debug_disasm_update_all(void); +void debug_view_update_type(running_machine *machine, int type); @@ -217,18 +241,24 @@ void debug_view_set_cursor_visible(debug_view *view, int visible); /* ----- registers view-specific properties ----- */ -/* return the CPU whose registers are currently displayed */ -const device_config *registers_view_get_cpu(debug_view *view); +/* return a linked list of subviews */ +const registers_subview_item *registers_view_get_subview_list(debug_view *view); -/* specify the CPU whose registers are to be displayed */ -void registers_view_set_cpu(debug_view *view, const device_config *device); +/* return the current subview index */ +int registers_view_get_subview(debug_view *view); + +/* select a new subview by index */ +void registers_view_set_subview(debug_view *view, int index); /* ----- disassembly view-specific properties ----- */ -/* return the address space whose disassembly is being displayed */ -const address_space *disasm_view_get_address_space(debug_view *view); +/* return a linked list of subviews */ +const disasm_subview_item *disasm_view_get_subview_list(debug_view *view); + +/* return the current subview index */ +int disasm_view_get_subview(debug_view *view); /* return the expression string describing the home address */ const char *disasm_view_get_expression(debug_view *view); @@ -245,8 +275,8 @@ UINT32 disasm_view_get_disasm_width(debug_view *view); /* return the PC of the currently selected address in the view */ offs_t disasm_view_get_selected_address(debug_view *view); -/* set the address space whose disassembly is being displayed */ -void disasm_view_set_address_space(debug_view *view, const address_space *space); +/* select a new subview by index */ +void disasm_view_set_subview(debug_view *view, int index); /* set the expression string describing the home address */ void disasm_view_set_expression(debug_view *view, const char *expression); @@ -267,11 +297,11 @@ void disasm_view_set_selected_address(debug_view *view, offs_t address); /* ----- memory view-specific properties ----- */ -/* return the address space whose memory is being displayed */ -const address_space *memory_view_get_address_space(debug_view *view); +/* return a linked list of subviews */ +const memory_subview_item *memory_view_get_subview_list(debug_view *view); -/* return a raw description of the memory being displayed */ -const memory_view_raw *memory_view_get_raw(debug_view *view); +/* return the current subview index */ +int memory_view_get_subview(debug_view *view); /* return the expression string describing the home address */ const char *memory_view_get_expression(debug_view *view); @@ -291,11 +321,8 @@ UINT8 memory_view_get_ascii(debug_view *view); /* return TRUE if the memory view is displaying physical addresses versus logical addresses */ UINT8 memory_view_get_physical(debug_view *view); -/* set the address space whose memory is being displayed */ -void memory_view_set_address_space(debug_view *view, const address_space *space); - -/* provide a raw description of the memory to be displayed */ -void memory_view_set_raw(debug_view *view, const memory_view_raw *raw); +/* select a new subview by index */ +void memory_view_set_subview(debug_view *view, int index); /* set the expression string describing the home address */ void memory_view_set_expression(debug_view *view, const char *expression); @@ -316,4 +343,87 @@ void memory_view_set_ascii(debug_view *view, UINT8 ascii); void memory_view_set_physical(debug_view *view, UINT8 physical); + +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + +/*------------------------------------------------- + registers_view_get_subview_by_index - return a + pointer to a registers subview by index +-------------------------------------------------*/ + +INLINE const registers_subview_item *registers_view_get_subview_by_index(const registers_subview_item *itemlist, int index) +{ + for ( ; itemlist != NULL; itemlist = itemlist->next) + if (itemlist->index == index) + return itemlist; + return NULL; +} + + +/*------------------------------------------------- + registers_view_get_current_subview - return a + pointer to the current subview of a + registers view +-------------------------------------------------*/ + +INLINE const registers_subview_item *registers_view_get_current_subview(debug_view *view) +{ + return registers_view_get_subview_by_index(registers_view_get_subview_list(view), registers_view_get_subview(view)); +} + + +/*------------------------------------------------- + disasm_view_get_subview_by_index - return a + pointer to a disasm subview by index +-------------------------------------------------*/ + +INLINE const disasm_subview_item *disasm_view_get_subview_by_index(const disasm_subview_item *itemlist, int index) +{ + for ( ; itemlist != NULL; itemlist = itemlist->next) + if (itemlist->index == index) + return itemlist; + return NULL; +} + + +/*------------------------------------------------- + disasm_view_get_current_subview - return a + pointer to the current subview of a + disassembly view +-------------------------------------------------*/ + +INLINE const disasm_subview_item *disasm_view_get_current_subview(debug_view *view) +{ + return disasm_view_get_subview_by_index(disasm_view_get_subview_list(view), disasm_view_get_subview(view)); +} + + +/*------------------------------------------------- + memory_view_get_subview_by_index - return a + pointer to a memory subview by index +-------------------------------------------------*/ + +INLINE const memory_subview_item *memory_view_get_subview_by_index(const memory_subview_item *itemlist, int index) +{ + for ( ; itemlist != NULL; itemlist = itemlist->next) + if (itemlist->index == index) + return itemlist; + return NULL; +} + + +/*------------------------------------------------- + memory_view_get_current_subview - return a + pointer to the current subview of a + memory view +-------------------------------------------------*/ + +INLINE const memory_subview_item *memory_view_get_current_subview(debug_view *view) +{ + return memory_view_get_subview_by_index(memory_view_get_subview_list(view), memory_view_get_subview(view)); +} + + #endif diff --git a/src/emu/mame.h b/src/emu/mame.h index 2da58eec3b3..afac454a7ad 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -135,6 +135,7 @@ typedef struct _input_port_private input_port_private; typedef struct _ui_input_private ui_input_private; typedef struct _cheat_private cheat_private; typedef struct _debugcpu_private debugcpu_private; +typedef struct _debugvw_private debugvw_private; /* description of the currently-running machine */ @@ -180,6 +181,7 @@ struct _running_machine ui_input_private * ui_input_data; /* internal data from uiinput.c */ cheat_private * cheat_data; /* internal data from cheat.c */ debugcpu_private * debugcpu_data; /* internal data from debugcpu.c */ + debugvw_private * debugvw_data; /* internal data from debugvw.c */ #ifdef MESS images_private * images_data; /* internal data from image.c */ ui_mess_private * ui_mess_data; /* internal data from uimess.c */ diff --git a/src/mame/machine/fddebug.c b/src/mame/machine/fddebug.c index 217993f6dca..1ba599fc467 100644 --- a/src/mame/machine/fddebug.c +++ b/src/mame/machine/fddebug.c @@ -280,9 +280,9 @@ static void execute_fdclist(running_machine *machine, int ref, int params, const static void execute_fdcsearch(running_machine *machine, int ref, int params, const char **param); static fd1094_possibility *try_all_possibilities(running_machine *machine, int basepc, int offset, int length, UINT8 *instrbuffer, UINT8 *keybuffer, fd1094_possibility *possdata); -static void tag_possibility(fd1094_possibility *possdata, UINT8 status); +static void tag_possibility(running_machine *machine, fd1094_possibility *possdata, UINT8 status); -static void perform_constrained_search(void); +static void perform_constrained_search(running_machine *machine); static UINT32 find_global_key_matches(UINT32 startwith, UINT16 *output); static int find_constraint_sequence(UINT32 global, int quick); static int does_key_work_for_constraints(const UINT16 *base, UINT8 *key); @@ -416,13 +416,13 @@ INLINE void set_constraint(fd1094_constraint *constraint, UINT32 pc, UINT16 stat for a given address -----------------------------------------------*/ -INLINE void print_possibilities(void) +INLINE void print_possibilities(running_machine *machine) { int i; - debug_console_printf("Possibilities @ %06X:\n", posslist[0].basepc); + debug_console_printf(machine, "Possibilities @ %06X:\n", posslist[0].basepc); for (i = 0; i < posscount; i++) - debug_console_printf(" %c%2x: %s\n", posslist[i].iffy ? ' ' : '*', i, posslist[i].dasm); + debug_console_printf(machine, " %c%2x: %s\n", posslist[i].iffy ? ' ' : '*', i, posslist[i].dasm); } @@ -679,8 +679,8 @@ void fd1094_regenerate_key(void) (*key_changed)(); /* force all memory and disassembly views to update */ - debug_view_update_type(DVT_MEMORY); - debug_disasm_update_all(); + debug_view_update_type(Machine, DVT_MEMORY); + debug_view_update_type(Machine, DVT_DISASSEMBLY); /* reset keydirty */ keydirty = FALSE; @@ -730,13 +730,13 @@ static int instruction_hook(const device_config *device, offs_t curpc) /* if we only ended up with one possibility, mark that one as good */ if (posscount == 1) { - tag_possibility(&posslist[0], STATUS_LOCKED); + tag_possibility(device->machine, &posslist[0], STATUS_LOCKED); fd1094_regenerate_key(); return 0; } /* print possibilities and break */ - print_possibilities(); + print_possibilities(device->machine); return 1; } @@ -748,7 +748,7 @@ static int instruction_hook(const device_config *device, offs_t curpc) static void execute_fdsave(running_machine *machine, int ref, int params, const char **param) { save_overlay_file(machine); - debug_console_printf("File saved\n"); + debug_console_printf(machine, "File saved\n"); } @@ -773,7 +773,7 @@ static void execute_fdoutput(running_machine *machine, int ref, int params, cons mame_fwrite(file, keyregion, KEY_SIZE); mame_fclose(file); } - debug_console_printf("File '%s' saved\n", param[0]); + debug_console_printf(machine, "File '%s' saved\n", param[0]); } @@ -819,7 +819,7 @@ static void execute_fdlockguess(running_machine *machine, int ref, int params, c /* make sure it is within range of our recent possibilities */ if (num1 >= posscount) { - debug_console_printf("Possibility of out range (%x max)\n", posscount); + debug_console_printf(machine, "Possibility of out range (%x max)\n", posscount); return; } @@ -827,7 +827,7 @@ static void execute_fdlockguess(running_machine *machine, int ref, int params, c memcpy(undobuff, keystatus, keystatus_words * 2); /* tag this possibility as indicated by the ref parameter, and then regenerate the key */ - tag_possibility(&posslist[num1], ref); + tag_possibility(machine, &posslist[num1], ref); fd1094_regenerate_key(); } @@ -854,7 +854,7 @@ static void execute_fdeliminate(running_machine *machine, int ref, int params, c /* make sure it is within range of our recent possibilities */ if (num1 >= posscount) { - debug_console_printf("Possibility %x of out range (%x max)\n", (int)num1, posscount); + debug_console_printf(machine, "Possibility %x of out range (%x max)\n", (int)num1, posscount); return; } @@ -879,7 +879,7 @@ static void execute_fdeliminate(running_machine *machine, int ref, int params, c posscount = possdst; /* reprint the possibilities */ - print_possibilities(); + print_possibilities(machine); } @@ -900,7 +900,7 @@ static void execute_fdunlock(running_machine *machine, int ref, int params, cons keyaddr = addr_to_keyaddr(offset / 2); /* toggle the ignore PC status */ - debug_console_printf("Unlocking PC %06X\n", (int)offset); + debug_console_printf(machine, "Unlocking PC %06X\n", (int)offset); /* iterate over all reps and unlock them */ for (repnum = 0; repnum < reps; repnum++) @@ -933,7 +933,7 @@ static void execute_fdignore(running_machine *machine, int ref, int params, cons if (params == 1 && strcmp(param[0], "all") == 0) { ignore_all = TRUE; - debug_console_printf("Ignoring all unknown opcodes\n"); + debug_console_printf(machine, "Ignoring all unknown opcodes\n"); return; } if (params != 1 || !debug_command_parameter_number(machine, param[0], &offset)) @@ -943,9 +943,9 @@ static void execute_fdignore(running_machine *machine, int ref, int params, cons /* toggle the ignore PC status */ ignorepc[offset] = !ignorepc[offset]; if (ignorepc[offset]) - debug_console_printf("Ignoring address %06X\n", (int)offset * 2); + debug_console_printf(machine, "Ignoring address %06X\n", (int)offset * 2); else - debug_console_printf("No longer ignoring address %06X\n", (int)offset * 2); + debug_console_printf(machine, "No longer ignoring address %06X\n", (int)offset * 2); /* if no parameter given, implicitly run as well */ if (params == 0) @@ -963,7 +963,7 @@ static void execute_fdundo(running_machine *machine, int ref, int params, const /* copy the undobuffer back and regenerate the key */ memcpy(keystatus, undobuff, keystatus_words * 2); fd1094_regenerate_key(); - debug_console_printf("Undid last change\n"); + debug_console_printf(machine, "Undid last change\n"); } @@ -993,9 +993,9 @@ static void execute_fdstatus(running_machine *machine, int ref, int params, cons else nomatter++; } - debug_console_printf("%4d/%4d keys locked (%d%%)\n", locked, KEY_SIZE, locked * 100 / KEY_SIZE); - debug_console_printf("%4d/%4d keys guessed (%d%%)\n", guesses, KEY_SIZE, guesses * 100 / KEY_SIZE); - debug_console_printf("%4d/%4d keys don't matter (%d%%)\n", nomatter, KEY_SIZE, nomatter * 100 / KEY_SIZE); + debug_console_printf(machine, "%4d/%4d keys locked (%d%%)\n", locked, KEY_SIZE, locked * 100 / KEY_SIZE); + debug_console_printf(machine, "%4d/%4d keys guessed (%d%%)\n", guesses, KEY_SIZE, guesses * 100 / KEY_SIZE); + debug_console_printf(machine, "%4d/%4d keys don't matter (%d%%)\n", nomatter, KEY_SIZE, nomatter * 100 / KEY_SIZE); } @@ -1015,12 +1015,12 @@ static void execute_fdstate(running_machine *machine, int ref, int params, const return; fd1094_set_state(keyregion, newstate); fd1094_regenerate_key(); - debug_view_update_type(DVT_MEMORY); - debug_disasm_update_all(); + debug_view_update_type(machine, DVT_MEMORY); + debug_view_update_type(machine, DVT_DISASSEMBLY); } /* 0 parameters displays the current state */ - debug_console_printf("FD1094 state = %X\n", fd1094_set_state(keyregion, -1)); + debug_console_printf(machine, "FD1094 state = %X\n", fd1094_set_state(keyregion, -1)); } @@ -1061,14 +1061,14 @@ static void execute_fdsearch(running_machine *machine, int ref, int params, cons if (searchsp == 0 || searchstack[searchsp-1] != pc) { int pcaddr; - debug_console_printf("Starting new search at PC=%06X\n", pc); + debug_console_printf(machine, "Starting new search at PC=%06X\n", pc); searchsp = 0; for (pcaddr = 0; pcaddr < coderegion_words; pcaddr++) keystatus[pcaddr] &= ~SEARCH_MASK; } else { - debug_console_printf("Resuming search at PC=%06X\n", pc); + debug_console_printf(machine, "Resuming search at PC=%06X\n", pc); searchsp--; } @@ -1085,7 +1085,7 @@ static void execute_fdsearch(running_machine *machine, int ref, int params, cons pc = searchstack[--searchsp]; if ((keystatus[pc/2] & SEARCH_MASK) != 0) { - debug_console_printf("Search stack exhausted\n"); + debug_console_printf(machine, "Search stack exhausted\n"); break; } @@ -1108,7 +1108,7 @@ static void execute_fdsearch(running_machine *machine, int ref, int params, cons length = -length; if (length == 0) { - debug_console_printf("Invalid opcode; unable to advance\n"); + debug_console_printf(machine, "Invalid opcode; unable to advance\n"); break; } @@ -1191,7 +1191,7 @@ static void execute_fddasm(running_machine *machine, int ref, int params, const filerr = mame_fopen(SEARCHPATH_RAW, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file); if (filerr != FILERR_NONE) { - debug_console_printf("Unable to create file '%s'\n", filename); + debug_console_printf(machine, "Unable to create file '%s'\n", filename); return; } @@ -1315,7 +1315,7 @@ static void execute_fdcset(running_machine *machine, int ref, int params, const /* validate parameters */ if ((pc & 1) != 0 || pc > 0xffffff) { - debug_console_printf("Invalid PC specified (%08X)\n", (UINT32)pc); + debug_console_printf(machine, "Invalid PC specified (%08X)\n", (UINT32)pc); return; } @@ -1340,7 +1340,7 @@ static void execute_fdcset(running_machine *machine, int ref, int params, const set_constraint(&constraints[cnum], pc, state, value, mask); /* explain what we did */ - debug_console_printf("Set new constraint at PC=%06X, state=%03X: decrypted & %04X == %04X\n", + debug_console_printf(machine, "Set new constraint at PC=%06X, state=%03X: decrypted & %04X == %04X\n", (int)pc, (int)state, (int)mask, (int)value); } @@ -1358,7 +1358,7 @@ static void execute_fdclist(running_machine *machine, int ref, int params, const for (cnum = 0; cnum < constcount; cnum++) { fd1094_constraint *constraint = &constraints[cnum]; - debug_console_printf(" PC=%06X, state=%03X: decrypted & %04X == %04X\n", + debug_console_printf(machine, " PC=%06X, state=%03X: decrypted & %04X == %04X\n", constraint->pc, constraint->state, constraint->mask, constraint->value); } } @@ -1371,8 +1371,8 @@ static void execute_fdclist(running_machine *machine, int ref, int params, const static void execute_fdcsearch(running_machine *machine, int ref, int params, const char **param) { -// debug_console_printf("Searching for possible global keys....\n"); - perform_constrained_search(); +// debug_console_printf(machine, "Searching for possible global keys....\n"); + perform_constrained_search(machine); } @@ -1507,7 +1507,7 @@ static fd1094_possibility *try_all_possibilities(running_machine *machine, int b with the specified status -----------------------------------------------*/ -static void tag_possibility(fd1094_possibility *possdata, UINT8 status) +static void tag_possibility(running_machine *machine, fd1094_possibility *possdata, UINT8 status) { int curfdstate = fd1094_set_state(keyregion, -1); int nomatter = 0, locked = 0, guessed = 0; @@ -1571,7 +1571,7 @@ static void tag_possibility(fd1094_possibility *possdata, UINT8 status) nomatter++; } - debug_console_printf("PC=%06X: locked %d, guessed %d, nochange %d\n", possdata->basepc, locked, guessed, nomatter); + debug_console_printf(machine, "PC=%06X: locked %d, guessed %d, nochange %d\n", possdata->basepc, locked, guessed, nomatter); } @@ -1581,7 +1581,7 @@ static void tag_possibility(fd1094_possibility *possdata, UINT8 status) given sequence/mask pair -----------------------------------------------*/ -static void perform_constrained_search(void) +static void perform_constrained_search(running_machine *machine) { UINT32 global; @@ -1604,7 +1604,7 @@ static void perform_constrained_search(void) global = find_global_key_matches(global + 1, output); if (global == 0) break; -// debug_console_printf("Checking global key %08X (PC=%06X)....\n", global, (output[2] << 16) | output[3]); +// debug_console_printf(machine, "Checking global key %08X (PC=%06X)....\n", global, (output[2] << 16) | output[3]); /* use the IRQ handler to find more possibilities */ numseeds = find_constraint_sequence(global, FALSE); @@ -1612,7 +1612,7 @@ static void perform_constrained_search(void) { int i; for (i = 0; i < numseeds; i++) - debug_console_printf(" Possible: global=%08X seed=%06X pc=%04X\n", global, possible_seed[i], output[3]); + debug_console_printf(machine, " Possible: global=%08X seed=%06X pc=%04X\n", global, possible_seed[i], output[3]); } } } @@ -1785,7 +1785,7 @@ static int find_constraint_sequence(UINT32 global, int quick) { UINT32 seedlow; -// debug_console_printf("Global %08X ... Looking for keys that generate a keyvalue of %02X at %04X\n", +// debug_console_printf(machine, "Global %08X ... Looking for keys that generate a keyvalue of %02X at %04X\n", // global, keyvalue, keyaddr); /* iterate over seed possibilities */ diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 43959cae57b..ef205569fbd 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -156,17 +156,6 @@ struct _debugwin_info }; -typedef struct _memorycombo_item memorycombo_item; -struct _memorycombo_item -{ - memorycombo_item * next; - TCHAR name[256]; - const address_space * space; - memory_view_raw raw; - UINT8 prefsize; -}; - - //============================================================ // GLOBAL VARIABLES //============================================================ @@ -180,8 +169,6 @@ struct _memorycombo_item static debugwin_info *window_list; static debugwin_info *main_console; -static memorycombo_item *memorycombo; - static UINT8 waiting_for_debugger; static HFONT debug_font; @@ -219,6 +206,7 @@ static void memory_process_string(debugwin_info *info, const char *string); static void memory_update_menu(debugwin_info *info); static int memory_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lparam); static int memory_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam); +static void memory_update_caption(running_machine *machine, HWND wnd); static void disasm_create_window(running_machine *machine); static void disasm_recompute_children(debugwin_info *info); @@ -445,14 +433,6 @@ void debugwin_destroy_windows(void) while (window_list) DestroyWindow(window_list->wnd); - // free the combobox info - while (memorycombo) - { - void *temp = memorycombo; - memorycombo = memorycombo->next; - free(temp); - } - main_console = NULL; } @@ -1691,121 +1671,6 @@ static void log_create_window(running_machine *machine) -//============================================================ -// memory_determine_combo_items -//============================================================ - -static void memory_determine_combo_items(running_machine *machine) -{ - memorycombo_item **tail = &memorycombo; - UINT32 cpunum, spacenum; - const char *rgntag; - int itemnum; - - // first add all the CPUs' address spaces - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - { - const address_space *space = cpu_get_address_space(machine->cpu[cpunum], spacenum); - if (space != NULL) - { - memorycombo_item *ci = malloc_or_die(sizeof(*ci)); - TCHAR *t_tag, *t_name, *t_space; - - memset(ci, 0, sizeof(*ci)); - ci->space = space; - ci->prefsize = MIN(space->dbits / 8, 8); - - t_tag = tstring_from_utf8(space->cpu->tag); - t_name = tstring_from_utf8(cpu_get_name(space->cpu)); - t_space = tstring_from_utf8(space->name); - _sntprintf(ci->name, ARRAY_LENGTH(ci->name), TEXT("CPU '%s' (%s) %s memory"), t_tag, t_name, t_space); - free(t_space), - free(t_name); - free(t_tag); - - *tail = ci; - tail = &ci->next; - } - } - - // then add all the memory regions - for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = memory_region_next(machine, rgntag)) - { - memorycombo_item *ci = malloc_or_die(sizeof(*ci)); - UINT32 flags = memory_region_flags(machine, rgntag); - UINT8 little_endian = ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE); - UINT8 width = 1 << ((flags & ROMREGION_WIDTHMASK) >> 8); - TCHAR *t_tag; - - memset(ci, 0, sizeof(*ci)); - ci->raw.base = memory_region(machine, rgntag); - ci->raw.length = memory_region_length(machine, rgntag); - ci->raw.offsetxor = width - 1; - ci->raw.endianness = little_endian ? CPU_IS_LE : CPU_IS_BE; - ci->prefsize = MIN(width, 8); - - t_tag = tstring_from_utf8(rgntag); - _sntprintf(ci->name, ARRAY_LENGTH(ci->name), TEXT("Region '%s'"), t_tag); - free(t_tag); - - *tail = ci; - tail = &ci->next; - } - - // finally add all global array symbols - for (itemnum = 0; itemnum < 10000; itemnum++) - { - UINT32 valsize, valcount; - const char *name; - void *base; - - /* stop when we run out of items */ - name = state_save_get_indexed_item(itemnum, &base, &valsize, &valcount); - if (name == NULL) - break; - - /* if this is a single-entry global, add it */ - if (valcount > 1 && strstr(name, "/globals/")) - { - memorycombo_item *ci = malloc_or_die(sizeof(*ci)); - TCHAR *t_name; - - memset(ci, 0, sizeof(*ci)); - ci->raw.base = base; - ci->raw.length = valcount * valsize; - ci->raw.endianness = CPU_IS_LE; - ci->prefsize = MIN(valsize, 8); - - t_name = tstring_from_utf8(name); - _tcscpy(ci->name, _tcsrchr(t_name, TEXT('/')) + 1); - free(t_name); - - *tail = ci; - tail = &ci->next; - } - } -} - - -//============================================================ -// memory_update_selection -//============================================================ - -static void memory_update_selection(debugwin_info *info, memorycombo_item *ci) -{ - debug_view_begin_update(info->view[0].view); - if (ci->space != NULL) - memory_view_set_address_space(info->view[0].view, ci->space); - else - memory_view_set_raw(info->view[0].view, &ci->raw); - memory_view_set_bytes_per_chunk(info->view[0].view, ci->prefsize); - debug_view_end_update(info->view[0].view); - SetWindowText(info->wnd, ci->name); -} - - //============================================================ // memory_create_window //============================================================ @@ -1813,7 +1678,7 @@ static void memory_update_selection(debugwin_info *info, memorycombo_item *ci) static void memory_create_window(running_machine *machine) { const device_config *curcpu = debug_cpu_get_visible_cpu(machine); - memorycombo_item *ci, *selci = NULL; + const memory_subview_item *subview; debugwin_info *info; HMENU optionsmenu; int cursel = 0; @@ -1866,27 +1731,23 @@ static void memory_create_window(running_machine *machine) SendMessage(info->otherwnd[0], WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE); // populate the combobox - if (memorycombo == NULL) - memory_determine_combo_items(machine); - for (ci = memorycombo; ci != NULL; ci = ci->next) + for (subview = memory_view_get_subview_list(info->view[0].view); subview != NULL; subview = subview->next) { - int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)ci->name); - if (selci == NULL && ci->space != NULL && ci->space->cpu == curcpu) - { + 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) cursel = item; - selci = ci; - } } SendMessage(info->otherwnd[0], CB_SETCURSEL, cursel, 0); + memory_view_set_subview(info->view[0].view, cursel); // set the child functions info->recompute_children = memory_recompute_children; info->process_string = memory_process_string; - // set the CPUnum and spacenum properties - if (selci == NULL) - selci = memorycombo; - memory_update_selection(info, selci); + // set the caption + memory_update_caption(machine, info->wnd); // recompute the children once to get the maxwidth memory_recompute_children(info); @@ -1999,11 +1860,8 @@ static int memory_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar int sel = SendMessage((HWND)lparam, CB_GETCURSEL, 0, 0); if (sel != CB_ERR) { - // find the matching entry - memorycombo_item *ci; - for (ci = memorycombo; ci; ci = ci->next) - if (sel-- == 0) - memory_update_selection(info, ci); + memory_view_set_subview(info->view[0].view, sel); + memory_update_caption(info->machine, info->wnd); // reset the focus SetFocus(info->focuswnd); @@ -2111,17 +1969,33 @@ static int memory_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam) +//============================================================ +// memory_update_caption +//============================================================ + +static void memory_update_caption(running_machine *machine, HWND wnd) +{ + debugwin_info *info = (debugwin_info *)(FPTR)GetWindowLongPtr(wnd, GWLP_USERDATA); + const memory_subview_item *subview = memory_view_get_current_subview(info->view[0].view); + char title[256]; + + sprintf(title, "Memory: %s", subview->name); + win_set_window_text_utf8(wnd, title); +} + + + //============================================================ // disasm_create_window //============================================================ static void disasm_create_window(running_machine *machine) { - const address_space *selspace = NULL, *fallbackspace = NULL; - int selindex = 0, fallbackindex = 0; + const device_config *curcpu = debug_cpu_get_visible_cpu(machine); + const disasm_subview_item *subview; debugwin_info *info; HMENU optionsmenu; - UINT32 cpunum; + int cursel = 0; // create the window info = debugwin_window_create(machine, "Disassembly", NULL); @@ -2160,47 +2034,26 @@ static void disasm_create_window(running_machine *machine) // create a combo box info->otherwnd[0] = CreateWindowEx(COMBO_BOX_STYLE_EX, TEXT("COMBOBOX"), NULL, COMBO_BOX_STYLE, - 0, 0, 100, 100, info->wnd, NULL, GetModuleHandle(NULL), NULL); + 0, 0, 100, 1000, info->wnd, NULL, GetModuleHandle(NULL), NULL); SetWindowLongPtr(info->otherwnd[0], GWLP_USERDATA, (LONG_PTR)info); SendMessage(info->otherwnd[0], WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE); // populate the combobox - for (cpunum = 0; cpunum < ARRAY_LENGTH(machine->cpu); cpunum++) - if (machine->cpu[cpunum] != NULL) - { - const address_space *space = cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM); - if (space != NULL) - { - TCHAR *t_cpu_name = tstring_from_utf8(cpu_get_name(space->cpu)); - TCHAR *t_cpu_tag = tstring_from_utf8(space->cpu->tag); - TCHAR name[100]; - int item; - - _sntprintf(name, ARRAY_LENGTH(name), TEXT("CPU '%s' (%s)"), t_cpu_tag, t_cpu_name); - free(t_cpu_tag); - free(t_cpu_name); - item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)name); - if (space->cpu == debug_cpu_get_visible_cpu(machine)) - { - selspace = space; - selindex = item; - } - else if (fallbackspace == NULL) - { - fallbackspace = space; - fallbackindex = item; - } - } - } - SendMessage(info->otherwnd[0], CB_SETCURSEL, (selspace != NULL) ? selindex : fallbackindex, 0); + for (subview = disasm_view_get_subview_list(info->view[0].view); subview != NULL; subview = subview->next) + { + 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->cpu == curcpu) + cursel = item; + } + SendMessage(info->otherwnd[0], CB_SETCURSEL, cursel, 0); + disasm_view_set_subview(info->view[0].view, cursel); // set the child functions info->recompute_children = disasm_recompute_children; info->process_string = disasm_process_string; - // set the target space - disasm_view_set_address_space(info->view[0].view, (selspace != NULL) ? selspace : fallbackspace); - // set the caption disasm_update_caption(machine, info->wnd); @@ -2314,18 +2167,8 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar int sel = SendMessage((HWND)lparam, CB_GETCURSEL, 0, 0); if (sel != CB_ERR) { - // find the matching entry - UINT32 cpunum; - for (cpunum = 0; cpunum < ARRAY_LENGTH(info->machine->cpu); cpunum++) - if (info->machine->cpu[cpunum] != NULL) - { - const address_space *space = cpu_get_address_space(info->machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM); - if (space != NULL && sel-- == 0) - { - disasm_view_set_address_space(info->view[0].view, space); - disasm_update_caption(info->machine, info->wnd); - } - } + disasm_view_set_subview(info->view[0].view, sel); + disasm_update_caption(info->machine, info->wnd); // reset the focus SetFocus(info->focuswnd); @@ -2356,7 +2199,7 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar case ID_RUN_TO_CURSOR: if (debug_view_get_cursor_visible(info->view[0].view)) { - const address_space *space = disasm_view_get_address_space(info->view[0].view); + const address_space *space = disasm_view_get_current_subview(info->view[0].view)->space; if (debug_cpu_get_visible_cpu(info->machine) == space->cpu) { offs_t address = memory_byte_to_address(space, disasm_view_get_selected_address(info->view[0].view)); @@ -2369,7 +2212,7 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar case ID_TOGGLE_BREAKPOINT: if (debug_view_get_cursor_visible(info->view[0].view)) { - const address_space *space = disasm_view_get_address_space(info->view[0].view); + const address_space *space = disasm_view_get_current_subview(info->view[0].view)->space; if (debug_cpu_get_visible_cpu(info->machine) == space->cpu) { offs_t address = memory_byte_to_address(space, disasm_view_get_selected_address(info->view[0].view)); @@ -2458,11 +2301,10 @@ static int disasm_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam) static void disasm_update_caption(running_machine *machine, HWND wnd) { debugwin_info *info = (debugwin_info *)(FPTR)GetWindowLongPtr(wnd, GWLP_USERDATA); - const address_space *space = disasm_view_get_address_space(info->view[0].view); - char title[100]; - - // then update the caption - sprintf(title, "Disassembly: CPU '%s' (%s)", space->cpu->tag, cpu_get_name(space->cpu)); + const disasm_subview_item *subview = disasm_view_get_current_subview(info->view[0].view); + char title[256]; + + sprintf(title, "Disassembly: %s", subview->name); win_set_window_text_utf8(wnd, title); } @@ -2474,11 +2316,12 @@ static void disasm_update_caption(running_machine *machine, HWND wnd) void console_create_window(running_machine *machine) { + const registers_subview_item *regsubview; + const disasm_subview_item *dasmsubview; debugwin_info *info; int bestwidth, bestheight; RECT bounds, work_bounds; HMENU optionsmenu; - UINT32 cpunum; // create the window info = debugwin_window_create(machine, "Debug", NULL); @@ -2528,30 +2371,30 @@ void console_create_window(running_machine *machine) // loop over all CPUs and compute the sizes info->minwidth = 0; info->maxwidth = 0; - for (cpunum = MAX_CPU - 1; (INT32)cpunum >= 0; cpunum--) - if (machine->cpu[cpunum] != NULL) - { - const address_space *program = cpu_get_address_space(machine->cpu[cpunum], ADDRESS_SPACE_PROGRAM); - UINT32 regchars, dischars, conchars; - UINT32 minwidth, maxwidth; + for (dasmsubview = disasm_view_get_subview_list(info->view[0].view); dasmsubview != NULL; dasmsubview = dasmsubview->next) + for (regsubview = registers_view_get_subview_list(info->view[1].view); regsubview != NULL; regsubview = regsubview->next) + if (dasmsubview->space->cpu == regsubview->device) + { + UINT32 regchars, dischars, conchars; + UINT32 minwidth, maxwidth; - // point all views to the new CPU number - disasm_view_set_address_space(info->view[0].view, program); - registers_view_set_cpu(info->view[1].view, program->cpu); + // point all views to the appropriate index + disasm_view_set_subview(info->view[0].view, dasmsubview->index); + registers_view_set_subview(info->view[1].view, regsubview->index); - // get the total width of all three children - dischars = debug_view_get_total_size(info->view[0].view).x; - regchars = debug_view_get_total_size(info->view[1].view).x; - conchars = debug_view_get_total_size(info->view[2].view).x; + // get the total width of all three children + dischars = debug_view_get_total_size(info->view[0].view).x; + regchars = debug_view_get_total_size(info->view[1].view).x; + conchars = debug_view_get_total_size(info->view[2].view).x; - // compute the preferred width - minwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + 100 + EDGE_WIDTH; - maxwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + ((dischars > conchars) ? dischars : conchars) * debug_font_width + vscroll_width + EDGE_WIDTH; - if (minwidth > info->minwidth) - info->minwidth = minwidth; - if (maxwidth > info->maxwidth) - info->maxwidth = maxwidth; - } + // compute the preferred width + minwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + 100 + EDGE_WIDTH; + maxwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + ((dischars > conchars) ? dischars : conchars) * debug_font_width + vscroll_width + EDGE_WIDTH; + if (minwidth > info->minwidth) + info->minwidth = minwidth; + if (maxwidth > info->maxwidth) + info->maxwidth = maxwidth; + } // get the work bounds SystemParametersInfo(SPI_GETWORKAREA, 0, &work_bounds, 0); @@ -2671,16 +2514,28 @@ static void console_process_string(debugwin_info *info, const char *string) static void console_set_cpu(const device_config *device) { + const registers_subview_item *regsubitem; + const disasm_subview_item *dasmsubitem; char title[256], curtitle[256]; // first set all the views to the new cpu number if (main_console->view[0].view != NULL) - disasm_view_set_address_space(main_console->view[0].view, cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM)); + for (dasmsubitem = disasm_view_get_subview_list(main_console->view[0].view); dasmsubitem != NULL; dasmsubitem = dasmsubitem->next) + if (dasmsubitem->space->cpu == device) + { + disasm_view_set_subview(main_console->view[0].view, dasmsubitem->index); + break; + } if (main_console->view[1].view != NULL) - registers_view_set_cpu(main_console->view[1].view, device); + for (regsubitem = registers_view_get_subview_list(main_console->view[1].view); regsubitem != NULL; regsubitem = regsubitem->next) + if (regsubitem->device == device) + { + registers_view_set_subview(main_console->view[1].view, regsubitem->index); + break; + } // then update the caption - snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU '%s' (%s)", device->machine->gamedrv->name, device->tag, cpu_get_name(device)); + snprintf(title, ARRAY_LENGTH(title), "Debug: %s - %s", device->machine->gamedrv->name, regsubitem->name); win_get_window_text_utf8(main_console->wnd, curtitle, ARRAY_LENGTH(curtitle)); if (strcmp(title, curtitle) != 0) win_set_window_text_utf8(main_console->wnd, title);