Commit f9b9aae4 authored by Connor Abbott's avatar Connor Abbott

restructure parsing

Now we always use the size in the header instead of guessing (often
incorrectly) the block size. I've also added some more details, and
removed some assertions that were tripping. Altogether, this is enough
to be able to parse a simple fragment shader from the malisc offline
shader compiler.
parent 14b53e65
......@@ -6,6 +6,12 @@ constexpr uint32_t COOKIE(const char a[4])
return (a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
};
struct Header
{
uint32_t cookie;
uint32_t size;
};
// Block Types seen
//
// MPB1
......@@ -29,101 +35,36 @@ constexpr uint32_t COOKIE(const char a[4])
struct Block_MPB1
{
// MPB1
uint32_t cookie;
// Size of the file sub 0x8
uint32_t size;
uint32_t unk1;
uint32_t unk2;
};
struct Block_VERT
{
// VERT
uint32_t cookie;
uint32_t unk1;
};
struct Block_FRAG
{
// FRAG
uint32_t cookie;
uint32_t unk1;
};
struct Block_COMP
{
// COMP
uint32_t cookie;
uint32_t unk1;
};
// Main header for the entire binary
struct Block_MBS2
{
// MBS2
uint32_t cookie;
// total size of the binary in bytes, minus 8 bytes for cookie and size.
uint32_t size;
// some kind of version
uint32_t version;
};
struct Block_VEHW
{
// VEHW
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
uint32_t unk4;
};
struct Block_CVER
{
// CVER
uint32_t cookie;
// XXX: Version?
uint32_t unk1;
};
struct Block_CMMN
{
// CMMN
uint32_t cookie;
uint32_t unk1;
};
struct Block_VELA
{
// VELA
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
};
struct Block_SSYM
{
// SSYM
uint32_t cookie;
uint32_t size;
uint32_t unk2;
};
struct Block_SYMB
{
// SYMB
uint32_t cookie;
uint32_t unk1;
};
struct Block_STRI
{
// STRI
uint32_t cookie;
// Size in bytes padded to the nearest word
uint32_t size;
// There is a string here
uint32_t unk1;
uint32_t unk2;
......@@ -136,16 +77,11 @@ struct Block_TYPE
enum Type : uint32_t
{
};
// TYPE
uint32_t cookie;
Type type;
};
struct Block_TPGE
{
// TPGE
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
uint32_t unk4;
......@@ -158,8 +94,6 @@ struct Block_TPIB
{
// TPIB
// Type buffer
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
uint32_t unk4;
......@@ -168,7 +102,6 @@ struct Block_TPST
{
// TPST
// Type struct
uint32_t cookie;
// XXX: Haven't seen it to fill it out
};
......@@ -176,24 +109,18 @@ struct Block_TPSE
{
// TPSE
// Type struct/buffer element
uint32_t cookie;
uint32_t unk1;
};
struct Block_TPAR
{
// TPAR
// Type array
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
};
struct Block_UBUF
{
// UBUF
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
};
......@@ -201,8 +128,6 @@ struct Block_UBUF
struct Block_EBIN
{
// EBIN
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
uint32_t unk4;
......@@ -213,8 +138,6 @@ struct Block_EBIN
struct Block_FSHA
{
// FSHA
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
uint32_t unk4;
......@@ -226,24 +149,18 @@ struct Block_FSHA
struct Block_BFRE
{
// BFRE
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
};
struct Block_SPDv
{
// SPDv
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
};
struct Block_SPDf
{
// SPDf
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
};
......@@ -251,52 +168,18 @@ struct Block_SPDf
struct Block_SPDc
{
// SPDc
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
};
struct Block_OBJC
{
// OBJC
uint32_t cookie;
uint32_t size;
};
struct Block_CFRA
{
// CFRA
uint32_t cookie;
uint32_t unk1;
};
struct Block_BATT
{
// BATT
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
};
struct Block_CCOM
{
// CCOM
uint32_t cookie;
uint32_t unk1;
};
struct Block_KERN
{
// KERN
uint32_t cookie;
uint32_t unk1;
};
struct Block_KWGS
{
// KWGS
uint32_t cookie;
uint32_t unk1;
uint32_t local_x;
uint32_t local_y;
uint32_t local_z;
......@@ -305,8 +188,6 @@ struct Block_KWGS
struct Block_RLOC
{
// RLOC
uint32_t cookie;
uint32_t unk1;
uint32_t unk2;
uint32_t unk3;
uint32_t unk4;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment