trunk/src/osd/modules/debugger/osx/debugconsole.m
| r243596 | r243597 | |
| 135 | 135 | [window makeFirstResponder:commandField]; |
| 136 | 136 | |
| 137 | 137 | // 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] |
| 148 | 152 | hasHorizontalScroller:YES |
| 149 | 153 | 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; |
| 158 | 156 | |
| 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); |
| 164 | 162 | |
| 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]; |
| 172 | 170 | |
| 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]; |
| 182 | 179 | |
| 183 | 180 | // select the current processor |
| 184 | 181 | [self setCPU:machine->firstcpu]; |
| r243596 | r243597 | |
| 206 | 203 | |
| 207 | 204 | |
| 208 | 205 | - (void)setCPU:(device_t *)device { |
| 209 | | [regView selectSubviewForCPU:device]; |
| 210 | | [dasmView selectSubviewForCPU:device]; |
| 206 | [regView selectSubviewForDevice:device]; |
| 207 | [dasmView selectSubviewForDevice:device]; |
| 211 | 208 | [window setTitle:[NSString stringWithFormat:@"Debug: %s - %s '%s'", |
| 212 | 209 | device->machine().system().name, |
| 213 | 210 | device->name(), |
| r243596 | r243597 | |
| 261 | 258 | } |
| 262 | 259 | |
| 263 | 260 | |
| 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 | |
| 264 | 295 | - (void)showDebugger:(NSNotification *)notification { |
| 265 | 296 | device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; |
| 266 | | if (&device->machine() == machine) { |
| 297 | if (&device->machine() == machine) |
| 298 | { |
| 267 | 299 | [self setCPU:device]; |
| 268 | 300 | [window makeKeyAndOrderFront:self]; |
| 269 | 301 | } |
| r243596 | r243597 | |
| 312 | 344 | |
| 313 | 345 | |
| 314 | 346 | - (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 | } |
| 319 | 357 | } |
| 320 | 358 | |
| 321 | 359 | |
trunk/src/osd/modules/debugger/osx/debugview.m
| r243596 | r243597 | |
| 14 | 14 | #include "debug/debugcpu.h" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | static NSColor *DefaultForeground; |
| 18 | static NSColor *ChangedForeground; |
| 19 | static NSColor *InvalidForeground; |
| 20 | static NSColor *CommentForeground; |
| 21 | static NSColor *DisabledChangedForeground; |
| 22 | static NSColor *DisabledInvalidForeground; |
| 23 | static NSColor *DisabledCommentForeground; |
| 24 | |
| 25 | static NSColor *DefaultBackground; |
| 26 | static NSColor *VisitedBackground; |
| 27 | static NSColor *AncillaryBackground; |
| 28 | static NSColor *SelectedBackground; |
| 29 | static NSColor *CurrentBackground; |
| 30 | static NSColor *SelectedCurrentBackground; |
| 31 | static NSColor *InactiveSelectedBackground; |
| 32 | static NSColor *InactiveSelectedCurrentBackground; |
| 33 | |
| 34 | |
| 17 | 35 | static void debugwin_view_update(debug_view &view, void *osdprivate) |
| 18 | 36 | { |
| 19 | 37 | [(MAMEDebugView *)osdprivate update]; |
| r243596 | r243597 | |
| 22 | 40 | |
| 23 | 41 | @implementation MAMEDebugView |
| 24 | 42 | |
| 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 | |
| 25 | 63 | - (NSColor *)foregroundForAttribute:(UINT8)attrib { |
| 26 | | const CGFloat alpha = (attrib & DCA_DISABLED) ? 0.5 : 1.0; |
| 27 | 64 | 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; |
| 29 | 66 | 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; |
| 31 | 68 | 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; |
| 33 | 70 | else |
| 34 | | return [NSColor colorWithCalibratedWhite:0.0 alpha:alpha]; |
| 71 | return DefaultForeground; |
| 35 | 72 | } |
| 36 | 73 | |
| 37 | 74 | |
| 38 | 75 | - (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; |
| 56 | 89 | } |
| 57 | 90 | |
| 58 | 91 | |
| r243596 | r243597 | |
| 71 | 104 | if (!data || (position.y < origin.y) || (position.y >= origin.y + size.y)) |
| 72 | 105 | { |
| 73 | 106 | // 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)); |
| 75 | 108 | } |
| 76 | 109 | else |
| 77 | 110 | { |
| r243596 | r243597 | |
| 121 | 154 | } |
| 122 | 155 | |
| 123 | 156 | |
| 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; |
| 131 | 160 | } |
| 132 | 161 | |
| 133 | 162 | |
| 134 | 163 | - (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]; |
| 137 | 169 | |
| 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 | | |
| 145 | 170 | // tell them what we think |
| 146 | 171 | view->set_visible_size(size); |
| 147 | 172 | view->set_visible_position(origin); |
| r243596 | r243597 | |
| 152 | 177 | |
| 153 | 178 | |
| 154 | 179 | - (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(); |
| 157 | 183 | view->process_char(ch); |
| 184 | debug_view_xy const newPos = view->cursor_position(); |
| 185 | if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) |
| 158 | 186 | { |
| 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)]; |
| 166 | 192 | } |
| 167 | 193 | } else { |
| 168 | 194 | view->process_char(ch); |
| r243596 | r243597 | |
| 211 | 237 | |
| 212 | 238 | |
| 213 | 239 | - (void)update { |
| 214 | | debug_view_xy newSize, newOrigin; |
| 215 | | |
| 216 | 240 | // 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)]; |
| 220 | 247 | totalWidth = newSize.x; |
| 221 | 248 | totalHeight = newSize.y; |
| 222 | 249 | } |
| 223 | 250 | |
| 224 | 251 | // 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 | { |
| 227 | 255 | [self scrollPoint:NSMakePoint([self visibleRect].origin.x, newOrigin.y * fontHeight)]; |
| 228 | 256 | originTop = newOrigin.y; |
| 229 | 257 | } |
| r243596 | r243597 | |
| 235 | 263 | |
| 236 | 264 | |
| 237 | 265 | - (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); |
| 240 | 269 | } |
| 241 | 270 | |
| 242 | 271 | |
| r243596 | r243597 | |
| 281 | 310 | debug_view_xy pos; |
| 282 | 311 | view->set_cursor_visible(true); |
| 283 | 312 | 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 |
| 285 | 314 | [self setNeedsDisplay:YES]; |
| 286 | 315 | return [super becomeFirstResponder]; |
| 287 | 316 | } else { |
| r243596 | r243597 | |
| 326 | 355 | |
| 327 | 356 | |
| 328 | 357 | - (void)drawRect:(NSRect)dirtyRect { |
| 329 | | debug_view_xy position, clip; |
| 358 | INT32 position, clip; |
| 330 | 359 | |
| 331 | 360 | // work out how much we need to draw |
| 332 | 361 | [self recomputeVisible]; |
| 333 | 362 | debug_view_xy const origin = view->visible_position(); |
| 334 | 363 | debug_view_xy const size = view->visible_size(); |
| 335 | | [self convertBounds:dirtyRect toPosition:&position size:&clip]; |
| 364 | [self convertBounds:dirtyRect toFirstAffectedLine:&position count:&clip]; |
| 336 | 365 | |
| 337 | 366 | // this gets the text for the whole visible area |
| 338 | 367 | debug_view_char const *data = view->viewdata(); |
| 339 | 368 | if (!data) |
| 340 | 369 | return; |
| 341 | 370 | |
| 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) |
| 344 | 373 | { |
| 345 | 374 | if ((row < origin.y) || (row >= origin.y + size.y)) |
| 346 | 375 | continue; |
| r243596 | r243597 | |
| 402 | 431 | |
| 403 | 432 | - (void)mouseDown:(NSEvent *)event { |
| 404 | 433 | 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]); |
| 406 | 439 | [self setNeedsDisplay:YES]; |
| 407 | 440 | } |
| 408 | 441 | |
| 409 | 442 | |
| 410 | 443 | - (void)rightMouseDown:(NSEvent *)event { |
| 411 | 444 | 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 | } |
| 414 | 451 | [super rightMouseDown:event]; |
| 415 | 452 | } |
| 416 | 453 | |
| r243596 | r243597 | |
| 419 | 456 | NSUInteger modifiers = [event modifierFlags]; |
| 420 | 457 | NSString *str = [event charactersIgnoringModifiers]; |
| 421 | 458 | |
| 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; |
| 456 | 496 | } |
| 457 | | } else if (modifiers & NSFunctionKeyMask) { |
| 458 | | switch ([str characterAtIndex:0]) { |
| 497 | } |
| 498 | else if (modifiers & NSFunctionKeyMask) |
| 499 | { |
| 500 | switch ([str characterAtIndex:0]) |
| 501 | { |
| 459 | 502 | case NSPageUpFunctionKey: |
| 460 | | if (modifiers & NSAlternateKeyMask) { |
| 503 | if (modifiers & NSAlternateKeyMask) |
| 504 | { |
| 461 | 505 | view->process_char(DCH_PUP); |
| 462 | 506 | return; |
| 463 | 507 | } |
| 464 | 508 | case NSPageDownFunctionKey: |
| 465 | | if (modifiers & NSAlternateKeyMask) { |
| 509 | if (modifiers & NSAlternateKeyMask) |
| 510 | { |
| 466 | 511 | view->process_char(DCH_PDOWN); |
| 467 | 512 | return; |
| 468 | 513 | } |
trunk/src/osd/modules/debugger/osx/disassemblyview.m
| r243596 | r243597 | |
| 11 | 11 | |
| 12 | 12 | #import "disassemblyview.h" |
| 13 | 13 | |
| 14 | #include "debugger.h" |
| 14 | 15 | #include "debug/debugcon.h" |
| 15 | 16 | #include "debug/debugcpu.h" |
| 16 | 17 | #include "debug/debugvw.h" |
| 17 | | #include "debug/dvdisasm.h" |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | @implementation MAMEDisassemblyView |
| r243596 | r243597 | |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
| 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; |
| 209 | 213 | } |
| 214 | else |
| 215 | { |
| 216 | return NO; |
| 217 | } |
| 210 | 218 | } |
| 211 | 219 | |
| 212 | 220 | |
| 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 | |
| 213 | 243 | - (NSString *)expression { |
| 214 | 244 | return [NSString stringWithUTF8String:downcast<debug_view_disasm *>(view)->expression()]; |
| 215 | 245 | } |
| r243596 | r243597 | |
| 220 | 250 | } |
| 221 | 251 | |
| 222 | 252 | |
| 253 | - (debug_view_disasm_source const *)source { |
| 254 | return downcast<debug_view_disasm_source const *>(view->source()); |
| 255 | } |
| 256 | |
| 257 | |
| 223 | 258 | - (IBAction)debugToggleBreakpoint:(id)sender { |
| 224 | | if (view->cursor_visible()) { |
| 259 | if (view->cursor_visible()) |
| 260 | { |
| 225 | 261 | 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(); |
| 228 | 265 | device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; |
| 229 | 266 | |
| 230 | 267 | // if it doesn't exist, add a new one |
| 231 | | if (useConsole) { |
| 268 | if (useConsole) |
| 269 | { |
| 232 | 270 | NSString *command; |
| 233 | 271 | if (bp == NULL) |
| 234 | 272 | command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address]; |
| 235 | 273 | else |
| 236 | 274 | command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()]; |
| 237 | 275 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 238 | | } else { |
| 276 | } |
| 277 | else |
| 278 | { |
| 239 | 279 | 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 | } |
| 241 | 284 | 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 | } |
| 243 | 290 | } |
| 291 | |
| 292 | // fail to do this and the display doesn't update |
| 293 | machine->debug_view().update_all(); |
| 294 | debugger_refresh_display(*machine); |
| 244 | 295 | } |
| 245 | 296 | } |
| 246 | 297 | } |
| 247 | 298 | |
| 248 | 299 | |
| 249 | 300 | - (IBAction)debugToggleBreakpointEnable:(id)sender { |
| 250 | | if (view->cursor_visible()) { |
| 301 | if (view->cursor_visible()) |
| 302 | { |
| 251 | 303 | 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(); |
| 254 | 307 | 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; |
| 259 | 313 | if (bp->enabled()) |
| 260 | 314 | command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()]; |
| 261 | 315 | else |
| 262 | 316 | command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()]; |
| 263 | 317 | debug_console_execute_command(*machine, [command UTF8String], 1); |
| 264 | | } else { |
| 318 | } |
| 319 | else |
| 320 | { |
| 265 | 321 | 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"); |
| 266 | 326 | } |
| 327 | machine->debug_view().update_all(); |
| 328 | debugger_refresh_display(*machine); |
| 267 | 329 | } |
| 268 | 330 | } |
| 269 | 331 | } |