2010-12-19 14:41:11 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace GSDumpGUI
|
|
|
|
|
{
|
|
|
|
|
public class GSDump
|
|
|
|
|
{
|
|
|
|
|
public Int32 CRC;
|
2010-12-21 07:29:33 +00:00
|
|
|
|
public byte[] GSFreeze;
|
2010-12-19 14:41:11 +00:00
|
|
|
|
public byte[] StateData;
|
|
|
|
|
public byte[] Registers; // 8192 bytes
|
|
|
|
|
|
2010-12-19 15:55:52 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-19 14:41:11 +00:00
|
|
|
|
public List<GSData> Data;
|
|
|
|
|
|
|
|
|
|
public GSDump()
|
|
|
|
|
{
|
|
|
|
|
Data = new List<GSData>();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-21 07:29:33 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-19 14:41:11 +00:00
|
|
|
|
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();
|
2010-12-21 07:29:33 +00:00
|
|
|
|
|
2010-12-19 14:41:11 +00:00
|
|
|
|
Int32 ss = br.ReadInt32();
|
2010-12-21 07:29:33 +00:00
|
|
|
|
dmp.StateData = br.ReadBytes(ss);
|
|
|
|
|
|
2010-12-19 14:41:11 +00:00
|
|
|
|
dmp.Registers = br.ReadBytes(8192);
|
|
|
|
|
|
|
|
|
|
while (br.PeekChar() != -1)
|
|
|
|
|
{
|
2010-12-20 16:28:59 +00:00
|
|
|
|
GSType id = (GSType)br.ReadByte();
|
|
|
|
|
switch (id)
|
2010-12-19 14:41:11 +00:00
|
|
|
|
{
|
|
|
|
|
case GSType.Transfer:
|
2010-12-20 16:28:59 +00:00
|
|
|
|
GSTransfer data = new GSTransfer();
|
|
|
|
|
|
2010-12-19 14:41:11 +00:00
|
|
|
|
byte index = br.ReadByte();
|
2010-12-20 16:28:59 +00:00
|
|
|
|
|
|
|
|
|
data.id = id;
|
|
|
|
|
data.Path = (GSTransferPath)index;
|
|
|
|
|
|
2010-12-19 15:55:52 +00:00
|
|
|
|
Int32 size = br.ReadInt32();
|
2010-12-19 14:41:11 +00:00
|
|
|
|
|
2010-12-19 15:55:52 +00:00
|
|
|
|
List<byte> Data = new List<byte>();
|
|
|
|
|
Data.AddRange(br.ReadBytes(size));
|
|
|
|
|
data.data = Data.ToArray();
|
2010-12-20 16:28:59 +00:00
|
|
|
|
dmp.Data.Add(data);
|
2010-12-19 14:41:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case GSType.VSync:
|
2010-12-20 16:28:59 +00:00
|
|
|
|
GSData dataV = new GSData();
|
|
|
|
|
dataV.id = id;
|
|
|
|
|
dataV.data = br.ReadBytes(1);
|
|
|
|
|
dmp.Data.Add(dataV);
|
2010-12-19 14:41:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case GSType.ReadFIFO2:
|
2010-12-20 16:28:59 +00:00
|
|
|
|
GSData dataR = new GSData();
|
|
|
|
|
dataR.id = id;
|
2010-12-19 14:41:11 +00:00
|
|
|
|
Int32 sF = br.ReadInt32();
|
2010-12-20 16:28:59 +00:00
|
|
|
|
dataR.data = BitConverter.GetBytes(sF);
|
|
|
|
|
dmp.Data.Add(dataR);
|
2010-12-19 14:41:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case GSType.Registers:
|
2010-12-20 16:28:59 +00:00
|
|
|
|
GSData dataRR = new GSData();
|
|
|
|
|
dataRR.id = id;
|
|
|
|
|
dataRR.data = br.ReadBytes(8192);
|
|
|
|
|
dmp.Data.Add(dataRR);
|
2010-12-19 14:41:11 +00:00
|
|
|
|
break;
|
2010-12-19 21:32:09 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2010-12-19 14:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
br.Close();
|
|
|
|
|
|
|
|
|
|
return dmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|