Started doing Register detection for the packets. (Still missing A+D and FOG)

Happy Christmas to everyone. ;)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4141 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
feal87@gmail.com 2010-12-25 11:12:41 +00:00
parent ed7638488c
commit bd7ff7de67
15 changed files with 470 additions and 127 deletions

View File

@ -274,7 +274,14 @@ namespace GSDumpGUI
string[] reg = vals[8].Split(new char[]{'~'}, StringSplitOptions.RemoveEmptyEntries);
for (int j = 1; j < reg.Length; j++)
{
nodeReg.Nodes.Add(reg[j]);
string[] fvals = reg[j].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);
}

View File

@ -55,7 +55,17 @@
<Compile Include="Forms\frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="Library\GSDump\GSData\GIFTag.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFPrim.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegPackedXYZ.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegPackedXYZF.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegPackedUV.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegPackedST.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\GIFRegPackedPrim.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegPackedRGBAQ.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\IGifData.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFTag.cs" />
<Compile Include="Library\GSDump\GSData\GSData.cs" />
<Compile Include="Library\GSDump\GSDump.cs" />
<Compile Include="Library\GSDump\GSData\GSTransfer.cs" />

View File

@ -401,7 +401,7 @@ namespace GSDumpGUI
switch (dump.Data[i].id)
{
case GSType.Transfer:
GIFTag tag = ExtractGifTag(dump.Data[i].data);
GIFTag tag = GIFTag.ExtractGifTag(dump.Data[i].data);
val += "Transfer Path " + ((GSTransfer)dump.Data[i]).Path.ToString() + "|";
val += "NLoop = " + tag.nloop + "|";
//val += "Pad1 = " + tag._pad1 + "|";
@ -412,9 +412,48 @@ namespace GSDumpGUI
val += "prim~Prim Class = " + ((GS_PRIM)tag.prim.Prim).ToString() + "~IIP = " + tag.prim.IIP + "~TME = "+ tag.prim.TME + "~FGE = "+ tag.prim.FGE + "~ABE = "+
tag.prim.ABE + "~AA1 = "+ tag.prim.AA1 + "~FST = "+ tag.prim.FST + "~CTXT = " + tag.prim.CTXT + "~FIX = " + tag.prim.FIX + "|";
val += "nreg = " + (tag.nreg == 0 ? 16 : tag.nreg) + "|";
val += "regs~ ";
val += "regs~";
foreach (var itm in tag.regs)
val += itm.Descriptor.ToString() + "~";
{
if (itm.GetType().IsSubclassOf(typeof(GIFReg)))
{
if (itm.GetType() == typeof(GIFRegPackedPrim))
{
GIFRegPackedPrim p = (GIFRegPackedPrim)itm;
val += "Packed Primitive@Primitive Type : " + p.PrimitiveType.ToString() + "@IIP : " + p.IIP.ToString() + "@TME : " + p.TME.ToString() + "@FGE : " + p.FGE.ToString()
+ "@ABE : " + p.ABE.ToString() + "@AA1 : " + p.AA1.ToString() + "@FST : " + p.FST.ToString() + "@CTXT : " + p.CTXT.ToString() + "@FIX : " + p.FIX.ToString() + "~";
}
if (itm.GetType() == typeof(GIFRegPackedRGBAQ))
{
GIFRegPackedRGBAQ p = (GIFRegPackedRGBAQ)itm;
val += "Packed RGBAQ@Red : " + p.R.ToString() + "@Green : " + p.G.ToString() + "@Blue : " + p.B.ToString() + "@Alpha : " + p.A.ToString() + "~";
}
if (itm.GetType() == typeof(GIFRegPackedST))
{
GIFRegPackedST p = (GIFRegPackedST)itm;
val += "Packed ST@S : " + p.S.ToString("F8") + "@T : " + p.T.ToString("F8") + "@Q : " + p.Q.ToString("F8") + "~";
}
if (itm.GetType() == typeof(GIFRegPackedUV))
{
GIFRegPackedUV p = (GIFRegPackedUV)itm;
val += "Packed UV@U : " + p.U.ToString("F4") + "@V : " + p.V.ToString("F4") + "~";
}
if (itm.GetType() == typeof(GIFRegPackedXYZF))
{
GIFRegPackedXYZF p = (GIFRegPackedXYZF)itm;
val += "Packed XYZF@X : " + p.X.ToString("F4") + "@Y : " + p.Y.ToString("F4") + "@Z : " + p.Z.ToString() + "@F : " + p.F.ToString() + "@ADC : " + p.ADC.ToString() + "~";
}
if (itm.GetType() == typeof(GIFRegPackedXYZ))
{
GIFRegPackedXYZ p = (GIFRegPackedXYZ)itm;
val += "Packed XYZ@X : " + p.X.ToString("F4") + "@Y : " + p.Y.ToString("F4") + "@Z : " + p.Z.ToString() + "@ADC : " + p.ADC.ToString() + "~";
}
}
else
{
}
}
break;
case GSType.VSync:
val += "Field = " + dump.Data[i].data[0].ToString();
@ -431,50 +470,5 @@ namespace GSDumpGUI
return val;
}
internal GIFTag ExtractGifTag(byte[] data)
{
Int16 nloopEOP = 0;
Int16 pad1 = 0;
Int32 pad2PrePrimFlgNReg = 0;
Int64 regs = 0;
nloopEOP = BitConverter.ToInt16(data, 0);
pad1 = BitConverter.ToInt16(data, 2);
pad2PrePrimFlgNReg = BitConverter.ToInt32(data, 4);
regs = BitConverter.ToInt64(data, 8);
GIFTag t = new GIFTag();
t.nloop = (nloopEOP & 0x7FFF);
t.eop = (nloopEOP & 0x8000) >> 15;
t._pad1 = pad1;
t._pad2 = (pad2PrePrimFlgNReg & 0x00003FFF);
t.pre = (pad2PrePrimFlgNReg & 0x00004000) >> 14;
int prim = (pad2PrePrimFlgNReg & 0x03FF8000) >> 15;
GIFPrim pri = new GIFPrim();
pri.Prim = (prim & 0x007);
pri.IIP = (prim & 0x008) >> 3;
pri.TME = (prim & 0x010) >> 4;
pri.FGE = (prim & 0x020) >> 5;
pri.ABE = (prim & 0x040) >> 6;
pri.AA1 = (prim & 0x080) >> 7;
pri.FST = (prim & 0x100) >> 8;
pri.CTXT = (prim & 0x200) >> 9;
pri.FIX = (prim & 0x400) >> 10;
t.prim = pri;
t.flg = (pad2PrePrimFlgNReg & 0xC000000) >> 26;
t.nreg = (int)(pad2PrePrimFlgNReg & 0xF0000000) >> 28;
t.regs = new List<GIFReg>();
for (int i = 0; i < t.nreg; i++)
{
GIFReg reg = new GIFReg();
reg.Descriptor = (GIFRegDescriptor)((regs & (Convert.ToInt32(Math.Pow(16, i + 1)) - 1)) >> i*4);
t.regs.Add(reg);
}
return t;
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFPrim
{
public Int32 Prim;
public Int32 IIP;
public Int32 TME;
public Int32 FGE;
public Int32 ABE;
public Int32 AA1;
public Int32 FST;
public Int32 CTXT;
public Int32 FIX;
static internal GIFPrim ExtractGIFPrim(Int32 rawValue)
{
GIFPrim pri = new GIFPrim();
pri.Prim = (rawValue & 0x007);
pri.IIP = (rawValue & 0x008) >> 3;
pri.TME = (rawValue & 0x010) >> 4;
pri.FGE = (rawValue & 0x020) >> 5;
pri.ABE = (rawValue & 0x040) >> 6;
pri.AA1 = (rawValue & 0x080) >> 7;
pri.FST = (rawValue & 0x100) >> 8;
pri.CTXT = (rawValue & 0x200) >> 9;
pri.FIX = (rawValue & 0x400) >> 10;
return pri;
}
}
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

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
abstract public class GIFReg : IGifData
{
public GIFRegDescriptor Descriptor;
}
public enum GIFRegDescriptor
{
PRIM = 0,
RGBAQ = 1,
ST = 2,
UV = 3,
XYZF2 = 4,
XYZ2 = 5,
TEX0_1 = 6,
TEX0_2 = 7,
CLAMP_1 = 8,
CLAMP_2 = 9,
FOG = 10,
Reserved = 11,
XYZF3 = 12,
XYZ3 = 13,
AD = 14,
NOP = 15
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFRegPackedPrim : 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 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

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFRegPackedRGBAQ : GIFReg
{
public int R;
public int G;
public int B;
public int A;
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFRegPackedST : GIFReg
{
public float S;
public float T;
public float Q;
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFRegPackedUV : GIFReg
{
public double U;
public double V;
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFRegPackedXYZ : GIFReg
{
public double X;
public double Y;
public UInt32 Z;
public bool ADC;
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFRegPackedXYZF : GIFReg
{
public double X;
public double Y;
public UInt32 Z;
public UInt16 F;
public bool ADC;
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GifImage : IGifData
{
public byte[] LowData;
public byte[] HighData;
}
}

View File

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public interface IGifData
{
}
}

View File

@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFTag
{
public Int32 nloop;
public Int32 eop;
public Int32 _pad1;
public Int32 _pad2;
public Int32 pre;
public GIFPrim prim;
public GIFFLG flg;
public Int32 nreg;
public List<IGifData> regs;
static internal unsafe GIFTag ExtractGifTag(byte[] data)
{
Int16 nloopEOP = 0;
Int16 pad1 = 0;
Int32 pad2PrePrimFlgNReg = 0;
Int64 regs = 0;
nloopEOP = BitConverter.ToInt16(data, 0);
pad1 = BitConverter.ToInt16(data, 2);
pad2PrePrimFlgNReg = BitConverter.ToInt32(data, 4);
regs = BitConverter.ToInt64(data, 8);
GIFTag t = new GIFTag();
t.nloop = (nloopEOP & 0x7FFF);
t.eop = (nloopEOP & 0x8000) >> 15;
t._pad1 = pad1;
t._pad2 = (pad2PrePrimFlgNReg & 0x00003FFF);
t.pre = (pad2PrePrimFlgNReg & 0x00004000) >> 14;
int prim = (pad2PrePrimFlgNReg & 0x03FF8000) >> 15;
GIFPrim primm = GIFPrim.ExtractGIFPrim(prim);
t.prim = primm;
t.flg = (GIFFLG)((pad2PrePrimFlgNReg & 0xC000000) >> 26);
t.nreg = (int)(pad2PrePrimFlgNReg & 0xF0000000) >> 28;
List<GIFRegDescriptor> registers = new List<GIFRegDescriptor>();
t.regs = new List<IGifData>();
for (int i = 0; i < t.nreg; i++)
registers.Add((GIFRegDescriptor)((regs & (Convert.ToInt32(Math.Pow(16, i + 1)) - 1)) >> i * 4));
for (int j = 0; j < t.nloop; j++)
{
for (int i = 0; i < registers.Count; i++)
{
UInt64 LowData = BitConverter.ToUInt64(data, (16 + (i * 16) + (j * 16 * registers.Count)));
UInt64 HighData = BitConverter.ToUInt64(data, (16 + (i * 16) + (j * 16 * registers.Count)));
switch (t.flg)
{
case GIFFLG.GIF_FLG_PACKED:
switch (registers[i])
{
case GIFRegDescriptor.PRIM:
if (t.pre == 1)
{
GIFRegPackedPrim pr = new GIFRegPackedPrim();
pr.Descriptor = registers[i];
pr.PrimitiveType = (GS_PRIM)(LowData & 0x7);
pr.IIP = (GSIIP)((LowData & 0x8) >> 3);
pr.TME = Convert.ToBoolean(((LowData & 0x10) >> 4));
pr.FGE = Convert.ToBoolean(((LowData & 0x20) >> 5));
pr.ABE = Convert.ToBoolean(((LowData & 0x40) >> 6));
pr.AA1 = Convert.ToBoolean(((LowData & 0x80) >> 7));
pr.FST = (GSFST)((LowData & 0x100) >> 8);
pr.CTXT = (GSCTXT)((LowData & 0x200) >> 9);
pr.FIX = (GSFIX)((LowData & 0x400) >> 10);
t.regs.Add(pr);
}
break;
case GIFRegDescriptor.RGBAQ:
GIFRegPackedRGBAQ r = new GIFRegPackedRGBAQ();
r.Descriptor = registers[i];
r.R = (int)(LowData & 0xFF);
r.G = (int)((LowData & 0xFF00000000) >> 32);
r.B = (int)((HighData & 0xFF));
r.A = (int)((HighData & 0xFF00000000) >> 32);
t.regs.Add(r);
break;
case GIFRegDescriptor.ST:
GIFRegPackedST st = new GIFRegPackedST();
st.Descriptor = registers[i];
ulong pt = ((LowData & 0xFFFFFFFF));
void* ptt = &pt;
st.S = *(float*)ptt;
pt = ((LowData & 0xFFFFFFFF00000000) >> 32);
ptt = &pt;
st.T = *(float*)ptt;
pt = ((HighData & 0xFFFFFFFF));
ptt = &pt;
st.Q = *(float*)ptt;
t.regs.Add(st);
break;
case GIFRegDescriptor.UV:
GIFRegPackedUV u = new GIFRegPackedUV();
u.Descriptor = registers[i];
u.U = (LowData & 0x3FFF) / 16d;
u.V = ((LowData & 0x3FFF00000000) >> 32) / 16d;
t.regs.Add(u);
break;
case GIFRegDescriptor.XYZF2:
GIFRegPackedXYZF xf = new GIFRegPackedXYZF();
xf.Descriptor = registers[i];
xf.X = (LowData & 0xFFFF) / 16d;
xf.Y = ((LowData & 0xFFFF00000000) >> 32) / 16d;
xf.Z = (UInt32)((HighData & 0xFFFFFF0) >> 4);
xf.F = (UInt16)((HighData & 0xFF000000000) >> 36);
xf.ADC = ((HighData & 0x1000000000000) >> 46) == 1;
t.regs.Add(xf);
break;
case GIFRegDescriptor.XYZ2:
GIFRegPackedXYZ xf2 = new GIFRegPackedXYZ();
xf2.Descriptor = registers[i];
xf2.X = (LowData & 0xFFFF) / 16d;
xf2.Y = ((LowData & 0xFFFF00000000) >> 32) / 16d;
xf2.Z = (UInt32)((HighData & 0xFFFFFF0) >> 4);
xf2.ADC = ((HighData & 0x1000000000000) >> 46) == 1;
t.regs.Add(xf2);
break;
case GIFRegDescriptor.FOG:
break;
case GIFRegDescriptor.Reserved:
break;
case GIFRegDescriptor.XYZF3:
GIFRegPackedXYZF xf3 = new GIFRegPackedXYZF();
xf3.Descriptor = registers[i];
xf3.X = (LowData & 0xFFFF) / 16d;
xf3.Y = ((LowData & 0xFFFF00000000) >> 32) / 16d;
xf3.Z = (UInt32)((HighData & 0xFFFFFF0) >> 4);
xf3.F = (UInt16)((HighData & 0xFF000000000) >> 36);
xf3.ADC = ((HighData & 0x1000000000000) >> 46) == 1;
t.regs.Add(xf3);
break;
case GIFRegDescriptor.XYZ3:
GIFRegPackedXYZ xf4 = new GIFRegPackedXYZ();
xf4.Descriptor = registers[i];
xf4.X = (LowData & 0xFFFF) / 16d;
xf4.Y = ((LowData & 0xFFFF00000000) >> 32) / 16d;
xf4.Z = (UInt32)((HighData & 0xFFFFFF0) >> 4);
xf4.ADC = ((HighData & 0x1000000000000) >> 46) == 1;
t.regs.Add(xf4);
break;
case GIFRegDescriptor.AD:
int destaddr = (int)(HighData & 0xF);
break;
case GIFRegDescriptor.NOP:
break;
default:
break;
}
break;
case GIFFLG.GIF_FLG_REGLIST:
// TODO :
break;
case GIFFLG.GIF_FLG_IMAGE:
GifImage image = new GifImage();
image.LowData = BitConverter.GetBytes(LowData);
image.HighData = BitConverter.GetBytes(HighData);
t.regs.Add(image);
break;
case GIFFLG.GIF_FLG_IMAGE2:
GifImage image2 = new GifImage();
image2.LowData = BitConverter.GetBytes(LowData);
image2.HighData = BitConverter.GetBytes(HighData);
t.regs.Add(image2);
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,77 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace GSDumpGUI
{
public class GIFTag
{
public Int32 nloop;
public Int32 eop;
public Int32 _pad1;
public Int32 _pad2;
public Int32 pre;
public GIFPrim prim;
public Int32 flg;
public Int32 nreg;
public List<GIFReg> regs;
}
public class GIFPrim
{
public Int32 Prim;
public Int32 IIP;
public Int32 TME;
public Int32 FGE;
public Int32 ABE;
public Int32 AA1;
public Int32 FST;
public Int32 CTXT;
public Int32 FIX;
}
public class GIFReg
{
public GIFRegDescriptor Descriptor;
}
public enum GIFRegDescriptor
{
PRIM = 0,
RGBAQ = 1,
ST = 2,
UV = 3,
XYZF2 = 4,
XYZ2 = 5,
TEX0_1 = 6,
TEX0_2 = 7,
CLAMP_1 = 8,
CLAMP_2 = 9,
FOG = 10,
Reserved = 11,
XYZF3 = 12,
XYZ3 = 13,
AD = 14,
NOP = 15
}
public enum GIFFLG
{
GIF_FLG_PACKED =0,
GIF_FLG_REGLIST =1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
}
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,
}
}