src/osd/sdl/debugosx.c
| r2913 | r2914 | |
| 128 | 128 | ID_1_BYTE_CHUNKS, |
| 129 | 129 | ID_2_BYTE_CHUNKS, |
| 130 | 130 | ID_4_BYTE_CHUNKS, |
| 131 | ID_8_BYTE_CHUNKS, |
| 132 | ID_LOGICAL_ADDRESSES, |
| 133 | ID_PHYSICAL_ADDRESSES, |
| 131 | 134 | ID_REVERSE_VIEW, |
| 132 | 135 | ID_INCREASE_MEM_WIDTH, |
| 133 | 136 | ID_DECREASE_MEM_WIDTH, |
| r2913 | r2914 | |
| 237 | 240 | |
| 238 | 241 | static EventHandlerRef keyEventHandler = NULL; |
| 239 | 242 | |
| 243 | static int osx_inited_debugger = 0; |
| 244 | |
| 240 | 245 | //============================================================ |
| 241 | 246 | // PROTOTYPES |
| 242 | 247 | //============================================================ |
| 243 | 248 | |
| 249 | static int debugwin_init_windows(void); |
| 244 | 250 | static debugwin_info *debug_window_create(const char * title, void *unused); |
| 245 | 251 | static void debug_window_free(debugwin_info *info); |
| 246 | 252 | static OSStatus debug_window_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData); |
| r2913 | r2914 | |
| 291 | 297 | // OSX stubs |
| 292 | 298 | //============================================================ |
| 293 | 299 | |
| 300 | INLINE void osx_init_debugger( void ) |
| 301 | { |
| 302 | if ( osx_inited_debugger == 0 ) |
| 303 | { |
| 304 | if ( debugwin_init_windows() != 0 ) |
| 305 | { |
| 306 | mame_printf_error( "Could not init debugger\n" ); |
| 307 | exit( -1 ); |
| 308 | } |
| 309 | osx_inited_debugger = 1; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 294 | 314 | static void osx_SetFocus( HIViewRef inView ) |
| 295 | 315 | { |
| 296 | 316 | HIViewRef focus; |
| r2913 | r2914 | |
| 333 | 353 | outGlobalPoint->y += windBounds.top; |
| 334 | 354 | } |
| 335 | 355 | |
| 336 | | void osx_RectToHIRect( const Rect *inRect, HIRect *outRect ) |
| 356 | INLINE void osx_RectToHIRect( const Rect *inRect, HIRect *outRect ) |
| 337 | 357 | { |
| 338 | 358 | outRect->origin.x = inRect->left; |
| 339 | 359 | outRect->origin.y = inRect->top; |
| r2913 | r2914 | |
| 350 | 370 | EventRef message; |
| 351 | 371 | EventTargetRef target = GetEventDispatcherTarget(); |
| 352 | 372 | |
| 373 | osx_init_debugger(); |
| 374 | |
| 353 | 375 | // create a console window |
| 354 | 376 | if (!main_console) |
| 355 | 377 | console_create_window(); |
| r2913 | r2914 | |
| 460 | 482 | |
| 461 | 483 | void debugwin_update_during_game(void) |
| 462 | 484 | { |
| 463 | | { |
| 464 | | static int osx_inited_debugger = 0; |
| 485 | osx_init_debugger(); |
| 465 | 486 | |
| 466 | | if ( osx_inited_debugger == 0 ) |
| 467 | | { |
| 468 | | if ( debugwin_init_windows() != 0 ) |
| 469 | | { |
| 470 | | mame_printf_error( "Could not init debugger\n" ); |
| 471 | | exit( -1 ); |
| 472 | | } |
| 473 | | osx_inited_debugger = 1; |
| 474 | | } |
| 475 | | } |
| 476 | | |
| 477 | 487 | // if we're running live, do some checks |
| 478 | 488 | if ( ! debug_cpu_is_stopped(Machine) ) |
| 479 | 489 | { |
| r2913 | r2914 | |
| 1829 | 1839 | Rect bounds; |
| 1830 | 1840 | |
| 1831 | 1841 | // create the window |
| 1832 | | sprintf(title, "Debug: %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); |
| 1842 | snprintf(title, ARRAY_LENGTH(title), "Debug: %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); |
| 1833 | 1843 | info = debug_window_create(title, NULL); |
| 1834 | 1844 | if (!info || !debug_view_create(info, 0, type)) |
| 1835 | 1845 | return; |
| r2913 | r2914 | |
| 1905 | 1915 | Rect bounds; |
| 1906 | 1916 | |
| 1907 | 1917 | // create the window |
| 1908 | | sprintf(title, "Errorlog: %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); |
| 1918 | snprintf(title, ARRAY_LENGTH(title), "Errorlog: %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); |
| 1909 | 1919 | info = debug_window_create(title, NULL); |
| 1910 | 1920 | if (!info || !debug_view_create(info, 0, DVT_LOG)) |
| 1911 | 1921 | return; |
| r2913 | r2914 | |
| 2105 | 2115 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, '2'); |
| 2106 | 2116 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("4-byte chunks"), 0, ID_4_BYTE_CHUNKS, &menuIndex ); |
| 2107 | 2117 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, '4'); |
| 2118 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("8-byte chunks"), 0, ID_8_BYTE_CHUNKS, &menuIndex ); |
| 2119 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, '8'); |
| 2108 | 2120 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("-"), kMenuItemAttrSeparator, 0, NULL ); |
| 2121 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Logical Addresses"), 0, ID_LOGICAL_ADDRESSES, &menuIndex ); |
| 2122 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'L'); |
| 2123 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Physical Addresses"), 0, ID_PHYSICAL_ADDRESSES, &menuIndex ); |
| 2124 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'Y'); |
| 2125 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("-"), kMenuItemAttrSeparator, 0, NULL ); |
| 2109 | 2126 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Reverse View"), 0, ID_REVERSE_VIEW, &menuIndex ); |
| 2110 | 2127 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'R'); |
| 2111 | 2128 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("-"), kMenuItemAttrSeparator, 0, NULL ); |
| r2913 | r2914 | |
| 2324 | 2341 | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 2)); |
| 2325 | 2342 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_4_BYTE_CHUNKS, 1, NULL, &menuindex); |
| 2326 | 2343 | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 4)); |
| 2344 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_8_BYTE_CHUNKS, 1, NULL, &menuindex); |
| 2345 | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 8)); |
| 2346 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_LOGICAL_ADDRESSES, 1, NULL, &menuindex); |
| 2347 | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION) == 0)); |
| 2348 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_PHYSICAL_ADDRESSES, 1, NULL, &menuindex); |
| 2349 | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION) != 0)); |
| 2327 | 2350 | GetIndMenuItemWithCommandID( info->contextualMenu, ID_REVERSE_VIEW, 1, NULL, &menuindex); |
| 2328 | 2351 | CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW))); |
| 2329 | 2352 | } |
| r2913 | r2914 | |
| 2390 | 2413 | memory_update_checkmarks(info); |
| 2391 | 2414 | return 1; |
| 2392 | 2415 | |
| 2416 | case ID_8_BYTE_CHUNKS: |
| 2417 | debug_view_begin_update(info->view[0].view); |
| 2418 | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 8); |
| 2419 | debug_view_end_update(info->view[0].view); |
| 2420 | memory_update_checkmarks(info); |
| 2421 | return 1; |
| 2422 | |
| 2423 | case ID_LOGICAL_ADDRESSES: |
| 2424 | debug_view_begin_update(info->view[0].view); |
| 2425 | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, FALSE); |
| 2426 | debug_view_end_update(info->view[0].view); |
| 2427 | memory_update_checkmarks(info); |
| 2428 | return 1; |
| 2429 | |
| 2430 | case ID_PHYSICAL_ADDRESSES: |
| 2431 | debug_view_begin_update(info->view[0].view); |
| 2432 | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, TRUE); |
| 2433 | debug_view_end_update(info->view[0].view); |
| 2434 | memory_update_checkmarks(info); |
| 2435 | return 1; |
| 2436 | |
| 2393 | 2437 | case ID_REVERSE_VIEW: |
| 2394 | 2438 | debug_view_begin_update(info->view[0].view); |
| 2395 | 2439 | 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)); |
| r2913 | r2914 | |
| 2463 | 2507 | memory_update_checkmarks(info); |
| 2464 | 2508 | return 1; |
| 2465 | 2509 | |
| 2510 | case '8': |
| 2511 | debug_view_begin_update(info->view[0].view); |
| 2512 | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, 8); |
| 2513 | debug_view_end_update(info->view[0].view); |
| 2514 | memory_update_checkmarks(info); |
| 2515 | return 1; |
| 2516 | |
| 2517 | case 'l': |
| 2518 | case 'L': |
| 2519 | debug_view_begin_update(info->view[0].view); |
| 2520 | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, FALSE); |
| 2521 | debug_view_end_update(info->view[0].view); |
| 2522 | memory_update_checkmarks(info); |
| 2523 | return 1; |
| 2524 | |
| 2525 | case 'y': |
| 2526 | case 'Y': |
| 2527 | debug_view_begin_update(info->view[0].view); |
| 2528 | debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_NO_TRANSLATION, TRUE); |
| 2529 | debug_view_end_update(info->view[0].view); |
| 2530 | memory_update_checkmarks(info); |
| 2531 | return 1; |
| 2532 | |
| 2466 | 2533 | case 'r': |
| 2467 | 2534 | case 'R': |
| 2468 | 2535 | debug_view_begin_update(info->view[0].view); |
| r2913 | r2914 | |
| 2549 | 2616 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Encrypted opcodes"), 0, ID_SHOW_ENCRYPTED, &menuIndex ); |
| 2550 | 2617 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'E'); |
| 2551 | 2618 | AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Comments"), 0, ID_SHOW_COMMENTS, &menuIndex ); |
| 2552 | | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'C'); |
| 2619 | SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'N'); |
| 2553 | 2620 | info->contextualMenu = optionsmenu; |
| 2554 | 2621 | disasm_update_checkmarks(info); |
| 2555 | 2622 | |
| r2913 | r2914 | |
| 2613 | 2680 | char name[100]; |
| 2614 | 2681 | UInt16 item; |
| 2615 | 2682 | |
| 2616 | | sprintf(name, "CPU #%d (%s)", cpunum, cpunum_name(cpunum)); |
| 2683 | snprintf(name, ARRAY_LENGTH(name), "CPU #%d (%s)", cpunum, cpunum_name(cpunum)); |
| 2617 | 2684 | |
| 2618 | 2685 | cfName = CFStringCreateWithCString( NULL, name, CFStringGetSystemEncoding() ); |
| 2619 | 2686 | AppendMenuItemTextWithCFString( popupmenu, cfName, 0, 0, &item ); |
| r2913 | r2914 | |
| 2926 | 2993 | (*info->recompute_children)(info); |
| 2927 | 2994 | return 1; |
| 2928 | 2995 | |
| 2929 | | case 'c': |
| 2930 | | case 'C': |
| 2996 | case 'n': |
| 2997 | case 'N': |
| 2931 | 2998 | debug_view_begin_update(info->view[0].view); |
| 2932 | 2999 | debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_COMMENTS); |
| 2933 | 3000 | debug_view_end_update(info->view[0].view); |
| r2913 | r2914 | |
| 3012 | 3079 | cpunum = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM); |
| 3013 | 3080 | |
| 3014 | 3081 | // then update the caption |
| 3015 | | sprintf(title, "Disassembly: %s (%d)", cpunum_name(cpunum), cpunum); |
| 3082 | snprintf(title, ARRAY_LENGTH(title), "Disassembly: %s (%d)", cpunum_name(cpunum), cpunum); |
| 3016 | 3083 | |
| 3017 | 3084 | cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() ); |
| 3018 | 3085 | |
| r2913 | r2914 | |
| 3042 | 3109 | MenuItemIndex menuIndex; |
| 3043 | 3110 | ControlButtonContentInfo content; |
| 3044 | 3111 | |
| 3045 | | debugwin_init_windows(); |
| 3046 | | |
| 3047 | 3112 | // create the window |
| 3048 | 3113 | info = debug_window_create("Debug", NULL); |
| 3049 | 3114 | if (!info) |
| r2913 | r2914 | |
| 3324 | 3389 | debug_view_set_property_UINT32(main_console->view[1].view, DVP_REGS_CPUNUM, cpunum); |
| 3325 | 3390 | |
| 3326 | 3391 | // then update the caption |
| 3327 | | sprintf(title, "Debug: %s - CPU %d (%s)", Machine->gamedrv->name, cpu_getactivecpu(), activecpu_name()); |
| 3392 | snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU %d (%s)", Machine->gamedrv->name, cpu_getactivecpu(), activecpu_name()); |
| 3328 | 3393 | |
| 3329 | 3394 | cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() ); |
| 3330 | 3395 | |