src/osd/sdl/debugwin.c
| r3755 | r3756 | |
| 41 | 41 | debug_view *console; |
| 42 | 42 | debug_view *disasm; |
| 43 | 43 | debug_view *registers; |
| 44 | | int cpu; |
| 45 | | running_machine *machine; |
| 44 | const device_config *cpu; // current CPU |
| 45 | running_machine *machine; // machine |
| 46 | 46 | } debugmain_i; |
| 47 | 47 | |
| 48 | 48 | typedef struct memorywin_i { |
| r3755 | r3756 | |
| 53 | 53 | GtkComboBox *zone_w; |
| 54 | 54 | debug_view *memory; |
| 55 | 55 | running_machine *machine; |
| 56 | |
| 56 | 57 | } memorywin_i; |
| 57 | 58 | |
| 58 | 59 | typedef struct disasmwin_i { |
| r3755 | r3756 | |
| 77 | 78 | { |
| 78 | 79 | struct memorycombo_item *next; |
| 79 | 80 | char name[256]; |
| 80 | | UINT8 cpunum; |
| 81 | | UINT8 spacenum; |
| 82 | | void * base; |
| 83 | | UINT32 length; |
| 84 | | UINT8 offset_xor; |
| 85 | | UINT8 little_endian; |
| 86 | 81 | UINT8 prefsize; |
| 87 | | running_machine *machine; |
| 82 | running_machine *machine; // machine |
| 83 | const memory_subview_item *subview; // subview |
| 84 | const device_config *device; // CPU device |
| 88 | 85 | } memorycombo_item; |
| 89 | 86 | |
| 90 | 87 | |
| r3755 | r3756 | |
| 115 | 112 | f(p3->win); |
| 116 | 113 | } |
| 117 | 114 | |
| 118 | | //============================================================ |
| 119 | | // memory_determine_combo_items |
| 120 | | //============================================================ |
| 121 | | |
| 122 | | static void memory_determine_combo_items(running_machine *machine) |
| 123 | | { |
| 124 | | memorycombo_item **tail = &memorycombo; |
| 125 | | UINT32 cpunum, spacenum; |
| 126 | | const char *rgntag; |
| 127 | | int itemnum; |
| 128 | | |
| 129 | | // first add all the CPUs' address spaces |
| 130 | | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 131 | | { |
| 132 | | if (machine->cpu[cpunum] != NULL) |
| 133 | | { |
| 134 | | const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); |
| 135 | | |
| 136 | | for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) |
| 137 | | { |
| 138 | | if (cpuinfo->space[spacenum].databytes) |
| 139 | | { |
| 140 | | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 141 | | memset(ci, 0, sizeof(*ci)); |
| 142 | | ci->cpunum = cpunum; |
| 143 | | ci->spacenum = spacenum; |
| 144 | | ci->machine = machine; |
| 145 | | ci->prefsize = MIN(cpuinfo->space[spacenum].databytes, 8); |
| 146 | | |
| 147 | | snprintf(ci->name, ARRAY_LENGTH(ci->name), "CPU #%d \"%s\" (%s) %s memory", cpunum, machine->config->cpu[cpunum].tag, cpu_get_name(machine->cpu[cpunum]), address_space_names[spacenum]); |
| 148 | | |
| 149 | | *tail = ci; |
| 150 | | tail = &ci->next; |
| 151 | | } |
| 152 | | } |
| 153 | | } |
| 154 | | } |
| 155 | | |
| 156 | | // then add all the memory regions |
| 157 | | for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = memory_region_next(machine, rgntag)) |
| 158 | | { |
| 159 | | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 160 | | UINT32 flags = memory_region_flags(machine, rgntag); |
| 161 | | UINT8 little_endian = ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE); |
| 162 | | UINT8 width = 1 << ((flags & ROMREGION_WIDTHMASK) >> 8); |
| 163 | | |
| 164 | | memset(ci, 0, sizeof(*ci)); |
| 165 | | ci->base = memory_region(machine, rgntag); |
| 166 | | ci->length = memory_region_length(machine, rgntag); |
| 167 | | ci->prefsize = MIN(width, 8); |
| 168 | | ci->offset_xor = width - 1; |
| 169 | | ci->little_endian = little_endian; |
| 170 | | ci->machine = machine; |
| 171 | | |
| 172 | | snprintf(ci->name, ARRAY_LENGTH(ci->name), "Region \"%s\"", rgntag); |
| 173 | | |
| 174 | | *tail = ci; |
| 175 | | tail = &ci->next; |
| 176 | | } |
| 177 | | |
| 178 | | // finally add all global array symbols |
| 179 | | for (itemnum = 0; itemnum < 10000; itemnum++) |
| 180 | | { |
| 181 | | UINT32 valsize, valcount; |
| 182 | | const char *name; |
| 183 | | void *base; |
| 184 | | |
| 185 | | /* stop when we run out of items */ |
| 186 | | name = state_save_get_indexed_item(itemnum, &base, &valsize, &valcount); |
| 187 | | if (name == NULL) |
| 188 | | break; |
| 189 | | |
| 190 | | /* if this is a single-entry global, add it */ |
| 191 | | if (valcount > 1 && strstr(name, "/globals/")) |
| 192 | | { |
| 193 | | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 194 | | memset(ci, 0, sizeof(*ci)); |
| 195 | | ci->base = base; |
| 196 | | ci->length = valcount * valsize; |
| 197 | | ci->prefsize = MIN(valsize, 8); |
| 198 | | ci->little_endian = TRUE; |
| 199 | | ci->machine = machine; |
| 200 | | strcpy(ci->name, strrchr(name, '/') + 1); |
| 201 | | *tail = ci; |
| 202 | | tail = &ci->next; |
| 203 | | } |
| 204 | | } |
| 205 | | } |
| 206 | | |
| 207 | | |
| 208 | 115 | static void edit_add_hist(edit *e, const char *text) |
| 209 | 116 | { |
| 210 | 117 | if(e->ch) |
| r3755 | r3756 | |
| 338 | 245 | |
| 339 | 246 | static void debugmain_update_checks(debugmain_i *info) |
| 340 | 247 | { |
| 341 | | int rc = debug_view_get_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN); |
| 342 | | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "raw_opcodes")), rc == DVP_DASM_RIGHTCOL_RAW); |
| 343 | | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "enc_opcodes")), rc == DVP_DASM_RIGHTCOL_ENCRYPTED); |
| 344 | | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "comments")), rc == DVP_DASM_RIGHTCOL_COMMENTS); |
| 248 | int rc = disasm_view_get_right_column(info->disasm); |
| 249 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "raw_opcodes")), rc == DASM_RIGHTCOL_RAW); |
| 250 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "enc_opcodes")), rc == DASM_RIGHTCOL_ENCRYPTED); |
| 251 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "comments")), rc == DASM_RIGHTCOL_COMMENTS); |
| 345 | 252 | } |
| 346 | 253 | |
| 347 | 254 | void debugmain_raw_opcodes_activate(GtkMenuItem *item, gpointer user_data) |
| r3755 | r3756 | |
| 349 | 256 | debugmain_i *info = user_data; |
| 350 | 257 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "raw_opcodes")))) { |
| 351 | 258 | debug_view_begin_update(info->disasm); |
| 352 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_RAW); |
| 259 | disasm_view_set_right_column(info->disasm, DASM_RIGHTCOL_RAW); |
| 353 | 260 | debug_view_end_update(info->disasm); |
| 354 | 261 | } |
| 355 | 262 | } |
| r3755 | r3756 | |
| 359 | 266 | debugmain_i *info = user_data; |
| 360 | 267 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "enc_opcodes")))) { |
| 361 | 268 | debug_view_begin_update(info->disasm); |
| 362 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_ENCRYPTED); |
| 269 | disasm_view_set_right_column(info->disasm, DASM_RIGHTCOL_ENCRYPTED); |
| 363 | 270 | debug_view_end_update(info->disasm); |
| 364 | 271 | } |
| 365 | 272 | } |
| r3755 | r3756 | |
| 369 | 276 | debugmain_i *info = user_data; |
| 370 | 277 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "comments")))) { |
| 371 | 278 | debug_view_begin_update(info->disasm); |
| 372 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_COMMENTS); |
| 279 | disasm_view_set_right_column(info->disasm, DASM_RIGHTCOL_COMMENTS); |
| 373 | 280 | debug_view_end_update(info->disasm); |
| 374 | 281 | } |
| 375 | 282 | } |
| 376 | 283 | |
| 377 | | static void debugmain_set_cpunum(running_machine *machine, int cpunum) |
| 284 | static void debugmain_set_cpu(const device_config *cpu) |
| 378 | 285 | { |
| 379 | | if(cpunum != dmain->cpu) { |
| 286 | if (cpu != dmain->cpu) |
| 287 | { |
| 380 | 288 | char title[256]; |
| 381 | | dmain->cpu = cpunum; |
| 289 | const registers_subview_item *regsubitem; |
| 290 | const disasm_subview_item *dasmsubitem; |
| 291 | |
| 292 | dmain->cpu = cpu; |
| 382 | 293 | |
| 383 | | // first set all the views to the new cpu number |
| 384 | | debug_view_set_property_UINT32(dmain->disasm, DVP_DASM_CPUNUM, cpunum); |
| 385 | | debug_view_set_property_UINT32(dmain->registers, DVP_REGS_CPUNUM, cpunum); |
| 294 | // first set all the views to the new cpu |
| 295 | for (dasmsubitem = disasm_view_get_subview_list(dmain->disasm); dasmsubitem != NULL; dasmsubitem = dasmsubitem->next) |
| 296 | if (dasmsubitem->space->cpu == cpu) |
| 297 | { |
| 298 | disasm_view_set_subview(dmain->disasm, dasmsubitem->index); |
| 299 | break; |
| 300 | } |
| 386 | 301 | |
| 302 | for (regsubitem = registers_view_get_subview_list(dmain->registers); regsubitem != NULL; regsubitem = regsubitem->next) |
| 303 | if (regsubitem->device == cpu) |
| 304 | { |
| 305 | registers_view_set_subview(dmain->registers, regsubitem->index); |
| 306 | break; |
| 307 | } |
| 308 | |
| 387 | 309 | // then update the caption |
| 388 | | sprintf(title, "Debug: %s - CPU #%d \"%s\" (%s)", machine->gamedrv->name, cpunum, machine->config->cpu[cpunum].tag, cpu_get_name(machine->cpu[cpunum])); |
| 310 | snprintf(title, ARRAY_LENGTH(title), "Debug: %s - %s", cpu->machine->gamedrv->name, regsubitem->name); |
| 389 | 311 | gtk_window_set_title(GTK_WINDOW(dmain->win), title); |
| 390 | 312 | debugmain_update_checks(dmain); |
| 391 | 313 | } |
| 392 | 314 | } |
| 393 | 315 | |
| 394 | | |
| 395 | 316 | // The entry point |
| 396 | 317 | |
| 397 | | void osd_wait_for_debugger(running_machine *machine, int firststop) |
| 318 | void osd_wait_for_debugger(const device_config *device, int firststop) |
| 398 | 319 | { |
| 399 | 320 | // create a console window |
| 400 | | if(!dmain) { |
| 321 | if(!dmain) |
| 322 | { |
| 401 | 323 | // GTK init should probably be done earlier |
| 402 | 324 | gtk_init(0, 0); |
| 403 | | debugmain_init(machine); |
| 325 | debugmain_init(device->machine); |
| 404 | 326 | } |
| 405 | 327 | |
| 406 | 328 | // update the views in the console to reflect the current CPU |
| 407 | | debugmain_set_cpunum(machine, cpunum_get_active()); |
| 329 | debugmain_set_cpu(device); |
| 408 | 330 | |
| 409 | 331 | debugwin_show(1); |
| 410 | 332 | gtk_main_iteration(); |
| r3755 | r3756 | |
| 431 | 353 | mame_schedule_exit(dmain->machine); |
| 432 | 354 | } |
| 433 | 355 | |
| 356 | //============================================================ |
| 357 | // debugwin_console_update |
| 358 | //============================================================ |
| 359 | |
| 360 | static void debugwin_console_update(debug_view *view, void *osdprivate) |
| 361 | { |
| 362 | debugmain_i *dbg_main = (debugmain_i *)osdprivate; |
| 363 | debug_view_xy size; |
| 364 | |
| 365 | size = debug_view_get_total_size(dbg_main->console); |
| 366 | if ((dbg_main->console_w->tr != size.y) || (dbg_main->console_w->tc != size.x)) |
| 367 | { |
| 368 | gtk_widget_queue_resize(GTK_WIDGET(dbg_main->console_w)); |
| 369 | } |
| 370 | else |
| 371 | { |
| 372 | gtk_widget_queue_draw(GTK_WIDGET(dbg_main->console_w)); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | //============================================================ |
| 377 | // debugwin_disasm_update |
| 378 | //============================================================ |
| 379 | |
| 380 | static void debugwin_disasm_update(debug_view *view, void *osdprivate) |
| 381 | { |
| 382 | debugmain_i *dbg_main = (debugmain_i *)osdprivate; |
| 383 | debug_view_xy size; |
| 384 | |
| 385 | size = debug_view_get_total_size(dbg_main->disasm); |
| 386 | if ((dbg_main->disasm_w->tr != size.y) || (dbg_main->disasm_w->tc != size.x)) |
| 387 | { |
| 388 | gtk_widget_queue_resize(GTK_WIDGET(dbg_main->disasm_w)); |
| 389 | } |
| 390 | else |
| 391 | { |
| 392 | gtk_widget_queue_draw(GTK_WIDGET(dbg_main->disasm_w)); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | //============================================================ |
| 397 | // debugwin_register_update |
| 398 | //============================================================ |
| 399 | |
| 400 | static void debugwin_register_update(debug_view *view, void *osdprivate) |
| 401 | { |
| 402 | debugmain_i *dbg_main = (debugmain_i *)osdprivate; |
| 403 | debug_view_xy size; |
| 404 | |
| 405 | size = debug_view_get_total_size(dbg_main->registers); |
| 406 | if ((dbg_main->registers_w->tr != size.y) || (dbg_main->registers_w->tc != size.x)) |
| 407 | { |
| 408 | gtk_widget_queue_resize(GTK_WIDGET(dbg_main->registers_w)); |
| 409 | } |
| 410 | else |
| 411 | { |
| 412 | gtk_widget_queue_draw(GTK_WIDGET(dbg_main->registers_w)); |
| 413 | } |
| 414 | } |
| 415 | |
| 434 | 416 | static void debugmain_init(running_machine *machine) |
| 435 | 417 | { |
| 436 | 418 | dmain = malloc(sizeof(*dmain)); |
| 437 | 419 | memset(dmain, 0, sizeof(*dmain)); |
| 438 | 420 | dmain->win = create_debugmain(machine); |
| 439 | | dmain->cpu = -1; |
| 421 | dmain->cpu = NULL; |
| 440 | 422 | dmain->machine = machine; |
| 441 | 423 | |
| 442 | 424 | dmain->console_w = DVIEW(lookup_widget(dmain->win, "console")); |
| 443 | 425 | dmain->disasm_w = DVIEW(lookup_widget(dmain->win, "disasm")); |
| 444 | 426 | dmain->registers_w = DVIEW(lookup_widget(dmain->win, "registers")); |
| 445 | 427 | |
| 446 | | dmain->console = debug_view_alloc(machine, DVT_CONSOLE); |
| 447 | | dmain->disasm = debug_view_alloc(machine, DVT_DISASSEMBLY); |
| 448 | | dmain->registers = debug_view_alloc(machine, DVT_REGISTERS); |
| 428 | dmain->console = debug_view_alloc(machine, DVT_CONSOLE, debugwin_console_update, dmain); |
| 429 | dmain->disasm = debug_view_alloc(machine, DVT_DISASSEMBLY, debugwin_disasm_update, dmain); |
| 430 | dmain->registers = debug_view_alloc(machine, DVT_REGISTERS, debugwin_register_update, dmain); |
| 449 | 431 | |
| 450 | 432 | dview_set_debug_view(dmain->console_w, dmain->console); |
| 451 | 433 | dview_set_debug_view(dmain->disasm_w, dmain->disasm); |
| r3755 | r3756 | |
| 456 | 438 | edit_init(machine, &dmain->ed, lookup_widget(dmain->win, "edit"), 0, 0, debugmain_process_string, &dmain); |
| 457 | 439 | |
| 458 | 440 | debug_view_begin_update(dmain->disasm); |
| 459 | | debug_view_set_property_string(dmain->disasm, DVP_DASM_EXPRESSION, "curpc"); |
| 460 | | debug_view_set_property_UINT32(dmain->disasm, DVP_DASM_TRACK_LIVE, 1); |
| 441 | disasm_view_set_expression(dmain->disasm, "curpc"); |
| 442 | // debug_view_set_property_UINT32(dmain->disasm, DVP_DASM_TRACK_LIVE, 1); |
| 461 | 443 | debug_view_end_update(dmain->disasm); |
| 462 | 444 | |
| 463 | 445 | g_signal_connect(dmain->win, "destroy", G_CALLBACK(debugmain_destroy), dmain); |
| r3755 | r3756 | |
| 470 | 452 | |
| 471 | 453 | static void memorywin_update_checks(memorywin_i *info) |
| 472 | 454 | { |
| 473 | | int bpc = debug_view_get_property_UINT32(info->memory, DVP_MEM_BYTES_PER_CHUNK); |
| 474 | | int rev = debug_view_get_property_UINT32(info->memory, DVP_MEM_REVERSE_VIEW); |
| 455 | int bpc = memory_view_get_bytes_per_chunk(info->memory); |
| 456 | int rev = memory_view_get_reverse(info->memory); |
| 475 | 457 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "chunks_1")), bpc == 1); |
| 476 | 458 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "chunks_2")), bpc == 2); |
| 477 | 459 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "chunks_4")), bpc == 4); |
| 478 | 460 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "reverse")), rev); |
| 479 | 461 | } |
| 480 | 462 | |
| 481 | | static void memorywin_update_selection(memorywin_i *info, memorycombo_item *ci) |
| 482 | | { |
| 483 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_CPUNUM, ci->cpunum); |
| 484 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_SPACENUM, ci->spacenum); |
| 485 | | debug_view_set_property_ptr(info->memory, DVP_MEM_RAW_BASE, ci->base); |
| 486 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_RAW_LENGTH, ci->length); |
| 487 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_RAW_OFFSET_XOR, ci->offset_xor); |
| 488 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_RAW_LITTLE_ENDIAN, ci->little_endian); |
| 489 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_BYTES_PER_CHUNK, ci->prefsize); |
| 490 | | memorywin_update_checks(info); |
| 491 | | gtk_window_set_title(GTK_WINDOW(info->win), ci->name); |
| 492 | | } |
| 493 | | |
| 494 | 463 | static void memorywin_zone_changed(GtkComboBox *zone_w, memorywin_i *mem) |
| 495 | 464 | { |
| 496 | 465 | int sel = gtk_combo_box_get_active(mem->zone_w); |
| 497 | | int i; |
| 498 | | memorycombo_item *ci; |
| 499 | | for(i=0, ci=memorycombo; i != sel; i++) |
| 500 | | ci = ci->next; |
| 501 | | memorywin_update_selection(mem, ci); |
| 466 | char title[256]; |
| 467 | const memory_subview_item *subview; |
| 468 | |
| 469 | // update the subview |
| 470 | memory_view_set_subview(mem->memory, sel); |
| 471 | |
| 472 | // change the checkmarks in the menu |
| 473 | memorywin_update_checks(mem); |
| 474 | |
| 475 | // update the window title |
| 476 | subview = memory_view_get_current_subview(mem->memory); |
| 477 | sprintf(title, "Memory: %s", subview->name); |
| 478 | gtk_window_set_title(GTK_WINDOW(mem->win), title); |
| 479 | |
| 502 | 480 | } |
| 503 | 481 | |
| 504 | 482 | static void memorywin_process_string(running_machine *machine, const char *str, void *memp) |
| 505 | 483 | { |
| 506 | 484 | memorywin_i *mem = memp; |
| 507 | | debug_view_set_property_string(mem->memory, DVP_MEM_EXPRESSION, str); |
| 485 | memory_view_set_expression(mem->memory, str); |
| 508 | 486 | } |
| 509 | 487 | |
| 510 | 488 | static void memorywin_destroy(GtkObject *obj, gpointer user_data) |
| r3755 | r3756 | |
| 521 | 499 | free(mem); |
| 522 | 500 | } |
| 523 | 501 | |
| 502 | static void memorywin_view_update(debug_view *view, void *osdprivate) |
| 503 | { |
| 504 | memorywin_i *mem = (memorywin_i *)osdprivate; |
| 505 | debug_view_xy size; |
| 506 | |
| 507 | size = debug_view_get_total_size(mem->memory); |
| 508 | if ((mem->memory_w->tr != size.y) || (mem->memory_w->tc != size.x)) |
| 509 | { |
| 510 | gtk_widget_queue_resize(GTK_WIDGET(mem->memory_w)); |
| 511 | } |
| 512 | else |
| 513 | { |
| 514 | gtk_widget_queue_draw(GTK_WIDGET(mem->memory_w)); |
| 515 | } |
| 516 | } |
| 517 | |
| 524 | 518 | static void memorywin_new(running_machine *machine) |
| 525 | 519 | { |
| 526 | 520 | memorywin_i *mem; |
| 527 | | int item, cursel, curcpu = cpunum_get_active(); |
| 528 | | memorycombo_item *ci, *selci = NULL; |
| 521 | int item, cursel; |
| 522 | const device_config *curcpu = debug_cpu_get_visible_cpu(machine); |
| 523 | const memory_subview_item *subview; |
| 529 | 524 | |
| 530 | 525 | mem = malloc(sizeof(*mem)); |
| 531 | 526 | memset(mem, 0, sizeof(*mem)); |
| r3755 | r3756 | |
| 537 | 532 | mem->memory_w = DVIEW(lookup_widget(mem->win, "memoryview")); |
| 538 | 533 | mem->zone_w = GTK_COMBO_BOX(lookup_widget(mem->win, "zone")); |
| 539 | 534 | |
| 540 | | mem->memory = debug_view_alloc(machine, DVT_MEMORY); |
| 535 | mem->memory = debug_view_alloc(machine, DVT_MEMORY, memorywin_view_update, mem); |
| 541 | 536 | |
| 542 | 537 | dview_set_debug_view(mem->memory_w, mem->memory); |
| 543 | 538 | |
| 544 | 539 | edit_init(machine, &mem->ed, lookup_widget(mem->win, "edit"), "0", 1, memorywin_process_string, mem); |
| 545 | 540 | |
| 546 | 541 | debug_view_begin_update(mem->memory); |
| 547 | | debug_view_set_property_string(mem->memory, DVP_MEM_EXPRESSION, "0"); |
| 548 | | debug_view_set_property_UINT32(mem->memory, DVP_MEM_TRACK_LIVE, 1); |
| 542 | memory_view_set_expression(mem->memory, "0"); |
| 543 | // debug_view_set_property_UINT32(mem->memory, DVP_MEM_TRACK_LIVE, 1); |
| 549 | 544 | debug_view_end_update(mem->memory); |
| 550 | 545 | |
| 551 | 546 | |
| 552 | 547 | // populate the combobox |
| 553 | 548 | if (!memorycombo) |
| 554 | | memory_determine_combo_items(machine); |
| 555 | | item = 0; |
| 556 | | cursel = 0; |
| 557 | | for (ci = memorycombo; ci; ci = ci->next) |
| 558 | 549 | { |
| 559 | | gtk_combo_box_append_text(mem->zone_w, ci->name); |
| 560 | | if (ci->base == NULL && ci->cpunum == curcpu && ci->spacenum == ADDRESS_SPACE_PROGRAM) |
| 550 | memorycombo_item **tail = &memorycombo; |
| 551 | |
| 552 | cursel = item = 0; |
| 553 | |
| 554 | for (subview = memory_view_get_subview_list(mem->memory); subview != NULL; subview = subview->next) |
| 561 | 555 | { |
| 562 | | cursel = item; |
| 563 | | selci = ci; |
| 556 | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 557 | memset(ci, 0, sizeof(*ci)); |
| 558 | ci->machine = machine; |
| 559 | ci->prefsize = 4; |
| 560 | ci->subview = subview; |
| 561 | ci->device = curcpu; |
| 562 | |
| 563 | strncpy(ci->name, subview->name, sizeof(ci->name)); |
| 564 | |
| 565 | *tail = ci; |
| 566 | tail = &ci->next; |
| 567 | |
| 568 | if (cursel == 0 && subview->space != NULL && subview->space->cpu == curcpu) |
| 569 | cursel = item; |
| 570 | |
| 571 | item++; |
| 564 | 572 | } |
| 565 | | item++; |
| 566 | 573 | |
| 574 | memory_view_set_subview(mem->memory, cursel); |
| 575 | gtk_combo_box_set_active(mem->zone_w, cursel); |
| 567 | 576 | } |
| 568 | | gtk_combo_box_set_active(mem->zone_w, cursel); |
| 569 | | memorywin_update_selection(mem, selci); |
| 570 | 577 | |
| 571 | 578 | g_signal_connect(mem->zone_w, "changed", G_CALLBACK(memorywin_zone_changed), mem); |
| 572 | 579 | g_signal_connect(lookup_widget(mem->win, "chunks_1"), "activate", G_CALLBACK(on_chunks_1_activate), mem); |
| r3755 | r3756 | |
| 582 | 589 | |
| 583 | 590 | static void disasmwin_update_checks(disasmwin_i *info) |
| 584 | 591 | { |
| 585 | | int rc = debug_view_get_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN); |
| 586 | | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "raw_opcodes")), rc == DVP_DASM_RIGHTCOL_RAW); |
| 587 | | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "enc_opcodes")), rc == DVP_DASM_RIGHTCOL_ENCRYPTED); |
| 588 | | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "comments")), rc == DVP_DASM_RIGHTCOL_COMMENTS); |
| 592 | int rc = disasm_view_get_right_column(info->disasm); |
| 593 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "raw_opcodes")), rc == DASM_RIGHTCOL_RAW); |
| 594 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "enc_opcodes")), rc == DASM_RIGHTCOL_ENCRYPTED); |
| 595 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "comments")), rc == DASM_RIGHTCOL_COMMENTS); |
| 589 | 596 | } |
| 590 | 597 | |
| 591 | | static void disasmwin_update_selection(disasmwin_i *info, int cpunum) |
| 598 | static void disasmwin_cpu_changed(GtkComboBox *cpu_w, disasmwin_i *dis) |
| 592 | 599 | { |
| 593 | | char title[4096]; |
| 594 | | debug_view_begin_update(info->disasm); |
| 595 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_CPUNUM, (cpunum == -1) ? 0 : cpunum); |
| 596 | | debug_view_end_update(info->disasm); |
| 600 | char title[256]; |
| 601 | const disasm_subview_item *subview; |
| 597 | 602 | |
| 598 | | disasmwin_update_checks(info); |
| 603 | disasm_view_set_subview(dis->disasm, gtk_combo_box_get_active(dis->cpu_w)); |
| 599 | 604 | |
| 600 | | sprintf(title, "Disassembly: CPU #%d \"%s\" (%s)", cpunum, info->machine->config->cpu[cpunum].tag, cpu_get_name(info->machine->cpu[cpunum])); |
| 601 | | gtk_window_set_title(GTK_WINDOW(info->win), title); |
| 602 | | } |
| 605 | disasmwin_update_checks(dis); |
| 603 | 606 | |
| 604 | | static void disasmwin_cpu_changed(GtkComboBox *cpu_w, disasmwin_i *dis) |
| 605 | | { |
| 606 | | int sel = gtk_combo_box_get_active(dis->cpu_w); |
| 607 | | int cpunum, item; |
| 608 | | item = 0; |
| 609 | | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 610 | | { |
| 611 | | if (dis->machine->cpu[cpunum] != NULL) |
| 612 | | { |
| 613 | | const cpu_debug_data *cpuinfo = cpu_get_debug_data(dis->machine->cpu[cpunum]); |
| 614 | | |
| 615 | | if (cpuinfo->space[ADDRESS_SPACE_PROGRAM].databytes) |
| 616 | | { |
| 617 | | if(item == sel) { |
| 618 | | disasmwin_update_selection(dis, cpunum); |
| 619 | | return; |
| 620 | | } |
| 621 | | item++; |
| 622 | | } |
| 623 | | } |
| 624 | | } |
| 607 | subview = disasm_view_get_current_subview(dis->disasm); |
| 608 | sprintf(title, "Disassembly: %s", subview->name); |
| 609 | gtk_window_set_title(GTK_WINDOW(dis->win), title); |
| 625 | 610 | } |
| 626 | 611 | |
| 627 | 612 | void disasmwin_raw_opcodes_activate(GtkMenuItem *item, gpointer user_data) |
| r3755 | r3756 | |
| 629 | 614 | disasmwin_i *info = user_data; |
| 630 | 615 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "raw_opcodes")))) { |
| 631 | 616 | debug_view_begin_update(info->disasm); |
| 632 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_RAW); |
| 617 | disasm_view_set_right_column(info->disasm, DASM_RIGHTCOL_RAW); |
| 633 | 618 | debug_view_end_update(info->disasm); |
| 634 | 619 | } |
| 635 | 620 | } |
| r3755 | r3756 | |
| 639 | 624 | disasmwin_i *info = user_data; |
| 640 | 625 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "enc_opcodes")))) { |
| 641 | 626 | debug_view_begin_update(info->disasm); |
| 642 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_ENCRYPTED); |
| 627 | disasm_view_set_right_column(info->disasm, DASM_RIGHTCOL_ENCRYPTED); |
| 643 | 628 | debug_view_end_update(info->disasm); |
| 644 | 629 | } |
| 645 | 630 | } |
| r3755 | r3756 | |
| 649 | 634 | disasmwin_i *info = user_data; |
| 650 | 635 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "comments")))) { |
| 651 | 636 | debug_view_begin_update(info->disasm); |
| 652 | | debug_view_set_property_UINT32(info->disasm, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_COMMENTS); |
| 637 | disasm_view_set_right_column(info->disasm, DASM_RIGHTCOL_COMMENTS); |
| 653 | 638 | debug_view_end_update(info->disasm); |
| 654 | 639 | } |
| 655 | 640 | } |
| r3755 | r3756 | |
| 657 | 642 | static void disasmwin_process_string(running_machine *machine, const char *str, void *disp) |
| 658 | 643 | { |
| 659 | 644 | disasmwin_i *dis = disp; |
| 660 | | debug_view_set_property_string(dis->disasm, DVP_DASM_EXPRESSION, str); |
| 645 | disasm_view_set_expression(dis->disasm, str); |
| 661 | 646 | } |
| 662 | 647 | |
| 663 | 648 | static void disasmwin_destroy(GtkObject *obj, gpointer user_data) |
| r3755 | r3756 | |
| 674 | 659 | free(dis); |
| 675 | 660 | } |
| 676 | 661 | |
| 662 | static void disasmwin_view_update(debug_view *view, void *osdprivate) |
| 663 | { |
| 664 | disasmwin_i *dis = (disasmwin_i *)osdprivate; |
| 665 | debug_view_xy size; |
| 666 | |
| 667 | size = debug_view_get_total_size(dis->disasm); |
| 668 | if ((dis->disasm_w->tr != size.y) || (dis->disasm_w->tc != size.x)) |
| 669 | { |
| 670 | gtk_widget_queue_resize(GTK_WIDGET(dis->disasm_w)); |
| 671 | } |
| 672 | else |
| 673 | { |
| 674 | gtk_widget_queue_draw(GTK_WIDGET(dis->disasm_w)); |
| 675 | } |
| 676 | } |
| 677 | |
| 677 | 678 | static void disasmwin_new(running_machine *machine) |
| 678 | 679 | { |
| 679 | 680 | disasmwin_i *dis; |
| 680 | | int cpunum, curcpu = cpunum_get_active(); |
| 681 | | int item, citem; |
| 681 | int item, cursel; |
| 682 | const device_config *curcpu = debug_cpu_get_visible_cpu(machine); |
| 683 | const disasm_subview_item *subview; |
| 684 | char title[256]; |
| 682 | 685 | |
| 683 | 686 | dis = malloc(sizeof(*dis)); |
| 684 | 687 | memset(dis, 0, sizeof(*dis)); |
| r3755 | r3756 | |
| 690 | 693 | dis->disasm_w = DVIEW(lookup_widget(dis->win, "disasmview")); |
| 691 | 694 | dis->cpu_w = GTK_COMBO_BOX(lookup_widget(dis->win, "cpu")); |
| 692 | 695 | |
| 693 | | dis->disasm = debug_view_alloc(machine, DVT_DISASSEMBLY); |
| 696 | dis->disasm = debug_view_alloc(machine, DVT_DISASSEMBLY, disasmwin_view_update, dmain); |
| 694 | 697 | |
| 695 | 698 | dview_set_debug_view(dis->disasm_w, dis->disasm); |
| 696 | 699 | |
| 697 | 700 | edit_init(machine, &dis->ed, lookup_widget(dis->win, "edit"), "curpc", 1, disasmwin_process_string, dis); |
| 698 | 701 | |
| 699 | 702 | debug_view_begin_update(dis->disasm); |
| 700 | | debug_view_set_property_string(dis->disasm, DVP_DASM_EXPRESSION, "curpc"); |
| 701 | | debug_view_set_property_UINT32(dis->disasm, DVP_DASM_TRACK_LIVE, 1); |
| 703 | disasm_view_set_expression(dis->disasm, "curpc"); |
| 704 | // debug_view_set_property_UINT32(dis->disasm, DVP_DASM_TRACK_LIVE, 1); |
| 702 | 705 | debug_view_end_update(dis->disasm); |
| 703 | 706 | |
| 704 | 707 | // populate the combobox |
| 705 | | item = 0; |
| 706 | | citem = -1; |
| 707 | | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 708 | cursel = item = 0; |
| 709 | for (subview = disasm_view_get_subview_list(dis->disasm); subview != NULL; subview = subview->next) |
| 708 | 710 | { |
| 709 | | if (machine->cpu[cpunum] != NULL) |
| 710 | | { |
| 711 | | const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); |
| 712 | | if (cpuinfo->space[ADDRESS_SPACE_PROGRAM].databytes) |
| 713 | | { |
| 714 | | char name[100]; |
| 715 | | sprintf(name, "CPU #%d \"%s\" (%s)", cpunum, machine->config->cpu[cpunum].tag, cpu_get_name(machine->cpu[cpunum])); |
| 716 | | gtk_combo_box_append_text(dis->cpu_w, name); |
| 717 | | if(cpunum == curcpu) |
| 718 | | citem = item; |
| 719 | | item++; |
| 720 | | } |
| 721 | | } |
| 722 | | } |
| 711 | gtk_combo_box_append_text(dis->cpu_w, subview->name); |
| 712 | if (cursel == 0 && subview->space->cpu == curcpu) |
| 713 | cursel = item; |
| 723 | 714 | |
| 724 | | if(citem == -1) { |
| 725 | | citem = 0; |
| 726 | | curcpu = 0; |
| 715 | item++; |
| 727 | 716 | } |
| 728 | 717 | |
| 729 | | gtk_combo_box_set_active(dis->cpu_w, citem); |
| 730 | | disasmwin_update_selection(dis, curcpu); |
| 718 | gtk_combo_box_set_active(dis->cpu_w, cursel); |
| 719 | disasm_view_set_subview(dis->disasm, cursel); |
| 731 | 720 | |
| 721 | subview = disasm_view_get_current_subview(dis->disasm); |
| 722 | sprintf(title, "Disassembly: %s", subview->name); |
| 723 | gtk_window_set_title(GTK_WINDOW(dis->win), title); |
| 724 | |
| 732 | 725 | g_signal_connect(dis->cpu_w, "changed", G_CALLBACK(disasmwin_cpu_changed), dis); |
| 733 | 726 | g_signal_connect(lookup_widget(dis->win, "raw_opcodes"), "activate", G_CALLBACK(disasmwin_raw_opcodes_activate), dis); |
| 734 | 727 | g_signal_connect(lookup_widget(dis->win, "enc_opcodes"), "activate", G_CALLBACK(disasmwin_enc_opcodes_activate), dis); |
| r3755 | r3756 | |
| 752 | 745 | free(log); |
| 753 | 746 | } |
| 754 | 747 | |
| 748 | static void logwin_view_update(debug_view *view, void *osdprivate) |
| 749 | { |
| 750 | logwin_i *log = (logwin_i *)osdprivate; |
| 751 | debug_view_xy size; |
| 752 | |
| 753 | size = debug_view_get_total_size(log->log); |
| 754 | if ((log->log_w->tr != size.y) || (log->log_w->tc != size.x)) |
| 755 | { |
| 756 | gtk_widget_queue_resize(GTK_WIDGET(log->log_w)); |
| 757 | } |
| 758 | else |
| 759 | { |
| 760 | gtk_widget_queue_draw(GTK_WIDGET(log->log_w)); |
| 761 | } |
| 762 | } |
| 763 | |
| 755 | 764 | static void logwin_new(running_machine *machine) |
| 756 | 765 | { |
| 757 | 766 | logwin_i *log; |
| r3755 | r3756 | |
| 765 | 774 | |
| 766 | 775 | log->log_w = DVIEW(lookup_widget(log->win, "logview")); |
| 767 | 776 | |
| 768 | | log->log = debug_view_alloc(machine, DVT_LOG); |
| 777 | log->log = debug_view_alloc(machine, DVT_LOG, logwin_view_update, dmain); |
| 769 | 778 | |
| 779 | dview_set_debug_view(log->log_w, log->log); |
| 780 | |
| 770 | 781 | dview_this_one_is_stupidly_autoscrolling(log->log_w); |
| 771 | | dview_set_debug_view(log->log_w, log->log); |
| 772 | 782 | g_signal_connect(log->win, "destroy", G_CALLBACK(logwin_destroy), log); |
| 773 | 783 | |
| 774 | 784 | gtk_widget_show_all(log->win); |
| r3755 | r3756 | |
| 851 | 861 | memorywin_i *info = user_data; |
| 852 | 862 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "chunks_1")))) { |
| 853 | 863 | debug_view_begin_update(info->memory); |
| 854 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_BYTES_PER_CHUNK, 1); |
| 864 | memory_view_set_bytes_per_chunk(info->memory, 1); |
| 855 | 865 | debug_view_end_update(info->memory); |
| 856 | 866 | } |
| 857 | 867 | } |
| r3755 | r3756 | |
| 861 | 871 | memorywin_i *info = user_data; |
| 862 | 872 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "chunks_2")))) { |
| 863 | 873 | debug_view_begin_update(info->memory); |
| 864 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_BYTES_PER_CHUNK, 2); |
| 874 | memory_view_set_bytes_per_chunk(info->memory, 2); |
| 865 | 875 | debug_view_end_update(info->memory); |
| 866 | 876 | } |
| 867 | 877 | } |
| r3755 | r3756 | |
| 871 | 881 | memorywin_i *info = user_data; |
| 872 | 882 | if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "chunks_4")))) { |
| 873 | 883 | debug_view_begin_update(info->memory); |
| 874 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_BYTES_PER_CHUNK, 4); |
| 884 | memory_view_set_bytes_per_chunk(info->memory, 4); |
| 875 | 885 | debug_view_end_update(info->memory); |
| 876 | 886 | } |
| 877 | 887 | } |
| r3755 | r3756 | |
| 880 | 890 | { |
| 881 | 891 | memorywin_i *info = user_data; |
| 882 | 892 | debug_view_begin_update(info->memory); |
| 883 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_REVERSE_VIEW, |
| 884 | | gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "reverse")))); |
| 893 | memory_view_set_reverse(info->memory, gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "reverse")))); |
| 894 | |
| 885 | 895 | debug_view_end_update(info->memory); |
| 886 | 896 | } |
| 887 | 897 | |
| r3755 | r3756 | |
| 889 | 899 | { |
| 890 | 900 | memorywin_i *info = user_data; |
| 891 | 901 | debug_view_begin_update(info->memory); |
| 892 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_WIDTH, |
| 893 | | debug_view_get_property_UINT32(info->memory, DVP_MEM_WIDTH) + 1); |
| 902 | memory_view_set_chunks_per_row(info->memory, memory_view_get_chunks_per_row(info->memory) + 1); |
| 894 | 903 | debug_view_end_update(info->memory); |
| 895 | 904 | } |
| 896 | 905 | |
| r3755 | r3756 | |
| 898 | 907 | { |
| 899 | 908 | memorywin_i *info = user_data; |
| 900 | 909 | debug_view_begin_update(info->memory); |
| 901 | | debug_view_set_property_UINT32(info->memory, DVP_MEM_WIDTH, |
| 902 | | debug_view_get_property_UINT32(info->memory, DVP_MEM_WIDTH) - 1); |
| 910 | memory_view_set_chunks_per_row(info->memory, memory_view_get_chunks_per_row(info->memory) - 1); |
| 903 | 911 | debug_view_end_update(info->memory); |
| 904 | 912 | } |
| 905 | 913 | |
src/osd/sdl/debugosx.c
| r3755 | r3756 | |
| 10 | 10 | // NOTES: |
| 11 | 11 | // |
| 12 | 12 | // debug_window_proc is called for events on the debugger windows: Must install carbon handler on it |
| 13 | | // debug_view_proc is called for events on the debugger controls: Must install carbon handler on it |
| 13 | // debugwin_view_proc is called for events on the debugger controls: Must install carbon handler on it |
| 14 | 14 | // |
| 15 | 15 | |
| 16 | 16 | |
| r3755 | r3756 | |
| 198 | 198 | }; |
| 199 | 199 | |
| 200 | 200 | |
| 201 | | typedef struct _memorycombo_item memorycombo_item; |
| 202 | | struct _memorycombo_item |
| 203 | | { |
| 204 | | memorycombo_item * next; |
| 205 | | char name[256]; |
| 206 | | UINT8 cpunum; |
| 207 | | UINT8 spacenum; |
| 208 | | void * base; |
| 209 | | UINT32 length; |
| 210 | | UINT8 offset_xor; |
| 211 | | UINT8 little_endian; |
| 212 | | UINT8 prefsize; |
| 213 | | }; |
| 214 | | |
| 215 | | |
| 216 | 201 | //============================================================ |
| 217 | 202 | // GLOBAL VARIABLES |
| 218 | 203 | //============================================================ |
| r3755 | r3756 | |
| 226 | 211 | static debugwin_info *window_list; |
| 227 | 212 | static debugwin_info *main_console = NULL; |
| 228 | 213 | |
| 229 | | static memorycombo_item *memorycombo; |
| 230 | | |
| 231 | 214 | static UINT8 debugger_active_countdown; |
| 232 | 215 | static UINT8 waiting_for_debugger; |
| 233 | 216 | |
| r3755 | r3756 | |
| 253 | 236 | static void debug_window_free(debugwin_info *info); |
| 254 | 237 | static OSStatus debug_window_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData); |
| 255 | 238 | |
| 256 | | static void debug_view_draw_contents(debugview_info *view, CGContextRef dc); |
| 239 | static void debugwin_view_draw_contents(debugview_info *view, CGContextRef dc); |
| 257 | 240 | static debugview_info *debug_view_find(debug_view *view); |
| 258 | | static OSStatus debug_view_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData); |
| 259 | | static void debug_view_update(debug_view *view); |
| 260 | | static int debug_view_create(debugwin_info *info, int which, int type); |
| 261 | | static void debug_view_process_scroll(HIViewRef inView, ControlPartCode partCode); |
| 241 | static OSStatus debugwin_view_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData); |
| 242 | static void debugwin_view_update(debug_view *view, void *osdprivate); |
| 243 | static int debugwin_view_create(debugwin_info *info, int which, int type); |
| 244 | static void debugwin_view_process_scroll(HIViewRef inView, ControlPartCode partCode); |
| 262 | 245 | |
| 263 | | static OSStatus debug_edit_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData); |
| 246 | static OSStatus debugwin_edit_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData); |
| 264 | 247 | |
| 265 | 248 | #if 0 |
| 266 | 249 | static void generic_create_window(int type); |
| r3755 | r3756 | |
| 273 | 256 | static void memory_update_checkmarks(debugwin_info *info); |
| 274 | 257 | static int memory_handle_command(debugwin_info *info, EventRef inEvent); |
| 275 | 258 | static int memory_handle_key(debugwin_info *info, EventRef inEvent); |
| 259 | static void memory_update_caption(debugwin_info *info); |
| 276 | 260 | |
| 277 | 261 | static void disasm_create_window(running_machine *machine); |
| 278 | 262 | static void disasm_recompute_children(debugwin_info *info); |
| r3755 | r3756 | |
| 285 | 269 | static void console_create_window(running_machine *machine); |
| 286 | 270 | static void console_recompute_children(debugwin_info *info); |
| 287 | 271 | static void console_process_string(debugwin_info *info, const char *string); |
| 288 | | static void console_set_cpunum(running_machine *machine, int cpunum); |
| 272 | static void console_set_cpu(const device_config *device); |
| 289 | 273 | |
| 290 | 274 | static MenuRef create_standard_menubar(void); |
| 291 | 275 | static int global_handle_command(debugwin_info *info, EventRef inEvent); |
| r3755 | r3756 | |
| 367 | 351 | // osd_wait_for_debugger |
| 368 | 352 | //============================================================ |
| 369 | 353 | |
| 370 | | void osd_wait_for_debugger(running_machine *machine, int firststop) |
| 354 | void osd_wait_for_debugger(const device_config *device, int firststop) |
| 371 | 355 | { |
| 372 | 356 | EventRef message; |
| 373 | 357 | EventTargetRef target = GetEventDispatcherTarget(); |
| 374 | 358 | |
| 375 | | osx_init_debugger(machine); |
| 359 | osx_init_debugger(device->machine); |
| 376 | 360 | |
| 377 | 361 | // create a console window |
| 378 | 362 | if (!main_console) |
| 379 | | console_create_window(machine); |
| 363 | console_create_window(device->machine); |
| 380 | 364 | |
| 381 | 365 | // update the views in the console to reflect the current CPU |
| 382 | 366 | if (main_console) |
| 383 | | console_set_cpunum(machine, cpunum_get_active()); |
| 367 | console_set_cpu(device); |
| 384 | 368 | |
| 385 | 369 | // make sure the debug windows are visible |
| 386 | 370 | waiting_for_debugger = TRUE; |
| r3755 | r3756 | |
| 503 | 487 | focuswnd = NULL; |
| 504 | 488 | } |
| 505 | 489 | |
| 506 | | debugger_break(machine); |
| 507 | | debug_console_printf("User-initiated break\n"); |
| 490 | debug_cpu_halt_on_next_instruction(debug_cpu_get_visible_cpu(machine), "User-initiated break\n"); |
| 508 | 491 | |
| 509 | 492 | // if we were focused on some window's edit box, reset it to default |
| 510 | 493 | for (info = window_list; info; info = info->next) |
| r3755 | r3756 | |
| 853 | 836 | { |
| 854 | 837 | if (info->view[curview].wnd == focusChild ) |
| 855 | 838 | { |
| 856 | | return debug_view_proc( inHandler, inEvent, &info->view[curview] ); |
| 839 | return debugwin_view_proc( inHandler, inEvent, &info->view[curview] ); |
| 857 | 840 | } |
| 858 | 841 | } |
| 859 | 842 | } |
| r3755 | r3756 | |
| 868 | 851 | |
| 869 | 852 | |
| 870 | 853 | //============================================================ |
| 871 | | // debug_view_create |
| 854 | // debugwin_view_create |
| 872 | 855 | //============================================================ |
| 873 | 856 | |
| 874 | | static int debug_view_create(debugwin_info *info, int which, int type) |
| 857 | static int debugwin_view_create(debugwin_info *info, int which, int type) |
| 875 | 858 | { |
| 876 | 859 | Rect bounds; |
| 877 | 860 | debugview_info *view = &info->view[which]; |
| 878 | | void *callback = (void *)debug_view_update; |
| 879 | 861 | |
| 880 | 862 | // set the owner |
| 881 | 863 | view->owner = info; |
| r3755 | r3756 | |
| 887 | 869 | if ( CreateUserPaneControl(info->wnd, &bounds, 0, &view->wnd) != noErr ) |
| 888 | 870 | goto cleanup; |
| 889 | 871 | |
| 890 | | if ( InstallEventHandler( GetControlEventTarget( view->wnd ), NewEventHandlerUPP(debug_view_proc), sizeof( debug_view_events ) / sizeof( EventTypeSpec ), debug_view_events, view, NULL ) != noErr ) |
| 872 | if ( InstallEventHandler( GetControlEventTarget( view->wnd ), NewEventHandlerUPP(debugwin_view_proc), sizeof( debug_view_events ) / sizeof( EventTypeSpec ), debug_view_events, view, NULL ) != noErr ) |
| 891 | 873 | goto cleanup; |
| 892 | 874 | |
| 893 | 875 | // create the scroll bars |
| 894 | 876 | bounds.top = bounds.bottom - hscroll_height; |
| 895 | 877 | |
| 896 | | if ( CreateScrollBarControl(info->wnd, &bounds, 0, 0, 0, 0, TRUE, NewControlActionUPP(debug_view_process_scroll), &view->hscroll ) != noErr ) |
| 878 | if ( CreateScrollBarControl(info->wnd, &bounds, 0, 0, 0, 0, TRUE, NewControlActionUPP(debugwin_view_process_scroll), &view->hscroll ) != noErr ) |
| 897 | 879 | goto cleanup; |
| 898 | 880 | |
| 899 | 881 | SetControlProperty(view->hscroll, 'MAME', 'info', sizeof( view ), &view ); |
| r3755 | r3756 | |
| 901 | 883 | bounds.top = 0; |
| 902 | 884 | bounds.left = bounds.right - vscroll_width; |
| 903 | 885 | |
| 904 | | if ( CreateScrollBarControl(info->wnd, &bounds, 0, 0, 0, 0, TRUE, NewControlActionUPP(debug_view_process_scroll), &view->vscroll ) != noErr ) |
| 886 | if ( CreateScrollBarControl(info->wnd, &bounds, 0, 0, 0, 0, TRUE, NewControlActionUPP(debugwin_view_process_scroll), &view->vscroll ) != noErr ) |
| 905 | 887 | goto cleanup; |
| 906 | 888 | |
| 907 | 889 | SetControlProperty(view->vscroll, 'MAME', 'info', sizeof( view ), &view ); |
| 908 | 890 | |
| 909 | 891 | // create the debug view |
| 910 | | view->view = debug_view_alloc(info->machine, type); |
| 892 | view->view = debug_view_alloc(info->machine, type, debugwin_view_update, view); |
| 911 | 893 | if (!view->view) |
| 912 | 894 | goto cleanup; |
| 913 | 895 | |
| 914 | | // set the update handler |
| 915 | | debug_view_set_property_fct(view->view, DVP_UPDATE_CALLBACK, callback); |
| 916 | 896 | return 1; |
| 917 | 897 | |
| 918 | 898 | cleanup: |
| r3755 | r3756 | |
| 930 | 910 | |
| 931 | 911 | |
| 932 | 912 | //============================================================ |
| 933 | | // debug_view_set_bounds |
| 913 | // debugwin_view_set_bounds |
| 934 | 914 | //============================================================ |
| 935 | 915 | |
| 936 | | static void debug_view_set_bounds(debugview_info *info, const Rect *newbounds) |
| 916 | static void debugwin_view_set_bounds(debugview_info *info, const Rect *newbounds) |
| 937 | 917 | { |
| 938 | 918 | // account for the edges and set the bounds |
| 939 | 919 | if (info->wnd) |
| r3755 | r3756 | |
| 949 | 929 | } |
| 950 | 930 | |
| 951 | 931 | // update |
| 952 | | debug_view_update(info->view); |
| 932 | debugwin_view_update(info->view, info); |
| 953 | 933 | } |
| 954 | 934 | |
| 955 | 935 | |
| 956 | 936 | |
| 957 | 937 | //============================================================ |
| 958 | | // debug_view_draw_contents |
| 938 | // debugwin_view_draw_contents |
| 959 | 939 | //============================================================ |
| 960 | 940 | |
| 961 | | static void debug_view_draw_contents(debugview_info *view, CGContextRef dc) |
| 941 | static void debugwin_view_draw_contents(debugview_info *view, CGContextRef dc) |
| 962 | 942 | { |
| 963 | | debug_view_char *viewdata; |
| 964 | | UINT32 visrows, viscols; |
| 943 | const debug_view_char *viewdata = debug_view_get_chars(view->view); |
| 944 | debug_view_xy visarea = debug_view_get_visible_size(view->view); |
| 965 | 945 | UINT32 col, row; |
| 966 | 946 | HIRect client; |
| 967 | 947 | |
| r3755 | r3756 | |
| 970 | 950 | // get the client rect |
| 971 | 951 | HIViewGetBounds(view->wnd,&client); |
| 972 | 952 | |
| 973 | | // first get the visible size from the view and a pointer to the data |
| 974 | | visrows = debug_view_get_property_UINT32(view->view, DVP_VISIBLE_ROWS); |
| 975 | | viscols = debug_view_get_property_UINT32(view->view, DVP_VISIBLE_COLS); |
| 976 | | viewdata = debug_view_get_property_ptr(view->view, DVP_VIEW_DATA); |
| 977 | | |
| 978 | 953 | if (!viewdata) return; |
| 979 | 954 | |
| 980 | 955 | // set the font |
| r3755 | r3756 | |
| 991 | 966 | } |
| 992 | 967 | |
| 993 | 968 | // iterate over rows and columns |
| 994 | | for (row = 0; row < visrows; row++) |
| 969 | for (row = 0; row < visarea.y; row++) |
| 995 | 970 | { |
| 996 | 971 | int iter; |
| 997 | 972 | |
| r3755 | r3756 | |
| 1011 | 986 | bounds.bottom = bounds.top + debug_font_height; |
| 1012 | 987 | |
| 1013 | 988 | // iterate over columns |
| 1014 | | for (col = 0; col < viscols; col++) |
| 989 | for (col = 0; col < visarea.x; col++) |
| 1015 | 990 | { |
| 1016 | 991 | // if the attribute changed, adjust the colors |
| 1017 | 992 | if (viewdata[col].attrib != last_attrib) |
| r3755 | r3756 | |
| 1105 | 1080 | } |
| 1106 | 1081 | |
| 1107 | 1082 | // advance viewdata |
| 1108 | | viewdata += viscols; |
| 1083 | viewdata += visarea.x; |
| 1109 | 1084 | } |
| 1110 | 1085 | |
| 1111 | 1086 | // erase anything beyond the bottom with white |
| 1112 | 1087 | HIViewGetBounds(view->wnd,&client); |
| 1113 | | client.origin.y = visrows * debug_font_height; |
| 1088 | client.origin.y = visarea.y * debug_font_height; |
| 1114 | 1089 | |
| 1115 | 1090 | CGContextSetRGBFillColor(dc, 1.0, 1.0, 1.0, 1.0); |
| 1116 | 1091 | CGContextFillRect(dc, client); |
| r3755 | r3756 | |
| 1120 | 1095 | |
| 1121 | 1096 | |
| 1122 | 1097 | //============================================================ |
| 1123 | | // debug_view_update |
| 1098 | // debugwin_view_update |
| 1124 | 1099 | //============================================================ |
| 1125 | 1100 | |
| 1126 | | static void debug_view_update(debug_view *view) |
| 1101 | static void debugwin_view_update(debug_view *view, void *osdprivate) |
| 1127 | 1102 | { |
| 1128 | 1103 | debugview_info *info = debug_view_find(view); |
| 1129 | 1104 | |
| r3755 | r3756 | |
| 1131 | 1106 | if (info && info->view) |
| 1132 | 1107 | { |
| 1133 | 1108 | HIRect bounds, vscroll_bounds, hscroll_bounds; |
| 1109 | debug_view_xy totalsize, visiblesize, topleft; |
| 1134 | 1110 | int show_vscroll, show_hscroll; |
| 1135 | | UINT32 visible_rows, visible_cols; |
| 1136 | | UINT32 total_rows, total_cols; |
| 1137 | | UINT32 top_row, left_col; |
| 1138 | 1111 | |
| 1139 | 1112 | // get the view window bounds |
| 1140 | 1113 | HIViewGetFrame(info->wnd,&bounds); |
| 1141 | | visible_rows = bounds.size.height / debug_font_height; |
| 1142 | | visible_cols = bounds.size.width / debug_font_width; |
| 1114 | visiblesize.x = bounds.size.width / debug_font_width; |
| 1115 | visiblesize.y = bounds.size.height / debug_font_height; |
| 1143 | 1116 | |
| 1144 | 1117 | // get the updated total rows/cols and left row/col |
| 1145 | | total_rows = debug_view_get_property_UINT32(view, DVP_TOTAL_ROWS); |
| 1146 | | total_cols = debug_view_get_property_UINT32(view, DVP_TOTAL_COLS); |
| 1147 | | top_row = debug_view_get_property_UINT32(view, DVP_TOP_ROW); |
| 1148 | | left_col = debug_view_get_property_UINT32(view, DVP_LEFT_COL); |
| 1118 | totalsize = debug_view_get_total_size(view); |
| 1119 | topleft = debug_view_get_visible_position(view); |
| 1149 | 1120 | |
| 1150 | 1121 | // determine if we need to show the scrollbars |
| 1151 | 1122 | show_vscroll = show_hscroll = 0; |
| 1152 | | if (total_rows > visible_rows) |
| 1123 | if (totalsize.x > visiblesize.x) |
| 1153 | 1124 | { |
| 1154 | | bounds.size.width -= vscroll_width; |
| 1155 | | visible_cols = bounds.size.width / debug_font_width; |
| 1156 | | show_vscroll = TRUE; |
| 1157 | | } |
| 1158 | | if (total_cols > visible_cols) |
| 1159 | | { |
| 1160 | 1125 | bounds.size.height -= hscroll_height; |
| 1161 | | visible_rows = bounds.size.height / debug_font_height; |
| 1126 | visiblesize.y = bounds.size.height / debug_font_height; |
| 1162 | 1127 | show_hscroll = TRUE; |
| 1163 | 1128 | } |
| 1164 | | if (!show_vscroll && total_rows > visible_rows) |
| 1129 | if (totalsize.y > visiblesize.y) |
| 1165 | 1130 | { |
| 1166 | 1131 | bounds.size.width -= vscroll_width; |
| 1167 | | visible_cols = bounds.size.width / debug_font_width; |
| 1132 | visiblesize.x = bounds.size.width / debug_font_width; |
| 1168 | 1133 | show_vscroll = TRUE; |
| 1169 | 1134 | } |
| 1135 | if (!show_vscroll && totalsize.y > visiblesize.y) |
| 1136 | { |
| 1137 | bounds.size.width -= vscroll_width; |
| 1138 | visiblesize.x = bounds.size.width / debug_font_width; |
| 1139 | show_vscroll = TRUE; |
| 1140 | } |
| 1170 | 1141 | |
| 1171 | 1142 | // compute the bounds of the scrollbars |
| 1172 | 1143 | vscroll_bounds = bounds; |
| r3755 | r3756 | |
| 1178 | 1149 | hscroll_bounds.size.height = hscroll_height; |
| 1179 | 1150 | |
| 1180 | 1151 | // if we hid the scrollbars, make sure we reset the top/left corners |
| 1181 | | if (top_row + visible_rows > total_rows) |
| 1182 | | top_row = (total_rows > visible_rows) ? (total_rows - visible_rows) : 0; |
| 1183 | | if (left_col + visible_cols > total_cols) |
| 1184 | | left_col = (total_cols > visible_cols) ? (total_cols - visible_cols) : 0; |
| 1152 | if (topleft.y + visiblesize.y > totalsize.y) |
| 1153 | topleft.y = MAX(totalsize.y - visiblesize.y, 0); |
| 1154 | if (topleft.x + visiblesize.x > totalsize.x) |
| 1155 | topleft.x = MAX(totalsize.x - visiblesize.x, 0); |
| 1185 | 1156 | |
| 1186 | 1157 | // fill out the scroll info struct for the vertical scrollbar |
| 1187 | 1158 | if ( show_vscroll ) |
| 1188 | 1159 | { |
| 1189 | 1160 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| 1190 | 1161 | HIViewSetMinimum(info->vscroll,0); |
| 1191 | | HIViewSetMaximum(info->vscroll,total_rows-visible_rows); |
| 1192 | | HIViewSetValue(info->vscroll,top_row); |
| 1193 | | HIViewSetViewSize(info->vscroll,visible_rows); |
| 1162 | HIViewSetMaximum(info->vscroll,totalsize.y-visiblesize.y); |
| 1163 | HIViewSetValue(info->vscroll,topleft.y); |
| 1164 | HIViewSetViewSize(info->vscroll,visiblesize.y); |
| 1194 | 1165 | #else // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| 1195 | 1166 | SetControl32BitMinimum(info->vscroll,0); |
| 1196 | | SetControl32BitMaximum(info->vscroll,total_rows-visible_rows); |
| 1197 | | SetControl32BitValue(info->vscroll,top_row); |
| 1167 | SetControl32BitMaximum(info->vscroll,totalsize.y-visiblesize.y); |
| 1168 | SetControl32BitValue(info->vscroll,topleft.y); |
| 1198 | 1169 | #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| 1199 | 1170 | } |
| 1200 | 1171 | |
| r3755 | r3756 | |
| 1203 | 1174 | { |
| 1204 | 1175 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| 1205 | 1176 | HIViewSetMinimum(info->hscroll,0); |
| 1206 | | HIViewSetMaximum(info->hscroll,total_cols-visible_cols); |
| 1207 | | HIViewSetValue(info->hscroll,left_col); |
| 1208 | | HIViewSetViewSize(info->hscroll,visible_cols); |
| 1177 | HIViewSetMaximum(info->hscroll,totalsize.x-visiblesize.x); |
| 1178 | HIViewSetValue(info->hscroll,topleft.x); |
| 1179 | HIViewSetViewSize(info->hscroll,visiblesize.x); |
| 1209 | 1180 | #else // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| 1210 | 1181 | SetControl32BitMinimum(info->hscroll,0); |
| 1211 | | SetControl32BitMaximum(info->hscroll,total_cols-visible_cols); |
| 1212 | | SetControl32BitValue(info->hscroll,left_col); |
| 1182 | SetControl32BitMaximum(info->hscroll,totalsize.x-visiblesize.x); |
| 1183 | SetControl32BitValue(info->hscroll,topleft.x); |
| 1213 | 1184 | #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| 1214 | 1185 | } |
| 1215 | 1186 | |
| 1216 | 1187 | // update window info |
| 1217 | | visible_rows++; |
| 1218 | | visible_cols++; |
| 1219 | | debug_view_set_property_UINT32(view, DVP_VISIBLE_ROWS, visible_rows); |
| 1220 | | debug_view_set_property_UINT32(view, DVP_VISIBLE_COLS, visible_cols); |
| 1221 | | debug_view_set_property_UINT32(view, DVP_TOP_ROW, top_row); |
| 1222 | | debug_view_set_property_UINT32(view, DVP_LEFT_COL, left_col); |
| 1188 | visiblesize.y++; |
| 1189 | visiblesize.x++; |
| 1190 | debug_view_set_visible_size(view, visiblesize); |
| 1191 | debug_view_set_visible_position(view, topleft); |
| 1223 | 1192 | |
| 1224 | 1193 | // invalidate the bounds |
| 1225 | 1194 | HIViewSetNeedsDisplay(info->wnd, TRUE); |
| r3755 | r3756 | |
| 1282 | 1251 | } |
| 1283 | 1252 | |
| 1284 | 1253 | //============================================================ |
| 1285 | | // debug_view_process_scroll |
| 1254 | // debugwin_view_process_scroll |
| 1286 | 1255 | //============================================================ |
| 1287 | 1256 | |
| 1288 | | static void debug_view_process_scroll(HIViewRef inView, ControlPartCode partCode) |
| 1257 | static void debugwin_view_process_scroll(HIViewRef inView, ControlPartCode partCode) |
| 1289 | 1258 | { |
| 1290 | 1259 | debugview_info *info; |
| 1291 | 1260 | INT32 result; |
| r3755 | r3756 | |
| 1321 | 1290 | |
| 1322 | 1291 | case kAppearancePartPageUpArea: |
| 1323 | 1292 | if ( isHorz ) |
| 1324 | | result -= debug_view_get_property_UINT32(info->view, DVP_VISIBLE_COLS); |
| 1293 | result -= debug_view_get_visible_size(info->view).x; |
| 1325 | 1294 | else |
| 1326 | | result -= debug_view_get_property_UINT32(info->view, DVP_VISIBLE_ROWS); |
| 1295 | result -= debug_view_get_visible_size(info->view).y; |
| 1327 | 1296 | break; |
| 1328 | 1297 | |
| 1329 | 1298 | case kAppearancePartPageDownArea: |
| 1330 | 1299 | if ( isHorz ) |
| 1331 | | result += debug_view_get_property_UINT32(info->view, DVP_VISIBLE_COLS); |
| 1300 | result += debug_view_get_visible_size(info->view).x; |
| 1332 | 1301 | else |
| 1333 | | result += debug_view_get_property_UINT32(info->view, DVP_VISIBLE_ROWS); |
| 1302 | result += debug_view_get_visible_size(info->view).y; |
| 1334 | 1303 | break; |
| 1335 | 1304 | } |
| 1336 | 1305 | |
| r3755 | r3756 | |
| 1341 | 1310 | |
| 1342 | 1311 | if ( isHorz ) |
| 1343 | 1312 | { |
| 1344 | | debug_view_set_property_UINT32(info->view, DVP_LEFT_COL, result); |
| 1313 | debug_view_xy topleft = debug_view_get_visible_position(info->view); |
| 1314 | topleft.x = result; |
| 1315 | debug_view_set_visible_position(info->view, topleft); |
| 1345 | 1316 | } |
| 1346 | 1317 | else |
| 1347 | 1318 | { |
| 1348 | | if (info->is_textbuf) |
| 1319 | // if (info->is_textbuf) |
| 1320 | // { |
| 1321 | // if( result == maxval ) |
| 1322 | // result = -1; |
| 1323 | // debug_view_set_property_UINT32(info->view, DVP_TEXTBUF_LINE_LOCK, result); |
| 1324 | // } |
| 1325 | // else |
| 1349 | 1326 | { |
| 1350 | | if( result == maxval ) |
| 1351 | | result = -1; |
| 1352 | | debug_view_set_property_UINT32(info->view, DVP_TEXTBUF_LINE_LOCK, result); |
| 1327 | debug_view_xy topleft = debug_view_get_visible_position(info->view); |
| 1328 | topleft.y = result; |
| 1329 | debug_view_set_visible_position(info->view, topleft); |
| 1353 | 1330 | } |
| 1354 | | else |
| 1355 | | debug_view_set_property_UINT32(info->view, DVP_TOP_ROW, result); |
| 1356 | 1331 | } |
| 1357 | 1332 | } |
| 1358 | 1333 | |
| 1359 | 1334 | |
| 1360 | 1335 | //============================================================ |
| 1361 | | // debug_view_prev_view |
| 1336 | // debugwin_view_prev_view |
| 1362 | 1337 | //============================================================ |
| 1363 | 1338 | |
| 1364 | | static void debug_view_prev_view(debugwin_info *info, debugview_info *curview) |
| 1339 | static void debugwin_view_prev_view(debugwin_info *info, debugview_info *curview) |
| 1365 | 1340 | { |
| 1366 | 1341 | int curindex = 1; |
| 1367 | 1342 | int numviews; |
| r3755 | r3756 | |
| 1391 | 1366 | } |
| 1392 | 1367 | |
| 1393 | 1368 | // positive numbers mean a view |
| 1394 | | else if (curindex >= 0 && info->view[curindex].wnd != NULL && debug_view_get_property_UINT32(info->view[curindex].view, DVP_SUPPORTS_CURSOR)) |
| 1369 | else if (curindex >= 0 && info->view[curindex].wnd != NULL && debug_view_get_cursor_supported(info->view[curindex].view)) |
| 1395 | 1370 | { |
| 1396 | 1371 | osx_SetFocus(info->view[curindex].wnd); |
| 1397 | 1372 | break; |
| r3755 | r3756 | |
| 1402 | 1377 | |
| 1403 | 1378 | |
| 1404 | 1379 | //============================================================ |
| 1405 | | // debug_view_next_view |
| 1380 | // debugwin_view_next_view |
| 1406 | 1381 | //============================================================ |
| 1407 | 1382 | |
| 1408 | | static void debug_view_next_view(debugwin_info *info, debugview_info *curview) |
| 1383 | static void debugwin_view_next_view(debugwin_info *info, debugview_info *curview) |
| 1409 | 1384 | { |
| 1410 | 1385 | int curindex = -1; |
| 1411 | 1386 | int numviews; |
| r3755 | r3756 | |
| 1435 | 1410 | } |
| 1436 | 1411 | |
| 1437 | 1412 | // positive numbers mean a view |
| 1438 | | else if (curindex >= 0 && info->view[curindex].wnd != NULL && debug_view_get_property_UINT32(info->view[curindex].view, DVP_SUPPORTS_CURSOR)) |
| 1413 | else if (curindex >= 0 && info->view[curindex].wnd != NULL && debug_view_get_cursor_supported(info->view[curindex].view)) |
| 1439 | 1414 | { |
| 1440 | 1415 | osx_SetFocus(info->view[curindex].wnd); |
| 1441 | 1416 | HIViewSetNeedsDisplay(info->view[curindex].wnd, TRUE); |
| r3755 | r3756 | |
| 1447 | 1422 | |
| 1448 | 1423 | |
| 1449 | 1424 | //============================================================ |
| 1450 | | // debug_view_proc |
| 1425 | // debugwin_view_proc |
| 1451 | 1426 | //============================================================ |
| 1452 | 1427 | |
| 1453 | | static OSStatus debug_view_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData) |
| 1428 | static OSStatus debugwin_view_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData) |
| 1454 | 1429 | { |
| 1455 | 1430 | debugview_info *info = (debugview_info *)inUserData; |
| 1456 | 1431 | UInt32 eventClass = GetEventClass( inEvent ); |
| r3755 | r3756 | |
| 1471 | 1446 | exit( -1 ); |
| 1472 | 1447 | } |
| 1473 | 1448 | |
| 1474 | | debug_view_draw_contents(info, dc); |
| 1449 | debugwin_view_draw_contents(info, dc); |
| 1475 | 1450 | return noErr; |
| 1476 | 1451 | } |
| 1477 | 1452 | break; |
| r3755 | r3756 | |
| 1485 | 1460 | { |
| 1486 | 1461 | if ( part == kControlFocusNoPart ) // losing focus |
| 1487 | 1462 | { |
| 1488 | | if (debug_view_get_property_UINT32(info->view, DVP_SUPPORTS_CURSOR)) |
| 1489 | | debug_view_set_property_UINT32(info->view, DVP_CURSOR_VISIBLE, 0); |
| 1463 | if (debug_view_get_cursor_supported(info->view)) |
| 1464 | debug_view_set_cursor_visible(info->view, FALSE); |
| 1490 | 1465 | } |
| 1491 | 1466 | else // gaining focus |
| 1492 | 1467 | { |
| 1493 | | if (debug_view_get_property_UINT32(info->view, DVP_SUPPORTS_CURSOR)) |
| 1494 | | debug_view_set_property_UINT32(info->view, DVP_CURSOR_VISIBLE, 1); |
| 1495 | | |
| 1468 | if (debug_view_get_cursor_supported(info->view)) |
| 1469 | debug_view_set_cursor_visible(info->view, TRUE); |
| 1470 | |
| 1496 | 1471 | part = kControlLabelPart; |
| 1497 | 1472 | SetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, sizeof(part), &part ); |
| 1498 | 1473 | } |
| r3755 | r3756 | |
| 1518 | 1493 | { |
| 1519 | 1494 | if ( button == kEventMouseButtonPrimary ) |
| 1520 | 1495 | { |
| 1521 | | int x = viewPos.x / debug_font_width; |
| 1522 | | int y = viewPos.y / debug_font_height; |
| 1523 | | debug_view_begin_update(info->view); |
| 1524 | | debug_view_set_property_UINT32(info->view, DVP_CURSOR_ROW, debug_view_get_property_UINT32(info->view, DVP_TOP_ROW) + y); |
| 1525 | | debug_view_set_property_UINT32(info->view, DVP_CURSOR_COL, debug_view_get_property_UINT32(info->view, DVP_LEFT_COL) + x); |
| 1526 | | debug_view_end_update(info->view); |
| 1527 | | osx_SetFocus(info->wnd); |
| 1496 | if (debug_view_get_cursor_supported(info->view)) |
| 1497 | { |
| 1498 | // debug_view_xy topleft = debug_view_get_visible_position(info->view); |
| 1499 | debug_view_xy newpos; |
| 1500 | newpos.x = viewPos.x / debug_font_width; |
| 1501 | newpos.y = viewPos.y / debug_font_height; |
| 1502 | debug_view_set_cursor_position(info->view, newpos); |
| 1503 | osx_SetFocus(info->wnd); |
| 1504 | } |
| 1528 | 1505 | return noErr; |
| 1529 | 1506 | } |
| 1530 | 1507 | } |
| r3755 | r3756 | |
| 1593 | 1570 | |
| 1594 | 1571 | if ( axis == kEventMouseWheelAxisX && info->hscroll ) |
| 1595 | 1572 | { |
| 1596 | | debug_view_set_property_UINT32(info->view, DVP_LEFT_COL, result); |
| 1573 | debug_view_xy topleft = debug_view_get_visible_position(info->view); |
| 1574 | topleft.x = result; |
| 1575 | debug_view_set_visible_position(info->view, topleft); |
| 1597 | 1576 | } |
| 1598 | 1577 | else if ( axis == kEventMouseWheelAxisY && info->vscroll != NULL ) |
| 1599 | 1578 | { |
| 1600 | | if (info->is_textbuf) |
| 1601 | | debug_view_set_property_UINT32(info->view, DVP_TEXTBUF_LINE_LOCK, result); |
| 1602 | | else |
| 1603 | | debug_view_set_property_UINT32(info->view, DVP_TOP_ROW, result); |
| 1579 | // if (info->is_textbuf) |
| 1580 | // debug_view_set_property_UINT32(info->view, DVP_TEXTBUF_LINE_LOCK, result); |
| 1581 | // else |
| 1582 | { |
| 1583 | debug_view_xy topleft = debug_view_get_visible_position(info->view); |
| 1584 | topleft.y = result; |
| 1585 | debug_view_set_visible_position(info->view, topleft); |
| 1586 | } |
| 1604 | 1587 | } |
| 1605 | 1588 | } |
| 1606 | 1589 | } |
| r3755 | r3756 | |
| 1615 | 1598 | { |
| 1616 | 1599 | case kUpArrowCharCode: |
| 1617 | 1600 | { |
| 1618 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_UP); |
| 1601 | debug_view_type_character(info->view, DCH_UP); |
| 1619 | 1602 | return noErr; |
| 1620 | 1603 | } |
| 1621 | 1604 | break; |
| 1622 | 1605 | |
| 1623 | 1606 | case kDownArrowCharCode: |
| 1624 | 1607 | { |
| 1625 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_DOWN); |
| 1608 | debug_view_type_character(info->view, DCH_DOWN); |
| 1626 | 1609 | return noErr; |
| 1627 | 1610 | } |
| 1628 | 1611 | break; |
| r3755 | r3756 | |
| 1630 | 1613 | case kLeftArrowCharCode: |
| 1631 | 1614 | { |
| 1632 | 1615 | if ( event.modifiers & cmdKey ) |
| 1633 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_CTRLLEFT); |
| 1616 | debug_view_type_character(info->view, DCH_CTRLLEFT); |
| 1634 | 1617 | else |
| 1635 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_LEFT); |
| 1618 | debug_view_type_character(info->view, DCH_LEFT); |
| 1636 | 1619 | |
| 1637 | 1620 | return noErr; |
| 1638 | 1621 | } |
| r3755 | r3756 | |
| 1641 | 1624 | case kRightArrowCharCode: |
| 1642 | 1625 | { |
| 1643 | 1626 | if ( event.modifiers & cmdKey ) |
| 1644 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_CTRLRIGHT); |
| 1627 | debug_view_type_character(info->view, DCH_CTRLRIGHT); |
| 1645 | 1628 | else |
| 1646 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_RIGHT); |
| 1629 | debug_view_type_character(info->view, DCH_RIGHT); |
| 1647 | 1630 | |
| 1648 | 1631 | return noErr; |
| 1649 | 1632 | } |
| r3755 | r3756 | |
| 1651 | 1634 | |
| 1652 | 1635 | case kPageUpCharCode: |
| 1653 | 1636 | { |
| 1654 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_PUP); |
| 1637 | debug_view_type_character(info->view, DCH_PUP); |
| 1655 | 1638 | return noErr; |
| 1656 | 1639 | } |
| 1657 | 1640 | break; |
| 1658 | 1641 | |
| 1659 | 1642 | case kPageDownCharCode: |
| 1660 | 1643 | { |
| 1661 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_PDOWN); |
| 1644 | debug_view_type_character(info->view, DCH_PDOWN); |
| 1662 | 1645 | return noErr; |
| 1663 | 1646 | } |
| 1664 | 1647 | break; |
| r3755 | r3756 | |
| 1666 | 1649 | case kHomeCharCode: |
| 1667 | 1650 | { |
| 1668 | 1651 | if ( event.modifiers & cmdKey ) |
| 1669 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_CTRLHOME); |
| 1652 | debug_view_type_character(info->view, DCH_CTRLHOME); |
| 1670 | 1653 | else |
| 1671 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_HOME); |
| 1654 | debug_view_type_character(info->view, DCH_HOME); |
| 1672 | 1655 | |
| 1673 | 1656 | return noErr; |
| 1674 | 1657 | } |
| r3755 | r3756 | |
| 1677 | 1660 | case kEndCharCode: |
| 1678 | 1661 | { |
| 1679 | 1662 | if ( event.modifiers & cmdKey ) |
| 1680 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_CTRLEND); |
| 1663 | debug_view_type_character(info->view, DCH_CTRLEND); |
| 1681 | 1664 | else |
| 1682 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, DCH_END); |
| 1665 | debug_view_type_character(info->view, DCH_END); |
| 1683 | 1666 | |
| 1684 | 1667 | return noErr; |
| 1685 | 1668 | } |
| r3755 | r3756 | |
| 1696 | 1679 | case kTabCharCode: |
| 1697 | 1680 | { |
| 1698 | 1681 | if ( event.modifiers & shiftKey ) |
| 1699 | | debug_view_prev_view(info->owner, info); |
| 1682 | debugwin_view_prev_view(info->owner, info); |
| 1700 | 1683 | else |
| 1701 | | debug_view_next_view(info->owner, info); |
| 1684 | debugwin_view_next_view(info->owner, info); |
| 1702 | 1685 | return noErr; |
| 1703 | 1686 | } |
| 1704 | 1687 | break; |
| r3755 | r3756 | |
| 1707 | 1690 | { |
| 1708 | 1691 | char code = event.message & charCodeMask; |
| 1709 | 1692 | |
| 1710 | | if (code >= 32 && code < 127 && debug_view_get_property_UINT32(info->view, DVP_SUPPORTS_CURSOR)) |
| 1693 | if (code >= 32 && code < 127 && debug_view_get_cursor_supported(info->view)) |
| 1711 | 1694 | { |
| 1712 | | debug_view_set_property_UINT32(info->view, DVP_CHARACTER, code); |
| 1695 | debug_view_type_character(info->view, code); |
| 1713 | 1696 | return noErr; |
| 1714 | 1697 | } |
| 1715 | 1698 | } |
| r3755 | r3756 | |
| 1724 | 1707 | |
| 1725 | 1708 | |
| 1726 | 1709 | //============================================================ |
| 1727 | | // debug_edit_proc |
| 1710 | // debugwin_edit_proc |
| 1728 | 1711 | //============================================================ |
| 1729 | 1712 | |
| 1730 | | static OSStatus debug_edit_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData) |
| 1713 | static OSStatus debugwin_edit_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData) |
| 1731 | 1714 | { |
| 1732 | 1715 | debugwin_info *info = (debugwin_info *)inUserData; |
| 1733 | 1716 | char buffer[MAX_EDIT_STRING]; |
| r3755 | r3756 | |
| 1784 | 1767 | case kTabCharCode: |
| 1785 | 1768 | { |
| 1786 | 1769 | if (event.modifiers & shiftKey) |
| 1787 | | debug_view_prev_view(info, NULL); |
| 1770 | debugwin_view_prev_view(info, NULL); |
| 1788 | 1771 | else |
| 1789 | | debug_view_next_view(info, NULL); |
| 1772 | debugwin_view_next_view(info, NULL); |
| 1790 | 1773 | |
| 1791 | 1774 | return noErr; |
| 1792 | 1775 | } |
| r3755 | r3756 | |
| 1846 | 1829 | |
| 1847 | 1830 | static void generic_recompute_children(debugwin_info *info) |
| 1848 | 1831 | { |
| 1832 | debug_view_xy totalsize = debug_view_get_total_size(info->view[0].view); |
| 1849 | 1833 | Rect parent; |
| 1850 | 1834 | Rect bounds; |
| 1851 | 1835 | HIRect hibounds; |
| 1852 | | UINT32 width; |
| 1853 | 1836 | |
| 1854 | | // get the view width |
| 1855 | | width = debug_view_get_property_UINT32(info->view[0].view, DVP_TOTAL_COLS); |
| 1856 | | |
| 1857 | 1837 | // compute a client rect |
| 1858 | 1838 | bounds.top = bounds.left = 0; |
| 1859 | | bounds.right = width * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 1839 | bounds.right = totalsize.x * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 1860 | 1840 | bounds.bottom = 200; |
| 1861 | 1841 | // AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); |
| 1862 | 1842 | |
| r3755 | r3756 | |
| 1874 | 1854 | parent.top += EDGE_WIDTH; parent.left += EDGE_WIDTH; |
| 1875 | 1855 | parent.bottom -= EDGE_WIDTH; parent.right -= EDGE_WIDTH; |
| 1876 | 1856 | |
| 1877 | | debug_view_set_bounds(&info->view[0], &parent); |
| 1857 | debugwin_view_set_bounds(&info->view[0], &parent); |
| 1878 | 1858 | } |
| 1879 | 1859 | |
| 1880 | 1860 | |
| r3755 | r3756 | |
| 1885 | 1865 | |
| 1886 | 1866 | static void log_create_window(running_machine *machine) |
| 1887 | 1867 | { |
| 1868 | debug_view_xy totalsize; |
| 1888 | 1869 | debugwin_info *info; |
| 1889 | 1870 | char title[256]; |
| 1890 | 1871 | UINT32 width, height; |
| r3755 | r3756 | |
| 1893 | 1874 | // create the window |
| 1894 | 1875 | snprintf(title, ARRAY_LENGTH(title), "Errorlog: %s [%s]", machine->gamedrv->description, machine->gamedrv->name); |
| 1895 | 1876 | info = debug_window_create(machine, title, NULL); |
| 1896 | | if (!info || !debug_view_create(info, 0, DVT_LOG)) |
| 1877 | if (info == NULL || !debugwin_view_create(info, 0, DVT_LOG)) |
| 1897 | 1878 | return; |
| 1898 | | info->view->is_textbuf = TRUE; |
| 1899 | 1879 | |
| 1900 | 1880 | // set the child function |
| 1901 | 1881 | info->recompute_children = generic_recompute_children; |
| 1902 | 1882 | |
| 1903 | 1883 | // get the view width |
| 1904 | | width = debug_view_get_property_UINT32(info->view[0].view, DVP_TOTAL_COLS); |
| 1884 | totalsize = debug_view_get_total_size(info->view[0].view); |
| 1905 | 1885 | |
| 1906 | 1886 | // compute a client rect |
| 1907 | 1887 | bounds.top = bounds.left = 0; |
| 1908 | | bounds.right = width * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 1888 | bounds.right = totalsize.x * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 1909 | 1889 | bounds.bottom = 200; |
| 1910 | 1890 | // AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); |
| 1911 | 1891 | |
| r3755 | r3756 | |
| 1931 | 1911 | |
| 1932 | 1912 | |
| 1933 | 1913 | //============================================================ |
| 1934 | | // memory_determine_combo_items |
| 1935 | | //============================================================ |
| 1936 | | |
| 1937 | | static void memory_determine_combo_items(running_machine *machine) |
| 1938 | | { |
| 1939 | | memorycombo_item **tail = &memorycombo; |
| 1940 | | UINT32 cpunum, spacenum; |
| 1941 | | const char *rgntag; |
| 1942 | | int itemnum; |
| 1943 | | |
| 1944 | | // first add all the CPUs' address spaces |
| 1945 | | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 1946 | | { |
| 1947 | | if (machine->cpu[cpunum] != NULL) |
| 1948 | | { |
| 1949 | | const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); |
| 1950 | | for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) |
| 1951 | | { |
| 1952 | | if (cpuinfo->space[spacenum].databytes) |
| 1953 | | { |
| 1954 | | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 1955 | | memset(ci, 0, sizeof(*ci)); |
| 1956 | | ci->cpunum = cpunum; |
| 1957 | | ci->spacenum = spacenum; |
| 1958 | | ci->prefsize = MIN(cpuinfo->space[spacenum].databytes, 8); |
| 1959 | | snprintf(ci->name, ARRAY_LENGTH(ci->name), "CPU #%d \"%s\" (%s) %s memory", cpunum, machine->config->cpu[cpunum].tag, cpu_get_name(machine->cpu[cpunum]), address_space_names[spacenum]); |
| 1960 | | *tail = ci; |
| 1961 | | tail = &ci->next; |
| 1962 | | } |
| 1963 | | } |
| 1964 | | } |
| 1965 | | } |
| 1966 | | |
| 1967 | | // then add all the memory regions |
| 1968 | | for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = memory_region_next(machine, rgntag)) |
| 1969 | | { |
| 1970 | | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 1971 | | UINT32 flags = memory_region_flags(machine, rgntag); |
| 1972 | | UINT8 little_endian = ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE); |
| 1973 | | UINT8 width = 1 << ((flags & ROMREGION_WIDTHMASK) >> 8); |
| 1974 | | |
| 1975 | | memset(ci, 0, sizeof(*ci)); |
| 1976 | | ci->base = memory_region(machine, rgntag); |
| 1977 | | ci->length = memory_region_length(machine, rgntag); |
| 1978 | | ci->prefsize = MIN(width, 8); |
| 1979 | | ci->offset_xor = width - 1; |
| 1980 | | ci->little_endian = little_endian; |
| 1981 | | |
| 1982 | | snprintf(ci->name, ARRAY_LENGTH(ci->name), "Regio \"%s\"", rgntag); |
| 1983 | | |
| 1984 | | *tail = ci; |
| 1985 | | tail = &ci->next; |
| 1986 | | } |
| 1987 | | |
| 1988 | | // finally add all global array symbols |
| 1989 | | for (itemnum = 0; itemnum < 10000; itemnum++) |
| 1990 | | { |
| 1991 | | UINT32 valsize, valcount; |
| 1992 | | const char *name; |
| 1993 | | void *base; |
| 1994 | | |
| 1995 | | /* stop when we run out of items */ |
| 1996 | | name = state_save_get_indexed_item(itemnum, &base, &valsize, &valcount); |
| 1997 | | if (name == NULL) |
| 1998 | | break; |
| 1999 | | |
| 2000 | | /* if this is a single-entry global, add it */ |
| 2001 | | if (valcount > 1 && strstr(name, "/globals/")) |
| 2002 | | { |
| 2003 | | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 2004 | | memset(ci, 0, sizeof(*ci)); |
| 2005 | | ci->base = base; |
| 2006 | | ci->length = valcount * valsize; |
| 2007 | | ci->prefsize = MIN(valsize, 8); |
| 2008 | | ci->little_endian = TRUE; |
| 2009 | | strcpy(ci->name, strrchr(name, '/') + 1); |
| 2010 | | *tail = ci; |
| 2011 | | tail = &ci->next; |
| 2012 | | } |
| 2013 | | } |
| 2014 | | } |
| 2015 | | |
| 2016 | | |
| 2017 | | //============================================================ |
| 2018 | | // memory_update_selection |
| 2019 | | //============================================================ |
| 2020 | | |
| 2021 | | static void memory_update_selection(debugwin_info *info, memorycombo_item *ci) |
| 2022 | | { |
| 2023 | | CFStringRef title; |
| 2024 | | |
| 2025 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_CPUNUM, ci->cpunum); |
| 2026 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_SPACENUM, ci->spacenum); |
| 2027 | | debug_view_set_property_ptr(info->view[0].view, DVP_MEM_RAW_BASE, ci->base); |
| 2028 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_RAW_LENGTH, ci->length); |
| 2029 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_RAW_OFFSET_XOR, ci->offset_xor); |
| 2030 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_RAW_LITTLE_ENDIAN, ci->little_endian); |
| 2031 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, ci->prefsize); |
| 2032 | | |
| 2033 | | title = CFStringCreateWithCString( NULL, ci->name, CFStringGetSystemEncoding() ); |
| 2034 | | |
| 2035 | | if ( title ) |
| 2036 | | { |
| 2037 | | SetWindowTitleWithCFString(info->wnd, title); |
| 2038 | | CFRelease( title ); |
| 2039 | | } |
| 2040 | | } |
| 2041 | | |
| 2042 | | |
| 2043 | | //============================================================ |
| 2044 | 1914 | // memory_create_window |
| 2045 | 1915 | //============================================================ |
| 2046 | 1916 | |
| 2047 | 1917 | static void memory_create_window(running_machine *machine) |
| 2048 | 1918 | { |
| 2049 | | int curcpu = cpunum_get_active(), cursel = 0; |
| 2050 | | memorycombo_item *ci, *selci = NULL; |
| 1919 | const device_config *curcpu = debug_cpu_get_visible_cpu(machine); |
| 1920 | const memory_subview_item *subview; |
| 1921 | int cursel = -1; |
| 2051 | 1922 | debugwin_info *info; |
| 2052 | 1923 | MenuRef optionsmenu,popupmenu; |
| 2053 | 1924 | Rect bounds; |
| r3755 | r3756 | |
| 2058 | 1929 | |
| 2059 | 1930 | // create the window |
| 2060 | 1931 | info = debug_window_create(machine, "Memory", NULL); |
| 2061 | | if (!info || !debug_view_create(info, 0, DVT_MEMORY)) |
| 1932 | if (!info || !debugwin_view_create(info, 0, DVT_MEMORY)) |
| 2062 | 1933 | return; |
| 2063 | 1934 | |
| 2064 | 1935 | // set the handlers |
| r3755 | r3756 | |
| 2103 | 1974 | memory_update_checkmarks(info); |
| 2104 | 1975 | |
| 2105 | 1976 | // set up the view to track the initial expression |
| 2106 | | debug_view_begin_update(info->view[0].view); |
| 2107 | | debug_view_set_property_string(info->view[0].view, DVP_MEM_EXPRESSION, "0"); |
| 1977 | memory_view_set_expression(info->view[0].view, "0"); |
| 2108 | 1978 | strcpy(info->edit_defstr, "0"); |
| 2109 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_TRACK_LIVE, 1); |
| 2110 | | debug_view_end_update(info->view[0].view); |
| 2111 | 1979 | |
| 2112 | 1980 | fontName[0] = strlen( OSX_DEBUGGER_FONT_NAME ); |
| 2113 | 1981 | strcpy( (char*)&fontName[1], OSX_DEBUGGER_FONT_NAME ); |
| r3755 | r3756 | |
| 2121 | 1989 | bounds.bottom = bounds.right = 100; |
| 2122 | 1990 | CreateEditUnicodeTextControl(info->wnd, &bounds, CFSTR("0"), false, NULL, &info->editwnd); |
| 2123 | 1991 | SetControlFontStyle(info->editwnd,&style); |
| 2124 | | InstallEventHandler( GetControlEventTarget(info->editwnd), NewEventHandlerUPP(debug_edit_proc), sizeof( debug_keyboard_events ) / sizeof( EventTypeSpec ), debug_keyboard_events, info, NULL ); |
| 1992 | InstallEventHandler( GetControlEventTarget(info->editwnd), NewEventHandlerUPP(debugwin_edit_proc), sizeof( debug_keyboard_events ) / sizeof( EventTypeSpec ), debug_keyboard_events, info, NULL ); |
| 2125 | 1993 | |
| 2126 | 1994 | // create action menu and attach the contextual menu |
| 2127 | 1995 | content.contentType = kControlContentTextOnly; |
| r3755 | r3756 | |
| 2148 | 2016 | } |
| 2149 | 2017 | |
| 2150 | 2018 | // populate the combobox |
| 2151 | | if (!memorycombo) |
| 2152 | | memory_determine_combo_items(machine); |
| 2153 | | for (ci = memorycombo; ci; ci = ci->next) |
| 2019 | for (subview = memory_view_get_subview_list(info->view[0].view); subview != NULL; subview = subview->next) |
| 2154 | 2020 | { |
| 2155 | | CFStringRef cfName = CFStringCreateWithCString( NULL, ci->name, CFStringGetSystemEncoding() ); |
| 2021 | CFStringRef cfName = CFStringCreateWithCString( NULL, subview->name, CFStringGetSystemEncoding() ); |
| 2156 | 2022 | UInt16 item; |
| 2157 | 2023 | |
| 2158 | 2024 | AppendMenuItemTextWithCFString( popupmenu, cfName, 0, 0, &item ); |
| 2159 | 2025 | |
| 2160 | 2026 | CFRelease( cfName ); |
| 2161 | 2027 | |
| 2162 | | if (ci->base == NULL && ci->cpunum == curcpu && ci->spacenum == ADDRESS_SPACE_PROGRAM) |
| 2028 | if (cursel == -1 && subview->space != NULL && subview->space->cpu == curcpu) |
| 2163 | 2029 | { |
| 2164 | 2030 | cursel = item; |
| 2165 | | selci = ci; |
| 2166 | 2031 | } |
| 2167 | 2032 | } |
| 2033 | if (cursel == -1) cursel = 0; |
| 2168 | 2034 | |
| 2169 | 2035 | SetControlData(info->otherwnd[0], kControlEntireControl, kControlPopupButtonOwnedMenuRefTag, sizeof(popupmenu),&popupmenu); |
| 2170 | 2036 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| r3755 | r3756 | |
| 2181 | 2047 | info->recompute_children = memory_recompute_children; |
| 2182 | 2048 | info->process_string = memory_process_string; |
| 2183 | 2049 | |
| 2184 | | // set the CPUnum and spacenum properties |
| 2185 | | if (selci == NULL) |
| 2186 | | selci = memorycombo; |
| 2187 | | memory_update_selection(info, selci); |
| 2050 | // set the caption |
| 2051 | memory_update_caption(info); |
| 2188 | 2052 | |
| 2189 | 2053 | // recompute the children once to get the maxwidth |
| 2190 | 2054 | memory_recompute_children(info); |
| r3755 | r3756 | |
| 2213 | 2077 | |
| 2214 | 2078 | static void memory_recompute_children(debugwin_info *info) |
| 2215 | 2079 | { |
| 2080 | debug_view_xy totalsize = debug_view_get_total_size(info->view[0].view); |
| 2216 | 2081 | Rect parent, memrect, editrect, comborect, actionrect; |
| 2217 | 2082 | Rect bounds; |
| 2218 | 2083 | HIRect hibounds; |
| 2219 | | UINT32 width; |
| 2220 | 2084 | |
| 2221 | | // get the view width |
| 2222 | | width = debug_view_get_property_UINT32(info->view[0].view, DVP_TOTAL_COLS); |
| 2223 | | |
| 2224 | 2085 | // compute a client rect |
| 2225 | 2086 | bounds.top = bounds.left = 0; |
| 2226 | | bounds.right = width * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 2087 | bounds.right = totalsize.x * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 2227 | 2088 | bounds.bottom = 200; |
| 2228 | 2089 | // AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); |
| 2229 | 2090 | |
| r3755 | r3756 | |
| 2263 | 2124 | memrect.right = parent.right - EDGE_WIDTH; |
| 2264 | 2125 | |
| 2265 | 2126 | // set the bounds of things |
| 2266 | | debug_view_set_bounds(&info->view[0], &memrect); |
| 2127 | debugwin_view_set_bounds(&info->view[0], &memrect); |
| 2267 | 2128 | |
| 2268 | 2129 | osx_RectToHIRect( &editrect, &hibounds ); |
| 2269 | 2130 | smart_set_view_bounds(info->editwnd, &hibounds); |
| r3755 | r3756 | |
| 2282 | 2143 | static void memory_process_string(debugwin_info *info, const char *string) |
| 2283 | 2144 | { |
| 2284 | 2145 | // set the string to the memory view |
| 2285 | | debug_view_set_property_string(info->view[0].view, DVP_MEM_EXPRESSION, string); |
| 2146 | memory_view_set_expression(info->view[0].view, string); |
| 2286 | 2147 | |
| 2287 | 2148 | // select everything in the edit text box |
| 2288 | 2149 | { |
| r3755 | r3756 | |
| 2311 | 2172 | MenuItemIndex menuindex; |
| 2312 | 2173 | |
| 2313 | 2174 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_1_BYTE_CHUNKS, 1, NULL, &menuindex ); |
| 2314 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 1)); |
| 2175 | CheckMenuItem(info->contextualMenu, menuindex, (memory_view_get_bytes_per_chunk(info->view[0].view) == 1)); |
| 2315 | 2176 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_2_BYTE_CHUNKS, 1, NULL, &menuindex); |
| 2316 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 2)); |
| 2177 | CheckMenuItem(info->contextualMenu, menuindex, (memory_view_get_bytes_per_chunk(info->view[0].view) == 2)); |
| 2317 | 2178 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_4_BYTE_CHUNKS, 1, NULL, &menuindex); |
| 2318 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 4)); |
| 2179 | CheckMenuItem(info->contextualMenu, menuindex, (memory_view_get_bytes_per_chunk(info->view[0].view) == 4)); |
| 2319 | 2180 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_8_BYTE_CHUNKS, 1, NULL, &menuindex); |
| 2320 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 8)); |
| 2181 | CheckMenuItem(info->contextualMenu, menuindex, (memory_view_get_bytes_per_chunk(info->view[0].view) == 8)); |
| 2321 | 2182 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_LOGICAL_ADDRESSES, 1, NULL, &menuindex); |
| 2322 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION) == 0)); |
| 2183 | CheckMenuItem(info->contextualMenu, menuindex, (memory_view_get_physical(info->view[0].view) == 0)); |
| 2323 | 2184 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_PHYSICAL_ADDRESSES, 1, NULL, &menuindex); |
| 2324 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION) != 0)); |
| 2185 | CheckMenuItem(info->contextualMenu, menuindex, (memory_view_get_physical(info->view[0].view) != 0)); |
| 2325 | 2186 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_REVERSE_VIEW, 1, NULL, &menuindex); |
| 2326 | | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW))); |
| 2187 | CheckMenuItem(info->contextualMenu, menuindex, memory_view_get_reverse(info->view[0].view)); |
| 2327 | 2188 | } |
| 2328 | 2189 | } |
| 2329 | 2190 | |
| r3755 | r3756 | |
| 2336 | 2197 | static int memory_handle_command(debugwin_info *info, EventRef inEvent) |
| 2337 | 2198 | { |
| 2338 | 2199 | HICommand cmd; |
| 2339 | | Rect bounds; |
| 2340 | 2200 | |
| 2341 | 2201 | if ( GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof( cmd ), NULL, &cmd ) != noErr ) |
| 2342 | 2202 | return global_handle_command(info, inEvent); |
| r3755 | r3756 | |
| 2353 | 2213 | |
| 2354 | 2214 | if ( sel > 0 ) |
| 2355 | 2215 | { |
| 2356 | | // find the matching entry |
| 2357 | | memorycombo_item *ci; |
| 2358 | | for (ci = memorycombo; ci; ci = ci->next) |
| 2359 | | if (--sel == 0) |
| 2360 | | { |
| 2361 | | debug_view_begin_update(info->view[0].view); |
| 2362 | | memory_update_selection(info, ci); |
| 2363 | | debug_view_end_update(info->view[0].view); |
| 2364 | | } |
| 2216 | memory_view_set_subview(info->view[0].view, sel); |
| 2217 | memory_update_caption(info); |
| 2365 | 2218 | |
| 2366 | 2219 | // reset the focus |
| 2367 | 2220 | osx_SetFocus(info->focuswnd); |
| r3755 | r3756 | |
| 2372 | 2225 | |
| 2373 | 2226 | |
| 2374 | 2227 | case ID_1_BYTE_CHUNKS: |
| 2375 | | debug_view_begin_update(info->view[0].view); |
| 2376 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 1); |
| 2377 | | debug_view_end_update(info->view[0].view); |
| 2378 | | memory_update_checkmarks(info); |
| 2228 | memory_view_set_bytes_per_chunk(info->view[0].view, 1); |
| 2379 | 2229 | return 1; |
| 2380 | 2230 | |
| 2381 | 2231 | case ID_2_BYTE_CHUNKS: |
| 2382 | | debug_view_begin_update(info->view[0].view); |
| 2383 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 2); |
| 2384 | | debug_view_end_update(info->view[0].view); |
| 2385 | | memory_update_checkmarks(info); |
| 2232 | memory_view_set_bytes_per_chunk(info->view[0].view, 2); |
| 2386 | 2233 | return 1; |
| 2387 | 2234 | |
| 2388 | 2235 | case ID_4_BYTE_CHUNKS: |
| 2389 | | debug_view_begin_update(info->view[0].view); |
| 2390 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 4); |
| 2391 | | debug_view_end_update(info->view[0].view); |
| 2392 | | memory_update_checkmarks(info); |
| 2236 | memory_view_set_bytes_per_chunk(info->view[0].view, 4); |
| 2393 | 2237 | return 1; |
| 2394 | 2238 | |
| 2395 | 2239 | case ID_8_BYTE_CHUNKS: |
| 2396 | | debug_view_begin_update(info->view[0].view); |
| 2397 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 8); |
| 2398 | | debug_view_end_update(info->view[0].view); |
| 2399 | | memory_update_checkmarks(info); |
| 2240 | memory_view_set_bytes_per_chunk(info->view[0].view, 8); |
| 2400 | 2241 | return 1; |
| 2401 | 2242 | |
| 2402 | 2243 | case ID_LOGICAL_ADDRESSES: |
| 2403 | | debug_view_begin_update(info->view[0].view); |
| 2404 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, FALSE); |
| 2405 | | debug_view_end_update(info->view[0].view); |
| 2406 | | memory_update_checkmarks(info); |
| 2244 | memory_view_set_physical(info->view[0].view, FALSE); |
| 2407 | 2245 | return 1; |
| 2408 | 2246 | |
| 2409 | 2247 | case ID_PHYSICAL_ADDRESSES: |
| 2410 | | debug_view_begin_update(info->view[0].view); |
| 2411 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, TRUE); |
| 2412 | | debug_view_end_update(info->view[0].view); |
| 2413 | | memory_update_checkmarks(info); |
| 2248 | memory_view_set_physical(info->view[0].view, TRUE); |
| 2414 | 2249 | return 1; |
| 2415 | 2250 | |
| 2416 | 2251 | case ID_REVERSE_VIEW: |
| 2417 | | debug_view_begin_update(info->view[0].view); |
| 2418 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW, !debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW)); |
| 2419 | | debug_view_end_update(info->view[0].view); |
| 2420 | | memory_update_checkmarks(info); |
| 2252 | memory_view_set_reverse(info->view[0].view, !memory_view_get_reverse(info->view[0].view)); |
| 2421 | 2253 | return 1; |
| 2422 | 2254 | |
| 2423 | 2255 | case ID_INCREASE_MEM_WIDTH: |
| 2424 | | GetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2425 | | bounds.right += 4*debug_font_width; |
| 2426 | | SetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2427 | | |
| 2428 | | debug_view_begin_update(info->view[0].view); |
| 2429 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_WIDTH, debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_WIDTH) + 1); |
| 2430 | | debug_view_end_update(info->view[0].view); |
| 2431 | | |
| 2432 | | memory_recompute_children(info); |
| 2256 | memory_view_set_chunks_per_row(info->view[0].view, memory_view_get_chunks_per_row(info->view[0].view) + 1); |
| 2433 | 2257 | return 1; |
| 2434 | 2258 | |
| 2435 | 2259 | case ID_DECREASE_MEM_WIDTH: |
| 2436 | | GetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2437 | | bounds.right -= 4*debug_font_width; |
| 2438 | | SetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2439 | | |
| 2440 | | debug_view_begin_update(info->view[0].view); |
| 2441 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_WIDTH, debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_WIDTH) - 1); |
| 2442 | | debug_view_end_update(info->view[0].view); |
| 2443 | | |
| 2444 | | memory_recompute_children(info); |
| 2260 | memory_view_set_chunks_per_row(info->view[0].view, memory_view_get_chunks_per_row(info->view[0].view) - 1); |
| 2445 | 2261 | return 1; |
| 2446 | 2262 | } |
| 2447 | 2263 | |
| r3755 | r3756 | |
| 2457 | 2273 | static int memory_handle_key(debugwin_info *info, EventRef inEvent) |
| 2458 | 2274 | { |
| 2459 | 2275 | EventRecord event; |
| 2460 | | Rect bounds; |
| 2461 | 2276 | |
| 2462 | 2277 | if ( ConvertEventRefToEventRecord( inEvent, &event ) ) |
| 2463 | 2278 | { |
| r3755 | r3756 | |
| 2466 | 2281 | switch( event.message & charCodeMask ) |
| 2467 | 2282 | { |
| 2468 | 2283 | case '1': |
| 2469 | | debug_view_begin_update(info->view[0].view); |
| 2470 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 1); |
| 2471 | | debug_view_end_update(info->view[0].view); |
| 2472 | | memory_update_checkmarks(info); |
| 2284 | memory_view_set_bytes_per_chunk(info->view[0].view, 1); |
| 2473 | 2285 | return 1; |
| 2474 | 2286 | |
| 2475 | 2287 | case '2': |
| 2476 | | debug_view_begin_update(info->view[0].view); |
| 2477 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 2); |
| 2478 | | debug_view_end_update(info->view[0].view); |
| 2479 | | memory_update_checkmarks(info); |
| 2288 | memory_view_set_bytes_per_chunk(info->view[0].view, 2); |
| 2480 | 2289 | return 1; |
| 2481 | 2290 | |
| 2482 | 2291 | case '4': |
| 2483 | | debug_view_begin_update(info->view[0].view); |
| 2484 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 4); |
| 2485 | | debug_view_end_update(info->view[0].view); |
| 2486 | | memory_update_checkmarks(info); |
| 2292 | memory_view_set_bytes_per_chunk(info->view[0].view, 4); |
| 2487 | 2293 | return 1; |
| 2488 | 2294 | |
| 2489 | 2295 | case '8': |
| 2490 | | debug_view_begin_update(info->view[0].view); |
| 2491 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 8); |
| 2492 | | debug_view_end_update(info->view[0].view); |
| 2493 | | memory_update_checkmarks(info); |
| 2296 | memory_view_set_bytes_per_chunk(info->view[0].view, 8); |
| 2494 | 2297 | return 1; |
| 2495 | 2298 | |
| 2496 | 2299 | case 'l': |
| 2497 | 2300 | case 'L': |
| 2498 | | debug_view_begin_update(info->view[0].view); |
| 2499 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, FALSE); |
| 2500 | | debug_view_end_update(info->view[0].view); |
| 2501 | | memory_update_checkmarks(info); |
| 2301 | memory_view_set_physical(info->view[0].view, FALSE); |
| 2502 | 2302 | return 1; |
| 2503 | 2303 | |
| 2504 | 2304 | case 'y': |
| 2505 | 2305 | case 'Y': |
| 2506 | | debug_view_begin_update(info->view[0].view); |
| 2507 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, TRUE); |
| 2508 | | debug_view_end_update(info->view[0].view); |
| 2509 | | memory_update_checkmarks(info); |
| 2306 | memory_view_set_physical(info->view[0].view, TRUE); |
| 2510 | 2307 | return 1; |
| 2511 | 2308 | |
| 2512 | 2309 | case 'r': |
| 2513 | 2310 | case 'R': |
| 2514 | | debug_view_begin_update(info->view[0].view); |
| 2515 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW, !debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW)); |
| 2516 | | debug_view_end_update(info->view[0].view); |
| 2517 | | memory_update_checkmarks(info); |
| 2311 | memory_view_set_reverse(info->view[0].view, !memory_view_get_reverse(info->view[0].view)); |
| 2518 | 2312 | return 1; |
| 2519 | 2313 | |
| 2520 | 2314 | case 'p': |
| 2521 | 2315 | case 'P': |
| 2522 | | GetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2523 | | bounds.right += 4*debug_font_width; |
| 2524 | | SetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2525 | | |
| 2526 | | debug_view_begin_update(info->view[0].view); |
| 2527 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_WIDTH, debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_WIDTH) + 1); |
| 2528 | | debug_view_end_update(info->view[0].view); |
| 2529 | | |
| 2530 | | memory_recompute_children(info); |
| 2316 | memory_view_set_chunks_per_row(info->view[0].view, memory_view_get_chunks_per_row(info->view[0].view) + 1); |
| 2531 | 2317 | return 1; |
| 2532 | 2318 | |
| 2533 | 2319 | case 'o': |
| 2534 | 2320 | case 'O': |
| 2535 | | GetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2536 | | bounds.right -= 4*debug_font_width; |
| 2537 | | SetWindowBounds(info->wnd, kWindowStructureRgn, &bounds ); |
| 2538 | | |
| 2539 | | debug_view_begin_update(info->view[0].view); |
| 2540 | | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_WIDTH, debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_WIDTH) - 1); |
| 2541 | | debug_view_end_update(info->view[0].view); |
| 2542 | | |
| 2543 | | memory_recompute_children(info); |
| 2321 | memory_view_set_chunks_per_row(info->view[0].view, memory_view_get_chunks_per_row(info->view[0].view) - 1); |
| 2544 | 2322 | return 1; |
| 2545 | 2323 | } |
| 2546 | 2324 | } |
| r3755 | r3756 | |
| 2552 | 2330 | |
| 2553 | 2331 | |
| 2554 | 2332 | //============================================================ |
| 2333 | // memory_update_caption |
| 2334 | //============================================================ |
| 2335 | |
| 2336 | static void memory_update_caption(debugwin_info *info) |
| 2337 | { |
| 2338 | const memory_subview_item *subview = memory_view_get_current_subview(info->view[0].view); |
| 2339 | CFStringRef cftitle; |
| 2340 | char title[256]; |
| 2341 | |
| 2342 | // update the caption |
| 2343 | snprintf(title, ARRAY_LENGTH(title), "Memory: %s", subview->name); |
| 2344 | |
| 2345 | cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() ); |
| 2346 | |
| 2347 | if ( cftitle ) |
| 2348 | { |
| 2349 | SetWindowTitleWithCFString( info->wnd, cftitle); |
| 2350 | CFRelease( cftitle ); |
| 2351 | } |
| 2352 | } |
| 2353 | |
| 2354 | |
| 2355 | |
| 2356 | //============================================================ |
| 2555 | 2357 | // disasm_create_window |
| 2556 | 2358 | //============================================================ |
| 2557 | 2359 | |
| 2558 | 2360 | static void disasm_create_window(running_machine *machine) |
| 2559 | 2361 | { |
| 2560 | | int curcpu = cpunum_get_active(), cursel = 0; |
| 2362 | const device_config *curcpu = debug_cpu_get_visible_cpu(machine); |
| 2363 | const disasm_subview_item *subview; |
| 2364 | int cursel = 0; |
| 2561 | 2365 | debugwin_info *info; |
| 2562 | 2366 | MenuRef optionsmenu, popupmenu; |
| 2563 | | UINT32 cpunum; |
| 2564 | 2367 | Rect bounds; |
| 2565 | 2368 | ControlFontStyleRec style; |
| 2566 | 2369 | Str255 fontName; |
| r3755 | r3756 | |
| 2569 | 2372 | |
| 2570 | 2373 | // create the window |
| 2571 | 2374 | info = debug_window_create(machine, "Disassembly", NULL); |
| 2572 | | if (!info || !debug_view_create(info, 0, DVT_DISASSEMBLY)) |
| 2375 | if (!info || !debugwin_view_create(info, 0, DVT_DISASSEMBLY)) |
| 2573 | 2376 | return; |
| 2574 | 2377 | |
| 2575 | 2378 | // create the options menu |
| r3755 | r3756 | |
| 2604 | 2407 | info->handle_key = disasm_handle_key; |
| 2605 | 2408 | |
| 2606 | 2409 | // set up the view to track the initial expression |
| 2607 | | debug_view_begin_update(info->view[0].view); |
| 2608 | | debug_view_set_property_string(info->view[0].view, DVP_DASM_EXPRESSION, "curpc"); |
| 2410 | disasm_view_set_expression(info->view[0].view, "curpc"); |
| 2609 | 2411 | strcpy(info->edit_defstr, "curpc"); |
| 2610 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_TRACK_LIVE, 1); |
| 2611 | | debug_view_end_update(info->view[0].view); |
| 2612 | 2412 | |
| 2613 | 2413 | fontName[0] = strlen( OSX_DEBUGGER_FONT_NAME ); |
| 2614 | 2414 | strcpy( (char*)&fontName[1], OSX_DEBUGGER_FONT_NAME ); |
| r3755 | r3756 | |
| 2622 | 2422 | bounds.bottom = bounds.right = 100; |
| 2623 | 2423 | CreateEditUnicodeTextControl(info->wnd, &bounds, CFSTR("0"), false, NULL, &info->editwnd); |
| 2624 | 2424 | SetControlFontStyle(info->editwnd,&style); |
| 2625 | | InstallEventHandler( GetControlEventTarget(info->editwnd), NewEventHandlerUPP(debug_edit_proc), sizeof( debug_keyboard_events ) / sizeof( EventTypeSpec ), debug_keyboard_events, info, NULL ); |
| 2425 | InstallEventHandler( GetControlEventTarget(info->editwnd), NewEventHandlerUPP(debugwin_edit_proc), sizeof( debug_keyboard_events ) / sizeof( EventTypeSpec ), debug_keyboard_events, info, NULL ); |
| 2626 | 2426 | |
| 2627 | 2427 | // create action menu and attach the contextual menu |
| 2628 | 2428 | content.contentType = kControlContentTextOnly; |
| r3755 | r3756 | |
| 2649 | 2449 | } |
| 2650 | 2450 | |
| 2651 | 2451 | // populate the combobox |
| 2652 | | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 2452 | for (subview = disasm_view_get_subview_list(info->view[0].view); subview != NULL; subview = subview->next) |
| 2653 | 2453 | { |
| 2654 | | if (machine->cpu[cpunum] != NULL) |
| 2655 | | { |
| 2656 | | const cpu_debug_data *cpuinfo = cpu_get_debug_data(machine->cpu[cpunum]); |
| 2657 | | if (cpuinfo->space[ADDRESS_SPACE_PROGRAM].databytes) |
| 2658 | | { |
| 2659 | | CFStringRef cfName; |
| 2660 | | char name[100]; |
| 2661 | | UInt16 item; |
| 2454 | CFStringRef cfName; |
| 2455 | char name[100]; |
| 2456 | UInt16 item; |
| 2662 | 2457 | |
| 2663 | | snprintf(name, ARRAY_LENGTH(name), "CPU #%d \"%s\" (%s)", cpunum, machine->config->cpu[cpunum].tag, cpu_get_name(machine->cpu[cpunum])); |
| 2458 | snprintf(name, ARRAY_LENGTH(name), "%s", subview->name); |
| 2664 | 2459 | |
| 2665 | | cfName = CFStringCreateWithCString( NULL, name, CFStringGetSystemEncoding() ); |
| 2666 | | AppendMenuItemTextWithCFString( popupmenu, cfName, 0, 0, &item ); |
| 2667 | | CFRelease( cfName ); |
| 2460 | cfName = CFStringCreateWithCString( NULL, name, CFStringGetSystemEncoding() ); |
| 2461 | AppendMenuItemTextWithCFString( popupmenu, cfName, 0, 0, &item ); |
| 2462 | CFRelease( cfName ); |
| 2668 | 2463 | |
| 2669 | | if (cpunum == curcpu) |
| 2670 | | cursel = item; |
| 2671 | | } |
| 2672 | | } |
| 2464 | if (cursel == 0 && subview->space->cpu == curcpu) |
| 2465 | cursel = item; |
| 2673 | 2466 | } |
| 2467 | disasm_view_set_subview(info->view[0].view, cursel); |
| 2674 | 2468 | |
| 2675 | 2469 | SetControlData(info->otherwnd[0], kControlEntireControl, kControlPopupButtonOwnedMenuRefTag, sizeof(popupmenu),&popupmenu); |
| 2676 | 2470 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 |
| r3755 | r3756 | |
| 2687 | 2481 | info->recompute_children = disasm_recompute_children; |
| 2688 | 2482 | info->process_string = disasm_process_string; |
| 2689 | 2483 | |
| 2690 | | // set the CPUnum and spacenum properties |
| 2691 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM, (curcpu == -1) ? 0 : curcpu); |
| 2692 | | |
| 2693 | 2484 | // set the caption |
| 2694 | 2485 | disasm_update_caption(info); |
| 2695 | 2486 | |
| r3755 | r3756 | |
| 2720 | 2511 | |
| 2721 | 2512 | static void disasm_recompute_children(debugwin_info *info) |
| 2722 | 2513 | { |
| 2514 | debug_view_xy totalsize = debug_view_get_total_size(info->view[0].view); |
| 2723 | 2515 | Rect parent, dasmrect, editrect, comborect, actionrect; |
| 2724 | 2516 | Rect bounds; |
| 2725 | 2517 | HIRect hibounds; |
| 2726 | | UINT32 width; |
| 2727 | 2518 | |
| 2728 | | // get the view width |
| 2729 | | width = debug_view_get_property_UINT32(info->view[0].view, DVP_TOTAL_COLS); |
| 2730 | | |
| 2731 | 2519 | // compute a client rect |
| 2732 | 2520 | bounds.top = bounds.left = 0; |
| 2733 | | bounds.right = width * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 2521 | bounds.right = totalsize.x * debug_font_width + vscroll_width + 2 * EDGE_WIDTH; |
| 2734 | 2522 | bounds.bottom = 200; |
| 2735 | 2523 | // AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); |
| 2736 | 2524 | |
| r3755 | r3756 | |
| 2769 | 2557 | dasmrect.right = parent.right - EDGE_WIDTH; |
| 2770 | 2558 | |
| 2771 | 2559 | // set the bounds of things |
| 2772 | | debug_view_set_bounds(&info->view[0], &dasmrect); |
| 2560 | debugwin_view_set_bounds(&info->view[0], &dasmrect); |
| 2773 | 2561 | |
| 2774 | 2562 | osx_RectToHIRect( &editrect, &hibounds ); |
| 2775 | 2563 | smart_set_view_bounds(info->editwnd, &hibounds); |
| r3755 | r3756 | |
| 2790 | 2578 | static void disasm_process_string(debugwin_info *info, const char *string) |
| 2791 | 2579 | { |
| 2792 | 2580 | // set the string to the disasm view |
| 2793 | | debug_view_set_property_string(info->view[0].view, DVP_DASM_EXPRESSION, string); |
| 2581 | disasm_view_set_expression(info->view[0].view, string); |
| 2794 | 2582 | |
| 2795 | 2583 | // select everything in the edit text box |
| 2796 | 2584 | { |
| r3755 | r3756 | |
| 2818 | 2606 | { |
| 2819 | 2607 | MenuItemIndex menuindex; |
| 2820 | 2608 | |
| 2821 | | int rightcol = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN); |
| 2609 | disasm_right_column rightcol = disasm_view_get_right_column(info->view[0].view); |
| 2822 | 2610 | |
| 2823 | 2611 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_SHOW_RAW, 1, NULL, &menuindex ); |
| 2824 | | CheckMenuItem(info->contextualMenu, menuindex, (rightcol == DVP_DASM_RIGHTCOL_RAW)); |
| 2612 | CheckMenuItem(info->contextualMenu, menuindex, (rightcol == DASM_RIGHTCOL_RAW)); |
| 2825 | 2613 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_SHOW_ENCRYPTED, 1, NULL, &menuindex ); |
| 2826 | | CheckMenuItem(info->contextualMenu, menuindex, (rightcol == DVP_DASM_RIGHTCOL_ENCRYPTED)); |
| 2614 | CheckMenuItem(info->contextualMenu, menuindex, (rightcol == DASM_RIGHTCOL_ENCRYPTED)); |
| 2827 | 2615 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_SHOW_COMMENTS, 1, NULL, &menuindex ); |
| 2828 | | CheckMenuItem(info->contextualMenu, menuindex, (rightcol == DVP_DASM_RIGHTCOL_COMMENTS)); |
| 2616 | CheckMenuItem(info->contextualMenu, menuindex, (rightcol == DASM_RIGHTCOL_COMMENTS)); |
| 2829 | 2617 | } |
| 2830 | 2618 | } |
| 2831 | 2619 | |
| r3755 | r3756 | |
| 2839 | 2627 | { |
| 2840 | 2628 | HICommand cmd; |
| 2841 | 2629 | char command[64]; |
| 2842 | | UINT32 active_address = 0x00; |
| 2843 | 2630 | |
| 2844 | 2631 | if ( GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof( cmd ), NULL, &cmd ) != noErr ) |
| 2845 | 2632 | return global_handle_command(info, inEvent); |
| r3755 | r3756 | |
| 2856 | 2643 | |
| 2857 | 2644 | if ( sel > 0 ) |
| 2858 | 2645 | { |
| 2859 | | // find the matching entry |
| 2860 | | UINT32 cpunum; |
| 2861 | | for (cpunum = 0; cpunum < MAX_CPU; cpunum++) |
| 2862 | | { |
| 2863 | | if (info->machine->cpu[cpunum] != NULL) |
| 2864 | | { |
| 2865 | | const cpu_debug_data *cpuinfo = cpu_get_debug_data(info->machine->cpu[cpunum]); |
| 2866 | | if (cpuinfo->space[ADDRESS_SPACE_PROGRAM].databytes) |
| 2867 | | { |
| 2868 | | if (--sel == 0) |
| 2869 | | { |
| 2870 | | debug_view_begin_update(info->view[0].view); |
| 2871 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM, cpunum); |
| 2872 | | debug_view_end_update(info->view[0].view); |
| 2873 | | disasm_update_caption(info); |
| 2874 | | } |
| 2875 | | } |
| 2876 | | } |
| 2877 | | } |
| 2646 | disasm_view_set_subview(info->view[0].view, sel); |
| 2647 | disasm_update_caption(info); |
| 2878 | 2648 | |
| 2879 | 2649 | // reset the focus |
| 2880 | 2650 | osx_SetFocus(info->focuswnd); |
| r3755 | r3756 | |
| 2884 | 2654 | break; |
| 2885 | 2655 | |
| 2886 | 2656 | case ID_SHOW_RAW: |
| 2887 | | debug_view_begin_update(info->view[0].view); |
| 2888 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_RAW); |
| 2889 | | debug_view_end_update(info->view[0].view); |
| 2890 | | disasm_update_checkmarks(info); |
| 2657 | disasm_view_set_right_column(info->view[0].view, DASM_RIGHTCOL_RAW); |
| 2891 | 2658 | (*info->recompute_children)(info); |
| 2892 | 2659 | return 1; |
| 2893 | 2660 | |
| 2894 | 2661 | case ID_SHOW_ENCRYPTED: |
| 2895 | | debug_view_begin_update(info->view[0].view); |
| 2896 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_ENCRYPTED); |
| 2897 | | debug_view_end_update(info->view[0].view); |
| 2898 | | disasm_update_checkmarks(info); |
| 2662 | disasm_view_set_right_column(info->view[0].view, DASM_RIGHTCOL_ENCRYPTED); |
| 2899 | 2663 | (*info->recompute_children)(info); |
| 2900 | 2664 | return 1; |
| 2901 | 2665 | |
| 2902 | 2666 | case ID_SHOW_COMMENTS: |
| 2903 | | debug_view_begin_update(info->view[0].view); |
| 2904 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_COMMENTS); |
| 2905 | | debug_view_end_update(info->view[0].view); |
| 2906 | | disasm_update_checkmarks(info); |
| 2667 | disasm_view_set_right_column(info->view[0].view, DASM_RIGHTCOL_COMMENTS); |
| 2907 | 2668 | (*info->recompute_children)(info); |
| 2908 | 2669 | return 1; |
| 2909 | 2670 | |
| 2910 | 2671 | case ID_RUN_TO_CURSOR: |
| 2911 | | if (debug_view_get_property_UINT32(info->view[0].view, DVP_CURSOR_VISIBLE)) |
| 2672 | if (debug_view_get_cursor_visible(info->view[0].view)) |
| 2912 | 2673 | { |
| 2913 | | active_address = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_ACTIVE_ADDRESS); |
| 2914 | | sprintf(command, "go %X", active_address); |
| 2915 | | debug_console_execute_command(info->machine, command, 1); |
| 2674 | const address_space *space = disasm_view_get_current_subview(info->view[0].view)->space; |
| 2675 | if (debug_cpu_get_visible_cpu(info->machine) == space->cpu) |
| 2676 | { |
| 2677 | offs_t address = memory_byte_to_address(space, disasm_view_get_selected_address(info->view[0].view)); |
| 2678 | sprintf(command, "go %X", address); |
| 2679 | debug_console_execute_command(info->machine, command, 1); |
| 2680 | } |
| 2916 | 2681 | } |
| 2917 | 2682 | return 1; |
| 2918 | 2683 | |
| 2919 | 2684 | case ID_TOGGLE_BREAKPOINT: |
| 2920 | | if (debug_view_get_property_UINT32(info->view[0].view, DVP_CURSOR_VISIBLE)) |
| 2685 | if (debug_view_get_cursor_visible(info->view[0].view)) |
| 2921 | 2686 | { |
| 2922 | | UINT32 cpu_num = 0; |
| 2923 | | cpu_debug_data *cpuinfo ; |
| 2924 | | debug_cpu_breakpoint *bp; |
| 2925 | | INT8 bp_exists = 0; |
| 2926 | | UINT32 bp_num = 0; |
| 2687 | const address_space *space = disasm_view_get_current_subview(info->view[0].view)->space; |
| 2688 | if (debug_cpu_get_visible_cpu(info->machine) == space->cpu) |
| 2689 | { |
| 2690 | offs_t address = memory_byte_to_address(space, disasm_view_get_selected_address(info->view[0].view)); |
| 2691 | cpu_debug_data *cpuinfo = cpu_get_debug_data(space->cpu); |
| 2692 | debug_cpu_breakpoint *bp; |
| 2693 | INT32 bpindex = -1; |
| 2927 | 2694 | |
| 2928 | | /* what address are we dealing with? */ |
| 2929 | | active_address = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_ACTIVE_ADDRESS); |
| 2695 | /* first find an existing breakpoint at this address */ |
| 2696 | for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) |
| 2697 | if (address == bp->address) |
| 2698 | { |
| 2699 | bpindex = bp->index; |
| 2700 | break; |
| 2701 | } |
| 2930 | 2702 | |
| 2931 | | /* is there already a breakpoint there? */ |
| 2932 | | cpu_num = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM); |
| 2933 | | cpuinfo = (cpu_debug_data*)cpu_get_debug_data(info->machine->cpu[cpu_num]); |
| 2934 | | |
| 2935 | | for (bp = cpuinfo->bplist; bp; bp = bp->next) |
| 2936 | | { |
| 2937 | | if (BYTE2ADDR(active_address, cpuinfo, ADDRESS_SPACE_PROGRAM) == bp->address) |
| 2938 | | { |
| 2939 | | bp_exists = 1; |
| 2940 | | bp_num = bp->index; |
| 2941 | | } |
| 2703 | /* if it doesn't exist, add a new one */ |
| 2704 | if (bpindex == -1) |
| 2705 | sprintf(command, "bpset %X", address); |
| 2706 | else |
| 2707 | sprintf(command, "bpclear %X", bpindex); |
| 2708 | debug_console_execute_command(info->machine, command, 1); |
| 2942 | 2709 | } |
| 2943 | | |
| 2944 | | /* Toggle */ |
| 2945 | | if (!bp_exists) |
| 2946 | | sprintf(command, "bpset %X", BYTE2ADDR(active_address, cpuinfo, ADDRESS_SPACE_PROGRAM)); |
| 2947 | | else |
| 2948 | | sprintf(command, "bpclear %X", bp_num); |
| 2949 | | debug_console_execute_command(info->machine, command, 1); |
| 2950 | 2710 | } |
| 2951 | 2711 | return 1; |
| 2952 | 2712 | } |
| r3755 | r3756 | |
| 2962 | 2722 | { |
| 2963 | 2723 | EventRecord event; |
| 2964 | 2724 | char command[64]; |
| 2965 | | UINT32 active_address = 0x00; |
| 2966 | 2725 | |
| 2967 | 2726 | if ( ConvertEventRefToEventRecord( inEvent, &event ) ) |
| 2968 | 2727 | { |
| r3755 | r3756 | |
| 2972 | 2731 | { |
| 2973 | 2732 | case 'r': |
| 2974 | 2733 | case 'R': |
| 2975 | | debug_view_begin_update(info->view[0].view); |
| 2976 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_RAW); |
| 2977 | | debug_view_end_update(info->view[0].view); |
| 2978 | | disasm_update_checkmarks(info); |
| 2734 | disasm_view_set_right_column(info->view[0].view, DASM_RIGHTCOL_RAW); |
| 2979 | 2735 | (*info->recompute_children)(info); |
| 2980 | 2736 | return 1; |
| 2981 | 2737 | |
| 2982 | 2738 | case 'e': |
| 2983 | 2739 | case 'E': |
| 2984 | | debug_view_begin_update(info->view[0].view); |
| 2985 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_ENCRYPTED); |
| 2986 | | debug_view_end_update(info->view[0].view); |
| 2987 | | disasm_update_checkmarks(info); |
| 2740 | disasm_view_set_right_column(info->view[0].view, DASM_RIGHTCOL_ENCRYPTED); |
| 2988 | 2741 | (*info->recompute_children)(info); |
| 2989 | 2742 | return 1; |
| 2990 | 2743 | |
| 2991 | 2744 | case 'n': |
| 2992 | 2745 | case 'N': |
| 2993 | | debug_view_begin_update(info->view[0].view); |
| 2994 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_COMMENTS); |
| 2995 | | debug_view_end_update(info->view[0].view); |
| 2996 | | disasm_update_checkmarks(info); |
| 2746 | disasm_view_set_right_column(info->view[0].view, DASM_RIGHTCOL_COMMENTS); |
| 2997 | 2747 | (*info->recompute_children)(info); |
| 2998 | 2748 | return 1; |
| 2999 | 2749 | } |
| r3755 | r3756 | |
| 3002 | 2752 | switch( ( ( event.message & keyCodeMask ) >> 8 ) & 0xFF ) |
| 3003 | 2753 | { |
| 3004 | 2754 | case KEY_F4: |
| 3005 | | if (debug_view_get_property_UINT32(info->view[0].view, DVP_CURSOR_VISIBLE)) |
| 2755 | if (debug_view_get_cursor_visible(info->view[0].view)) |
| 3006 | 2756 | { |
| 3007 | | active_address = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_ACTIVE_ADDRESS); |
| 3008 | | sprintf(command, "go %X", active_address); |
| 3009 | | debug_console_execute_command(info->machine, command, 1); |
| 2757 | const address_space *space = disasm_view_get_current_subview(info->view[0].view)->space; |
| 2758 | if (debug_cpu_get_visible_cpu(info->machine) == space->cpu) |
| 2759 | { |
| 2760 | offs_t address = memory_byte_to_address(space, disasm_view_get_selected_address(info->view[0].view)); |
| 2761 | sprintf(command, "go %X", address); |
| 2762 | debug_console_execute_command(info->machine, command, 1); |
| 2763 | } |
| 3010 | 2764 | } |
| 3011 | 2765 | return 1; |
| 3012 | 2766 | |
| 3013 | 2767 | case KEY_F9: |
| 3014 | | if (debug_view_get_property_UINT32(info->view[0].view, DVP_CURSOR_VISIBLE)) |
| 2768 | if (debug_view_get_cursor_visible(info->view[0].view)) |
| 3015 | 2769 | { |
| 3016 | | UINT32 cpu_num = 0; |
| 3017 | | cpu_debug_data *cpuinfo ; |
| 3018 | | debug_cpu_breakpoint *bp; |
| 3019 | | INT8 bp_exists = 0; |
| 3020 | | UINT32 bp_num = 0; |
| 2770 | const address_space *space = disasm_view_get_current_subview(info->view[0].view)->space; |
| 2771 | if (debug_cpu_get_visible_cpu(info->machine) == space->cpu) |
| 2772 | { |
| 2773 | offs_t address = memory_byte_to_address(space, disasm_view_get_selected_address(info->view[0].view)); |
| 2774 | cpu_debug_data *cpuinfo = cpu_get_debug_data(space->cpu); |
| 2775 | debug_cpu_breakpoint *bp; |
| 2776 | INT32 bpindex = -1; |
| 3021 | 2777 | |
| 3022 | | /* what address are we dealing with? */ |
| 3023 | | active_address = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_ACTIVE_ADDRESS); |
| 2778 | /* first find an existing breakpoint at this address */ |
| 2779 | for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) |
| 2780 | if (address == bp->address) |
| 2781 | { |
| 2782 | bpindex = bp->index; |
| 2783 | break; |
| 2784 | } |
| 3024 | 2785 | |
| 3025 | | /* is there already a breakpoint there? */ |
| 3026 | | cpu_num = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM); |
| 3027 | | cpuinfo = (cpu_debug_data*)cpu_get_debug_data(info->machine->cpu[cpu_num]); |
| 3028 | | |
| 3029 | | for (bp = cpuinfo->bplist; bp; bp = bp->next) |
| 3030 | | { |
| 3031 | | if (BYTE2ADDR(active_address, cpuinfo, ADDRESS_SPACE_PROGRAM) == bp->address) |
| 3032 | | { |
| 3033 | | bp_exists = 1; |
| 3034 | | bp_num = bp->index; |
| 3035 | | } |
| 2786 | /* if it doesn't exist, add a new one */ |
| 2787 | if (bpindex == -1) |
| 2788 | sprintf(command, "bpset %X", address); |
| 2789 | else |
| 2790 | sprintf(command, "bpclear %X", bpindex); |
| 2791 | debug_console_execute_command(info->machine, command, 1); |
| 3036 | 2792 | } |
| 3037 | | |
| 3038 | | /* Toggle */ |
| 3039 | | if (!bp_exists) |
| 3040 | | sprintf(command, "bpset %X", BYTE2ADDR(active_address, cpuinfo, ADDRESS_SPACE_PROGRAM)); |
| 3041 | | else |
| 3042 | | sprintf(command, "bpclear %X", bp_num); |
| 3043 | | debug_console_execute_command(info->machine, command, 1); |
| 3044 | 2793 | } |
| 3045 | 2794 | return 1; |
| 3046 | 2795 | } |
| 3047 | 2796 | |
| 3048 | 2797 | if ( ( event.message & charCodeMask ) == kReturnCharCode ) |
| 3049 | 2798 | { |
| 3050 | | if (debug_view_get_property_UINT32(info->view[0].view, DVP_CURSOR_VISIBLE)) |
| 2799 | if (debug_view_get_cursor_visible(info->view[0].view)) |
| 3051 | 2800 | { |
| 3052 | 2801 | debug_cpu_single_step(info->machine, 1); |
| 3053 | 2802 | return 1; |
| r3755 | r3756 | |
| 3066 | 2815 | |
| 3067 | 2816 | static void disasm_update_caption(debugwin_info *info) |
| 3068 | 2817 | { |
| 2818 | const disasm_subview_item *subview = disasm_view_get_current_subview(info->view[0].view); |
| 3069 | 2819 | CFStringRef cftitle; |
| 3070 | 2820 | char title[100]; |
| 3071 | | UINT32 cpunum; |
| 3072 | 2821 | |
| 3073 | | // get the properties |
| 3074 | | cpunum = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM); |
| 2822 | // update the caption |
| 2823 | snprintf(title, ARRAY_LENGTH(title), "Disassembly: %s", subview->name); |
| 3075 | 2824 | |
| 3076 | | // then update the caption |
| 3077 | | snprintf(title, ARRAY_LENGTH(title), "Disassembly: CPU #%d \"%s\" (%s)", cpunum, info->machine->config->cpu[cpunum].tag, cpu_get_name(info->machine->cpu[cpunum])); |
| 3078 | | |
| 3079 | 2825 | cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() ); |
| 3080 | 2826 | |
| 3081 | 2827 | if ( cftitle ) |
| r3755 | r3756 | |
| 3093 | 2839 | |
| 3094 | 2840 | void console_create_window(running_machine *machine) |
| 3095 | 2841 | { |
| 2842 | const registers_subview_item *regsubview; |
| 2843 | const disasm_subview_item *dasmsubview; |
| 3096 | 2844 | debugwin_info *info; |
| 3097 | 2845 | int bestwidth, bestheight; |
| 3098 | 2846 | Rect bounds, work_bounds; |
| 3099 | 2847 | MenuRef optionsmenu, popupmenu; |
| 3100 | | UINT32 cpunum; |
| 3101 | 2848 | ControlFontStyleRec style; |
| 3102 | 2849 | Str255 fontName; |
| 3103 | 2850 | CGDirectDisplayID mainID = CGMainDisplayID(); |
| r3755 | r3756 | |
| 3106 | 2853 | |
| 3107 | 2854 | // create the window |
| 3108 | 2855 | info = debug_window_create(machine, "Debug", NULL); |
| 3109 | | if (!info) |
| 2856 | if (info == NULL) |
| 3110 | 2857 | return; |
| 3111 | 2858 | main_console = info; |
| 3112 | | console_set_cpunum(machine, 0); |
| 2859 | console_set_cpu(machine->cpu[0]); |
| 3113 | 2860 | |
| 3114 | 2861 | // create the views |
| 3115 | | if (!debug_view_create(info, 0, DVT_DISASSEMBLY)) |
| 2862 | if (!debugwin_view_create(info, 0, DVT_DISASSEMBLY)) |
| 3116 | 2863 | goto cleanup; |
| 3117 | | if (!debug_view_create(info, 1, DVT_REGISTERS)) |
| 2864 | if (!debugwin_view_create(info, 1, DVT_REGISTERS)) |
| 3118 | 2865 | goto cleanup; |
| 3119 | | if (!debug_view_create(info, 2, DVT_CONSOLE)) |
| 2866 | if (!debugwin_view_create(info, 2, DVT_CONSOLE)) |
| 3120 | 2867 | goto cleanup; |
| 3121 | 2868 | |
| 3122 | 2869 | // create the options menu |
| r3755 | r3756 | |
| 3163 | 2910 | info->view[2].is_textbuf = TRUE; |
| 3164 | 2911 | |
| 3165 | 2912 | // set up the disassembly view to track the current pc |
| 3166 | | debug_view_begin_update(info->view[0].view); |
| 3167 | | debug_view_set_property_string(info->view[0].view, DVP_DASM_EXPRESSION, "curpc"); |
| 3168 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_TRACK_LIVE, 1); |
| 3169 | | debug_view_end_update(info->view[0].view); |
| 2913 | disasm_view_set_expression(info->view[0].view, "curpc"); |
| 3170 | 2914 | |
| 3171 | 2915 | fontName[0] = strlen( OSX_DEBUGGER_FONT_NAME ); |
| 3172 | 2916 | strcpy( (char*)&fontName[1], OSX_DEBUGGER_FONT_NAME ); |
| r3755 | r3756 | |
| 3180 | 2924 | bounds.bottom = bounds.right = 100; |
| 3181 | 2925 | CreateEditUnicodeTextControl(info->wnd, &bounds, CFSTR("0"), false, NULL, &info->editwnd); |
| 3182 | 2926 | SetControlFontStyle(info->editwnd,&style); |
| 3183 | | InstallEventHandler( GetControlEventTarget(info->editwnd), NewEventHandlerUPP(debug_edit_proc), sizeof( debug_keyboard_events ) / sizeof( EventTypeSpec ), debug_keyboard_events, info, NULL ); |
| 2927 | InstallEventHandler( GetControlEventTarget(info->editwnd), NewEventHandlerUPP(debugwin_edit_proc), sizeof( debug_keyboard_events ) / sizeof( EventTypeSpec ), debug_keyboard_events, info, NULL ); |
| 3184 | 2928 | |
| 3185 | 2929 | // create popup menu and attach the contextual menu |
| 3186 | 2930 | content.contentType = kControlContentTextOnly; |
| r3755 | r3756 | |
| 3196 | 2940 | // loop over all CPUs and compute the sizes |
| 3197 | 2941 | info->minwidth = 0; |
| 3198 | 2942 | info->maxwidth = 0; |
| 3199 | | for (cpunum = MAX_CPU - 1; (INT32)cpunum >= 0; cpunum--) |
| 3200 | | if (machine->config->cpu[cpunum].type != CPU_DUMMY) |
| 3201 | | { |
| 3202 | | UINT32 regchars, dischars, conchars; |
| 3203 | | UINT32 minwidth, maxwidth; |
| 2943 | for (dasmsubview = disasm_view_get_subview_list(info->view[0].view); dasmsubview != NULL; dasmsubview = dasmsubview->next) |
| 2944 | for (regsubview = registers_view_get_subview_list(info->view[1].view); regsubview != NULL; regsubview = regsubview->next) |
| 2945 | if (dasmsubview->space->cpu == regsubview->device) |
| 2946 | { |
| 2947 | UINT32 regchars, dischars, conchars; |
| 2948 | UINT32 minwidth, maxwidth; |
| 3204 | 2949 | |
| 3205 | | // point all views to the new CPU number |
| 3206 | | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM, cpunum); |
| 3207 | | debug_view_set_property_UINT32(info->view[1].view, DVP_REGS_CPUNUM, cpunum); |
| 2950 | // point all views to the new CPU number |
| 2951 | disasm_view_set_subview(info->view[0].view, dasmsubview->index); |
| 2952 | registers_view_set_subview(info->view[1].view, regsubview->index); |
| 3208 | 2953 | |
| 3209 | | // get the total width of all three children |
| 3210 | | dischars = debug_view_get_property_UINT32(info->view[0].view, DVP_TOTAL_COLS); |
| 3211 | | regchars = debug_view_get_property_UINT32(info->view[1].view, DVP_TOTAL_COLS); |
| 3212 | | conchars = debug_view_get_property_UINT32(info->view[2].view, DVP_TOTAL_COLS); |
| 2954 | // get the total width of all three children |
| 2955 | dischars = debug_view_get_total_size(info->view[0].view).x; |
| 2956 | regchars = debug_view_get_total_size(info->view[1].view).x; |
| 2957 | conchars = debug_view_get_total_size(info->view[2].view).x; |
| 3213 | 2958 | |
| 3214 | | // compute the preferred width |
| 3215 | | minwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + 100 + EDGE_WIDTH; |
| 3216 | | maxwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + ((dischars > conchars) ? dischars : conchars) * debug_font_width + vscroll_width + EDGE_WIDTH; |
| 3217 | | if (minwidth > info->minwidth) |
| 3218 | | info->minwidth = minwidth; |
| 3219 | | if (maxwidth > info->maxwidth) |
| 3220 | | info->maxwidth = maxwidth; |
| 3221 | | } |
| 2959 | // compute the preferred width |
| 2960 | minwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + 100 + EDGE_WIDTH; |
| 2961 | maxwidth = EDGE_WIDTH + regchars * debug_font_width + vscroll_width + 2 * EDGE_WIDTH + ((dischars > conchars) ? dischars : conchars) * debug_font_width + vscroll_width + EDGE_WIDTH; |
| 2962 | if (minwidth > info->minwidth) |
| 2963 | info->minwidth = minwidth; |
| 2964 | if (maxwidth > info->maxwidth) |
| 2965 | info->maxwidth = maxwidth; |
| 2966 | } |
| 3222 | 2967 | |
| 3223 | 2968 | // get the work bounds |
| 3224 | 2969 | { |
| r3755 | r3756 | |
| 3295 | 3040 | parent.right = hibounds.origin.x + hibounds.size.width; |
| 3296 | 3041 | |
| 3297 | 3042 | // get the total width of all three children |
| 3298 | | dischars = debug_view_get_property_UINT32(info->view[0].view, DVP_TOTAL_COLS); |
| 3299 | | regchars = debug_view_get_property_UINT32(info->view[1].view, DVP_TOTAL_COLS); |
| 3300 | | conchars = debug_view_get_property_UINT32(info->view[2].view, DVP_TOTAL_COLS); |
| 3043 | dischars = debug_view_get_total_size(info->view[0].view).x; |
| 3044 | regchars = debug_view_get_total_size(info->view[1].view).x; |
| 3045 | conchars = debug_view_get_total_size(info->view[2].view).x; |
| 3301 | 3046 | |
| 3302 | 3047 | // registers always get their desired width, and span the entire height |
| 3303 | 3048 | regrect.top = parent.top + EDGE_WIDTH; |
| r3755 | r3756 | |
| 3333 | 3078 | conrect.right = parent.right - EDGE_WIDTH; |
| 3334 | 3079 | |
| 3335 | 3080 | // set the bounds of things |
| 3336 | | debug_view_set_bounds(&info->view[0], &disrect); |
| 3337 | | debug_view_set_bounds(&info->view[1], ®rect); |
| 3338 | | debug_view_set_bounds(&info->view[2], &conrect); |
| 3081 | debugwin_view_set_bounds(&info->view[0], &disrect); |
| 3082 | debugwin_view_set_bounds(&info->view[1], ®rect); |
| 3083 | debugwin_view_set_bounds(&info->view[2], &conrect); |
| 3339 | 3084 | |
| 3340 | 3085 | osx_RectToHIRect( &editrect, &hibounds ); |
| 3341 | 3086 | smart_set_view_bounds(info->editwnd, &hibounds); |
| r3755 | r3756 | |
| 3369 | 3114 | |
| 3370 | 3115 | |
| 3371 | 3116 | //============================================================ |
| 3372 | | // console_set_cpunum |
| 3117 | // console_set_cpu |
| 3373 | 3118 | //============================================================ |
| 3374 | 3119 | |
| 3375 | | static void console_set_cpunum(running_machine *machine, int cpunum) |
| 3120 | static void console_set_cpu(const device_config *device) |
| 3376 | 3121 | { |
| 3122 | const registers_subview_item *regsubitem = NULL; |
| 3123 | const disasm_subview_item *dasmsubitem; |
| 3377 | 3124 | char title[256]; |
| 3378 | 3125 | CFStringRef cftitle; |
| 3379 | 3126 | |
| 3380 | 3127 | // first set all the views to the new cpu number |
| 3381 | | if (main_console->view[0].view) |
| 3382 | | debug_view_set_property_UINT32(main_console->view[0].view, DVP_DASM_CPUNUM, cpunum); |
| 3383 | | if (main_console->view[1].view) |
| 3384 | | debug_view_set_property_UINT32(main_console->view[1].view, DVP_REGS_CPUNUM, cpunum); |
| 3128 | if (main_console->view[0].view != NULL) |
| 3129 | for (dasmsubitem = disasm_view_get_subview_list(main_console->view[0].view); dasmsubitem != NULL; dasmsubitem = dasmsubitem->next) |
| 3130 | if (dasmsubitem->space->cpu == device) |
| 3131 | { |
| 3132 | disasm_view_set_subview(main_console->view[0].view, dasmsubitem->index); |
| 3133 | break; |
| 3134 | } |
| 3135 | if (main_console->view[1].view != NULL) |
| 3136 | for (regsubitem = registers_view_get_subview_list(main_console->view[1].view); regsubitem != NULL; regsubitem = regsubitem->next) |
| 3137 | if (regsubitem->device == device) |
| 3138 | { |
| 3139 | registers_view_set_subview(main_console->view[1].view, regsubitem->index); |
| 3140 | break; |
| 3141 | } |
| 3385 | 3142 | |
| 3386 | 3143 | // then update the caption |
| 3387 | | snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU #%d \"%s\" (%s)", machine->gamedrv->name, cpunum, machine->config->cpu[cpunum].tag, cpu_get_name(machine->cpu[cpunum])); |
| 3144 | if (regsubitem != NULL) |
| 3145 | { |
| 3146 | snprintf(title, ARRAY_LENGTH(title), "Debug: %s - %s", device->machine->gamedrv->name, regsubitem->name); |
| 3388 | 3147 | |
| 3389 | | cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() ); |
| 3148 | cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() ); |
| 3390 | 3149 | |
| 3391 | | if ( cftitle ) |
| 3392 | | { |
| 3393 | | SetWindowTitleWithCFString( main_console->wnd, cftitle); |
| 3394 | | CFRelease( cftitle ); |
| 3150 | if ( cftitle ) |
| 3151 | { |
| 3152 | SetWindowTitleWithCFString( main_console->wnd, cftitle); |
| 3153 | CFRelease( cftitle ); |
| 3154 | } |
| 3395 | 3155 | } |
| 3396 | 3156 | } |
| 3397 | 3157 | |