2016-06-04 14:43:13 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Imaging;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-11-24 18:30:08 -05:00
|
|
|
|
using System.Xml;
|
2016-11-23 23:46:01 -05:00
|
|
|
|
using System.Xml.Serialization;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
using Mesen.GUI.Debugger;
|
2016-12-18 12:43:20 -05:00
|
|
|
|
using Mesen.GUI.Controls;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Config
|
|
|
|
|
{
|
2016-12-04 14:02:22 -05:00
|
|
|
|
public enum ByteCodePosition
|
|
|
|
|
{
|
|
|
|
|
Hidden,
|
|
|
|
|
Left,
|
|
|
|
|
Below
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum PrgAddressPosition
|
|
|
|
|
{
|
|
|
|
|
Hidden,
|
|
|
|
|
Replace,
|
|
|
|
|
Below
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public class DebugViewInfo
|
|
|
|
|
{
|
2016-12-04 14:02:22 -05:00
|
|
|
|
public ByteCodePosition ByteCodePosition = ByteCodePosition.Hidden;
|
|
|
|
|
public PrgAddressPosition PrgAddressPosition = PrgAddressPosition.Hidden;
|
2016-12-18 12:43:20 -05:00
|
|
|
|
public float FontSize = BaseControl.DefaultFontSize;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-23 23:46:01 -05:00
|
|
|
|
public class DebugWorkspace
|
|
|
|
|
{
|
|
|
|
|
public List<Breakpoint> Breakpoints = new List<Breakpoint>();
|
|
|
|
|
public List<string> WatchValues = new List<string>();
|
|
|
|
|
public List<CodeLabel> Labels = new List<CodeLabel>();
|
2017-02-26 19:18:01 -05:00
|
|
|
|
public List<string> TblMappings = null;
|
2016-11-23 23:46:01 -05:00
|
|
|
|
private string _filePath;
|
|
|
|
|
|
|
|
|
|
public static DebugWorkspace GetWorkspace()
|
|
|
|
|
{
|
|
|
|
|
RomInfo info = InteropEmu.GetRomInfo();
|
|
|
|
|
return Deserialize(Path.Combine(ConfigManager.DebuggerFolder, info.GetRomName() + ".Workspace.xml"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static DebugWorkspace Deserialize(string path)
|
|
|
|
|
{
|
|
|
|
|
DebugWorkspace config = config = new DebugWorkspace();
|
|
|
|
|
|
|
|
|
|
if(File.Exists(path)) {
|
|
|
|
|
try {
|
|
|
|
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(DebugWorkspace));
|
|
|
|
|
using(TextReader textReader = new StreamReader(path)) {
|
|
|
|
|
config = (DebugWorkspace)xmlSerializer.Deserialize(textReader);
|
|
|
|
|
}
|
|
|
|
|
} catch { }
|
2017-08-31 23:29:33 -04:00
|
|
|
|
}
|
2016-11-23 23:46:01 -05:00
|
|
|
|
|
|
|
|
|
config._filePath = path;
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
|
|
|
|
try {
|
2016-11-24 18:30:08 -05:00
|
|
|
|
XmlWriterSettings ws = new XmlWriterSettings();
|
|
|
|
|
ws.NewLineHandling = NewLineHandling.Entitize;
|
|
|
|
|
|
2016-11-23 23:46:01 -05:00
|
|
|
|
XmlSerializer xmlSerializer = new XmlSerializer(typeof(DebugWorkspace));
|
2016-11-24 18:30:08 -05:00
|
|
|
|
using(XmlWriter xmlWriter = XmlWriter.Create(_filePath, ws)) {
|
|
|
|
|
xmlSerializer.Serialize(xmlWriter, this);
|
2016-11-23 23:46:01 -05:00
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-05 23:35:07 -05:00
|
|
|
|
public enum DisassemblyType
|
|
|
|
|
{
|
|
|
|
|
VerifiedCode,
|
|
|
|
|
Everything,
|
|
|
|
|
EverythingButData
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public class DebugInfo
|
|
|
|
|
{
|
2017-08-30 18:31:27 -04:00
|
|
|
|
private const int MaxRecentScripts = 10;
|
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public DebugViewInfo LeftView;
|
|
|
|
|
public DebugViewInfo RightView;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
|
|
|
|
public bool ShowOnlyDisassembledCode = true;
|
2016-12-05 23:35:07 -05:00
|
|
|
|
public bool DisplayOpCodesInLowerCase = false;
|
|
|
|
|
public bool ShowEffectiveAddresses = true;
|
|
|
|
|
public DisassemblyType DisassemblyType = DisassemblyType.VerifiedCode;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public bool SplitView = false;
|
|
|
|
|
public bool HexDisplay = true;
|
|
|
|
|
|
|
|
|
|
public bool PpuAutoRefresh = true;
|
2016-06-05 10:26:05 -04:00
|
|
|
|
public bool PpuPartialDraw = false;
|
2016-12-02 18:10:37 -05:00
|
|
|
|
public bool ShowPpuScrollOverlay = true;
|
2016-12-04 10:47:48 -05:00
|
|
|
|
public bool ShowTileGrid = false;
|
|
|
|
|
public bool ShowAttributeGrid = false;
|
2017-08-20 12:06:45 -04:00
|
|
|
|
public bool HighlightChrTile = false;
|
2016-12-02 18:10:37 -05:00
|
|
|
|
public int PpuDisplayCycle = 0;
|
|
|
|
|
public int PpuDisplayScanline = 241;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
|
2016-09-04 18:08:16 -04:00
|
|
|
|
public bool ShowCpuMemoryMapping = true;
|
|
|
|
|
public bool ShowPpuMemoryMapping = true;
|
2016-12-06 22:50:27 -05:00
|
|
|
|
|
|
|
|
|
public bool ShowRightPanel = true;
|
|
|
|
|
public bool ShowBottomPanel = true;
|
|
|
|
|
public int LeftPanelWidth = 930;
|
|
|
|
|
public int TopPanelHeight = 450;
|
2016-09-04 18:08:16 -04:00
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public bool RamAutoRefresh = true;
|
|
|
|
|
public int RamColumnCount = 2;
|
2016-12-18 12:43:20 -05:00
|
|
|
|
public float RamFontSize = BaseControl.DefaultFontSize;
|
2017-02-26 18:58:48 -05:00
|
|
|
|
public bool RamShowCharacters = true;
|
2017-03-01 20:52:15 -05:00
|
|
|
|
public bool RamHighlightExecution = true;
|
|
|
|
|
public bool RamHighlightWrites = true;
|
|
|
|
|
public bool RamHighlightReads = true;
|
|
|
|
|
public int RamFadeSpeed = 300;
|
2017-03-04 23:15:50 -05:00
|
|
|
|
public bool RamHideUnusedBytes;
|
|
|
|
|
public bool RamHideReadBytes;
|
|
|
|
|
public bool RamHideWrittenBytes;
|
|
|
|
|
public bool RamHideExecutedBytes;
|
2017-10-05 19:59:24 -04:00
|
|
|
|
public Size MemoryViewerSize = new Size(0, 0);
|
2016-06-04 14:43:13 -04:00
|
|
|
|
|
2016-11-26 20:58:27 -05:00
|
|
|
|
public int WindowWidth = -1;
|
|
|
|
|
public int WindowHeight = -1;
|
|
|
|
|
|
2016-11-28 20:57:53 -05:00
|
|
|
|
public int BreakInCount = 1;
|
|
|
|
|
public bool BreakInPpuCycles = false;
|
|
|
|
|
|
2016-11-27 19:43:17 -05:00
|
|
|
|
public bool HighlightUnexecutedCode = true;
|
2017-08-31 23:29:33 -04:00
|
|
|
|
|
2016-12-01 20:45:13 -05:00
|
|
|
|
public bool FindOccurrencesMatchCase = false;
|
|
|
|
|
public bool FindOccurrencesMatchWholeWord = false;
|
|
|
|
|
public string FindOccurrencesLastSearch = string.Empty;
|
2016-11-27 19:43:17 -05:00
|
|
|
|
|
2016-12-01 21:43:32 -05:00
|
|
|
|
public bool AutoLoadDbgFiles = false;
|
2017-08-19 22:00:12 -04:00
|
|
|
|
public bool AutoLoadCdlFiles = false;
|
2016-12-04 09:43:43 -05:00
|
|
|
|
public bool DisableDefaultLabels = false;
|
2016-12-01 21:43:32 -05:00
|
|
|
|
|
2017-06-29 13:47:49 -04:00
|
|
|
|
public bool RefreshWatchWhileRunning = false;
|
|
|
|
|
|
2016-12-04 09:37:01 -05:00
|
|
|
|
public bool BreakOnOpen = true;
|
2016-12-04 09:53:25 -05:00
|
|
|
|
public bool BreakOnReset = true;
|
2017-03-04 16:18:28 -05:00
|
|
|
|
public bool BreakOnUnofficialOpcodes = true;
|
|
|
|
|
public bool BreakOnBrk = false;
|
2017-06-29 13:55:12 -04:00
|
|
|
|
public bool BreakOnDebuggerFocus = false;
|
2016-12-04 09:37:01 -05:00
|
|
|
|
|
2017-03-16 21:34:28 -04:00
|
|
|
|
public TraceLoggerOptions TraceLoggerOptions;
|
2017-03-04 15:18:00 -05:00
|
|
|
|
public bool TraceAutoRefresh = true;
|
|
|
|
|
public int TraceLineCount = 1000;
|
|
|
|
|
public bool TraceIndentCode = false;
|
2017-08-06 16:23:22 -04:00
|
|
|
|
public Size TraceLoggerSize = new Size(0, 0);
|
2017-03-04 15:18:00 -05:00
|
|
|
|
|
2017-08-30 18:31:27 -04:00
|
|
|
|
public Size ScriptWindowSize = new Size(0, 0);
|
|
|
|
|
public int ScriptCodeWindowHeight = 0;
|
|
|
|
|
public List<string> RecentScripts = new List<string>();
|
|
|
|
|
public bool SaveScriptBeforeRun = true;
|
2017-09-01 14:57:02 -04:00
|
|
|
|
public ScriptStartupBehavior ScriptStartupBehavior = ScriptStartupBehavior.ShowTutorial;
|
|
|
|
|
public bool AutoLoadLastScript = true;
|
2017-08-30 18:31:27 -04:00
|
|
|
|
public int ScriptZoom = 100;
|
|
|
|
|
|
2017-08-31 23:29:33 -04:00
|
|
|
|
public bool AssemblerCodeHighlighting = true;
|
|
|
|
|
public XmlColor AssemblerOpcodeColor = Color.DarkSlateGray;
|
|
|
|
|
public XmlColor AssemblerLabelDefinitionColor = Color.Blue;
|
|
|
|
|
public XmlColor AssemblerImmediateColor = Color.Chocolate;
|
|
|
|
|
public XmlColor AssemblerAddressColor = Color.DarkRed;
|
|
|
|
|
public XmlColor AssemblerCommentColor = Color.Green;
|
|
|
|
|
public Size AssemblerSize = new Size(0, 0);
|
|
|
|
|
public int AssemblerZoom = 100;
|
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public DebugInfo()
|
|
|
|
|
{
|
|
|
|
|
LeftView = new DebugViewInfo();
|
|
|
|
|
RightView = new DebugViewInfo();
|
2017-03-16 21:34:28 -04:00
|
|
|
|
TraceLoggerOptions = new TraceLoggerOptions() {
|
|
|
|
|
ShowByteCode = true,
|
|
|
|
|
ShowCpuCycles = false,
|
|
|
|
|
ShowEffectiveAddresses = true,
|
|
|
|
|
ShowExtraInfo = true,
|
|
|
|
|
ShowPpuFrames = false,
|
|
|
|
|
ShowPpuCycles = true,
|
|
|
|
|
ShowPpuScanline = true,
|
|
|
|
|
ShowRegisters = true,
|
|
|
|
|
UseLabels = false,
|
|
|
|
|
StatusFormat = StatusFlagFormat.Hexadecimal
|
|
|
|
|
};
|
2016-06-04 14:43:13 -04:00
|
|
|
|
}
|
2017-08-30 18:31:27 -04:00
|
|
|
|
|
|
|
|
|
public void AddRecentScript(string scriptFile)
|
|
|
|
|
{
|
|
|
|
|
string existingItem = RecentScripts.Where((file) => file == scriptFile).FirstOrDefault();
|
|
|
|
|
if(existingItem != null) {
|
|
|
|
|
RecentScripts.Remove(existingItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RecentScripts.Insert(0, scriptFile);
|
|
|
|
|
if(RecentScripts.Count > DebugInfo.MaxRecentScripts) {
|
|
|
|
|
RecentScripts.RemoveAt(DebugInfo.MaxRecentScripts);
|
|
|
|
|
}
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
2016-06-04 14:43:13 -04:00
|
|
|
|
}
|
2017-08-31 23:29:33 -04:00
|
|
|
|
|
2017-09-01 14:57:02 -04:00
|
|
|
|
public enum ScriptStartupBehavior
|
|
|
|
|
{
|
|
|
|
|
ShowTutorial = 0,
|
|
|
|
|
ShowBlankWindow = 1,
|
|
|
|
|
LoadLastScript = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-08-31 23:29:33 -04:00
|
|
|
|
public class XmlColor
|
|
|
|
|
{
|
|
|
|
|
private Color _color = Color.Black;
|
|
|
|
|
|
|
|
|
|
public XmlColor() { }
|
|
|
|
|
public XmlColor(Color c) { _color = c; }
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public Color Color
|
|
|
|
|
{
|
|
|
|
|
get { return _color; }
|
|
|
|
|
set { _color = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static implicit operator Color(XmlColor x)
|
|
|
|
|
{
|
|
|
|
|
return x.Color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static implicit operator XmlColor(Color c)
|
|
|
|
|
{
|
|
|
|
|
return new XmlColor(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[XmlAttribute]
|
|
|
|
|
public string ColorString
|
|
|
|
|
{
|
|
|
|
|
get { return ColorTranslator.ToHtml(_color); }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
_color = ColorTranslator.FromHtml(value);
|
|
|
|
|
} catch(Exception) {
|
|
|
|
|
_color = Color.Black;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-04 14:43:13 -04:00
|
|
|
|
}
|