private DebugEventInfo?GetEventAtPosition(Point location) { Point pos = GetHClockAndScanline(location); EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions(); DebugEventInfo evt = new DebugEventInfo(); DebugApi.GetEventViewerEvent(this.CpuType, ref evt, (UInt16)pos.Y, (UInt16)pos.X, options); if (evt.ProgramCounter == 0xFFFFFFFF) { int[] xOffsets = new int[] { 0, 1, -1, 2, -2, 3 }; int[] yOffsets = new int[] { 0, -1, 1 }; //Check for other events near the current mouse position for (int j = 0; j < yOffsets.Length; j++) { for (int i = 0; i < xOffsets.Length; i++) { DebugApi.GetEventViewerEvent(this.CpuType, ref evt, (UInt16)(pos.Y + yOffsets[j]), (UInt16)(pos.X + xOffsets[i] * _xRatio), options); if (evt.ProgramCounter != 0xFFFFFFFF) { return(evt); } } } return(null); } else { return(evt); } }
private void picPicture_MouseMove(object sender, MouseEventArgs e) { int cycle = ((e.X & ~0x01) / (_zoomed ? 2 : 1)) / 2; int scanline = ((e.Y & ~0x01) / (_zoomed ? 2 : 1)) / 2; EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions(); DebugEventInfo evt = DebugApi.GetEventViewerEvent((UInt16)scanline, (UInt16)cycle, options); if (evt.ProgramCounter == 0xFFFFFFFF) { ResetTooltip(); UpdateOverlay(e.Location); return; } Dictionary <string, string> values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(evt.Type) }, { "Scanline", evt.Scanline.ToString() }, { "Cycle", evt.Cycle.ToString() }, { "PC", "$" + evt.ProgramCounter.ToString("X6") }, }; switch (evt.Type) { case DebugEventType.Register: bool isWrite = evt.Operation.Type == MemoryOperationType.Write || evt.Operation.Type == MemoryOperationType.DmaWrite; bool isDma = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead; values["Register"] = "$" + evt.Operation.Address.ToString("X4") + (isWrite ? " (Write)" : " (Read)") + (isDma ? " (DMA)" : ""); values["Value"] = "$" + evt.Operation.Value.ToString("X2"); break; case DebugEventType.Breakpoint: //TODO /*ReadOnlyCollection<Breakpoint> breakpoints = BreakpointManager.Breakpoints; * if(debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) { * Breakpoint bp = breakpoints[debugEvent.BreakpointId]; * values["BP Type"] = bp.ToReadableType(); * values["BP Addresses"] = bp.GetAddressString(true); * if(bp.Condition.Length > 0) { * values["BP Condition"] = bp.Condition; * } * }*/ break; } double scale = _zoomed ? 2 : 1; UpdateOverlay(new Point((int)(evt.Cycle * 2 * scale), (int)(evt.Scanline * 2 * scale))); ResetTooltip(); Form parentForm = this.FindForm(); _tooltip = new frmInfoTooltip(parentForm, values, 10); _tooltip.FormClosed += (s, ev) => { _tooltip = null; }; Point location = picViewer.PointToScreen(e.Location); location.Offset(10, 10); _tooltip.SetFormLocation(location, this); }
private void picPicture_MouseMove(object sender, MouseEventArgs e) { Point pos = GetCycleScanline(e.Location); if (_lastPos == pos) { return; } EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions(); DebugEventInfo evt = DebugApi.GetEventViewerEvent((UInt16)pos.Y, (UInt16)pos.X, options); if (evt.ProgramCounter == 0xFFFFFFFF) { ResetTooltip(); UpdateOverlay(e.Location); return; } Dictionary <string, string> values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(evt.Type) }, { "Scanline", evt.Scanline.ToString() }, { "Cycle", evt.Cycle.ToString() }, { "PC", "$" + evt.ProgramCounter.ToString("X6") }, }; switch (evt.Type) { case DebugEventType.Register: bool isWrite = evt.Operation.Type == MemoryOperationType.Write || evt.Operation.Type == MemoryOperationType.DmaWrite; bool isDma = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead; values["Register"] = "$" + evt.Operation.Address.ToString("X4") + (isWrite ? " (Write)" : " (Read)") + (isDma ? " (DMA)" : ""); values["Value"] = "$" + evt.Operation.Value.ToString("X2"); if (isDma) { bool indirectHdma = false; values["Channel"] = evt.DmaChannel.ToString(); if (evt.DmaChannelInfo.InterruptedByHdma != 0) { indirectHdma = evt.DmaChannelInfo.HdmaIndirectAddressing != 0; values["Channel"] += indirectHdma ? " (Indirect HDMA)" : " (HDMA)"; values["Line Counter"] = "$" + evt.DmaChannelInfo.HdmaLineCounterAndRepeat.ToString("X2"); } values["Mode"] = evt.DmaChannelInfo.TransferMode.ToString(); int aBusAddress; if (indirectHdma) { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize; } else { aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress; } if (evt.DmaChannelInfo.InvertDirection == 0) { values["Transfer"] = "$" + aBusAddress.ToString("X4") + " -> $" + evt.DmaChannelInfo.DestAddress.ToString("X2"); } else { values["Transfer"] = "$" + aBusAddress.ToString("X4") + " <- $" + evt.DmaChannelInfo.DestAddress.ToString("X2"); } } break; case DebugEventType.Breakpoint: //TODO /*ReadOnlyCollection<Breakpoint> breakpoints = BreakpointManager.Breakpoints; * if(debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) { * Breakpoint bp = breakpoints[debugEvent.BreakpointId]; * values["BP Type"] = bp.ToReadableType(); * values["BP Addresses"] = bp.GetAddressString(true); * if(bp.Condition.Length > 0) { * values["BP Condition"] = bp.Condition; * } * }*/ break; } UpdateOverlay(new Point((int)(evt.Cycle * 2 * this.ImageScale), (int)(evt.Scanline * 2 * this.ImageScale))); Form parentForm = this.FindForm(); Point location = parentForm.PointToClient(this.PointToScreen(new Point(e.Location.X - picViewer.ScrollOffsets.X, e.Location.Y - picViewer.ScrollOffsets.Y))); BaseForm.GetPopupTooltip(parentForm).SetTooltip(location, values); }