private void RefreshData() { if (_formClosed) { return; } if (DebugWorkspaceManager.GetWorkspace() != this._previousWorkspace) { this.InitTblMappings(); _previousWorkspace = DebugWorkspaceManager.GetWorkspace(); } if (this.tabMain.SelectedTab == this.tpgAccessCounters) { this.ctrlMemoryAccessCounters.RefreshData(); } else if (this.tabMain.SelectedTab == this.tpgMemoryViewer) { this.UpdateByteColorProvider(); this.ctrlHexViewer.RefreshData(_memoryType); } else if (this.tabMain.SelectedTab == this.tpgProfiler) { this.ctrlProfiler.RefreshData(); } }
private void UpdateWorkspace() { DebugWorkspaceManager.SaveWorkspace(); DebugWorkspace workspace = DebugWorkspaceManager.GetWorkspace(); ctrlLabelList.UpdateLabelList(); ctrlFunctionList.UpdateFunctionList(true); ctrlBreakpoints.RefreshList(); }
public static Form OpenDebugWindow(DebugWindow window) { Form existingWindow = GetExistingSingleInstanceWindow(window); if (existingWindow != null) { existingWindow.BringToFront(); if (existingWindow.WindowState == FormWindowState.Minimized) { //Unminimize window if it was minimized existingWindow.WindowState = FormWindowState.Normal; } existingWindow.Focus(); return(existingWindow); } else { BaseForm frm = null; switch (window) { case DebugWindow.PpuViewer: frm = new frmPpuViewer(); frm.Icon = Properties.Resources.Video; break; case DebugWindow.TraceLogger: frm = new frmTraceLogger(); frm.Icon = Properties.Resources.LogWindow; break; case DebugWindow.MemoryViewer: frm = new frmMemoryViewer(); frm.Icon = Properties.Resources.CheatCode; break; case DebugWindow.Assembler: frm = new frmAssembler(); frm.Icon = Properties.Resources.Chip; break; case DebugWindow.Debugger: frm = new frmDebugger(); frm.Icon = Properties.Resources.Bug; break; case DebugWindow.ScriptWindow: frm = new frmScript(); frm.Icon = Properties.Resources.Script; break; case DebugWindow.ApuViewer: frm = new frmApuViewer(); frm.Icon = Properties.Resources.Audio; break; case DebugWindow.EventViewer: frm = new frmEventViewer(); frm.Icon = Properties.Resources.NesEventViewer; break; case DebugWindow.TextHooker: frm = new frmTextHooker(); frm.Icon = Properties.Resources.Font; break; case DebugWindow.Profiler: frm = new frmProfiler(); frm.Icon = Properties.Resources.Speed; break; case DebugWindow.WatchWindow: frm = new frmWatchWindow(); frm.Icon = Properties.Resources.Find; break; } if (_openedWindows.Count == 0) { DebugWorkspaceManager.GetWorkspace(); DebugWorkspaceManager.AutoLoadDbgFiles(true); } _openedWindows.Add(frm); frm.FormClosed += Debugger_FormClosed; frm.Show(); return(frm); } }
public static Form OpenDebugWindow(DebugWindow window) { Form existingWindow = GetExistingSingleInstanceWindow(window); if (existingWindow != null) { BringToFront(existingWindow); return(existingWindow); } else { BaseForm frm = null; switch (window) { case DebugWindow.Debugger: frm = new frmDebugger(CpuType.Cpu); frm.Icon = Properties.Resources.Debugger; break; case DebugWindow.SpcDebugger: frm = new frmDebugger(CpuType.Spc); frm.Icon = Properties.Resources.SpcDebugger; break; case DebugWindow.Sa1Debugger: frm = new frmDebugger(CpuType.Sa1); frm.Icon = Properties.Resources.Sa1Debugger; break; case DebugWindow.GsuDebugger: frm = new frmDebugger(CpuType.Gsu); frm.Icon = Properties.Resources.GsuDebugger; break; case DebugWindow.TraceLogger: frm = new frmTraceLogger(); frm.Icon = Properties.Resources.LogWindow; break; case DebugWindow.MemoryTools: frm = new frmMemoryTools(); frm.Icon = Properties.Resources.CheatCode; break; case DebugWindow.TileViewer: frm = new frmTileViewer(); frm.Icon = Properties.Resources.VerticalLayout; break; case DebugWindow.TilemapViewer: frm = new frmTilemapViewer(); frm.Icon = Properties.Resources.VideoOptions; break; case DebugWindow.PaletteViewer: frm = new frmPaletteViewer(); frm.Icon = Properties.Resources.VideoFilter; break; case DebugWindow.SpriteViewer: frm = new frmSpriteViewer(); frm.Icon = Properties.Resources.PerfTracker; break; case DebugWindow.EventViewer: frm = new frmEventViewer(); frm.Icon = Properties.Resources.NesEventViewer; break; case DebugWindow.ScriptWindow: frm = new frmScript(); frm.Icon = Properties.Resources.Script; break; case DebugWindow.RegisterViewer: frm = new frmRegisterViewer(); frm.Icon = Properties.Resources.RegisterIcon; break; } if (_openedWindows.Count == 0) { DebugWorkspaceManager.GetWorkspace(); } _openedWindows.Add(frm); frm.FormClosed += Debugger_FormClosed; frm.Show(); return(frm); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!DesignMode) { DebugWorkspaceManager.GetWorkspace(); DebugWorkspaceManager.AutoLoadDbgFiles(true); _notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId); _notifListener.OnNotification += _notifListener_OnNotification; ctrlWatch.UpdateWatch(true); } }
public static void OpenAssembler(CpuType cpuType, string code = "", int startAddress = 0, int blockLength = 0) { if (_openedWindows.Count == 0) { DebugWorkspaceManager.GetWorkspace(); } frmAssembler frm = new frmAssembler(cpuType, code, startAddress, blockLength); frm.Icon = Properties.Resources.Chip; _openedWindows.Add(frm); frm.FormClosed += Debugger_FormClosed; frm.Show(); }
private void OnNotificationReceived(NotificationEventArgs e) { switch (e.NotificationType) { case ConsoleNotificationType.GameLoaded: { if (ConfigManager.Config.Debug.Debugger.BreakOnPowerCycleReset) { DebugApi.Step(_cpuType, 1, StepType.Step); } BreakpointManager.SetBreakpoints(); DebugState state = DebugApi.GetState(); this.BeginInvoke((MethodInvoker)(() => { //Refresh workspace here as well as frmMain to ensure workspace //is up-to-date no matter which form is notified first. DebugWorkspaceManager.GetWorkspace(); bool isPowerCycle = e.Parameter.ToInt32() != 0; if (!isPowerCycle) { DebugWorkspaceManager.AutoImportSymbols(); } LabelManager.RefreshLabels(); DebugApi.RefreshDisassembly(_cpuType); UpdateDebugger(state, null); })); break; } case ConsoleNotificationType.GameReset: if (ConfigManager.Config.Debug.Debugger.BreakOnPowerCycleReset) { DebugApi.Step(_cpuType, 1, StepType.PpuStep); } break; case ConsoleNotificationType.PpuFrameDone: this.BeginInvoke((MethodInvoker)(() => { UpdateContinueAction(); })); break; case ConsoleNotificationType.CodeBreak: { BreakEvent evt = (BreakEvent)Marshal.PtrToStructure(e.Parameter, typeof(BreakEvent)); RefreshDebugger(evt); break; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!this.DesignMode) { this.mnuRefreshOnBreak.Checked = ConfigManager.Config.DebugInfo.EventViewerRefreshOnBreak; this.chkShowPpuRegisterWrites.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPpuRegisterWrites; this.chkShowPpuRegisterReads.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPpuRegisterReads; this.chkShowIrq.Checked = ConfigManager.Config.DebugInfo.EventViewerShowIrq; this.chkShowNmi.Checked = ConfigManager.Config.DebugInfo.EventViewerShowNmi; this.chkShowSpriteZero.Checked = ConfigManager.Config.DebugInfo.EventViewerShowSpriteZeroHit; this.chkShowMapperRegisterWrites.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMapperRegisterWrites; this.chkShowMapperRegisterReads.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMapperRegisterReads; this.chkBreakpoints.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMarkedBreakpoints; this.chkShowPreviousFrameEvents.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPreviousFrameEvents; string toggleViewTooltip = "Toggle Compact/Normal View"; if (ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView != Keys.None) { toggleViewTooltip += " (" + DebuggerShortcutsConfig.GetShortcutDisplay(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) + ")"; } this.toolTip.SetToolTip(this.btnToggleView, toggleViewTooltip); string toggleZoomTooltip = "Toggle 2x Zoom"; if (ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleZoom != Keys.None) { toggleZoomTooltip += " (" + DebuggerShortcutsConfig.GetShortcutDisplay(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleZoom) + ")"; } this.toolTip.SetToolTip(this.chkToggleZoom, toggleZoomTooltip); _previousPictureSize = ctrlEventViewerPpuView.Size; this.GetData(); this.RefreshViewer(); DebugWorkspaceManager.GetWorkspace(); if (!ConfigManager.Config.DebugInfo.EventViewerLocation.IsEmpty) { this.StartPosition = FormStartPosition.Manual; this.Location = ConfigManager.Config.DebugInfo.EventViewerLocation; } this._notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId); this._notifListener.OnNotification += this._notifListener_OnNotification; } }
public static Form OpenDebugWindow(DebugWindow window) { Form existingWindow = GetExistingSingleInstanceWindow(window); if (existingWindow != null) { existingWindow.BringToFront(); if (existingWindow.WindowState == FormWindowState.Minimized) { //Unminimize window if it was minimized existingWindow.WindowState = FormWindowState.Normal; } existingWindow.Focus(); return(existingWindow); } else { BaseForm frm = null; switch (window) { case DebugWindow.Debugger: frm = new frmDebugger(CpuType.Cpu); frm.Icon = Properties.Resources.Debugger; break; case DebugWindow.SpcDebugger: frm = new frmDebugger(CpuType.Spc); frm.Icon = Properties.Resources.SpcDebugger; break; case DebugWindow.TraceLogger: frm = new frmTraceLogger(); frm.Icon = Properties.Resources.LogWindow; break; case DebugWindow.MemoryTools: frm = new frmMemoryTools(); frm.Icon = Properties.Resources.CheatCode; break; case DebugWindow.TileViewer: frm = new frmTileViewer(); frm.Icon = Properties.Resources.VerticalLayout; break; case DebugWindow.TilemapViewer: frm = new frmTilemapViewer(); frm.Icon = Properties.Resources.VideoOptions; break; case DebugWindow.PaletteViewer: frm = new frmPaletteViewer(); frm.Icon = Properties.Resources.VideoFilter; break; case DebugWindow.EventViewer: frm = new frmEventViewer(); frm.Icon = Properties.Resources.NesEventViewer; break; } if (_openedWindows.Count == 0) { DebugWorkspaceManager.GetWorkspace(); } _openedWindows.Add(frm); frm.FormClosed += Debugger_FormClosed; frm.Show(); return(frm); } }
private void InitTblMappings() { DebugWorkspace workspace = DebugWorkspaceManager.GetWorkspace(); if (workspace.TblMappings != null && workspace.TblMappings.Count > 0) { var tblDict = TblLoader.ToDictionary(workspace.TblMappings.ToArray()); if (tblDict != null) { this.ctrlHexViewer.ByteCharConverter = new TblByteCharConverter(tblDict); } } else { this.ctrlHexViewer.ByteCharConverter = null; } }
private void RefreshData() { if (DebugWorkspaceManager.GetWorkspace() != this._previousWorkspace) { this.InitTblMappings(); _previousWorkspace = DebugWorkspaceManager.GetWorkspace(); } if (this.tabMain.SelectedTab == this.tpgAccessCounters) { this.ctrlMemoryAccessCounters.RefreshData(); } else if (this.tabMain.SelectedTab == this.tpgMemoryViewer) { this.UpdateByteColorProvider(); this.ctrlHexViewer.SetData(InteropEmu.DebugGetMemoryState(this._memoryType)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!this.DesignMode) { this.GetData(); this.RefreshViewer(); DebugWorkspaceManager.GetWorkspace(); if (!ConfigManager.Config.DebugInfo.EventViewerSize.IsEmpty) { this.Size = ConfigManager.Config.DebugInfo.EventViewerSize; } this._notifListener = new InteropEmu.NotificationListener(); this._notifListener.OnNotification += this._notifListener_OnNotification; } }
private void mnuLoadTblFile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.SetFilter("TBL files (*.tbl)|*.tbl"); if (ofd.ShowDialog() == DialogResult.OK) { string[] fileContents = File.ReadAllLines(ofd.FileName); var tblDict = TblLoader.ToDictionary(fileContents); if (tblDict == null) { MessageBox.Show("Could not load TBL file. The file selected file appears to be invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DebugWorkspaceManager.GetWorkspace().TblMappings = new List <string>(fileContents); this.ctrlHexViewer.ByteCharConverter = new TblByteCharConverter(tblDict); this.mnuShowCharacters.Checked = true; } } }
private void RefreshLog(bool scrollToBottom, bool forceUpdate) { if (_refreshRunning) { return; } //Make sure labels are up to date DebugWorkspaceManager.GetWorkspace(); _refreshRunning = true; SetOptions(); Task.Run(() => { //Update trace log in another thread for performance DebugState state = new DebugState(); InteropEmu.DebugGetState(ref state); if (_previousCycleCount != state.CPU.CycleCount || forceUpdate) { string newTrace = InteropEmu.DebugGetExecutionTrace((UInt32)_lineCount); _previousCycleCount = state.CPU.CycleCount; _previousTrace = newTrace; int index = 0; string line = null; Func <bool> readLine = () => { if (index < newTrace.Length) { int endOfLineIndex = newTrace.IndexOf('\n', index); line = newTrace.Substring(index, endOfLineIndex - index); index = endOfLineIndex + 1; return(true); } else { return(false); } }; List <int> programCounter = new List <int>(30000); List <string> byteCode = new List <string>(30000); List <string> lineContent = new List <string>(30000); List <int> indent = new List <int>(30000); bool showByteCode = false; while (readLine()) { string[] parts = line.Split('\x1'); programCounter.Add(Int32.Parse(parts[0], System.Globalization.NumberStyles.HexNumber)); byteCode.Add(parts[1]); string content = parts[2]; while (true) { string str = content.TrimStart(); if (str.StartsWith(parts[0])) { content = str.Substring(4); } else if (str.StartsWith(parts[1])) { content = str.Substring(11); showByteCode = true; } else if (str.StartsWith(parts[1].Replace("$", ""))) { content = str.Substring(8); showByteCode = true; } else { break; } } lineContent.Add(content); indent.Add(0); } this.BeginInvoke((Action)(() => { txtTraceLog.ShowContentNotes = showByteCode; txtTraceLog.ShowSingleContentLineNotes = showByteCode; txtTraceLog.LineIndentations = indent.ToArray(); txtTraceLog.LineNumbers = programCounter.ToArray(); txtTraceLog.TextLineNotes = byteCode.ToArray(); txtTraceLog.TextLines = lineContent.ToArray(); if (scrollToBottom) { txtTraceLog.ScrollToLineIndex(txtTraceLog.LineCount - 1); } })); } _refreshRunning = false; }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!this.DesignMode) { _binder.Entity = _config; mnuRefreshOnBreak.Checked = _config.EventViewerRefreshOnBreak; _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2000), chkWrite2000); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2001), chkWrite2001); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2003), chkWrite2003); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2004), chkWrite2004); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2005), chkWrite2005); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2006), chkWrite2006); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuWrite2007), chkWrite2007); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuRead2002), chkRead2002); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuRead2004), chkRead2004); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPpuRead2007), chkRead2007); _binder.AddBinding(nameof(DebugInfo.EventViewerShowIrq), chkShowIrq); _binder.AddBinding(nameof(DebugInfo.EventViewerShowNmi), chkShowNmi); _binder.AddBinding(nameof(DebugInfo.EventViewerShowSpriteZeroHit), chkShowSpriteZero); _binder.AddBinding(nameof(DebugInfo.EventViewerShowMapperRegisterWrites), chkShowMapperRegisterWrites); _binder.AddBinding(nameof(DebugInfo.EventViewerShowMapperRegisterReads), chkShowMapperRegisterReads); _binder.AddBinding(nameof(DebugInfo.EventViewerShowDmcDmaReads), chkShowDmcDmaRead); _binder.AddBinding(nameof(DebugInfo.EventViewerShowMarkedBreakpoints), chkBreakpoints); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2000Color), picWrite2000); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2001Color), picWrite2001); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2003Color), picWrite2003); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2004Color), picWrite2004); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2005Color), picWrite2005); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2006Color), picWrite2006); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterWrite2007Color), picWrite2007); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterRead2002Color), picRead2002); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterRead2004Color), picRead2004); _binder.AddBinding(nameof(DebugInfo.EventViewerPpuRegisterRead2007Color), picRead2007); _binder.AddBinding(nameof(DebugInfo.EventViewerMapperRegisterWriteColor), picMapperWrite); _binder.AddBinding(nameof(DebugInfo.EventViewerMapperRegisterReadColor), picMapperRead); _binder.AddBinding(nameof(DebugInfo.EventViewerNmiColor), picNmi); _binder.AddBinding(nameof(DebugInfo.EventViewerIrqColor), picIrq); _binder.AddBinding(nameof(DebugInfo.EventViewerSpriteZeroHitColor), picSpriteZeroHit); _binder.AddBinding(nameof(DebugInfo.EventViewerBreakpointColor), picBreakpoint); _binder.AddBinding(nameof(DebugInfo.EventViewerDmcDmaReadColor), picDmcDmaRead); _binder.AddBinding(nameof(DebugInfo.EventViewerShowPreviousFrameEvents), chkShowPreviousFrameEvents); _binder.AddBinding(nameof(DebugInfo.EventViewerShowNtscBorders), chkShowNtscBorders); DebugWorkspaceManager.GetWorkspace(); RestoreLocation(_config.EventViewerLocation, _config.EventViewerSize); mnuAutoRefresh.Checked = _config.EventViewerAutoRefresh; mnuAutoRefreshLow.Click += (s, evt) => _refreshManager.AutoRefreshSpeed = RefreshSpeed.Low; mnuAutoRefreshNormal.Click += (s, evt) => _refreshManager.AutoRefreshSpeed = RefreshSpeed.Normal; mnuAutoRefreshHigh.Click += (s, evt) => _refreshManager.AutoRefreshSpeed = RefreshSpeed.High; mnuAutoRefreshSpeed.DropDownOpening += (s, evt) => UpdateRefreshSpeedMenu(); this.RefreshData(); _binder.UpdateUI(); this.RefreshViewer(); _refreshManager = new WindowRefreshManager(this); _refreshManager.AutoRefresh = _config.EventViewerAutoRefresh; _refreshManager.AutoRefreshSpeed = _config.EventViewerAutoRefreshSpeed; this._notifListener = new InteropEmu.NotificationListener(_config.DebugConsoleId); this._notifListener.OnNotification += this._notifListener_OnNotification; InitShortcuts(); } }
public frmScript(bool forceBlank = false) { InitializeComponent(); ThemeHelper.ExcludeFromTheme(txtScriptContent); txtScriptContent.ForeColor = Color.Black; DebugInfo.ApplyConfig(); List <string> builtInScripts = new List <string> { "DmcCapture.lua", "DrawMode.lua", "Example.lua", "GameBoyMode.lua", "Grid.lua", "LogParallax.lua", "ModifyScreen.lua", "NtscSafeArea.lua", "ReverseMode.lua", "SpriteBox.lua" }; foreach (string script in builtInScripts) { ToolStripItem item = mnuBuiltInScripts.DropDownItems.Add(script); item.Click += (s, e) => { LoadBuiltInScript(item.Text); }; } tsToolbar.AddItemsToToolbar( mnuOpen, mnuSave, null, mnuRun, mnuStop, null, mnuBuiltInScripts ); //Make sure labels are loaded DebugWorkspaceManager.GetWorkspace(); DebugInfo config = ConfigManager.Config.DebugInfo; _popupMenu = new AutocompleteMenu(txtScriptContent, this); _popupMenu.ImageList = new ImageList(); _popupMenu.ImageList.Images.Add(Resources.Enum); _popupMenu.ImageList.Images.Add(Resources.Function); _popupMenu.SelectedColor = Color.LightBlue; _popupMenu.SearchPattern = @"[\w\.]"; List <AutocompleteItem> items = new List <AutocompleteItem>(); _availableFunctions.Sort((a, b) => { int type = a[0].CompareTo(b[0]); if (type == 0) { return(a[1].CompareTo(b[1])); } else { return(-type); } }); foreach (List <string> item in _availableFunctions) { MethodAutocompleteItem autocompleteItem = new MethodAutocompleteItem(item[1]); autocompleteItem.ImageIndex = item[0] == "func" ? 1 : 0; autocompleteItem.ToolTipTitle = item[2]; if (!string.IsNullOrWhiteSpace(item[3])) { autocompleteItem.ToolTipText = "Parameters" + Environment.NewLine + item[3] + Environment.NewLine + Environment.NewLine; } if (!string.IsNullOrWhiteSpace(item[4])) { autocompleteItem.ToolTipText += "Return Value" + Environment.NewLine + item[4] + Environment.NewLine + Environment.NewLine; } if (!string.IsNullOrWhiteSpace(item[5])) { autocompleteItem.ToolTipText += "Description" + Environment.NewLine + item[5] + Environment.NewLine + Environment.NewLine; } items.Add(autocompleteItem); } _popupMenu.Items.SetAutocompleteItems(items); UpdateRecentScripts(); mnuTutorialScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowTutorial; mnuBlankWindow.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowBlankWindow; mnuAutoLoadLastScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.LoadLastScript; if (!forceBlank) { if (mnuAutoLoadLastScript.Checked && mnuRecentScripts.DropDownItems.Count > 0) { string scriptToLoad = config.RecentScripts.Where((s) => File.Exists(s)).FirstOrDefault(); if (scriptToLoad != null) { LoadScriptFile(scriptToLoad, false); } } else if (mnuTutorialScript.Checked) { LoadBuiltInScript("Example.lua"); } } RestoreLocation(config.ScriptWindowLocation, config.ScriptWindowSize); mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun; if (config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize) { if (config.ScriptCodeWindowHeight == Int32.MaxValue) { ctrlSplit.CollapsePanel(); } else { ctrlSplit.SplitterDistance = config.ScriptCodeWindowHeight; } } txtScriptContent.Font = new Font(config.ScriptFontFamily, config.ScriptFontSize, config.ScriptFontStyle); txtScriptContent.Zoom = config.ScriptZoom; }
private void RefreshLog(bool scrollToBottom) { if (_refreshRunning) { return; } //Make sure labels are up to date DebugWorkspaceManager.GetWorkspace(); _refreshRunning = true; SetOptions(); Task.Run(() => { //Update trace log in another thread for performance DebugState state = new DebugState(); InteropEmu.DebugGetState(ref state); if (_previousCycleCount != state.CPU.CycleCount) { string newTrace = InteropEmu.DebugGetExecutionTrace((UInt32)_lineCount); _previousCycleCount = state.CPU.CycleCount; _previousTrace = newTrace; int index = 0; string line = null; Func <bool> readLine = () => { if (index < newTrace.Length) { int endOfLineIndex = newTrace.IndexOf('\n', index); line = newTrace.Substring(index, endOfLineIndex - index); index = endOfLineIndex + 1; return(true); } else { return(false); } }; List <int> programCounter = new List <int>(30000); List <string> byteCode = new List <string>(30000); List <string> lineContent = new List <string>(30000); List <int> indent = new List <int>(30000); char[] splitter = new char[] { ' ' }; while (readLine()) { programCounter.Add(Int32.Parse(line.Substring(0, 4), System.Globalization.NumberStyles.HexNumber)); byteCode.Add(line.Substring(6, 11)); lineContent.Add(line.Substring(19)); indent.Add(6); } this.BeginInvoke((Action)(() => { txtTraceLog.ShowContentNotes = chkShowByteCode.Checked; txtTraceLog.ShowSingleContentLineNotes = chkShowByteCode.Checked; txtTraceLog.LineIndentations = indent.ToArray(); txtTraceLog.LineNumbers = programCounter.ToArray(); txtTraceLog.TextLineNotes = byteCode.ToArray(); txtTraceLog.TextLines = lineContent.ToArray(); if (scrollToBottom) { txtTraceLog.ScrollToLineIndex(txtTraceLog.LineCount - 1); } })); } _refreshRunning = false; }); }
private void mnuResetTblMappings_Click(object sender, EventArgs e) { DebugWorkspaceManager.GetWorkspace().TblMappings = null; this.ctrlHexViewer.ByteCharConverter = null; }