Previous 199869 Revisions Next

r35085 Tuesday 17th February, 2015 at 06:31:52 UTC by Vasantha Crabb
* Map visited to a background colour
* Allocate colours once only
* Make disassembly view context menu easier to use again
* Console feedback for breakpoint changes
* Update views for breakpoint changes
* Map Option-/Command-click to middle/right click
* Disassembly/memory views inherit focus from parent window
[src/osd/modules/debugger]debugosx.m
[src/osd/modules/debugger/osx]debugconsole.h debugconsole.m debugview.h debugview.m debugwindowhandler.h debugwindowhandler.m disassemblyview.h disassemblyview.m disassemblyviewer.h disassemblyviewer.m memoryview.h memoryview.m memoryviewer.h memoryviewer.m registersview.h registersview.m

trunk/src/osd/modules/debugger/debugosx.m
r243596r243597
1212
1313// TODO:
1414//  * Automatic scrolling for console and log views
15//  * Using alpha for disabled foreground colours doesn't really work
16//  * New windows created from auxiliary windows should inherit focus rather than pointing at current CPU
1715//  * Keyboard shortcuts in error log windows
1816//  * Don't accept keyboard input while the game is running
1917//  * Interior focus rings - standard/exterior focus rings look really ugly here
18//  * Improve automatic window sizing - it isn't working all that well
19//  * Updates causing debug views' widths to change are sometimes obscured by the scroll views' opaque backgrounds
2020//  * Scroll views with content narrower than clipping area are flaky under Tiger - nothing I can do about this
2121
2222
r243596r243597
9797   if (firststop) {
9898      NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:[NSValue valueWithPointer:&device],
9999                                                      @"MAMEDebugDevice",
100                                                      [NSValue valueWithPointer:m_machine],
101                                                      @"MAMEDebugMachine",
100102                                                      nil];
101103      [[NSNotificationCenter defaultCenter] postNotificationName:MAMEShowDebuggerNotification
102104                                             object:m_console
trunk/src/osd/modules/debugger/osx/debugconsole.h
r243596r243597
4242- (IBAction)debugNewErrorLogWindow:(id)sender;
4343- (IBAction)debugNewPointsWindow:(id)sender;
4444
45- (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression;
46- (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression;
47
4548- (void)showDebugger:(NSNotification *)notification;
4649- (void)auxiliaryWindowWillClose:(NSNotification *)notification;
4750
trunk/src/osd/modules/debugger/osx/debugconsole.m
r243596r243597
135135   [window makeFirstResponder:commandField];
136136
137137   // calculate the optimal size for everything
138   {
139      NSRect   available = [[NSScreen mainScreen] visibleFrame];
140      NSRect   windowFrame = [window frame];
141      NSSize   regCurrent = [regScroll frame].size;
142      NSSize   regSize = [NSScrollView frameSizeForContentSize:[regView maximumFrameSize]
143                               hasHorizontalScroller:YES
144                                 hasVerticalScroller:YES
145                                       borderType:[regScroll borderType]];
146      NSSize   dasmCurrent = [dasmScroll frame].size;
147      NSSize   dasmSize = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize]
138   NSRect   available = [[NSScreen mainScreen] visibleFrame];
139   NSRect   windowFrame = [window frame];
140   NSSize   regCurrent = [regScroll frame].size;
141   NSSize   regSize = [NSScrollView frameSizeForContentSize:[regView maximumFrameSize]
142                             hasHorizontalScroller:YES
143                              hasVerticalScroller:YES
144                                     borderType:[regScroll borderType]];
145   NSSize   dasmCurrent = [dasmScroll frame].size;
146   NSSize   dasmSize = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize]
147                             hasHorizontalScroller:YES
148                              hasVerticalScroller:YES
149                                     borderType:[dasmScroll borderType]];
150   NSSize   consoleCurrent = [consoleContainer frame].size;
151   NSSize   consoleSize = [NSScrollView frameSizeForContentSize:[consoleView maximumFrameSize]
148152                                hasHorizontalScroller:YES
149153                                 hasVerticalScroller:YES
150                                        borderType:[dasmScroll borderType]];
151      NSSize   consoleCurrent = [consoleContainer frame].size;
152      NSSize   consoleSize = [NSScrollView frameSizeForContentSize:[consoleView maximumFrameSize]
153                                  hasHorizontalScroller:YES
154                                    hasVerticalScroller:YES
155                                          borderType:[consoleScroll borderType]];
156      NSSize   adjustment;
157      NSRect   lhsFrame, rhsFrame;
154                                        borderType:[consoleScroll borderType]];
155   NSSize   adjustment;
158156
159      consoleSize.width += consoleCurrent.width - [consoleScroll frame].size.width;
160      consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height;
161      adjustment.width = regSize.width - regCurrent.width;
162      adjustment.height = regSize.height - regCurrent.height;
163      adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width);
157   consoleSize.width += consoleCurrent.width - [consoleScroll frame].size.width;
158   consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height;
159   adjustment.width = regSize.width - regCurrent.width;
160   adjustment.height = regSize.height - regCurrent.height;
161   adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width);
164162
165      windowFrame.size.width += adjustment.width;
166      windowFrame.size.height += adjustment.height; // not used - better to go for fixed height
167      windowFrame.size.height = MIN(512.0, available.size.height);
168      windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
169      windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
170      windowFrame.origin.y = available.origin.y;
171      [window setFrame:windowFrame display:YES];
163   windowFrame.size.width += adjustment.width;
164   windowFrame.size.height += adjustment.height; // not used - better to go for fixed height
165   windowFrame.size.height = MIN(512.0, available.size.height);
166   windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
167   windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
168   windowFrame.origin.y = available.origin.y;
169   [window setFrame:windowFrame display:YES];
172170
173      lhsFrame = [regScroll frame];
174      rhsFrame = [dasmSplit frame];
175      adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2);
176      rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width;
177      rhsFrame.size.width += lhsFrame.size.width - adjustment.width;
178      lhsFrame.size.width = adjustment.width;
179      [regScroll setFrame:lhsFrame];
180      [dasmSplit setFrame:rhsFrame];
181   }
171   NSRect lhsFrame = [regScroll frame];
172   NSRect rhsFrame = [dasmSplit frame];
173   adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2);
174   rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width;
175   rhsFrame.size.width += lhsFrame.size.width - adjustment.width;
176   lhsFrame.size.width = adjustment.width;
177   [regScroll setFrame:lhsFrame];
178   [dasmSplit setFrame:rhsFrame];
182179
183180   // select the current processor
184181   [self setCPU:machine->firstcpu];
r243596r243597
206203
207204
208205- (void)setCPU:(device_t *)device {
209   [regView selectSubviewForCPU:device];
210   [dasmView selectSubviewForCPU:device];
206   [regView selectSubviewForDevice:device];
207   [dasmView selectSubviewForDevice:device];
211208   [window setTitle:[NSString stringWithFormat:@"Debug: %s - %s '%s'",
212209                                    device->machine().system().name,
213210                                    device->name(),
r243596r243597
261258}
262259
263260
261- (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression {
262   MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self];
263   [auxiliaryWindows addObject:win];
264   [win release];
265   if ([win selectSubviewForSpace:space])
266   {
267      if (expression != nil)
268         [win setExpression:expression];
269   }
270   else
271   {
272      [win selectSubviewForDevice:device];
273   }
274   [win activate];
275}
276
277
278- (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression {
279   MAMEDisassemblyViewer *win = [[MAMEDisassemblyViewer alloc] initWithMachine:*machine console:self];
280   [auxiliaryWindows addObject:win];
281   [win release];
282   if ([win selectSubviewForSpace:space])
283   {
284      if (expression != nil)
285         [win setExpression:expression];
286   }
287   else
288   {
289      [win selectSubviewForDevice:device];
290   }
291   [win activate];
292}
293
294
264295- (void)showDebugger:(NSNotification *)notification {
265296   device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue];
266   if (&device->machine() == machine) {
297   if (&device->machine() == machine)
298   {
267299      [self setCPU:device];
268300      [window makeKeyAndOrderFront:self];
269301   }
r243596r243597
312344
313345
314346- (void)windowWillClose:(NSNotification *)notification {
315   if ([notification object] != window)
316      return;
317   [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification object:self];
318   debug_cpu_get_visible_cpu(*machine)->debug()->go();
347   if ([notification object] == window)
348   {
349      NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:[NSValue valueWithPointer:machine],
350                                                      @"MAMEDebugMachine",
351                                                      nil];
352      [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification
353                                             object:self
354                                            userInfo:info];
355      debug_cpu_get_visible_cpu(*machine)->debug()->go();
356   }
319357}
320358
321359
trunk/src/osd/modules/debugger/osx/debugview.h
r243596r243597
5555- (NSString *)selectedSubviewName;
5656- (int)selectedSubviewIndex;
5757- (void)selectSubviewAtIndex:(int)index;
58- (void)selectSubviewForCPU:(device_t *)device;
58- (BOOL)selectSubviewForDevice:(device_t *)device;
5959
6060@end
6161
trunk/src/osd/modules/debugger/osx/debugview.m
r243596r243597
1414#include "debug/debugcpu.h"
1515
1616
17static NSColor *DefaultForeground;
18static NSColor *ChangedForeground;
19static NSColor *InvalidForeground;
20static NSColor *CommentForeground;
21static NSColor *DisabledChangedForeground;
22static NSColor *DisabledInvalidForeground;
23static NSColor *DisabledCommentForeground;
24
25static NSColor *DefaultBackground;
26static NSColor *VisitedBackground;
27static NSColor *AncillaryBackground;
28static NSColor *SelectedBackground;
29static NSColor *CurrentBackground;
30static NSColor *SelectedCurrentBackground;
31static NSColor *InactiveSelectedBackground;
32static NSColor *InactiveSelectedCurrentBackground;
33
34
1735static void debugwin_view_update(debug_view &view, void *osdprivate)
1836{
1937   [(MAMEDebugView *)osdprivate update];
r243596r243597
2240
2341@implementation MAMEDebugView
2442
43+ (void)initialize {
44   DefaultForeground = [[NSColor colorWithCalibratedWhite:0.0 alpha:1.0] retain];
45   ChangedForeground = [[NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:1.0] retain];
46   InvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:1.0] retain];
47   CommentForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.375 blue:0.0 alpha:1.0] retain];
48   DisabledChangedForeground = [[NSColor colorWithCalibratedRed:0.5 green:0.125 blue:0.125 alpha:1.0] retain];
49   DisabledInvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.5 alpha:1.0] retain];
50   DisabledCommentForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.25 blue:0.0 alpha:1.0] retain];
51
52   DefaultBackground = [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] retain];
53   VisitedBackground = [[NSColor colorWithCalibratedRed:0.75 green:1.0 blue:0.75 alpha:1.0] retain];
54   AncillaryBackground = [[NSColor colorWithCalibratedWhite:0.75 alpha:1.0] retain];
55   SelectedBackground = [[NSColor colorWithCalibratedRed:0.75 green:0.875 blue:1.0 alpha:1.0] retain];
56   CurrentBackground = [[NSColor colorWithCalibratedRed:1.0 green:0.75 blue:0.75 alpha:1.0] retain];
57   SelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0] retain];
58   InactiveSelectedBackground = [[NSColor colorWithCalibratedWhite:0.875 alpha:1.0] retain];
59   InactiveSelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0] retain];
60}
61
62
2563- (NSColor *)foregroundForAttribute:(UINT8)attrib {
26   const CGFloat alpha = (attrib & DCA_DISABLED) ? 0.5 : 1.0;
2764   if (attrib & DCA_COMMENT)
28      return [NSColor colorWithCalibratedRed:0.0 green:0.375 blue:0.0 alpha:1.0];
65      return (attrib & DCA_DISABLED) ? DisabledCommentForeground : CommentForeground;
2966   else if (attrib & DCA_INVALID)
30      return [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:alpha];
67      return (attrib & DCA_DISABLED) ? DisabledInvalidForeground : InvalidForeground;
3168   else if (attrib & DCA_CHANGED)
32      return [NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:alpha];
69      return (attrib & DCA_DISABLED) ? DisabledChangedForeground : ChangedForeground;
3370   else
34      return [NSColor colorWithCalibratedWhite:0.0 alpha:alpha];
71      return DefaultForeground;
3572}
3673
3774
3875- (NSColor *)backgroundForAttribute:(UINT8)attrib {
39   if ((attrib & DCA_SELECTED) && (attrib & DCA_CURRENT)) {
40      if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self))
41         return [NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0];
42      else
43         return [NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0];
44   } else if (attrib & DCA_CURRENT) {
45      return [NSColor colorWithCalibratedRed:1.0 green:0.625 blue:0.625 alpha:1.0];
46   } else if (attrib & DCA_SELECTED) {
47      if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self))
48         return [NSColor colorWithCalibratedRed:0.75 green:0.875 blue:1.0 alpha:1.0];
49      else
50         return [NSColor colorWithCalibratedWhite:0.875 alpha:1.0];
51   } else if (attrib & DCA_ANCILLARY) {
52      return [NSColor colorWithCalibratedWhite:0.75 alpha:1.0];
53   } else {
54      return [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
55   }
76   BOOL const active = [[self window] isKeyWindow] && ([[self window] firstResponder] == self);
77   if ((attrib & DCA_SELECTED) && (attrib & DCA_CURRENT))
78      return active ? SelectedCurrentBackground : InactiveSelectedCurrentBackground;
79   else if (attrib & DCA_CURRENT)
80      return CurrentBackground;
81   else if (attrib & DCA_SELECTED)
82      return active ? SelectedBackground : InactiveSelectedBackground;
83   else if (attrib & DCA_ANCILLARY)
84      return AncillaryBackground;
85   else if (attrib & DCA_VISITED)
86      return VisitedBackground;
87   else
88      return DefaultBackground;
5689}
5790
5891
r243596r243597
71104   if (!data || (position.y < origin.y) || (position.y >= origin.y + size.y))
72105   {
73106      // y coordinate outside visible area, x will be a guess
74      position.x = lround(floor(location.x / fontWidth));
107      position.x = lround(floor((location.x - [textContainer lineFragmentPadding]) / fontWidth));
75108   }
76109   else
77110   {
r243596r243597
121154}
122155
123156
124- (void)convertBounds:(NSRect)b toPosition:(debug_view_xy *)origin size:(debug_view_xy *)size {
125   origin->x = lround(floor(b.origin.x / fontWidth));
126   origin->y = lround(floor(b.origin.y / fontHeight));
127
128   // FIXME: this is not using proper font metrics horizontally
129   size->x = lround(ceil((b.origin.x + b.size.width) / fontWidth)) - origin->x;
130   size->y = lround(ceil((b.origin.y + b.size.height) / fontHeight)) - origin->y;
157- (void)convertBounds:(NSRect)b toFirstAffectedLine:(INT32 *)f count:(INT32 *)c {
158   *f = lround(floor(b.origin.y / fontHeight));
159   *c = lround(ceil((b.origin.y + b.size.height) / fontHeight)) - *f;
131160}
132161
133162
134163- (void)recomputeVisible {
135   if ([self window] != nil) {
136      debug_view_xy   origin, size;
164   if ([self window] != nil)
165   {
166      // this gets all the lines that are at least partially visible
167      debug_view_xy origin(0, 0), size(totalWidth, totalHeight);
168      [self convertBounds:[self visibleRect] toFirstAffectedLine:&origin.y count:&size.y];
137169
138      // this gets all the characters that are at least paritally visible
139      [self convertBounds:[self visibleRect] toPosition:&origin size:&size];
140
141      // need to render entire lines or we get screwed up characters when widening views
142      origin.x = 0;
143      size.x = totalWidth;
144
145170      // tell them what we think
146171      view->set_visible_size(size);
147172      view->set_visible_position(origin);
r243596r243597
152177
153178
154179- (void)typeCharacterAndScrollToCursor:(char)ch {
155   if (view->cursor_supported()) {
156      debug_view_xy oldPos = view->cursor_position();
180   if (view->cursor_supported())
181   {
182      debug_view_xy const oldPos = view->cursor_position();
157183      view->process_char(ch);
184      debug_view_xy const newPos = view->cursor_position();
185      if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y))
158186      {
159         debug_view_xy newPos = view->cursor_position();
160         if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) {
161            [self scrollRectToVisible:NSMakeRect(newPos.x * fontWidth, // FIXME - use proper metrics
162                                        newPos.y * fontHeight,
163                                        fontWidth,
164                                        fontHeight)];
165         }
187         // FIXME - use proper font metrics
188         [self scrollRectToVisible:NSMakeRect((newPos.x * fontWidth) + [textContainer lineFragmentPadding],
189                                     newPos.y * fontHeight,
190                                     fontWidth,
191                                     fontHeight)];
166192      }
167193   } else {
168194      view->process_char(ch);
r243596r243597
211237
212238
213239- (void)update {
214   debug_view_xy   newSize, newOrigin;
215
216240   // resize our frame if the total size has changed
217   newSize = view->total_size();
218   if ((newSize.x != totalWidth) || (newSize.y != totalHeight)) {
219      [self setFrameSize:NSMakeSize(fontWidth * newSize.x, fontHeight * newSize.y)]; // FIXME: metrics
241   debug_view_xy const newSize = view->total_size();
242   BOOL const resized = (newSize.x != totalWidth) || (newSize.y != totalHeight);
243   if (resized)
244   {
245      [self setFrameSize:NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]),
246                             fontHeight * newSize.y)];
220247      totalWidth = newSize.x;
221248      totalHeight = newSize.y;
222249   }
223250
224251   // scroll the view if we're being told to
225   newOrigin = view->visible_position();
226   if (newOrigin.y != originTop) {
252   debug_view_xy const newOrigin = view->visible_position();
253   if (newOrigin.y != originTop)
254   {
227255      [self scrollPoint:NSMakePoint([self visibleRect].origin.x, newOrigin.y * fontHeight)];
228256      originTop = newOrigin.y;
229257   }
r243596r243597
235263
236264
237265- (NSSize)maximumFrameSize {
238   debug_view_xy max = view->total_size();
239   return NSMakeSize(max.x * fontWidth, max.y * fontHeight);
266   debug_view_xy const max = view->total_size();
267   return NSMakeSize((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding]),
268                  max.y * fontHeight);
240269}
241270
242271
r243596r243597
281310      debug_view_xy pos;
282311      view->set_cursor_visible(true);
283312      pos = view->cursor_position();
284      [self scrollRectToVisible:NSMakeRect(pos.x * fontWidth, pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics
313      [self scrollRectToVisible:NSMakeRect((pos.x * fontWidth) + [textContainer lineFragmentPadding], pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics
285314      [self setNeedsDisplay:YES];
286315      return [super becomeFirstResponder];
287316   } else {
r243596r243597
326355
327356
328357- (void)drawRect:(NSRect)dirtyRect {
329   debug_view_xy position, clip;
358   INT32 position, clip;
330359
331360   // work out how much we need to draw
332361   [self recomputeVisible];
333362   debug_view_xy const origin = view->visible_position();
334363   debug_view_xy const size = view->visible_size();
335   [self convertBounds:dirtyRect toPosition:&position size:&clip];
364   [self convertBounds:dirtyRect toFirstAffectedLine:&position count:&clip];
336365
337366   // this gets the text for the whole visible area
338367   debug_view_char const *data = view->viewdata();
339368   if (!data)
340369      return;
341370
342   data += ((position.y - origin.y) * size.x);
343   for (UINT32 row = position.y; row < position.y + clip.y; row++, data += size.x)
371   data += ((position - origin.y) * size.x);
372   for (UINT32 row = position; row < position + clip; row++, data += size.x)
344373   {
345374      if ((row < origin.y) || (row >= origin.y + size.y))
346375         continue;
r243596r243597
402431
403432- (void)mouseDown:(NSEvent *)event {
404433   NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil];
405   view->process_click(DCK_LEFT_CLICK, [self convertLocation:location]);
434   NSUInteger const modifiers = [event modifierFlags];
435   view->process_click((modifiers & NSCommandKeyMask) ? DCK_RIGHT_CLICK
436                 : (modifiers & NSAlternateKeyMask) ? DCK_MIDDLE_CLICK
437                 : DCK_LEFT_CLICK,
438                  [self convertLocation:location]);
406439   [self setNeedsDisplay:YES];
407440}
408441
409442
410443- (void)rightMouseDown:(NSEvent *)event {
411444   NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil];
412   view->process_click(DCK_RIGHT_CLICK, [self convertLocation:location]);
413   [self setNeedsDisplay:YES];
445   if (view->cursor_supported())
446   {
447      view->set_cursor_position([self convertLocation:location]);
448      view->set_cursor_visible(true);
449      [self setNeedsDisplay:YES];
450   }
414451   [super rightMouseDown:event];
415452}
416453
r243596r243597
419456   NSUInteger   modifiers = [event modifierFlags];
420457   NSString   *str = [event charactersIgnoringModifiers];
421458
422   if ([str length] == 1) {
423      if (modifiers & NSNumericPadKeyMask) {
424         switch ([str characterAtIndex:0]) {
425            case NSUpArrowFunctionKey:
426               if (modifiers & NSCommandKeyMask)
427                  view->process_char(DCH_CTRLHOME);
428               else
429                  view->process_char(DCH_UP);
430               return;
431            case NSDownArrowFunctionKey:
432               if (modifiers & NSCommandKeyMask)
433                  view->process_char(DCH_CTRLEND);
434               else
435                  view->process_char(DCH_DOWN);
436               return;
437            case NSLeftArrowFunctionKey:
438               if (modifiers & NSCommandKeyMask)
439                  [self typeCharacterAndScrollToCursor:DCH_HOME];
440               else if (modifiers & NSAlternateKeyMask)
441                  [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT];
442               else
443                  [self typeCharacterAndScrollToCursor:DCH_LEFT];
444               return;
445            case NSRightArrowFunctionKey:
446               if (modifiers & NSCommandKeyMask)
447                  [self typeCharacterAndScrollToCursor:DCH_END];
448               else if (modifiers & NSAlternateKeyMask)
449                  [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT];
450               else
451                  [self typeCharacterAndScrollToCursor:DCH_RIGHT];
452               return;
453            default:
454               [self interpretKeyEvents:[NSArray arrayWithObject:event]];
455               return;
459   if ([str length] == 1)
460   {
461      if (modifiers & NSNumericPadKeyMask)
462      {
463         switch ([str characterAtIndex:0])
464         {
465         case NSUpArrowFunctionKey:
466            if (modifiers & NSCommandKeyMask)
467               view->process_char(DCH_CTRLHOME);
468            else
469               view->process_char(DCH_UP);
470            return;
471         case NSDownArrowFunctionKey:
472            if (modifiers & NSCommandKeyMask)
473               view->process_char(DCH_CTRLEND);
474            else
475               view->process_char(DCH_DOWN);
476            return;
477         case NSLeftArrowFunctionKey:
478            if (modifiers & NSCommandKeyMask)
479               [self typeCharacterAndScrollToCursor:DCH_HOME];
480            else if (modifiers & NSAlternateKeyMask)
481               [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT];
482            else
483               [self typeCharacterAndScrollToCursor:DCH_LEFT];
484            return;
485         case NSRightArrowFunctionKey:
486            if (modifiers & NSCommandKeyMask)
487               [self typeCharacterAndScrollToCursor:DCH_END];
488            else if (modifiers & NSAlternateKeyMask)
489               [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT];
490            else
491               [self typeCharacterAndScrollToCursor:DCH_RIGHT];
492            return;
493         default:
494            [self interpretKeyEvents:[NSArray arrayWithObject:event]];
495            return;
456496         }
457      } else if (modifiers & NSFunctionKeyMask) {
458         switch ([str characterAtIndex:0]) {
497      }
498      else if (modifiers & NSFunctionKeyMask)
499      {
500         switch ([str characterAtIndex:0])
501         {
459502            case NSPageUpFunctionKey:
460               if (modifiers & NSAlternateKeyMask) {
503               if (modifiers & NSAlternateKeyMask)
504               {
461505                  view->process_char(DCH_PUP);
462506                  return;
463507               }
464508            case NSPageDownFunctionKey:
465               if (modifiers & NSAlternateKeyMask) {
509               if (modifiers & NSAlternateKeyMask)
510               {
466511                  view->process_char(DCH_PDOWN);
467512                  return;
468513               }
trunk/src/osd/modules/debugger/osx/debugwindowhandler.h
r243596r243597
9090
9191- (id <MAMEDebugViewExpressionSupport>)documentView;
9292
93- (NSString *)expression;
94- (void)setExpression:(NSString *)expression;
95
9396- (IBAction)doExpression:(id)sender;
9497
9598- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor;
trunk/src/osd/modules/debugger/osx/debugwindowhandler.m
r243596r243597
231231
232232
233233- (void)showDebugger:(NSNotification *)notification {
234   device_t *device = (device_t *) [[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue];
235   if (&device->machine() == machine) {
234   running_machine *m = (running_machine *)[[[notification userInfo] objectForKey:@"MAMEDebugMachine"] pointerValue];
235   if (m == machine)
236   {
236237      if (![window isVisible] && ![window isMiniaturized])
237238         [window orderFront:self];
238239   }
r243596r243597
240241
241242
242243- (void)hideDebugger:(NSNotification *)notification {
243   [window orderOut:self];
244   running_machine *m = (running_machine *)[[[notification userInfo] objectForKey:@"MAMEDebugMachine"] pointerValue];
245   if (m == machine)
246      [window orderOut:self];
244247}
245248
246249@end
r243596r243597
309312   desired.height -= current.height;
310313
311314   windowFrame.size.width += desired.width;
315   windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
312316   windowFrame.size.height += desired.height;
313317   windowFrame.size.height = MIN(MIN(windowFrame.size.height, 240), available.size.height);
314   windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
315318   windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
316319   windowFrame.origin.y = available.origin.y;
317320   [window setFrame:windowFrame display:YES];
r243596r243597
352355}
353356
354357
358- (NSString *)expression {
359   return [[self documentView] expression];
360}
361
362- (void)setExpression:(NSString *)expression {
363   [history add:expression];
364   [[self documentView] setExpression:expression];
365   [expressionField setStringValue:expression];
366   [expressionField selectText:self];
367}
368
369
355370- (IBAction)doExpression:(id)sender {
356371   NSString *expr = [sender stringValue];
357372   if ([expr length] > 0) {
trunk/src/osd/modules/debugger/osx/disassemblyview.h
r243596r243597
1414#import "debugview.h"
1515
1616#include "emu.h"
17#include "debug/dvdisasm.h"
1718
1819#import <Cocoa/Cocoa.h>
1920
r243596r243597
3031- (NSString *)selectedSubviewName;
3132- (int)selectedSubviewIndex;
3233- (void)selectSubviewAtIndex:(int)index;
33- (void)selectSubviewForCPU:(device_t *)device;
34- (BOOL)selectSubviewForDevice:(device_t *)device;
35- (BOOL)selectSubviewForSpace:(address_space *)space;
3436
3537- (NSString *)expression;
3638- (void)setExpression:(NSString *)exp;
3739
40- (debug_view_disasm_source const *)source;
41
3842- (IBAction)debugToggleBreakpoint:(id)sender;
3943- (IBAction)debugToggleBreakpointEnable:(id)sender;
4044- (IBAction)debugRunToCursor:(id)sender;
trunk/src/osd/modules/debugger/osx/disassemblyview.m
r243596r243597
1111
1212#import "disassemblyview.h"
1313
14#include "debugger.h"
1415#include "debug/debugcon.h"
1516#include "debug/debugcpu.h"
1617#include "debug/debugvw.h"
17#include "debug/dvdisasm.h"
1818
1919
2020@implementation MAMEDisassemblyView
r243596r243597
199199}
200200
201201
202- (void)selectSubviewForCPU:(device_t *)device {
203   const debug_view_source     *selected = view->source();
204   const debug_view_source     *source = view->source_for_device(device);
205   if ( selected != source ) {
206      view->set_source(*source);
207      if ([[self window] firstResponder] != self)
208         view->set_cursor_visible(false);
202- (BOOL)selectSubviewForDevice:(device_t *)device {
203   debug_view_source const *const source = view->source_for_device(device);
204   if (source != NULL)
205   {
206      if (view->source() != source)
207      {
208         view->set_source(*source);
209         if ([[self window] firstResponder] != self)
210            view->set_cursor_visible(false);
211      }
212      return YES;
209213   }
214   else
215   {
216      return NO;
217   }
210218}
211219
212220
221- (BOOL)selectSubviewForSpace:(address_space *)space {
222   if (space == NULL) return NO;
223   debug_view_disasm_source const *source = downcast<debug_view_disasm_source const *>(view->first_source());
224   while ((source != NULL) && (&source->space() != space))
225      source = downcast<debug_view_disasm_source *>(source->next());
226   if (source != NULL)
227   {
228      if (view->source() != source)
229      {
230         view->set_source(*source);
231         if ([[self window] firstResponder] != self)
232            view->set_cursor_visible(false);
233      }
234      return YES;
235   }
236   else
237   {
238      return NO;
239   }
240}
241
242
213243- (NSString *)expression {
214244   return [NSString stringWithUTF8String:downcast<debug_view_disasm *>(view)->expression()];
215245}
r243596r243597
220250}
221251
222252
253- (debug_view_disasm_source const *)source {
254   return downcast<debug_view_disasm_source const *>(view->source());
255}
256
257
223258- (IBAction)debugToggleBreakpoint:(id)sender {
224   if (view->cursor_visible()) {
259   if (view->cursor_visible())
260   {
225261      address_space &space = downcast<const debug_view_disasm_source *>(view->source())->space();
226      if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) {
227         offs_t            address = downcast<debug_view_disasm *>(view)->selected_address();
262      if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device()))
263      {
264         offs_t const address = downcast<debug_view_disasm *>(view)->selected_address();
228265         device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space];
229266
230267         // if it doesn't exist, add a new one
231         if (useConsole) {
268         if (useConsole)
269         {
232270            NSString *command;
233271            if (bp == NULL)
234272               command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address];
235273            else
236274               command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()];
237275            debug_console_execute_command(*machine, [command UTF8String], 1);
238         } else {
276         }
277         else
278         {
239279            if (bp == NULL)
240               space.device().debug()->breakpoint_set(address, NULL, NULL);
280            {
281               UINT32 const bpnum = space.device().debug()->breakpoint_set(address, NULL, NULL);
282               debug_console_printf(*machine, "Breakpoint %X set\n", bpnum);
283            }
241284            else
242               space.device().debug()->breakpoint_clear(bp->index());
285            {
286               int const bpnum = bp->index();
287               space.device().debug()->breakpoint_clear(bpnum);
288               debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum);
289            }
243290         }
291
292         // fail to do this and the display doesn't update
293         machine->debug_view().update_all();
294         debugger_refresh_display(*machine);
244295      }
245296   }
246297}
247298
248299
249300- (IBAction)debugToggleBreakpointEnable:(id)sender {
250   if (view->cursor_visible()) {
301   if (view->cursor_visible())
302   {
251303      address_space &space = downcast<const debug_view_disasm_source *>(view->source())->space();
252      if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) {
253         offs_t            address = downcast<debug_view_disasm *>(view)->selected_address();
304      if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device()))
305      {
306         offs_t const address = downcast<debug_view_disasm *>(view)->selected_address();
254307         device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space];
255
256         if (bp != NULL) {
257            NSString *command;
258            if (useConsole) {
308         if (bp != NULL)
309         {
310            if (useConsole)
311            {
312               NSString *command;
259313               if (bp->enabled())
260314                  command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()];
261315               else
262316                  command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()];
263317               debug_console_execute_command(*machine, [command UTF8String], 1);
264            } else {
318            }
319            else
320            {
265321               space.device().debug()->breakpoint_enable(bp->index(), !bp->enabled());
322               debug_console_printf(*machine,
323                               "Breakpoint %X %s\n",
324                               (UINT32)bp->index(),
325                               bp->enabled() ? "enabled" : "disabled");
266326            }
327            machine->debug_view().update_all();
328            debugger_refresh_display(*machine);
267329         }
268330      }
269331   }
trunk/src/osd/modules/debugger/osx/disassemblyviewer.h
r243596r243597
2323@interface MAMEDisassemblyViewer : MAMEExpressionAuxiliaryDebugWindowHandler
2424{
2525   MAMEDisassemblyView   *dasmView;
26   NSPopUpButton      *subviewButton;
2627}
2728
2829- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c;
2930
31- (BOOL)selectSubviewForDevice:(device_t *)device;
32- (BOOL)selectSubviewForSpace:(address_space *)space;
33
3034- (IBAction)changeSubview:(id)sender;
3135
3236@end
trunk/src/osd/modules/debugger/osx/disassemblyviewer.m
r243596r243597
1111
1212#import "disassemblyviewer.h"
1313
14#import "debugconsole.h"
1415#import "debugview.h"
1516#import "disassemblyview.h"
1617
r243596r243597
2223- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c {
2324   NSScrollView   *dasmScroll;
2425   NSView         *expressionContainer;
25   NSPopUpButton   *actionButton, *subviewButton;
26   NSPopUpButton   *actionButton;
2627   NSRect         contentBounds, expressionFrame;
2728
2829   if (!(self = [super initWithMachine:m title:@"Disassembly" console:c]))
r243596r243597
9899   [actionButton release];
99100
100101   // set default state
101   [dasmView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)];
102   [dasmView selectSubviewForDevice:debug_cpu_get_visible_cpu(*machine)];
102103   [dasmView setExpression:@"curpc"];
103104   [expressionField setStringValue:@"curpc"];
104105   [expressionField selectText:self];
r243596r243597
130131}
131132
132133
134- (IBAction)debugNewMemoryWindow:(id)sender {
135   debug_view_disasm_source const *source = [dasmView source];
136   [console debugNewMemoryWindowForSpace:&source->space()
137                           device:&source->device()
138                        expression:nil];
139}
140
141
142- (IBAction)debugNewDisassemblyWindow:(id)sender {
143   debug_view_disasm_source const *source = [dasmView source];
144   [console debugNewDisassemblyWindowForSpace:&source->space()
145                              device:&source->device()
146                           expression:[dasmView expression]];
147}
148
149
150- (BOOL)selectSubviewForDevice:(device_t *)device {
151   BOOL const result = [dasmView selectSubviewForDevice:device];
152   [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]];
153   [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]];
154   return result;
155}
156
157
158- (BOOL)selectSubviewForSpace:(address_space *)space {
159   BOOL const result = [dasmView selectSubviewForSpace:space];
160   [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]];
161   [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]];
162   return result;
163}
164
165
133166- (IBAction)changeSubview:(id)sender {
134167   [dasmView selectSubviewAtIndex:[[sender selectedItem] tag]];
135168   [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]];
trunk/src/osd/modules/debugger/osx/memoryview.h
r243596r243597
1414#import "debugview.h"
1515
1616#include "emu.h"
17#include "debug/dvmemory.h"
1718
1819#import <Cocoa/Cocoa.h>
1920
r243596r243597
2930- (NSString *)selectedSubviewName;
3031- (int)selectedSubviewIndex;
3132- (void)selectSubviewAtIndex:(int)index;
32- (void)selectSubviewForCPU:(device_t *)device;
33- (BOOL)selectSubviewForDevice:(device_t *)device;
34- (BOOL)selectSubviewForSpace:(address_space *)space;
3335
3436- (NSString *)expression;
3537- (void)setExpression:(NSString *)exp;
3638
39- (debug_view_memory_source const *)source;
40
3741- (IBAction)showChunkSize:(id)sender;
3842- (IBAction)showPhysicalAddresses:(id)sender;
3943- (IBAction)showReverseView:(id)sender;
trunk/src/osd/modules/debugger/osx/memoryview.m
r243596r243597
1313
1414#include "debug/debugcpu.h"
1515#include "debug/debugvw.h"
16#include "debug/dvmemory.h"
1716
1817
1918@implementation MAMEMemoryView
r243596r243597
107106}
108107
109108
110- (void)selectSubviewForCPU:(device_t *)device {
111   debug_view_source const      *selected = view->source();
112   debug_view_source const      *source = view->source_for_device(device);
113   if ( selected != source ) {
114      view->set_source(*source);
115      if ([[self window] firstResponder] != self)
116         view->set_cursor_visible(false);
109- (BOOL)selectSubviewForDevice:(device_t *)device {
110   debug_view_source const *const source = view->source_for_device(device);
111   if (source != NULL)
112   {
113      if (view->source() != source)
114      {
115         view->set_source(*source);
116         if ([[self window] firstResponder] != self)
117            view->set_cursor_visible(false);
118      }
119      return YES;
117120   }
121   else
122   {
123      return NO;
124   }
118125}
119126
120127
128- (BOOL)selectSubviewForSpace:(address_space *)space {
129   if (space == NULL) return NO;
130   debug_view_memory_source const *source = downcast<debug_view_memory_source const *>(view->first_source());
131   while ((source != NULL) && (source->space() != space))
132      source = downcast<debug_view_memory_source *>(source->next());
133   if (source != NULL)
134   {
135      if (view->source() != source)
136      {
137         view->set_source(*source);
138         if ([[self window] firstResponder] != self)
139            view->set_cursor_visible(false);
140      }
141      return YES;
142   }
143   else
144   {
145      return NO;
146   }
147}
148
149
121150- (NSString *)expression {
122151   return [NSString stringWithUTF8String:downcast<debug_view_memory *>(view)->expression()];
123152}
r243596r243597
128157}
129158
130159
160- (debug_view_memory_source const *)source {
161   return downcast<debug_view_memory_source const *>(view->source());
162}
163
164
131165- (IBAction)showChunkSize:(id)sender {
132166   downcast<debug_view_memory *>(view)->set_bytes_per_chunk([sender tag]);
133167}
trunk/src/osd/modules/debugger/osx/memoryviewer.h
r243596r243597
2323@interface MAMEMemoryViewer : MAMEExpressionAuxiliaryDebugWindowHandler
2424{
2525   MAMEMemoryView   *memoryView;
26   NSPopUpButton   *subviewButton;
2627}
2728
2829- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c;
2930
31- (BOOL)selectSubviewForDevice:(device_t *)device;
32- (BOOL)selectSubviewForSpace:(address_space *)space;
33
3034- (IBAction)changeSubview:(id)sender;
3135
3236@end
trunk/src/osd/modules/debugger/osx/memoryviewer.m
r243596r243597
1111
1212#import "memoryviewer.h"
1313
14#import "debugconsole.h"
1415#import "debugview.h"
1516#import "memoryview.h"
1617
1718#include "debug/debugcpu.h"
19#include "debug/dvmemory.h"
1820
1921
2022@implementation MAMEMemoryViewer
r243596r243597
2224- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c {
2325   NSScrollView   *memoryScroll;
2426   NSView         *expressionContainer;
25   NSPopUpButton   *actionButton, *subviewButton;
27   NSPopUpButton   *actionButton;
2628   NSRect         contentBounds, expressionFrame;
2729
2830   if (!(self = [super initWithMachine:m title:@"Memory" console:c]))
r243596r243597
9799   [actionButton release];
98100
99101   // set default state
100   [memoryView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)];
102   [memoryView selectSubviewForDevice:debug_cpu_get_visible_cpu(*machine)];
101103   [memoryView setExpression:@"0"];
102104   [expressionField setStringValue:@"0"];
103105   [expressionField selectText:self];
r243596r243597
127129}
128130
129131
132- (IBAction)debugNewMemoryWindow:(id)sender {
133   debug_view_memory_source const *source = [memoryView source];
134   [console debugNewMemoryWindowForSpace:source->space()
135                           device:source->device()
136                        expression:[memoryView expression]];
137}
138
139
140- (IBAction)debugNewDisassemblyWindow:(id)sender {
141   debug_view_memory_source const *source = [memoryView source];
142   [console debugNewDisassemblyWindowForSpace:source->space()
143                              device:source->device()
144                           expression:[memoryView expression]];
145}
146
147
148- (BOOL)selectSubviewForDevice:(device_t *)device {   
149   BOOL const result = [memoryView selectSubviewForDevice:device];
150   [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]];
151   [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]];
152   return result;
153}
154
155
156- (BOOL)selectSubviewForSpace:(address_space *)space {
157   BOOL const result = [memoryView selectSubviewForSpace:space];
158   [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]];
159   [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]];
160   return result;
161}
162
163
130164- (IBAction)changeSubview:(id)sender {
131165   [memoryView selectSubviewAtIndex:[[sender selectedItem] tag]];
132166   [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]];
trunk/src/osd/modules/debugger/osx/registersview.h
r243596r243597
2929- (NSString *)selectedSubviewName;
3030- (int)selectedSubviewIndex;
3131- (void)selectSubviewAtIndex:(int)index;
32- (void)selectSubviewForCPU:(device_t *)device;
32- (void)selectSubviewForDevice:(device_t *)device;
3333
3434@end
trunk/src/osd/modules/debugger/osx/registersview.m
r243596r243597
6464}
6565
6666
67- (void)selectSubviewForCPU:(device_t *)device {
67- (void)selectSubviewForDevice:(device_t *)device {
6868   view->set_source(*view->source_for_device(device));
6969}
7070


Previous 199869 Revisions Next


© 1997-2024 The MAME Team