[skip ci] Tools: Move gsdumpgui in it's own repository.

https://github.com/PCSX2/GSDumpGUI

Initial release has been published as well so developers can download
and use it without the hassle of compiling.
This commit is contained in:
lightningterror 2020-09-12 03:30:56 +02:00
parent dae2c31951
commit e5db98c137
60 changed files with 0 additions and 9363 deletions

2
.gitignore vendored
View File

@ -108,8 +108,6 @@ oprofile_data/
/plugins/GSdx/Template
/plugins/USBqemu/Win32/bin
/tools/bin
/tools/GSDumpGUI/bin
/tools/GSDumpGUI/obj
.vs
/pcsx2/windows/VCprojects/GSdx_opengl_debug_hw.txt

View File

@ -18,8 +18,6 @@ skip_commits:
# Linux only plugins for now
- plugins/onepad/
- plugins/onepad_legacy/
# Tools
- tools/GSDumpGUI/
environment:
matrix:

View File

@ -1,461 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Specialized = System.Collections.Specialized;
using Reflection = System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Diagnostics;
using GSDumpGUI.Properties;
using System.IO;
using TCPLibrary.MessageBased.Core;
using System.Drawing;
namespace GSDumpGUI
{
static class Program
{
static public GSDumpGUI frmMain;
static public TCPLibrary.MessageBased.Core.BaseMessageServer Server;
static public List<TCPLibrary.MessageBased.Core.BaseMessageClientS> Clients;
static public TCPLibrary.MessageBased.Core.BaseMessageClient Client;
static private GSDump dump;
static private GSDXWrapper wrap;
static private TreeNode CurrentNode;
static public IntPtr hMainIcon;
[STAThread]
static void Main(String[] args)
{
if (args.Length == 5)
{
hMainIcon = Resources.AppIcon.Handle;
// do this first, else racy mess ;)
wrap = new GSDXWrapper();
var port = Convert.ToInt32(args[4]);
try
{
Client = new TCPLibrary.MessageBased.Core.BaseMessageClient();
Client.OnMessageReceived += new TCPLibrary.MessageBased.Core.BaseMessageClient.MessageReceivedHandler(Client_OnMessageReceived);
Client.Connect("localhost", port);
}
catch (Exception)
{
Client = null;
}
// Retrieve parameters
String DLLPath = args[0];
String DumpPath = args[1];
String Operation = args[2];
Int32 Renderer = Convert.ToInt32(args[3]);
wrap.Load(DLLPath);
Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\"));
if (Operation == "GSReplay")
{
dump = GSDump.LoadDump(DumpPath);
if (Client != null)
{
SendStatistics();
SendDumpSize();
}
wrap.Run(dump, Renderer);
}
else
wrap.GSConfig();
wrap.Unload();
if (GSDXWrapper.DumpTooOld)
{
if (Client != null)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.StateOld;
Client.Send(msg);
}
}
if (Client != null)
Client.Disconnect();
}
else
{
Clients = new List<TCPLibrary.MessageBased.Core.BaseMessageClientS>();
Server = new TCPLibrary.MessageBased.Core.BaseMessageServer();
Server.OnClientMessageReceived += new BaseMessageServer.MessageReceivedHandler(Server_OnClientMessageReceived);
Server.OnClientAfterConnect += new TCPLibrary.Core.Server.ConnectedHandler(Server_OnClientAfterConnect);
Server.OnClientAfterDisconnected += new TCPLibrary.Core.Server.DisconnectedHandler(Server_OnClientAfterDisconnected);
Server.Enabled = true;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (frmMain = new GSDumpGUI())
{
Application.Run(frmMain);
}
Server.Enabled = false;
}
}
static void Server_OnClientAfterDisconnected(TCPLibrary.Core.Server server, TCPLibrary.Core.ClientS sender)
{
Clients.Remove((TCPLibrary.MessageBased.Core.BaseMessageClientS)sender);
RefreshList(false);
}
static void Server_OnClientMessageReceived(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess)
{
switch (Mess.MessageType)
{
case MessageType.Connect:
break;
case MessageType.MaxUsers:
break;
case MessageType.SizeDump:
frmMain.Invoke(new Action<object>(delegate(object e)
{
frmMain.txtDumpSize.Text = (((int)Mess.Parameters[0]) / 1024f / 1024f).ToString("F2") + " MB";
}), new object[] { null });
break;
case MessageType.Statistics:
frmMain.Invoke(new Action<object>(delegate(object e)
{
frmMain.txtGIFPackets.Text = ((int)Mess.Parameters[0]).ToString();
frmMain.txtPath1.Text = ((int)Mess.Parameters[1]).ToString();
frmMain.txtPath2.Text = ((int)Mess.Parameters[2]).ToString();
frmMain.txtPath3.Text = ((int)Mess.Parameters[3]).ToString();
frmMain.txtReadFifo.Text = ((int)Mess.Parameters[5]).ToString();
frmMain.txtVSync.Text = ((int)Mess.Parameters[4]).ToString();
frmMain.txtRegisters.Text = ((int)Mess.Parameters[6]).ToString();
}), new object[] { null });
break;
case MessageType.StateOld:
frmMain.Invoke(new Action<object>(delegate(object e)
{
MessageBox.Show("Savestate too old to be read. :(", "Warning");
frmMain.Focus();
}), new object[] { null });
break;
case MessageType.GetDebugMode:
frmMain.Invoke(new Action<object>(delegate(object e)
{
frmMain.chkDebugMode.Checked = (Boolean)Mess.Parameters[0];
frmMain.lblGif.Enabled = frmMain.chkDebugMode.Checked;
frmMain.lblContent.Enabled = frmMain.chkDebugMode.Checked;
frmMain.btnRunToSelection.Enabled = frmMain.chkDebugMode.Checked;
frmMain.treTreeView.Enabled = frmMain.chkDebugMode.Checked;
frmMain.btnStep.Enabled = frmMain.chkDebugMode.Checked;
frmMain.cmdGoToStart.Enabled = frmMain.chkDebugMode.Checked;
frmMain.cmdGoToNextVSync.Enabled = frmMain.chkDebugMode.Checked;
frmMain.treeGifPacketContent.Enabled = frmMain.chkDebugMode.Checked;
if (frmMain.chkDebugMode.Checked == false)
{
frmMain.treeGifPacketContent.Nodes.Clear();
frmMain.treTreeView.Nodes.Clear();
}
}), new object[] { null });
break;
case MessageType.DebugState:
frmMain.Invoke(new Action<object>(delegate(object e)
{
frmMain.treTreeView.Nodes.Clear();
List<TreeNode> parents = new List<TreeNode>();
List<TreeNode> nodes = new List<TreeNode>();
foreach (var itm in Mess.Parameters)
{
String[] parts = itm.ToString().Split(new char[] { '|' });
switch (parts[1])
{
case "Transfer":
TreeNode tn2 = new TreeNode();
tn2.Name = parts[0];
tn2.Text = parts[0] + " - " + parts[1] + " - " + parts[2] + " - " + parts[3] + " byte";
nodes.Add(tn2);
break;
case "ReadFIFO2":
TreeNode tn3 = new TreeNode();
tn3.Name = parts[0];
tn3.Text = parts[0] + " - " + parts[1] + " - " + parts[2] + " byte";
nodes.Add(tn3);
break;
case "VSync":
TreeNode tn = new TreeNode();
tn.Name = parts[0];
tn.Text = parts[0] + " - " + parts[1] + " - " + parts[2] + " byte";
tn.Nodes.AddRange(nodes.ToArray());
parents.Add(tn);
nodes.Clear();
break;
case "Registers":
TreeNode tn4 = new TreeNode();
tn4.Name = parts[0];
tn4.Text = parts[0] + " - " + parts[1] + " - " + parts[2] + " byte";
nodes.Add(tn4);
break;
}
}
frmMain.treTreeView.Nodes.AddRange(parents.ToArray());
}), new object[] { null });
break;
case MessageType.Step:
case MessageType.RunToCursor:
frmMain.Invoke(new Action<object>(delegate(object e)
{
int idtoselect = (int)Mess.Parameters[0];
TreeNode[] noes = frmMain.treTreeView.Nodes.Find(idtoselect.ToString(), true);
if (noes.Length > 0)
{
if (CurrentNode != null)
CurrentNode.BackColor = Color.White;
noes[0].BackColor = Color.LightBlue;
CurrentNode = noes[0];
frmMain.treTreeView.SelectedNode = noes[0];
}
}), new object[] { null });
break;
case MessageType.PacketInfo:
frmMain.Invoke(new Action<object>(delegate(object e)
{
if (Mess.Parameters[0].GetType() == typeof(GIFTag))
{
GIFTag tag = (GIFTag)Mess.Parameters[0];
frmMain.txtGifPacketSize.Text = tag.size + " bytes";
frmMain.treeGifPacketContent.Nodes.Clear();
frmMain.treeGifPacketContent.Nodes.Add("Transfer Path " + tag.path);
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("nloop = " + tag.nloop);
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("eop = " + tag.eop);
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("flg = " + tag.flg.ToString());
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("pre = " + tag.pre);
TreeNode nodePrim = new TreeNode("Prim");
string[] prim = tag.prim.ToString().Split(new char[] { '@' });
for (int j = 0; j < prim.Length; j++)
nodePrim.Nodes.Add(prim[j]);
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add(nodePrim);
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add("nreg = " + (tag.nreg == 0 ? (16).ToString() : tag.nreg.ToString()));
TreeNode nodeReg = new TreeNode("reg");
for (int j = 0; j < tag.regs.Count; j++)
{
string[] fvals = tag.regs[j].ToString().Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
TreeNode nodeObj = new TreeNode(fvals[0]);
for (int z = 1; z < fvals.Length; z++)
{
TreeNode item = new TreeNode(fvals[z]);
nodeObj.Nodes.Add(item);
}
nodeReg.Nodes.Add(nodeObj);
}
frmMain.treeGifPacketContent.Nodes[0].Nodes.Add(nodeReg);
frmMain.treeGifPacketContent.Nodes[0].ExpandAll();
}
else
{
String[] vals = Mess.Parameters[0].ToString().Split('|');
frmMain.txtGifPacketSize.Text = vals[0] + " bytes";
frmMain.treeGifPacketContent.Nodes.Clear();
frmMain.treeGifPacketContent.Nodes.Add(vals[1]);
frmMain.treeGifPacketContent.Nodes[0].ExpandAll();
}
}), new object[] { null });
break;
default:
break;
}
}
static void Client_OnMessageReceived(TCPLibrary.Core.Client sender, TCPLibrary.MessageBased.Core.TCPMessage Mess)
{
TCPMessage msg;
switch (Mess.MessageType)
{
case TCPLibrary.MessageBased.Core.MessageType.Connect:
break;
case TCPLibrary.MessageBased.Core.MessageType.MaxUsers:
break;
case TCPLibrary.MessageBased.Core.MessageType.SizeDump:
SendDumpSize();
break;
case MessageType.Statistics:
SendStatistics();
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);
msg = new TCPMessage();
msg.MessageType = MessageType.Step;
msg.Parameters.Add(dump.Data.FindIndex(a => a == wrap.CurrentGIFPacket));
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);
msg = new TCPMessage();
msg.MessageType = MessageType.Step;
msg.Parameters.Add(dump.Data.FindIndex(a => a == wrap.CurrentGIFPacket));
Client.Send(msg);
}
break;
case MessageType.PacketInfo:
int id = (int)Mess.Parameters[0];
msg = new TCPMessage();
msg.MessageType = MessageType.PacketInfo;
msg.Parameters.Add(wrap.GetGifPacketInfo(dump, id));
Client.Send(msg);
break;
case MessageType.Step:
case MessageType.RunToCursor:
case MessageType.RunToNextVSync:
wrap.ExternalEvent.WaitOne();
wrap.ExternalEvent.Reset();
wrap.QueueMessage.Enqueue(Mess);
wrap.ThereIsWork = true;
break;
default:
break;
}
}
private static void SendDumpSize()
{
TCPMessage msg;
msg = new TCPMessage();
msg.MessageType = MessageType.SizeDump;
if (dump != null)
msg.Parameters.Add(dump.Size);
else
msg.Parameters.Add(0);
Client.Send(msg);
}
private static void SendStatistics()
{
TCPMessage msg;
msg = new TCPMessage();
msg.MessageType = MessageType.Statistics;
if (dump != null)
{
msg.Parameters.Add(dump.Data.Count);
msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 0 && (a.data[0] == 3 || a.data[0] == 0)).Count);
msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 0 && a.data[0] == 1).Count);
msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 0 && a.data[0] == 2).Count);
msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 1).Count);
msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 2).Count);
msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 3).Count);
}
else
{
msg.Parameters.Add(0);
msg.Parameters.Add(0);
msg.Parameters.Add(0);
msg.Parameters.Add(0);
msg.Parameters.Add(0);
msg.Parameters.Add(0);
msg.Parameters.Add(0);
}
Client.Send(msg);
}
static void Server_OnClientAfterConnect(TCPLibrary.Core.Server server, TCPLibrary.Core.ClientS sender)
{
Clients.Add((TCPLibrary.MessageBased.Core.BaseMessageClientS)sender);
RefreshList(true);
}
private static void RefreshList(bool SelectLast)
{
frmMain.Invoke(new Action<object>( delegate(object e)
{
frmMain.lstProcesses.Items.Clear();
foreach (var itm in Clients)
{
frmMain.lstProcesses.Items.Add(itm.IPAddress);
}
if (SelectLast)
frmMain.lstProcesses.SelectedIndex = frmMain.lstProcesses.Items.Count - 1;
if (frmMain.lstProcesses.SelectedIndex == -1)
{
frmMain.chkDebugMode.Checked = false;
frmMain.chkDebugMode.Enabled = false;
frmMain.lblGif.Enabled = false;
frmMain.lblContent.Enabled = false;
frmMain.btnRunToSelection.Enabled = false;
frmMain.treTreeView.Enabled = false;
frmMain.btnStep.Enabled = false;
frmMain.cmdGoToStart.Enabled = false;
frmMain.cmdGoToNextVSync.Enabled = false;
frmMain.treeGifPacketContent.Enabled = false;
frmMain.treeGifPacketContent.Nodes.Clear();
frmMain.treTreeView.Nodes.Clear();
}
}), new object[] { null});
}
}
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace GSDumpGUI.Forms.Entities
{
public sealed class GsDlls : GsFiles<GsFile> { }
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.IO;
namespace GSDumpGUI.Forms.Entities
{
public sealed class GsDumpFile : GsFile
{
public FileInfo PreviewFile { get; set; }
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.IO;
namespace GSDumpGUI.Forms.Entities
{
public sealed class GsDumps : GsFiles<GsDumpFile>
{
private FileInfo GsDumpPreviewFile { get; set; }
}
}

View File

@ -1,32 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.IO;
namespace GSDumpGUI.Forms.Entities
{
public class GsFile
{
public FileInfo File { get; set; }
public string DisplayText { get; set; }
}
}

View File

@ -1,78 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.ComponentModel;
namespace GSDumpGUI.Forms.Entities
{
public abstract class GsFiles<TUnderlying>
where TUnderlying : GsFile
{
private int _selectedFileIndex = -1;
public class SelectedIndexUpdatedEventArgs
{
public SelectedIndexUpdatedEventArgs(int formerIndex, int updatedIndex)
{
FormerIndex = formerIndex;
UpdatedIndex = updatedIndex;
}
public int FormerIndex { get; }
public int UpdatedIndex { get; }
}
public delegate void SelectedIndexUpdateEventHandler(object sender, SelectedIndexUpdatedEventArgs args);
public event SelectedIndexUpdateEventHandler OnIndexUpdatedEvent;
public BindingList<TUnderlying> Files { get; } = new BindingList<TUnderlying>();
public int SelectedFileIndex
{
get
{
return _selectedFileIndex;
}
set
{
var oldValue = _selectedFileIndex;
_selectedFileIndex = value;
OnIndexUpdatedEvent?.Invoke(this, new SelectedIndexUpdatedEventArgs(oldValue, value));
}
}
public bool IsSelected => SelectedFileIndex != -1 && Files.Count > SelectedFileIndex;
public TUnderlying Selected
{
get
{
return SelectedFileIndex >= 0 ? Files[SelectedFileIndex] : null;
}
set
{
SelectedFileIndex = Files.IndexOf(value);
}
}
}
}

View File

@ -1,66 +0,0 @@
/*
* Copyright (C) 2009-2020 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Windows.Forms;
// Important ! Create the ExtensionMethods class as a "public static" class
public static class ExtensionMethods
{
public static void EnableContextMenu(this RichTextBox rtb)
{
if (rtb.ContextMenuStrip == null)
{
// Create a ContextMenuStrip without icons
ContextMenuStrip cms = new ContextMenuStrip();
cms.ShowImageMargin = false;
// Add the Copy option (copies the selected text inside the richtextbox)
ToolStripMenuItem tsmiCopy = new ToolStripMenuItem("Copy");
tsmiCopy.Click += (sender, e) => rtb.Copy();
cms.Items.Add(tsmiCopy);
// Add the Clear option (clears the text inside the richtextbox)
ToolStripMenuItem tsmiClear = new ToolStripMenuItem("Clear Log");
tsmiClear.Click += (sender, e) => rtb.Clear();
cms.Items.Add(tsmiClear);
// Add a Separator
cms.Items.Add(new ToolStripSeparator());
// Add the Select All Option (selects all the text inside the richtextbox)
ToolStripMenuItem tsmiSelectAll = new ToolStripMenuItem("Select All");
tsmiSelectAll.Click += (sender, e) => rtb.SelectAll();
cms.Items.Add(tsmiSelectAll);
// When opening the menu, check if the condition is fulfilled
// in order to enable the action
cms.Opening += (sender, e) =>
{
tsmiCopy.Enabled = rtb.SelectionLength > 0;
tsmiClear.Enabled = rtb.TextLength > 0;
tsmiSelectAll.Enabled = rtb.TextLength > 0 && rtb.SelectionLength < rtb.TextLength;
};
rtb.ContextMenuStrip = cms;
}
}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.IO;
using System.Linq;
namespace GSDumpGUI.Forms.Helper
{
public class FolderWithFallBackFinder : IFolderWithFallBackFinder
{
public DirectoryInfo GetViaPatternWithFallback(string defaultDir, string filePattern, params string[] fallBackFolder)
{
if (!string.IsNullOrWhiteSpace(defaultDir))
return new DirectoryInfo(defaultDir);
DirectoryInfo gsdxDllDirectory;
if (TryGetExistingDirectory(fallBackFolder, filePattern, out gsdxDllDirectory))
return gsdxDllDirectory;
return new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
}
private static bool TryGetExistingDirectory(string[] relativePaths, string pattern, out DirectoryInfo validDirectory)
{
if (relativePaths == null)
throw new ArgumentNullException(nameof(relativePaths));
foreach (var relativePath in relativePaths)
{
var candidate = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath));
if (candidate.Exists && candidate.GetFiles(pattern).Any())
{
validDirectory = candidate;
return true;
}
}
validDirectory = null;
return false;
}
}
}

View File

@ -1,86 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Collections.Generic;
using System.IO;
using GSDumpGUI.Forms.Entities;
namespace GSDumpGUI.Forms.Helper
{
public class GsDumpFinder : IGsDumpFinder
{
private readonly ILogger _logger;
public GsDumpFinder(ILogger logger)
{
_logger = logger;
}
public IEnumerable<GsDumpFile> GetValidGsdxDumps(DirectoryInfo directory)
{
var dumps = new FileInfo[0];
try
{
dumps = directory.GetFiles("*.gs", SearchOption.TopDirectoryOnly);
}
catch (DirectoryNotFoundException)
{
_logger.Warning($"Failed to open folder '{directory}'.");
yield break;
}
foreach (var dump in dumps)
{
int crc;
using (var fileStream = File.OpenRead(dump.FullName))
{
using (var br = new BinaryReader(fileStream))
{
crc = br.ReadInt32();
br.Close();
}
}
var extensions = new[] {".png", ".bmp"};
var dumpPreview = default(FileInfo);
foreach (var extension in extensions)
{
var imageFile = new FileInfo(Path.ChangeExtension(dump.FullName, extension));
if (!imageFile.Exists)
continue;
dumpPreview = imageFile;
break;
}
_logger.Information($"Identified Dump for game ({crc:X}) with filename '{dump}'");
yield return new GsDumpFile
{
DisplayText = dump.Name + " | CRC : " + crc.ToString("X"),
File = dump,
PreviewFile = dumpPreview
};
}
}
}
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Collections.Generic;
using System.IO;
using GSDumpGUI.Forms.Entities;
namespace GSDumpGUI.Forms.Helper
{
public class GsdxDllFinder : IGsdxDllFinder
{
private readonly ILogger _logger;
public GsdxDllFinder(ILogger logger)
{
_logger = logger;
}
public IEnumerable<GsFile> GetEnrichedPathToValidGsdxDlls(DirectoryInfo directory)
{
var availableDlls = directory.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
var wrap = new GSDXWrapper();
foreach (var availableDll in availableDlls)
{
GsFile dll;
try
{
wrap.Load(availableDll.FullName);
dll = new GsFile
{
DisplayText = availableDll.Name + " | " + wrap.PS2EGetLibName(),
File = availableDll
};
_logger.Information($"'{availableDll}' correctly identified as '{wrap.PS2EGetLibName()}'");
wrap.Unload();
}
catch (InvalidGSPlugin)
{
_logger.Warning($"Failed to load '{availableDll}'. Is it really a GSdx DLL?");
continue;
}
yield return dll;
}
}
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.IO;
namespace GSDumpGUI.Forms.Helper
{
public interface IFolderWithFallBackFinder
{
DirectoryInfo GetViaPatternWithFallback(string defaultDir, string filePattern, params string[] fallBackFolder);
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Collections.Generic;
using System.IO;
using GSDumpGUI.Forms.Entities;
namespace GSDumpGUI.Forms.Helper
{
public interface IGsDumpFinder
{
IEnumerable<GsDumpFile> GetValidGsdxDumps(DirectoryInfo directory);
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Collections.Generic;
using System.IO;
using GSDumpGUI.Forms.Entities;
namespace GSDumpGUI.Forms.Helper
{
public interface IGsdxDllFinder
{
IEnumerable<GsFile> GetEnrichedPathToValidGsdxDlls(DirectoryInfo directory);
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace GSDumpGUI.Forms.Helper
{
public interface ILogger
{
void Information(string line = null);
void Warning(string line = null);
void Error(string line = null);
}
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace GSDumpGUI.Forms.Helper
{
public class RichTextBoxLogger : ILogger
{
private readonly RichTextBox _richTextBox;
public RichTextBoxLogger(RichTextBox richTextBox)
{
_richTextBox = richTextBox;
_richTextBox.BackColor = Color.White;
_richTextBox.Focus();
_richTextBox.HideSelection = false;
}
private void WriteLine(Color color, string line = null)
{
_richTextBox.Invoke(new MethodInvoker(delegate
{
ThreadLocalWrite(color, line);
}));
}
private void ThreadLocalWrite(Color color, string line)
{
if (line == null)
{
_richTextBox.AppendText(Environment.NewLine);
return;
}
_richTextBox.SelectionStart = _richTextBox.TextLength;
_richTextBox.SelectionLength = 0;
_richTextBox.SelectionColor = color;
_richTextBox.AppendText(line);
_richTextBox.SelectionColor = _richTextBox.ForeColor;
_richTextBox.AppendText(Environment.NewLine);
}
public void Information(string line = null) => WriteLine(Color.Black, line);
public void Warning(string line = null) => WriteLine(Color.DarkGoldenrod, line);
public void Error(string line = null) => WriteLine(Color.DarkRed, line);
}
}

View File

@ -1,216 +0,0 @@
/*
* Copyright (C) 2009-2019 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
using System.Xml;
using System.Xml.Linq;
namespace GSDumpGUI.Forms.SettingsProvider
{
public sealed class PortableXmlSettingsProvider : System.Configuration.SettingsProvider, IApplicationSettingsProvider
{
private const string RootNode = "configuration";
private static string SettingsDirectory => AppDomain.CurrentDomain.BaseDirectory;
public override string Name => nameof(PortableXmlSettingsProvider);
private static string ApplicationSettingsFile => Path.Combine(SettingsDirectory, "portable.config");
public static void ApplyProvider(params ApplicationSettingsBase[] settingsList)
=> ApplyProvider(new PortableXmlSettingsProvider(), settingsList);
public override string ApplicationName
{
get
{
return nameof(GSDumpGUI);
}
set { }
}
private static XDocument GetOrCreateXmlDocument()
{
if (!File.Exists(ApplicationSettingsFile))
return CreateNewDocument();
try
{
return XDocument.Load(ApplicationSettingsFile);
}
catch
{
return CreateNewDocument();
}
}
private static void ApplyProvider(PortableXmlSettingsProvider provider, params ApplicationSettingsBase[] settingsList)
{
foreach (ApplicationSettingsBase settings in settingsList)
{
settings.Providers.Clear();
settings.Providers.Add(provider);
foreach (SettingsProperty property in settings.Properties)
property.Provider = provider;
settings.Reload();
}
}
public override void Initialize(string name, NameValueCollection config)
{
if (String.IsNullOrEmpty(name))
name = Name;
base.Initialize(name, config);
}
public SettingsPropertyValue GetPreviousVersion(SettingsContext context, SettingsProperty property)
{
throw new NotImplementedException();
}
public void Reset(SettingsContext context)
{
if (!File.Exists(ApplicationSettingsFile))
return;
File.Delete(ApplicationSettingsFile);
}
public void Upgrade(SettingsContext context, SettingsPropertyCollection properties) { }
private static XDocument CreateNewDocument()
{
return new XDocument(new XElement(RootNode));
}
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection collection)
{
var xmlDoc = GetOrCreateXmlDocument();
var propertyValueCollection = new SettingsPropertyValueCollection();
foreach (SettingsProperty settingsProperty in collection)
{
propertyValueCollection.Add(new SettingsPropertyValue(settingsProperty)
{
IsDirty = false,
SerializedValue = GetValue(xmlDoc, settingsProperty)
});
}
return propertyValueCollection;
}
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
{
var xmlDoc = GetOrCreateXmlDocument();
foreach (SettingsPropertyValue settingsPropertyValue in collection)
SetValue(xmlDoc, settingsPropertyValue);
try
{
using (var writer = CreateWellFormattedXmlWriter(ApplicationSettingsFile))
{
xmlDoc.Save(writer);
}
}
catch { }
}
private static XmlWriter CreateWellFormattedXmlWriter(string outputFileName)
{
var settings = new XmlWriterSettings
{
NewLineHandling = NewLineHandling.Entitize,
Indent = true
};
return XmlWriter.Create(outputFileName, settings);
}
private static object GetValue(XContainer xmlDoc, SettingsProperty prop)
{
if (xmlDoc == null)
return prop.DefaultValue;
var rootNode = xmlDoc.Element(RootNode);
if (rootNode == null)
return prop.DefaultValue;
var settingNode = rootNode.Element(prop.Name);
if (settingNode == null)
return prop.DefaultValue;
return DeserializeSettingValueFromXmlNode(settingNode, prop);
}
private static void SetValue(XContainer xmlDoc, SettingsPropertyValue value)
{
if (xmlDoc == null)
throw new ArgumentNullException(nameof(xmlDoc));
var rootNode = xmlDoc.Element(RootNode);
if (rootNode == null)
throw new ArgumentNullException(nameof(rootNode));
var settingNode = rootNode.Element(value.Name);
var settingValueNode = SerializeSettingValueToXmlNode(value);
if (settingNode == null)
rootNode.Add(new XElement(value.Name, settingValueNode));
else
settingNode.ReplaceAll(settingValueNode);
}
private static XNode SerializeSettingValueToXmlNode(SettingsPropertyValue value)
{
if (value.SerializedValue == null)
return new XText("");
switch (value.Property.SerializeAs)
{
case SettingsSerializeAs.String:
return new XText((string) value.SerializedValue);
case SettingsSerializeAs.Xml:
case SettingsSerializeAs.Binary:
case SettingsSerializeAs.ProviderSpecific:
throw new NotImplementedException($"I don't know how to handle serialization of settings that should be serialized as {value.Property.SerializeAs}");
default:
throw new ArgumentOutOfRangeException();
}
}
private static object DeserializeSettingValueFromXmlNode(XNode node, SettingsProperty prop)
{
using (var reader = node.CreateReader())
{
reader.MoveToContent();
switch (prop.SerializeAs)
{
case SettingsSerializeAs.Xml:
case SettingsSerializeAs.Binary:
case SettingsSerializeAs.ProviderSpecific:
throw new NotImplementedException($"I don't know how to handle deserialization of settings that should be deserialized as {prop.SerializeAs}");
case SettingsSerializeAs.String:
return reader.ReadElementContentAsString();
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
}

View File

@ -1,801 +0,0 @@
namespace GSDumpGUI
{
partial class GSDumpGUI
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
DisposeExtra();
if (components != null)
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GSDumpGUI));
this.txtGSDXDirectory = new System.Windows.Forms.TextBox();
this.lblDirectory = new System.Windows.Forms.Label();
this.cmdBrowseGSDX = new System.Windows.Forms.Button();
this.cmdBrowseDumps = new System.Windows.Forms.Button();
this.lblDumpDirectory = new System.Windows.Forms.Label();
this.txtDumpsDirectory = new System.Windows.Forms.TextBox();
this.lstGSDX = new System.Windows.Forms.ListBox();
this.lstDumps = new System.Windows.Forms.ListBox();
this.lblDumps = new System.Windows.Forms.Label();
this.GsdxList = new System.Windows.Forms.Label();
this.cmdRun = new System.Windows.Forms.Button();
this.cmdConfigGSDX = new System.Windows.Forms.Button();
this.txtLog = new System.Windows.Forms.RichTextBox();
this.lblLog = new System.Windows.Forms.Label();
this.cmdOpenIni = new System.Windows.Forms.Button();
this.pctBox = new System.Windows.Forms.PictureBox();
this.rdaDX9HW = new System.Windows.Forms.RadioButton();
this.rdaDX1011HW = new System.Windows.Forms.RadioButton();
this.rdaOGLHW = new System.Windows.Forms.RadioButton();
this.rdaDX9SW = new System.Windows.Forms.RadioButton();
this.rdaDX1011SW = new System.Windows.Forms.RadioButton();
this.rdaOGLSW = new System.Windows.Forms.RadioButton();
this.lblOverride = new System.Windows.Forms.Label();
this.rdaNone = new System.Windows.Forms.RadioButton();
this.lblInternalLog = new System.Windows.Forms.Label();
this.txtIntLog = new System.Windows.Forms.RichTextBox();
this.lblDebugger = new System.Windows.Forms.Label();
this.lstProcesses = new System.Windows.Forms.ListBox();
this.lblChild = new System.Windows.Forms.Label();
this.lblDumpSize = new System.Windows.Forms.Label();
this.txtDumpSize = 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();
this.label2 = new System.Windows.Forms.Label();
this.txtPath2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txtPath3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.txtVSync = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txtReadFifo = new System.Windows.Forms.Label();
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();
this.cmdGoToStart = new System.Windows.Forms.Button();
this.cmdGoToNextVSync = new System.Windows.Forms.Button();
this.txtGifPacketSize = new System.Windows.Forms.Label();
this.lblGIFPacketSize = new System.Windows.Forms.Label();
this.treeGifPacketContent = new System.Windows.Forms.TreeView();
this.lblContent = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pctBox)).BeginInit();
this.SuspendLayout();
//
// txtGSDXDirectory
//
this.txtGSDXDirectory.Location = new System.Drawing.Point(871, 24);
this.txtGSDXDirectory.Name = "txtGSDXDirectory";
this.txtGSDXDirectory.Size = new System.Drawing.Size(243, 20);
this.txtGSDXDirectory.TabIndex = 0;
this.txtGSDXDirectory.TabStop = false;
this.txtGSDXDirectory.Enter += new System.EventHandler(this.txtGSDXDirectory_Enter);
this.txtGSDXDirectory.Leave += new System.EventHandler(this.txtGSDXDirectory_Leave);
this.txtGSDXDirectory.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtGSDXDirectory_KeyDown);
//
// lblDirectory
//
this.lblDirectory.AutoSize = true;
this.lblDirectory.Location = new System.Drawing.Point(871, 10);
this.lblDirectory.Name = "lblDirectory";
this.lblDirectory.Size = new System.Drawing.Size(78, 13);
this.lblDirectory.TabIndex = 1;
this.lblDirectory.Text = "GSdx Directory";
//
// cmdBrowseGSDX
//
this.cmdBrowseGSDX.Location = new System.Drawing.Point(1120, 24);
this.cmdBrowseGSDX.Name = "cmdBrowseGSDX";
this.cmdBrowseGSDX.Size = new System.Drawing.Size(26, 22);
this.cmdBrowseGSDX.TabIndex = 2;
this.cmdBrowseGSDX.TabStop = false;
this.cmdBrowseGSDX.Text = "...";
this.cmdBrowseGSDX.UseVisualStyleBackColor = true;
this.cmdBrowseGSDX.Click += new System.EventHandler(this.cmdBrowseGSDX_Click);
//
// cmdBrowseDumps
//
this.cmdBrowseDumps.Location = new System.Drawing.Point(1120, 64);
this.cmdBrowseDumps.Name = "cmdBrowseDumps";
this.cmdBrowseDumps.Size = new System.Drawing.Size(26, 23);
this.cmdBrowseDumps.TabIndex = 5;
this.cmdBrowseDumps.TabStop = false;
this.cmdBrowseDumps.Text = "...";
this.cmdBrowseDumps.UseVisualStyleBackColor = true;
this.cmdBrowseDumps.Click += new System.EventHandler(this.cmdBrowseDumps_Click);
//
// lblDumpDirectory
//
this.lblDumpDirectory.AutoSize = true;
this.lblDumpDirectory.Location = new System.Drawing.Point(871, 51);
this.lblDumpDirectory.Name = "lblDumpDirectory";
this.lblDumpDirectory.Size = new System.Drawing.Size(85, 13);
this.lblDumpDirectory.TabIndex = 4;
this.lblDumpDirectory.Text = "Dumps Directory";
//
// txtDumpsDirectory
//
this.txtDumpsDirectory.Location = new System.Drawing.Point(871, 67);
this.txtDumpsDirectory.Name = "txtDumpsDirectory";
this.txtDumpsDirectory.Size = new System.Drawing.Size(243, 20);
this.txtDumpsDirectory.TabIndex = 3;
this.txtDumpsDirectory.TabStop = false;
this.txtDumpsDirectory.Enter += new System.EventHandler(this.txtDumpsDirectory_Enter);
this.txtDumpsDirectory.Leave += new System.EventHandler(this.txtDumpsDirectory_Leave);
this.txtDumpsDirectory.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDumpsDirectory_KeyDown);
//
// lstGSDX
//
this.lstGSDX.FormattingEnabled = true;
this.lstGSDX.Location = new System.Drawing.Point(451, 24);
this.lstGSDX.Name = "lstGSDX";
this.lstGSDX.Size = new System.Drawing.Size(411, 173);
this.lstGSDX.TabIndex = 1;
//
// lstDumps
//
this.lstDumps.FormattingEnabled = true;
this.lstDumps.Location = new System.Drawing.Point(12, 24);
this.lstDumps.Name = "lstDumps";
this.lstDumps.Size = new System.Drawing.Size(433, 173);
this.lstDumps.TabIndex = 0;
//
// lblDumps
//
this.lblDumps.AutoSize = true;
this.lblDumps.Location = new System.Drawing.Point(9, 8);
this.lblDumps.Name = "lblDumps";
this.lblDumps.Size = new System.Drawing.Size(59, 13);
this.lblDumps.TabIndex = 9;
this.lblDumps.Text = "Dumps List";
//
// GsdxList
//
this.GsdxList.AutoSize = true;
this.GsdxList.Location = new System.Drawing.Point(451, 8);
this.GsdxList.Name = "GsdxList";
this.GsdxList.Size = new System.Drawing.Size(52, 13);
this.GsdxList.TabIndex = 10;
this.GsdxList.Text = "GSdx List";
//
// cmdRun
//
this.cmdRun.Location = new System.Drawing.Point(871, 167);
this.cmdRun.Name = "cmdRun";
this.cmdRun.Size = new System.Drawing.Size(275, 30);
this.cmdRun.TabIndex = 11;
this.cmdRun.TabStop = false;
this.cmdRun.Text = "Run";
this.cmdRun.UseVisualStyleBackColor = true;
this.cmdRun.Click += new System.EventHandler(this.cmdRun_Click);
//
// cmdConfigGSDX
//
this.cmdConfigGSDX.Location = new System.Drawing.Point(1051, 93);
this.cmdConfigGSDX.Name = "cmdConfigGSDX";
this.cmdConfigGSDX.Size = new System.Drawing.Size(95, 32);
this.cmdConfigGSDX.TabIndex = 12;
this.cmdConfigGSDX.TabStop = false;
this.cmdConfigGSDX.Text = "Configure GSdx";
this.cmdConfigGSDX.UseVisualStyleBackColor = true;
this.cmdConfigGSDX.Click += new System.EventHandler(this.cmdConfigGSDX_Click);
//
// txtLog
//
this.txtLog.Location = new System.Drawing.Point(15, 225);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.txtLog.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Both;
this.txtLog.Size = new System.Drawing.Size(430, 160);
this.txtLog.TabIndex = 13;
this.txtLog.TabStop = false;
this.txtLog.EnableContextMenu();
//
// lblLog
//
this.lblLog.AutoSize = true;
this.lblLog.Location = new System.Drawing.Point(12, 209);
this.lblLog.Name = "lblLog";
this.lblLog.Size = new System.Drawing.Size(54, 13);
this.lblLog.TabIndex = 14;
this.lblLog.Text = "Log GSdx";
//
// cmdOpenIni
//
this.cmdOpenIni.Location = new System.Drawing.Point(1051, 130);
this.cmdOpenIni.Name = "cmdOpenIni";
this.cmdOpenIni.Size = new System.Drawing.Size(95, 32);
this.cmdOpenIni.TabIndex = 15;
this.cmdOpenIni.TabStop = false;
this.cmdOpenIni.Text = "Open GSdx.ini";
this.cmdOpenIni.UseVisualStyleBackColor = true;
this.cmdOpenIni.Click += new System.EventHandler(this.cmdOpenIni_Click);
//
// pctBox
//
this.pctBox.Location = new System.Drawing.Point(871, 225);
this.pctBox.Name = "pctBox";
this.pctBox.Size = new System.Drawing.Size(275, 160);
this.pctBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pctBox.TabIndex = 16;
this.pctBox.TabStop = false;
this.pctBox.Click += new System.EventHandler(PreviewImageClick);
//
// rdaDX9HW
//
this.rdaDX9HW.AutoSize = true;
this.rdaDX9HW.Location = new System.Drawing.Point(874, 111);
this.rdaDX9HW.Name = "rdaDX9HW";
this.rdaDX9HW.Size = new System.Drawing.Size(75, 17);
this.rdaDX9HW.TabIndex = 17;
this.rdaDX9HW.Tag = "1";
this.rdaDX9HW.Text = "D3D9 HW";
this.rdaDX9HW.UseVisualStyleBackColor = true;
this.rdaDX9HW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// rdaDX1011HW
//
this.rdaDX1011HW.AutoSize = true;
this.rdaDX1011HW.Location = new System.Drawing.Point(874, 129);
this.rdaDX1011HW.Name = "rdaDX1011HW";
this.rdaDX1011HW.Size = new System.Drawing.Size(81, 17);
this.rdaDX1011HW.TabIndex = 18;
this.rdaDX1011HW.Tag = "2";
this.rdaDX1011HW.Text = "D3D11 HW";
this.rdaDX1011HW.UseVisualStyleBackColor = true;
this.rdaDX1011HW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// rdaOGLHW
//
this.rdaOGLHW.AutoSize = true;
this.rdaOGLHW.Location = new System.Drawing.Point(874, 147);
this.rdaOGLHW.Name = "rdaOGLHW";
this.rdaOGLHW.Size = new System.Drawing.Size(69, 17);
this.rdaOGLHW.TabIndex = 19;
this.rdaOGLHW.Tag = "3";
this.rdaOGLHW.Text = "OGL HW";
this.rdaOGLHW.UseVisualStyleBackColor = true;
this.rdaOGLHW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// rdaDX9SW
//
this.rdaDX9SW.AutoSize = true;
this.rdaDX9SW.Location = new System.Drawing.Point(971, 111);
this.rdaDX9SW.Name = "rdaDX9SW";
this.rdaDX9SW.Size = new System.Drawing.Size(74, 17);
this.rdaDX9SW.TabIndex = 20;
this.rdaDX9SW.Tag = "4";
this.rdaDX9SW.Text = "D3D9 SW";
this.rdaDX9SW.UseVisualStyleBackColor = true;
this.rdaDX9SW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// rdaDX1011SW
//
this.rdaDX1011SW.AutoSize = true;
this.rdaDX1011SW.Location = new System.Drawing.Point(971, 129);
this.rdaDX1011SW.Name = "rdaDX1011SW";
this.rdaDX1011SW.Size = new System.Drawing.Size(80, 17);
this.rdaDX1011SW.TabIndex = 21;
this.rdaDX1011SW.Tag = "5";
this.rdaDX1011SW.Text = "D3D11 SW";
this.rdaDX1011SW.UseVisualStyleBackColor = true;
this.rdaDX1011SW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// rdaOGLSW
//
this.rdaOGLSW.AutoSize = true;
this.rdaOGLSW.Location = new System.Drawing.Point(971, 147);
this.rdaOGLSW.Name = "rdaOGLSW";
this.rdaOGLSW.Size = new System.Drawing.Size(68, 17);
this.rdaOGLSW.TabIndex = 22;
this.rdaOGLSW.Tag = "6";
this.rdaOGLSW.Text = "OGL SW";
this.rdaOGLSW.UseVisualStyleBackColor = true;
this.rdaOGLSW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// lblOverride
//
this.lblOverride.AutoSize = true;
this.lblOverride.Location = new System.Drawing.Point(871, 93);
this.lblOverride.Name = "lblOverride";
this.lblOverride.Size = new System.Drawing.Size(94, 13);
this.lblOverride.TabIndex = 23;
this.lblOverride.Text = "Renderer Override";
//
// rdaNone
//
this.rdaNone.AutoSize = true;
this.rdaNone.Checked = true;
this.rdaNone.Location = new System.Drawing.Point(971, 93);
this.rdaNone.Name = "rdaNone";
this.rdaNone.Size = new System.Drawing.Size(51, 17);
this.rdaNone.TabIndex = 24;
this.rdaNone.TabStop = true;
this.rdaNone.Tag = "0";
this.rdaNone.Text = "None";
this.rdaNone.UseVisualStyleBackColor = true;
this.rdaNone.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
//
// lblInternalLog
//
this.lblInternalLog.AutoSize = true;
this.lblInternalLog.Location = new System.Drawing.Point(451, 209);
this.lblInternalLog.Name = "lblInternalLog";
this.lblInternalLog.Size = new System.Drawing.Size(63, 13);
this.lblInternalLog.TabIndex = 25;
this.lblInternalLog.Text = "Log Internal";
//
// txtIntLog
//
this.txtIntLog.Location = new System.Drawing.Point(451, 225);
this.txtIntLog.Multiline = true;
this.txtIntLog.Name = "txtIntLog";
this.txtIntLog.ReadOnly = true;
this.txtIntLog.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Both;
this.txtIntLog.Size = new System.Drawing.Size(411, 160);
this.txtIntLog.TabIndex = 24;
this.txtIntLog.TabStop = false;
this.txtIntLog.EnableContextMenu();
//
// lblDebugger
//
this.lblDebugger.AutoSize = true;
this.lblDebugger.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDebugger.Location = new System.Drawing.Point(417, 398);
this.lblDebugger.Name = "lblDebugger";
this.lblDebugger.Size = new System.Drawing.Size(62, 13);
this.lblDebugger.TabIndex = 26;
this.lblDebugger.Text = "Debugger";
//
// lstProcesses
//
this.lstProcesses.FormattingEnabled = true;
this.lstProcesses.Location = new System.Drawing.Point(12, 430);
this.lstProcesses.Name = "lstProcesses";
this.lstProcesses.Size = new System.Drawing.Size(248, 277);
this.lstProcesses.TabIndex = 27;
this.lstProcesses.SelectedIndexChanged += new System.EventHandler(this.lstProcesses_SelectedIndexChanged);
//
// lblChild
//
this.lblChild.AutoSize = true;
this.lblChild.Location = new System.Drawing.Point(9, 414);
this.lblChild.Name = "lblChild";
this.lblChild.Size = new System.Drawing.Size(82, 13);
this.lblChild.TabIndex = 28;
this.lblChild.Text = "Child Processes";
//
// lblDumpSize
//
this.lblDumpSize.AutoSize = true;
this.lblDumpSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDumpSize.Location = new System.Drawing.Point(279, 430);
this.lblDumpSize.Name = "lblDumpSize";
this.lblDumpSize.Size = new System.Drawing.Size(67, 13);
this.lblDumpSize.TabIndex = 29;
this.lblDumpSize.Text = "Dump Size";
//
// txtDumpSize
//
this.txtDumpSize.AutoSize = true;
this.txtDumpSize.Location = new System.Drawing.Point(279, 445);
this.txtDumpSize.Name = "txtDumpSize";
this.txtDumpSize.Size = new System.Drawing.Size(27, 13);
this.txtDumpSize.TabIndex = 30;
this.txtDumpSize.Text = "N/A";
//
// txtGIFPackets
//
this.txtGIFPackets.AutoSize = true;
this.txtGIFPackets.Location = new System.Drawing.Point(279, 478);
this.txtGIFPackets.Name = "txtGIFPackets";
this.txtGIFPackets.Size = new System.Drawing.Size(27, 13);
this.txtGIFPackets.TabIndex = 33;
this.txtGIFPackets.Text = "N/A";
//
// lblGIFPackets
//
this.lblGIFPackets.AutoSize = true;
this.lblGIFPackets.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblGIFPackets.Location = new System.Drawing.Point(279, 463);
this.lblGIFPackets.Name = "lblGIFPackets";
this.lblGIFPackets.Size = new System.Drawing.Size(110, 13);
this.lblGIFPackets.TabIndex = 32;
this.lblGIFPackets.Text = "Total GIF Packets";
//
// txtPath1
//
this.txtPath1.AutoSize = true;
this.txtPath1.Location = new System.Drawing.Point(279, 512);
this.txtPath1.Name = "txtPath1";
this.txtPath1.Size = new System.Drawing.Size(27, 13);
this.txtPath1.TabIndex = 35;
this.txtPath1.Text = "N/A";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(279, 497);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(114, 13);
this.label2.TabIndex = 34;
this.label2.Text = "Path1 GIF Packets";
//
// txtPath2
//
this.txtPath2.AutoSize = true;
this.txtPath2.Location = new System.Drawing.Point(279, 546);
this.txtPath2.Name = "txtPath2";
this.txtPath2.Size = new System.Drawing.Size(27, 13);
this.txtPath2.TabIndex = 37;
this.txtPath2.Text = "N/A";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(279, 531);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(114, 13);
this.label3.TabIndex = 36;
this.label3.Text = "Path2 GIF Packets";
//
// txtPath3
//
this.txtPath3.AutoSize = true;
this.txtPath3.Location = new System.Drawing.Point(279, 580);
this.txtPath3.Name = "txtPath3";
this.txtPath3.Size = new System.Drawing.Size(27, 13);
this.txtPath3.TabIndex = 39;
this.txtPath3.Text = "N/A";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(279, 565);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(114, 13);
this.label5.TabIndex = 38;
this.label5.Text = "Path3 GIF Packets";
//
// txtVSync
//
this.txtVSync.AutoSize = true;
this.txtVSync.Location = new System.Drawing.Point(279, 615);
this.txtVSync.Name = "txtVSync";
this.txtVSync.Size = new System.Drawing.Size(27, 13);
this.txtVSync.TabIndex = 41;
this.txtVSync.Text = "N/A";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(279, 600);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(91, 13);
this.label4.TabIndex = 40;
this.label4.Text = "Vsync Packets";
//
// txtReadFifo
//
this.txtReadFifo.AutoSize = true;
this.txtReadFifo.Location = new System.Drawing.Point(279, 649);
this.txtReadFifo.Name = "txtReadFifo";
this.txtReadFifo.Size = new System.Drawing.Size(27, 13);
this.txtReadFifo.TabIndex = 43;
this.txtReadFifo.Text = "N/A";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(279, 634);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(114, 13);
this.label7.TabIndex = 42;
this.label7.Text = "ReadFIFO Packets";
//
// txtRegisters
//
this.txtRegisters.AutoSize = true;
this.txtRegisters.Location = new System.Drawing.Point(279, 684);
this.txtRegisters.Name = "txtRegisters";
this.txtRegisters.Size = new System.Drawing.Size(27, 13);
this.txtRegisters.TabIndex = 45;
this.txtRegisters.Text = "N/A";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(279, 669);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(110, 13);
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(759, 430);
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(417, 415);
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(759, 499);
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(759, 545);
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, 431);
this.treTreeView.Name = "treTreeView";
this.treTreeView.Size = new System.Drawing.Size(332, 276);
this.treTreeView.TabIndex = 51;
this.treTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treTreeView_AfterSelect);
//
// cmdGoToStart
//
this.cmdGoToStart.Enabled = false;
this.cmdGoToStart.Location = new System.Drawing.Point(759, 453);
this.cmdGoToStart.Name = "cmdGoToStart";
this.cmdGoToStart.Size = new System.Drawing.Size(108, 40);
this.cmdGoToStart.TabIndex = 52;
this.cmdGoToStart.TabStop = false;
this.cmdGoToStart.Text = "Go to Start";
this.cmdGoToStart.UseVisualStyleBackColor = true;
this.cmdGoToStart.Click += new System.EventHandler(this.cmdGoToStart_Click);
//
// cmdGoToNextVSync
//
this.cmdGoToNextVSync.Enabled = false;
this.cmdGoToNextVSync.Location = new System.Drawing.Point(759, 591);
this.cmdGoToNextVSync.Name = "cmdGoToNextVSync";
this.cmdGoToNextVSync.Size = new System.Drawing.Size(108, 40);
this.cmdGoToNextVSync.TabIndex = 53;
this.cmdGoToNextVSync.TabStop = false;
this.cmdGoToNextVSync.Text = "Go to next VSync";
this.cmdGoToNextVSync.UseVisualStyleBackColor = true;
this.cmdGoToNextVSync.Click += new System.EventHandler(this.cmdGoToNextVSync_Click);
//
// txtGifPacketSize
//
this.txtGifPacketSize.AutoSize = true;
this.txtGifPacketSize.Location = new System.Drawing.Point(873, 430);
this.txtGifPacketSize.Name = "txtGifPacketSize";
this.txtGifPacketSize.Size = new System.Drawing.Size(0, 13);
this.txtGifPacketSize.TabIndex = 55;
//
// lblGIFPacketSize
//
this.lblGIFPacketSize.AutoSize = true;
this.lblGIFPacketSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblGIFPacketSize.Location = new System.Drawing.Point(871, 398);
this.lblGIFPacketSize.Name = "lblGIFPacketSize";
this.lblGIFPacketSize.Size = new System.Drawing.Size(95, 13);
this.lblGIFPacketSize.TabIndex = 54;
this.lblGIFPacketSize.Text = "Gif Packet Size";
//
// treeGifPacketContent
//
this.treeGifPacketContent.Enabled = false;
this.treeGifPacketContent.Location = new System.Drawing.Point(874, 431);
this.treeGifPacketContent.Name = "treeGifPacketContent";
this.treeGifPacketContent.Size = new System.Drawing.Size(272, 276);
this.treeGifPacketContent.TabIndex = 57;
//
// lblContent
//
this.lblContent.AutoSize = true;
this.lblContent.Enabled = false;
this.lblContent.Location = new System.Drawing.Point(871, 414);
this.lblContent.Name = "lblContent";
this.lblContent.Size = new System.Drawing.Size(101, 13);
this.lblContent.TabIndex = 56;
this.lblContent.Text = "GIF Packet Content";
//
// GSDumpGUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1158, 718);
this.Controls.Add(this.treeGifPacketContent);
this.Controls.Add(this.lblContent);
this.Controls.Add(this.txtGifPacketSize);
this.Controls.Add(this.lblGIFPacketSize);
this.Controls.Add(this.cmdGoToNextVSync);
this.Controls.Add(this.cmdGoToStart);
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);
this.Controls.Add(this.label7);
this.Controls.Add(this.txtVSync);
this.Controls.Add(this.label4);
this.Controls.Add(this.txtPath3);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtPath2);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtPath1);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtGIFPackets);
this.Controls.Add(this.lblGIFPackets);
this.Controls.Add(this.txtDumpSize);
this.Controls.Add(this.lblDumpSize);
this.Controls.Add(this.lstProcesses);
this.Controls.Add(this.lblChild);
this.Controls.Add(this.lblDebugger);
this.Controls.Add(this.lblInternalLog);
this.Controls.Add(this.txtIntLog);
this.Controls.Add(this.rdaNone);
this.Controls.Add(this.lblOverride);
this.Controls.Add(this.rdaOGLSW);
this.Controls.Add(this.rdaDX1011SW);
this.Controls.Add(this.rdaDX9SW);
this.Controls.Add(this.rdaOGLHW);
this.Controls.Add(this.rdaDX1011HW);
this.Controls.Add(this.rdaDX9HW);
this.Controls.Add(this.lstGSDX);
this.Controls.Add(this.pctBox);
this.Controls.Add(this.cmdOpenIni);
this.Controls.Add(this.lblLog);
this.Controls.Add(this.txtLog);
this.Controls.Add(this.cmdConfigGSDX);
this.Controls.Add(this.cmdRun);
this.Controls.Add(this.GsdxList);
this.Controls.Add(this.lblDumps);
this.Controls.Add(this.lstDumps);
this.Controls.Add(this.cmdBrowseDumps);
this.Controls.Add(this.lblDumpDirectory);
this.Controls.Add(this.txtDumpsDirectory);
this.Controls.Add(this.cmdBrowseGSDX);
this.Controls.Add(this.lblDirectory);
this.Controls.Add(this.txtGSDXDirectory);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
this.MaximizeBox = false;
this.Name = "GSDumpGUI";
this.Text = "GSDumpGUI";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GSDumpGUI_FormClosing);
this.Load += new System.EventHandler(this.GSDumpGUI_Load);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GSDumpGUI_KeyDown);
((System.ComponentModel.ISupportInitialize)(this.pctBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtGSDXDirectory;
private System.Windows.Forms.Label lblDirectory;
private System.Windows.Forms.Button cmdBrowseGSDX;
private System.Windows.Forms.Button cmdBrowseDumps;
private System.Windows.Forms.Label lblDumpDirectory;
private System.Windows.Forms.TextBox txtDumpsDirectory;
private System.Windows.Forms.ListBox lstGSDX;
private System.Windows.Forms.ListBox lstDumps;
private System.Windows.Forms.Label lblDumps;
private System.Windows.Forms.Label GsdxList;
private System.Windows.Forms.Button cmdRun;
private System.Windows.Forms.Button cmdConfigGSDX;
private System.Windows.Forms.RichTextBox txtLog;
private System.Windows.Forms.Label lblLog;
private System.Windows.Forms.Button cmdOpenIni;
private System.Windows.Forms.PictureBox pctBox;
private System.Windows.Forms.RadioButton rdaDX9HW;
private System.Windows.Forms.RadioButton rdaDX1011HW;
private System.Windows.Forms.RadioButton rdaOGLHW;
private System.Windows.Forms.RadioButton rdaDX9SW;
private System.Windows.Forms.RadioButton rdaDX1011SW;
private System.Windows.Forms.RadioButton rdaOGLSW;
private System.Windows.Forms.Label lblOverride;
private System.Windows.Forms.RadioButton rdaNone;
private System.Windows.Forms.Label lblInternalLog;
private System.Windows.Forms.RichTextBox txtIntLog;
private System.Windows.Forms.Label lblDebugger;
private System.Windows.Forms.Label lblChild;
public System.Windows.Forms.ListBox lstProcesses;
private System.Windows.Forms.Label lblDumpSize;
public System.Windows.Forms.Label txtDumpSize;
public System.Windows.Forms.Label txtGIFPackets;
private System.Windows.Forms.Label lblGIFPackets;
public System.Windows.Forms.Label txtPath1;
private System.Windows.Forms.Label label2;
public System.Windows.Forms.Label txtPath2;
private System.Windows.Forms.Label label3;
public System.Windows.Forms.Label txtPath3;
private System.Windows.Forms.Label label5;
public System.Windows.Forms.Label txtVSync;
private System.Windows.Forms.Label label4;
public System.Windows.Forms.Label txtReadFifo;
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;
public System.Windows.Forms.Button cmdGoToStart;
public System.Windows.Forms.Button cmdGoToNextVSync;
public System.Windows.Forms.Label txtGifPacketSize;
private System.Windows.Forms.Label lblGIFPacketSize;
public System.Windows.Forms.TreeView treeGifPacketContent;
public System.Windows.Forms.Label lblContent;
}
}

View File

@ -1,685 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using GSDumpGUI.Forms.Entities;
using GSDumpGUI.Forms.Helper;
using GSDumpGUI.Forms.SettingsProvider;
using GSDumpGUI.Properties;
using TCPLibrary.MessageBased.Core;
namespace GSDumpGUI
{
public partial class GSDumpGUI : Form
{
private readonly ILogger _internalLogger;
private readonly ILogger _gsdxLogger;
private readonly IGsdxDllFinder _gsdxDllFinder;
private readonly IGsDumpFinder _gsDumpFinder;
private readonly IFolderWithFallBackFinder _folderWithFallBackFinder;
public List<Process> Processes;
private Int32 _selected;
public Int32 SelectedRad
{
get { return _selected; }
set
{
if (value > 6)
value = 0;
_selected = value;
switch (_selected)
{
case 0:
rdaNone.Checked = true;
break;
case 1:
rdaDX9HW.Checked = true;
break;
case 2:
rdaDX1011HW.Checked = true;
break;
case 3:
rdaOGLHW.Checked = true;
break;
case 4:
rdaDX9SW.Checked = true;
break;
case 5:
rdaDX1011SW.Checked = true;
break;
case 6:
rdaOGLSW.Checked = true;
break;
}
}
}
private readonly Bitmap NoImage;
private Settings Settings => Settings.Default;
private readonly GsDumps _availableGsDumps;
private readonly GsDlls _availableGsDlls;
private List<FileSystemWatcher> _dllWatcher;
private List<FileSystemWatcher> _dumpWatcher;
enum FileChangeEvt { Dll = 1, Dump = 2 };
private ConcurrentQueue<FileChangeEvt> _watcherEvents;
private System.Windows.Forms.Timer _fileChangesWatchdog;
private string _gsdxPathOld, _dumpPathOld;
public GSDumpGUI()
{
PortableXmlSettingsProvider.ApplyProvider(Settings);
InitializeComponent();
_internalLogger = new RichTextBoxLogger(txtIntLog);
_gsdxLogger = new RichTextBoxLogger(txtLog);
_gsdxDllFinder = new GsdxDllFinder(_internalLogger);
_gsDumpFinder = new GsDumpFinder(_internalLogger);
_folderWithFallBackFinder = new FolderWithFallBackFinder();
_availableGsDumps = new GsDumps();
_availableGsDlls = new GsDlls();
_availableGsDumps.OnIndexUpdatedEvent += UpdatePreviewImage;
this.Text += Environment.Is64BitProcess ? " 64bits" : " 32bits";
if (String.IsNullOrEmpty(Settings.GSDXDir) || !Directory.Exists(Settings.GSDXDir))
Settings.GSDXDir = AppDomain.CurrentDomain.BaseDirectory;
if (String.IsNullOrEmpty(Settings.DumpDir) || !Directory.Exists(Settings.DumpDir))
Settings.DumpDir = AppDomain.CurrentDomain.BaseDirectory;
txtGSDXDirectory.Text = Settings.GSDXDir;
txtDumpsDirectory.Text = Settings.DumpDir;
BindListControl(lstDumps, _availableGsDumps, g => g.Files, f => f.DisplayText, g => g.SelectedFileIndex);
BindListControl(lstGSDX, _availableGsDlls, g => g.Files, f => f.DisplayText, g => g.SelectedFileIndex);
Processes = new List<Process>();
NoImage = CreateDefaultImage();
_dllWatcher = new List<FileSystemWatcher>();
_dumpWatcher = new List<FileSystemWatcher>();
_watcherEvents = new ConcurrentQueue<FileChangeEvt>();
_fileChangesWatchdog = new System.Windows.Forms.Timer();
_fileChangesWatchdog.Tick += new EventHandler(FileChangesWatchdog);
_fileChangesWatchdog.Interval = 1000;
_fileChangesWatchdog.Start();
}
private void DisposeExtra()
{
foreach (FileSystemWatcher w in _dllWatcher)
{
w.EnableRaisingEvents = false;
w.Dispose();
}
foreach (FileSystemWatcher w in _dumpWatcher)
{
w.EnableRaisingEvents = false;
w.Dispose();
}
_dllWatcher.Clear();
_dumpWatcher.Clear();
_fileChangesWatchdog.Stop();
_fileChangesWatchdog.Dispose();
}
private void FileChangesWatchdog(object source, EventArgs e)
{
bool dllReload = false;
bool dumpReload = false;
FileChangeEvt evt;
while (_watcherEvents.TryDequeue(out evt))
{
if (evt == FileChangeEvt.Dll) dllReload = true;
else if (evt == FileChangeEvt.Dump) dumpReload = true;
}
if (dllReload) ReloadGsdxDlls();
if (dumpReload) ReloadGsdxDumps();
}
private void OnDllDirChange(object source, FileSystemEventArgs e)
{
_watcherEvents.Enqueue(FileChangeEvt.Dll);
}
private void OnDumpDirChange(object source, FileSystemEventArgs e)
{
_watcherEvents.Enqueue(FileChangeEvt.Dump);
}
private static void BindListControl<TModel, TElement>(ListControl lb, TModel model, Func<TModel, BindingList<TElement>> collectionAccessor, Expression<Func<TElement, string>> displayTextAccessor, Expression<Func<TModel, int>> selectedIndexAccessor)
{
lb.DataSource = new BindingSource
{
DataSource = collectionAccessor(model)
};
lb.DisplayMember = ((MemberExpression)displayTextAccessor.Body).Member.Name;
lb.DataBindings.Add(nameof(lb.SelectedIndex), model, ((MemberExpression)selectedIndexAccessor.Body).Member.Name, false, DataSourceUpdateMode.OnPropertyChanged);
}
private static Bitmap CreateDefaultImage()
{
var defaultImage = new Bitmap(320, 240, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(defaultImage))
{
g.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, 320, 240));
g.DrawString("No Image", new Font(FontFamily.GenericSansSerif, 48, FontStyle.Regular), new SolidBrush(Color.White), new PointF(0, 70));
}
return defaultImage;
}
private void ReloadGsdxDlls()
{
_internalLogger.Information("Starting GSdx Loading Procedures");
var gsdxFolder = _folderWithFallBackFinder.GetViaPatternWithFallback(Settings.GSDXDir, "*.dll", "", "plugins", "dll", "dlls");
_availableGsDlls.Files.Clear();
foreach (var file in _gsdxDllFinder.GetEnrichedPathToValidGsdxDlls(gsdxFolder))
_availableGsDlls.Files.Add(file);
Settings.GSDXDir = gsdxFolder.FullName;
_internalLogger.Information("Completed GSdx Loading Procedures");
string[] paths = { "", "\\plugins", "\\dll", "\\dlls" };
foreach (FileSystemWatcher w in _dllWatcher)
{
w.EnableRaisingEvents = false;
w.Dispose();
}
_dllWatcher.Clear();
for (int i = 0; i < paths.Length; i++)
{
try
{
FileSystemWatcher w = new FileSystemWatcher(Settings.GSDXDir + paths[i], "*.dll");
//w.Changed += OnDllDirChange;
w.Created += OnDllDirChange;
w.Deleted += OnDllDirChange;
w.Renamed += OnDllDirChange;
w.EnableRaisingEvents = true;
_dllWatcher.Add(w);
}
catch { }
}
}
private void ReloadGsdxDumps()
{
_internalLogger.Information("Starting GSdx Dump Loading Procedures...");
var dumpFolder = _folderWithFallBackFinder.GetViaPatternWithFallback(Settings.DumpDir, "*.gs", "", "dumps", "gsdumps");
_availableGsDumps.Files.Clear();
foreach (var file in _gsDumpFinder.GetValidGsdxDumps(dumpFolder))
_availableGsDumps.Files.Add(file);
Settings.DumpDir = dumpFolder.FullName;
_internalLogger.Information("...Completed GSdx Dump Loading Procedures");
string[] paths = { "", "\\dumps", "\\gsdumps" };
foreach (FileSystemWatcher w in _dumpWatcher)
{
w.EnableRaisingEvents = false;
w.Dispose();
}
_dumpWatcher.Clear();
for (int i = 0; i < paths.Length; i++)
{
try
{
FileSystemWatcher w = new FileSystemWatcher(Settings.DumpDir + paths[i], "*.gs");
//w.Changed += OnDumpDirChange;
w.Created += OnDumpDirChange;
w.Deleted += OnDumpDirChange;
w.Renamed += OnDumpDirChange;
w.EnableRaisingEvents = true;
_dumpWatcher.Add(w);
}
catch { }
}
}
private void GSDumpGUI_Load(object sender, EventArgs e)
{
ReloadGsdxDlls();
ReloadGsdxDumps();
// Auto select GS dump and GSdx dll
_availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault();
_availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault();
}
private void cmdBrowseGSDX_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ValidateNames = false;
ofd.CheckFileExists = false;
ofd.CheckPathExists = true;
ofd.InitialDirectory = Settings.GSDXDir;
ofd.FileName = "Select Folder";
if(ofd.ShowDialog() == DialogResult.OK)
{
string newpath = Path.GetDirectoryName(ofd.FileName);
if (!Settings.GSDXDir.Equals(newpath, StringComparison.OrdinalIgnoreCase))
{
txtGSDXDirectory.Text = newpath;
Settings.GSDXDir = newpath;
Settings.Save();
ReloadGsdxDlls();
_availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault();
}
}
}
private void cmdBrowseDumps_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ValidateNames = false;
ofd.CheckFileExists = false;
ofd.CheckPathExists = true;
ofd.InitialDirectory = Settings.DumpDir;
ofd.FileName = "Select Folder";
if (ofd.ShowDialog() == DialogResult.OK)
{
string newpath = Path.GetDirectoryName(ofd.FileName);
if (!Settings.DumpDir.Equals(newpath, StringComparison.OrdinalIgnoreCase))
{
txtDumpsDirectory.Text = newpath;
Settings.DumpDir = newpath;
Settings.Save();
ReloadGsdxDumps();
_availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault();
}
}
}
private void cmdRun_Click(object sender, EventArgs e)
{
// Execute the GSReplay function
if (!_availableGsDumps.IsSelected)
{
MessageBox.Show("Select your Dump first", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (!_availableGsDlls.IsSelected)
{
MessageBox.Show("Select your GSdx first", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ExecuteFunction("GSReplay");
}
private void ExecuteFunction(String Function)
{
txtLog.Text = "";
CreateDirs();
// Set the Arguments to pass to the child
String SelectedRenderer = "";
switch (SelectedRad)
{
case 0:
SelectedRenderer = "-1";
break;
case 1:
SelectedRenderer = "0";
break;
case 2:
SelectedRenderer = "3";
break;
case 3:
SelectedRenderer = "12";
break;
case 4:
SelectedRenderer = "1";
break;
case 5:
SelectedRenderer = "4";
break;
case 6:
SelectedRenderer = "13";
break;
}
if (SelectedRenderer != "-1")
{
String GSdxIniPath = AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\inis\\gsdx.ini";
NativeMethods.WritePrivateProfileString("Settings", "Renderer", SelectedRenderer, GSdxIniPath);
}
var port = Program.Server.Port;
// dll path is mandatory for the two operations GSReplay and GSconfigure but dumpPath only for GSReplay
var dllPath = _availableGsDlls.Selected.File.FullName;
var dumpPath = _availableGsDumps.Selected?.File?.FullName;
if (string.IsNullOrWhiteSpace(dumpPath) && "GSReplay".Equals(Function))
throw new ArgumentException("You need to specify a dump path in case you want to replay a GsDump.", nameof(dumpPath));
_gsdxLogger.Information("Start new gsdx instance");
_gsdxLogger.Information($"\tdll: {dllPath}");
_gsdxLogger.Information($"\tdump: {dumpPath}");
// Start the child and link the events.
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.CreateNoWindow = true;
psi.FileName = Process.GetCurrentProcess().ProcessName;
psi.Arguments = "\"" + dllPath + "\"" + " \"" + dumpPath + "\"" + " \"" + Function + "\"" + " " + SelectedRenderer + " " + port;
Process p = Process.Start(psi);
p.OutputDataReceived += new DataReceivedEventHandler(p_StdOutDataReceived);
p.ErrorDataReceived += new DataReceivedEventHandler(p_StdErrDataReceived);
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.Exited += new EventHandler(p_Exited);
Processes.Add(p);
}
private static void CreateDirs()
{
// Create and set the config directory.
String Dir = AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\";
if (!Directory.Exists(Dir))
{
Directory.CreateDirectory(Dir);
}
Dir += "\\Inis\\";
if (!Directory.Exists(Dir))
{
Directory.CreateDirectory(Dir);
File.Create(Dir + "\\gsdx.ini").Close();
}
Dir = AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs";
Directory.SetCurrentDirectory(Dir);
}
private void p_Exited(object sender, EventArgs e)
{
// Remove the child if is closed
Processes.Remove((Process)sender);
}
private void p_StdOutDataReceived(object sender, DataReceivedEventArgs e)
{
_gsdxLogger.Information(e.Data);
}
private void p_StdErrDataReceived(object sender, DataReceivedEventArgs e)
{
_gsdxLogger.Error(e.Data);
}
private void cmdConfigGSDX_Click(object sender, EventArgs e)
{
// Execute the GSconfigure function
if (!_availableGsDlls.IsSelected)
{
MessageBox.Show("Select your GSdx first", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
ExecuteFunction("GSconfigure");
}
private void cmdOpenIni_Click(object sender, EventArgs e)
{
// Execute the GSconfigure function
CreateDirs();
Process.Start(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\inis\\gsdx.ini");
}
private void UpdatePreviewImage(object sender, GsFiles<GsDumpFile>.SelectedIndexUpdatedEventArgs args)
{
if (pctBox.Image != NoImage)
pctBox.Image?.Dispose();
if (_availableGsDumps.Selected?.PreviewFile == null)
{
pctBox.Image = NoImage;
pctBox.Cursor = Cursors.Default;
}
else
{
pctBox.Load(_availableGsDumps.Selected.PreviewFile.FullName);
pctBox.Cursor = Cursors.Hand;
}
pctBox.Tag = _availableGsDumps.Selected?.PreviewFile?.FullName;
}
private static void PreviewImageClick(object sender, EventArgs e)
{
var previewControl = (PictureBox)sender;
if (previewControl.Tag == null)
return;
Process.Start((string)previewControl.Tag);
}
private void GSDumpGUI_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return && !txtGSDXDirectory.Focused && !txtDumpsDirectory.Focused)
cmdRun_Click(sender, e);
if (e.KeyCode == Keys.F1)
cmdConfigGSDX_Click(sender, e);
if ((e.KeyCode == Keys.F2))
SelectedRad++;
}
private void rda_CheckedChanged(object sender, EventArgs e)
{
RadioButton itm = ((RadioButton)(sender));
if (itm.Checked == true)
SelectedRad = Convert.ToInt32(itm.Tag);
}
private void txtGSDXDirectory_Enter(object sender, EventArgs e)
{
_gsdxPathOld = txtGSDXDirectory.Text;
}
private void txtDumpsDirectory_Enter(object sender, EventArgs e)
{
_dumpPathOld = txtDumpsDirectory.Text;
}
private void txtGSDXDirectory_Leave(object sender, EventArgs e)
{
string newpath = txtGSDXDirectory.Text;
if (!_gsdxPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase))
txtGSDXDirectory.Text = _gsdxPathOld;
}
private void txtDumpsDirectory_Leave(object sender, EventArgs e)
{
string newpath = txtDumpsDirectory.Text;
if(!_dumpPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase))
txtDumpsDirectory.Text = _dumpPathOld;
}
private void txtGSDXDirectory_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
string newpath = txtGSDXDirectory.Text;
if (!String.IsNullOrEmpty(newpath) &&
!_gsdxPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase) &&
Directory.Exists(newpath))
{
_gsdxPathOld = newpath;
Settings.GSDXDir = newpath;
Settings.Save();
ReloadGsdxDlls();
_availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault();
}
}
}
private void txtDumpsDirectory_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
string newpath = txtDumpsDirectory.Text;
if (!String.IsNullOrEmpty(newpath) &&
!_dumpPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase) &&
Directory.Exists(newpath))
{
_dumpPathOld = newpath;
Settings.DumpDir = newpath;
Settings.Save();
ReloadGsdxDumps();
_availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault();
}
}
}
private void lstProcesses_SelectedIndexChanged(object sender, EventArgs e)
{
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)
{
if (lstProcesses.SelectedIndex != -1)
{
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)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.Step;
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
private void btnRunToSelection_Click(object sender, EventArgs e)
{
if (treTreeView.SelectedNode != null)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.RunToCursor;
msg.Parameters.Add(Convert.ToInt32(treTreeView.SelectedNode.Text.Split(new string[]{" - "}, StringSplitOptions.None)[0]));
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
else
MessageBox.Show("You have not selected a node to jump to");
}
private void cmdGoToStart_Click(object sender, EventArgs e)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.RunToCursor;
msg.Parameters.Add(0);
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
private void cmdGoToNextVSync_Click(object sender, EventArgs e)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.RunToNextVSync;
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
private void treTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{
if (treTreeView.SelectedNode != null)
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.PacketInfo;
msg.Parameters.Add(Convert.ToInt32(treTreeView.SelectedNode.Text.Split(new string[] { " - " }, StringSplitOptions.None)[0]));
Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg);
}
treTreeView.SelectedNode = e.Node;
}
private void GSDumpGUI_FormClosing(object sender, FormClosingEventArgs e)
{
// Make sure all child processes are closed upon closing the main form
Processes.ForEach(p =>
{
try { p.Kill(); } catch { }
p.Dispose();
});
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,164 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{825E4311-652D-4A1E-8AA1-F6D81B186E33}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GSDumpGUI</RootNamespace>
<AssemblyName>GSDumpGUI</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ApplicationIcon>Resources\AppIcon.ico</ApplicationIcon>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Forms\Entities\GsDlls.cs" />
<Compile Include="Forms\Entities\GsDumpFile.cs" />
<Compile Include="Forms\Entities\GsDumps.cs" />
<Compile Include="Forms\Entities\GsFile.cs" />
<Compile Include="Forms\Entities\GsFiles.cs" />
<Compile Include="Forms\frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Helper\ExtensionMethods.cs" />
<Compile Include="Forms\Helper\FolderWithFallBackFinder.cs" />
<Compile Include="Forms\Helper\GsDumpFinder.cs" />
<Compile Include="Forms\Helper\GsdxDllFinder.cs" />
<Compile Include="Forms\Helper\IFolderWithFallBackFinder.cs" />
<Compile Include="Forms\Helper\IGsDumpFinder.cs" />
<Compile Include="Forms\Helper\IGsdxDllFinder.cs" />
<Compile Include="Forms\Helper\ILogger.cs" />
<Compile Include="Forms\Helper\RichTextBoxLogger.cs" />
<Compile Include="Forms\SettingsProvider\PortableXmlSettingsProvider.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFPrim.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegNOP.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegUnimpl.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegAD.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegTEX0.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegFOG.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegXYZF.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegUV.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegST.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFReg.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GifImage.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegPRIM.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegRGBAQ.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\IGifData.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFTag.cs" />
<Compile Include="Library\GSDump\GSData\GIFUtil.cs" />
<Compile Include="Library\GSDump\GSData\GSData.cs" />
<Compile Include="Library\GSDump\GSDump.cs" />
<Compile Include="Library\GSDump\GSData\GSTransfer.cs" />
<Compile Include="Library\GSDXWrapper.cs" />
<Compile Include="Library\NativeMethods.cs" />
<Compile Include="Core\Program.cs" />
<Compile Include="Library\TCPLibrary\Message\BaseMessageClient.cs" />
<Compile Include="Library\TCPLibrary\Message\BaseMessageClientS.cs" />
<Compile Include="Library\TCPLibrary\Message\BaseMessageServer.cs" />
<Compile Include="Library\TCPLibrary\Base\CancelArgs.cs" />
<Compile Include="Library\TCPLibrary\Base\Client.cs" />
<Compile Include="Library\TCPLibrary\Base\ClientS.cs" />
<Compile Include="Library\TCPLibrary\Base\Data.cs" />
<Compile Include="Library\TCPLibrary\Base\Server.cs" />
<Compile Include="Library\TCPLibrary\Message\TCPMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Forms\frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AppIcon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GSDumpGUI", "GSDumpGUI.csproj", "{825E4311-652D-4A1E-8AA1-F6D81B186E33}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x64.ActiveCfg = Debug|x64
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x64.Build.0 = Debug|x64
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x86.ActiveCfg = Debug|x86
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|x86.Build.0 = Debug|x86
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x64.ActiveCfg = Release|x64
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x64.Build.0 = Release|x64
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x86.ActiveCfg = Release|x86
{825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {19DB287E-B866-4E97-B0AE-95CF54B00134}
EndGlobalSection
EndGlobal

View File

@ -1,462 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using TCPLibrary.MessageBased.Core;
using System.Threading;
namespace GSDumpGUI
{
public delegate void GSgifTransfer(IntPtr data, int size);
public delegate void GSgifTransfer1(IntPtr data, int size);
public delegate void GSgifTransfer2(IntPtr data, int size);
public delegate void GSgifTransfer3(IntPtr data, int size);
public delegate void GSVSync(byte field);
public delegate void GSreset();
public delegate void GSreadFIFO2(IntPtr data, int size);
public delegate void GSsetGameCRC(int crc, int options);
public delegate int GSfreeze(int mode, IntPtr data);
public delegate int GSopen(IntPtr hwnd, String Title, int renderer);
public delegate void GSclose();
public delegate void GSshutdown();
public delegate void GSConfigure();
public delegate void GSsetBaseMem(IntPtr data);
public delegate IntPtr PS2EgetLibName();
public delegate void GSinit();
public delegate UInt32 GSmakeSnapshot(string path);
public class InvalidGSPlugin : Exception
{
public InvalidGSPlugin(string reason) : base(reason) {}
}
public class GSDXWrapper
{
static public bool DumpTooOld = false;
private GSConfigure gsConfigure;
private PS2EgetLibName Ps2egetLibName;
private GSgifTransfer GSgifTransfer;
private GSgifTransfer1 GSgifTransfer1;
private GSgifTransfer2 GSgifTransfer2;
private GSgifTransfer3 GSgifTransfer3;
private GSVSync GSVSync;
private GSreadFIFO2 GSreadFIFO2;
private GSsetGameCRC GSsetGameCRC;
private GSfreeze GSfreeze;
private GSopen GSopen;
private GSclose GSclose;
private GSshutdown GSshutdown;
private GSsetBaseMem GSsetBaseMem;
private GSinit GSinit;
private GSreset GSreset;
private GSmakeSnapshot GSmakeSnapshot;
private Boolean Loaded;
private String DLL;
private IntPtr DLLAddr;
private Boolean Running;
public Queue<TCPMessage> QueueMessage;
public Boolean DebugMode;
public GSData CurrentGIFPacket;
public bool ThereIsWork;
public AutoResetEvent ExternalEvent;
public int RunTo;
public void Load(String DLL)
{
var formerDirectory = Directory.GetCurrentDirectory();
try
{
this.DLL = DLL;
NativeMethods.SetErrorMode(0x8007);
if (Loaded)
Unload();
string dir = DLL;
dir = Path.GetDirectoryName(dir);
if (dir == null) return;
Directory.SetCurrentDirectory(dir);
IntPtr hmod = NativeMethods.LoadLibrary(DLL);
if (hmod != IntPtr.Zero)
{
DLLAddr = hmod;
IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName");
IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure");
IntPtr funcaddrGIF = NativeMethods.GetProcAddress(hmod, "GSgifTransfer");
IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1");
IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2");
IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3");
IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync");
IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem");
IntPtr funcaddrGSReset = NativeMethods.GetProcAddress(hmod, "GSreset");
IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen");
IntPtr funcaddrSetCRC = NativeMethods.GetProcAddress(hmod, "GSsetGameCRC");
IntPtr funcaddrClose = NativeMethods.GetProcAddress(hmod, "GSclose");
IntPtr funcaddrShutdown = NativeMethods.GetProcAddress(hmod, "GSshutdown");
IntPtr funcaddrFreeze = NativeMethods.GetProcAddress(hmod, "GSfreeze");
IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2");
IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit");
IntPtr funcmakeSnapshot = NativeMethods.GetProcAddress(hmod, "GSmakeSnapshot");
if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrGIF.ToInt64() > 0)))
throw new InvalidGSPlugin("");
gsConfigure = (GSConfigure) Marshal.GetDelegateForFunctionPointer(funcaddrConfig, typeof(GSConfigure));
Ps2egetLibName = (PS2EgetLibName) Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PS2EgetLibName));
this.GSgifTransfer = (GSgifTransfer) Marshal.GetDelegateForFunctionPointer(funcaddrGIF, typeof(GSgifTransfer));
this.GSgifTransfer1 = (GSgifTransfer1) Marshal.GetDelegateForFunctionPointer(funcaddrGIF1, typeof(GSgifTransfer1));
this.GSgifTransfer2 = (GSgifTransfer2) Marshal.GetDelegateForFunctionPointer(funcaddrGIF2, typeof(GSgifTransfer2));
this.GSgifTransfer3 = (GSgifTransfer3) Marshal.GetDelegateForFunctionPointer(funcaddrGIF3, typeof(GSgifTransfer3));
this.GSVSync = (GSVSync) Marshal.GetDelegateForFunctionPointer(funcaddrVSync, typeof(GSVSync));
this.GSsetBaseMem = (GSsetBaseMem) Marshal.GetDelegateForFunctionPointer(funcaddrSetBaseMem, typeof(GSsetBaseMem));
this.GSopen = (GSopen) Marshal.GetDelegateForFunctionPointer(funcaddrOpen, typeof(GSopen));
this.GSsetGameCRC = (GSsetGameCRC) Marshal.GetDelegateForFunctionPointer(funcaddrSetCRC, typeof(GSsetGameCRC));
this.GSclose = (GSclose) Marshal.GetDelegateForFunctionPointer(funcaddrClose, typeof(GSclose));
this.GSshutdown = (GSshutdown) Marshal.GetDelegateForFunctionPointer(funcaddrShutdown, typeof(GSshutdown));
this.GSfreeze = (GSfreeze) Marshal.GetDelegateForFunctionPointer(funcaddrFreeze, typeof(GSfreeze));
this.GSreset = (GSreset) Marshal.GetDelegateForFunctionPointer(funcaddrGSReset, typeof(GSreset));
this.GSreadFIFO2 = (GSreadFIFO2) Marshal.GetDelegateForFunctionPointer(funcaddrGSreadFIFO2, typeof(GSreadFIFO2));
this.GSinit = (GSinit) Marshal.GetDelegateForFunctionPointer(funcaddrinit, typeof(GSinit));
this.GSmakeSnapshot = (GSmakeSnapshot)Marshal.GetDelegateForFunctionPointer(funcmakeSnapshot, typeof(GSmakeSnapshot));
Loaded = true;
}
if (!Loaded)
{
Exception lasterror = Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", DLL + " failed to load. Error " + lasterror.ToString() + Environment.NewLine);
NativeMethods.SetErrorMode(0x0000);
Unload();
throw new InvalidGSPlugin(lasterror.ToString());
}
NativeMethods.SetErrorMode(0x0000);
}
finally
{
Directory.SetCurrentDirectory(formerDirectory);
}
}
public void Unload()
{
NativeMethods.FreeLibrary(DLLAddr);
Loaded = false;
}
public void GSConfig()
{
if (!Loaded)
throw new Exception("GSdx is not loaded");
gsConfigure.Invoke();
}
public String PS2EGetLibName()
{
if (!Loaded)
throw new Exception("GSdx is not loaded");
return Marshal.PtrToStringAnsi(Ps2egetLibName.Invoke());
}
public unsafe void Run(GSDump dump, int rendererOverride)
{
QueueMessage = new Queue<TCPMessage>();
Running = true;
ExternalEvent = new AutoResetEvent(true);
GSinit();
byte[] tempregisters = new byte[8192];
Array.Copy(dump.Registers, tempregisters, 8192);
fixed (byte* pointer = tempregisters)
{
GSsetBaseMem(new IntPtr(pointer));
IntPtr hWnd = IntPtr.Zero;
if (GSopen(new IntPtr(&hWnd), "", rendererOverride) != 0)
return;
GSsetGameCRC(dump.CRC, 0);
NativeMethods.SetClassLong(hWnd,/*GCL_HICON*/ -14, Program.hMainIcon);
fixed (byte* freeze = dump.StateData)
{
byte[] GSFreez;
if (Environment.Is64BitProcess)
{
GSFreez = new byte[16];
Array.Copy(BitConverter.GetBytes((Int64)dump.StateData.Length), 0, GSFreez, 0, 8);
Array.Copy(BitConverter.GetBytes(new IntPtr(freeze).ToInt64()), 0, GSFreez, 8, 8);
}
else
{
GSFreez = new byte[8];
Array.Copy(BitConverter.GetBytes((Int32)dump.StateData.Length), 0, GSFreez, 0, 4);
Array.Copy(BitConverter.GetBytes(new IntPtr(freeze).ToInt32()), 0, GSFreez, 4, 4);
}
fixed (byte* fr = GSFreez)
{
int ris = GSfreeze(0, new IntPtr(fr));
if (ris == -1)
{
DumpTooOld = true;
Running = false;
}
GSVSync(1);
GSreset();
Marshal.Copy(dump.Registers, 0, new IntPtr(pointer), 8192);
GSsetBaseMem(new IntPtr(pointer));
GSfreeze(0, new IntPtr(fr));
GSData gsd_vsync = new GSData();
gsd_vsync.id = GSType.VSync;
int gs_idx = 0;
int debug_idx = 0;
NativeMessage msg;
while (Running)
{
while (NativeMethods.PeekMessage(out msg, hWnd, 0, 0, 1)) // PM_REMOVE
{
NativeMethods.TranslateMessage(ref msg);
NativeMethods.DispatchMessage(ref msg);
if(msg.msg == 0x0100) // WM_KEYDOWN
{
switch(msg.wParam.ToInt32() & 0xFF)
{
case 0x1B: Running = false; break; // VK_ESCAPE;
case 0x77: GSmakeSnapshot(""); break; // VK_F8;
}
}
}
if (!Running || !NativeMethods.IsWindowVisible(hWnd))
break;
if (DebugMode)
{
if (QueueMessage.Count > 0)
{
TCPMessage Mess = QueueMessage.Dequeue();
switch (Mess.MessageType)
{
case MessageType.Step:
if (debug_idx >= dump.Data.Count)
debug_idx = 0;
RunTo = debug_idx;
break;
case MessageType.RunToCursor:
RunTo = (int)Mess.Parameters[0];
if(debug_idx > RunTo)
debug_idx = 0;
break;
case MessageType.RunToNextVSync:
if (debug_idx >= dump.Data.Count)
debug_idx = 1;
RunTo = dump.Data.FindIndex(debug_idx, a => a.id == GSType.VSync);
break;
default:
break;
}
}
if (debug_idx <= RunTo)
{
while (debug_idx <= RunTo)
{
GSData itm = dump.Data[debug_idx];
CurrentGIFPacket = itm;
Step(itm, pointer);
debug_idx++;
}
int idxnextReg = dump.Data.FindIndex(debug_idx, a => a.id == GSType.Registers);
if (idxnextReg != -1)
Step(dump.Data[idxnextReg], pointer);
TCPMessage Msg = new TCPMessage();
Msg.MessageType = MessageType.RunToCursor;
Msg.Parameters.Add(debug_idx - 1);
Program.Client.Send(Msg);
ExternalEvent.Set();
}
Step(gsd_vsync, pointer);
}
else
{
while (gs_idx < dump.Data.Count)
{
GSData itm = dump.Data[gs_idx++];
CurrentGIFPacket = itm;
Step(itm, pointer);
if (gs_idx < dump.Data.Count && dump.Data[gs_idx].id == GSType.VSync)
break;
}
if (gs_idx >= dump.Data.Count) gs_idx = 0;
}
}
GSclose();
GSshutdown();
}
}
}
}
private unsafe void Step(GSData itm, byte* registers)
{
/*"C:\Users\Alessio\Desktop\Plugins\Dll\GSdx-SSE4.dll" "C:\Users\Alessio\Desktop\Plugins\Dumps\gsdx_20101222215004.gs" "GSReplay" 0*/
switch (itm.id)
{
case GSType.Transfer:
switch (((GSTransfer)itm).Path)
{
case GSTransferPath.Path1Old:
byte[] data = new byte[16384];
int addr = 16384 - itm.data.Length;
Array.Copy(itm.data, 0, data, addr, itm.data.Length);
fixed (byte* gifdata = data)
{
GSgifTransfer1(new IntPtr(gifdata), addr);
}
break;
case GSTransferPath.Path2:
fixed (byte* gifdata = itm.data)
{
GSgifTransfer2(new IntPtr(gifdata), (itm.data.Length) / 16);
}
break;
case GSTransferPath.Path3:
fixed (byte* gifdata = itm.data)
{
GSgifTransfer3(new IntPtr(gifdata), (itm.data.Length) / 16);
}
break;
case GSTransferPath.Path1New:
fixed (byte* gifdata = itm.data)
{
GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) / 16);
}
break;
}
break;
case GSType.VSync:
GSVSync((*((int*)(registers + 4096)) & 0x2000) > 0 ? (byte)1 : (byte)0);
break;
case GSType.ReadFIFO2:
fixed (byte* FIFO = itm.data)
{
byte[] arrnew = new byte[*((int*)FIFO)];
fixed (byte* arrn = arrnew)
{
GSreadFIFO2(new IntPtr(arrn), *((int*)FIFO));
}
}
break;
case GSType.Registers:
Marshal.Copy(itm.data, 0, new IntPtr(registers), 8192);
break;
default:
break;
}
}
public void Stop()
{
Running = false;
}
internal List<Object> GetGifPackets(GSDump dump)
{
List<Object> Data = new List<Object>();
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() + "|";
act += ((GSTransfer)dump.Data[i]).data.Length;
}
else
{
act += ((GSData)dump.Data[i]).data.Length;
}
Data.Add(act);
}
return Data;
}
internal object GetGifPacketInfo(GSDump dump, int i)
{
if (dump.Data[i].id == GSType.Transfer)
{
try
{
GIFTag val = GIFTag.ExtractGifTag(dump.Data[i].data, ((GSTransfer)dump.Data[i]).Path);
return val;
}
catch (Exception)
{
return new GIFTag();
}
}
else
{
switch (dump.Data[i].id)
{
case GSType.VSync:
return dump.Data[i].data.Length + "|Field = " + dump.Data[i].data[0].ToString();
case GSType.ReadFIFO2:
return dump.Data[i].data.Length + "|ReadFIFO2 : Size = " + BitConverter.ToInt32(dump.Data[i].data, 0).ToString() + " byte";
case GSType.Registers:
return dump.Data[i].data.Length + "|Registers";
default:
return "";
}
}
}
}
}

