Previous 15994 Revisions Next

r2914 Saturday 28th June, 2008 at 20:04:04 UTC by Wilbert Pol
[OSX debugger] Cleaned up u7/u8 update patch. Synced debugger functionality with mainline.
[src/osd/sdl]debugosx.c

src/osd/sdl/debugosx.c
r2913r2914
128128   ID_1_BYTE_CHUNKS,
129129   ID_2_BYTE_CHUNKS,
130130   ID_4_BYTE_CHUNKS,
131   ID_8_BYTE_CHUNKS,
132   ID_LOGICAL_ADDRESSES,
133   ID_PHYSICAL_ADDRESSES,
131134   ID_REVERSE_VIEW,
132135   ID_INCREASE_MEM_WIDTH,
133136   ID_DECREASE_MEM_WIDTH,
r2913r2914
237240
238241static EventHandlerRef keyEventHandler = NULL;
239242
243static int osx_inited_debugger = 0;
244
240245//============================================================
241246//  PROTOTYPES
242247//============================================================
243248
249static int debugwin_init_windows(void);
244250static debugwin_info *debug_window_create(const char * title, void *unused);
245251static void debug_window_free(debugwin_info *info);
246252static OSStatus debug_window_proc(EventHandlerCallRef inHandler, EventRef inEvent, void * inUserData);
r2913r2914
291297//  OSX stubs
292298//============================================================
293299
300INLINE 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
294314static void osx_SetFocus( HIViewRef inView )
295315{
296316   HIViewRef   focus;
r2913r2914
333353   outGlobalPoint->y += windBounds.top;
334354}
335355
336void osx_RectToHIRect( const Rect *inRect, HIRect *outRect )
356INLINE void osx_RectToHIRect( const Rect *inRect, HIRect *outRect )
337357{
338358   outRect->origin.x = inRect->left;
339359   outRect->origin.y = inRect->top;
r2913r2914
350370   EventRef      message;
351371   EventTargetRef   target = GetEventDispatcherTarget();
352372
373   osx_init_debugger();
374
353375   // create a console window
354376   if (!main_console)
355377      console_create_window();
r2913r2914
460482
461483void debugwin_update_during_game(void)
462484{
463   {
464      static int osx_inited_debugger = 0;
485   osx_init_debugger();
465486
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
477487   // if we're running live, do some checks
478488   if ( ! debug_cpu_is_stopped(Machine) )
479489   {
r2913r2914
18291839   Rect   bounds;
18301840
18311841   // 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);
18331843   info = debug_window_create(title, NULL);
18341844   if (!info || !debug_view_create(info, 0, type))
18351845      return;
r2913r2914
19051915   Rect bounds;
19061916
19071917   // 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);
19091919   info = debug_window_create(title, NULL);
19101920   if (!info || !debug_view_create(info, 0, DVT_LOG))
19111921      return;
r2913r2914
21052115   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, '2');
21062116   AppendMenuItemTextWithCFString( optionsmenu, CFSTR("4-byte chunks"), 0, ID_4_BYTE_CHUNKS, &menuIndex );
21072117   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, '4');
2118   AppendMenuItemTextWithCFString( optionsmenu, CFSTR("8-byte chunks"), 0, ID_8_BYTE_CHUNKS, &menuIndex );
2119   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, '8');
21082120   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 );
21092126   AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Reverse View"), 0, ID_REVERSE_VIEW, &menuIndex );
21102127   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'R');
21112128   AppendMenuItemTextWithCFString( optionsmenu, CFSTR("-"), kMenuItemAttrSeparator, 0, NULL );
r2913r2914
23242341      CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK) == 2));
23252342      GetIndMenuItemWithCommandID( info->contextualMenu, ID_4_BYTE_CHUNKS, 1, NULL, &menuindex);
23262343      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));
23272350      GetIndMenuItemWithCommandID( info->contextualMenu, ID_REVERSE_VIEW, 1, NULL, &menuindex);
23282351      CheckMenuItem(info->contextualMenu, menuindex, (debug_view_get_property_UINT32(info->view[0].view, DVP_MEM_REVERSE_VIEW)));
23292352   }
r2913r2914
23902413         memory_update_checkmarks(info);
23912414         return 1;
23922415
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
23932437      case ID_REVERSE_VIEW:
23942438         debug_view_begin_update(info->view[0].view);
23952439         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));
r2913r2914
24632507               memory_update_checkmarks(info);
24642508               return 1;
24652509
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
24662533            case 'r':
24672534            case 'R':
24682535               debug_view_begin_update(info->view[0].view);
r2913r2914
25492616   AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Encrypted opcodes"), 0, ID_SHOW_ENCRYPTED, &menuIndex );
25502617   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'E');
25512618   AppendMenuItemTextWithCFString( optionsmenu, CFSTR("Comments"), 0, ID_SHOW_COMMENTS, &menuIndex );
2552   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'C');
2619   SetMenuItemCommandKey(optionsmenu, menuIndex, FALSE, 'N');
25532620   info->contextualMenu = optionsmenu;
25542621   disasm_update_checkmarks(info);
25552622
r2913r2914
26132680            char         name[100];
26142681            UInt16         item;
26152682
2616            sprintf(name, "CPU #%d (%s)", cpunum, cpunum_name(cpunum));
2683            snprintf(name, ARRAY_LENGTH(name), "CPU #%d (%s)", cpunum, cpunum_name(cpunum));
26172684           
26182685            cfName = CFStringCreateWithCString( NULL, name, CFStringGetSystemEncoding() );
26192686            AppendMenuItemTextWithCFString( popupmenu, cfName, 0, 0, &item );
r2913r2914
29262993               (*info->recompute_children)(info);
29272994               return 1;
29282995           
2929            case 'c':
2930            case 'C':
2996            case 'n':
2997            case 'N':
29312998               debug_view_begin_update(info->view[0].view);
29322999               debug_view_set_property_UINT32(info->view[0].view, DVP_DASM_RIGHT_COLUMN, DVP_DASM_RIGHTCOL_COMMENTS);
29333000               debug_view_end_update(info->view[0].view);
r2913r2914
30123079   cpunum = debug_view_get_property_UINT32(info->view[0].view, DVP_DASM_CPUNUM);
30133080
30143081   // 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);
30163083
30173084   cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() );
30183085   
r2913r2914
30423109   MenuItemIndex   menuIndex;
30433110   ControlButtonContentInfo   content;
30443111
3045   debugwin_init_windows();
3046
30473112   // create the window
30483113   info = debug_window_create("Debug", NULL);
30493114   if (!info)
r2913r2914
33243389      debug_view_set_property_UINT32(main_console->view[1].view, DVP_REGS_CPUNUM, cpunum);
33253390
33263391   // 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());
33283393   
33293394   cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() );
33303395   

Previous 15994 Revisions Next


© 1998-2018 The MESS Team