diff --git a/src/osd/modules/debugger/debugosx.m b/src/osd/modules/debugger/debugosx.m index 460a666a5fb..3b9c971483b 100644 --- a/src/osd/modules/debugger/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -12,7 +12,7 @@ // TODO: // * Automatic scrolling for console and log views -// * Keyboard shortcuts in error log windows +// * Keyboard shortcuts in error log and devices windows // * Don't accept keyboard input while the game is running // * Interior focus rings - standard/exterior focus rings look really ugly here // * Improve automatic window sizing - it isn't working all that well diff --git a/src/osd/modules/debugger/osx/breakpointsview.h b/src/osd/modules/debugger/osx/breakpointsview.h index f2701200e25..e31a63aebed 100644 --- a/src/osd/modules/debugger/osx/breakpointsview.h +++ b/src/osd/modules/debugger/osx/breakpointsview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxbreakpointsview.h - MacOS X Cocoa debug window handling +// breakpointsview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/breakpointsview.m b/src/osd/modules/debugger/osx/breakpointsview.m index d84f1efbce1..97545370955 100644 --- a/src/osd/modules/debugger/osx/breakpointsview.m +++ b/src/osd/modules/debugger/osx/breakpointsview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxbreakpointsview.m - MacOS X Cocoa debug window handling +// breakpointsview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/consoleview.h b/src/osd/modules/debugger/osx/consoleview.h index 9ff4f15fa9f..5538ea49f28 100644 --- a/src/osd/modules/debugger/osx/consoleview.h +++ b/src/osd/modules/debugger/osx/consoleview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxconsoleview.h - MacOS X Cocoa debug window handling +// consoleview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/consoleview.m b/src/osd/modules/debugger/osx/consoleview.m index b0777cd2a84..3e2e29b9202 100644 --- a/src/osd/modules/debugger/osx/consoleview.m +++ b/src/osd/modules/debugger/osx/consoleview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxconsoleview.m - MacOS X Cocoa debug window handling +// consoleview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugcommandhistory.h b/src/osd/modules/debugger/osx/debugcommandhistory.h index 3cb0f23d06c..1e77b1f6cfb 100644 --- a/src/osd/modules/debugger/osx/debugcommandhistory.h +++ b/src/osd/modules/debugger/osx/debugcommandhistory.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugcommandhistory.h - MacOS X Cocoa debug window handling +// debugcommandhistory.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugcommandhistory.m b/src/osd/modules/debugger/osx/debugcommandhistory.m index b7f9e4bf91d..882c313000e 100644 --- a/src/osd/modules/debugger/osx/debugcommandhistory.m +++ b/src/osd/modules/debugger/osx/debugcommandhistory.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugcommandhistory.m - MacOS X Cocoa debug window handling +// debugcommandhistory.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugconsole.h b/src/osd/modules/debugger/osx/debugconsole.h index 24ed021fcb4..bf210458ed7 100644 --- a/src/osd/modules/debugger/osx/debugconsole.h +++ b/src/osd/modules/debugger/osx/debugconsole.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugconsole.h - MacOS X Cocoa debug window handling +// debugconsole.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -41,6 +41,7 @@ - (IBAction)debugNewDisassemblyWindow:(id)sender; - (IBAction)debugNewErrorLogWindow:(id)sender; - (IBAction)debugNewPointsWindow:(id)sender; +- (IBAction)debugNewDevicesWindow:(id)sender; - (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression; - (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression; diff --git a/src/osd/modules/debugger/osx/debugconsole.m b/src/osd/modules/debugger/osx/debugconsole.m index 3df65689e4f..bc290db2df8 100644 --- a/src/osd/modules/debugger/osx/debugconsole.m +++ b/src/osd/modules/debugger/osx/debugconsole.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugconsole.m - MacOS X Cocoa debug window handling +// debugconsole.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -14,6 +14,7 @@ #import "debugcommandhistory.h" #import "consoleview.h" #import "debugview.h" +#import "devicesviewer.h" #import "disassemblyview.h" #import "disassemblyviewer.h" #import "errorlogviewer.h" @@ -258,6 +259,14 @@ } +- (IBAction)debugNewDevicesWindow:(id)sender { + MAMEDevicesViewer *win = [[MAMEDevicesViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + [win activate]; +} + + - (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression { MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self]; [auxiliaryWindows addObject:win]; diff --git a/src/osd/modules/debugger/osx/debugosx.h b/src/osd/modules/debugger/osx/debugosx.h index 8971955dacb..016ea752e34 100644 --- a/src/osd/modules/debugger/osx/debugosx.h +++ b/src/osd/modules/debugger/osx/debugosx.h @@ -46,6 +46,9 @@ typedef float CGFloat; @protocol NSTextFieldDelegate @end +@protocol NSOutlineViewDataSource +@end + #endif // MAC_OS_X_VERSION_MAX_ALLOWED < 1060 #endif // MAC_OS_X_VERSION_MAX_ALLOWED diff --git a/src/osd/modules/debugger/osx/debugview.h b/src/osd/modules/debugger/osx/debugview.h index 56afd03351b..abb53efb852 100644 --- a/src/osd/modules/debugger/osx/debugview.h +++ b/src/osd/modules/debugger/osx/debugview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugview.h - MacOS X Cocoa debug window handling +// debugview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugview.m b/src/osd/modules/debugger/osx/debugview.m index 2167e4321be..8ce77b59cc3 100644 --- a/src/osd/modules/debugger/osx/debugview.m +++ b/src/osd/modules/debugger/osx/debugview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugview.h - MacOS X Cocoa debug window handling +// debugview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h index 4c157d825f8..56f3c98f9df 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.h +++ b/src/osd/modules/debugger/osx/debugwindowhandler.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugwindowhandler.h - MacOS X Cocoa debug window handling +// debugwindowhandler.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -72,6 +72,7 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification; - (IBAction)debugNewDisassemblyWindow:(id)sender; - (IBAction)debugNewErrorLogWindow:(id)sender; - (IBAction)debugNewPointsWindow:(id)sender; +- (IBAction)debugNewDevicesWindow:(id)sender; - (void)windowWillClose:(NSNotification *)notification; diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m index d26ca25979b..ba0a0d83351 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.m +++ b/src/osd/modules/debugger/osx/debugwindowhandler.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugwindowhandler.m - MacOS X Cocoa debug window handling +// debugwindowhandler.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -33,85 +33,86 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD @implementation MAMEDebugWindowHandler + (void)addCommonActionItems:(NSMenu *)menu { - { - NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" - action:@selector(debugRun:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; - NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; - [runParentItem setSubmenu:runMenu]; - [runMenu release]; - [runParentItem setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"and Hide Debugger" - action:@selector(debugRunAndHide:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"to Next CPU" - action:@selector(debugRunToNextCPU:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" - action:@selector(debugRunToNextInterrupt:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"until Next VBLANK" - action:@selector(debugRunToNextVBLANK:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] - setKeyEquivalentModifierMask:0]; - } - { - NSMenuItem *stepParentItem = [menu addItemWithTitle:@"Step" action:NULL keyEquivalent:@""]; - NSMenu *stepMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Step"]; - [stepParentItem setSubmenu:stepMenu]; - [stepMenu release]; - [[stepMenu addItemWithTitle:@"Into" - action:@selector(debugStepInto:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[stepMenu addItemWithTitle:@"Over" - action:@selector(debugStepOver:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[stepMenu addItemWithTitle:@"Out" - action:@selector(debugStepOut:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] - setKeyEquivalentModifierMask:NSShiftKeyMask]; - } - { - NSMenuItem *resetParentItem = [menu addItemWithTitle:@"Reset" action:NULL keyEquivalent:@""]; - NSMenu *resetMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset"]; - [resetParentItem setSubmenu:resetMenu]; - [resetMenu release]; - [[resetMenu addItemWithTitle:@"Soft" - action:@selector(debugSoftReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[resetMenu addItemWithTitle:@"Hard" - action:@selector(debugHardReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] - setKeyEquivalentModifierMask:NSShiftKeyMask]; - } + NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" + action:@selector(debugRun:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; + NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; + [runParentItem setSubmenu:runMenu]; + [runMenu release]; + [runParentItem setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"and Hide Debugger" + action:@selector(debugRunAndHide:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"to Next CPU" + action:@selector(debugRunToNextCPU:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" + action:@selector(debugRunToNextInterrupt:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"until Next VBLANK" + action:@selector(debugRunToNextVBLANK:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] + setKeyEquivalentModifierMask:0]; + + NSMenuItem *stepParentItem = [menu addItemWithTitle:@"Step" action:NULL keyEquivalent:@""]; + NSMenu *stepMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Step"]; + [stepParentItem setSubmenu:stepMenu]; + [stepMenu release]; + [[stepMenu addItemWithTitle:@"Into" + action:@selector(debugStepInto:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[stepMenu addItemWithTitle:@"Over" + action:@selector(debugStepOver:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[stepMenu addItemWithTitle:@"Out" + action:@selector(debugStepOut:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] + setKeyEquivalentModifierMask:NSShiftKeyMask]; + + NSMenuItem *resetParentItem = [menu addItemWithTitle:@"Reset" action:NULL keyEquivalent:@""]; + NSMenu *resetMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset"]; + [resetParentItem setSubmenu:resetMenu]; + [resetMenu release]; + [[resetMenu addItemWithTitle:@"Soft" + action:@selector(debugSoftReset:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[resetMenu addItemWithTitle:@"Hard" + action:@selector(debugHardReset:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] + setKeyEquivalentModifierMask:NSShiftKeyMask]; + [menu addItem:[NSMenuItem separatorItem]]; - { - NSMenuItem *newParentItem = [menu addItemWithTitle:@"New" action:NULL keyEquivalent:@""]; - NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"New"]; - [newParentItem setSubmenu:newMenu]; - [newMenu release]; - [newMenu addItemWithTitle:@"Memory Window" - action:@selector(debugNewMemoryWindow:) - keyEquivalent:@"d"]; - [newMenu addItemWithTitle:@"Disassembly Window" - action:@selector(debugNewDisassemblyWindow:) - keyEquivalent:@"a"]; - [newMenu addItemWithTitle:@"Error Log Window" - action:@selector(debugNewErrorLogWindow:) - keyEquivalent:@"l"]; - [newMenu addItemWithTitle:@"(Break|Watch)points Window" - action:@selector(debugNewPointsWindow:) - keyEquivalent:@"b"]; - } + + NSMenuItem *newParentItem = [menu addItemWithTitle:@"New" action:NULL keyEquivalent:@""]; + NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"New"]; + [newParentItem setSubmenu:newMenu]; + [newMenu release]; + [newMenu addItemWithTitle:@"Memory Window" + action:@selector(debugNewMemoryWindow:) + keyEquivalent:@"d"]; + [newMenu addItemWithTitle:@"Disassembly Window" + action:@selector(debugNewDisassemblyWindow:) + keyEquivalent:@"a"]; + [newMenu addItemWithTitle:@"Error Log Window" + action:@selector(debugNewErrorLogWindow:) + keyEquivalent:@"l"]; + [newMenu addItemWithTitle:@"(Break|Watch)points Window" + action:@selector(debugNewPointsWindow:) + keyEquivalent:@"b"]; + [newMenu addItemWithTitle:@"Devices Window" + action:@selector(debugNewDevicesWindow:) + keyEquivalent:@"D"]; + [menu addItem:[NSMenuItem separatorItem]]; + [menu addItemWithTitle:@"Close Window" action:@selector(performClose:) keyEquivalent:@"w"]; - [menu addItemWithTitle:@"Exit" action:@selector(debugExit:) keyEquivalent:@""]; + [menu addItemWithTitle:@"Quit" action:@selector(debugExit:) keyEquivalent:@"q"]; } @@ -298,6 +299,11 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD } +- (IBAction)debugNewDevicesWindow:(id)sender { + [console debugNewDevicesWindow:sender]; +} + + - (void)windowWillClose:(NSNotification *)notification { [[NSNotificationCenter defaultCenter] postNotificationName:MAMEAuxiliaryDebugWindowWillCloseNotification object:self]; @@ -314,7 +320,7 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD windowFrame.size.width += desired.width; windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); windowFrame.size.height += desired.height; - windowFrame.size.height = MIN(MIN(windowFrame.size.height, 240), available.size.height); + windowFrame.size.height = MIN(MIN(windowFrame.size.height, 320), available.size.height); windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; windowFrame.origin.y = available.origin.y; [window setFrame:windowFrame display:YES]; diff --git a/src/osd/modules/debugger/osx/devicesviewer.h b/src/osd/modules/debugger/osx/devicesviewer.h new file mode 100644 index 00000000000..3737a497163 --- /dev/null +++ b/src/osd/modules/debugger/osx/devicesviewer.h @@ -0,0 +1,31 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// devicesviewer.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugConsole, MAMEDeviceWrapper; + +@interface MAMEDevicesViewer : MAMEAuxiliaryDebugWindowHandler +{ + MAMEDeviceWrapper *root; + NSOutlineView *devicesView; +} + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; + +@end diff --git a/src/osd/modules/debugger/osx/devicesviewer.m b/src/osd/modules/debugger/osx/devicesviewer.m new file mode 100644 index 00000000000..29910c57c40 --- /dev/null +++ b/src/osd/modules/debugger/osx/devicesviewer.m @@ -0,0 +1,210 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// devicesviewer.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "devicesviewer.h" + + +@interface MAMEDeviceWrapper : NSObject +{ + running_machine *machine; + device_t *device; + NSArray *children; +} + +- (id)initWithMachine:(running_machine &)m device:(device_t &)d; + +- (running_machine &)machine; +- (device_t &)device; +- (NSString *)tag; +- (NSString *)name; +- (NSUInteger)children; +- (MAMEDeviceWrapper *)childAtIndex:(NSUInteger)index; + +@end + + +@implementation MAMEDeviceWrapper + +- (void)wrapChildren { + NSMutableArray *const tmp = [[NSMutableArray alloc] init]; + for (device_t *child = device->first_subdevice(); child != NULL; child = child->next()) + { + MAMEDeviceWrapper *const wrap = [[MAMEDeviceWrapper alloc] initWithMachine:*machine + device:*child]; + [tmp addObject:wrap]; + [wrap release]; + } + children = [[NSArray alloc] initWithArray:tmp]; + [tmp release]; +} + + +- (id)initWithMachine:(running_machine &)m device:(device_t &)d { + if (!(self = [super init])) + return nil; + machine = &m; + device = &d; + children = nil; + return self; +} + + +- (void)dealloc { + if (children != nil) + [children release]; + [super dealloc]; +} + + +- (running_machine &)machine { + return *machine; +} + + +- (device_t &)device { + return *device; +} + + +- (NSString *)tag { + return (device == &machine->root_device()) ? @"" + : [NSString stringWithUTF8String:device->basetag()]; +} + + +- (NSString *)name { + return [NSString stringWithUTF8String:device->name()]; +} + + +- (NSUInteger)children { + if (children == nil) + [self wrapChildren]; + return [children count]; +} + + +- (MAMEDeviceWrapper *)childAtIndex:(NSUInteger)index { + if (children == nil) + [self wrapChildren]; + return (index < [children count]) ? [children objectAtIndex:index] : nil; +} + +@end + + +@implementation MAMEDevicesViewer + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { + NSScrollView *devicesScroll; + NSTableColumn *tagColumn, *nameColumn; + + if (!(self = [super initWithMachine:m title:@"All Devices" console:c])) + return nil; + root = [[MAMEDeviceWrapper alloc] initWithMachine:m device:m.root_device()]; + + // create the devices view + devicesView = [[NSOutlineView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [devicesView setUsesAlternatingRowBackgroundColors:YES]; + [devicesView setAllowsColumnReordering:YES]; + [devicesView setAllowsColumnResizing:YES]; + [devicesView setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; + [devicesView setAllowsEmptySelection:YES]; + [devicesView setAllowsMultipleSelection:NO]; + [devicesView setAllowsColumnSelection:NO]; + tagColumn = [[NSTableColumn alloc] initWithIdentifier:@"tag"]; + [[tagColumn headerCell] setStringValue:@"Tag"]; + [tagColumn setEditable:NO]; + [tagColumn setMinWidth:100]; + [tagColumn setWidth:120]; + [tagColumn setResizingMask:(NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)]; + [devicesView addTableColumn:tagColumn]; + [tagColumn release]; + nameColumn = [[NSTableColumn alloc] initWithIdentifier:@"name"]; + [[nameColumn headerCell] setStringValue:@"Name"]; + [nameColumn setEditable:NO]; + [nameColumn setMinWidth:100]; + [nameColumn setMinWidth:360]; + [nameColumn setResizingMask:(NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)]; + [devicesView addTableColumn:nameColumn]; + [nameColumn release]; + [devicesView setOutlineTableColumn:tagColumn]; + [devicesView setAutoresizesOutlineColumn:YES]; + [devicesView setDataSource:self]; + devicesScroll = [[NSScrollView alloc] initWithFrame:[[window contentView] bounds]]; + [devicesScroll setDrawsBackground:YES]; + [devicesScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [devicesScroll setHasHorizontalScroller:YES]; + [devicesScroll setHasVerticalScroller:YES]; + [devicesScroll setAutohidesScrollers:YES]; + [devicesScroll setBorderType:NSNoBorder]; + [devicesScroll setDocumentView:devicesView]; + [devicesView release]; + [[window contentView] addSubview:devicesScroll]; + [devicesScroll release]; + + // set default state + [devicesView expandItem:root expandChildren:YES]; + [window makeFirstResponder:devicesView]; + [window setTitle:[NSString stringWithFormat:@"All Devices"]]; + + // calculate the optimal size for everything + NSSize const desired = [NSScrollView frameSizeForContentSize:NSMakeSize(480, 320) + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[devicesScroll borderType]]; + [self cascadeWindowWithDesiredSize:desired forView:devicesScroll]; + + // don't forget the result + return self; +} + + +- (void)dealloc { + if (root != nil) + [root release]; + [super dealloc]; +} + + +- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { + return [(MAMEDeviceWrapper *)item children] > 0; +} + + +- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { + if (item != nil) + return [(MAMEDeviceWrapper *)item children]; + else + return 1; +} + + +- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { + if (item != nil) + return [(MAMEDeviceWrapper *)item childAtIndex:index]; + else if (index == 0) + return root; + else + return nil; +} + + +- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { + if ([[tableColumn identifier] isEqualToString:@"tag"]) + return [(MAMEDeviceWrapper *)item tag]; + else if ([[tableColumn identifier] isEqualToString:@"name"]) + return [(MAMEDeviceWrapper *)item name]; + else + return nil; +} + +@end diff --git a/src/osd/modules/debugger/osx/disassemblyview.h b/src/osd/modules/debugger/osx/disassemblyview.h index 534f6f7fb40..40d2b04f379 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.h +++ b/src/osd/modules/debugger/osx/disassemblyview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyview.h - MacOS X Cocoa debug window handling +// disassemblyview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/disassemblyview.m b/src/osd/modules/debugger/osx/disassemblyview.m index 9ddd31d60f5..f5e5864372b 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.m +++ b/src/osd/modules/debugger/osx/disassemblyview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyview.m - MacOS X Cocoa debug window handling +// disassemblyview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.h b/src/osd/modules/debugger/osx/disassemblyviewer.h index 6027d3c13da..27099aa9dc7 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.h +++ b/src/osd/modules/debugger/osx/disassemblyviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyviewer.h - MacOS X Cocoa debug window handling +// disassemblyviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.m b/src/osd/modules/debugger/osx/disassemblyviewer.m index 0342ad83315..7fcbb842b2d 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.m +++ b/src/osd/modules/debugger/osx/disassemblyviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyviewer.m - MacOS X Cocoa debug window handling +// disassemblyviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -24,11 +24,11 @@ NSScrollView *dasmScroll; NSView *expressionContainer; NSPopUpButton *actionButton; - NSRect contentBounds, expressionFrame; + NSRect expressionFrame; if (!(self = [super initWithMachine:m title:@"Disassembly" console:c])) return nil; - contentBounds = [[window contentView] bounds]; + NSRect const contentBounds = [[window contentView] bounds]; // create the expression field expressionField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; @@ -108,13 +108,11 @@ [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; // calculate the optimal size for everything - { - NSSize desired = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[dasmScroll borderType]]; - [self cascadeWindowWithDesiredSize:desired forView:dasmScroll]; - } + NSSize const desired = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[dasmScroll borderType]]; + [self cascadeWindowWithDesiredSize:desired forView:dasmScroll]; // don't forget the result return self; diff --git a/src/osd/modules/debugger/osx/errorlogview.h b/src/osd/modules/debugger/osx/errorlogview.h index 168511c1819..bcb6a541a8c 100644 --- a/src/osd/modules/debugger/osx/errorlogview.h +++ b/src/osd/modules/debugger/osx/errorlogview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogview.h - MacOS X Cocoa debug window handling +// errorlogview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/errorlogview.m b/src/osd/modules/debugger/osx/errorlogview.m index 6ba563b071a..80380bc1e16 100644 --- a/src/osd/modules/debugger/osx/errorlogview.m +++ b/src/osd/modules/debugger/osx/errorlogview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogview.m - MacOS X Cocoa debug window handling +// errorlogview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/errorlogviewer.h b/src/osd/modules/debugger/osx/errorlogviewer.h index c2728298c14..22538f81307 100644 --- a/src/osd/modules/debugger/osx/errorlogviewer.h +++ b/src/osd/modules/debugger/osx/errorlogviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogviewer.h - MacOS X Cocoa debug window handling +// errorlogviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/errorlogviewer.m b/src/osd/modules/debugger/osx/errorlogviewer.m index 44189922f91..f049286aaa4 100644 --- a/src/osd/modules/debugger/osx/errorlogviewer.m +++ b/src/osd/modules/debugger/osx/errorlogviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogviewer.m - MacOS X Cocoa debug window handling +// errorlogviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryview.h b/src/osd/modules/debugger/osx/memoryview.h index c6bd9c65baf..1336426c896 100644 --- a/src/osd/modules/debugger/osx/memoryview.h +++ b/src/osd/modules/debugger/osx/memoryview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryview.h - MacOS X Cocoa debug window handling +// memoryview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryview.m b/src/osd/modules/debugger/osx/memoryview.m index 8883fc303d7..0f02fac83ef 100644 --- a/src/osd/modules/debugger/osx/memoryview.m +++ b/src/osd/modules/debugger/osx/memoryview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryview.m - MacOS X Cocoa debug window handling +// memoryview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryviewer.h b/src/osd/modules/debugger/osx/memoryviewer.h index 4180f0a6ee7..63c9d4eea2b 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.h +++ b/src/osd/modules/debugger/osx/memoryviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryviewer.h - MacOS X Cocoa debug window handling +// memoryviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryviewer.m b/src/osd/modules/debugger/osx/memoryviewer.m index 5412cc6457d..517efa9fd0a 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.m +++ b/src/osd/modules/debugger/osx/memoryviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryviewer.m - MacOS X Cocoa debug window handling +// memoryviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/pointsviewer.h b/src/osd/modules/debugger/osx/pointsviewer.h index 5df282ef850..3943f6b486f 100644 --- a/src/osd/modules/debugger/osx/pointsviewer.h +++ b/src/osd/modules/debugger/osx/pointsviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxpointsviewer.h - MacOS X Cocoa debug window handling +// pointsviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/pointsviewer.m b/src/osd/modules/debugger/osx/pointsviewer.m index 27c8f36417e..7c85324fd70 100644 --- a/src/osd/modules/debugger/osx/pointsviewer.m +++ b/src/osd/modules/debugger/osx/pointsviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxpointsviewer.m - MacOS X Cocoa debug window handling +// pointsviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/registersview.h b/src/osd/modules/debugger/osx/registersview.h index ec6f6cca5f8..90e656104fc 100644 --- a/src/osd/modules/debugger/osx/registersview.h +++ b/src/osd/modules/debugger/osx/registersview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxregistersview.h - MacOS X Cocoa debug window handling +// registersview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/registersview.m b/src/osd/modules/debugger/osx/registersview.m index 5768635f127..50191b4c9a5 100644 --- a/src/osd/modules/debugger/osx/registersview.m +++ b/src/osd/modules/debugger/osx/registersview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxregistersview.m - MacOS X Cocoa debug window handling +// registersview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/watchpointsview.h b/src/osd/modules/debugger/osx/watchpointsview.h index 23379de570c..0480c685d20 100644 --- a/src/osd/modules/debugger/osx/watchpointsview.h +++ b/src/osd/modules/debugger/osx/watchpointsview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxwatchpointsview.h - MacOS X Cocoa debug window handling +// watchpointsview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/watchpointsview.m b/src/osd/modules/debugger/osx/watchpointsview.m index 34dc5858a48..0b1ab9ae39c 100644 --- a/src/osd/modules/debugger/osx/watchpointsview.m +++ b/src/osd/modules/debugger/osx/watchpointsview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxwatchpointsview.m - MacOS X Cocoa debug window handling +// watchpointsview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 423e4422954..198ef34c339 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -295,6 +295,7 @@ DEBUGOBJS = \ $(OSDOBJ)/modules/debugger/osx/debugconsole.o \ $(OSDOBJ)/modules/debugger/osx/debugview.o \ $(OSDOBJ)/modules/debugger/osx/debugwindowhandler.o \ + $(OSDOBJ)/modules/debugger/osx/devicesviewer.o \ $(OSDOBJ)/modules/debugger/osx/disassemblyview.o \ $(OSDOBJ)/modules/debugger/osx/disassemblyviewer.o \ $(OSDOBJ)/modules/debugger/osx/errorlogview.o \