View File

@ -1,76 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFPrim : GIFUtil
{
public GS_PRIM PrimitiveType;
public GSIIP IIP;
public bool TME;
public bool FGE;
public bool ABE;
public bool AA1;
public GSFST FST;
public GSCTXT CTXT;
public GSFIX FIX;
static internal GIFPrim ExtractGIFPrim(UInt32 LowData)
{
GIFPrim pr = new GIFPrim();
pr.PrimitiveType = (GS_PRIM)GetBit(LowData, 0, 3);
pr.IIP = (GSIIP)GetBit(LowData, 3, 1);
pr.TME = Convert.ToBoolean(GetBit(LowData, 4, 1));
pr.FGE = Convert.ToBoolean(GetBit(LowData, 5, 1));
pr.ABE = Convert.ToBoolean(GetBit(LowData, 6, 1));
pr.AA1 = Convert.ToBoolean(GetBit(LowData, 7, 1));
pr.FST = (GSFST)(GetBit(LowData, 8, 1));
pr.CTXT = (GSCTXT)(GetBit(LowData, 9, 1));
pr.FIX = (GSFIX)(GetBit(LowData, 10, 1));
return pr;
}
public override string ToString()
{
return "Primitive Type : " + PrimitiveType.ToString() + "@IIP : " + IIP.ToString() + "@TME : " + TME.ToString() + "@FGE : " + FGE.ToString()
+ "@ABE : " + ABE.ToString() + "@AA1 : " + AA1.ToString() + "@FST : " + FST.ToString() + "@CTXT : " + CTXT.ToString() + "@FIX : " + FIX.ToString();
}
}
public enum GS_PRIM
{
GS_POINTLIST = 0,
GS_LINELIST = 1,
GS_LINESTRIP = 2,
GS_TRIANGLELIST = 3,
GS_TRIANGLESTRIP = 4,
GS_TRIANGLEFAN = 5,
GS_SPRITE = 6,
GS_INVALID = 7,
}
}

