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\IGifData.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\GSDump.cs" />
<Compile Include="Library\GSDump\GSData\GSTransfer.cs" />

View File

@ -401,21 +401,29 @@ namespace GSDumpGUI
switch (dump.Data[i].id)
{
case GSType.Transfer:
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 + "|";
//val += "Pad2 = " + tag._pad2 + "|";
val += "eop = " + tag.eop + "|";
val += "flg = " + ((GIFFLG)tag.flg).ToString() + "|";
val += "pre = " + tag.pre + "|";
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~";
foreach (var itm in tag.regs)
try
{
val += itm.ToString() + "~";
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 + "|";
//val += "Pad2 = " + tag._pad2 + "|";
val += "eop = " + tag.eop + "|";
val += "flg = " + ((GIFFLG)tag.flg).ToString() + "|";
val += "pre = " + tag.pre + "|";
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~";
foreach (var itm in tag.regs)
{
val += itm.ToString() + "~";
}
}
catch (ArgumentException) // out of bounds because of split primitive
{
// accomodating hacked up tree builder
val += "Unhandled split GIF primitive|||||||||";
}
break;
case GSType.VSync:

View File

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

View File

@ -4,7 +4,7 @@ using System.Text;
namespace GSDumpGUI
{
abstract public class GIFReg : IGifData
abstract public class GIFReg : GIFUtil, IGifData
{
public GIFRegDescriptor Descriptor;
public UInt64 LowData, HighData;
@ -12,18 +12,13 @@ namespace GSDumpGUI
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.HighData = HighData;
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();
}

View File

@ -6,10 +6,10 @@ namespace GSDumpGUI
{
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);
if (reg == (int)GIFRegDescriptor.AD)
byte reg = (byte)GIFReg.GetBit(HighData, 0, 8);
if (reg == (byte)GIFRegDescriptor.AD)
return GIFRegNOP.Unpack(tag, reg, LowData, HighData, PackedFormat);
return GIFTag.GetUnpack(reg)(tag, reg, LowData, HighData, false);
}

View File

@ -8,9 +8,9 @@ namespace GSDumpGUI
{
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);
u.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,11 +6,11 @@ namespace GSDumpGUI
{
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);
nop.Descriptor = GIFRegDescriptor.NOP;

View File

@ -16,9 +16,9 @@ namespace GSDumpGUI
public GSCTXT CTXT;
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);
pr.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,32 +6,32 @@ namespace GSDumpGUI
{
public class GIFRegRGBAQ : GIFReg
{
public int R;
public int G;
public int B;
public int A;
public byte R;
public byte G;
public byte B;
public byte A;
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);
r.Descriptor = (GIFRegDescriptor)addr;
if (PackedFormat)
{
r.R = (int)GetBit(LowData, 0, 8);
r.G = (int)GetBit(LowData, 32, 8);
r.B = (int)GetBit(HighData, 0, 8);
r.A = (int)GetBit(HighData, 32, 8);
r.R = (byte)GetBit(LowData, 0, 8);
r.G = (byte)GetBit(LowData, 32, 8);
r.B = (byte)GetBit(HighData, 0, 8);
r.A = (byte)GetBit(HighData, 32, 8);
r.Q = tag.Q;
}
else
{
r.R = (int)GetBit(LowData, 0, 8);
r.G = (int)GetBit(LowData, 8, 8);
r.B = (int)GetBit(LowData, 16, 8);
r.A = (int)GetBit(LowData, 24, 8);
r.R = (byte)GetBit(LowData, 0, 8);
r.G = (byte)GetBit(LowData, 8, 8);
r.B = (byte)GetBit(LowData, 16, 8);
r.A = (byte)GetBit(LowData, 24, 8);
r.Q = BitConverter.ToSingle(BitConverter.GetBytes(LowData), 4);
}
return r;

View File

@ -12,9 +12,9 @@ namespace GSDumpGUI
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);
st.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,37 +6,37 @@ namespace GSDumpGUI
{
public class GIFRegTEX0 : GIFReg
{
public int TBP0;
public int TBW;
public ushort TBP0;
public byte TBW;
public TEXPSM PSM;
public int TW;
public int TH;
public byte TW;
public byte TH;
public TEXTCC TCC;
public TEXTFX TFX;
public int CBP;
public ushort CBP;
public TEXCPSM CPSM;
public TEXCSM CSM;
public int CSA;
public int CLD;
public byte CSA;
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);
tex0.Descriptor = (GIFRegDescriptor)addr;
tex0.TBP0 = (int)GetBit(LowData, 0, 14);
tex0.TBW = (int)GetBit(LowData, 14, 6);
tex0.PSM = (TEXPSM)(int)GetBit(LowData, 20, 6);
tex0.TW = (int)GetBit(LowData, 26, 4);
tex0.TH = (int)GetBit(LowData, 30, 4);
tex0.TCC = (TEXTCC)(int)GetBit(LowData, 34, 1);
tex0.TFX = (TEXTFX)(int)GetBit(LowData, 35, 2);
tex0.CBP = (int)GetBit(LowData, 37, 14);
tex0.CPSM = (TEXCPSM)(int)GetBit(LowData, 51, 4);
tex0.CSM = (TEXCSM)(int)GetBit(LowData, 55, 1);
tex0.CSA = (int)GetBit(LowData, 56, 5);
tex0.CLD = (int)GetBit(LowData, 61, 3);
tex0.TBP0 = (ushort)GetBit(LowData, 0, 14);
tex0.TBW = (byte)GetBit(LowData, 14, 6);
tex0.PSM = (TEXPSM)GetBit(LowData, 20, 6);
tex0.TW = (byte)GetBit(LowData, 26, 4);
tex0.TH = (byte)GetBit(LowData, 30, 4);
tex0.TCC = (TEXTCC)GetBit(LowData, 34, 1);
tex0.TFX = (TEXTFX)GetBit(LowData, 35, 2);
tex0.CBP = (ushort)GetBit(LowData, 37, 14);
tex0.CPSM = (TEXCPSM)GetBit(LowData, 51, 4);
tex0.CSM = (TEXCSM)GetBit(LowData, 55, 1);
tex0.CSA = (byte)GetBit(LowData, 56, 5);
tex0.CLD = (byte)GetBit(LowData, 61, 3);
return tex0;
}

