GSDumpGUI: went a bit mad on changing type width and signs after finding a signedness bug, and (more importantly for now), handled (kind of) split GIF primitives without crashing (hopefully)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4164 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
sudonim1 2010-12-28 18:31:45 +00:00
parent 3d0b2979bd
commit 22a70739db
15 changed files with 111 additions and 119 deletions

View File

@ -70,6 +70,7 @@
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFReg\GIFRegRGBAQ.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\GIFReg\IGifData.cs" />
<Compile Include="Library\GSDump\GSData\GIFPacket\GIFTag.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\GSData\GSData.cs" />
<Compile Include="Library\GSDump\GSDump.cs" /> <Compile Include="Library\GSDump\GSDump.cs" />
<Compile Include="Library\GSDump\GSData\GSTransfer.cs" /> <Compile Include="Library\GSDump\GSData\GSTransfer.cs" />

View File

@ -401,6 +401,8 @@ namespace GSDumpGUI
switch (dump.Data[i].id) switch (dump.Data[i].id)
{ {
case GSType.Transfer: case GSType.Transfer:
try
{
GIFTag tag = GIFTag.ExtractGifTag(dump.Data[i].data); GIFTag tag = GIFTag.ExtractGifTag(dump.Data[i].data);
val += "Transfer Path " + ((GSTransfer)dump.Data[i]).Path.ToString() + "|"; val += "Transfer Path " + ((GSTransfer)dump.Data[i]).Path.ToString() + "|";
val += "NLoop = " + tag.nloop + "|"; val += "NLoop = " + tag.nloop + "|";
@ -417,6 +419,12 @@ namespace GSDumpGUI
{ {
val += itm.ToString() + "~"; val += itm.ToString() + "~";
} }
}
catch (ArgumentException) // out of bounds because of split primitive
{
// accomodating hacked up tree builder
val += "Unhandled split GIF primitive|||||||||";
}
break; break;
case GSType.VSync: case GSType.VSync:
val += "Field = " + dump.Data[i].data[0].ToString(); val += "Field = " + dump.Data[i].data[0].ToString();

View File

@ -4,19 +4,19 @@ using System.Text;
namespace GSDumpGUI namespace GSDumpGUI
{ {
public class GIFPrim public class GIFPrim : GIFUtil
{ {
public Int32 Prim; public UInt32 Prim;
public Int32 IIP; public UInt32 IIP;
public Int32 TME; public UInt32 TME;
public Int32 FGE; public UInt32 FGE;
public Int32 ABE; public UInt32 ABE;
public Int32 AA1; public UInt32 AA1;
public Int32 FST; public UInt32 FST;
public Int32 CTXT; public UInt32 CTXT;
public Int32 FIX; public UInt32 FIX;
static internal GIFPrim ExtractGIFPrim(Int32 rawValue) static internal GIFPrim ExtractGIFPrim(UInt32 rawValue)
{ {
GIFPrim pri = new GIFPrim(); GIFPrim pri = new GIFPrim();
pri.Prim = (rawValue & 0x007); pri.Prim = (rawValue & 0x007);

View File

@ -4,7 +4,7 @@ using System.Text;
namespace GSDumpGUI namespace GSDumpGUI
{ {
abstract public class GIFReg : IGifData abstract public class GIFReg : GIFUtil, IGifData
{ {
public GIFRegDescriptor Descriptor; public GIFRegDescriptor Descriptor;
public UInt64 LowData, HighData; public UInt64 LowData, HighData;
@ -12,18 +12,13 @@ namespace GSDumpGUI
private GIFReg() { } private GIFReg() { }
public GIFReg(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) public GIFReg(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
this.LowData = LowData; this.LowData = LowData;
this.HighData = HighData; this.HighData = HighData;
this.PackedFormat = PackedFormat; this.PackedFormat = PackedFormat;
} }
static public UInt64 GetBit(UInt64 value, byte lower, byte count)
{
return (value >> lower) & (ulong)((1 << count) - 1);
}
abstract public new String ToString(); abstract public new String ToString();
} }

View File

@ -6,10 +6,10 @@ namespace GSDumpGUI
{ {
public static class GIFRegAD public static class GIFRegAD
{ {
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
int reg = (int)GIFReg.GetBit(HighData, 0, 8); byte reg = (byte)GIFReg.GetBit(HighData, 0, 8);
if (reg == (int)GIFRegDescriptor.AD) if (reg == (byte)GIFRegDescriptor.AD)
return GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat); return GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat);
return GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false); return GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false);
} }

View File

@ -8,9 +8,9 @@ namespace GSDumpGUI
{ {
public double F; public double F;
public GIFRegFOG(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegFOG(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegFOG u = new GIFRegFOG(addr, LowData, HighData, PackedFormat); GIFRegFOG u = new GIFRegFOG(addr, LowData, HighData, PackedFormat);
u.Descriptor = (GIFRegDescriptor)addr; u.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,11 +6,11 @@ namespace GSDumpGUI
{ {
public class GIFRegNOP : GIFReg public class GIFRegNOP : GIFReg
{ {
public int addr; public byte addr;
public GIFRegNOP(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegNOP(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegNOP nop = new GIFRegNOP(addr, LowData, HighData, PackedFormat); GIFRegNOP nop = new GIFRegNOP(addr, LowData, HighData, PackedFormat);
nop.Descriptor = GIFRegDescriptor.NOP; nop.Descriptor = GIFRegDescriptor.NOP;

View File

@ -16,9 +16,9 @@ namespace GSDumpGUI
public GSCTXT CTXT; public GSCTXT CTXT;
public GSFIX FIX; public GSFIX FIX;
public GIFRegPRIM(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegPRIM(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegPRIM pr = new GIFRegPRIM(addr, LowData, HighData, PackedFormat); GIFRegPRIM pr = new GIFRegPRIM(addr, LowData, HighData, PackedFormat);
pr.Descriptor = (GIFRegDescriptor)addr; pr.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,32 +6,32 @@ namespace GSDumpGUI
{ {
public class GIFRegRGBAQ : GIFReg public class GIFRegRGBAQ : GIFReg
{ {
public int R; public byte R;
public int G; public byte G;
public int B; public byte B;
public int A; public byte A;
public float Q; public float Q;
public GIFRegRGBAQ(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegRGBAQ(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegRGBAQ r = new GIFRegRGBAQ(addr, LowData, HighData, PackedFormat); GIFRegRGBAQ r = new GIFRegRGBAQ(addr, LowData, HighData, PackedFormat);
r.Descriptor = (GIFRegDescriptor)addr; r.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat) if (PackedFormat)
{ {
r.R = (int)GetBit(LowData, 0, 8); r.R = (byte)GetBit(LowData, 0, 8);
r.G = (int)GetBit(LowData, 32, 8); r.G = (byte)GetBit(LowData, 32, 8);
r.B = (int)GetBit(HighData, 0, 8); r.B = (byte)GetBit(HighData, 0, 8);
r.A = (int)GetBit(HighData, 32, 8); r.A = (byte)GetBit(HighData, 32, 8);
r.Q = tag.Q; r.Q = tag.Q;
} }
else else
{ {
r.R = (int)GetBit(LowData, 0, 8); r.R = (byte)GetBit(LowData, 0, 8);
r.G = (int)GetBit(LowData, 8, 8); r.G = (byte)GetBit(LowData, 8, 8);
r.B = (int)GetBit(LowData, 16, 8); r.B = (byte)GetBit(LowData, 16, 8);
r.A = (int)GetBit(LowData, 24, 8); r.A = (byte)GetBit(LowData, 24, 8);
r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4); r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
} }
return r; return r;

View File

@ -12,9 +12,9 @@ namespace GSDumpGUI
public bool isSTQ; public bool isSTQ;
public GIFRegST(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegST(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegST st = new GIFRegST(addr, LowData, HighData, PackedFormat); GIFRegST st = new GIFRegST(addr, LowData, HighData, PackedFormat);
st.Descriptor = (GIFRegDescriptor)addr; st.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,37 +6,37 @@ namespace GSDumpGUI
{ {
public class GIFRegTEX0 : GIFReg public class GIFRegTEX0 : GIFReg
{ {
public int TBP0; public ushort TBP0;
public int TBW; public byte TBW;
public TEXPSM PSM; public TEXPSM PSM;
public int TW; public byte TW;
public int TH; public byte TH;
public TEXTCC TCC; public TEXTCC TCC;
public TEXTFX TFX; public TEXTFX TFX;
public int CBP; public ushort CBP;
public TEXCPSM CPSM; public TEXCPSM CPSM;
public TEXCSM CSM; public TEXCSM CSM;
public int CSA; public byte CSA;
public int CLD; public byte CLD;
public GIFRegTEX0(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegTEX0(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegTEX0 tex0 = new GIFRegTEX0(addr, LowData, HighData, PackedFormat); GIFRegTEX0 tex0 = new GIFRegTEX0(addr, LowData, HighData, PackedFormat);
tex0.Descriptor = (GIFRegDescriptor)addr; tex0.Descriptor = (GIFRegDescriptor)addr;
tex0.TBP0 = (int)GetBit(LowData, 0, 14); tex0.TBP0 = (ushort)GetBit(LowData, 0, 14);
tex0.TBW = (int)GetBit(LowData, 14, 6); tex0.TBW = (byte)GetBit(LowData, 14, 6);
tex0.PSM = (TEXPSM)(int)GetBit(LowData, 20, 6); tex0.PSM = (TEXPSM)GetBit(LowData, 20, 6);
tex0.TW = (int)GetBit(LowData, 26, 4); tex0.TW = (byte)GetBit(LowData, 26, 4);
tex0.TH = (int)GetBit(LowData, 30, 4); tex0.TH = (byte)GetBit(LowData, 30, 4);
tex0.TCC = (TEXTCC)(int)GetBit(LowData, 34, 1); tex0.TCC = (TEXTCC)GetBit(LowData, 34, 1);
tex0.TFX = (TEXTFX)(int)GetBit(LowData, 35, 2); tex0.TFX = (TEXTFX)GetBit(LowData, 35, 2);
tex0.CBP = (int)GetBit(LowData, 37, 14); tex0.CBP = (ushort)GetBit(LowData, 37, 14);
tex0.CPSM = (TEXCPSM)(int)GetBit(LowData, 51, 4); tex0.CPSM = (TEXCPSM)GetBit(LowData, 51, 4);
tex0.CSM = (TEXCSM)(int)GetBit(LowData, 55, 1); tex0.CSM = (TEXCSM)GetBit(LowData, 55, 1);
tex0.CSA = (int)GetBit(LowData, 56, 5); tex0.CSA = (byte)GetBit(LowData, 56, 5);
tex0.CLD = (int)GetBit(LowData, 61, 3); tex0.CLD = (byte)GetBit(LowData, 61, 3);
return tex0; return tex0;
} }

View File

@ -9,9 +9,9 @@ namespace GSDumpGUI
public double U; public double U;
public double V; public double V;
public GIFRegUV(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegUV(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegUV uv = new GIFRegUV(addr, LowData, HighData, PackedFormat); GIFRegUV uv = new GIFRegUV(addr, LowData, HighData, PackedFormat);
uv.Descriptor = (GIFRegDescriptor)addr; uv.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,9 +6,9 @@ namespace GSDumpGUI
{ {
public class GIFRegUnimpl : GIFReg public class GIFRegUnimpl : GIFReg
{ {
public GIFRegUnimpl(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegUnimpl(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegUnimpl u = new GIFRegUnimpl(addr, LowData, HighData, PackedFormat); GIFRegUnimpl u = new GIFRegUnimpl(addr, LowData, HighData, PackedFormat);
u.Descriptor = (GIFRegDescriptor)addr; u.Descriptor = (GIFRegDescriptor)addr;

View File

@ -13,9 +13,9 @@ namespace GSDumpGUI
public bool IsXYZF; public bool IsXYZF;
public GIFRegXYZF(int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { } public GIFRegXYZF(byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) : base(addr, LowData, HighData, PackedFormat) { }
static public GIFReg UnpackXYZ(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg UnpackXYZ(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat); GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat);
@ -40,7 +40,7 @@ namespace GSDumpGUI
return xyzf; return xyzf;
} }
static public GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat) static public GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat)
{ {
GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat); GIFRegXYZF xyzf = new GIFRegXYZF(addr, LowData, HighData, PackedFormat);

View File

@ -4,19 +4,19 @@ using System.Text;
namespace GSDumpGUI namespace GSDumpGUI
{ {
public class GIFTag public class GIFTag : GIFUtil
{ {
public delegate GIFReg Unpack(GIFTag tag, int addr, UInt64 LowData, UInt64 HighData, bool PackedFormat); public delegate GIFReg Unpack(GIFTag tag, byte addr, UInt64 LowData, UInt64 HighData, bool PackedFormat);
static public Dictionary<int, Unpack> UnpackReg; static public Dictionary<int, Unpack> UnpackReg;
public Int32 nloop; public UInt64 TAG, REGS;
public Int32 eop;
public Int32 _pad1; public UInt32 nloop;
public Int32 _pad2; public UInt32 eop;
public Int32 pre; public UInt32 pre;
public GIFPrim prim; public GIFPrim prim;
public GIFFLG flg; public GIFFLG flg;
public Int32 nreg; public UInt32 nreg;
public List<IGifData> regs; public List<IGifData> regs;
public 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 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
@ -90,40 +90,28 @@ namespace GSDumpGUI
static internal GIFTag ExtractGifTag(byte[] data) static 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(); GIFTag t = new GIFTag();
t.TAG = BitConverter.ToUInt64(data, 0);
t.REGS = BitConverter.ToUInt64(data, 8);
t.Q = 1f; t.Q = 1f;
t.nloop = (nloopEOP & 0x7FFF); t.nloop = (uint)GetBit(t.TAG, 0, 15);
t.eop = (nloopEOP & 0x8000) >> 15; t.eop = (uint)GetBit(t.TAG, 15, 1);
t._pad1 = pad1; t.pre = (uint)GetBit(t.TAG, 46, 1);
t._pad2 = (pad2PrePrimFlgNReg & 0x00003FFF); t.prim = GIFPrim.ExtractGIFPrim((uint)GetBit(t.TAG, 47, 11));
t.pre = (pad2PrePrimFlgNReg & 0x00004000) >> 14; t.flg = (GIFFLG)GetBit(t.TAG, 58, 2);
t.nreg = (uint)GetBit(t.TAG, 60, 4);
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;
if (t.nreg == 0) if (t.nreg == 0)
t.nreg = 16; t.nreg = 16;
int[] registers = new int[t.nreg]; byte[] registers = new byte[t.nreg];
Unpack[] regsunpack = new Unpack[t.nreg]; Unpack[] regsunpack = new Unpack[t.nreg];
t.regs = new List<IGifData>(); t.regs = new List<IGifData>();
for (int i = 0; i < t.nreg; i++) for (byte i = 0; i < t.nreg; i++)
{ {
int reg = (int)(regs >> (i * 4) & 15); byte reg = (byte)GetBit(t.REGS, i * 4, 4);
registers[i] = reg; registers[i] = reg;
regsunpack[i] = GetUnpack(reg); regsunpack[i] = GetUnpack(reg);
} }