View File

@ -1,109 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
abstract public class GIFReg : GIFUtil, IGifData
{
public GIFRegDescriptor Descriptor;
public UInt64 LowData, HighData;
public bool PackedFormat;
private GIFReg() { }
public GIFReg(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
this.LowData = LowData;
this.HighData = HighData;
this.PackedFormat = PackedFormat;
}
abstract public new String ToString();
}
public enum GIFRegDescriptor
{
PRIM = 0x00,
RGBAQ = 0x01,
ST = 0x02,
UV = 0x03,
XYZF2 = 0x04,
XYZ2 = 0x05,
TEX0_1 = 0x06,
TEX0_2 = 0x07,
CLAMP_1 = 0x08,
CLAMP_2 = 0x09,
FOG = 0x0a,
XYZF3 = 0x0c,
XYZ3 = 0x0d,
AD = 0x0e,
NOP = 0x0f, // actually, 0xf is the standard GIF NOP and 0x7f is the standard GS NOP, but all unregistered addresses act as NOPs... probably
TEX1_1 = 0x14,
TEX1_2 = 0x15,
TEX2_1 = 0x16,
TEX2_2 = 0x17,
XYOFFSET_1 = 0x18,
XYOFFSET_2 = 0x19,
PRMODECONT = 0x1a,
PRMODE = 0x1b,
TEXCLUT = 0x1c,
SCANMSK = 0x22,
MIPTBP1_1 = 0x34,
MIPTBP1_2 = 0x35,
MIPTBP2_1 = 0x36,
MIPTBP2_2 = 0x37,
TEXA = 0x3b,
FOGCOL = 0x3d,
TEXFLUSH = 0x3f,
SCISSOR_1 = 0x40,
SCISSOR_2 = 0x41,
ALPHA_1 = 0x42,
ALPHA_2 = 0x43,
DIMX = 0x44,
DTHE = 0x45,
COLCLAMP = 0x46,
TEST_1 = 0x47,
TEST_2 = 0x48,
PABE = 0x49,
FBA_1 = 0x4a,
FBA_2 = 0x4b,
FRAME_1 = 0x4c,
FRAME_2 = 0x4d,
ZBUF_1 = 0x4e,
ZBUF_2 = 0x4f,
BITBLTBUF = 0x50,
TRXPOS = 0x51,
TRXREG = 0x52,
TRXDIR = 0x53,
HWREG = 0x54,
SIGNAL = 0x60,
FINISH = 0x61,
LABEL = 0x62,
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public static class GIFRegAD
{
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
byte reg = (byte)GIFReg.GetBit(HighData, 0, 8);
if (reg == (byte)GIFRegDescriptor.AD)
return GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat);
return GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false);
}
}
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegFOG : GIFReg
{
public double F;
public GIFRegFOG(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegFOG u = new GIFRegFOG(addr, LowData, HighData, PackedFormat);
u.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat)
u.F = (UInt16)(GetBit(HighData, 36, 8));
else
u.F = GetBit(LowData, 56, 8);
return u;
}
public override string ToString()
{
return Descriptor.ToString() + "@F : " + F.ToString();
}
}
}

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegNOP : GIFReg
{
public byte addr;
public GIFRegNOP(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegNOP nop = new GIFRegNOP(addr, LowData, HighData, PackedFormat);
nop.Descriptor = GIFRegDescriptor.NOP;
return nop;
}
public override string ToString()
{
return Descriptor.ToString() + " (0x" + addr.ToString("X2") + ")";
}
}
}

