GSDumpGUI: Minor improvements.

Loop changes, icon and info shows up, can take screenshot.
This commit is contained in:
KrossX 2019-07-28 22:24:39 -03:00 committed by lightningterror
parent 66487b18e3
commit 003046c91c
2 changed files with 89 additions and 105 deletions

View File

@ -43,17 +43,19 @@ namespace GSDumpGUI
static public List<TCPLibrary.MessageBased.Core.BaseMessageClientS> Clients; static public List<TCPLibrary.MessageBased.Core.BaseMessageClientS> Clients;
static public TCPLibrary.MessageBased.Core.BaseMessageClient Client; static public TCPLibrary.MessageBased.Core.BaseMessageClient Client;
static private Boolean ChangeIcon;
static private GSDump dump; static private GSDump dump;
static private GSDXWrapper wrap; static private GSDXWrapper wrap;
static private TreeNode CurrentNode; static private TreeNode CurrentNode;
static public IntPtr hMainIcon;
[STAThread] [STAThread]
static void Main(String[] args) static void Main(String[] args)
{ {
if (args.Length == 5) if (args.Length == 5)
{ {
hMainIcon = Resources.AppIcon.Handle;
// do this first, else racy mess ;) // do this first, else racy mess ;)
wrap = new GSDXWrapper(); wrap = new GSDXWrapper();
var port = Convert.ToInt32(args[4]); var port = Convert.ToInt32(args[4]);
@ -69,29 +71,6 @@ namespace GSDumpGUI
Client = null; Client = null;
} }
Thread thd = new Thread(new ThreadStart(delegate
{
while (true)
{
IntPtr pt = Process.GetCurrentProcess().MainWindowHandle;
if (ChangeIcon)
{
if (pt.ToInt64() != 0)
{
NativeMethods.SetClassLong(pt, -14, Resources.AppIcon.Handle.ToInt64());
ChangeIcon = false;
}
}
Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf;
if (tmp != 0)
Process.GetCurrentProcess().Kill();
Thread.Sleep(16);
}
}));
thd.IsBackground = true;
thd.Start();
// Retrieve parameters // Retrieve parameters
String DLLPath = args[0]; String DLLPath = args[0];
String DumpPath = args[1]; String DumpPath = args[1];
@ -111,7 +90,6 @@ namespace GSDumpGUI
} }
wrap.Run(dump, Renderer); wrap.Run(dump, Renderer);
ChangeIcon = true;
} }
else else
wrap.GSConfig(); wrap.GSConfig();

View File

