diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 7f15808c2..b8ec03824 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -21,6 +21,7 @@ namespace GSDumpGUI static public TCPLibrary.MessageBased.Core.BaseMessageClient Client; static private Boolean ChangeIcon; static private GSDump dump; + static private GSDXWrapper wrap; [STAThread] static void Main(String[] args) @@ -66,7 +67,7 @@ namespace GSDumpGUI String Operation = args[2]; Int32 Renderer = Convert.ToInt32(args[3]); - GSDXWrapper wrap = new GSDXWrapper(); + wrap = new GSDXWrapper(); wrap.Load(DLLPath); Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + Path.GetFileName(DLLPath) + "\\")); if (Operation == "GSReplay") @@ -149,6 +150,53 @@ namespace GSDumpGUI { MessageBox.Show("Savestate too old to be read. :(", "Warning"); frmMain.Focus(); + }), new object[] { null }); + break; + case MessageType.GetDebugMode: + frmMain.Invoke(new Action(delegate(object e) + { + frmMain.chkDebugMode.Checked = (Boolean)Mess.Parameters[0]; + + frmMain.lblGif.Enabled = frmMain.chkDebugMode.Checked; + frmMain.btnRunToSelection.Enabled = frmMain.chkDebugMode.Checked; + frmMain.treTreeView.Enabled = frmMain.chkDebugMode.Checked; + frmMain.btnStep.Enabled = frmMain.chkDebugMode.Checked; + if (frmMain.chkDebugMode.Checked == false) + frmMain.treTreeView.Nodes.Clear(); + + }), new object[] { null }); + break; + case MessageType.DebugState: + frmMain.Invoke(new Action(delegate(object e) + { + frmMain.treTreeView.Nodes.Clear(); + List parents = new List(); + List nodes = new List(); + foreach (var itm in Mess.Parameters) + { + String[] parts = itm.ToString().Split(new char[] { '|' }); + switch (parts[1]) + { + case "Transfer": + nodes.Add(new TreeNode(parts[0] + " - " + parts[1] + " - " + parts[2])); + break; + case "ReadFIFO2": + nodes.Add(new TreeNode(parts[0] + " - " + parts[1])); + break; + case "VSync": + TreeNode tn = new TreeNode(); + tn.Text = parts[0] + " - " + parts[1]; + tn.Nodes.AddRange(nodes.ToArray()); + parents.Add(tn); + + nodes.Clear(); + break; + case "Registers": + nodes.Add(new TreeNode(parts[0] + " - " + parts[1])); + break; + } + } + frmMain.treTreeView.Nodes.AddRange(parents.ToArray()); }), new object[] { null }); break; default: @@ -199,6 +247,37 @@ namespace GSDumpGUI } Client.Send(msg); break; + case MessageType.SetDebugMode: + wrap.DebugMode = (Boolean)Mess.Parameters[0]; + + msg = new TCPMessage(); + msg.MessageType = MessageType.GetDebugMode; + msg.Parameters.Add(wrap.DebugMode); + Client.Send(msg); + + if (wrap.DebugMode) + { + msg = new TCPMessage(); + msg.MessageType = MessageType.DebugState; + msg.Parameters.AddRange(wrap.GetGifPackets(dump)); + Client.Send(msg); + } + break; + case MessageType.GetDebugMode: + msg = new TCPMessage(); + msg.MessageType = MessageType.GetDebugMode; + msg.Parameters.Add(wrap.DebugMode); + Client.Send(msg); + + if (wrap.DebugMode) + { + msg = new TCPMessage(); + msg.MessageType = MessageType.DebugState; + msg.Parameters.AddRange(wrap.GetGifPackets(dump)); + Client.Send(msg); + } + break; + default: break; } diff --git a/tools/GSDumpGUI/Forms/frmMain.Designer.cs b/tools/GSDumpGUI/Forms/frmMain.Designer.cs index b7f37384f..9b0af7949 100644 --- a/tools/GSDumpGUI/Forms/frmMain.Designer.cs +++ b/tools/GSDumpGUI/Forms/frmMain.Designer.cs @@ -58,7 +58,6 @@ this.lblChild = new System.Windows.Forms.Label(); this.lblDumpSize = new System.Windows.Forms.Label(); this.txtDumpSize = new System.Windows.Forms.Label(); - this.lblWIP = new System.Windows.Forms.Label(); this.txtGIFPackets = new System.Windows.Forms.Label(); this.lblGIFPackets = new System.Windows.Forms.Label(); this.txtPath1 = new System.Windows.Forms.Label(); @@ -73,6 +72,11 @@ this.label7 = new System.Windows.Forms.Label(); this.txtRegisters = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); + this.chkDebugMode = new System.Windows.Forms.CheckBox(); + this.lblGif = new System.Windows.Forms.Label(); + this.btnStep = new System.Windows.Forms.Button(); + this.btnRunToSelection = new System.Windows.Forms.Button(); + this.treTreeView = new System.Windows.Forms.TreeView(); ((System.ComponentModel.ISupportInitialize)(this.pctBox)).BeginInit(); this.SuspendLayout(); // @@ -368,17 +372,6 @@ this.txtDumpSize.Size = new System.Drawing.Size(0, 13); this.txtDumpSize.TabIndex = 30; // - // lblWIP - // - this.lblWIP.AutoSize = true; - this.lblWIP.Font = new System.Drawing.Font("Times New Roman", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblWIP.ForeColor = System.Drawing.Color.Red; - this.lblWIP.Location = new System.Drawing.Point(468, 587); - this.lblWIP.Name = "lblWIP"; - this.lblWIP.Size = new System.Drawing.Size(508, 73); - this.lblWIP.TabIndex = 31; - this.lblWIP.Text = "Work in Progress"; - // // txtGIFPackets // this.txtGIFPackets.AutoSize = true; @@ -505,11 +498,70 @@ this.label6.TabIndex = 44; this.label6.Text = "Registers Packets"; // + // chkDebugMode + // + this.chkDebugMode.AutoSize = true; + this.chkDebugMode.Enabled = false; + this.chkDebugMode.Location = new System.Drawing.Point(481, 487); + this.chkDebugMode.Name = "chkDebugMode"; + this.chkDebugMode.Size = new System.Drawing.Size(88, 17); + this.chkDebugMode.TabIndex = 46; + this.chkDebugMode.Text = "Debug Mode"; + this.chkDebugMode.UseVisualStyleBackColor = true; + this.chkDebugMode.CheckedChanged += new System.EventHandler(this.chkDebugMode_CheckedChanged); + // + // lblGif + // + this.lblGif.AutoSize = true; + this.lblGif.Enabled = false; + this.lblGif.Location = new System.Drawing.Point(427, 520); + this.lblGif.Name = "lblGif"; + this.lblGif.Size = new System.Drawing.Size(66, 13); + this.lblGif.TabIndex = 48; + this.lblGif.Text = "GIF Packets"; + // + // btnStep + // + this.btnStep.Enabled = false; + this.btnStep.Location = new System.Drawing.Point(629, 533); + this.btnStep.Name = "btnStep"; + this.btnStep.Size = new System.Drawing.Size(108, 40); + this.btnStep.TabIndex = 49; + this.btnStep.TabStop = false; + this.btnStep.Text = "Step"; + this.btnStep.UseVisualStyleBackColor = true; + this.btnStep.Click += new System.EventHandler(this.btnStep_Click); + // + // btnRunToSelection + // + this.btnRunToSelection.Enabled = false; + this.btnRunToSelection.Location = new System.Drawing.Point(629, 579); + this.btnRunToSelection.Name = "btnRunToSelection"; + this.btnRunToSelection.Size = new System.Drawing.Size(108, 40); + this.btnRunToSelection.TabIndex = 50; + this.btnRunToSelection.TabStop = false; + this.btnRunToSelection.Text = "Run To Selection"; + this.btnRunToSelection.UseVisualStyleBackColor = true; + this.btnRunToSelection.Click += new System.EventHandler(this.btnRunToSelection_Click); + // + // treTreeView + // + this.treTreeView.Enabled = false; + this.treTreeView.Location = new System.Drawing.Point(420, 539); + this.treTreeView.Name = "treTreeView"; + this.treTreeView.Size = new System.Drawing.Size(200, 240); + this.treTreeView.TabIndex = 51; + // // GSDumpGUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(988, 790); + this.Controls.Add(this.treTreeView); + this.Controls.Add(this.btnRunToSelection); + this.Controls.Add(this.btnStep); + this.Controls.Add(this.lblGif); + this.Controls.Add(this.chkDebugMode); this.Controls.Add(this.txtRegisters); this.Controls.Add(this.label6); this.Controls.Add(this.txtReadFifo); @@ -524,7 +576,6 @@ this.Controls.Add(this.label2); this.Controls.Add(this.txtGIFPackets); this.Controls.Add(this.lblGIFPackets); - this.Controls.Add(this.lblWIP); this.Controls.Add(this.txtDumpSize); this.Controls.Add(this.lblDumpSize); this.Controls.Add(this.lstProcesses); @@ -599,7 +650,6 @@ public System.Windows.Forms.ListBox lstProcesses; private System.Windows.Forms.Label lblDumpSize; public System.Windows.Forms.Label txtDumpSize; - private System.Windows.Forms.Label lblWIP; public System.Windows.Forms.Label txtGIFPackets; private System.Windows.Forms.Label lblGIFPackets; public System.Windows.Forms.Label txtPath1; @@ -614,6 +664,11 @@ private System.Windows.Forms.Label label7; public System.Windows.Forms.Label txtRegisters; private System.Windows.Forms.Label label6; + public System.Windows.Forms.CheckBox chkDebugMode; + public System.Windows.Forms.TreeView treTreeView; + public System.Windows.Forms.Label lblGif; + public System.Windows.Forms.Button btnStep; + public System.Windows.Forms.Button btnRunToSelection; } } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index dcdaa20c2..6a26822ac 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -195,10 +195,17 @@ namespace GSDumpGUI { String ini = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini"); int pos = ini.IndexOf("Renderer=", 0); - String newini = ini.Substring(0, pos + 9); - newini += SelectedRenderer; - newini += ini.Substring(pos + 10, ini.Length - pos - 10); - File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", newini); + if (pos != -1) + { + String newini = ini.Substring(0, pos + 9); + newini += SelectedRenderer; + newini += ini.Substring(pos + 10, ini.Length - pos - 10); + File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", newini); + } + else + { + File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", ini + Environment.NewLine + "Renderer=" + SelectedRenderer); + } } } if (lstDumps.SelectedItem != null) @@ -369,13 +376,43 @@ namespace GSDumpGUI { if (lstProcesses.SelectedIndex != -1) { + chkDebugMode.Enabled = true; + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.GetDebugMode; + msg.Parameters.Add(chkDebugMode.Checked); + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + + msg = new TCPMessage(); msg.MessageType = MessageType.SizeDump; Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + msg = new TCPMessage(); msg.MessageType = MessageType.Statistics; Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); } + else + { + chkDebugMode.Enabled = false; + } + } + + private void chkDebugMode_CheckedChanged(object sender, EventArgs e) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.SetDebugMode; + msg.Parameters.Add(chkDebugMode.Checked); + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + } + + private void btnStep_Click(object sender, EventArgs e) + { + MessageBox.Show("Not Implemented"); + } + + private void btnRunToSelection_Click(object sender, EventArgs e) + { + MessageBox.Show("Not Implemented"); } } } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 8976c9cc7..2fd7301b0 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.IO; +using TCPLibrary.MessageBased.Core; +using System.Threading; namespace GSDumpGUI { @@ -49,6 +51,11 @@ namespace GSDumpGUI private Boolean Running; + public List QueueMessage; + public Boolean DebugMode; + public GSData CurrentGIFPacket; + public AutoResetEvent Event; + static public Boolean IsValidGSDX(String DLL) { NativeMethods.SetErrorMode(0x8007); @@ -168,7 +175,10 @@ namespace GSDumpGUI public unsafe void Run(GSDump dump, int rendererOverride) { + QueueMessage = new List(); Running = true; + Event = new AutoResetEvent(true); + GSinit(); fixed (byte* pointer = dump.Registers) { @@ -199,11 +209,13 @@ namespace GSDumpGUI Running = false; break; } + foreach (var itm in dump.Data) { + CurrentGIFPacket = itm; + Step(itm, pointer); } - } GSclose(); @@ -275,5 +287,25 @@ namespace GSDumpGUI { Running = false; } + + internal List GetGifPackets(GSDump dump) + { + List Data = new List(); + for (int i = 0; i < dump.Data.Count; i++) + { + String act = i.ToString() + "|"; + act += dump.Data[i].id.ToString() + "|"; + if (dump.Data[i].GetType().IsSubclassOf(typeof(GSData))) + { + act += ((GSTransfer)dump.Data[i]).Path.ToString(); + } + else + { + + } + Data.Add(act); + } + return Data; + } } } diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs index dc0512e73..dc6222e09 100644 --- a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs @@ -111,6 +111,10 @@ namespace TCPLibrary.MessageBased.Core MaxUsers, SizeDump, Statistics, - StateOld + StateOld, + + GetDebugMode, + SetDebugMode, + DebugState } }