View File

@ -1,91 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegPRIM : GIFReg
{
public GS_PRIM PrimitiveType;
public GSIIP IIP;
public bool TME;
public bool FGE;
public bool ABE;
public bool AA1;
public GSFST FST;
public GSCTXT CTXT;
public GSFIX FIX;
public GIFRegPRIM(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegPRIM pr = new GIFRegPRIM(addr, LowData, HighData, PackedFormat);
pr.Descriptor = (GIFRegDescriptor)addr;
pr.PrimitiveType = (GS_PRIM)GetBit(LowData, 0, 3);
pr.IIP = (GSIIP)GetBit(LowData, 3, 1);
pr.TME = Convert.ToBoolean(GetBit(LowData, 4, 1));
pr.FGE = Convert.ToBoolean(GetBit(LowData, 5, 1));
pr.ABE = Convert.ToBoolean(GetBit(LowData, 6, 1));
pr.AA1 = Convert.ToBoolean(GetBit(LowData, 7, 1));
pr.FST = (GSFST)(GetBit(LowData, 8, 1));
pr.CTXT = (GSCTXT)(GetBit(LowData, 9, 1));
pr.FIX = (GSFIX)(GetBit(LowData, 10, 1));
return pr;
}
public override string ToString()
{
return Descriptor.ToString() + "@Primitive Type : " + PrimitiveType.ToString() + "@IIP : " + IIP.ToString() + "@TME : " + TME.ToString() + "@FGE : " + FGE.ToString()
+ "@ABE : " + ABE.ToString() + "@AA1 : " + AA1.ToString() + "@FST : " + FST.ToString() + "@CTXT : " + CTXT.ToString() + "@FIX : " + FIX.ToString();
}
}
public enum GSIIP
{
FlatShading=0,
Gouraud=1
}
public enum GSFST
{
STQValue=0,
UVValue=1
}
public enum GSCTXT
{
Context1 =0,
Context2 =1
}
public enum GSFIX
{
Unfixed =0,
Fixed = 1
}
}