View File

@ -9,9 +9,9 @@ namespace GSDumpGUI
public double U;
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);
uv.Descriptor = (GIFRegDescriptor)addr;

View File

@ -6,9 +6,9 @@ namespace GSDumpGUI
{
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);
u.Descriptor = (GIFRegDescriptor)addr;

View File

@ -13,9 +13,9 @@ namespace GSDumpGUI
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);
@ -40,7 +40,7 @@ namespace GSDumpGUI
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);

View File

@ -4,19 +4,19 @@ using System.Text;
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;
public Int32 nloop;
public Int32 eop;
public Int32 _pad1;
public Int32 _pad2;
public Int32 pre;
public UInt64 TAG, REGS;
public UInt32 nloop;
public UInt32 eop;
public UInt32 pre;
public GIFPrim prim;
public GIFFLG flg;
public Int32 nreg;
public UInt32 nreg;
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
@ -90,40 +90,28 @@ namespace GSDumpGUI
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();
t.TAG = BitConverter.ToUInt64(data, 0);
t.REGS = BitConverter.ToUInt64(data, 8);
t.Q = 1f;
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;
t.nloop = (uint)GetBit(t.TAG, 0, 15);
t.eop = (uint)GetBit(t.TAG, 15, 1);
t.pre = (uint)GetBit(t.TAG, 46, 1);
t.prim = GIFPrim.ExtractGIFPrim((uint)GetBit(t.TAG, 47, 11));
t.flg = (GIFFLG)GetBit(t.TAG, 58, 2);
t.nreg = (uint)GetBit(t.TAG, 60, 4);
if (t.nreg == 0)
t.nreg = 16;
int[] registers = new int[t.nreg];
byte[] registers = new byte[t.nreg];
Unpack[] regsunpack = new Unpack[t.nreg];
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;
regsunpack[i] = GetUnpack(reg);
}