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;
|
|
|
|
|
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>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
GSData data = new GSData();
|
|
|
|
|
data.id = (GSType)br.ReadByte();
|
|
|
|
|
|
|
|
|
|
switch (data.id)
|
|
|
|
|
{
|
|
|
|
|
case GSType.Transfer:
|
|
|
|
|
byte index = br.ReadByte();
|
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.Add(index);
|
|
|
|
|
Data.AddRange(br.ReadBytes(size));
|
|
|
|
|
data.data = Data.ToArray();
|
2010-12-19 14:41:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case GSType.VSync:
|
|
|
|
|
data.data = br.ReadBytes(1);
|
|
|
|
|
break;
|
|
|
|
|
case GSType.ReadFIFO2:
|
|
|
|
|
Int32 sF = br.ReadInt32();
|
2010-12-19 21:32:09 +00:00
|
|
|
|
data.data = BitConverter.GetBytes(sF);
|
2010-12-19 14:41:11 +00:00
|
|
|
|
break;
|
|
|
|
|
case GSType.Registers:
|
|
|
|
|
data.data = br.ReadBytes(8192);
|
|
|
|
|
break;
|
2010-12-19 21:32:09 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2010-12-19 14:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
dmp.Data.Add(data);
|
|
|
|
|
}
|
|
|
|
|
br.Close();
|
|
|
|
|
|
|
|
|
|
return dmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|