View File

@ -1,69 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegRGBAQ : GIFReg
{
public byte R;
public byte G;
public byte B;
public byte A;
public float Q;
public GIFRegRGBAQ(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegRGBAQ r = new GIFRegRGBAQ(addr, LowData, HighData, PackedFormat);
r.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat)
{
r.R = (byte)GetBit(LowData, 0, 8);
r.G = (byte)GetBit(LowData, 32, 8);
r.B = (byte)GetBit(HighData, 0, 8);
r.A = (byte)GetBit(HighData, 32, 8);
r.Q = tag.Q;
}
else
{
r.R = (byte)GetBit(LowData, 0, 8);
r.G = (byte)GetBit(LowData, 8, 8);
r.B = (byte)GetBit(LowData, 16, 8);
r.A = (byte)GetBit(LowData, 24, 8);
r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
}
return r;
}
public override string ToString()
{
return Descriptor.ToString() + "@Red : " + R.ToString() + "@Green : " + G.ToString() + "@Blue : " + B.ToString() + "@Alpha : " + A.ToString();
}
}
}

View File

@ -1,65 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegST : GIFReg
{
public float S;
public float T;
public float Q;
public bool isSTQ;
public GIFRegST(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegST st = new GIFRegST(addr, LowData, HighData, PackedFormat);
st.Descriptor = (GIFRegDescriptor)addr;
st.S = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 0);
st.T = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
if (PackedFormat)
{
st.Q = BitConverter.ToSingle(BitConverter.GetBytes(HighData), 0);
tag.Q = st.Q;
st.isSTQ = true;
}
else
st.isSTQ = false;
return st;
}
public override string ToString()
{
return Descriptor.ToString() + "@S : " + S.ToString("F8") + "@T : " + T.ToString("F8") + (isSTQ ? "@Q : " + Q.ToString("F8") : "");
}
}
}