@ -39,14 +39,15 @@ namespace GSDumpGUI
public delegate void GSreset(); public delegate void GSreset();
public delegate void GSreadFIFO2(IntPtr data, int size); public delegate void GSreadFIFO2(IntPtr data, int size);
public delegate void GSsetGameCRC(int crc, int options); public delegate void GSsetGameCRC(int crc, int options);
public delegate int GSfreeze(int mode, IntPtr data); public delegate int GSfreeze(int mode, IntPtr data);
public delegate void GSopen(IntPtr hwnd, String Title, int renderer); public delegate int GSopen(IntPtr hwnd, String Title, int renderer);
public delegate void GSclose(); public delegate void GSclose();
public delegate void GSshutdown(); public delegate void GSshutdown();
public delegate void GSConfigure(); public delegate void GSConfigure();
public delegate void GSsetBaseMem(IntPtr data); public delegate void GSsetBaseMem(IntPtr data);
public delegate IntPtr PSEgetLibName(); public delegate IntPtr PSEgetLibName();
public delegate void GSinit(); public delegate void GSinit();
public delegate UInt32 GSmakeSnapshot(string path);
public class InvalidGSPlugin : Exception public class InvalidGSPlugin : Exception
{ {
@ -73,7 +74,7 @@ namespace GSDumpGUI
private GSsetBaseMem GSsetBaseMem; private GSsetBaseMem GSsetBaseMem;
private GSinit GSinit; private GSinit GSinit;
private GSreset GSreset; private GSreset GSreset;
private GSmakeSnapshot GSmakeSnapshot;
private Boolean Loaded; private Boolean Loaded;
private String DLL; private String DLL;
@ -128,6 +129,7 @@ namespace GSDumpGUI
IntPtr funcaddrFreeze = NativeMethods.GetProcAddress(hmod, "GSfreeze"); IntPtr funcaddrFreeze = NativeMethods.GetProcAddress(hmod, "GSfreeze");
IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2"); IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2");
IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit");
IntPtr funcmakeSnapshot = NativeMethods.GetProcAddress(hmod, "GSmakeSnapshot");
if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrGIF.ToInt64() > 0))) if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrGIF.ToInt64() > 0)))
{ {
@ -151,6 +153,7 @@ namespace GSDumpGUI
this.GSreset = (GSreset) Marshal.GetDelegateForFunctionPointer(funcaddrGSReset, typeof(GSreset)); this.GSreset = (GSreset) Marshal.GetDelegateForFunctionPointer(funcaddrGSReset, typeof(GSreset));
this.GSreadFIFO2 = (GSreadFIFO2) Marshal.GetDelegateForFunctionPointer(funcaddrGSreadFIFO2, typeof(GSreadFIFO2)); this.GSreadFIFO2 = (GSreadFIFO2) Marshal.GetDelegateForFunctionPointer(funcaddrGSreadFIFO2, typeof(GSreadFIFO2));
this.GSinit = (GSinit) Marshal.GetDelegateForFunctionPointer(funcaddrinit, typeof(GSinit)); this.GSinit = (GSinit) Marshal.GetDelegateForFunctionPointer(funcaddrinit, typeof(GSinit));
this.GSmakeSnapshot = (GSmakeSnapshot)Marshal.GetDelegateForFunctionPointer(funcmakeSnapshot, typeof(GSmakeSnapshot));
Loaded = true; Loaded = true;
} }
@ -205,10 +208,15 @@ namespace GSDumpGUI
fixed (byte* pointer = tempregisters) fixed (byte* pointer = tempregisters)
{ {
GSsetBaseMem(new IntPtr(pointer)); GSsetBaseMem(new IntPtr(pointer));
Int32 HWND = 0; IntPtr hWnd = IntPtr.Zero;
GSopen(new IntPtr(&HWND), "", rendererOverride);
if (GSopen(new IntPtr(&hWnd), "", rendererOverride) != 0)
return;
GSsetGameCRC(dump.CRC, 0); GSsetGameCRC(dump.CRC, 0);
NativeMethods.SetClassLong(hWnd,/*GCL_HICON*/ -14, Program.hMainIcon.ToInt32());
fixed (byte* freeze = dump.StateData) fixed (byte* freeze = dump.StateData)
{ {
byte[] GSFreez = new byte[8]; byte[] GSFreez = new byte[8];
@ -225,95 +233,93 @@ namespace GSDumpGUI
} }
GSVSync(1); GSVSync(1);
GSreset();
Marshal.Copy(dump.Registers, 0, new IntPtr(pointer), 8192);
GSsetBaseMem(new IntPtr(pointer));
GSfreeze(0, new IntPtr(fr));
int gs_idx = 0;
int debug_idx = 0;
NativeMessage msg;
while (Running) while (Running)
{ {
if (!NativeMethods.IsWindowVisible(new IntPtr(HWND))) while (NativeMethods.PeekMessage(out msg, hWnd, 0, 0, 1)) // PM_REMOVE
{ {
Running = false; NativeMethods.TranslateMessage(ref msg);
break; 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;
}
}
} }
GSreset(); if (!Running)
Marshal.Copy(dump.Registers, 0, new IntPtr(pointer), 8192); break;
GSsetBaseMem(new IntPtr(pointer));
GSfreeze(0, new IntPtr(fr));
for (int i = 0; i < dump.Data.Count; i++) if (DebugMode)
{ {
GSData itm = dump.Data[i]; if (QueueMessage.Count > 0)
CurrentGIFPacket = itm;
if (DebugMode)
{ {
if (RunTo != -1) TCPMessage Mess = QueueMessage.Dequeue();
switch (Mess.MessageType)
{ {
if (i == RunTo) case MessageType.Step:
{ if (debug_idx >= dump.Data.Count) debug_idx = 0;
RunTo = -1; RunTo = debug_idx;
int idxnextReg = dump.Data.FindIndex(i, a => a.id == GSType.Registers); break;
if (idxnextReg != -1) case MessageType.RunToCursor:
{ RunTo = (int)Mess.Parameters[0];
Step(dump.Data[idxnextReg], pointer); if(debug_idx > RunTo) debug_idx = 0;
} break;
case MessageType.RunToNextVSync:
GSData g = new GSData(); if (debug_idx >= dump.Data.Count) debug_idx = 1;
g.id = GSType.VSync; RunTo = dump.Data.FindIndex(debug_idx, a => a.id == GSType.VSync);
Step(g, pointer); break;
default:
TCPMessage Msg = new TCPMessage();
Msg.MessageType = MessageType.RunToCursor;
Msg.Parameters.Add(i);
Program.Client.Send(Msg);
ExternalEvent.Set();
}
else
{
Step(itm, pointer);
}
}
else
{
while (!ThereIsWork && Running)
{
NativeMessage message;
while (NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 1))
{
if (!NativeMethods.IsWindowVisible(new IntPtr(HWND)))
{
Running = false;
}
NativeMethods.TranslateMessage(ref message);
NativeMethods.DispatchMessage(ref message);
}
}
ThereIsWork = false;
if (QueueMessage.Count > 0)
{
TCPMessage Mess = QueueMessage.Dequeue();
switch (Mess.MessageType)
{
case MessageType.Step:
RunTo = i;
break;
case MessageType.RunToCursor:
RunTo = (int)Mess.Parameters[0];
break;
case MessageType.RunToNextVSync:
RunTo = dump.Data.FindIndex(i, a => a.id == GSType.VSync);
break;
default:
break;
}
break; break;
}
} }
} }
else
if (debug_idx <= RunTo)
{ {
Step(itm, pointer); 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();
} }
GSData g = new GSData();
g.id = GSType.VSync;
Step(g, pointer);
}
else
{
GSData itm = dump.Data[gs_idx++];
CurrentGIFPacket = itm;
Step(itm, pointer);
if (gs_idx >= dump.Data.Count) gs_idx = 0;
} }
} }