View File

@ -1,118 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegTEX0 : GIFReg
{
public ushort TBP0;
public byte TBW;
public TEXPSM PSM;
public byte TW;
public byte TH;
public TEXTCC TCC;
public TEXTFX TFX;
public ushort CBP;
public TEXCPSM CPSM;
public TEXCSM CSM;
public byte CSA;
public byte CLD;
public GIFRegTEX0(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegTEX0 tex0 = new GIFRegTEX0(addr, LowData, HighData, PackedFormat);
tex0.Descriptor = (GIFRegDescriptor)addr;
tex0.TBP0 = (ushort)GetBit(LowData, 0, 14);
tex0.TBW = (byte)GetBit(LowData, 14, 6);
tex0.PSM = (TEXPSM)GetBit(LowData, 20, 6);
tex0.TW = (byte)GetBit(LowData, 26, 4);
tex0.TH = (byte)GetBit(LowData, 30, 4);
tex0.TCC = (TEXTCC)GetBit(LowData, 34, 1);
tex0.TFX = (TEXTFX)GetBit(LowData, 35, 2);
tex0.CBP = (ushort)GetBit(LowData, 37, 14);
tex0.CPSM = (TEXCPSM)GetBit(LowData, 51, 4);
tex0.CSM = (TEXCSM)GetBit(LowData, 55, 1);
tex0.CSA = (byte)GetBit(LowData, 56, 5);
tex0.CLD = (byte)GetBit(LowData, 61, 3);
return tex0;
}
public override string ToString()
{
return Descriptor.ToString() + "@TBP0 : " + TBP0.ToString() + "@TBW : " + TBW.ToString() + "@PSM : " + PSM.ToString() + "@TW : " + TW.ToString() + "@TH : " + TH.ToString()
+ "@TCC : " + TCC.ToString() + "@TFX : " + TFX.ToString() + "@CBP : " + CBP.ToString() + "@CPSM : " + CPSM.ToString() + "@CSM : " + CSM.ToString()
+ "@CSA : " + CSA.ToString() + "@CLD : " + CLD.ToString();
}
}
public enum TEXPSM
{
PSMCT32 = 0,
PSMCT24 = 1,
PSMCT16 = 2,
PSMCT16S = 10,
PSMT8 = 19,
PSMT4 = 20,
PSMT8H = 27,
PSMT4HL = 36,
PSMT4HH = 44,
PSMZ32 = 48,
PSMZ24 = 49,
PSMZ16 = 50,
PSMZ16S = 58
}
public enum TEXTCC
{
RGB = 0,
RGBA = 1
}
public enum TEXTFX
{
MODULATE = 0,
DECAL = 1,
HIGHLIGHT = 2,
HIGHLIGHT2 = 3
}
public enum TEXCPSM
{
PSMCT32 = 0,
PSMCT16 = 2,
PSMCT16S = 10
}
public enum TEXCSM
{
CSM1 = 0,
CSM2 = 1
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegUV : GIFReg
{
public double U;
public double V;
public GIFRegUV(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegUV uv = new GIFRegUV(addr, LowData, HighData, PackedFormat);
uv.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat)
{
uv.U = GetBit(LowData, 0, 14) / 16d;
uv.V = GetBit(LowData, 32, 14) / 16d;
}
else
{
uv.U = GetBit(LowData, 0, 14) / 16d;
uv.V = GetBit(LowData, 16, 14) / 16d;
}
return uv;
}
public override string ToString()
{
return Descriptor.ToString() + "@U : " + U.ToString("F4") + "@V : " + V.ToString("F4");
}
}
}

View File

@ -1,47 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegUnimpl : GIFReg
{
public GIFRegUnimpl(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegUnimpl u = new GIFRegUnimpl(addr, LowData, HighData, PackedFormat);
u.Descriptor = (GIFRegDescriptor)addr;
return u;
}
public override string ToString()
{
return Descriptor.ToString();
}
}
}

View File

@ -1,99 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFRegXYZF : GIFReg
{
public double X;
public double Y;
public UInt32 Z;
public UInt16 F;
public bool IsXYZF;
public GIFRegXYZF(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg UnpackXYZ(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat);
xyzf.IsXYZF = false;
if (PackedFormat && addr == (int)GIFRegDescriptor.XYZ2 && GetBit(HighData, 47, 1) == 1)
xyzf.Descriptor = GIFRegDescriptor.XYZ3;
else
xyzf.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat)
{
xyzf.X = GetBit(LowData, 0, 16) / 16d;
xyzf.Y = GetBit(LowData, 32, 16) / 16d;
xyzf.Z = (UInt32)(GetBit(HighData, 0, 32));
}
else
{
xyzf.X = GetBit(LowData, 0, 16) / 16d;
xyzf.Y = GetBit(LowData, 16, 16) / 16d;
xyzf.Z = (UInt32)(GetBit(LowData, 32, 32));
}
return xyzf;
}
static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{
GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat);
xyzf.IsXYZF = true;
if (PackedFormat && addr == (int)GIFRegDescriptor.XYZF2 && GetBit(HighData, 47, 1) == 1)
xyzf.Descriptor = GIFRegDescriptor.XYZF3;
else
xyzf.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat)
{
xyzf.X = GetBit(LowData, 0, 16) / 16d;
xyzf.Y = GetBit(LowData, 32, 16) / 16d;
xyzf.Z = (UInt32)(GetBit(HighData, 4, 24));
xyzf.F = (UInt16)(GetBit(HighData, 36, 8));
}
else
{
xyzf.X = GetBit(LowData, 0, 16) / 16d;
xyzf.Y = GetBit(LowData, 16, 16) / 16d;
xyzf.Z = (UInt32)(GetBit(LowData, 32, 24));
xyzf.F = (UInt16)(GetBit(LowData, 56, 8));
}
return xyzf;
}
public override string ToString()
{
return Descriptor.ToString() + "@X : " + X.ToString("F4") + "@Y : " + Y.ToString("F4") + "@Z : " + Z.ToString() + (IsXYZF ? "@F : " + F.ToString() : "");
}
}
}

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GifImage : IGifData
{
public byte[] Data;
public override string ToString()
{
return "IMAGE@" + Data.Length.ToString() + " bytes";
}
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public interface IGifData
{
String ToString();
}
}

View File

@ -1,193 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
[Serializable]
public class GIFTag : GIFUtil
{
public delegate GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat);
static public Dictionary<int, Unpack> UnpackReg;
private UInt64 TAG, REGS;
internal float Q; // GIF has an internal Q register which is reset to 1.0 at the tag and updated on packed ST(Q) for output at next RGBAQ
public GSTransferPath path;
public UInt32 nloop;
public UInt32 eop;
public UInt32 pre;
public GIFPrim prim;
public GIFFLG flg;
public UInt32 nreg;
public List<IGifData> regs;
public int size;
static GIFTag()
{
UnpackReg = new Dictionary<int, Unpack>();
UnpackReg.Add((int)GIFRegDescriptor.PRIM, GIFRegPRIM.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.RGBAQ, GIFRegRGBAQ.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.ST, GIFRegST.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.UV, GIFRegUV.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.XYZF2, GIFRegXYZF.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.XYZ2, GIFRegXYZF.UnpackXYZ);
UnpackReg.Add((int)GIFRegDescriptor.TEX0_1, GIFRegTEX0.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEX0_2, GIFRegTEX0.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.CLAMP_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.CLAMP_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FOG, GIFRegFOG.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.XYZF3, GIFRegXYZF.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.XYZ3, GIFRegXYZF.UnpackXYZ);
UnpackReg.Add((int)GIFRegDescriptor.AD, GIFRegAD.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEX1_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEX1_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEX2_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEX2_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.XYOFFSET_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.XYOFFSET_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.PRMODECONT, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.PRMODE, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEXCLUT, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.SCANMSK, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.MIPTBP1_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.MIPTBP1_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.MIPTBP2_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.MIPTBP2_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEXA, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FOGCOL, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEXFLUSH, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.SCISSOR_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.SCISSOR_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.ALPHA_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.ALPHA_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.DIMX, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.DTHE, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.COLCLAMP, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEST_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TEST_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.PABE, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FBA_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FBA_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FRAME_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FRAME_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.ZBUF_1, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.ZBUF_2, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.BITBLTBUF, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TRXPOS, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TRXREG, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.TRXDIR, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.HWREG, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.SIGNAL, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.FINISH, GIFRegUnimpl.Unpack);
UnpackReg.Add((int)GIFRegDescriptor.LABEL, GIFRegUnimpl.Unpack);
}
public static Unpack GetUnpack(int reg)
{
Unpack ret;
if (!UnpackReg.TryGetValue(reg, out ret))
return GIFRegNOP.Unpack;
return ret;
}
static internal GIFTag ExtractGifTag(byte[] data, GSTransferPath path)
{
GIFTag t = new GIFTag();
t.size = data.Length;
t.path = path;
t.TAG = BitConverter.ToUInt64(data, 0);
t.REGS = BitConverter.ToUInt64(data, 8);
t.Q = 1f;
t.nloop = (uint)GetBit(t.TAG, 0, 15);
t.eop = (uint)GetBit(t.TAG, 15, 1);
t.pre = (uint)GetBit(t.TAG, 46, 1);
t.prim = GIFPrim.ExtractGIFPrim((uint)GetBit(t.TAG, 47, 11));
t.flg = (GIFFLG)GetBit(t.TAG, 58, 2);
t.nreg = (uint)GetBit(t.TAG, 60, 4);
if (t.nreg == 0)
t.nreg = 16;
byte[] registers = new byte[t.nreg];
Unpack[] regsunpack = new Unpack[t.nreg];
t.regs = new List<IGifData>();
for (byte i = 0; i < t.nreg; i++)
{
byte reg = (byte)GetBit(t.REGS, i * 4, 4);
registers[i] = reg;
regsunpack[i] = GetUnpack(reg);
}
int p = 16;
switch (t.flg)
{
case GIFFLG.GIF_FLG_PACKED:
for (int j = 0; j < t.nloop; j++)
for (int i = 0; i < t.nreg; i++)
{
UInt64 LowData = BitConverter.ToUInt64(data, p);
UInt64 HighData = BitConverter.ToUInt64(data, p + 8);
t.regs.Add(regsunpack[i](t, registers[i], LowData, HighData, true));
p += 16;
}
break;
case GIFFLG.GIF_FLG_REGLIST:
for (int j = 0; j < t.nloop; j++)
for (int i = 0; i < t.nreg; i++)
{
UInt64 Data = BitConverter.ToUInt64(data, p);
t.regs.Add(regsunpack[i](t, registers[i], Data, 0, false));
p += 8;
}
break;
case GIFFLG.GIF_FLG_IMAGE:
case GIFFLG.GIF_FLG_IMAGE2:
GifImage image = new GifImage();
image.Data = new byte[t.nloop * 16];
try
{
Array.Copy(data, 16, image.Data, 0, t.nloop * 16);
}
catch (ArgumentException) { }
t.regs.Add(image);
break;
default:
break;
}
return t;
}
}
public enum GIFFLG
{
GIF_FLG_PACKED =0,
GIF_FLG_REGLIST =1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
}
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
namespace GSDumpGUI
{
[Serializable]
public class GIFUtil
{
public static UInt64 GetBit(UInt64 value, int lower, int count)
{
return (value >> lower) & (ulong)((1ul << count) - 1);
}
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GSData
{
public GSType id;
public byte[] data;
}
public enum GSType
{
Transfer = 0,
VSync = 1,
ReadFIFO2 = 2,
Registers = 3
}
}

View File

@ -1,42 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GSTransfer : GSData
{
public GSTransferPath Path;
}
public enum GSTransferPath
{
Path1Old = 0,
Path2 = 1,
Path3 = 2,
Path1New = 3
}
}

View File

@ -1,156 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace GSDumpGUI
{
public class GSDump
{
public Int32 CRC;
public byte[] GSFreeze;
public byte[] StateData;
public byte[] Registers; // 8192 bytes
public int Size
{
get
{
int size = 0;
size = 4;
size += StateData.Length;
size += Registers.Length;
foreach (var itm in Data)
{
size += itm.data.Length;
}
return size;
}
}
public List<GSData> Data;
public GSDump()
{
Data = new List<GSData>();
}
public GSDump Clone()
{
GSDump newDump = new GSDump();
newDump.CRC = this.CRC;
byte[] state = new byte[StateData.Length];
Array.Copy(StateData,state, StateData.Length);
newDump.StateData = state;
newDump.Registers = new byte[8192];
Array.Copy(this.Registers, newDump.Registers, 8192);
foreach (var itm in this.Data)
{
if (itm.GetType().IsInstanceOfType(typeof(GSTransfer)))
{
GSTransfer gt = new GSTransfer();
gt.id = itm.id;
gt.Path = ((GSTransfer)itm).Path;
gt.data = new byte[itm.data.Length];
Array.Copy(itm.data, gt.data, itm.data.Length);
newDump.Data.Add(gt);
}
else
{
GSData gt = new GSData();
gt.id = itm.id;
gt.data = new byte[itm.data.Length];
Array.Copy(itm.data, gt.data, itm.data.Length);
newDump.Data.Add(gt);
}
}
return newDump;
}
static public GSDump LoadDump(String FileName)
{
GSDump dmp = new GSDump();
BinaryReader br = new BinaryReader(System.IO.File.Open(FileName, FileMode.Open));
dmp.CRC = br.ReadInt32();
Int32 ss = br.ReadInt32();
dmp.StateData = br.ReadBytes(ss);
dmp.Registers = br.ReadBytes(8192);
while (br.PeekChar() != -1)
{
GSType id = (GSType)br.ReadByte();
switch (id)
{
case GSType.Transfer:
GSTransfer data = new GSTransfer();
byte index = br.ReadByte();
data.id = id;
data.Path = (GSTransferPath)index;
Int32 size = br.ReadInt32();
List<byte> Data = new List<byte>();
Data.AddRange(br.ReadBytes(size));
data.data = Data.ToArray();
dmp.Data.Add(data);
break;
case GSType.VSync:
GSData dataV = new GSData();
dataV.id = id;
dataV.data = br.ReadBytes(1);
dmp.Data.Add(dataV);
break;
case GSType.ReadFIFO2:
GSData dataR = new GSData();
dataR.id = id;
Int32 sF = br.ReadInt32();
dataR.data = BitConverter.GetBytes(sF);
dmp.Data.Add(dataR);
break;
case GSType.Registers:
GSData dataRR = new GSData();
dataRR.id = id;
dataRR.data = br.ReadBytes(8192);
dmp.Data.Add(dataRR);
break;
default:
break;
}
}
br.Close();
return dmp;
}
}
}

View File

@ -1,108 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Runtime.InteropServices;
using System.Drawing;
namespace GSDumpGUI
{
static public class NativeMethods
{
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
public extern static IntPtr LoadLibrary(string lpLibFileName);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public extern static bool FreeLibrary(IntPtr hLibModule);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public extern static IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32")]
public extern static UInt32 SetErrorMode(UInt32 uMode);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32")]
public extern static UInt32 GetLastError();
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public extern static bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32")]
public extern static UInt16 GetAsyncKeyState(Int32 vKey);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32", CharSet = CharSet.Auto, EntryPoint = "SetClassLong")]
public extern static UInt32 SetClassLong32(IntPtr hWnd, Int32 index, Int32 dwNewLong);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32", CharSet = CharSet.Auto, EntryPoint = "SetClassLongPtr")]
public extern static UIntPtr SetClassLong64(IntPtr hWnd, Int32 index, IntPtr dwNewLong);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32")]
public extern static bool IsWindowVisible(IntPtr hWnd);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PeekMessage(out NativeMessage lpMsg, IntPtr hWnd, UInt32 wMsgFilterMin, UInt32 wMsgFilterMax, UInt32 wRemoveMsg);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TranslateMessage(ref NativeMessage lpMsg);
[SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern UInt32 DispatchMessage(ref NativeMessage lpMsg);
public static UIntPtr SetClassLong(IntPtr hWnd, Int32 index, IntPtr dwNewLong)
{
if (Environment.Is64BitProcess) return SetClassLong64(hWnd, index, dwNewLong);
else return new UIntPtr(SetClassLong32(hWnd, index, dwNewLong.ToInt32()));
}
}
[StructLayout(LayoutKind.Sequential)]
public struct NativeMessage
{
public IntPtr hWnd;
public uint msg;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public Point p;
}
}

View File

@ -1,57 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace TCPLibrary.Core
{
/// <summary>
/// Class for containing information regarding the acceptance of a determinate situation.
/// </summary>
public class CancelArgs
{
/// <summary>
/// Whether the operation should be cancelled.
/// </summary>
private Boolean _cancel;
/// <summary>
/// Get/set the flag that determines if the operation should be cancelled.
/// </summary>
public Boolean Cancel
{
get { return _cancel; }
set { _cancel = value; }
}
/// <summary>
/// Base constructor of the class.
/// </summary>
/// <param name="cancel">Whether the operation should be cancelled.</param>
public CancelArgs(Boolean cancel)
{
this._cancel = cancel;
}
}
}

View File

@ -1,324 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using System.IO;
using System.ComponentModel;
using System.Text;
using System.Diagnostics;
namespace TCPLibrary.Core
{
/// <summary>
/// Base TCP client class wrapped around TcpClient.
/// </summary>
public class Client
{
/// <summary>
/// Lock object to assure that certain operation over the socket class are executed
/// in an exclusive way.
/// </summary>
private Object _lock;
/// <summary>
/// Wrapper around the Network Stream of the socket. (Read-Only)
/// </summary>
private BinaryReader tr;
/// <summary>
/// Wrapper around the Network Stream of the socket. (Write-Only)
/// </summary>
private BinaryWriter tw;
/// <summary>
/// Address to which the client is connected.
/// </summary>
private IPEndPoint _address;
/// <summary>
/// Flag to permit thread exit from the external.
/// </summary>
protected Boolean _active;
/// <summary>
/// Socket maintaining the connection.
/// </summary>
protected TcpClient _socket;
/// <summary>
/// Get/set the address to which the client is connected.
/// </summary>
public IPEndPoint Address
{
get { return _address; }
}
/// <summary>
/// Get the state of the connection.
/// </summary>
public Boolean Connected
{
get { return _socket != null; }
}
/// <summary>
/// Delegate for the event of receiving/sending a line of data from/to the server.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Data">Line of data received.</param>
public delegate void DataCommunicationHandler(Client sender, Data Data);
/// <summary>
/// Occurs when a line of data is received from the server.
/// </summary>
public event DataCommunicationHandler OnDataReceived;
/// <summary>
/// Occurs before the client send a line of data to the server.
/// </summary>
public event DataCommunicationHandler OnBeforeDataSent;
/// <summary>
/// Occurs after the client send a line of data to the server.
/// </summary>
public event DataCommunicationHandler OnAfterDataSent;
/// <summary>
/// Delegate for the event of connection/disconnection to the server.
/// </summary>
/// <param name="sender">Sender of the event.</param>
public delegate void ConnectionStateHandler(Client sender);
/// <summary>
/// Occurs when the client successfully connect the server.
/// </summary>
public event ConnectionStateHandler OnConnected;
/// <summary>
/// Occurs when the client is disconnected from the server.
/// </summary>
public event ConnectionStateHandler OnDisconnected;
/// <summary>
/// Delegate for the event of connection failed for rejection by the server.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Message">Message of fail sent by the server.</param>
public delegate void ConnectionFailedHandler(Client sender, byte[] Message);
/// <summary>
/// Occurs when the client failed to connect to the server because the server rejected the connection.
/// </summary>
public event ConnectionFailedHandler OnConnectFailed;
/// <summary>
/// Base constructor of the class.
/// </summary>
public Client()
{
_lock = new object();
_address = null;
}
/// <summary>
/// Try to connect to the server specified.
/// </summary>
/// <param name="Indirizzo">Address of the server to connect.</param>
/// <param name="Port">Port of the server to connect.</param>
/// <returns>True if the connection is successfull, false otherwise.</returns>
/// <exception cref="TCPLibrary.Core.AlreadyConnectedException" />
/// <exception cref="System.Net.Sockets.SocketException" />
public virtual Boolean Connect(String Indirizzo, Int32 Port)
{
if (!Connected)
{
IPHostEntry addr = Dns.GetHostEntry(Indirizzo);
IPAddress ip = null;
foreach (var itm in addr.AddressList)
{
if (itm.AddressFamily == AddressFamily.InterNetwork)
{
ip = itm;
break;
}
}
if (ip != null)
{
_address = new IPEndPoint(ip, Port);
_socket = new TcpClient();
try
{
_socket.Connect(_address);
}
catch (SocketException)
{
_socket = null;
_address = null;
throw;
}
tr = new BinaryReader(_socket.GetStream());
tw = new BinaryWriter(_socket.GetStream());
// Receive the confirmation of the status of the connection to the server.
// Is CONNECTEDTCPSERVER if the connection is successfull, all other cases are wrong.
Int32 Length = Convert.ToInt32(tr.ReadInt32());
byte[] arr = new byte[Length];
tr.Read(arr, 0, Length);
ASCIIEncoding ae = new ASCIIEncoding();
String Accept = ae.GetString(arr, 0, arr.Length);
if (Accept == "CONNECTEDTCPSERVER")
{
_active = true;
Thread thd = new Thread(new ThreadStart(MainThread));
thd.IsBackground = true;
thd.Name = "Client connected to " + Indirizzo + ":" + Port.ToString();
thd.Start();
if (OnConnected != null)
OnConnected(this);
return true;
}
else
{
Stop();
if (OnConnectFailed != null)
OnConnectFailed(this, arr);
return false;
}
}
else
return false;
}
else
throw new ArgumentException("The client is already connected!");
}
/// <summary>
/// Disconnect a Client if connected.
/// </summary>
public virtual void Disconnect()
{
lock (_lock)
{
_active = false;
tr.Close();
tw.Close();
}
}
/// <summary>
/// Disconnect a Client if connected.
/// </summary>
protected virtual void Stop()
{
if (_socket != null)
{
tr.Close();
tw.Close();
_socket.Close();
_socket = null;
_address = null;
if (OnDisconnected != null)
OnDisconnected(this);
}
}
/// <summary>
/// Thread function that actually run the socket work.
/// </summary>
private void MainThread()
{
while (_active)
{
byte[] arr = null;
try
{
int length = Convert.ToInt32(tr.ReadInt32());
arr = new byte[length];
int index = 0;
while (length > 0)
{
int receivedBytes = tr.Read(arr, index, length);
length -= receivedBytes;
index += receivedBytes;
}
}
catch (Exception) { }
lock (_lock)
{
if (_active)
{
Boolean Stato = _socket.Client.Poll(100, SelectMode.SelectRead);
if ((arr == null) && (Stato == true))
break;
else
if (OnDataReceived != null)
OnDataReceived(this, new Data(arr));
}
else
break;
}
}
Stop();
}
/// <summary>
/// Send a line of data to the server.
/// </summary>
/// <param name="msg">Data to send to the server.</param>
/// <exception cref="TCPLibrary.Core.NotConnectedException" />
public void Send(Data msg)
{
if (_active)
{
if (OnBeforeDataSent != null)
OnBeforeDataSent(this, msg);
try
{
tw.Write(msg.Message.Length);
tw.Write(msg.Message);
tw.Flush();
if (OnAfterDataSent != null)
OnAfterDataSent(this, msg);
}
catch (IOException)
{
// Pensare a cosa fare quà. Questo è il caso in cui il server ha chiuso forzatamente
// la connessione mentre il client mandava roba.
}
}
else
throw new ArgumentException("The link is closed. Unable to send data.");
}
}
}

View File

@ -1,227 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Diagnostics;
namespace TCPLibrary.Core
{
/// <summary>
/// Base class that manages the single connection between a client and the server.
/// </summary>
public class ClientS
{
/// <summary>
/// Lock object to assure that certain operation over the socket class are executed
/// in an exclusive way.
/// </summary>
private Object _lock;
/// <summary>
/// Wrapper around the Network Stream of the socket. (Read-Only)
/// </summary>
private BinaryReader tr;
/// <summary>
/// Wrapper around the Network Stream of the socket. (Write-Only)
/// </summary>
private BinaryWriter tw;
/// <summary>
/// Current IP address of the client.
/// </summary>
private String _ipaddress;
/// <summary>
/// Flag to permit thread exit from the external.
/// </summary>
protected Boolean _active;
/// <summary>
/// Link to the server to which this client is connected.
/// </summary>
protected Server _server;
/// <summary>
/// Actual socket of the client.
/// </summary>
protected TcpClient _client;
/// <summary>
/// Get the state of the connection.
/// </summary>
public Boolean Connected
{
get { return _client != null; }
}
/// <summary>
/// IP Address of the client.
/// </summary>
public String IPAddress
{
get { return _ipaddress; }
}
/// <summary>
/// Base class constructor.
/// </summary>
/// <param name="server">Server to which this client is linked to.</param>
/// <param name="client">Socket of the client.</param>
protected internal ClientS(Server server, TcpClient client)
{
_lock = new object();
_active = true;
_server = server;
_client = client;
_ipaddress = _client.Client.RemoteEndPoint.ToString();
NetworkStream ns = _client.GetStream();
tr = new BinaryReader(ns);
tw = new BinaryWriter(ns);
}
/// <summary>
/// Start up the thread managing this Client-Server connection.
/// </summary>
protected internal virtual void Start()
{
Thread _thread = new Thread(new ThreadStart(MainThread));
_thread.IsBackground = true;
_thread.Name = "Thread Client " + _ipaddress;
_thread.Start();
}
/// <summary>
/// Thread function that actually run the socket work.
/// </summary>
private void MainThread()
{
while (_active)
{
byte[] arr = null;
try
{
int length = Convert.ToInt32(tr.ReadInt32());
arr = new byte[length];
int index = 0;
while (length > 0)
{
int receivedBytes = tr.Read(arr, index, length);
length -= receivedBytes;
index += receivedBytes;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
lock (_lock)
{
if (_active)
{
Boolean Stato = _client.Client.Poll(100, SelectMode.SelectRead);
if ((arr == null) && (Stato == true))
break;
else
_server.RaiseDataReceivedEvent(this, new Data(arr));
}
else
break;
}
}
Stop();
}
/// <summary>
/// Send a line of data to the client.
/// </summary>
/// <param name="Data">Data to send to the client.</param>
/// <exception cref="TCPLibrary.Core.NotConnectedException" />
public void Send(Data Data)
{
if (_active)
{
_server.RaiseBeforeDataSentEvent(this, Data);
try
{
tw.Write(Data.Message.Length);
tw.Write(Data.Message);
tw.Flush();
_server.RaiseAfterDataSentEvent(this, Data);
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
// Pensare a cosa fare quà. Questo è il caso in cui il client ha chiuso forzatamente
// la connessione mentre il server mandava roba.
}
}
else
throw new ArgumentException("The link is closed. Unable to send data.");
}
/// <summary>
/// Close the link between Client e Server.
/// </summary>
public void Disconnect()
{
lock (_lock)
{
_active = false;
tr.Close();
tw.Close();
}
}
/// <summary>
/// Close the link between Client e Server.
/// </summary>
protected internal void Stop()
{
if (_client != null)
{
_server.RaiseClientBeforeDisconnectedEvent(this);
tr.Close();
tw.Close();
_client.Close();
_client = null;
lock (_server.Clients)
{
_server.Clients.Remove(this);
}
_server.RaiseClientAfterDisconnectedEvent(this);
}
}
}
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace TCPLibrary.Core
{
/// <summary>
/// Structure for containing the data to be sent over a base client/server
/// </summary>
public class Data
{
/// <summary>
/// Data to be sent.
/// </summary>
private byte[] _message;
/// <summary>
/// Get/set the data to be sent.
/// </summary>
public byte[] Message
{
get { return _message; }
set { _message = value; }
}
/// <summary>
/// Base constructor of the class.
/// </summary>
/// <param name="msg">Data to be sent.</param>
public Data(byte[] msg)
{
this._message = msg;
}
}
}

View File

@ -1,359 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.ComponentModel;
using System.Text;
namespace TCPLibrary.Core
{
/// <summary>
/// Base TCP server class wrapped around TcpListener.
/// </summary>
public class Server
{
/// <summary>
/// Socket maintaining the connection.
/// </summary>
private TcpListener _socket;
/// <summary>
/// Whether the server is enabled or not.
/// </summary>
private Boolean _enabled;
/// <summary>
/// List of the clients connected to the server.
/// </summary>
private List<ClientS> _clients;
/// <summary>
/// Number of connection permitted in the backlog of the server.
/// </summary>
private Int32 _connectionbacklog;
/// <summary>
/// Delegate for the event of the Enabled property change.
/// </summary>
/// <param name="sender">Sender of the event.</param>
public delegate void EnabledChangedHandler(Server sender);
/// <summary>
/// Occurs when the Enabled property is changed.
/// </summary>
public event EnabledChangedHandler OnEnabledChanged;
/// <summary>
/// Delegate for the event of receiving a line of data from a client.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="client">Client involved in the communication.</param>
/// <param name="Data">Line of data received.</param>
public delegate void DataCommunicationHandler(Server server, ClientS client, Data Data);
/// <summary>
/// Occurs when a client send a line of data to the server.
/// </summary>
public event DataCommunicationHandler OnClientDataReceived;
/// <summary>
/// Occurs before the server send a line of data to a client.
/// </summary>
public event DataCommunicationHandler OnClientBeforeDataSent;
/// <summary>
/// Occurs after the server send a line of data to a client.
/// </summary>
public event DataCommunicationHandler OnClientAfterDataSent;
/// <summary>
/// Delegate for the event of a connection of a client.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="sender">The new client connected.</param>
public delegate void ConnectedHandler(Server server, ClientS sender);
/// <summary>
/// Occurs after a client is connected to the server.
/// </summary>
public event ConnectedHandler OnClientAfterConnect;
/// <summary>
/// Delegate for the event of a connection of a client.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="client">The new client to be connected.</param>
/// <param name="args">Specify if the client should be accepted into the server.</param>
public delegate void BeforeConnectedHandler(Server server, ClientS client, CancelArgs args);
/// <summary>
/// Occurs before a client is allowed to connect to the server.
/// </summary>
public event BeforeConnectedHandler OnClientBeforeConnect;
/// <summary>
/// Delegate for the event of disconnection of a client.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="sender">The client disconnected.</param>
public delegate void DisconnectedHandler(Server server, ClientS sender);
/// <summary>
/// Occurs right after a client disconnect from the server.
/// </summary>
public event DisconnectedHandler OnClientAfterDisconnected;
/// <summary>
/// Occurs before a client disconnect from the server.
/// </summary>
public event DisconnectedHandler OnClientBeforeDisconnected;
/// <summary>
/// Get/set the port number to which the server will listen. Cannot be set while the server is active.
/// </summary>
/// <exception cref="TCPLibrary.Core.ServerAttivoException" />
public Int32 Port
{
get
{
if (Enabled)
return ((IPEndPoint) _socket.LocalEndpoint).Port;
throw new NotSupportedException("Server is not running and hence has no port.");
}
}
/// <summary>
/// Get/set the enabled state of the server. Setting this to true will actually activate the server.
/// </summary>
/// <exception cref="System.Net.Sockets.SocketException" />
public Boolean Enabled
{
get { return _enabled; }
set
{
if (value == true)
{
if (_enabled == false)
ActivateServer();
}
else
{
if (_enabled == true)
DeactivateServer();
}
}
}
/// <summary>
/// Get/set the number of connection permitted in the backlog of the server.
/// </summary>
/// <exception cref="TCPLibrary.Core.ServerAttivoException" />
public Int32 ConnectionBackLog
{
get { return _connectionbacklog; }
set
{
if (Enabled == false)
_connectionbacklog = value;
else
throw new ArgumentException("Impossibile eseguire l'operazione a server attivo");
}
}
/// <summary>
/// Get the list of the clients connected to the server.
/// </summary>
public List<ClientS> Clients
{
get { return _clients; }
}
/// <summary>
/// Deactivate the server.
/// </summary>
protected virtual void DeactivateServer()
{
_enabled = false;
_socket.Stop();
_socket = null;
lock (_clients)
{
for (int i = 0; i < _clients.Count; i++)
_clients[i].Disconnect();
}
if (OnEnabledChanged != null)
OnEnabledChanged(this);
}
/// <summary>
/// Activate the server.
/// </summary>
protected virtual void ActivateServer()
{
_socket = new TcpListener(IPAddress.Any, 0);
_socket.Start(ConnectionBackLog);
Thread thd = new Thread(new ThreadStart(MainThread));
thd.Name = "Server on port " + ((IPEndPoint) _socket.LocalEndpoint).Port;
thd.IsBackground = true;
thd.Start();
_enabled = true;
if (OnEnabledChanged != null)
OnEnabledChanged(this);
}
/// <summary>
/// Broadcast a line of data to all the clients connected to the server.
/// </summary>
/// <param name="Data">Line of data to be sent.</param>
/// <exception cref="TCPLibrary.Core.ServerNonAttivoException" />
public void Broadcast(Data Data)
{
if (Enabled)
{
lock (_clients)
{
foreach (var itm in _clients)
if (itm.Connected)
itm.Send(Data);
}
}
else
throw new ArgumentException("Unable to execute this operation when the server is inactive.");
}
/// <summary>
/// Base constructor of the class.
/// </summary>
public Server()
{
_clients = new List<ClientS>();
_connectionbacklog = 0;
_enabled = false;
}
/// <summary>
/// Thread function that actually run the server socket work.
/// </summary>
private void MainThread()
{
try
{
while (Enabled == true)
{
TcpClient client = _socket.AcceptTcpClient();
CancelArgs args = new CancelArgs(false);
ClientS cl = CreateClient(client);
if (OnClientBeforeConnect != null)
OnClientBeforeConnect(this, cl, args);
if (args.Cancel != true)
{
lock (_clients)
{
_clients.Add(cl);
}
ASCIIEncoding ae = new ASCIIEncoding();
byte[] arr = ae.GetBytes("CONNECTEDTCPSERVER");
cl.Send(new Data(arr));
if (OnClientAfterConnect != null)
OnClientAfterConnect(this, cl);
cl.Start();
}
else
{
client.GetStream().Close();
client.Close();
}
}
}
catch (SocketException)
{
Enabled = false;
}
}
/// <summary>
/// Overridable function that create the structure to memorize the client data.
/// </summary>
/// <param name="socket">Socket of the client.</param>
/// <returns>The structure in which memorize all the information of the client.</returns>
protected virtual ClientS CreateClient(TcpClient socket)
{
ClientS cl = new ClientS(this, socket);
return cl;
}
/// <summary>
/// Raise the OnClientAfterDataSent event.
/// </summary>
/// <param name="cl">Client that raised the event.</param>
/// <param name="data">Line of data sent.</param>
internal void RaiseAfterDataSentEvent(ClientS cl, Data data)
{
if (OnClientAfterDataSent != null)
OnClientAfterDataSent(this, cl, data);
}
/// <summary>
/// Raise the OnClientBeforeDataSent event.
/// </summary>
/// <param name="cl">Client that raised the event.</param>
/// <param name="data">Line of data sent.</param>
internal void RaiseBeforeDataSentEvent(ClientS cl, Data data)
{
if (OnClientBeforeDataSent != null)
OnClientBeforeDataSent(this, cl, data);
}
/// <summary>
/// Raise the OnDataReceived event.
/// </summary>
/// <param name="cl">Client that raised the event.</param>
/// <param name="data">Line of data received.</param>
internal void RaiseDataReceivedEvent(ClientS cl, Data data)
{
if (OnClientDataReceived != null)
OnClientDataReceived(this, cl, data);
}
/// <summary>
/// Raise the OnClientAfterDisconnected event.
/// </summary>
/// <param name="cl">Client that raised the event.</param>
internal void RaiseClientAfterDisconnectedEvent(ClientS cl)
{
if (OnClientAfterDisconnected != null)
OnClientAfterDisconnected(this, cl);
}
/// <summary>
/// Raise the OnClientBeforeDisconnected event.
/// </summary>
/// <param name="cl">Client that raised the event.</param>
internal void RaiseClientBeforeDisconnectedEvent(ClientS cl)
{
if (OnClientBeforeDisconnected != null)
OnClientBeforeDisconnected(this, cl);
}
}
}

View File

@ -1,137 +0,0 @@
/*
The MIT License
Copyright (c) 2008 Ferreri Alessio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using TCPLibrary.MessageBased.Core;
using TCPLibrary.Core;
using System;
namespace TCPLibrary.MessageBased.Core
{
/// <summary>
/// TCP Client Class that work with Message structures.
/// </summary>
public class BaseMessageClient : Client
{
/// <summary>
/// Delegate for the event of receiving a message structure from the server.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Mess">Message received.</param>
public delegate void MessageReceivedHandler(Client sender, TCPMessage Mess);
/// <summary>
/// Occurs when the client receive a message structure from the server.
/// </summary>
public event MessageReceivedHandler OnMessageReceived;
/// <summary>
/// Delegate for the event of sending a message structure to the server.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Mess">Message sent.</param>
public delegate void MessageSentHandler(Client sender, TCPMessage Mess);
/// <summary>
/// Occurs before the client send a message structure to the server.
/// </summary>
public event MessageSentHandler OnBeforeMessageSent;
/// <summary>
/// Occurs after the client send a message structure to the server.
/// </summary>
public event MessageSentHandler OnAfterMessageSent;
/// <summary>
/// Delegate for the event of connection fail for max users number reached.
/// </summary>
/// <param name="sender">Sender of the event.</param>
public delegate void MaxUsersReached(Client sender);
/// <summary>
/// Occurs when the connection fail as the server reached the maximum number of clients allowed.
/// </summary>
public event MaxUsersReached OnMaxUsersConnectionFail;
/// <summary>
/// Base constructor of the class.
/// </summary>
public BaseMessageClient()
{
OnDataReceived += new DataCommunicationHandler(BaseMessageClient_OnDataReceived);
OnAfterDataSent += new DataCommunicationHandler(BaseMessageClient_OnDataSent);
OnConnectFailed += new ConnectionFailedHandler(BaseMessageClient_OnConnectFailed);
}
/// <summary>
/// When the connection is rejected by the server raise the correct event.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Message">Message of the server.</param>
void BaseMessageClient_OnConnectFailed(Client sender, byte[] Message)
{
if (TCPLibrary.MessageBased.Core.TCPMessage.FromByteArray(Message).MessageType == MessageType.MaxUsers)
if (OnMaxUsersConnectionFail != null)
OnMaxUsersConnectionFail(sender);
}
/// <summary>
/// Parse the raw data sent to the server and create Message structures.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Data">Line of data sent.</param>
void BaseMessageClient_OnDataSent(Client sender, Data Data)
{
TCPMessage msg = TCPMessage.FromByteArray(Data.Message);
if (OnAfterMessageSent != null)
OnAfterMessageSent(sender, msg);
}
/// <summary>
/// Parse the raw data received from the server and create Message structures.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="Data">Line of data received.</param>
void BaseMessageClient_OnDataReceived(Client sender, Data Data)
{
TCPMessage msg = null;
try
{
msg = TCPMessage.FromByteArray(Data.Message);
}
catch (Exception)
{
}
if (msg != null)
if (OnMessageReceived != null)
OnMessageReceived(sender, msg);
}
/// <summary>
/// Send a message structure to the server.
/// </summary>
/// <param name="msg">Message structure to be send.</param>
/// <exception cref="TCPLibrary.Core.NotConnectedException"></exception>
public void Send(TCPMessage msg)
{
if (OnBeforeMessageSent != null)
OnBeforeMessageSent(this, msg);
base.Send(new Data(msg.ToByteArray()));
}
}
}

View File

@ -1,59 +0,0 @@
/*
The MIT License
Copyright (c) 2008 Ferreri Alessio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System.Net.Sockets;
using TCPLibrary.Core;
using TCPLibrary.MessageBased.Core;
namespace TCPLibrary.MessageBased.Core
{
/// <summary>
/// Class that manages the single connection between a client and the server based
/// on Message structures.
/// </summary>
public class BaseMessageClientS : ClientS
{
/// <summary>
/// Base constructor of the class.
/// </summary>
/// <param name="server">Server to which this client is linked to.</param>
/// <param name="client">Socket of the client.</param>
protected internal BaseMessageClientS(Server server, TcpClient client)
: base(server, client)
{
}
/// <summary>
/// Send a Message structure to the client.
/// </summary>
/// <param name="msg">Message to be sent.</param>
/// <exception cref="TCPLibrary.Core.NotConnectedException" />
public void Send(TCPMessage msg)
{
((BaseMessageServer)_server).RaiseBeforeMessageSentEvent(this, msg);
base.Send(new Data(msg.ToByteArray()));
}
}
}

View File

@ -1,186 +0,0 @@
/*
The MIT License
Copyright (c) 2008 Ferreri Alessio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using TCPLibrary.MessageBased.Core;
using System.Net.Sockets;
using System.Threading;
using TCPLibrary.Core;
namespace TCPLibrary.MessageBased.Core
{
/// <summary>
/// TCP Server Class that work with Message structures.
/// </summary>
public class BaseMessageServer : Server
{
/// <summary>
/// Limit of user allowed inside the server.
/// </summary>
protected Int32 _userlimit;
/// <summary>
/// Delegate for the event of receiving a Message from a client.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="sender">Client sending the message.</param>
/// <param name="Mess">Message received.</param>
public delegate void MessageReceivedHandler(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess);
/// <summary>
/// Occurs when a Message is received by the server.
/// </summary>
public event MessageReceivedHandler OnClientMessageReceived;
/// <summary>
/// Delegate for the event of sending a Message to a client.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="receiver">Client that will receive the message.</param>
/// <param name="Mess">Message to be sent.</param>
public delegate void MessageSentHandler(BaseMessageServer server, BaseMessageClientS receiver, TCPMessage Mess);
/// <summary>
/// Occurs when the server send a Message to a client.
/// </summary>
public event MessageSentHandler OnClientBeforeMessageSent;
/// <summary>
/// Occurs when the server send a Message to a client.
/// </summary>
public event MessageSentHandler OnClientAfterMessageSent;
/// <summary>
/// Get/set the limit of users allowed inside the server.
/// </summary>
public Int32 UserLimit
{
get { return _userlimit; }
set { _userlimit = value; }
}
/// <summary>
/// Base constructor of the class.
/// </summary>
public BaseMessageServer() : base()
{
OnClientBeforeConnect += new BeforeConnectedHandler(BaseMessageServer_OnClientBeforeConnect);
OnClientDataReceived += new DataCommunicationHandler(BaseMessageServer_OnDataReceived);
OnClientAfterDataSent += new DataCommunicationHandler(BaseMessageServer_OnDataSent);
_userlimit = 0;
}
/// <summary>
/// Kick the client if the server reached the maximum allowed number of clients.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="client">Client connecting to the server.</param>
/// <param name="args">Specify if the client should be accepted into the server.</param>
void BaseMessageServer_OnClientBeforeConnect(Server server, ClientS client, CancelArgs args)
{
if ((Clients.Count >= UserLimit) && (UserLimit != 0))
{
TCPMessage msg = new TCPMessage();
msg.MessageType = MessageType.MaxUsers;
((BaseMessageClientS)client).Send(msg);
args.Cancel = true;
}
}
/// <summary>
/// Trasform the line of data sent into a Message structure and raise
/// the event linked.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="receiver">Client that will receive the Message.</param>
/// <param name="Data">Line of data sent.</param>
void BaseMessageServer_OnDataSent(Server server, ClientS receiver, Data Data)
{
TCPMessage msg = null;
try
{
msg = TCPMessage.FromByteArray(Data.Message);
}
catch (Exception)
{
}
if (msg != null)
if (OnClientAfterMessageSent != null)
OnClientAfterMessageSent(this, (BaseMessageClientS)receiver, msg);
}
/// <summary>
/// Raise the OnClientBeforeMessageSent event.
/// </summary>
/// <param name="cl">Client that raised the event.</param>
/// <param name="msg">Message to be sent.</param>
internal void RaiseBeforeMessageSentEvent(ClientS cl, TCPMessage msg)
{
if (OnClientBeforeMessageSent != null)
OnClientBeforeMessageSent(this, (BaseMessageClientS)cl, msg);
}
/// <summary>
/// Trasform the line of data received into a Message structure and raise
/// the event linked.
/// </summary>
/// <param name="server">Server raising the event.</param>
/// <param name="sender">Client sending the data.</param>
/// <param name="Data">Line of data received.</param>
void BaseMessageServer_OnDataReceived(Server server, ClientS sender, Data Data)
{
TCPMessage msg = null;
try
{
msg = TCPMessage.FromByteArray(Data.Message);
}
catch (Exception)
{
}
if (msg != null)
if (OnClientMessageReceived != null)
OnClientMessageReceived(this, (BaseMessageClientS)sender, msg);
}
/// <summary>
/// Function that create the structure to memorize the client data.
/// </summary>
/// <param name="socket">Socket of the client.</param>
/// <returns>The structure in which memorize all the information of the client.</returns>
protected override ClientS CreateClient(TcpClient socket)
{
return new BaseMessageClientS(this, socket);
}
/// <summary>
/// Send a message to all clients in broadcast.
/// </summary>
/// <param name="Data">Message to be sent.</param>
public void Broadcast(TCPMessage Data)
{
base.Broadcast(new Data(Data.ToByteArray()));
}
}
}

View File

@ -1,125 +0,0 @@
/*
The MIT License
Copyright (c) 2008 Ferreri Alessio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace TCPLibrary.MessageBased.Core
{
/// <summary>
/// Message structure that contains all the information of the message exchanged between
/// Message driven server/client.
/// </summary>
[Serializable]
public class TCPMessage
{
/// <summary>
/// Message Type.
/// </summary>
private MessageType _messageType;
/// <summary>
/// Messages parameters.
/// </summary>
private List<object> _parameters;
/// <summary>
/// Get/set the message type.
/// </summary>
public MessageType MessageType
{
get { return _messageType; }
set { _messageType = value; }
}
/// <summary>
/// Get/set the message parameters.
/// </summary>
public List<object> Parameters
{
get { return _parameters; }
}
/// <summary>
/// Base constructor of the class.
/// </summary>
public TCPMessage()
{
_messageType = MessageType.Connect;
_parameters = new List<object>();
}
/// <summary>
/// Parse a string and create a Message structure.
/// </summary>
/// <param name="data">Raw data.</param>
/// <returns>Parsed message structure.</returns>
static public TCPMessage FromByteArray(byte[] data)
{
MemoryStream ms = new MemoryStream();
BinaryWriter sw = new BinaryWriter(ms);
sw.Write(data, 0, data.Length);
sw.Flush();
ms.Position = 0;
BinaryFormatter formatter = new BinaryFormatter();
TCPMessage msg = formatter.Deserialize(ms) as TCPMessage;
return msg;
}
/// <summary>
/// Trasform the structure into a String.
/// </summary>
/// <returns>The structure in a String format.</returns>
public byte[] ToByteArray()
{
MemoryStream ms = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms, this);
ms.Position = 0;
return ms.ToArray();
}
}
public enum MessageType
{
Connect,
MaxUsers,
SizeDump,
Statistics,
StateOld,
GetDebugMode,
SetDebugMode,
DebugState,
PacketInfo,
Step,
RunToCursor,
RunToNextVSync
}
}

View File

@ -1,59 +0,0 @@
/*
* Copyright (C) 2009-2011 Ferreri Alessio
* Copyright (C) 2009-2018 PCSX2 Dev Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GSDumpGUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("PCSX2 Team")]
[assembly: AssemblyProduct("GSDumpGUI")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ff0f400c-a2cc-4d81-be4a-43c53eed5025")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,73 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GSDumpGUI.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GSDumpGUI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon AppIcon {
get {
object obj = ResourceManager.GetObject("AppIcon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AppIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\AppIcon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -1,50 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GSDumpGUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string GSDXDir {
get {
return ((string)(this["GSDXDir"]));
}
set {
this["GSDXDir"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string DumpDir {
get {
return ((string)(this["DumpDir"]));
}
set {
this["DumpDir"] = value;
}
}
}
}

View File

@ -1,12 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="GSDumpGUI.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="GSDXDir" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="DumpDir" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

View File

@ -1,18 +0,0 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="GSDumpGUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<userSettings>
<GSDumpGUI.Properties.Settings>
<setting name="GSDXDir" serializeAs="String">
<value/>
</setting>
<setting name="DumpDir" serializeAs="String">
<value/>
</setting>
</GSDumpGUI.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>