├── .gitignore ├── 010 Templates ├── CAP.bt ├── CHR.bt ├── DADMP.bt ├── DDS.bt ├── DF.bt ├── EDID.bt ├── ERF.bt ├── FDI.bt ├── FSD.bt ├── FV.bt ├── FXO.bt ├── FezFX.bt ├── GFF.bt ├── GM.bt ├── GRM.bt ├── GW.bt ├── HD6.bt ├── HFE.bt ├── HRM.bt ├── IMD.bt ├── IMG.bt ├── IcoDF.bt ├── JC2.bt ├── LIB.bt ├── LZO.bt ├── MFM.bt ├── MGFX.bt ├── MIA.bt ├── NBT.bt ├── OVL.bt ├── OVLT.bt ├── P2O.bt ├── PIR.bt ├── RD.bt ├── RIFF.bt ├── ROM.bt ├── SAV.bt ├── SIG.bt ├── SQLite.bt ├── SSD.bt ├── Shader.bt ├── TM2.bt ├── UBNT.bt ├── UPK.bt ├── Unity.bt ├── XEX.bt ├── XGS.bt ├── XNB.bt ├── XSB.bt └── XWB.bt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # editor backups 2 | *.bak 3 | *~ 4 | 5 | # repository 6 | 010\ Scripts/Repository/ 7 | 010\ Templates/Repository/ 8 | -------------------------------------------------------------------------------- /010 Templates/CAP.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: CAP.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: UEFI Cap firmware file 8 | // Category: Misc 9 | // File Mask: *.cap 10 | // History: 11 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.2 2012-08-30 Andrew McRae: Merge changes 13 | // 0.1 2012-08-24 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef ubyte UINT8; 17 | typedef byte INT8; 18 | 19 | typedef struct { 20 | UINT32 Data1; 21 | UINT16 Data2; 22 | UINT16 Data3; 23 | BigEndian(); 24 | UINT64 Data4; 25 | LittleEndian(); 26 | } GUID ; 27 | 28 | string read_GUID(GUID &in) { 29 | local string out; 30 | local UINT32 d1 = in.Data1; 31 | local UINT32 d2 = in.Data2; 32 | local UINT32 d3 = in.Data3; 33 | local UINT64 d4 = in.Data4; 34 | local UINT32 d4a = d4 >> 32; 35 | local UINT32 d4b = d4 & 0xFFFFFFFF; 36 | if (d1 == 0x3b6686bd && d2 == 0x0d76 && d3 == 0x4030 && d4a == 0xb70eb551 && d4b == 0x9e2fc5a0) { 37 | out = "EFI_CAPSULE_GUID"; 38 | } 39 | else if (d1 == 0x4a3ca68b && d2 == 0x7723 && d3 == 0x48fb && d4a == 0x803d578c && d4b == 0xc1fec44d) { 40 | out = "EFI_SIGNED_CAPSULE_GUID"; 41 | } 42 | else if (d1 == 0xa7717414 && d2 == 0xc616 && d3 == 0x4977 && d4a == 0x94208447 && d4b == 0x12a735bf) { 43 | out = "EFI_CERT_TYPE_RSA2048_SHA256_GUID"; 44 | } 45 | else if (d1 == 0x4aafd29d && d2 == 0x68df && d3 == 0x49ee && d4a == 0x8aa9347d && d4b == 0x375665a7) { 46 | out = "EFI_CERT_TYPE_PKCS7_GUID"; 47 | } 48 | else if (d1 == 0x51aa59de && d2 == 0xfdf2 && d3 == 0x4ea3 && d4a == 0xbc63875f && d4b == 0xb7842ee9) { 49 | out = "EFI_HASH_ALGORITHM_SHA256_GUID"; 50 | } 51 | else { 52 | SPrintf(out, "{%08X-%04X-%04X-%04X-%04X%08X}", 53 | d1, d2, d3, d4a >> 16, d4a & 0xFFFF, d4b); 54 | } 55 | return out; 56 | } 57 | 58 | typedef struct { 59 | UINT32 Offset; 60 | 61 | if (Offset) { 62 | local quad pos = FTell(); 63 | FSeek(Offset); 64 | SetBackColor(0xc0c0ff); 65 | while (ReadShort(FTell())) { 66 | wstring name; 67 | } 68 | SetBackColor(0xb0b0e0); 69 | UINT16 end; 70 | FSeek(pos); 71 | } 72 | } EFI_STRING_OFFSET ; 73 | 74 | string read_EFI_STRING_OFFSET(EFI_STRING_OFFSET &in) { 75 | if (in.Offset) { 76 | return WStringToUTF8(in.name); 77 | } 78 | else { 79 | return ""; 80 | } 81 | } 82 | 83 | typedef struct { 84 | local UINT32 value = ReadUInt(FTell()); 85 | BitfieldDisablePadding(); 86 | 87 | // 0x00000001 88 | int EFI_CAPSULE_HEADER_FLAG_SETUP: 1; 89 | 90 | int CAPSULE_FLAGS_res1: 15 ; 91 | 92 | // 0x00010000 93 | int CAPSULE_FLAGS_PERSIST_ACROSS_RESET: 1; 94 | 95 | // 0x00020000 96 | int CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE: 1; 97 | 98 | int CAPSULE_FLAGS_res2: 14 ; 99 | 100 | BitfieldEnablePadding(); 101 | } EFI_CAPSULE_HEADER_FLAGS ; 102 | 103 | string read_EFI_CAPSULE_HEADER_FLAGS(EFI_CAPSULE_HEADER_FLAGS &in) { 104 | local string out; 105 | SPrintf(out, "%Xh", in.value); 106 | return out; 107 | } 108 | 109 | typedef struct { 110 | GUID OemGuid; 111 | UINT32 HeaderSize; 112 | 113 | if (HeaderSize > (16 + 4)) { 114 | SetBackColor(0xe0b0b0); 115 | UINT8 Data[HeaderSize - (16 + 4)]; 116 | } 117 | } EFI_CAPSULE_OEM_HEADER; 118 | 119 | typedef struct { 120 | GUID HashType; 121 | UINT8 PublicKey[256]; 122 | UINT8 Signature[256]; 123 | } EFI_CERT_TYPE_RSA2048_SHA256; 124 | 125 | typedef struct { 126 | UINT32 dwLength; 127 | UINT16 wRevision; 128 | enum { 129 | WIN_CERT_TYPE_PKCS_SIGNED_DATA = 0x002, 130 | WIN_CERT_TYPE_EFI_PKCS115 = 0x0EF0, 131 | WIN_CERT_TYPE_EFI_GUID = 0xEF1 132 | } wCertificateType; 133 | 134 | if (wCertificateType == WIN_CERT_TYPE_EFI_GUID) { 135 | GUID CertType; 136 | if (read_GUID(CertType) == "EFI_CERT_TYPE_RSA2048_SHA256_GUID") { 137 | EFI_CERT_TYPE_RSA2048_SHA256 Cert; 138 | } 139 | } 140 | } WIN_CERTIFICATE; 141 | 142 | typedef struct { 143 | GUID CapsuleGuid; 144 | UINT32 HeaderSize; 145 | Assert(HeaderSize == 0x1c || HeaderSize == 0x50, "Unknown HeaderSize"); 146 | EFI_CAPSULE_HEADER_FLAGS Flags; 147 | UINT32 CapsuleImageSize; 148 | //Assert(CapsuleImageSize == FileSize(), "Invalid CapsuleImageSize"); 149 | if (HeaderSize == 0x50) { 150 | UINT32 SequenceNumber; 151 | GUID InstanceId; 152 | UINT32 OffsetToSplitInformation; 153 | UINT32 OffsetToCapsuleBody; 154 | UINT32 OffsetToOemDefinedHeader; 155 | EFI_STRING_OFFSET OffsetToAuthorInformation; 156 | EFI_STRING_OFFSET OffsetToRevisionInformation; 157 | EFI_STRING_OFFSET OffsetToShortDescription; 158 | EFI_STRING_OFFSET OffsetToLongDescription; 159 | UINT32 OffsetToApplicableDevices; 160 | 161 | if (OffsetToOemDefinedHeader) { 162 | FSeek(OffsetToOemDefinedHeader); 163 | SetBackColor(0xffc0c0); 164 | EFI_CAPSULE_OEM_HEADER oh; 165 | } 166 | } 167 | else if (read_GUID(CapsuleGuid) == "EFI_SIGNED_CAPSULE_GUID") { 168 | UINT16 OffsetToCapsuleBody; 169 | UINT16 OffsetToOemDefinedHeader; 170 | 171 | SetBackColor(0xc0ffc0); 172 | WIN_CERTIFICATE c; 173 | EFI_CERT_TYPE_RSA2048_SHA256 c2; 174 | 175 | if (OffsetToOemDefinedHeader) { 176 | FSeek(OffsetToOemDefinedHeader); 177 | SetBackColor(0xffc0c0); 178 | UINT8 oh[OffsetToCapsuleBody - OffsetToOemDefinedHeader]; 179 | } 180 | } 181 | else { 182 | local UINT32 OffsetToCapsuleBody = 0; 183 | } 184 | } EFI_CAPSULE_HEADER ; 185 | 186 | string read_EFI_CAPSULE_HEADER(EFI_CAPSULE_HEADER &in) { 187 | return read_GUID(in.CapsuleGuid); 188 | } 189 | 190 | DisplayFormatHex(); 191 | LittleEndian(); 192 | 193 | SetBackColor(0xe0e0e0); 194 | EFI_CAPSULE_HEADER h; 195 | 196 | if (h.OffsetToCapsuleBody) { 197 | FSeek(h.OffsetToCapsuleBody); 198 | } 199 | 200 | SetBackColor(0xa0a0a0); 201 | UINT8 data[h.CapsuleImageSize - FTell()]; 202 | -------------------------------------------------------------------------------- /010 Templates/CHR.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: CHR.bt 5 | // Authors: Andrew McRae 6 | // Version: 0.1 7 | // Purpose: Parse PS2 Level 5 CHR files 8 | // Category: Archive 9 | // File Mask: *.chr, *.pac, *.snd 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | 14 | typedef uint64 u8; 15 | typedef uint32 u4; 16 | typedef uint16 u2; 17 | typedef ubyte u1; 18 | typedef int64 s8; 19 | typedef int32 s4; 20 | typedef int16 s2; 21 | typedef byte s1; 22 | 23 | 24 | typedef struct { 25 | local quad _start_offset; 26 | _start_offset = FTell(); 27 | char name[64]; 28 | 29 | u4 header_size; 30 | u4 file_size; 31 | u4 next_offset; 32 | u4 unknown4C; 33 | 34 | if (file_size > 0) { 35 | SetBackColor(0xffb0ff); 36 | u1 data[file_size]; 37 | } 38 | 39 | FSeek(_start_offset + next_offset); 40 | 41 | Assert(header_size == 0x50, "FILE header_size != 50h"); 42 | } FILE ; 43 | 44 | string read_FILE(FILE &in) { 45 | local string out; 46 | SPrintf(out, "'%s' %Xh+%Xh", in.name, in._start_offset+in.header_size, in.file_size); 47 | return out; 48 | } 49 | 50 | 51 | DisplayFormatHex(); 52 | LittleEndian(); 53 | 54 | while (ReadByte() != 0) { 55 | SetBackColor(0xb0ffff); 56 | FILE f; 57 | } 58 | -------------------------------------------------------------------------------- /010 Templates/DADMP.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: DADMP.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Dragon Age Origins addon file 8 | // Category: Archive 9 | // File Mask: *.dadmp 10 | // History: 11 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.1 2012-06-01 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | DisplayFormatHex(); 16 | LittleEndian(); 17 | 18 | typedef struct { 19 | uint Length; 20 | char Data[Length]; 21 | } DA_STRING ; 22 | 23 | string DA_STRINGread(DA_STRING &in) { 24 | return in.Data; 25 | } 26 | 27 | SetBackColor(0xe0e0e0); 28 | DA_STRING game; 29 | DA_STRING addon; 30 | DA_STRING version; 31 | DA_STRING filename; 32 | DA_STRING url; 33 | -------------------------------------------------------------------------------- /010 Templates/DDS.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: DDS.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: DDS File parser 8 | // Category: Image 9 | // File Mask: *.dds 10 | // ID Bytes: 44 44 53 // DDS 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2015-09-07 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef struct { 17 | DWORD dwSize ; 18 | Assert(dwSize == 32, "DDS_PIXELFORMAT size not 32"); 19 | 20 | struct DDPF_FLAGS { 21 | DWORD ALPHAPIXELS: 1 ; // 0x1 22 | DWORD ALPHA: 1 ; // 0x2 23 | DWORD FOURCC: 1 ; // 0x4 24 | DWORD reserved: 3 ; 25 | DWORD RGB: 1 ; // 0x40 26 | DWORD reserved: 2 ; 27 | DWORD YUV: 1 ; // 0x200 28 | DWORD reserved: 7 ; 29 | DWORD LUMINANCE: 1 ; // 0x2000 30 | DWORD reserved: 14 ; 31 | } dwFlags ; 32 | char dwFourCC[4]; 33 | DWORD dwRGBBitCount ; 34 | DWORD dwRBitMask; 35 | DWORD dwGBitMask; 36 | DWORD dwBBitMask; 37 | DWORD dwABitMask; 38 | } DDS_PIXELFORMAT ; 39 | string read_DDS_PIXELFORMAT(DDS_PIXELFORMAT &in) { 40 | return in.dwFourCC; 41 | } 42 | string read_DDPF_FLAGS(DDPF_FLAGS &in) { 43 | local string out; 44 | if (in.ALPHAPIXELS) out += "ALPHAPIXELS "; 45 | if (in.ALPHA) out += "ALPHA "; 46 | if (in.FOURCC) out += "FOURCC "; 47 | if (in.RGB) out += "RGB "; 48 | if (in.YUV) out += "YUV "; 49 | if (in.LUMINANCE) out += "LUMINANCE "; 50 | return out; 51 | } 52 | 53 | typedef struct { 54 | DWORD dwSize ; 55 | Assert(dwSize == 124, "DDS_HEADER size not 124"); 56 | 57 | struct DDS_FLAGS { 58 | DWORD CAPS: 1 ; // 0x1 59 | DWORD HEIGHT: 1 ; // 0x2 60 | DWORD WIDTH: 1 ; // 0x4 61 | DWORD PITCH: 1 ; // 0x8 62 | DWORD reserved: 8 ; 63 | DWORD PIXELFORMAT: 1 ; // 0x1000 64 | DWORD reserved: 4 ; 65 | DWORD MIPMAPCOUNT: 1 ; // 0x20000 66 | DWORD reserved: 1 ; 67 | DWORD LINEARSIZE: 1 ; // 0x80000 68 | DWORD reserved : 3 ; 69 | DWORD DEPTH: 1 ; // 0x800000 70 | DWORD reserved: 8 ; 71 | } dwFlags ; 72 | 73 | DWORD dwHeight ; 74 | DWORD dwWidth ; 75 | DWORD dwPitchOrLinearSize; 76 | DWORD dwDepth ; 77 | DWORD dwMipMapCount ; 78 | DWORD dwReserved1[11] ; 79 | 80 | DDS_PIXELFORMAT ddspf; 81 | 82 | struct DDS_CAPS { 83 | DWORD reserved: 3 ; 84 | DWORD COMPLEX: 1 ; // 0x8 85 | DWORD reserved: 8 ; 86 | DWORD TEXTURE: 1 ; // 0x1000 87 | DWORD reserved: 9 ; 88 | DWORD MIPMAP: 1 ; // 0x400000 89 | DWORD reserved: 8 ; 90 | } dwCaps ; 91 | 92 | struct DDS_CAPS2 { 93 | DWORD reserved: 9 ; 94 | DWORD CUBEMAP: 1 ; // 0x200 95 | DWORD CUBEMAP_POSITIVEX: 1 ; // 0x400 96 | DWORD CUBEMAP_NEGATIVEX: 1 ; // 0x800 97 | DWORD CUBEMAP_POSITIVEY: 1 ; // 0x1000 98 | DWORD CUBEMAP_NEGATIVEY: 1 ; // 0x2000 99 | DWORD CUBEMAP_POSITIVEZ: 1 ; // 0x4000 100 | DWORD CUBEMAP_NEGATIVEZ: 1 ; // 0x8000 101 | DWORD reserved: 5 ; 102 | DWORD VOLUME: 1 ; // 0x20000 103 | DWORD reserved: 10 ; 104 | } dwCaps2 ; 105 | 106 | struct DDS_CAPS3 { 107 | DWORD reserved: 32 ; 108 | } dwCaps3 ; 109 | 110 | struct DDS_CAPS4 { 111 | DWORD reserved: 32 ; 112 | } dwCaps4 ; 113 | 114 | DWORD dwReserved2 ; 115 | } DDS_HEADER ; 116 | string read_DDS_HEADER(DDS_HEADER &in) { 117 | local string out; 118 | SPrintf(out, "%dx%d %s", in.dwWidth, in.dwHeight, read_DDS_PIXELFORMAT(in.ddspf)); 119 | return out; 120 | } 121 | string read_DDS_FLAGS(DDS_FLAGS &in) { 122 | local string out; 123 | if (in.CAPS) out += "CAPS "; 124 | if (in.HEIGHT) out += "HEIGHT "; 125 | if (in.WIDTH) out += "WIDTH "; 126 | if (in.PITCH) out += "PITCH "; 127 | if (in.PIXELFORMAT) out += "PIXELFORMAT "; 128 | if (in.MIPMAPCOUNT) out += "MIPMAPCOUNT "; 129 | if (in.LINEARSIZE) out += "LINEARSIZE "; 130 | if (in.DEPTH) out += "DEPTH "; 131 | return out; 132 | } 133 | string read_DDS_CAPS(DDS_CAPS &in) { 134 | local string out; 135 | if (in.COMPLEX) out += "COMPLEX "; 136 | if (in.TEXTURE) out += "TEXTURE "; 137 | if (in.MIPMAP) out += "MIPMAP "; 138 | return out; 139 | } 140 | string read_DDS_CAPS2(DDS_CAPS2 &in) { 141 | local string out; 142 | if (in.CUBEMAP) out += "CUBEMAP "; 143 | if (in.CUBEMAP_POSITIVEX) out += "CUBEMAP_POSITIVEX "; 144 | if (in.CUBEMAP_NEGATIVEX) out += "CUBEMAP_NEGATIVEX "; 145 | if (in.CUBEMAP_POSITIVEY) out += "CUBEMAP_POSITIVEY "; 146 | if (in.CUBEMAP_NEGATIVEY) out += "CUBEMAP_NEGATIVEY "; 147 | if (in.CUBEMAP_POSITIVEZ) out += "CUBEMAP_POSITIVEZ "; 148 | if (in.CUBEMAP_NEGATIVEZ) out += "CUBEMAP_NEGATIVEZ "; 149 | if (in.VOLUME) out += "VOLUME "; 150 | return out; 151 | } 152 | 153 | typedef enum { 154 | DXGI_FORMAT_UNKNOWN = 0, 155 | DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, 156 | DXGI_FORMAT_R32G32B32A32_FLOAT = 2, 157 | DXGI_FORMAT_R32G32B32A32_UINT = 3, 158 | DXGI_FORMAT_R32G32B32A32_SINT = 4, 159 | DXGI_FORMAT_R32G32B32_TYPELESS = 5, 160 | DXGI_FORMAT_R32G32B32_FLOAT = 6, 161 | DXGI_FORMAT_R32G32B32_UINT = 7, 162 | DXGI_FORMAT_R32G32B32_SINT = 8, 163 | DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, 164 | DXGI_FORMAT_R16G16B16A16_FLOAT = 10, 165 | DXGI_FORMAT_R16G16B16A16_UNORM = 11, 166 | DXGI_FORMAT_R16G16B16A16_UINT = 12, 167 | DXGI_FORMAT_R16G16B16A16_SNORM = 13, 168 | DXGI_FORMAT_R16G16B16A16_SINT = 14, 169 | DXGI_FORMAT_R32G32_TYPELESS = 15, 170 | DXGI_FORMAT_R32G32_FLOAT = 16, 171 | DXGI_FORMAT_R32G32_UINT = 17, 172 | DXGI_FORMAT_R32G32_SINT = 18, 173 | DXGI_FORMAT_R32G8X24_TYPELESS = 19, 174 | DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, 175 | DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, 176 | DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, 177 | DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, 178 | DXGI_FORMAT_R10G10B10A2_UNORM = 24, 179 | DXGI_FORMAT_R10G10B10A2_UINT = 25, 180 | DXGI_FORMAT_R11G11B10_FLOAT = 26, 181 | DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, 182 | DXGI_FORMAT_R8G8B8A8_UNORM = 28, 183 | DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, 184 | DXGI_FORMAT_R8G8B8A8_UINT = 30, 185 | DXGI_FORMAT_R8G8B8A8_SNORM = 31, 186 | DXGI_FORMAT_R8G8B8A8_SINT = 32, 187 | DXGI_FORMAT_R16G16_TYPELESS = 33, 188 | DXGI_FORMAT_R16G16_FLOAT = 34, 189 | DXGI_FORMAT_R16G16_UNORM = 35, 190 | DXGI_FORMAT_R16G16_UINT = 36, 191 | DXGI_FORMAT_R16G16_SNORM = 37, 192 | DXGI_FORMAT_R16G16_SINT = 38, 193 | DXGI_FORMAT_R32_TYPELESS = 39, 194 | DXGI_FORMAT_D32_FLOAT = 40, 195 | DXGI_FORMAT_R32_FLOAT = 41, 196 | DXGI_FORMAT_R32_UINT = 42, 197 | DXGI_FORMAT_R32_SINT = 43, 198 | DXGI_FORMAT_R24G8_TYPELESS = 44, 199 | DXGI_FORMAT_D24_UNORM_S8_UINT = 45, 200 | DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, 201 | DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, 202 | DXGI_FORMAT_R8G8_TYPELESS = 48, 203 | DXGI_FORMAT_R8G8_UNORM = 49, 204 | DXGI_FORMAT_R8G8_UINT = 50, 205 | DXGI_FORMAT_R8G8_SNORM = 51, 206 | DXGI_FORMAT_R8G8_SINT = 52, 207 | DXGI_FORMAT_R16_TYPELESS = 53, 208 | DXGI_FORMAT_R16_FLOAT = 54, 209 | DXGI_FORMAT_D16_UNORM = 55, 210 | DXGI_FORMAT_R16_UNORM = 56, 211 | DXGI_FORMAT_R16_UINT = 57, 212 | DXGI_FORMAT_R16_SNORM = 58, 213 | DXGI_FORMAT_R16_SINT = 59, 214 | DXGI_FORMAT_R8_TYPELESS = 60, 215 | DXGI_FORMAT_R8_UNORM = 61, 216 | DXGI_FORMAT_R8_UINT = 62, 217 | DXGI_FORMAT_R8_SNORM = 63, 218 | DXGI_FORMAT_R8_SINT = 64, 219 | DXGI_FORMAT_A8_UNORM = 65, 220 | DXGI_FORMAT_R1_UNORM = 66, 221 | DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, 222 | DXGI_FORMAT_R8G8_B8G8_UNORM = 68, 223 | DXGI_FORMAT_G8R8_G8B8_UNORM = 69, 224 | DXGI_FORMAT_BC1_TYPELESS = 70, 225 | DXGI_FORMAT_BC1_UNORM = 71, 226 | DXGI_FORMAT_BC1_UNORM_SRGB = 72, 227 | DXGI_FORMAT_BC2_TYPELESS = 73, 228 | DXGI_FORMAT_BC2_UNORM = 74, 229 | DXGI_FORMAT_BC2_UNORM_SRGB = 75, 230 | DXGI_FORMAT_BC3_TYPELESS = 76, 231 | DXGI_FORMAT_BC3_UNORM = 77, 232 | DXGI_FORMAT_BC3_UNORM_SRGB = 78, 233 | DXGI_FORMAT_BC4_TYPELESS = 79, 234 | DXGI_FORMAT_BC4_UNORM = 80, 235 | DXGI_FORMAT_BC4_SNORM = 81, 236 | DXGI_FORMAT_BC5_TYPELESS = 82, 237 | DXGI_FORMAT_BC5_UNORM = 83, 238 | DXGI_FORMAT_BC5_SNORM = 84, 239 | DXGI_FORMAT_B5G6R5_UNORM = 85, 240 | DXGI_FORMAT_B5G5R5A1_UNORM = 86, 241 | DXGI_FORMAT_B8G8R8A8_UNORM = 87, 242 | DXGI_FORMAT_B8G8R8X8_UNORM = 88, 243 | DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, 244 | DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, 245 | DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, 246 | DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, 247 | DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, 248 | DXGI_FORMAT_BC6H_TYPELESS = 94, 249 | DXGI_FORMAT_BC6H_UF16 = 95, 250 | DXGI_FORMAT_BC6H_SF16 = 96, 251 | DXGI_FORMAT_BC7_TYPELESS = 97, 252 | DXGI_FORMAT_BC7_UNORM = 98, 253 | DXGI_FORMAT_BC7_UNORM_SRGB = 99, 254 | DXGI_FORMAT_AYUV = 100, 255 | DXGI_FORMAT_Y410 = 101, 256 | DXGI_FORMAT_Y416 = 102, 257 | DXGI_FORMAT_NV12 = 103, 258 | DXGI_FORMAT_P010 = 104, 259 | DXGI_FORMAT_P016 = 105, 260 | DXGI_FORMAT_420_OPAQUE = 106, 261 | DXGI_FORMAT_YUY2 = 107, 262 | DXGI_FORMAT_Y210 = 108, 263 | DXGI_FORMAT_Y216 = 109, 264 | DXGI_FORMAT_NV11 = 110, 265 | DXGI_FORMAT_AI44 = 111, 266 | DXGI_FORMAT_IA44 = 112, 267 | DXGI_FORMAT_P8 = 113, 268 | DXGI_FORMAT_A8P8 = 114, 269 | DXGI_FORMAT_B4G4R4A4_UNORM = 115, 270 | DXGI_FORMAT_P208 = 130, 271 | DXGI_FORMAT_V208 = 131, 272 | DXGI_FORMAT_V408 = 132, 273 | DXGI_FORMAT_FORCE_UINT = 0xffffffff 274 | } DXGI_FORMAT; 275 | 276 | typedef enum { 277 | D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2, 278 | D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3, 279 | D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4 280 | } D3D10_RESOURCE_DIMENSION; 281 | 282 | typedef struct { 283 | DXGI_FORMAT dxgiFormat; 284 | enum { 285 | TEXTURE1D = 2, 286 | TEXTURE2D = 3, 287 | TEXTURE3D = 4 288 | } resourceDimension; 289 | struct DDS10_MISC { 290 | UINT reserved: 2 ; 291 | UINT TEXTURECUBE: 1 ; 292 | UINT reserved: 29 ; 293 | } miscFlag ; 294 | UINT arraySize ; 295 | struct DDS10_MISC2 { 296 | enum { 297 | ALPHA_MODE_UNKNOWN, 298 | ALPHA_MODE_STRAIGHT, 299 | ALPHA_MODE_PREMULTIPLIED, 300 | ALPHA_MODE_OPAQUE, 301 | ALPHA_MODE_CUSTOM 302 | } alpha: 3; 303 | UINT reserved: 29 ; 304 | } miscFlags2 ; 305 | } DDS_HEADER_DXT10 ; 306 | string read_DDS_HEADER_DXT10(DDS_HEADER_DXT10 &in) { 307 | return EnumToString(in.dxgiFormat); 308 | } 309 | string read_DDS10_MISC(DDS10_MISC &in) { 310 | local string out; 311 | if (in.TEXTURECUBE) out += "TEXTURECUBE "; 312 | return out; 313 | } 314 | string read_DDS10_MISC2(DDS10_MISC2 &in) { 315 | return EnumToString(in.alpha); 316 | } 317 | 318 | DisplayFormatHex(); 319 | LittleEndian(); 320 | 321 | Assert(ReadString(0, 4) == "DDS ", "Bad sig!"); 322 | 323 | SetBackColor(0xb0b0b0); 324 | char dwMagic[4]; 325 | 326 | DDS_HEADER header; 327 | 328 | if (header.ddspf.dwFlags.FOURCC && header.ddspf.dwFourCC == "DX10") { 329 | DDS_HEADER_DXT10 header10; 330 | } 331 | 332 | SetBackColor(0xffb0b0); 333 | if (header.dwFlags.LINEARSIZE) { 334 | UBYTE bdata[header.dwPitchOrLinearSize]; 335 | } else if (header.dwFlags.PITCH) { 336 | struct { 337 | UBYTE row[header.dwPitchOrLinearSize]; 338 | } bdata[header.dwHeight]; 339 | } 340 | 341 | SetBackColor(0xb0ffb0); 342 | if (!FEof()) { 343 | UBYTE bdata2[FileSize() - FTell()]; 344 | } 345 | -------------------------------------------------------------------------------- /010 Templates/DF.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: DF.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: DF File parser 8 | // Category: Archive 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | string read_Filename(char &in) { 15 | return in; 16 | } 17 | 18 | typedef struct { 19 | local quad cur_pos; 20 | uint Unknown; 21 | uint Unknown; 22 | uint Unknown; 23 | uint Data_Size ; 24 | string Filename; 25 | uchar Padding[512 - Strlen(Filename) - 1]; 26 | uint Unknown; 27 | uint Data_Offset; 28 | uint Padding; 29 | uint Padding; 30 | uint Padding; 31 | 32 | cur_pos = FTell(); 33 | FSeek(Data_Offset); 34 | 35 | SetBackColor(0xffc0c0); 36 | uchar Data[Data_Size]; 37 | SetBackColor(0xc0ffc0); 38 | 39 | FSeek(cur_pos); 40 | } FILE ; 41 | 42 | string READ_FILE(FILE &in) { 43 | return in.Filename; 44 | } 45 | 46 | typedef struct { 47 | uint File_Count ; 48 | uint Data_Offset; 49 | uint Padding; 50 | uint Padding; 51 | } HEADER; 52 | 53 | DisplayFormatHex(); 54 | LittleEndian(); 55 | 56 | local int i; 57 | 58 | SetBackColor(0xe0e0e0); 59 | HEADER h; 60 | 61 | SetBackColor(0xc0ffc0); 62 | for (i = 0; i < h.File_Count; i++) { 63 | FILE f; 64 | } 65 | -------------------------------------------------------------------------------- /010 Templates/ERF.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: ERF.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Aurora ERF file 8 | // Category: Archive 9 | // File Mask: *.erf 10 | // ID Bytes: 45 00 52 00 46 20 00 // ERF 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2012-06-01 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | local int file_encrypted; 17 | 18 | // UNICODE support 19 | // Thanks to Graeme Sweet for pointing this out! 20 | int CalcUnicodeLen() { 21 | local quad pos = FTell(); 22 | local quad base = pos; 23 | while ((ReadUShort(pos) != 0) && (pos - base < 65535)) { 24 | pos += 2; 25 | } 26 | return (pos - base + 2) / 2; 27 | } 28 | 29 | typedef struct { 30 | ushort s[CalcUnicodeLen()]; 31 | } zstringw ; 32 | 33 | string ReadUNICODE(zstringw &z) { 34 | local int len = sizeof(z.s) / 2; 35 | char s[len]; 36 | ConvertUNICODEToASCIIW(len, z.s, s); 37 | return s; 38 | } 39 | 40 | typedef struct { 41 | ushort s[4]; 42 | } stringw4 ; 43 | 44 | string ReadUNICODE4(stringw4 &z) { 45 | local int len = 4; 46 | char s[len]; 47 | ConvertUNICODEToASCIIW(len, z.s, s); 48 | return s; 49 | } 50 | 51 | typedef struct { 52 | ushort s[32]; 53 | } zstringw32 ; 54 | 55 | string ReadUNICODE32(zstringw32 &z) { 56 | local int len = sizeof(z.s) / 2; 57 | char s[len]; 58 | ConvertUNICODEToASCIIW(len, z.s, s); 59 | return s; 60 | } 61 | 62 | typedef struct { 63 | local uint cur_offset; 64 | zstringw32 file_name; 65 | uint file_offset; 66 | uint file_size; 67 | if (file_encrypted) { 68 | uint unknown; 69 | } 70 | 71 | if (file_size > 0) { 72 | cur_offset = FTell(); 73 | 74 | FSeek(file_offset); 75 | 76 | SetBackColor(0xc0ffff); 77 | ubyte Data[file_size]; 78 | SetBackColor(0xc0ffc0); 79 | 80 | FSeek(cur_offset); 81 | } 82 | } FILE_ENTRY ; 83 | 84 | string FILE_ENTRYread(FILE_ENTRY &in) { 85 | return ReadUNICODE32(in.file_name); 86 | } 87 | 88 | typedef struct { 89 | local int i; 90 | 91 | stringw4 type; 92 | if (type.s[0] != 0x45 || type.s[1] != 0x52 || type.s[2] != 0x46 || type.s[3] != 0x20) { 93 | Warning("Invalid signature"); 94 | Exit(-1); 95 | } 96 | stringw4 version; 97 | if (version.s[0] != 0x56 || version.s[1] != 0x32 || version.s[2] != 0x2e || !(version.s[3] == 0x30 || version.s[3] == 0x32)) { 98 | Warning("Unknown version"); 99 | //Exit(-1); 100 | } 101 | file_encrypted = version.s[3] == 0x32; 102 | 103 | uint file_count; 104 | uint build_year ; 105 | uint build_day ; 106 | uint desc_str_ref; 107 | 108 | if (file_encrypted) { 109 | uint unknown; 110 | uint unknown; 111 | uint key_md5[4]; 112 | } 113 | 114 | SetBackColor(0xc0ffc0); 115 | for (i = 0; i < file_count; i++) { 116 | FILE_ENTRY f; 117 | } 118 | SetBackColor(0xe0e0e0); 119 | } HEADER; 120 | 121 | DisplayFormatHex(); 122 | LittleEndian(); 123 | 124 | SetBackColor(0xe0e0e0); 125 | HEADER h; 126 | -------------------------------------------------------------------------------- /010 Templates/FDI.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: FDI.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: FDI disk image parser 8 | // Category: Drives 9 | // File Mask: *.fdi 10 | // ID Bytes: 46 6F 72 6D 61 74 74 65 64 20 44 69 73 6B 20 49 6D 61 67 65 20 66 69 6C 65 0D 0A // Formatted Disk Image file 11 | // History: 12 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.2 2016-03-16 Andrew McRae: Merge changes 14 | // 0.1 2016-03-04 Andrew McRae: Initial revision 15 | //------------------------------------------------ 16 | 17 | typedef uint64 u8; 18 | typedef uint32 u4; 19 | typedef uint16 u2; 20 | typedef ubyte u1; 21 | typedef int64 s8; 22 | typedef int32 s4; 23 | typedef int16 s2; 24 | typedef byte s1; 25 | 26 | typedef enum { 27 | T_48 = 0, T_67, T_96, T_100, T_135, T_192 28 | } TPI; 29 | 30 | typedef struct { 31 | char signature[25]; 32 | char nl0[2] ; 33 | char creator[30]; 34 | char nl1[2] ; 35 | char comment[80]; 36 | char eof[1] ; 37 | u1 version_hi ; 38 | u1 version_lo ; 39 | u2 ltrack ; 40 | u1 lhead ; 41 | enum { D_8 = 0, D_5_25, D_3_5, D_3 } type; 42 | u1 rotspeed ; 43 | u1 flags_res : 5 ; 44 | u1 flags_rev : 1; 45 | u1 flags_idx : 1; 46 | u1 flags_wp : 1; 47 | TPI tpi; 48 | TPI headwidth; 49 | u2 res ; 50 | u2 tracks[176]; 51 | u4 dataCRC; 52 | u4 headerCRC; 53 | } HEADER; 54 | string read_rotspeed(u1 rotspeed) { 55 | local string out; 56 | SPrintf(out, "%d rpm", rotspeed+128); 57 | return out; 58 | } 59 | 60 | typedef struct (quad _track, quad _head) { 61 | local quad track, head; 62 | local quad _pos; 63 | 64 | track = _track; 65 | head = _head; 66 | 67 | _pos = FTell(); 68 | 69 | FSeek((_track * ((quad)h.lhead + 1) + _head) * 2 + 0x98); 70 | SetBackColor(0xe0e0e0); 71 | u2 type: 8; 72 | u2 size: 8; 73 | 74 | SetBackColor(0xc0ffff); 75 | FSeek(_pos); 76 | u1 data[1] ; 77 | } TRACK_EMPTY ; 78 | string read_TRACK_EMPTY(TRACK_EMPTY &in) { 79 | local string out; 80 | SPrintf(out, "%2d %d", in.track, in.head); 81 | return out; 82 | } 83 | 84 | typedef struct (quad _track, quad _head) { 85 | local quad track, head; 86 | local quad _pos; 87 | 88 | track = _track; 89 | head = _head; 90 | 91 | Warning("Unknown track type at %d %d: %02x", track, head, _type); 92 | Printf("Unknown track type at %d %d: %02x\n", track, head, _type); 93 | 94 | _pos = FTell(); 95 | 96 | FSeek((_track * ((quad)h.lhead + 1) + _head) * 2 + 0x98); 97 | SetBackColor(0xe0e0e0); 98 | u2 type: 8; 99 | u2 size: 8; 100 | 101 | SetBackColor(0xc0ffff); 102 | FSeek(_pos); 103 | } TRACK ; 104 | string read_TRACK(TRACK &in) { 105 | local string out; 106 | SPrintf(out, "%2d %d %x", in.track, in.head, in.type); 107 | return out; 108 | } 109 | 110 | typedef struct { 111 | SetBackColor(0xb0e0b0); 112 | BitfieldDisablePadding(); 113 | enum { C_NONE = 0, C_HUFF, C_RES1, C_RES2 } comp: 2; 114 | u4 size: 22 ; 115 | BitfieldEnablePadding(); 116 | } PS_SIZE ; 117 | string read_PS_SIZE(PS_SIZE &in) { 118 | local string out; 119 | SPrintf(out, "%d %s", in.size, EnumToString(in.comp)); 120 | return out; 121 | } 122 | 123 | typedef struct (quad _size) { 124 | local quad _pos; 125 | if (_size > 0) { 126 | SetBackColor(0xd0ffd0); 127 | u1 sign_ext : 1; 128 | u1 low_bits : 7; 129 | u1 bits : 1; 130 | u1 high_bits : 7; 131 | u1 d[_size - 2]; 132 | } 133 | } HUFF; 134 | 135 | typedef struct (quad _track, quad _head) { 136 | local quad track, head; 137 | local quad _pos, _end; 138 | 139 | track = _track; 140 | head = _head; 141 | 142 | _pos = FTell(); 143 | 144 | FSeek((_track * ((quad)h.lhead + 1) + _head) * 2 + 0x98); 145 | SetBackColor(0xe0e0e0); 146 | u2 type: 2 ; 147 | u2 size: 14; 148 | 149 | FSeek(_pos); 150 | _end = _pos + size * 256; 151 | 152 | SetBackColor(0xb0e0b0); 153 | u4 numpulses ; 154 | PS_SIZE avg; 155 | PS_SIZE min; 156 | PS_SIZE max; 157 | PS_SIZE idx; 158 | 159 | SetBackColor(0xd0ffd0); 160 | if (avg.size > 0) { 161 | if (avg.comp == C_HUFF) { 162 | HUFF davg(avg.size); 163 | } else { 164 | u1 davg[avg.size]; 165 | } 166 | } 167 | if (min.size > 0) { 168 | if (min.comp == C_HUFF) { 169 | HUFF dmin(min.size); 170 | } else { 171 | u1 dmin[min.size]; 172 | } 173 | } 174 | if (max.size > 0) { 175 | if (max.comp == C_HUFF) { 176 | HUFF dmax(max.size); 177 | } else { 178 | u1 dmax[max.size]; 179 | } 180 | } 181 | if (idx.size > 0) { 182 | if (idx.comp == C_HUFF) { 183 | HUFF didx(idx.size); 184 | } else { 185 | u1 didx[idx.size]; 186 | } 187 | } 188 | 189 | if (_end - FTell() > 0) { 190 | SetBackColor(0xf0fff0); 191 | u1 padding[_end - FTell()] ; 192 | } 193 | } TRACK_PULSE ; 194 | string read_TRACK_PULSE(TRACK_PULSE &in) { 195 | local string out; 196 | SPrintf(out, "%2d %d", in.track, in.head); 197 | return out; 198 | } 199 | 200 | local int _t, _h, _type; 201 | local quad _pos; 202 | 203 | DisplayFormatHex(); 204 | BigEndian(); 205 | 206 | local char _sig[25]; 207 | ReadBytes(_sig, 0, 25); 208 | if (_sig != "Formatted Disk Image file") { 209 | Warning("Bad sig!"); 210 | Printf("Bad sig!\n"); 211 | return -1; 212 | } 213 | 214 | SetBackColor(0xc0c0c0); 215 | HEADER h; 216 | 217 | for (_t = 0; _t <= h.ltrack; _t++) { 218 | for (_h = 0; _h <= h.lhead; _h++) { 219 | _type = h.tracks[_t * (h.lhead + 1) + _h] >> 8; 220 | if (_type == 0) { 221 | _pos = FTell(); 222 | FSeek(_pos - 1); 223 | TRACK_EMPTY t(_t, _h); 224 | FSeek(_pos); 225 | } else if ((_type & 0xC0) == 0x80) { 226 | TRACK_PULSE t(_t, _h); 227 | } else { 228 | TRACK t(_t, _h); 229 | } 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /010 Templates/FSD.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: FSD.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: Parse FSD file 8 | // Category: Drives 9 | // File Mask: *.fsd 10 | // ID Bytes: 46 53 44 // FSD 11 | // History: 12 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.2 2016-03-10 Andrew McRae: Merge changes 14 | // 0.1 2016-03-08 Andrew McRae: Initial revision 15 | //------------------------------------------------ 16 | 17 | typedef uint64 u8; 18 | typedef uint32 u4; 19 | typedef uint16 u2; 20 | typedef ubyte u1; 21 | typedef int64 s8; 22 | typedef int32 s4; 23 | typedef int16 s2; 24 | typedef byte s1; 25 | 26 | typedef struct { 27 | local int date_y, release; 28 | 29 | u1 date_y_h : 3; 30 | u1 date_d : 5; 31 | u1 date_y_l : 8; 32 | u1 date_m : 4; 33 | u1 creator : 4; 34 | u1 release_l : 8; 35 | u1 unknown : 6 ; 36 | u1 release_h : 2; 37 | 38 | date_y = (int)date_y_h << 8 | date_y_l; 39 | release = (int)release_h << 8 | release_l; 40 | } CREATOR ; 41 | string read_CREATOR(CREATOR &in) { 42 | local string out; 43 | SPrintf(out, "%04d-%02d-%02d %d %d", in.date_y, in.date_m, in.date_d, in.creator, in.release); 44 | return out; 45 | } 46 | 47 | typedef struct { 48 | char sig[3]; 49 | CREATOR c; 50 | string title; 51 | u1 tracks ; 52 | } HEADER ; 53 | string read_HEADER(HEADER &in) { 54 | return in.title; 55 | } 56 | 57 | typedef enum { 58 | E_OK = 0, 59 | E_CRC = 0x0E, 60 | E_DELETED = 0x20 61 | } ERROR; 62 | 63 | typedef struct (int t, int s) { 64 | local int reported_size_actual, real_size_actual; 65 | 66 | SetBackColor(0xe0ffe0); 67 | u1 track_id ; 68 | u1 head_id ; 69 | u1 sector_id ; 70 | u1 reported_size; 71 | u1 real_size; 72 | ERROR error_code; 73 | 74 | if (reported_size > 8) { 75 | reported_size_actual = 0; 76 | } else { 77 | reported_size_actual = 1 << (7 + (int)reported_size); 78 | } 79 | real_size_actual = 1 << (7 + (int)real_size); 80 | 81 | SetBackColor(0xc0ffc0); 82 | u1 d[real_size_actual]; 83 | 84 | if (error_code == 0) { 85 | if (track_id != t || sector_id != s || head_id != 0 || reported_size != real_size) { 86 | _mismatch++; 87 | } else if (real_size != 1) { 88 | _nonstandard++; 89 | } else { 90 | _good++; 91 | } 92 | } else { 93 | if (error_code == 0x0e) { 94 | _crc++; 95 | } else if (error_code == 0x20) { 96 | _deleted++; 97 | } else { 98 | _unknown++; 99 | } 100 | } 101 | 102 | if (error_code != 0 || track_id != t || sector_id != s || head_id != 0 || reported_size != real_size) { 103 | Printf("%d,%d %d,%d,%d %d %d %s\n", t, s, track_id, head_id, sector_id, reported_size, real_size, EnumToString(error_code)); 104 | } 105 | } SECTOR ; 106 | string read_SECTOR(SECTOR &in) { 107 | local string out; 108 | SPrintf(out, "%2d,%2d,%2d %d %d %s (%02X)", in.track_id, in.head_id, in.sector_id, in.reported_size_actual, in.real_size_actual, EnumToString(in.error_code), in.error_code); 109 | return out; 110 | } 111 | 112 | typedef struct (int t, int s) { 113 | SetBackColor(0xe0e0ff); 114 | u1 track_id ; 115 | u1 head_id ; 116 | u1 sector_id ; 117 | u1 reported_size; 118 | 119 | _unreadable++; 120 | 121 | Printf("%d,%d %02X %02X %02X %02X UNFORMATTED\n", t, s, track_id, head_id, sector_id, reported_size); 122 | } SECTOR_UNREADABLE ; 123 | string read_SECTOR_UNREADABLE(SECTOR_UNREADABLE &in) { 124 | local string out; 125 | SPrintf(out, "%02X %02X %02X %02X", in.track_id, in.head_id, in.sector_id, in.reported_size); 126 | return out; 127 | } 128 | 129 | typedef struct (int t) { 130 | local int _i; 131 | 132 | SetBackColor(0xffc0c0); 133 | 134 | u1 track ; 135 | u1 sectors ; 136 | 137 | if (sectors) { 138 | enum { R_NO = 0, R_YES = 0xff } readable; 139 | 140 | if (readable == 0xff) { 141 | for (_i = 0; _i < sectors; _i++) { 142 | SECTOR s(t, _i); 143 | } 144 | } else { 145 | for (_i = 0; _i < sectors; _i++) { 146 | SECTOR_UNREADABLE s(t, _i); 147 | } 148 | } 149 | } else { 150 | local u1 readable = 0; 151 | _unformatted++; 152 | } 153 | } TRACK ; 154 | string read_TRACK(TRACK &in) { 155 | local string out; 156 | SPrintf(out, "%2d %2d%s", in.track, in.sectors, (in.readable == 0)?" *":""); 157 | return out; 158 | } 159 | 160 | local int _i; 161 | local int _unformatted, _unreadable, _crc, _deleted, _unknown, _good, _mismatch, _nonstandard; 162 | 163 | DisplayFormatHex(); 164 | LittleEndian(); 165 | 166 | local char _sig[3]; 167 | ReadBytes(_sig, 0, 3); 168 | if (_sig != "FSD") { 169 | Warning("Bad sig!"); 170 | Printf("Bad sig!\n"); 171 | return -1; 172 | } 173 | 174 | SetBackColor(0xc0c0c0); 175 | HEADER h; 176 | 177 | for (_i = 0; _i <= h.tracks; _i++) { 178 | TRACK t(_i); 179 | } 180 | 181 | Printf("Standard: %d sectors\nNonstandard: %d sectors\nMismatched: %d sectors\nCRC: %d sectors\nDeleted: %d sectors\nUnknown: %d sectors\nUnreadable: %d sectors\nUnformatted: %d tracks\n", _good, _nonstandard, _mismatch, _crc, _deleted, _unknown, _unreadable, _unformatted); 182 | -------------------------------------------------------------------------------- /010 Templates/FXO.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: FXO.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: binary DX FX 4/5 files 8 | // Category: Programming 9 | // File Mask: *.fxo 10 | // History: 11 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.2 2015-11-04 Andrew McRae: Merge changes 13 | // 0.1 2012-06-01 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | DisplayFormatHex(); 17 | 18 | typedef uint64 u8; 19 | typedef uint32 u4; 20 | typedef uint16 u2; 21 | typedef ubyte u1; 22 | typedef int64 s8; 23 | typedef int32 s4; 24 | typedef int16 s2; 25 | typedef byte s1; 26 | 27 | local quad _data_start; 28 | 29 | string read_sig(u4 &in) { 30 | local string out; 31 | local string ver; 32 | switch(in & 0xffff) { 33 | case 0x0901: 34 | ver = "fx_2_0"; 35 | break; 36 | case 0x1001: 37 | ver = "fx_4_0"; 38 | break; 39 | case 0x1011: 40 | ver = "fx_4_1"; 41 | break; 42 | case 0x2001: 43 | ver = "fx_5_0"; 44 | break; 45 | default: 46 | SPrintf(ver, "(%04X)", in & 0xffff); 47 | break; 48 | } 49 | SPrintf(out, "%s %s", IsBigEndian() ? "BE" : "LE", ver); 50 | return out; 51 | } 52 | 53 | typedef struct { 54 | u4 sig; 55 | u4 data_offset; 56 | } HEADER ; 57 | string read_HEADER(HEADER &in) { 58 | return read_sig(in.sig); 59 | } 60 | 61 | typedef struct { 62 | local quad _pos, _padding; 63 | 64 | u4 offset ; 65 | 66 | _pos = FTell(); 67 | FSeek(_data_start + offset); 68 | 69 | SetBackColor(0xffffc0); 70 | u4 size ; 71 | 72 | if (size) { 73 | SetBackColor(0xffff98); 74 | char n[size]; 75 | 76 | _padding = 4 - (FTell() & 3); 77 | if (_padding > 0 && _padding < 4) { 78 | SetForeColor(cGray); 79 | SetBackColor(0xffffff); 80 | u1 _p[_padding] ; 81 | SetForeColor(cBlack); 82 | } 83 | } else { 84 | local string n = ""; 85 | } 86 | FSeek(_pos); 87 | } D3DX_NAME ; 88 | string read_D3DX_NAME(D3DX_NAME &in) { 89 | local string out; 90 | if (in.size) { 91 | SPrintf(out, "'%s'", in.n); 92 | } else { 93 | out = ""; 94 | } 95 | return out; 96 | } 97 | 98 | typedef enum { 99 | SYMTYPE_VOID, 100 | SYMTYPE_BOOL, 101 | SYMTYPE_INT, 102 | SYMTYPE_FLOAT, 103 | SYMTYPE_STRING, 104 | SYMTYPE_TEXTURE, 105 | SYMTYPE_TEXTURE1D, 106 | SYMTYPE_TEXTURE2D, 107 | SYMTYPE_TEXTURE3D, 108 | SYMTYPE_TEXTURECUBE, 109 | SYMTYPE_SAMPLER, 110 | SYMTYPE_SAMPLER1D, 111 | SYMTYPE_SAMPLER2D, 112 | SYMTYPE_SAMPLER3D, 113 | SYMTYPE_SAMPLERCUBE, 114 | SYMTYPE_PIXELSHADER, 115 | SYMTYPE_VERTEXSHADER, 116 | SYMTYPE_PIXELFRAGMENT, 117 | SYMTYPE_VERTEXFRAGMENT, 118 | SYMTYPE_UNSUPPORTED 119 | } D3DX_SYMTYPE; 120 | 121 | typedef enum { 122 | SYMCLASS_SCALAR, 123 | SYMCLASS_VECTOR, 124 | SYMCLASS_MATRIX_ROWS, 125 | SYMCLASS_MATRIX_COLUMNS, 126 | SYMCLASS_OBJECT, 127 | SYMCLASS_STRUCT 128 | } D3DX_SYMCLASS; 129 | 130 | typedef enum 131 | { 132 | SAMP_UNKNOWN0, 133 | SAMP_UNKNOWN1, 134 | SAMP_UNKNOWN2, 135 | SAMP_UNKNOWN3, 136 | SAMP_TEXTURE, 137 | SAMP_ADDRESSU, 138 | SAMP_ADDRESSV, 139 | SAMP_ADDRESSW, 140 | SAMP_BORDERCOLOR, 141 | SAMP_MAGFILTER, 142 | SAMP_MINFILTER, 143 | SAMP_MIPFILTER, 144 | SAMP_MIPMAPLODBIAS, 145 | SAMP_MAXMIPLEVEL, 146 | SAMP_MAXANISOTROPY, 147 | SAMP_SRGBTEXTURE, 148 | SAMP_ELEMENTINDEX, 149 | SAMP_DMAPOFFSET 150 | } D3DX_EFFECT_SAMPLER; 151 | 152 | struct D3DX_EFFECT_VALUE; 153 | typedef struct { 154 | D3DX_EFFECT_SAMPLER stype: 5; 155 | u4 unknown: 27; 156 | u4 unknown; 157 | D3DX_EFFECT_VALUE value; 158 | } D3DX_VALUE_SAMPLER ; 159 | 160 | typedef struct { 161 | local quad _pos; 162 | 163 | u4 typedef_offset ; 164 | u4 value_offset ; 165 | 166 | _pos = FTell(); 167 | FSeek(_data_start + typedef_offset); 168 | 169 | SetBackColor(0xc0c0ff); 170 | D3DX_SYMTYPE type; 171 | D3DX_SYMCLASS class; 172 | D3DX_NAME name; 173 | SetBackColor(0xc0c0ff); 174 | D3DX_NAME semantic; 175 | SetBackColor(0xc0c0ff); 176 | u4 element_count ; 177 | 178 | switch(class) { 179 | case SYMCLASS_STRUCT: 180 | Warning("SYMCLASS_STRUCT not supported"); 181 | Printf("SYMCLASS_STRUCT not supported\n"); 182 | break; 183 | case SYMCLASS_OBJECT: 184 | if (type == SYMTYPE_SAMPLER || type == SYMTYPE_SAMPLER1D || type == SYMTYPE_SAMPLER2D || type == SYMTYPE_SAMPLER3D) { 185 | FSeek(_data_start + value_offset); 186 | SetBackColor(0x9898ff); 187 | u4 state_count ; 188 | if (state_count) { 189 | D3DX_VALUE_SAMPLER s[state_count]; 190 | } 191 | } else { 192 | local u4 object_count = 1; 193 | if (element_count) { 194 | object_count = element_count; 195 | } 196 | FSeek(_data_start + value_offset); 197 | SetBackColor(0x9898ff); 198 | u4 v[object_count]; 199 | } 200 | break; 201 | default: 202 | local u4 value_count = 1; 203 | if (element_count) { 204 | value_count = element_count; 205 | } 206 | u4 column_count ; 207 | u4 row_count ; 208 | if (column_count * row_count) { 209 | FSeek(_data_start + value_offset); 210 | SetBackColor(0x9898ff); 211 | if (type == SYMTYPE_FLOAT) { 212 | float v[column_count * row_count * value_count]; 213 | } else { 214 | u4 v[column_count * row_count * value_count]; 215 | } 216 | } 217 | break; 218 | } 219 | 220 | FSeek(_pos); 221 | } D3DX_EFFECT_VALUE ; 222 | string read_D3DX_EFFECT_VALUE(D3DX_EFFECT_VALUE &in) { 223 | local string out; 224 | SPrintf(out, "%s %s %s", read_D3DX_NAME(in.name), EnumToString(in.class), EnumToString(in.type)); 225 | return out; 226 | } 227 | 228 | typedef struct { 229 | D3DX_EFFECT_VALUE value; 230 | u4 flags; 231 | u4 annotation_count ; 232 | 233 | if (annotation_count) { 234 | D3DX_EFFECT_VALUE a[annotation_count]; 235 | } 236 | } D3DX_PARAMETER ; 237 | string read_D3DX_PARAMETER(D3DX_PARAMETER &in) { 238 | return read_D3DX_EFFECT_VALUE(in.value); 239 | } 240 | 241 | typedef enum { 242 | RS_ZENABLE, 243 | RS_FILLMODE, 244 | RS_SHADEMODE, 245 | RS_ZWRITEENABLE, 246 | RS_ALPHATESTENABLE, 247 | RS_LASTPIXEL, 248 | RS_SRCBLEND, 249 | RS_DESTBLEND, 250 | RS_CULLMODE, 251 | RS_ZFUNC, 252 | RS_ALPHAREF, 253 | RS_ALPHAFUNC, 254 | RS_DITHERENABLE, 255 | RS_ALPHABLENDENABLE, 256 | RS_FOGENABLE, 257 | RS_SPECULARENABLE, 258 | RS_FOGCOLOR, 259 | RS_FOGTABLEMODE, 260 | RS_FOGSTART, 261 | RS_FOGEND, 262 | RS_FOGDENSITY, 263 | RS_RANGEFOGENABLE, 264 | RS_STENCILENABLE, 265 | RS_STENCILFAIL, 266 | RS_STENCILZFAIL, 267 | RS_STENCILPASS, 268 | RS_STENCILFUNC, 269 | RS_STENCILREF, 270 | RS_STENCILMASK, 271 | RS_STENCILWRITEMASK, 272 | RS_TEXTUREFACTOR, 273 | RS_WRAP0, 274 | RS_WRAP1, 275 | RS_WRAP2, 276 | RS_WRAP3, 277 | RS_WRAP4, 278 | RS_WRAP5, 279 | RS_WRAP6, 280 | RS_WRAP7, 281 | RS_WRAP8, 282 | RS_WRAP9, 283 | RS_WRAP10, 284 | RS_WRAP11, 285 | RS_WRAP12, 286 | RS_WRAP13, 287 | RS_WRAP14, 288 | RS_WRAP15, 289 | RS_CLIPPING, 290 | RS_LIGHTING, 291 | RS_AMBIENT, 292 | RS_FOGVERTEXMODE, 293 | RS_COLORVERTEX, 294 | RS_LOCALVIEWER, 295 | RS_NORMALIZENORMALS, 296 | RS_DIFFUSEMATERIALSOURCE, 297 | RS_SPECULARMATERIALSOURCE, 298 | RS_AMBIENTMATERIALSOURCE, 299 | RS_EMISSIVEMATERIALSOURCE, 300 | RS_VERTEXBLEND, 301 | RS_CLIPPLANEENABLE, 302 | RS_POINTSIZE, 303 | RS_POINTSIZE_MIN, 304 | RS_POINTSPRITEENABLE, 305 | RS_POINTSCALEENABLE, 306 | RS_POINTSCALE_A, 307 | RS_POINTSCALE_B, 308 | RS_POINTSCALE_C, 309 | RS_MULTISAMPLEANTIALIAS, 310 | RS_MULTISAMPLEMASK, 311 | RS_PATCHEDGESTYLE, 312 | RS_DEBUGMONITORTOKEN, 313 | RS_POINTSIZE_MAX, 314 | RS_INDEXEDVERTEXBLENDENABLE, 315 | RS_COLORWRITEENABLE, 316 | RS_TWEENFACTOR, 317 | RS_BLENDOP, 318 | RS_POSITIONDEGREE, 319 | RS_NORMALDEGREE, 320 | RS_SCISSORTESTENABLE, 321 | RS_SLOPESCALEDEPTHBIAS, 322 | RS_ANTIALIASEDLINEENABLE, 323 | RS_MINTESSELLATIONLEVEL, 324 | RS_MAXTESSELLATIONLEVEL, 325 | RS_ADAPTIVETESS_X, 326 | RS_ADAPTIVETESS_Y, 327 | RS_ADAPTIVETESS_Z, 328 | RS_ADAPTIVETESS_W, 329 | RS_ENABLEADAPTIVETESSELLATION, 330 | RS_TWOSIDEDSTENCILMODE, 331 | RS_CCW_STENCILFAIL, 332 | RS_CCW_STENCILZFAIL, 333 | RS_CCW_STENCILPASS, 334 | RS_CCW_STENCILFUNC, 335 | RS_COLORWRITEENABLE1, 336 | RS_COLORWRITEENABLE2, 337 | RS_COLORWRITEENABLE3, 338 | RS_BLENDFACTOR, 339 | RS_SRGBWRITEENABLE, 340 | RS_DEPTHBIAS, 341 | RS_SEPARATEALPHABLENDENABLE, 342 | RS_SRCBLENDALPHA, 343 | RS_DESTBLENDALPHA, 344 | RS_BLENDOPALPHA, 345 | RS_VERTEXSHADER = 146, 346 | RS_PIXELSHADER = 147 347 | } D3DX_RENDERSTATE; 348 | 349 | typedef struct { 350 | D3DX_RENDERSTATE operation; 351 | s4 index ; 352 | D3DX_EFFECT_VALUE value; 353 | } D3DX_STATE ; 354 | 355 | typedef struct { 356 | D3DX_NAME name; 357 | u4 annotation_count ; 358 | u4 state_count ; 359 | 360 | if (annotation_count) { 361 | D3DX_EFFECT_VALUE a[annotation_count]; 362 | } 363 | 364 | if (state_count) { 365 | D3DX_STATE s[state_count]; 366 | } 367 | } D3DX_PASS ; 368 | string read_D3DX_PASS(D3DX_PASS &in) { 369 | return read_D3DX_NAME(in.name); 370 | } 371 | 372 | typedef struct { 373 | D3DX_NAME name; 374 | u4 annotation_count ; 375 | u4 pass_count ; 376 | 377 | if (annotation_count) { 378 | D3DX_EFFECT_VALUE a[annotation_count]; 379 | } 380 | 381 | if (pass_count) { 382 | D3DX_PASS p[pass_count]; 383 | } 384 | } D3DX_TECHNIQUE ; 385 | string read_D3DX_TECHNIQUE(D3DX_TECHNIQUE &in) { 386 | return read_D3DX_NAME(in.name); 387 | } 388 | 389 | typedef struct { 390 | s4 index ; 391 | u4 size ; 392 | if (size) { 393 | SetBackColor(0xb0ffb0); 394 | u1 data[size]; 395 | } 396 | } D3DX_SMALL ; 397 | 398 | typedef struct { 399 | s4 technique_index ; 400 | s4 index ; 401 | s4 element_index ; 402 | s4 state_index ; 403 | u4 usage; 404 | u4 size ; 405 | if (size) { 406 | SetBackColor(0xb0ffb0); 407 | u1 data[size]; 408 | } 409 | } D3DX_LARGE ; 410 | 411 | typedef struct { 412 | local int i, _padding; 413 | 414 | u4 parameter_count ; 415 | u4 technique_count ; 416 | u4 unknown_count ; 417 | u4 object_count ; 418 | 419 | if (parameter_count) { 420 | D3DX_PARAMETER p[parameter_count]; 421 | } 422 | 423 | if (technique_count) { 424 | D3DX_TECHNIQUE t[technique_count]; 425 | } 426 | 427 | u4 small_count ; 428 | u4 large_count ; 429 | 430 | if (small_count) { 431 | SetBackColor(0xd0ffd0); 432 | D3DX_SMALL s[small_count]; 433 | } 434 | 435 | for (i = 0; i < large_count; i++) { 436 | SetBackColor(0xd0ffd0); 437 | D3DX_LARGE r; 438 | 439 | _padding = 4 - (FTell() & 3); 440 | if (_padding > 0 && _padding < 4) { 441 | SetForeColor(cGray); 442 | SetBackColor(0xffffff); 443 | u1 _p[_padding] ; 444 | SetForeColor(cBlack); 445 | } 446 | } 447 | } D3DX_EFFECT ; 448 | 449 | local u4 _sig, _ver; 450 | LittleEndian(); 451 | _sig = ReadUInt(0); 452 | 453 | if ((_sig & 0xffff0000) == 0xfeff0000) { 454 | LittleEndian(); 455 | } else if ((_sig & 0xffff) == 0xfffe) { 456 | BigEndian(); 457 | _sig = ReadUInt(0); 458 | Warning("BigEndian"); 459 | } else { 460 | Warning("Bad sig!"); 461 | Printf("Bad sig!\n"); 462 | return -1; 463 | } 464 | 465 | _ver = _sig & 0xffff; 466 | if (_ver > 0x0901) { 467 | Warning("Unsupported version!"); 468 | Printf("Unsupported version! %04X\n", _ver); 469 | return -1; 470 | } 471 | 472 | SetBackColor(0xc0c0c0); 473 | HEADER h; 474 | 475 | SetBackColor(0xf0f0f0); 476 | _data_start = FTell(); 477 | FSeek(_data_start + h.data_offset); 478 | 479 | SetBackColor(0xffd0d0); 480 | D3DX_EFFECT e; 481 | -------------------------------------------------------------------------------- /010 Templates/FezFX.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: FezFX.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Fez MonoGame v5 Effect file 8 | // Category: Programming 9 | // File Mask: *.fxo 10 | // History: 11 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.1 2015-01-21 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | typedef uint64 u8; 16 | typedef uint32 u4; 17 | typedef uint16 u2; 18 | typedef ubyte u1; 19 | typedef int64 s8; 20 | typedef int32 s4; 21 | typedef int16 s2; 22 | typedef byte s1; 23 | 24 | typedef struct { 25 | local int v = 0; 26 | local int shift = 0; 27 | SetBackColor(0xd8d8d8); 28 | do { 29 | u1 val; 30 | v |= (val & 0x7F) << shift; 31 | shift += 7; 32 | } while (val & 0x80); 33 | } EncodedInt ; 34 | string read_EncodedInt(EncodedInt &in) { 35 | local string out; 36 | SPrintf(out, "%Xh", in.v); 37 | return out; 38 | } 39 | 40 | typedef struct { 41 | EncodedInt length; 42 | SetBackColor(0xc0c0c0); 43 | if (length.v) { 44 | char v[length.v]; 45 | } else { 46 | local string v = ""; 47 | } 48 | } EncodedStr ; 49 | string read_EncodedStr(EncodedStr &in) { 50 | return in.v; 51 | } 52 | 53 | typedef struct { 54 | u4 Signature; 55 | u1 Version; 56 | u1 Profile; 57 | } HEADER ; 58 | string read_HEADER(HEADER &in) { 59 | local string out; 60 | local string profile; 61 | switch(in.Profile) { 62 | case 0: 63 | profile = "GL"; 64 | break; 65 | case 1: 66 | profile = "DX"; 67 | break; 68 | default: 69 | SPrintf(profile, "(%d)", in.Profile); 70 | break; 71 | } 72 | SPrintf(out, "MGFX v%d %s", in.Version, profile); 73 | return out; 74 | } 75 | 76 | typedef struct { 77 | u1 p; 78 | u2 o; 79 | } CBParam; 80 | 81 | typedef struct { 82 | local int i; 83 | 84 | EncodedStr name; 85 | u2 size; 86 | 87 | u1 pCount ; 88 | if (pCount) { 89 | CBParam cbp[pCount]; 90 | } 91 | } ConstantBuffer ; 92 | string read_ConstantBuffer(ConstantBuffer &in) { 93 | return in.name.v; 94 | } 95 | 96 | typedef enum { 97 | TAM_Wrap, 98 | TAM_Clamp, 99 | TAM_Mirror 100 | } TextureAddressMode; 101 | 102 | typedef struct { 103 | enum { 104 | ST_2D, 105 | ST_Cube, 106 | ST_Volume, 107 | ST_1D 108 | } type; 109 | u1 textureSlot ; 110 | u1 samplerSlot ; 111 | u1 hasState; 112 | if (hasState) { 113 | TextureAddressMode state_AddressU; 114 | TextureAddressMode state_AddressV; 115 | TextureAddressMode state_AddressW; 116 | u1 state_Filter; 117 | u4 state_MaxAnisotropy; 118 | u4 state_MaxMipLevel; 119 | float state_MipMapLevelOfDetailBias; 120 | } 121 | EncodedStr name; 122 | u1 parameter ; 123 | } Sampler ; 124 | string read_Sampler(Sampler &in) { 125 | return in.name.v; 126 | } 127 | 128 | typedef struct { 129 | EncodedStr name; 130 | enum { 131 | VEU_Position, 132 | VEU_Color, 133 | VEU_TextureCoordinate, 134 | VEU_Normal, 135 | VEU_Binormal, 136 | VEU_Tangent, 137 | VEU_BlendIndices, 138 | VEU_BlendWeight, 139 | VEU_Depth, 140 | VEU_Fog, 141 | VEU_PointSize, 142 | VEU_Sample, 143 | VEU_TessellateFactor 144 | } usage; 145 | u1 index ; 146 | u2 format; 147 | } Attribute ; 148 | string read_Attribute(Attribute &in) { 149 | return in.name.v; 150 | } 151 | 152 | typedef struct { 153 | local int i; 154 | 155 | u1 isVertex; 156 | u2 length ; 157 | SetBackColor(0x80ff80); 158 | char bytecode[length]; 159 | SetBackColor(0xd0ffd0); 160 | 161 | u1 sCount ; 162 | if (sCount) { 163 | Sampler s[sCount]; 164 | } 165 | 166 | u1 cbCount ; 167 | if (cbCount) { 168 | u1 cBuffer[cbCount]; 169 | } 170 | 171 | u1 aCount ; 172 | if (aCount) { 173 | Attribute a[aCount]; 174 | } 175 | } Shader ; 176 | string read_Shader(Shader &in) { 177 | if (in.isVertex) { 178 | return "VS"; 179 | } else { 180 | return "PS"; 181 | } 182 | } 183 | 184 | struct Parameter; 185 | typedef struct { 186 | local int i; 187 | 188 | enum { 189 | PC_Scalar, 190 | PC_Vector, 191 | C_Matrix, 192 | PC_Object, 193 | PC_Struct 194 | } class; 195 | enum { 196 | PT_Void, 197 | PT_Bool, 198 | PT_Int32, 199 | PT_Single, 200 | PT_String, 201 | PT_Texture, 202 | PT_Texture1D, 203 | PT_Texture2D, 204 | PT_Texture3D, 205 | PT_TextureCube 206 | } type; 207 | EncodedStr name; 208 | EncodedStr semantic; 209 | u1 aCount ; 210 | u1 rowCount; 211 | u1 columnCount; 212 | u1 registerCount; 213 | 214 | u1 eCount ; 215 | if (eCount) { 216 | Parameter elements[eCount]; 217 | } 218 | 219 | u1 smCount ; 220 | if (smCount) { 221 | Parameter structMembers[smCount]; 222 | } 223 | 224 | if (eCount == 0 && smCount == 0 && rowCount > 0 && columnCount > 0) { 225 | float data[rowCount * columnCount]; 226 | } 227 | } Parameter ; 228 | string read_Parameter(Parameter &in) { 229 | return in.name.v; 230 | } 231 | 232 | typedef enum { 233 | BF_Add, 234 | BF_Subtract, 235 | BF_ReverseSubtract, 236 | BF_Max, 237 | BF_Min 238 | } BlendFunction; 239 | 240 | typedef enum { 241 | B_One, 242 | B_Zero, 243 | B_SourceColor, 244 | B_InverseSourceColor, 245 | B_SourceAlpha, 246 | B_InverseSourceAlpha, 247 | B_DestinationColor, 248 | B_InverseDestinationColor, 249 | B_DestinationAlpha, 250 | B_InverseDestinationAlpha, 251 | B_BlendFactor, 252 | B_InverseBlendFactor, 253 | B_SourceAlphaSaturation 254 | } Blend; 255 | 256 | typedef enum { 257 | SO_Keep, 258 | SO_Zero, 259 | SO_Replace, 260 | SO_Increment, 261 | SO_Decrement, 262 | SO_IncrementSaturation, 263 | SO_DecrementSaturation, 264 | SO_Invert 265 | } StencilOperation; 266 | 267 | typedef enum { 268 | SCF_Always, 269 | SCF_Never, 270 | SCF_Less, 271 | SCF_LessEqual, 272 | SCF_Equal, 273 | SCF_GreaterEqual, 274 | SCF_Greater, 275 | SCF_NotEqual 276 | } CompareFunction; 277 | 278 | typedef enum { 279 | CM_None, 280 | CM_CullClockwiseFace, 281 | CM_CullCounterClockwiseFace 282 | } CullMode; 283 | 284 | typedef enum { 285 | FM_Solid, 286 | FM_WireFrame 287 | } FillMode; 288 | 289 | typedef struct { 290 | EncodedStr name; 291 | u1 aCount ; 292 | u1 vertexShader ; 293 | u1 pixelShader ; 294 | 295 | u1 hasBlendState ; 296 | if (hasBlendState) { 297 | BlendFunction AlphaBlendFunction; 298 | Blend AlphaDestinationBlend; 299 | Blend AlphaSourceBlend; 300 | u4 BlendFactor; 301 | BlendFunction ColorBlendFunction; 302 | Blend ColorDestinationBlend; 303 | Blend ColorSourceBlend; 304 | u1 ColorWriteChannels0; 305 | u1 ColorWriteChannels1; 306 | u1 ColorWriteChannels2; 307 | u1 ColorWriteChannels3; 308 | u4 MultiSampleMask; 309 | } 310 | 311 | u1 hasDepthStencilState ; 312 | if (hasDepthStencilState) { 313 | StencilOperation CounterClockwiseStencilDepthBufferFail; 314 | StencilOperation CounterClockwiseStencilFail; 315 | CompareFunction CounterClockwiseStencilFunction; 316 | StencilOperation CounterClockwiseStencilPass; 317 | u1 DepthBufferEnable; 318 | CompareFunction DepthBufferFunction; 319 | u1 DepthBufferWriteEnable; 320 | u4 ReferenceStencil; 321 | StencilOperation StencilDepthBufferFail; 322 | u1 StencilEnable; 323 | StencilOperation StencilFail; 324 | CompareFunction StencilFunction; 325 | u4 StencilMask; 326 | StencilOperation StencilPass; 327 | u4 StencilWriteMask; 328 | u1 TwoSidedStencilMode; 329 | } 330 | 331 | u1 hasRasterizerState ; 332 | if (hasRasterizerState) { 333 | CullMode cm; 334 | float DepthBias; 335 | FillMode fm; 336 | u1 MultiSampleAntiAlias; 337 | u1 ScissorTestEnable; 338 | float SlopeScaleDepthBias; 339 | } 340 | } Pass ; 341 | string read_Pass(Pass &in) { 342 | return in.name.v; 343 | } 344 | 345 | typedef struct { 346 | EncodedStr name; 347 | u1 aCount ; 348 | 349 | u1 pCount ; 350 | if (pCount) { 351 | Pass p[pCount]; 352 | } 353 | } Technique ; 354 | string read_Technique(Technique &in) { 355 | return in.name.v; 356 | } 357 | 358 | DisplayFormatHex(); 359 | LittleEndian(); 360 | 361 | local string out; 362 | local int i; 363 | 364 | local u4 _sig; 365 | _sig = ReadUInt(0); 366 | if (_sig == 0x5846474D) { 367 | LittleEndian(); 368 | } else if (_sig == 0x4D474658) { 369 | BigEndian(); 370 | _sig = ReadUInt(0); 371 | Warning("BigEndian"); 372 | } else { 373 | SPrintf(out, "Bad sig! %04X", _sig); 374 | Warning(out); 375 | Printf("%s\n", out); 376 | return -1; 377 | } 378 | 379 | local s1 _ver; 380 | _ver = ReadByte(4); 381 | if (_ver != 5) { 382 | SPrintf(out, "Bad version! %d", _ver); 383 | Warning(out); 384 | Printf("%s\n", out); 385 | return -1; 386 | } 387 | 388 | local s1 _profile; 389 | _profile = ReadByte(5); 390 | if (_profile != 0) { 391 | SPrintf(out, "Bad profile! %d", _profile); 392 | Warning(out); 393 | Printf("%s\n", out); 394 | return -1; 395 | } 396 | 397 | SetBackColor(0xd0d0d0); 398 | HEADER h; 399 | 400 | SetBackColor(0xffd0d0); 401 | u1 cbCount ; 402 | if (cbCount) { 403 | ConstantBuffer cb[cbCount]; 404 | } 405 | 406 | SetBackColor(0xd0ffd0); 407 | u1 sCount ; 408 | if (sCount) { 409 | Shader s[sCount]; 410 | } 411 | 412 | SetBackColor(0xd0ffff); 413 | u1 pCount ; 414 | if (pCount) { 415 | Parameter p[pCount]; 416 | } 417 | 418 | SetBackColor(0xffd0ff); 419 | u1 tCount ; 420 | if (tCount) { 421 | Technique t[tCount]; 422 | } 423 | -------------------------------------------------------------------------------- /010 Templates/GFF.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: GFF.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Aurora GFF file 8 | // Category: Misc 9 | // File Mask: *.gff 10 | // ID Bytes: 47 46 46 20 // GFF 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2012-06-01 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | // UNICODE support 17 | // Thanks to Graeme Sweet for pointing this out! 18 | int CalcUnicodeLen() { 19 | local quad pos = FTell(); 20 | local quad base = pos; 21 | while ((ReadUShort(pos) != 0) && (pos - base < 65535)) 22 | pos += 2; 23 | return (pos - base + 2)/2; 24 | } 25 | 26 | typedef struct { 27 | ushort str[CalcUnicodeLen()]; 28 | } zstringw ; 29 | 30 | string ReadUNICODE(zstringw &z) { 31 | local int len = sizeof(z.str) / 2; 32 | char s[len]; 33 | ConvertUNICODEToASCIIW(len, z.str, s); 34 | return s; 35 | } 36 | 37 | typedef enum { 38 | T_UINT8, T_INT8, T_UINT16, T_INT16, T_UINT32, T_INT32, T_UINT64, T_INT64, 39 | T_FLOAT32, T_FLOAT64, T_Vector3f, T_Vector4f = 12, T_Quaternionf, T_ECString, 40 | T_Color4f, T_Matrix4x4f, T_TlkString, T_Generic = 0xffff 41 | } FieldType; 42 | 43 | typedef struct { 44 | ushort : 13; 45 | ushort Ref_Flag : 1; 46 | ushort Struct_Flag : 1; 47 | ushort List_Flag : 1; 48 | } FieldFlags ; 49 | 50 | string ReadFieldFlags(FieldFlags &in) { 51 | local string out = ""; 52 | if (in.List_Flag) out += "List "; 53 | if (in.Struct_Flag) out += "Struct "; 54 | if (in.Ref_Flag) out += "Ref "; 55 | return out; 56 | } 57 | 58 | typedef struct { 59 | uint Label ; 60 | FieldType TypeID; 61 | FieldFlags Flags; 62 | // ushort Flags ; 63 | uint Index ; 64 | } FIELD; 65 | 66 | typedef struct { 67 | local int i; 68 | local quad pos; 69 | 70 | char StructType[4]; 71 | uint FieldCount ; 72 | uint FieldOffset; 73 | uint StructSize; 74 | 75 | pos = FTell(); 76 | FSeek(FieldOffset); 77 | 78 | SetBackColor(0xc0ffff); 79 | for (i = 0; i < FieldCount; i++) { 80 | FIELD f; 81 | } 82 | SetBackColor(0xc0ffc0); 83 | 84 | FSeek(pos); 85 | } STRUCT ; 86 | 87 | string ReadSTRUCT(STRUCT &in) { 88 | return in.StructType; 89 | } 90 | 91 | typedef struct { 92 | local int i; 93 | 94 | char GFFMagicNumber[4]; 95 | if (GFFMagicNumber != "GFF ") { 96 | Warning("Invalid signature"); 97 | Exit(-1); 98 | } 99 | char GFFVersion[4]; 100 | if (GFFVersion != "V4.0") { 101 | Warning("Unknown version"); 102 | Exit(-1); 103 | } 104 | char TargetPlatform[4]; 105 | if (TargetPlatform != "PC " && TargetPlatform != "PS3 " && TargetPlatform != "X360") { 106 | Warning("Unknown platform"); 107 | Exit(-1); 108 | } 109 | char FileType[4]; 110 | char FileVersion[4]; 111 | uint StructCount ; 112 | uint DataOffset; 113 | 114 | SetBackColor(0xc0ffc0); 115 | for (i = 0; i < StructCount; i++) { 116 | STRUCT s; 117 | } 118 | SetBackColor(0xe0e0e0); 119 | } HEADER; 120 | 121 | DisplayFormatHex(); 122 | LittleEndian(); 123 | 124 | SetBackColor(0xe0e0e0); 125 | HEADER h; 126 | -------------------------------------------------------------------------------- /010 Templates/GRM.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: GRM.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: GRM File parser 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | typedef struct { 15 | uint hash; 16 | uint offset; 17 | uint packed; 18 | uint unpacked; 19 | } FILE_ENTRY; 20 | 21 | typedef struct { 22 | uchar signature[4]; 23 | uint filecount; 24 | FILE_ENTRY f[filecount]; 25 | } HEADER; 26 | 27 | DisplayFormatHex(); 28 | LittleEndian(); 29 | 30 | SetBackColor(0xe0e0e0); 31 | HEADER h; 32 | -------------------------------------------------------------------------------- /010 Templates/GW.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: GW.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: GW File parser 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | BigEndian(); 16 | 17 | typedef struct { 18 | string s; 19 | } ENTRY ; 20 | 21 | string ENTRY_read(ENTRY &in) { 22 | return in.s; 23 | } 24 | 25 | SetBackColor(0xe0e0e0); 26 | CHAR Signature[4]; 27 | UINT32 FileSize; 28 | 29 | CHAR Signature2[4]; 30 | UINT32 DataOffset; 31 | 32 | SetBackColor(0xffc0c0); 33 | while (FTell() < DataOffset) { 34 | ENTRY e; 35 | } 36 | 37 | FSeek(DataOffset+8); 38 | 39 | SetBackColor(0xc0c0ff); 40 | CHAR Signature3[4]; 41 | UINT32 Unknown; 42 | UINT32 Unknown; 43 | UINT32 Unknown; 44 | UINT32 Unknown; 45 | UINT32 Unknown; 46 | UINT32 Unknown; 47 | UINT32 Unknown; 48 | UINT32 Unknown; 49 | UINT32 Unknown; 50 | UINT32 Unknown; 51 | UINT32 Unknown; 52 | -------------------------------------------------------------------------------- /010 Templates/HD6.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: HD6.bt 5 | // Authors: Andrew McRae 6 | // Version: 0.1 7 | // Purpose: Parse PS2 Level 5 data.hd6 8 | // Category: Archive 9 | // File Mask: *.hd6 10 | // ID Bytes: 48 44 36 00 // HD6 11 | // History: 12 | //------------------------------------------------ 13 | 14 | typedef uint64 u8; 15 | typedef uint32 u4; 16 | typedef uint16 u2; 17 | typedef ubyte u1; 18 | typedef int64 s8; 19 | typedef int32 s4; 20 | typedef int16 s2; 21 | typedef byte s1; 22 | 23 | 24 | typedef struct { 25 | string n; 26 | } NAMEPART ; 27 | 28 | string read_NAMEPART(NAMEPART &in) { 29 | return in.n; 30 | } 31 | 32 | 33 | typedef struct { 34 | NAMEPART nameparts[h.nameparts_count]; 35 | } NAMEPARTS; 36 | 37 | 38 | typedef struct { 39 | local int v = 0; 40 | local int shift = 0; 41 | do { 42 | u1 val; 43 | v |= (val & 0x7F) << shift; 44 | shift += 7; 45 | } while (val & 0x80); 46 | } NP_OFFSET ; 47 | 48 | string read_NP_OFFSET(NP_OFFSET &in) { 49 | local string out; 50 | SPrintf(out, "%d '%s'", in.v, nameparts.nameparts[in.v].n); 51 | return out; 52 | } 53 | 54 | 55 | typedef struct { 56 | u8 name_offset:18; 57 | u8 offset:22; 58 | u8 size:24; 59 | local string name = "INVALID"; 60 | local quad _offset, _len; 61 | if (name_offset < h.namelists_size) { 62 | _offset = FTell(); 63 | SetBackColor(0xb0ffff); 64 | FSeek(name_offset + h.namelists_offset); 65 | name = ""; 66 | while (ReadByte() != 0) { 67 | NP_OFFSET np; 68 | name += nameparts.nameparts[np.v].n; 69 | } 70 | FSeek(_offset); 71 | SetBackColor(0xffb0ff); 72 | } 73 | } FILE ; 74 | 75 | string read_FILE(FILE &in) { 76 | local string out; 77 | SPrintf(out, "'%s' %Xh+%Xh", in.name, in.offset * 2048, in.size * 16); 78 | return out; 79 | } 80 | 81 | 82 | typedef struct { 83 | char sig[4]; 84 | 85 | u4 nameparts_offset; 86 | u4 nameparts_size; 87 | u4 nameparts_count ; 88 | u4 zero10; 89 | u4 namelists_offset; 90 | u4 namelists_size; 91 | u4 zero1C; 92 | u4 unknown20; 93 | u4 file_count ; 94 | u4 file_offset; 95 | u4 zero2C; 96 | u4 header_size; 97 | 98 | Assert(zero10 == 0, "HEADER zero10"); 99 | Assert(zero1C == 0, "HEADER zero1C"); 100 | Assert(zero2C == 0, "HEADER zero2C"); 101 | Assert(unknown20 == 0x10, "HEADER unknown20 != 0x10"); 102 | } HEADER; 103 | 104 | 105 | DisplayFormatHex(); 106 | LittleEndian(); 107 | 108 | Assert(ReadString(0, 3) == "HD6", "Bad sig!"); 109 | 110 | SetBackColor(0xb0b0b0); 111 | HEADER h; 112 | 113 | FSeek(h.nameparts_offset); 114 | SetBackColor(0xb0b0ff); 115 | NAMEPARTS nameparts; 116 | 117 | FSeek(h.namelists_offset); 118 | SetBackColor(0xd8ffff); 119 | u1 namelists[h.namelists_size]; 120 | 121 | FSeek(h.file_offset); 122 | SetBackColor(0xffb0ff); 123 | FILE files[h.file_count]; 124 | -------------------------------------------------------------------------------- /010 Templates/HFE.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: HFE.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: Parse HFE floppy image files 8 | // Category: Drives 9 | // File Mask: *.hfe 10 | // ID Bytes: 48 58 43 50 49 43 46 45 // HXCPICFE 11 | // History: 12 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.2 2016-03-08 Andrew McRae: Merge changes 14 | // 0.1 2016-02-26 Andrew McRae: Initial revision 15 | //------------------------------------------------ 16 | 17 | typedef uint64 u8; 18 | typedef uint32 u4; 19 | typedef uint16 u2; 20 | typedef ubyte u1; 21 | typedef int64 s8; 22 | typedef int32 s4; 23 | typedef int16 s2; 24 | typedef byte s1; 25 | 26 | typedef enum { 27 | NO_B = 0x00, 28 | YES_B = 0xff 29 | } BOOL; 30 | 31 | typedef enum { 32 | YES_nB = 0x00, 33 | NO_nB = 0xff 34 | } nBOOL; 35 | 36 | typedef enum { 37 | IBMPC_DD_FLOPPYMODE = 0x00, 38 | IBMPC_HD_FLOPPYMODE = 0x01, 39 | ATARIST_DD_FLOPPYMODE = 0x02, 40 | ATARIST_HD_FLOPPYMODE = 0x03, 41 | AMIGA_DD_FLOPPYMODE = 0x04, 42 | AMIGA_HD_FLOPPYMODE = 0x05, 43 | CPC_DD_FLOPPYMODE = 0x06, 44 | GENERIC_SHUGGART_DD_FLOPPYMODE = 0x07, 45 | IBMPC_ED_FLOPPYMODE = 0x08, 46 | MSX2_DD_FLOPPYMODE = 0x09, 47 | C64_DD_FLOPPYMODE = 0x0A, 48 | EMU_SHUGART_FLOPPYMODE = 0x0B, 49 | S950_DD_FLOPPYMODE = 0x0C, 50 | S950_HD_FLOPPYMODE = 0x0D, 51 | DISABLE_FLOPPYMODE = 0xFE 52 | } FLOPPYMODE; 53 | 54 | typedef enum { 55 | ISOIBM_MFM_ENCODING = 0x00, 56 | AMIGA_MFM_ENCODING = 0x01, 57 | ISOIBM_FM_ENCODING = 0x02, 58 | EMU_FM_ENCODING = 0x03, 59 | UNKNOWN_ENCODING = 0xff 60 | } ENCODING; 61 | 62 | typedef struct { 63 | char HEADERSIGNATURE[8]; 64 | u1 formatrevision; 65 | u1 number_of_track ; 66 | u1 number_of_side ; 67 | ENCODING track_encoding; 68 | u2 bitRate ; 69 | u2 floppyRPM ; 70 | FLOPPYMODE floppyinterfacemode; 71 | u1 dnu; 72 | u2 track_list_offset; 73 | BOOL write_allowed; 74 | BOOL single_step; 75 | nBOOL track0s0_altencoding; 76 | ENCODING track0s0_encoding; 77 | nBOOL track0s1_altencoding; 78 | ENCODING track0s1_encoding; 79 | } picfileformatheader; 80 | 81 | typedef struct { 82 | u2 offset; 83 | u2 track_len; 84 | } pictrack; 85 | 86 | typedef struct (quad l) { 87 | SetBackColor(0xc0ffc0); 88 | u1 side0[l]; 89 | if (l < 0x100) { 90 | SetBackColor(0xe0ffe0); 91 | u1 side0p[0x100 - l] ; 92 | } 93 | 94 | SetBackColor(0xffc0c0); 95 | u1 side1[l]; 96 | if (l < 0x100) { 97 | SetBackColor(0xffe0e0); 98 | u1 side1p[0x100 - l] ; 99 | } 100 | } block; 101 | 102 | typedef struct (quad l) { 103 | local int i; 104 | for (i = l; i > 0; i -= 0x200) { 105 | if (i >= 0x200) { 106 | block b(0x100); 107 | } else { 108 | block b(i / 2); 109 | } 110 | } 111 | } track; 112 | 113 | local int i; 114 | 115 | DisplayFormatHex(); 116 | LittleEndian(); 117 | 118 | local char _sig[8]; 119 | ReadBytes(_sig, 0, 8); 120 | if (_sig != "HXCPICFE") { 121 | Warning("Bad sig!"); 122 | Printf("Bad sig!\n"); 123 | return -1; 124 | } 125 | 126 | SetBackColor(0xc0c0c0); 127 | picfileformatheader h; 128 | 129 | FSeek((quad)h.track_list_offset * 0x200); 130 | SetBackColor(0xc0c0ff); 131 | pictrack pt[h.number_of_track]; 132 | 133 | for (i = 0; i < h.number_of_track; i++) { 134 | FSeek((quad)pt[i].offset * 0x200); 135 | track t(pt[i].track_len); 136 | } 137 | -------------------------------------------------------------------------------- /010 Templates/HRM.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: HRM.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Human Resource Machine resource.pak 8 | // Category: Image 9 | // File Mask: resource.pak 10 | // History: 11 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.1 2015-10-28 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | typedef uint64 u8; 16 | typedef uint32 u4; 17 | typedef uint16 u2; 18 | typedef ubyte u1; 19 | typedef int64 s8; 20 | typedef int32 s4; 21 | typedef int16 s2; 22 | typedef byte s1; 23 | 24 | typedef struct { 25 | SetBackColor(0xc0c0c0); 26 | u4 hash; 27 | u4 compressed; 28 | u4 offset; 29 | u4 size; 30 | 31 | local quad o = FTell(); 32 | FSeek(offset); 33 | 34 | if (compressed) { 35 | SetBackColor(0xe0ffe0); 36 | u4 compressed_size; 37 | u4 uncompressed_size; 38 | 39 | SetBackColor(0xb0ffb0); 40 | u1 data[compressed_size]; 41 | } else { 42 | SetBackColor(0xb0b0ff); 43 | u1 data[size]; 44 | } 45 | 46 | FSeek(o); 47 | } FILE_ENTRY ; 48 | string read_FILE_ENTRY(FILE_ENTRY &in) { 49 | local string out; 50 | if (in.compressed) { 51 | SPrintf(out, "%Xh+%Xh %Xh", in.offset, in.size, in.uncompressed_size); 52 | } else { 53 | SPrintf(out, "%Xh+%Xh", in.offset, in.size); 54 | } 55 | return out; 56 | } 57 | 58 | DisplayFormatHex(); 59 | LittleEndian(); 60 | 61 | local int i; 62 | 63 | SetBackColor(0xe0e0e0); 64 | u4 unknown; 65 | u4 file_count; 66 | 67 | SetBackColor(0xc0c0c0); 68 | FILE_ENTRY f[file_count]; 69 | -------------------------------------------------------------------------------- /010 Templates/IMD.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: IMD.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Parse IMD floppy image 8 | // Category: Drives 9 | // File Mask: *.imd 10 | // ID Bytes: 49 4D 44 20 // IMD 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2016-03-11 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | DisplayFormatHex(); 26 | LittleEndian(); 27 | 28 | typedef struct (int size, int sector) { 29 | local int _sector = sector; 30 | SetBackColor(0xe0ffe0); 31 | enum { 32 | S_NONE = 0, 33 | S_NORM, 34 | S_NORM_C, 35 | S_DEL, 36 | S_DEL_C, 37 | S_ERR, 38 | S_ERR_C, 39 | S_DELERR, 40 | S_DELERR_C 41 | } data_type; 42 | 43 | SetBackColor(0xc0ffc0); 44 | switch (data_type) { 45 | case S_NONE: 46 | break; 47 | case S_NORM: 48 | case S_DEL: 49 | case S_ERR: 50 | case S_DELERR: 51 | u1 d[size]; 52 | break; 53 | case S_NORM_C: 54 | case S_DEL_C: 55 | case S_ERR_C: 56 | case S_DELERR_C: 57 | u1 d; 58 | break; 59 | } 60 | } SECTOR ; 61 | string read_SECTOR(SECTOR &in) { 62 | local string out; 63 | SPrintf(out, "%d %s", in._sector, EnumToString(in.data_type)); 64 | return out; 65 | } 66 | 67 | typedef struct { 68 | local int _i; 69 | local int sector_size; 70 | 71 | enum { 72 | M_FM_500 = 0, 73 | M_FM_300, 74 | M_FM_250, 75 | M_MFM_500, 76 | M_MFM_300, 77 | M_MFM_250 78 | } track_mode_code; 79 | u1 physical_cylinder ; 80 | u1 physical_head : 6 ; 81 | u1 has_head_map : 1 ; 82 | u1 has_cylinder_map : 1 ; 83 | u1 number_of_sectors ; 84 | u1 sector_size_code ; 85 | 86 | sector_size = 1 << (7 + (int)sector_size_code); 87 | 88 | if (number_of_sectors > 0) { 89 | u1 sector_map[number_of_sectors] ; 90 | if (has_cylinder_map != 0) { 91 | u1 cylinder_map[number_of_sectors] ; 92 | } 93 | if (has_head_map != 0) { 94 | u1 head_map[number_of_sectors] ; 95 | } 96 | 97 | for (_i = 0; _i < number_of_sectors; _i++) { 98 | SECTOR s(sector_size, sector_map[_i]); 99 | } 100 | } 101 | } TRACK ; 102 | string read_TRACK(TRACK &in) { 103 | local string out; 104 | SPrintf(out, "%2d,%2d %2d %d %s", in.physical_cylinder, in.physical_head, in.number_of_sectors, in.sector_size, EnumToString(in.track_mode_code)); 105 | return out; 106 | } 107 | 108 | typedef struct { 109 | local quad _len; 110 | local u1 _eof[1]; 111 | _eof[0] = 0x1A; 112 | _len = FindFirst(_eof); 113 | char sig[_len + 1]; 114 | } HEADER; 115 | 116 | local char _sig[4]; 117 | ReadBytes(_sig, 0, 4); 118 | if (_sig != "IMD ") { 119 | Warning("Bad sig!"); 120 | Printf("Bad sig!\n"); 121 | return -1; 122 | } 123 | 124 | SetBackColor(0xc0c0c0); 125 | HEADER h; 126 | 127 | while (!FEof()) { 128 | SetBackColor(0xffc0c0); 129 | TRACK t; 130 | } 131 | -------------------------------------------------------------------------------- /010 Templates/IMG.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: IMG.bt 5 | // Authors: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Parse PS2 Level 5 IMG files 8 | // Category: Archive 9 | // File Mask: *.img 10 | // ID Bytes: 49 4D 33 00 // IM3 11 | // History: 12 | //------------------------------------------------ 13 | 14 | typedef uint64 u8; 15 | typedef uint32 u4; 16 | typedef uint16 u2; 17 | typedef ubyte u1; 18 | typedef int64 s8; 19 | typedef int32 s4; 20 | typedef int16 s2; 21 | typedef byte s1; 22 | 23 | 24 | typedef struct { 25 | char sig[4]; 26 | 27 | u4 image_offset; 28 | u4 image_count ; 29 | u4 zero0C; 30 | 31 | Assert(zero0C == 0, "HEADER zero0C"); 32 | } HEADER; 33 | 34 | 35 | typedef struct { 36 | char name[32]; 37 | u4 header_size; 38 | u4 offset; 39 | u4 unknown28; 40 | u4 unknown2C; 41 | u4 unknown30; 42 | u4 size; 43 | u4 unknown38; 44 | u4 zero3C; 45 | 46 | local quad _offset; 47 | if (_offset < FileSize() && size > 0) { 48 | _offset = FTell(); 49 | FSeek(offset); 50 | SetBackColor(0xffb0ff); 51 | u1 data[size]; 52 | SetBackColor(0xb0ffff); 53 | FSeek(_offset); 54 | } 55 | 56 | Assert(header_size == 0x40, "IMAGE header_size != 40h"); 57 | //Assert(unknown28 == 0x01, "IMAGE unknown28 != 1h"); 58 | //Assert(unknown2C == 0x0, "IMAGE unknown2C != 0h"); 59 | //Assert(unknown30 == 0x0, "IMAGE unknown30 != 0h"); 60 | //Assert(unknown38 == 0x05, "IMAGE unknown38 != 5h"); 61 | Assert(zero3C == 0x0, "IMAGE zero3C"); 62 | } IMAGE ; 63 | 64 | string read_IMAGE(IMAGE &in) { 65 | local string out; 66 | SPrintf(out, "%04X %04X %04X %04X %04X '%s' %Xh+%Xh", in.unknown28, in.unknown2C, in.unknown30, in.unknown38, in.zero3C, in.name, in.offset, in.size); 67 | return out; 68 | } 69 | 70 | 71 | DisplayFormatHex(); 72 | LittleEndian(); 73 | 74 | Assert(ReadString(0, 3) == "IM3", "Bad sig!"); 75 | 76 | SetBackColor(0xb0b0b0); 77 | HEADER h; 78 | 79 | FSeek(h.image_offset); 80 | 81 | SetBackColor(0xb0ffff); 82 | IMAGE i[h.image_count]; 83 | -------------------------------------------------------------------------------- /010 Templates/IcoDF.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: IcoDF.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Parse Ico data.df 8 | // Category: Archive 9 | // File Mask: data.df 10 | // History: 11 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.1 2012-06-01 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | DisplayFormatHex(); 16 | LittleEndian(); 17 | 18 | string read_Filename(char &in) { 19 | return in; 20 | } 21 | 22 | typedef struct { 23 | local quad cur_pos; 24 | 25 | char filename[32]; 26 | uint file_offset; 27 | uint file_size ; 28 | 29 | cur_pos = FTell(); 30 | FSeek(file_offset); 31 | 32 | /* 33 | SetBackColor(0xc0ffc0); 34 | ubyte data[file_size]; 35 | SetBackColor(0xe0e0e0); 36 | */ 37 | 38 | FSeek(cur_pos); 39 | } DIR ; 40 | 41 | string READ_DIR(DIR &in) { 42 | return in.filename; 43 | } 44 | 45 | local int i; 46 | 47 | uint num_files ; 48 | 49 | SetBackColor(0xe0e0e0); 50 | for (i = 0; i < num_files; i++) { 51 | DIR d; 52 | } 53 | -------------------------------------------------------------------------------- /010 Templates/JC2.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: JC2.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Just Cause 2 savegame 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | LittleEndian(); 16 | 17 | typedef struct { 18 | int16 Index; 19 | int DataSize; 20 | 21 | SetBackColor(0xa0ffa0); 22 | byte d[DataSize]; 23 | SetBackColor(0xd0ffd0); 24 | } ChunkDataEntry ; 25 | 26 | string read_ChunkDataEntry(ChunkDataEntry &in) { 27 | string out; 28 | SPrintf(out, "[%d] %d", in.Index, in.DataSize); 29 | return out; 30 | } 31 | 32 | typedef struct { 33 | local quad cur_pos; 34 | 35 | int ObjectID; 36 | int InstanceID; 37 | 38 | int EntryListOffset; 39 | int EntryListSize; 40 | 41 | cur_pos = FTell(); 42 | FSeek(EntryListOffset + 236032); 43 | 44 | while (FTell() < EntryListOffset + EntryListSize + 236032) { 45 | SetBackColor(0xd0ffd0); 46 | ChunkDataEntry d; 47 | SetBackColor(0xd0d0ff); 48 | } 49 | 50 | FSeek(cur_pos); 51 | } ChunkHeader ; 52 | 53 | string read_ChunkHeader(ChunkHeader &in) { 54 | string out; 55 | SPrintf(out, "%08x %08x-%08x %s", in.ObjectID, in.EntryListOffset + 236032, in.EntryListOffset + in.EntryListSize + 236032, NameLookup(in.ObjectID)); 56 | return out; 57 | } 58 | 59 | string NameLookup(int hash) { 60 | string out; 61 | SPrintf(out, "%04X", hash); 62 | 63 | switch(hash) { 64 | case 0x07763c5a: 65 | return "WorldTime"; 66 | case 0x0d7295f3: 67 | return "PDADatabase"; 68 | case 0x24543a6f: 69 | return "SaveBitStorage"; 70 | case 0x269ab061: 71 | return "CHeatSpawnManager"; 72 | case 0x2bba6b01: 73 | return "CSpawnManager"; 74 | case 0x419aabd2: 75 | return "HeatLevels"; 76 | case 0x56e9fcec: 77 | return "Settlements"; 78 | case 0x5b5fba2f: 79 | return "CSheldonService"; 80 | case 0x753ec2e1: 81 | return "HeatSystem"; 82 | case 0x8315344b: 83 | return "DripfeedManager"; 84 | case 0x834020bb: 85 | return "player_vocals"; 86 | case 0x83a89d0d: 87 | return "MissionSystem"; 88 | case 0x89215d85: 89 | return "Weather"; 90 | case 0xb0f23d91: 91 | return "ResourceItemHandler"; 92 | case 0xc944399d: 93 | return "Difficulty"; 94 | case 0xccbcfa29: 95 | return "TriggerSaveHandler"; 96 | case 0xdf107f97: 97 | return "BlackmarketHook"; 98 | case 0xe9bb5fd1: 99 | return "CPlayer"; 100 | } 101 | 102 | return out; 103 | } 104 | 105 | typedef struct { 106 | int unk; 107 | int unk; 108 | int TotalChaos ; 109 | int TotalCash ; 110 | int PercentDone ; 111 | int unk; 112 | uint32 PlayTime ; 113 | int unk; 114 | time_t TimeSaved; 115 | int unk; 116 | int Difficulty; 117 | int unk; 118 | int unk; 119 | int unk; 120 | } SaveFileHeader; 121 | 122 | SetBackColor(0xc0c0c0); 123 | SaveFileHeader s; 124 | SetBackColor(0xe8e8e8); 125 | SaveFileHeader ignore[7]; 126 | 127 | FSeek(512); 128 | SetBackColor(0xd0d0ff); 129 | int ch_cnt; 130 | ChunkHeader ch[ch_cnt]; 131 | -------------------------------------------------------------------------------- /010 Templates/LIB.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: LIB.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: MS lib file 8 | // Category: Programming 9 | // File Mask: *.lib 10 | // ID Bytes: 21 3C 61 72 63 68 3E // ! 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2015-09-07 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | typedef struct { 26 | SetBackColor(0xe8e8e8); 27 | if (!FEof()) { 28 | local quad padding = 2 - (FTell() & 1); 29 | 30 | if (padding > 0 && padding < 2) { 31 | u1 p; 32 | } 33 | } 34 | } PADDING2 ; 35 | 36 | typedef struct { 37 | char name[16]; 38 | char date[12]; 39 | char user[6]; 40 | char group[6]; 41 | char mode[8]; 42 | char size[10]; 43 | char end[2]; 44 | local int _size = Atoi(size); 45 | } HEADER ; 46 | 47 | string read_HEADER(HEADER &in) { 48 | string out; 49 | SPrintf(out, "%s %d", in.name, in._size); 50 | return out; 51 | } 52 | 53 | typedef struct { 54 | string d; 55 | } str ; 56 | 57 | string read_str(str &in) { 58 | return in.d; 59 | } 60 | 61 | typedef struct { 62 | BigEndian(); 63 | 64 | HEADER h; 65 | 66 | u4 size; 67 | if (size) { 68 | u4 offset[size]; 69 | str name[size]; 70 | } 71 | } LINKER1 ; 72 | 73 | string read_LINKER1(LINKER1 &in) { 74 | return read_HEADER(in.h); 75 | } 76 | 77 | typedef struct { 78 | LittleEndian(); 79 | 80 | HEADER h; 81 | 82 | u4 size; 83 | if (size) { 84 | u4 offset[size]; 85 | } 86 | u4 symbols; 87 | if (symbols) { 88 | u2 index[symbols]; 89 | str name[symbols]; 90 | } 91 | } LINKER2 ; 92 | 93 | string read_LINKER2(LINKER2 &in) { 94 | return read_HEADER(in.h); 95 | } 96 | 97 | typedef struct { 98 | LittleEndian(); 99 | 100 | HEADER h; 101 | 102 | local int64 start = FTell(); 103 | local int64 offset = 0; 104 | 105 | while (offset < h._size) { 106 | str name; 107 | offset = FTell() - start; 108 | } 109 | } LONGNAMES ; 110 | 111 | string read_LONGNAMES(LONGNAMES &in) { 112 | return read_HEADER(in.h); 113 | } 114 | 115 | typedef struct { 116 | LittleEndian(); 117 | 118 | HEADER h; 119 | 120 | if (h._size) { 121 | u1 d[h._size]; 122 | } 123 | } ENTRY ; 124 | 125 | string read_ENTRY(ENTRY &in) { 126 | string out; 127 | string name = in.h.name; 128 | int slash_pos = Strchr(name, '/'); 129 | int len = Strlen(name); 130 | if (slash_pos > 0) { 131 | name = SubStr(name, 0, slash_pos); 132 | } 133 | else if (slash_pos == 0) { 134 | int offset = Atoi(SubStr(name, 1)); 135 | name = ReadString(n.start + offset); 136 | } 137 | SPrintf(out, "%s %d", name, in.h._size); 138 | return out; 139 | } 140 | 141 | DisplayFormatHex(); 142 | LittleEndian(); 143 | 144 | local uchar _sig[8]; 145 | ReadBytes(_sig, 0, 8); 146 | 147 | if (_sig != "!\n") { 148 | Printf("Invalid signature\n"); 149 | Warning("Invalid signature"); 150 | return -1; 151 | } 152 | 153 | SetBackColor(0xd0d0d0); 154 | char sig[8]; 155 | 156 | LINKER1 l1; 157 | 158 | PADDING2 p; 159 | LINKER2 l2; 160 | 161 | PADDING2 p; 162 | LONGNAMES n; 163 | 164 | while (!FEof()) { 165 | PADDING2 p; 166 | if (!FEof()) { 167 | ENTRY e; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /010 Templates/LZO.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: LZO.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: UE3 LZO file 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | LittleEndian(); 16 | 17 | typedef struct { 18 | local int j; 19 | local uint num_blocks; 20 | local quad block_offset; 21 | 22 | uint Signature; 23 | if (Signature != 0x9E2A83C1) { 24 | Warning("Invalid signature in compressed block"); 25 | } 26 | uint BlockSize; 27 | uint CompressedSize; 28 | uint UncompressedSize; 29 | 30 | num_blocks = (uint)Ceil((double)UncompressedSize / (double)BlockSize); 31 | 32 | block_offset = 16 + num_blocks * 8; 33 | for (j = 0; j < num_blocks; j++) { 34 | FSeek(16 + j * 8); 35 | struct { 36 | local quad cur_offset2; 37 | uint CompressedSize2; 38 | uint UncompressedSize2; 39 | 40 | cur_offset2 = FTell(); 41 | FSeek(block_offset); 42 | SetBackColor(0xffc0ff); 43 | ubyte Data[CompressedSize2]; 44 | SetBackColor(0xc0ffff); 45 | FSeek(cur_offset2); 46 | block_offset += CompressedSize2; 47 | } Block; 48 | } 49 | } Chunk; 50 | 51 | local uint sig; 52 | sig = ReadInt(0); 53 | 54 | if (sig == 0x9E2A83C1) { 55 | LittleEndian(); 56 | } 57 | else if (sig == 0xC1832A9E) { 58 | Warning("BigEndian"); 59 | BigEndian(); 60 | } 61 | else { 62 | Warning("Invalid signature"); 63 | Exit(-1); 64 | } 65 | FSeek(0); 66 | 67 | SetBackColor(0xc0ffff); 68 | Chunk block; 69 | -------------------------------------------------------------------------------- /010 Templates/MFM.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: MFM.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: HxC MFM floppy image 8 | // Category: Drives 9 | // File Mask: *.mfm 10 | // ID Bytes: 48 58 43 4D 46 4D 00 // HXCMFM 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2016-03-11 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | typedef struct { 26 | char sig[7]; 27 | u2 tracks ; 28 | u1 sides ; 29 | u2 rpm ; 30 | u2 bitrate ; 31 | u1 iftype; 32 | u4 track_offset; 33 | } MFMIMG ; 34 | string read_MFMIMG(MFMIMG &in) { 35 | local string out; 36 | SPrintf(out, "%2d,%2d", h.tracks, h.sides); 37 | return out; 38 | } 39 | 40 | typedef struct { 41 | local quad _pos; 42 | 43 | SetBackColor(0xe0ffe0); 44 | u2 track ; 45 | u1 side ; 46 | u4 size ; 47 | u4 offset; 48 | 49 | if (size > 0 && offset > 0) { 50 | _pos = FTell(); 51 | FSeek(offset); 52 | 53 | SetBackColor(0xc0ffc0); 54 | u1 d[size]; 55 | 56 | FSeek(_pos); 57 | } 58 | } MFMTRACKIMG ; 59 | string read_MFMTRACKIMG(MFMTRACKIMG &in) { 60 | local string out; 61 | SPrintf(out, "%2d,%2d", in.track, in.side); 62 | return out; 63 | } 64 | 65 | local int _t, _h; 66 | 67 | DisplayFormatHex(); 68 | LittleEndian(); 69 | 70 | local char _sig[7]; 71 | ReadBytes(_sig, 0, 7); 72 | if (_sig != "HXCMFM\0") { 73 | Warning("Bad sig!"); 74 | Printf("Bad sig!\n"); 75 | return -1; 76 | } 77 | 78 | SetBackColor(0xc0c0c0); 79 | MFMIMG h; 80 | 81 | FSeek(h.track_offset); 82 | for (_t = 0; _t < h.tracks; _t++) { 83 | for (_h = 0; _h < h.sides; _h++) { 84 | SetBackColor(0xffc0c0); 85 | MFMTRACKIMG t; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /010 Templates/MGFX.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: MGFX.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: MonoGame v6 Effect file 8 | // Category: Programming 9 | // File Mask: *.fxo 10 | // History: 11 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.1 2015-01-21 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | typedef uint64 u8; 16 | typedef uint32 u4; 17 | typedef uint16 u2; 18 | typedef ubyte u1; 19 | typedef int64 s8; 20 | typedef int32 s4; 21 | typedef int16 s2; 22 | typedef byte s1; 23 | 24 | typedef struct { 25 | local int v = 0; 26 | local int shift = 0; 27 | SetBackColor(0xd8d8d8); 28 | do { 29 | u1 val; 30 | v |= (val & 0x7F) << shift; 31 | shift += 7; 32 | } while (val & 0x80); 33 | } EncodedInt ; 34 | string read_EncodedInt(EncodedInt &in) { 35 | local string out; 36 | SPrintf(out, "%Xh", in.v); 37 | return out; 38 | } 39 | 40 | typedef struct { 41 | EncodedInt length; 42 | SetBackColor(0xc0c0c0); 43 | if (length.v) { 44 | char v[length.v]; 45 | } else { 46 | local string v = ""; 47 | } 48 | } EncodedStr ; 49 | string read_EncodedStr(EncodedStr &in) { 50 | return in.v; 51 | } 52 | 53 | typedef struct { 54 | u4 Signature; 55 | u1 Version; 56 | u1 Profile; 57 | u4 EffectKey; 58 | } HEADER ; 59 | string read_HEADER(HEADER &in) { 60 | local string out; 61 | local string profile; 62 | switch(in.Profile) { 63 | case 0: 64 | profile = "GL"; 65 | break; 66 | case 1: 67 | profile = "DX"; 68 | break; 69 | default: 70 | SPrintf(profile, "(%d)", in.Profile); 71 | break; 72 | } 73 | SPrintf(out, "MGFX v%d %s", in.Version, profile); 74 | return out; 75 | } 76 | 77 | typedef struct { 78 | u1 p; 79 | u2 o; 80 | } CBParam; 81 | 82 | typedef struct { 83 | local int i; 84 | 85 | EncodedStr name; 86 | u2 size; 87 | 88 | u1 pCount ; 89 | if (pCount) { 90 | CBParam cbp[pCount]; 91 | } 92 | } ConstantBuffer ; 93 | string read_ConstantBuffer(ConstantBuffer &in) { 94 | return in.name.v; 95 | } 96 | 97 | typedef enum { 98 | TAM_Wrap, 99 | TAM_Clamp, 100 | TAM_Mirror 101 | } TextureAddressMode; 102 | 103 | typedef struct { 104 | enum { 105 | ST_2D, 106 | ST_Cube, 107 | ST_Volume, 108 | ST_1D 109 | } type; 110 | u1 textureSlot ; 111 | u1 samplerSlot ; 112 | u1 hasState; 113 | if (hasState) { 114 | TextureAddressMode state_AddressU; 115 | TextureAddressMode state_AddressV; 116 | TextureAddressMode state_AddressW; 117 | u1 state_Filter; 118 | u4 state_MaxAnisotropy; 119 | u4 state_MaxMipLevel; 120 | float state_MipMapLevelOfDetailBias; 121 | } 122 | EncodedStr name; 123 | u1 parameter ; 124 | } Sampler ; 125 | string read_Sampler(Sampler &in) { 126 | return in.name.v; 127 | } 128 | 129 | typedef struct { 130 | EncodedStr name; 131 | enum { 132 | VEU_Position, 133 | VEU_Color, 134 | VEU_TextureCoordinate, 135 | VEU_Normal, 136 | VEU_Binormal, 137 | VEU_Tangent, 138 | VEU_BlendIndices, 139 | VEU_BlendWeight, 140 | VEU_Depth, 141 | VEU_Fog, 142 | VEU_PointSize, 143 | VEU_Sample, 144 | VEU_TessellateFactor 145 | } usage; 146 | u1 index ; 147 | u2 format; 148 | } Attribute ; 149 | string read_Attribute(Attribute &in) { 150 | return in.name.v; 151 | } 152 | 153 | typedef struct { 154 | local int i; 155 | 156 | u1 isVertex; 157 | u4 length ; 158 | SetBackColor(0x80ff80); 159 | char bytecode[length]; 160 | SetBackColor(0xd0ffd0); 161 | 162 | u1 sCount ; 163 | if (sCount) { 164 | Sampler s[sCount]; 165 | } 166 | 167 | u1 cbCount ; 168 | if (cbCount) { 169 | u1 cBuffer[cbCount]; 170 | } 171 | 172 | u1 aCount ; 173 | if (aCount) { 174 | Attribute a[aCount]; 175 | } 176 | } Shader ; 177 | string read_Shader(Shader &in) { 178 | if (in.isVertex) { 179 | return "VS"; 180 | } else { 181 | return "PS"; 182 | } 183 | } 184 | 185 | struct Parameter; 186 | typedef struct { 187 | local int i; 188 | 189 | enum { 190 | PC_Scalar, 191 | PC_Vector, 192 | C_Matrix, 193 | PC_Object, 194 | PC_Struct 195 | } class; 196 | enum { 197 | PT_Void, 198 | PT_Bool, 199 | PT_Int32, 200 | PT_Single, 201 | PT_String, 202 | PT_Texture, 203 | PT_Texture1D, 204 | PT_Texture2D, 205 | PT_Texture3D, 206 | PT_TextureCube 207 | } type; 208 | EncodedStr name; 209 | EncodedStr semantic; 210 | u1 aCount ; 211 | u1 rowCount; 212 | u1 columnCount; 213 | 214 | u1 eCount ; 215 | if (eCount) { 216 | Parameter elements[eCount]; 217 | } 218 | 219 | u1 smCount ; 220 | if (smCount) { 221 | Parameter structMembers[smCount]; 222 | } 223 | 224 | if (eCount == 0 && smCount == 0) { 225 | if (type == PT_Bool || type == PT_Int32 || type == PT_Single) { 226 | float data[rowCount * columnCount]; 227 | } 228 | } 229 | } Parameter ; 230 | string read_Parameter(Parameter &in) { 231 | return in.name.v; 232 | } 233 | 234 | typedef enum { 235 | BF_Add, 236 | BF_Subtract, 237 | BF_ReverseSubtract, 238 | BF_Max, 239 | BF_Min 240 | } BlendFunction; 241 | 242 | typedef enum { 243 | B_One, 244 | B_Zero, 245 | B_SourceColor, 246 | B_InverseSourceColor, 247 | B_SourceAlpha, 248 | B_InverseSourceAlpha, 249 | B_DestinationColor, 250 | B_InverseDestinationColor, 251 | B_DestinationAlpha, 252 | B_InverseDestinationAlpha, 253 | B_BlendFactor, 254 | B_InverseBlendFactor, 255 | B_SourceAlphaSaturation 256 | } Blend; 257 | 258 | typedef enum { 259 | SO_Keep, 260 | SO_Zero, 261 | SO_Replace, 262 | SO_Increment, 263 | SO_Decrement, 264 | SO_IncrementSaturation, 265 | SO_DecrementSaturation, 266 | SO_Invert 267 | } StencilOperation; 268 | 269 | typedef enum { 270 | SCF_Always, 271 | SCF_Never, 272 | SCF_Less, 273 | SCF_LessEqual, 274 | SCF_Equal, 275 | SCF_GreaterEqual, 276 | SCF_Greater, 277 | SCF_NotEqual 278 | } CompareFunction; 279 | 280 | typedef enum { 281 | CM_None, 282 | CM_CullClockwiseFace, 283 | CM_CullCounterClockwiseFace 284 | } CullMode; 285 | 286 | typedef enum { 287 | FM_Solid, 288 | FM_WireFrame 289 | } FillMode; 290 | 291 | typedef struct { 292 | EncodedStr name; 293 | u1 aCount ; 294 | u1 vertexShader ; 295 | u1 pixelShader ; 296 | 297 | if (pixelShader != 255) { 298 | u1 hasBlendState ; 299 | if (hasBlendState) { 300 | BlendFunction AlphaBlendFunction; 301 | Blend AlphaDestinationBlend; 302 | Blend AlphaSourceBlend; 303 | u4 BlendFactor; 304 | BlendFunction ColorBlendFunction; 305 | Blend ColorDestinationBlend; 306 | Blend ColorSourceBlend; 307 | u1 ColorWriteChannels0; 308 | u1 ColorWriteChannels1; 309 | u1 ColorWriteChannels2; 310 | u1 ColorWriteChannels3; 311 | u4 MultiSampleMask; 312 | } 313 | 314 | u1 hasDepthStencilState ; 315 | if (hasDepthStencilState) { 316 | StencilOperation CounterClockwiseStencilDepthBufferFail; 317 | StencilOperation CounterClockwiseStencilFail; 318 | CompareFunction CounterClockwiseStencilFunction; 319 | StencilOperation CounterClockwiseStencilPass; 320 | u1 DepthBufferEnable; 321 | CompareFunction DepthBufferFunction; 322 | u1 DepthBufferWriteEnable; 323 | u4 ReferenceStencil; 324 | StencilOperation StencilDepthBufferFail; 325 | u1 StencilEnable; 326 | StencilOperation StencilFail; 327 | CompareFunction StencilFunction; 328 | u4 StencilMask; 329 | StencilOperation StencilPass; 330 | u4 StencilWriteMask; 331 | u1 TwoSidedStencilMode; 332 | } 333 | 334 | u1 hasRasterizerState ; 335 | if (hasRasterizerState) { 336 | CullMode cm; 337 | float DepthBias; 338 | FillMode fm; 339 | u1 MultiSampleAntiAlias; 340 | u1 ScissorTestEnable; 341 | float SlopeScaleDepthBias; 342 | } 343 | } 344 | } Pass ; 345 | string read_Pass(Pass &in) { 346 | return in.name.v; 347 | } 348 | 349 | typedef struct { 350 | EncodedStr name; 351 | u1 aCount ; 352 | 353 | u1 pCount ; 354 | if (pCount) { 355 | Pass p[pCount]; 356 | } 357 | } Technique ; 358 | string read_Technique(Technique &in) { 359 | return in.name.v; 360 | } 361 | 362 | DisplayFormatHex(); 363 | LittleEndian(); 364 | 365 | local string out; 366 | local int i; 367 | 368 | local u4 _sig; 369 | _sig = ReadUInt(0); 370 | if (_sig == 0x5846474D) { 371 | LittleEndian(); 372 | } else if (_sig == 0x4D474658) { 373 | BigEndian(); 374 | _sig = ReadUInt(0); 375 | Warning("BigEndian"); 376 | } else { 377 | SPrintf(out, "Bad sig! %04X", _sig); 378 | Warning(out); 379 | Printf("%s\n", out); 380 | return -1; 381 | } 382 | 383 | local s1 _ver; 384 | _ver = ReadByte(4); 385 | if (_ver != 6) { 386 | SPrintf(out, "Bad version! %d", _ver); 387 | Warning(out); 388 | Printf("%s\n", out); 389 | return -1; 390 | } 391 | 392 | local s1 _profile; 393 | _profile = ReadByte(5); 394 | if (_profile != 0) { 395 | SPrintf(out, "Bad profile! %d", _profile); 396 | Warning(out); 397 | Printf("%s\n", out); 398 | return -1; 399 | } 400 | 401 | SetBackColor(0xd0d0d0); 402 | HEADER h; 403 | 404 | SetBackColor(0xffd0d0); 405 | u1 cbCount ; 406 | if (cbCount) { 407 | ConstantBuffer cb[cbCount]; 408 | } 409 | 410 | SetBackColor(0xd0ffd0); 411 | u1 sCount ; 412 | if (sCount) { 413 | Shader s[sCount]; 414 | } 415 | 416 | SetBackColor(0xd0ffff); 417 | u1 pCount ; 418 | if (pCount) { 419 | Parameter p[pCount]; 420 | } 421 | 422 | SetBackColor(0xffd0ff); 423 | u1 tCount ; 424 | if (tCount) { 425 | Technique t[tCount]; 426 | } 427 | -------------------------------------------------------------------------------- /010 Templates/MIA.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: MIA.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: MIA File parser 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2014-01-24 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | typedef struct { 15 | char type; 16 | 17 | switch (type) { 18 | case 'T': 19 | string i; 20 | break; 21 | case 'I': 22 | unsigned int i; 23 | break; 24 | case 'i': 25 | signed int i; 26 | break; 27 | default: 28 | return -1; 29 | } 30 | } ITEM ; 31 | 32 | string readITEM(ITEM &in) { 33 | string out = ""; 34 | switch (in.type) { 35 | case 'T': 36 | out = in.i; 37 | break; 38 | case 'I': 39 | SPrintf(out, "%u", in.i); 40 | break; 41 | case 'i': 42 | SPrintf(out, "%d", in.i); 43 | break; 44 | } 45 | return out; 46 | } 47 | 48 | DisplayFormatHex(); 49 | LittleEndian(); 50 | 51 | while (true) { 52 | ITEM i; 53 | } 54 | -------------------------------------------------------------------------------- /010 Templates/NBT.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: NBT.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Minecraft NBT file 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | enum TAG_TYPE { 15 | TAG_End = 0, 16 | TAG_Byte, 17 | TAG_Short, 18 | TAG_Int, 19 | TAG_Long, 20 | TAG_Float, 21 | TAG_Double, 22 | TAG_Byte_Array, 23 | TAG_String, 24 | TAG_List, 25 | TAG_Compound 26 | }; 27 | 28 | typedef struct { 29 | } TAG_End; 30 | 31 | typedef byte TAG_Byte; 32 | 33 | typedef short TAG_Short; 34 | 35 | typedef int TAG_Int; 36 | 37 | typedef int64 TAG_Long; 38 | 39 | typedef float TAG_Float; 40 | 41 | typedef double TAG_Double; 42 | 43 | typedef struct { 44 | TAG_Int length ; 45 | if (length > 0) byte d[length]; 46 | } TAG_Byte_Array ; 47 | 48 | string read_TAG_Byte_Array(TAG_Byte_Array &in) { 49 | string out; 50 | 51 | SPrintf(out, "byte[%i]", in.length); 52 | 53 | return out; 54 | } 55 | 56 | typedef struct { 57 | TAG_Short length ; 58 | if (length > 0) char d[length]; 59 | } TAG_String ; 60 | 61 | string read_TAG_String(TAG_String &in) { 62 | if (in.length > 0) { 63 | return in.d; 64 | } 65 | 66 | return ""; 67 | } 68 | 69 | typedef struct { 70 | local int i; 71 | TAG_TYPE tagType ; 72 | TAG_Int length ; 73 | 74 | for (i = 0; i < length; i++) { 75 | TAG(tagType); 76 | } 77 | } TAG_List ; 78 | 79 | string read_TAG_LIST(TAG_List &in) { 80 | string out; 81 | 82 | SPrintf(out, "%s[%i]", EnumToString(in.tagType), in.length); 83 | 84 | return out; 85 | } 86 | 87 | typedef struct { 88 | TAG_TYPE tagType ; 89 | 90 | if (tagType != 0) { 91 | TAG_String name ; 92 | TAG(tagType); 93 | } 94 | } TAG_Named ; 95 | 96 | string read_TAG_Named(TAG_Named &in) { 97 | string out; 98 | 99 | SPrintf(out, "%s", EnumToString(in.tagType)); 100 | 101 | if (in.tagType != 0) { 102 | SPrintf(out, "%s(\"%s\")", out, read_TAG_String(in.name)); 103 | } 104 | 105 | return out; 106 | } 107 | 108 | typedef struct { 109 | local int found_end = 0; 110 | local int tag_count = 0; 111 | 112 | while (!found_end) { 113 | found_end = (ReadByte(FTell()) == 0); 114 | 115 | TAG_Named d; 116 | tag_count++; 117 | } 118 | } TAG_Compound ; 119 | 120 | string read_TAG_Compound(TAG_Compound &in) { 121 | string out; 122 | 123 | SPrintf(out, "TAG_Named[%i]", in.tag_count - 1); 124 | 125 | return out; 126 | } 127 | 128 | void TAG(TAG_TYPE tagType) { 129 | switch (tagType) { 130 | case 0: 131 | TAG_End d; 132 | break; 133 | case 1: 134 | TAG_Byte d; 135 | break; 136 | case 2: 137 | TAG_Short d; 138 | break; 139 | case 3: 140 | TAG_Int d; 141 | break; 142 | case 4: 143 | TAG_Long d; 144 | break; 145 | case 5: 146 | TAG_Float d; 147 | break; 148 | case 6: 149 | TAG_Double d; 150 | break; 151 | case 7: 152 | TAG_Byte_Array d; 153 | break; 154 | case 8: 155 | TAG_String d; 156 | break; 157 | case 9: 158 | TAG_List d; 159 | break; 160 | case 10: 161 | TAG_Compound d; 162 | break; 163 | } 164 | } 165 | 166 | DisplayFormatDecimal(); 167 | BigEndian(); 168 | 169 | TAG_Named f; 170 | -------------------------------------------------------------------------------- /010 Templates/OVL.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: OVL.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: Parse Elite Dangerous ovl files 8 | // Category: Archive 9 | // File Mask: *.ovl 10 | // ID Bytes: 46 52 45 53 // FRES 11 | // History: 12 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.2 2015-08-03 Andrew McRae: Merge changes 14 | // 0.1 2015-03-10 Andrew McRae: Initial revision 15 | //------------------------------------------------ 16 | 17 | typedef uint64 u8; 18 | typedef uint32 u4; 19 | typedef uint16 u2; 20 | typedef ubyte u1; 21 | typedef int64 s8; 22 | typedef int32 s4; 23 | typedef int16 s2; 24 | typedef byte s1; 25 | 26 | local u4 zlib_length = 0; 27 | local u4 zlib_uncomp_length = 0; 28 | 29 | typedef struct { 30 | char sig[4]; // 1575F48 31 | 32 | u1 flags; // 1575F4C 33 | u1 version; // 1575F4D 34 | 35 | u1 need_bswap; // 1575F4E 36 | u1 unknown07 ; // 1575F4F 37 | u4 flags2; // 1575F50 38 | u4 unknown0C ; // 1575F54 39 | 40 | u4 names_length; // 1575F58 41 | 42 | u4 unknown2_count ; // 1575F5C 43 | u4 other_count ; // 1575F60 44 | u2 dir_count ; // 1575F64 45 | u2 type_count ; // 1575F66 46 | u4 file_count ; // 1575F68 47 | u4 file_count2 ; // 1575F6C 48 | u4 part_count ; // 1575F70 49 | u4 archive_count ; // 1575F74 50 | 51 | u4 unknown30 ; // 1575F78 52 | u4 unknown34 ; // 1575F7C 53 | u4 unknown38 ; // 1575F80 54 | u4 unknown3C ; // 1575F84 55 | 56 | u4 unknown_count ; // 1575F88 57 | 58 | u4 unknown44 ; // 1575F8C 59 | u4 unknown48 ; // 1575F90 60 | u4 unknown4C ; // 1575F94 61 | 62 | //Assert((flags == 0) || (flags == 0x08), "HEADER flags not 0 or 0x08"); 63 | Assert((version == 0x12) || (version == 0x13), "HEADER version not 0x12 or 0x13"); 64 | Assert(file_count2 == file_count, "HEADER file_count2 mismatch"); 65 | Assert((file_count == 0) || (names_length > 0), "HEADER names_length is 0"); 66 | //Assert(dir_count == 0, "HEADER dir_count not 0"); 67 | //Assert(part_count == 0, "HEADER part_count not 0"); 68 | //Assert(other_count == 0, "HEADER other_count not 0"); 69 | //Assert(archive_count == 1, "HEADER archive_count not 1"); 70 | Assert(unknown2_count == 0, "HEADER unknown2_count not 0"); 71 | //Assert(!(dir_count != 0 && part_count != 0), "HEADER dir and part"); 72 | Assert(!(dir_count != 0 && other_count != 0), "HEADER dir and other"); 73 | Assert(!(part_count != 0 && other_count != 0), "HEADER part and other"); 74 | 75 | //Assert(flags2 == 0x00006094, "HEADER flags2 not 0x00006094"); 76 | } HEADER; 77 | 78 | typedef struct { 79 | u4 archive_names_length; 80 | u4 file_count3 ; 81 | u4 type_names_length; 82 | 83 | u4 zero0C ; 84 | u4 zero10 ; 85 | u4 zero14 ; 86 | u4 zero18 ; 87 | u4 zero1C ; 88 | u4 zero20 ; 89 | u4 zero24 ; 90 | u4 zero28 ; 91 | u4 zero2C ; 92 | u4 zero30 ; 93 | u4 zero34 ; 94 | u4 zero38 ; 95 | u4 zero3C ; 96 | 97 | Assert((h.archive_count == 0) || (archive_names_length > 0), "HEADER archive_names_length is 0"); 98 | Assert((h.file_count == 0) || (type_names_length > 0), "HEADER2 type_names_length is 0"); 99 | Assert(file_count3 == h.file_count, "HEADER2 file_count3 mismatch"); 100 | 101 | Assert(zero0C == 0, "HEADER2 zero0C"); 102 | Assert(zero10 == 0, "HEADER2 zero10"); 103 | Assert(zero14 == 0, "HEADER2 zero14"); 104 | Assert(zero18 == 0, "HEADER2 zero18"); 105 | Assert(zero1C == 0, "HEADER2 zero1C"); 106 | Assert(zero20 == 0, "HEADER2 zero20"); 107 | Assert(zero24 == 0, "HEADER2 zero24"); 108 | Assert(zero28 == 0, "HEADER2 zero28"); 109 | Assert(zero2C == 0, "HEADER2 zero2C"); 110 | Assert(zero30 == 0, "HEADER2 zero30"); 111 | Assert(zero34 == 0, "HEADER2 zero34"); 112 | Assert(zero38 == 0, "HEADER2 zero38"); 113 | Assert(zero3C == 0, "HEADER2 zero3C"); 114 | } HEADER2; 115 | 116 | typedef struct { 117 | u4 name_offset; 118 | if (is64bit) { 119 | u4 zero04 ;; 120 | } 121 | u4 hash; 122 | 123 | u2 unknown08 ; 124 | u2 unknown0A ; 125 | u4 unknown0C ; 126 | u4 count ; 127 | 128 | Assert(name_offset < h.names_length, "TYPE name_offset too high"); 129 | if (is64bit) { 130 | Assert(zero04 == 0, "TYPE zero60"); 131 | } 132 | 133 | local quad o = FTell(); 134 | FSeek(name_offset + full_names_offset); 135 | 136 | string name ; 137 | 138 | FSeek(o); 139 | } TYPE ; 140 | string read_TYPE(TYPE &in) { 141 | local string out; 142 | SPrintf(out, "\"%s\" %08Xh %Xh %Xh %Xh %d", in.name, in.hash, in.unknown08, in.unknown0A, in.unknown0C, in.count); 143 | return out; 144 | } 145 | 146 | typedef struct { 147 | TYPE t[h.type_count]; 148 | } TYPES ; 149 | string read_TYPES(TYPES &in) { 150 | local string out; 151 | SPrintf(out, "%u", h.type_count); 152 | return out; 153 | } 154 | 155 | typedef struct { 156 | u4 name_offset; 157 | u4 hash; 158 | 159 | u2 unknown08 ; 160 | 161 | u2 type ; 162 | 163 | Assert(type < h.type_count, "FILE type too high"); 164 | Assert(name_offset < h.names_length, "FILE name_offset too high"); 165 | 166 | local quad o = FTell(); 167 | FSeek(name_offset + full_names_offset); 168 | 169 | string name ; 170 | 171 | FSeek(o); 172 | } FILE ; 173 | string read_FILE(FILE &in) { 174 | local string out; 175 | SPrintf(out, "\"%s\" \"%s\" %08Xh %Xh", in.name, t.t[in.type].name, in.hash, in.unknown08); 176 | return out; 177 | } 178 | 179 | typedef struct { 180 | FILE f[h.file_count]; 181 | } FILES ; 182 | string read_FILES(FILES &in) { 183 | local string out; 184 | SPrintf(out, "%u", h.file_count); 185 | return out; 186 | } 187 | 188 | typedef struct { 189 | u4 name_offset; 190 | 191 | u4 unknown04 ; 192 | u4 unknown08 ; 193 | u4 fh2_count ; 194 | u2 fh3_count ; 195 | u2 fh1_count ; 196 | u4 zero14 ; 197 | u4 unknown18 ; 198 | u4 fh6_count ; 199 | u4 fh5_count ; 200 | u4 zero24 ; 201 | u4 unknown28 ; 202 | 203 | u4 comp_size; 204 | u4 uncomp_size; 205 | 206 | u4 zero34 ; 207 | u4 unknown38 ; 208 | u4 header2_size; 209 | u4 unknown40 ; 210 | 211 | Assert(name_offset < h2.archive_names_length, "FILE name_offset too high"); 212 | 213 | local quad o = FTell(); 214 | FSeek(name_offset + full_archive_names_offset); 215 | 216 | string name ; 217 | 218 | FSeek(o); 219 | 220 | // check if STATIC archive 221 | if (name == "STATIC") { 222 | zlib_length = comp_size; 223 | zlib_uncomp_length = uncomp_size; 224 | } 225 | 226 | //Assert(unknown04 == 0, "ARCHIVE unknown04"); 227 | //Assert(unknown08 == 0, "ARCHIVE unknown08"); 228 | Assert(zero14 == 0, "ARCHIVE zero14"); 229 | Assert(zero24 == 0, "ARCHIVE zero24"); 230 | Assert(zero34 == 0, "ARCHIVE zero34"); 231 | //Assert(unknown38 == 0, "ARCHIVE unknown38"); 232 | //Assert(unknown40 == 0, "ARCHIVE unknown40"); 233 | } ARCHIVE ; 234 | string read_ARCHIVE(ARCHIVE &in) { 235 | local string out; 236 | SPrintf(out, "\"%s\" %Xh %Xh", in.name, in.comp_size, in.uncomp_size); 237 | return out; 238 | } 239 | 240 | typedef struct { 241 | ARCHIVE a[h.archive_count]; 242 | } ARCHIVES ; 243 | string read_ARCHIVES(ARCHIVES &in) { 244 | local string out; 245 | SPrintf(out, "%u", h.archive_count); 246 | return out; 247 | } 248 | 249 | typedef struct { 250 | u4 name_offset; 251 | 252 | Assert(name_offset < h.names_length, "DIR name_offset too high"); 253 | 254 | local quad o = FTell(); 255 | FSeek(name_offset + full_names_offset); 256 | 257 | string name ; 258 | 259 | FSeek(o); 260 | } DIR ; 261 | string read_DIR(DIR &in) { 262 | local string out; 263 | SPrintf(out, "\"%s\"", in.name); 264 | return out; 265 | } 266 | 267 | typedef struct { 268 | DIR d[h.dir_count]; 269 | } DIRS ; 270 | string read_DIRS(DIRS &in) { 271 | local string out; 272 | SPrintf(out, "%u", h.dir_count); 273 | return out; 274 | } 275 | 276 | typedef struct { 277 | u4 hash; 278 | u4 name_offset; 279 | 280 | u4 unknown08 ; 281 | u4 unknown0C ; 282 | u4 unknown10 ; 283 | 284 | Assert(name_offset < h.names_length, "PART name_offset too high"); 285 | 286 | local quad o = FTell(); 287 | FSeek(name_offset + full_names_offset); 288 | 289 | string name ; 290 | 291 | FSeek(o); 292 | } PART ; 293 | string read_PART(PART &in) { 294 | local string file_name; 295 | SPrintf(file_name, "%08Xh", in.hash); 296 | local int i; 297 | for (i = 0; i < h.file_count; i++) { 298 | if (f.f[i].hash == in.hash) { 299 | SPrintf(file_name, "\"%s\"", f.f[i].name); 300 | break; 301 | } 302 | } 303 | 304 | local string out; 305 | SPrintf(out, "%s \"%s\" %Xh %Xh %Xh", file_name, in.name, in.unknown08, in.unknown0C, in.unknown10); 306 | return out; 307 | } 308 | 309 | typedef struct { 310 | PART p[h.part_count]; 311 | } PARTS ; 312 | string read_PARTS(PARTS &in) { 313 | local string out; 314 | SPrintf(out, "%u", h.part_count); 315 | return out; 316 | } 317 | 318 | typedef struct { 319 | u4 unknown00 ; 320 | 321 | u4 name_offset; 322 | 323 | u4 unknown08 ; 324 | 325 | Assert(name_offset < h.names_length, "OTHER name_offset too high"); 326 | 327 | local quad o = FTell(); 328 | FSeek(name_offset + full_names_offset); 329 | 330 | string name ; 331 | 332 | FSeek(o); 333 | } OTHER ; 334 | string read_OTHER(OTHER &in) { 335 | local string out; 336 | SPrintf(out, "\"%s\" %Xh %08Xh", in.name, in.unknown00, in.unknown08); 337 | return out; 338 | } 339 | 340 | typedef struct { 341 | OTHER o[h.other_count]; 342 | } OTHERS ; 343 | string read_OTHERS(OTHERS &in) { 344 | local string out; 345 | SPrintf(out, "%u", h.other_count); 346 | return out; 347 | } 348 | 349 | typedef struct { 350 | u4 unknown00 ; 351 | u4 unknown04 ; 352 | u4 unknown08 ; 353 | } UNKNOWN ; 354 | string read_UNKNOWN(UNKNOWN &in) { 355 | local string out; 356 | SPrintf(out, "%Xh %Xh %Xh", in.unknown00, in.unknown04, in.unknown08); 357 | return out; 358 | } 359 | 360 | typedef struct { 361 | UNKNOWN u[h.unknown_count]; 362 | } UNKNOWNS ; 363 | string read_UNKNOWNS(UNKNOWNS &in) { 364 | local string out; 365 | SPrintf(out, "%u", h.unknown_count); 366 | return out; 367 | } 368 | 369 | typedef struct { 370 | u4 unknown00 ; 371 | u4 data_size ; 372 | } ARCHIVE2 ; 373 | string read_ARCHIVE2(ARCHIVE2 &in) { 374 | local string out; 375 | SPrintf(out, "%Xh %Xh", in.unknown00, in.data_size); 376 | return out; 377 | } 378 | 379 | typedef struct { 380 | ARCHIVE2 a2[h.archive_count]; 381 | } ARCHIVES2 ; 382 | string read_ARCHIVES2(ARCHIVES2 &in) { 383 | local string out; 384 | SPrintf(out, "%u", h.archive_count); 385 | return out; 386 | } 387 | 388 | typedef struct { 389 | Assert(zlib_length > 0, "ZLIB zlib_length is 0"); 390 | Assert(ReadUShort() == 0x9c78, "ZLIB bad zlib header"); 391 | 392 | u1 data[zlib_length]; 393 | 394 | Assert(FTell() == FileSize(), "ZLIB trailing data"); 395 | } ZLIB ; 396 | string read_ZLIB(ZLIB &in) { 397 | local string out; 398 | SPrintf(out, "%Xh %Xh", zlib_length, zlib_uncomp_length); 399 | return out; 400 | } 401 | 402 | DisplayFormatHex(); 403 | LittleEndian(); 404 | 405 | local int i; 406 | 407 | Assert(ReadString(0, 4) == "FRES", "Bad sig!"); 408 | 409 | local u4 full_names_offset = 0x90; 410 | 411 | SetBackColor(0xb0b0b0); 412 | HEADER h; 413 | HEADER2 h2; 414 | 415 | local int is64bit = h.flags & 0x08; 416 | 417 | // skip main name table 418 | local u4 full_types_offset = h.names_length + full_names_offset; 419 | FSeek(full_types_offset); 420 | 421 | SetBackColor(0xffb0b0); 422 | if (h.type_count) { 423 | TYPES t; 424 | } 425 | 426 | SetBackColor(0xb0ffb0); 427 | if (h.file_count) { 428 | FILES f; 429 | } 430 | 431 | // skip archive name table 432 | local u4 full_archive_names_offset; 433 | local u4 full_archives_offset; 434 | if (is64bit) { 435 | full_archive_names_offset = h.file_count * 0x0C + h.type_count * 0x18 + full_types_offset; 436 | } else { 437 | full_archive_names_offset = h.file_count * 0x0C + h.type_count * 0x14 + full_types_offset; 438 | } 439 | full_archives_offset = h2.archive_names_length + full_archive_names_offset; 440 | FSeek(full_archives_offset); 441 | 442 | SetBackColor(0xb0b0ff); 443 | if (h.archive_count) { 444 | ARCHIVES a; 445 | } 446 | 447 | SetBackColor(0xb0ffff); 448 | if (h.dir_count) { 449 | DIRS d; 450 | } 451 | 452 | SetBackColor(0xffb0ff); 453 | if (h.part_count) { 454 | PARTS p; 455 | } 456 | 457 | SetBackColor(0xffffb0); 458 | if (h.other_count) { 459 | OTHERS o; 460 | } 461 | 462 | SetBackColor(0x48a0ff); 463 | if (h.unknown_count) { 464 | UNKNOWNS u; 465 | } 466 | 467 | SetBackColor(0xffa048); 468 | if (h.archive_count) { 469 | ARCHIVES2 a2; 470 | } 471 | 472 | SetBackColor(0x909090); 473 | ZLIB z; 474 | 475 | if (h.archive_count) { 476 | for (i = 0; i < h.archive_count; i++) { 477 | Printf("\nname: %s, comp_size: %Xh, uncomp_size: %Xh\n", a.a[i].name, a.a[i].comp_size, a.a[i].uncomp_size); 478 | Printf("header2_size: %Xh, data_size: %Xh\n", a.a[i].header2_size, a2.a2[i].data_size); 479 | Printf("(%d, %d, %d, ?, %d, %d, ?)\n", a.a[i].fh1_count, a.a[i].fh2_count, a.a[i].fh3_count, a.a[i].fh5_count, a.a[i].fh6_count); 480 | } 481 | } 482 | -------------------------------------------------------------------------------- /010 Templates/OVLT.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: OVLT.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: Parse Elite Dangerous compressed ovl texture block 8 | // Category: Image 9 | // History: 10 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.2 2015-08-03 Andrew McRae: Merge changes 12 | // 0.1 2015-08-01 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | typedef uint64 u8; 16 | typedef uint32 u4; 17 | typedef uint16 u2; 18 | typedef ubyte u1; 19 | typedef int64 s8; 20 | typedef int32 s4; 21 | typedef int16 s2; 22 | typedef byte s1; 23 | 24 | typedef struct { 25 | u2 unknown00 ; 26 | u2 unknown02 ; 27 | } FILE_HEAD1 ; 28 | string read_FILE_HEAD1(FILE_HEAD1 &in) { 29 | local string out; 30 | SPrintf(out, "%Xh %Xh", in.unknown00, in.unknown02); 31 | return out; 32 | } 33 | 34 | typedef struct { 35 | u4 zero00 ; 36 | u4 h2_size; 37 | u4 h2_offset; 38 | u4 file_hash ; 39 | u4 unknown10 ; 40 | u4 type_hash ; 41 | u4 zero18 ; 42 | 43 | Assert(zero00 == 0, "FILE_HEAD2 zero00"); 44 | Assert(zero18 == 0, "FILE_HEAD2 zero18"); 45 | } FILE_HEAD2 ; 46 | string read_FILE_HEAD2(FILE_HEAD2 &in) { 47 | local string out; 48 | SPrintf(out, "%Xh %Xh %Xh %Xh %Xh %Xh %Xh", in.zero00, in.h2_size, in.h2_offset, in.file_hash, in.unknown10, in.type_hash, in.zero18); 49 | return out; 50 | } 51 | 52 | typedef struct { 53 | u4 file_hash; 54 | u4 type_hash; 55 | u4 unknown08 ; 56 | u4 unknown0C ; 57 | u4 unknown10 ; 58 | u4 file_length; 59 | } FILE_HEAD3 ; 60 | string read_FILE_HEAD3(FILE_HEAD3 &in) { 61 | local string out; 62 | SPrintf(out, "%Xh %Xh %Xh %Xh %Xh %Xh", in.file_hash, in.type_hash, in.unknown08, in.unknown0C, in.unknown10, in.file_length); 63 | return out; 64 | } 65 | 66 | typedef struct { 67 | u4 unknown00 ; 68 | u4 unknown04 ; 69 | u4 unknown08 ; 70 | u4 file_length; 71 | } FILE_HEAD4 ; 72 | string read_FILE_HEAD4(FILE_HEAD4 &in) { 73 | local string out; 74 | SPrintf(out, "%Xh %Xh %Xh %Xh", in.unknown00, in.unknown04, in.unknown08, in.file_length); 75 | return out; 76 | } 77 | 78 | typedef struct { 79 | u4 file_hash; 80 | u4 type_hash; 81 | u4 unknown08 ; 82 | u4 offset; 83 | } FILE_HEAD5 ; 84 | string read_FILE_HEAD5(FILE_HEAD5 &in) { 85 | local string out; 86 | SPrintf(out, "%Xh %Xh %Xh %Xh", in.file_hash, in.type_hash, in.unknown08, in.offset); 87 | return out; 88 | } 89 | 90 | typedef struct { 91 | u4 unknown00 ; 92 | u4 offset1; 93 | u4 unknown08 ; 94 | u4 offset2; 95 | } FILE_HEAD6 ; 96 | string read_FILE_HEAD6(FILE_HEAD6 &in) { 97 | local string out; 98 | SPrintf(out, "%Xh %Xh %Xh %Xh", in.unknown00, in.offset1, in.unknown08, in.offset2); 99 | return out; 100 | } 101 | 102 | typedef struct { 103 | u4 unknown00 ; 104 | u4 unknown04 ; 105 | } FILE_HEAD7 ; 106 | string read_FILE_HEAD7(FILE_HEAD7 &in) { 107 | local string out; 108 | SPrintf(out, "%Xh %Xh", in.unknown00, in.unknown04); 109 | return out; 110 | } 111 | 112 | typedef struct (int fh1_count, int fh2_count, int fh3_count, int fh4_count, int fh5_count, int fh6_count, int fh7_count) { 113 | if (fh1_count) { 114 | FILE_HEAD1 fh1[fh1_count]; 115 | } 116 | if (fh2_count) { 117 | FILE_HEAD2 fh2[fh2_count]; 118 | } 119 | if (fh3_count) { 120 | FILE_HEAD3 fh3[fh3_count]; 121 | } 122 | if (fh4_count) { 123 | FILE_HEAD4 fh4[fh4_count]; 124 | } 125 | if (fh5_count) { 126 | FILE_HEAD5 fh5[fh5_count]; 127 | } 128 | if (fh6_count) { 129 | FILE_HEAD6 fh6[fh6_count]; 130 | } 131 | if (fh7_count) { 132 | FILE_HEAD7 fh7[fh7_count]; 133 | } 134 | 135 | u8 sig; 136 | 137 | Assert(sig == 0x010204083F7FBFFF, "HEADER signature not 0x010204083F7FBFFF"); 138 | } HEADER; 139 | 140 | DisplayFormatHex(); 141 | LittleEndian(); 142 | 143 | local int header2_size = 0; 144 | local int data1_size = 0; 145 | local int data2_size = 0; 146 | 147 | //header2_size = 0x60; // StationIdents/Data.ovl 148 | //data2_size = 0x1ab00; // StationIdents/Data.ovl 149 | //header2_size = 0x1490; // Astro.ovl 150 | header2_size = 0x28; // Earth/Data.ovl 151 | data2_size = 0xaaac; // Earth/Data.ovl 152 | //header2_size = 8; // Earth/Data.ovs.textures_l0 153 | //data2_size = 0x2aaaaac; // Earth/Data.ovs.textures_l0 154 | //header2_size = 0x2a0; // Root_Final.ovl 155 | //data1_size = 0x0234; // Root_Final.ovl 156 | //data2_size = 0x5570; // Root_Final.ovl 157 | 158 | local int i; 159 | 160 | SetBackColor(0xb0b0b0); 161 | //HEADER h(1, 1, 4, 4, 4, 4, 1); // StationIdents/Data.ovl 162 | //HEADER h(2, 2, 0, 0, 23, 104, 1); // Astro.ovl 163 | HEADER h(1, 1, 1, 1, 1, 1, 1); // Earth/Data.ovl 164 | //HEADER h(1, 1, 1, 0, 0, 0, 1); // Earth/Data.ovs.textures_l0 165 | //HEADER h(2, 2, 5, 2, 5, 12, 1); // Root_Final.ovl 166 | //HEADER h(4, 4, 3, 3, 5, 13, 1); // FederationSymbol/Data.ovl 167 | 168 | if (header2_size) { 169 | SetBackColor(0xffb0b0); 170 | u1 h2[header2_size]; 171 | } 172 | 173 | if (data1_size) { 174 | SetBackColor(0xb0b0ff); 175 | u1 d1[data1_size]; 176 | } 177 | 178 | if (data2_size) { 179 | SetBackColor(0xd0d0ff); 180 | u1 d2[data2_size]; 181 | } 182 | -------------------------------------------------------------------------------- /010 Templates/PIR.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: PIR.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: XBOX LIVE/PIRS/CON files 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | // UNICODE support 15 | // Thanks to Graeme Sweet for pointing this out! 16 | int CalcUnicodeLen() { 17 | local quad pos = FTell(); 18 | local quad base = pos; 19 | while ((ReadUShort(pos) != 0) && (pos - base < 65535)) { 20 | pos += 2; 21 | } 22 | return (pos - base + 2) / 2; 23 | } 24 | 25 | typedef struct { 26 | UINT16 s[CalcUnicodeLen()]; 27 | } WCHAR ; 28 | 29 | string WCHAR_read(WCHAR &z) { 30 | int len = sizeof(z.s) / 2; 31 | char s[len]; 32 | ConvertUNICODEToASCIIW(len, z.s, s); 33 | return s; 34 | } 35 | 36 | typedef struct { 37 | UINT16 s[128]; 38 | } WCHAR128 ; 39 | 40 | string WCHAR128_read(WCHAR128 &z) { 41 | int len = 128; 42 | char s[len]; 43 | ConvertUNICODEToASCIIW(len, z.s, s); 44 | return s; 45 | } 46 | 47 | typedef struct { 48 | UINT16 s[64]; 49 | } WCHAR64 ; 50 | 51 | string WCHAR64_read(WCHAR64 &z) { 52 | int len = 64; 53 | char s[len]; 54 | ConvertUNICODEToASCIIW(len, z.s, s); 55 | return s; 56 | } 57 | 58 | typedef struct { 59 | UBYTE d[3]; 60 | } UINT24 ; 61 | 62 | string UINT24_read(UINT24 &in) { 63 | string out; 64 | int i; 65 | for (i = 0; i < 2; i++) { 66 | SPrintf(out, "%s%02X", out, in.d[i]); 67 | } 68 | SPrintf(out, "%sh", out); 69 | return out; 70 | } 71 | 72 | typedef struct { 73 | UBYTE d[5]; 74 | } UINT40 ; 75 | 76 | string UINT40_read(UINT40 &in) { 77 | string out; 78 | int i; 79 | for (i = 0; i < 5; i++) { 80 | SPrintf(out, "%s%02X", out, in.d[i]); 81 | } 82 | SPrintf(out, "%sh", out); 83 | return out; 84 | } 85 | 86 | typedef struct { 87 | UBYTE d[20]; 88 | } SHA1HASH ; 89 | 90 | string SHA1_read(struct SHA1HASH &in) { 91 | string out; 92 | int i; 93 | for (i = 0; i < 20; i++) { 94 | SPrintf(out, "%s%02X", out, in.d[i]); 95 | } 96 | SPrintf(out, "%sh", out); 97 | return out; 98 | } 99 | 100 | typedef struct { 101 | UINT64 Id; 102 | UINT32 Int1; 103 | UINT32 Int2; 104 | } LICENSE ; 105 | 106 | string LICENSE_read(struct LICENSE &in) { 107 | string out; 108 | 109 | SPrintf(out, "%016LXh", in.Id); 110 | return out; 111 | } 112 | 113 | typedef struct { 114 | local string csum; 115 | local int i; 116 | 117 | CHAR Sig[4]; 118 | 119 | if (Sig == "CON ") { 120 | UBYTE Cert[0xA8]; 121 | UBYTE ConsoleSig[0x100]; 122 | UBYTE FileSig[0x80]; 123 | } 124 | else { 125 | UBYTE Signature[0x100]; 126 | UBYTE Unknown[0x128]; 127 | } 128 | 129 | for (i = 0; i < 0x10; i++) { 130 | LICENSE l; 131 | } 132 | 133 | SHA1HASH ContentID; 134 | 135 | UINT32 EntryID; 136 | UINT32 ContentType; 137 | UINT32 MetadataVersion; 138 | UINT64 ContentSize; 139 | UINT32 MediaID; 140 | UINT32 Version; 141 | UINT32 VersionBase; 142 | UINT32 TitleID; 143 | UBYTE Platform; 144 | UBYTE ExecutableType; 145 | UBYTE DiscNumber; 146 | UBYTE DiscInSet; 147 | UINT32 SaveGameID; 148 | UINT40 SaveConsoleID; 149 | UINT64 ProfileID; 150 | UBYTE VolumeDescSize; 151 | UBYTE Unknown; 152 | UBYTE BlockSeperation; 153 | LittleEndian(); 154 | UINT16 FileTableBlockCount; 155 | BigEndian(); 156 | UINT24 FileTableBlockNumber; 157 | SHA1HASH MasterHash; 158 | UINT32 AllocCount; 159 | UINT32 UnallocCount; 160 | UINT32 DataFileCount; 161 | UINT64 DataFileSize; 162 | UINT32 Unknown; 163 | UINT32 Unknown; 164 | if (MetadataVersion == 2) { 165 | UBYTE SeriesID[0x10]; 166 | UBYTE SeasonID[0x10]; 167 | UINT16 SeasonNumber; 168 | UINT16 EpisodeNumber; 169 | } 170 | else { 171 | UINT32 Unknown; 172 | UINT32 Unknown; 173 | UINT32 Unknown; 174 | UINT32 Unknown; 175 | UINT32 Unknown; 176 | UINT32 Unknown; 177 | UINT32 Unknown; 178 | UINT32 Unknown; 179 | UINT32 Unknown; 180 | } 181 | UINT32 Unknown; 182 | UINT32 Unknown; 183 | UINT32 Unknown; 184 | UINT32 Unknown; 185 | UINT32 Unknown; 186 | UINT32 Unknown; 187 | UINT32 Unknown; 188 | UINT32 Unknown; 189 | UINT32 Unknown; 190 | UINT32 Unknown; 191 | CHAR DeviceID[0x14]; 192 | for (i = 0; i < 9; i++) { 193 | WCHAR128 Titles; 194 | } 195 | for (i = 0; i < 9; i++) { 196 | WCHAR128 Descriptions; 197 | } 198 | WCHAR64 Publisher; 199 | WCHAR64 Title; 200 | UBYTE TransferFlags; 201 | UINT32 PackageImageSize; 202 | UINT32 ContentImageSize; 203 | if (MetadataVersion == 2) { 204 | UBYTE PackageImage[0x3D00]; 205 | for (i = 0; i < 3; i++) { 206 | WCHAR128 Titles; 207 | } 208 | UBYTE ContentImage[0x3D00]; 209 | for (i = 0; i < 3; i++) { 210 | WCHAR128 Descriptions; 211 | } 212 | } 213 | else { 214 | UBYTE PackageImage[0x4000]; 215 | UBYTE ContentImage[0x4000]; 216 | } 217 | } STFSHEADER ; 218 | 219 | string read_STFSHEADER(STFSHEADER &in) { 220 | return WCHAR128_read(in.Titles[0]); 221 | // string out; 222 | // SPrintf(out, "%s %s", in.Sig, WCHAR128_read(in.Titles[0])); 223 | // return out; 224 | } 225 | 226 | DisplayFormatHex(); 227 | BigEndian(); 228 | 229 | local uchar sig[4]; 230 | ReadBytes(sig, 0, 4); 231 | 232 | if (sig == "CON " || sig == "LIVE" || sig == "PIRS") { 233 | } 234 | else { 235 | Printf("Invalid signature\n"); 236 | Exit(-1); 237 | } 238 | 239 | SetBackColor(0xe0e0e0); 240 | STFSHEADER f; 241 | -------------------------------------------------------------------------------- /010 Templates/RD.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: RD.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: PS2 BIOS ROMDIR parser 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | LittleEndian(); 16 | 17 | local int64 cur_pos; 18 | local int64 temp_pos; 19 | local int64 extinfo_pos; 20 | local char cur_filename[10]; 21 | local int extinfo_found; 22 | 23 | typedef struct { 24 | ushort value; 25 | ubyte size ; 26 | ubyte id; 27 | 28 | if (size > 0) { 29 | SetBackColor(0xffffc0); 30 | ubyte data[size]; 31 | SetBackColor(0xffffe0); 32 | } 33 | } EXTINFO ; 34 | 35 | string EXTINFO_read(EXTINFO &in) { 36 | string out; 37 | switch (in.id) { 38 | case 1: 39 | SPrintf(out, "%02x%02x-%02x-%02x", in.data[3], in.data[2], in.data[1], in.data[0]); 40 | break; 41 | case 2: 42 | SPrintf(out, "V: %x", in.value); 43 | break; 44 | case 3: 45 | SPrintf(out, "\"%s\"", in.data); 46 | break; 47 | case 0x7f: 48 | SPrintf(out, ""); 49 | break; 50 | default: 51 | SPrintf(out, "(%02x) %04x", in.id, in.value); 52 | break; 53 | } 54 | return out; 55 | } 56 | 57 | typedef struct { 58 | char filename[10]; 59 | ushort extinfosize ; 60 | uint filesize ; 61 | 62 | temp_pos = FTell(); 63 | 64 | if (extinfosize > 0) { 65 | FSeek(extinfo_pos); 66 | 67 | do { 68 | SetBackColor(0xffffe0); 69 | EXTINFO e; 70 | SetBackColor(0xe0e0e0); 71 | } while (FTell() < (extinfo_pos + extinfosize)); 72 | 73 | extinfo_pos += extinfosize; 74 | } 75 | 76 | FSeek(cur_pos); 77 | 78 | if (filename != "ROMDIR" && filename != "EXTINFO") { 79 | SetBackColor(0xc0ffc0); 80 | } 81 | else { 82 | SetBackColor(cNone); 83 | } 84 | ubyte data[filesize]; 85 | SetBackColor(0xe0e0e0); 86 | 87 | if ((filesize % 0x10) == 0) { 88 | cur_pos += filesize; 89 | } 90 | else { 91 | cur_pos += (filesize + 0x10) & 0xfffffff0; 92 | } 93 | 94 | FSeek(temp_pos); 95 | } ROMDIR ; 96 | 97 | string ROMDIR_read(ROMDIR & in) { 98 | return in.filename; 99 | } 100 | 101 | cur_pos = 0; 102 | do { 103 | ReadBytes(cur_filename, cur_pos, 10); 104 | 105 | if (cur_filename == "RESET") break; 106 | 107 | cur_pos += 16; 108 | } while (cur_pos < 512*1024); 109 | 110 | if (cur_pos >= 512*1024) { 111 | Warning("ROMDIR not found"); 112 | Exit(-1); 113 | } 114 | 115 | FSeek(cur_pos); 116 | 117 | temp_pos = 0; 118 | do { 119 | ReadBytes(cur_filename, cur_pos, 10); 120 | 121 | if (cur_filename == "EXTINFO") { 122 | extinfo_pos = temp_pos; 123 | break; 124 | } 125 | 126 | temp_pos += ReadInt(cur_pos + 0xc); 127 | 128 | cur_pos += 16; 129 | } while (ReadByte(cur_pos) != 0); 130 | 131 | cur_pos = 0; 132 | do { 133 | SetBackColor(0xe0e0e0); 134 | ROMDIR d; 135 | SetBackColor(cNone); 136 | } while (ReadByte(FTell()) != 0); 137 | -------------------------------------------------------------------------------- /010 Templates/RIFF.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: RIFF.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: scan for RIFF blocks 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2014-01-24 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | typedef struct { 15 | SetBackColor(0x8080ff); 16 | char s[4]; 17 | int l; 18 | SetBackColor(0xc0c0ff); 19 | uchar d[l]; 20 | SetBackColor(cNone); 21 | if (!FEof() && (l & 1)) { 22 | char p ; 23 | } 24 | } RIFF ; 25 | 26 | string read_RIFF(RIFF &in) { 27 | string out; 28 | if (IsLittleEndian()) { 29 | SPrintf(out, "%c%c%c%c %d", in.s[3], in.s[2], in.s[1], in.s[0], in.l); 30 | } else { 31 | SPrintf(out, "%s %d", in.s, in.l); 32 | } 33 | return out; 34 | } 35 | 36 | DisplayFormatHex(); 37 | 38 | FSeek(GetCursorPos()); 39 | 40 | while (!FEof()) { 41 | RIFF b; 42 | } 43 | -------------------------------------------------------------------------------- /010 Templates/ROM.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: ROM.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Option ROM parser 8 | // Category: Misc 9 | // File Mask: *.rom 10 | // History: 11 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.1 2012-06-01 Andrew McRae: Initial revision 13 | //------------------------------------------------ 14 | 15 | int block_type(int64 block_pos) { 16 | local ubyte cur_block[512]; 17 | local int i; 18 | local int empty_block; 19 | 20 | if (block_pos >= FileSize()) 21 | return -1; 22 | 23 | ReadBytes(cur_block, block_pos, 512); 24 | 25 | if (cur_block[0] == 0x55 && cur_block[1] == 0xAA) { 26 | if (cur_block[0x1E] == 0x49 && cur_block[0x1F] == 0x42 && cur_block[0x20] == 0x4D) 27 | return 3; 28 | 29 | if (cur_block[4] == 0xF1 && cur_block[5] == 0x0E) 30 | return 4; 31 | 32 | return 2; 33 | } 34 | 35 | if (cur_block[0] == 0x4D && cur_block[1] == 0x43 && cur_block[2] == 0x75 && cur_block[3] == 0x43) 36 | return 5; 37 | 38 | empty_block = 0; 39 | 40 | if (cur_block[0] == 0xff || cur_block[0] == 0x00) { 41 | empty_block = 1; 42 | 43 | for (i = 0; i < 512; i++) { 44 | if (cur_block[i] != cur_block[0]) { 45 | empty_block = 0; 46 | break; 47 | } 48 | } 49 | } 50 | 51 | if (empty_block) 52 | return 0; 53 | 54 | return 1; 55 | } 56 | 57 | typedef struct { 58 | local int64 rom_start = parentof(this).block_start; 59 | local int64 block_start = FTell(); 60 | local int64 block_end; 61 | 62 | char PCISignature[4]; 63 | ushort VendorID; 64 | ushort DeviceID; 65 | ushort VPDPtr; 66 | ushort Length; 67 | ubyte PCIRevision; 68 | ubyte ClassIFType; 69 | ubyte ClassSubType; 70 | ubyte ClassType; 71 | ushort ImageLength; 72 | ushort Revision; 73 | ubyte CodeType; 74 | ubyte Indicator; 75 | SetBackColor(0xffffd0); 76 | ushort r2 ; 77 | SetBackColor(0xffff90); 78 | 79 | block_end = FTell(); 80 | 81 | if (Length > 0x18) { 82 | SetBackColor(0xffffd0); 83 | ubyte r3[Length - (block_end - block_start)] ; 84 | SetBackColor(0xffff90); 85 | } 86 | 87 | //Printf("PCIR: %06Lxh+%06xh %02x\n", block_start, Length, checksum); 88 | } PCI_header; 89 | 90 | typedef struct { 91 | ubyte Display: 1; 92 | ubyte Input : 1; 93 | ubyte IPL : 1; 94 | ubyte Reserved : 1; 95 | ubyte Boot : 1; 96 | ubyte Cache : 1; 97 | ubyte Shadow : 1; 98 | ubyte DDI : 1; 99 | } PnPDevIndicators ; 100 | 101 | string read_PnPDevIndicators(PnPDevIndicators &flags) { 102 | string s = ""; 103 | 104 | if (flags.Display) Strcat(s, "Display "); 105 | if (flags.Input) Strcat(s, "Input "); 106 | if (flags.IPL) Strcat(s, "IPL "); 107 | if (flags.Reserved) Strcat(s, "Reserved "); 108 | if (flags.Boot) Strcat(s, "Boot "); 109 | if (flags.Cache) Strcat(s, "Cache "); 110 | if (flags.Shadow) Strcat(s, "Shadow "); 111 | if (flags.DDI) Strcat(s, "DDI "); 112 | 113 | return s; 114 | } 115 | 116 | typedef struct { 117 | local int64 rom_start = parentof(this).block_start; 118 | local int64 block_start = FTell(); 119 | local int64 block_end; 120 | local ubyte checksum; 121 | local char temp_sig[4]; 122 | 123 | char PnPSignature[4]; 124 | ubyte Revision; 125 | ubyte Length; 126 | ushort NextHeader; 127 | SetBackColor(0xffd0ff); 128 | ubyte r1 ; 129 | SetBackColor(0xff90ff); 130 | ubyte ChecksumFix; 131 | ushort VendorID; 132 | ushort DeviceID; 133 | ushort ManufacturerPtr; 134 | 135 | if (Length > 1) { 136 | ushort ProductNamePtr; 137 | ubyte DeviceType; 138 | ubyte DeviceSubType; 139 | ubyte DeviceIFType; 140 | PnPDevIndicators DeviceIndicators; 141 | ushort BootConnectionVector; 142 | ushort DisconnectVector; 143 | ushort BootstrapEntry; 144 | SetBackColor(0xffd0ff); 145 | ushort r2 ; 146 | SetBackColor(0xff90ff); 147 | ushort StaticResourceInformationVector; 148 | } 149 | 150 | block_end = FTell(); 151 | 152 | if (ManufacturerPtr) { 153 | FSeek(rom_start + ManufacturerPtr); 154 | 155 | SetBackColor(0xc0c0c0); 156 | string Manufacturer; 157 | SetBackColor(0xff90ff); 158 | } 159 | 160 | if (Length > 1) { 161 | if (ProductNamePtr) { 162 | FSeek(rom_start + ProductNamePtr); 163 | 164 | SetBackColor(0xc0c0c0); 165 | string ProductName; 166 | SetBackColor(0xff90ff); 167 | } 168 | } 169 | 170 | if (NextHeader) { 171 | ReadBytes(temp_sig, rom_start + PnPHeader, 4); 172 | 173 | if (temp_sig == "$PnP") { 174 | FSeek(block_start + PnPHeader); 175 | 176 | Warning("Nested $PnP Block"); 177 | } 178 | } 179 | 180 | FSeek(block_end); 181 | 182 | checksum = Checksum(CHECKSUM_BYTE, block_start, (Length*16)); 183 | 184 | //Printf("$PnP: %06Lxh+%06xh %02x\n", block_start, (Length*16), checksum); 185 | } PnP_header ; 186 | 187 | string read_PnP_header(PnP_header &in) { 188 | string out; 189 | SPrintf(out, "%02Xh", in.checksum); 190 | return out; 191 | } 192 | 193 | typedef struct { 194 | local int64 block_start = FTell(); 195 | local int64 data_start; 196 | local int64 block_end; 197 | local ubyte checksum; 198 | local char temp_sig[4]; 199 | 200 | ushort Signature; 201 | ubyte ROMLength; 202 | ubyte InitEntryCode[3]; 203 | SetBackColor(0xd0d0ff); 204 | ubyte r1[0x12] ; 205 | SetBackColor(0x9090ff); 206 | ushort PCIRHeader; 207 | ushort PnPHeader; 208 | 209 | data_start = FTell(); 210 | 211 | SetBackColor(0xd0d0ff); 212 | ubyte data[(ROMLength*512) - (data_start - block_start)]; 213 | SetBackColor(0x9090ff); 214 | 215 | block_end = FTell(); 216 | 217 | if (PCIRHeader) { 218 | ReadBytes(temp_sig, block_start + PCIRHeader, 4); 219 | 220 | if (temp_sig == "PCIR") { 221 | FSeek(block_start + PCIRHeader); 222 | 223 | SetBackColor(0xffff90); 224 | PCI_header h; 225 | SetBackColor(0x9090ff); 226 | } 227 | } 228 | 229 | if (PnPHeader) { 230 | ReadBytes(temp_sig, block_start + PnPHeader, 4); 231 | 232 | if (temp_sig == "$PnP") { 233 | FSeek(block_start + PnPHeader); 234 | 235 | SetBackColor(0xff90ff); 236 | PnP_header h; 237 | SetBackColor(0x9090ff); 238 | } 239 | } 240 | 241 | FSeek(block_end); 242 | 243 | checksum = Checksum(CHECKSUM_BYTE, block_start, (ROMLength*512)); 244 | 245 | //Printf("OPTROM: %06Lxh+%06xh %02x\n", block_start, (ROMLength*512), checksum); 246 | } OPTROM ; 247 | 248 | string read_OPTROM(OPTROM &in) { 249 | string out; 250 | SPrintf(out, "%02Xh", in.checksum); 251 | return out; 252 | } 253 | 254 | typedef struct { 255 | local int64 block_start = FTell(); 256 | local int64 data_start; 257 | local int64 block_end; 258 | local ubyte checksum; 259 | local char temp_sig[4]; 260 | 261 | ushort Signature; 262 | ubyte ROMLength; 263 | ubyte InitEntryCode[3]; 264 | SetBackColor(0xffd0d0); 265 | ubyte r1[0x12] ; 266 | SetBackColor(0xff9090); 267 | ushort PCIRHeader; 268 | SetBackColor(0xffd0d0); 269 | ubyte r2[4] ; 270 | SetBackColor(0xff9090); 271 | char VideoSignature[3]; 272 | 273 | data_start = FTell(); 274 | 275 | SetBackColor(0xffd0d0); 276 | ubyte data[(ROMLength*512) - (data_start - block_start)]; 277 | SetBackColor(0xff9090); 278 | 279 | block_end = FTell(); 280 | 281 | if (PCIRHeader) { 282 | ReadBytes(temp_sig, block_start + PCIRHeader, 4); 283 | 284 | if (temp_sig == "PCIR") { 285 | FSeek(block_start + PCIRHeader); 286 | 287 | SetBackColor(0xffff90); 288 | PCI_header h; 289 | SetBackColor(0xff9090); 290 | } 291 | } 292 | 293 | FSeek(block_end); 294 | 295 | checksum = Checksum(CHECKSUM_BYTE, block_start, (ROMLength*512)); 296 | 297 | //Printf("VIDROM: %06Lxh+%06xh %02x\n", block_start, (ROMLength*512), checksum); 298 | } VIDROM ; 299 | 300 | string read_VIDROM(VIDROM &in) { 301 | string out; 302 | SPrintf(out, "%02Xh", in.checksum); 303 | return out; 304 | } 305 | 306 | typedef struct { 307 | local int64 block_start = FTell(); 308 | local int64 data_start; 309 | local int64 block_end; 310 | local ubyte checksum; 311 | local char temp_sig[4]; 312 | 313 | ushort Signature; 314 | ushort ROMLength; 315 | ushort EFISignature; 316 | SetBackColor(0xd0ffd0); 317 | ubyte r1[0x12] ; 318 | SetBackColor(0x90ff90); 319 | ushort PCIRHeader; 320 | SetBackColor(0xd0ffd0); 321 | ubyte r2[2] ; 322 | SetBackColor(0x90ff90); 323 | 324 | data_start = FTell(); 325 | 326 | SetBackColor(0xd0ffd0); 327 | ubyte data[(ROMLength*512) - (data_start - block_start)]; 328 | SetBackColor(0x90ff90); 329 | 330 | block_end = FTell(); 331 | 332 | if (PCIRHeader) { 333 | ReadBytes(temp_sig, block_start + PCIRHeader, 4); 334 | 335 | if (temp_sig == "PCIR") { 336 | FSeek(block_start + PCIRHeader); 337 | 338 | SetBackColor(0xffff90); 339 | PCI_header h; 340 | SetBackColor(0x90ff90); 341 | } 342 | } 343 | 344 | FSeek(block_end); 345 | 346 | checksum = Checksum(CHECKSUM_BYTE, block_start, (ROMLength*512)); 347 | 348 | //Printf("EFIROM: %06Lxh+%06xh %02x\n", block_start, (ROMLength*512), checksum); 349 | } EFIROM ; 350 | 351 | string read_EFIROM(EFIROM &in) { 352 | string out; 353 | SPrintf(out, "%02Xh", in.checksum); 354 | return out; 355 | } 356 | 357 | typedef struct { 358 | local int64 block_start = FTell(); 359 | local int64 data_start; 360 | local int64 block_end; 361 | local int ROMLength; 362 | 363 | char Signature[4]; 364 | 365 | data_start = FTell(); 366 | 367 | ROMLength = 1; 368 | while (block_type(block_start + (ROMLength*512)) == 1) ROMLength++; 369 | 370 | SetBackColor(0xd0ffff); 371 | ubyte data[(ROMLength*512) - (data_start - block_start)]; 372 | SetBackColor(0x90ffff); 373 | 374 | block_end = FTell(); 375 | 376 | FSeek(block_end); 377 | 378 | //Printf("MCCROM: %06Lxh+%06xh\n", block_start, (ROMLength*512)); 379 | } MCCROM; 380 | 381 | typedef struct { 382 | local int64 block_start = FTell(); 383 | local int64 data_start; 384 | local int64 block_end; 385 | local int ROMLength; 386 | 387 | data_start = FTell(); 388 | 389 | ROMLength = 1; 390 | while (block_type(block_start + (ROMLength*512)) == 1) ROMLength++; 391 | 392 | ubyte data[(ROMLength*512) - (data_start - block_start)]; 393 | 394 | block_end = FTell(); 395 | 396 | FSeek(block_end); 397 | 398 | //Printf("RAWROM: %06Lxh+%06xh\n", block_start, (ROMLength*512)); 399 | } RAWROM; 400 | 401 | typedef struct { 402 | local int64 block_start = FTell(); 403 | local int64 data_start; 404 | local int64 block_end; 405 | local int ROMLength; 406 | 407 | data_start = FTell(); 408 | 409 | ROMLength = 1; 410 | while (block_type(block_start + (ROMLength*512)) == 0) ROMLength++; 411 | 412 | ubyte data[(ROMLength*512) - (data_start - block_start)]; 413 | 414 | block_end = FTell(); 415 | 416 | FSeek(block_end); 417 | 418 | //Printf("BLANK : %06Lxh+%06xh\n", block_start, (ROMLength*512)); 419 | } BLANK; 420 | 421 | DisplayFormatHex(); 422 | LittleEndian(); 423 | 424 | local int cur_block_type; 425 | 426 | if (ReadUShort(0) == 0xAA55) { 427 | do { 428 | cur_block_type = block_type(FTell()); 429 | 430 | switch (cur_block_type) { 431 | case 0: 432 | BLANK d; 433 | break; 434 | 435 | case 1: 436 | SetBackColor(0xd0d0d0); 437 | RAWROM d; 438 | SetBackColor(cNone); 439 | break; 440 | 441 | case 2: 442 | SetBackColor(0x9090ff); 443 | OPTROM d; 444 | SetBackColor(cNone); 445 | break; 446 | 447 | case 3: 448 | SetBackColor(0xff9090); 449 | VIDROM d; 450 | SetBackColor(cNone); 451 | break; 452 | 453 | case 4: 454 | SetBackColor(0x90ff90); 455 | EFIROM d; 456 | SetBackColor(cNone); 457 | break; 458 | 459 | case 5: 460 | SetBackColor(0x90ffff); 461 | MCCROM d; 462 | SetBackColor(cNone); 463 | break; 464 | 465 | default: 466 | Assert(0, "Unknown block"); 467 | break; 468 | } 469 | } while ((cur_block_type != -1) && !FEof()); 470 | } 471 | -------------------------------------------------------------------------------- /010 Templates/SAV.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: SAV.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: SAV File parser 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | LittleEndian(); 16 | 17 | // UNICODE support 18 | // Thanks to Graeme Sweet for pointing this out! 19 | int CalcUnicodeLen() { 20 | local quad pos = FTell(); 21 | local quad base = pos; 22 | while ((ReadUShort(pos) != 0) && (pos - base < 65535)) { 23 | pos += 2; 24 | } 25 | return (pos - base + 2) / 2; 26 | } 27 | 28 | typedef struct { 29 | UINT16 s[CalcUnicodeLen()]; 30 | } WCHAR ; 31 | 32 | string WCHAR_read(WCHAR &z) { 33 | int len = sizeof(z.s) / 2; 34 | char s[len]; 35 | ConvertUNICODEToASCIIW(len, z.s, s); 36 | return s; 37 | } 38 | 39 | typedef struct { 40 | UINT32 Length; 41 | if (Length > 0) { 42 | string d; 43 | } 44 | } UTSTRING ; 45 | 46 | string UTSTRING_read(UTSTRING &in) { 47 | if (in.Length > 0) { 48 | return in.d; 49 | } 50 | else { 51 | return ""; 52 | } 53 | } 54 | 55 | typedef struct { 56 | UINT32 Start; 57 | UINT32 Unknown; 58 | UINT32 Unknown; 59 | UINT32 Unknown; 60 | UINT32 Unknown; 61 | UINT32 Unknown; 62 | UTSTRING Name; 63 | UINT32 Unknown; 64 | UINT32 Unknown; 65 | UINT32 Unknown; 66 | UINT32 Unknown; 67 | UINT32 Unknown; 68 | UINT32 Unknown; 69 | UINT32 Unknown; 70 | UINT32 Unknown; 71 | UINT32 Unknown; 72 | } ENTRY ; 73 | 74 | string ENTRY_read(ENTRY &in) { 75 | return UTSTRING_read(in.Name); 76 | } 77 | 78 | LittleEndian(); 79 | 80 | SetBackColor(0xe0e0e0); 81 | 82 | local int i; 83 | 84 | UINT32 Unknown; 85 | UINT32 Unknown; 86 | UINT32 Unknown; 87 | UINT32 Unknown; 88 | 89 | //UTSTRING Name; 90 | 91 | UINT32 Unknown; 92 | UINT32 EntrySize; 93 | UINT32 Unknown; 94 | UINT32 EntryCount; 95 | 96 | for (i = 0; i < EntryCount; i++) { 97 | ENTRY e; 98 | } 99 | 100 | UINT32 Unknown; 101 | UINT32 Unknown; 102 | UINT32 Unknown; 103 | UINT32 Unknown; 104 | UINT32 Unknown; 105 | UINT32 Unknown; 106 | UINT32 Unknown; 107 | UINT32 Unknown; 108 | UINT32 Unknown; 109 | -------------------------------------------------------------------------------- /010 Templates/SIG.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: SIG.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: EFI signature list 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-08-30 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | typedef ubyte UINT8; 15 | typedef byte INT8; 16 | 17 | typedef struct { 18 | UINT32 Data1; 19 | UINT16 Data2; 20 | UINT16 Data3; 21 | BigEndian(); 22 | UINT64 Data4; 23 | LittleEndian(); 24 | } GUID ; 25 | 26 | string read_GUID(GUID &in) { 27 | local string out; 28 | local UINT32 d1 = in.Data1; 29 | local UINT32 d2 = in.Data2; 30 | local UINT32 d3 = in.Data3; 31 | local UINT64 d4 = in.Data4; 32 | local UINT32 d4a = d4 >> 32; 33 | local UINT32 d4b = d4 & 0xFFFFFFFF; 34 | if (d1 == 0xa7717414 && d2 == 0xc616 && d3 == 0x4977 && d4a == 0x94208447 && d4b == 0x12a735bf) { 35 | out = "EFI_CERT_TYPE_RSA2048_SHA256_GUID"; 36 | } 37 | else if (d1 == 0x51aa59de && d2 == 0xfdf2 && d3 == 0x4ea3 && d4a == 0xbc63875f && d4b == 0xb7842ee9) { 38 | out = "EFI_HASH_ALGORITHM_SHA256_GUID"; 39 | } 40 | else if (d1 == 0xc1c41626 && d2 == 0x504c && d3 == 0x4092 && d4a == 0xaca941f9 && d4b == 0x36934328) { 41 | out = "EFI_CERT_SHA256_GUID"; 42 | } 43 | else if (d1 == 0x3c5766e8 && d2 == 0x269c && d3 == 0x4e34 && d4a == 0xaa14ed77 && d4b == 0x6e85b3b6) { 44 | out = "EFI_CERT_RSA2048_GUID"; 45 | } 46 | else if (d1 == 0xe2b36190 && d2 == 0x879b && d3 == 0x4a3d && d4a == 0xad8df2e7 && d4b == 0xbba32784) { 47 | out = "EFI_CERT_RSA2048_SHA256_GUID"; 48 | } 49 | else if (d1 == 0x826ca512 && d2 == 0xcf10 && d3 == 0x4ac9 && d4a == 0xb187be01 && d4b == 0x496631bd) { 50 | out = "EFI_CERT_SHA1_GUID"; 51 | } 52 | else if (d1 == 0x67f8444f && d2 == 0x8743 && d3 == 0x48f1 && d4a == 0xa3281eaa && d4b == 0xb8736080) { 53 | out = "EFI_CERT_RSA2048_SHA1_GUID"; 54 | } 55 | else if (d1 == 0xa5c059a1 && d2 == 0x94e4 && d3 == 0x4aa7 && d4a == 0x87b5ab15 && d4b == 0x5c2bf072) { 56 | out = "EFI_CERT_X509_GUID"; 57 | } 58 | else if (d1 == 0x0b6e5233 && d2 == 0xa65c && d3 == 0x44c9 && d4a == 0x9407d9ab && d4b == 0x83bfc8bd) { 59 | out = "EFI_CERT_SHA224_GUID"; 60 | } 61 | else if (d1 == 0xff3e5307 && d2 == 0x9fd0 && d3 == 0x48c9 && d4a == 0x85f18ad5 && d4b == 0x6c701e01) { 62 | out = "EFI_CERT_SHA384_GUID"; 63 | } 64 | else if (d1 == 0x093e0fae && d2 == 0xa6c4 && d3 == 0x4f50 && d4a == 0x9f1bd41e && d4b == 0x2b89c19a) { 65 | out = "EFI_CERT_SHA512_GUID"; 66 | } 67 | else if (d1 == 0x4aafd29d && d2 == 0x68df && d3 == 0x49ee && d4a == 0x8aa9347d && d4b == 0x375665a7) { 68 | out = "EFI_CERT_TYPE_PKCS7_GUID"; 69 | } 70 | else { 71 | SPrintf(out, "{%08X-%04X-%04X-%04X-%04X%08X}", 72 | d1, d2, d3, d4a >> 16, d4a & 0xFFFF, d4b); 73 | } 74 | return out; 75 | } 76 | 77 | typedef struct (int size) { 78 | GUID SignatureOwner; 79 | 80 | SetBackColor(0xc0d8c0); 81 | UINT8 SignatureData[size - 16]; 82 | } EFI_SIGNATURE_DATA ; 83 | 84 | typedef struct { 85 | local quad start_pos = FTell(); 86 | GUID SignatureType; 87 | UINT32 SignatureListSize; 88 | UINT32 SignatureHeaderSize; 89 | UINT32 SignatureSize; 90 | 91 | if (SignatureHeaderSize) { 92 | SetBackColor(0xc0c0ff); 93 | UINT8 SignatureHeader[SignatureHeaderSize]; 94 | } 95 | 96 | local quad cur_pos = FTell(); 97 | while ((cur_pos - start_pos) < SignatureListSize) { 98 | SetBackColor(0xc0ffc0); 99 | EFI_SIGNATURE_DATA Signature(SignatureSize); 100 | cur_pos = FTell(); 101 | } 102 | } EFI_SIGNATURE_LIST ; 103 | 104 | DisplayFormatHex(); 105 | LittleEndian(); 106 | 107 | while (!FEof()) { 108 | SetBackColor(0xe0e0e0); 109 | EFI_SIGNATURE_LIST l; 110 | } 111 | -------------------------------------------------------------------------------- /010 Templates/SQLite.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: SQLite.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: SQLite data file 8 | // Category: Database 9 | // File Mask: *.sqlite,*.db 10 | // ID Bytes: 53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00 // SQLite format 3 11 | // History: 12 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.2 2016-01-18 Andrew McRae: Updated header for repo 14 | // 0.1 2015-09-07 Andrew McRae: Initial revision 15 | //------------------------------------------------ 16 | 17 | BigEndian(); 18 | 19 | typedef struct { 20 | SetBackColor( cLtBlue ); 21 | char magic[16]; // 0-15 22 | Assert(magic == "SQLite format 3\0"); 23 | ushort page_size; // 16-17 24 | ubyte write_version; // 18 25 | ubyte read_version; // 19 26 | ubyte unused_page_space; // 20 27 | ubyte max_index_embed; // 21 28 | Assert(max_index_embed == 64); 29 | ubyte min_index_embed; // 22 30 | Assert(min_index_embed == 32); 31 | ubyte min_table_embed; // 23 32 | Assert(min_table_embed == 32); 33 | uint change_count; // 24-27 34 | uint database_size; // 28-31 35 | uint freelist_trunk_page; // 32-35 36 | uint db_free_pages; // 36-39 37 | uint schema_cookie; // 40-43 38 | uint schema_file_format; // 44-47 39 | Assert(schema_file_format >= 1 && schema_file_format <= 4); 40 | uint page_cache_size; // 48-51 41 | uint top_root_page; // 52-55 42 | enum TEXT_ENCODING { UTF8=1, UTF16LE=2, UTF16BE=3 } text_encoding; // 56-59 43 | uint user_version; // 60-63 44 | uint inc_vacuum; // 64-67 45 | uint application_id; // 68-71 46 | ubyte reserved[20]; // 72-91 47 | uint version_valid_for; // 92-95 48 | uint sqlite_version_number; // 96-99 49 | } DB_HEADER; 50 | 51 | DB_HEADER db_h; 52 | -------------------------------------------------------------------------------- /010 Templates/SSD.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: SSD.bt 5 | // Author: Andrew McRae 6 | // Version: 0.4 7 | // Purpose: Parse BBC DFS SSD files 8 | // Category: Drives 9 | // File Mask: *.ssd 10 | // History: 11 | // 0.4 2016-04-05 Andrew McRae: Further handling of truncated images 12 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.2 2016-03-09 Andrew McRae: Merge changes 14 | // 0.1 2016-02-25 Andrew McRae: Initial revision 15 | //------------------------------------------------ 16 | 17 | typedef uint64 u8; 18 | typedef uint32 u4; 19 | typedef uint16 u2; 20 | typedef ubyte u1; 21 | typedef int64 s8; 22 | typedef int32 s4; 23 | typedef int16 s2; 24 | typedef byte s1; 25 | 26 | quad ext18(quad lo, quad hi) { 27 | local quad out; 28 | out = lo; 29 | out |= (quad)hi << 16; 30 | return out; 31 | } 32 | 33 | quad ext10(quad lo, quad hi) { 34 | local quad out; 35 | out = lo; 36 | out |= (quad)hi << 8; 37 | return out; 38 | } 39 | 40 | quad ext18addr(quad lo, quad hi) { 41 | local quad out; 42 | out = ext18(lo, hi); 43 | if (hi == 0x3) { 44 | out |= 0xff0000; 45 | } 46 | return out; 47 | } 48 | 49 | typedef struct { 50 | char name0 : 7; 51 | u1 hi0 : 1; 52 | char name1 : 7; 53 | u1 hi1 : 1; 54 | char name2 : 7; 55 | u1 hi2 : 1; 56 | char name3 : 7; 57 | u1 hi3 : 1; 58 | char name4 : 7; 59 | u1 hi4 : 1; 60 | char name5 : 7; 61 | u1 hi5 : 1; 62 | char name6 : 7; 63 | u1 hi6 : 1; 64 | 65 | char dir : 7; 66 | u1 locked : 1; 67 | } FILE_NAME ; 68 | string read_FILE_NAME(FILE_NAME &in) { 69 | local string out; 70 | local char name[7]; 71 | name[0] = in.name0; 72 | name[1] = in.name1; 73 | name[2] = in.name2; 74 | name[3] = in.name3; 75 | name[4] = in.name4; 76 | name[5] = in.name5; 77 | name[6] = in.name6; 78 | 79 | SPrintf(out, "%c.%s%s", in.dir, name, in.locked?" L":""); 80 | return out; 81 | } 82 | 83 | typedef struct { 84 | u2 load_lo; 85 | u2 execute_lo; 86 | u2 length_lo; 87 | u1 start_hi : 2; 88 | u1 load_hi : 2; 89 | u1 length_hi : 2; 90 | u1 execute_hi : 2; 91 | u1 start_lo; 92 | } FILE_DETAILS ; 93 | string read_FILE_DETAILS(FILE_DETAILS &in) { 94 | local string out; 95 | SPrintf(out, "%06X %06X %06X %03X", 96 | ext18addr(in.load_lo, in.load_hi), ext18addr(in.execute_lo, in.execute_hi), 97 | ext18(in.length_lo, in.length_hi), ext10(in.start_lo, in.start_hi)); 98 | return out; 99 | } 100 | 101 | typedef struct { 102 | char title1[8]; 103 | FILE_NAME fn[31]; 104 | char title2[4]; 105 | u1 cycle ; 106 | u1 count ; 107 | u1 sectors_hi : 2; 108 | u1 nondfs : 2; 109 | enum {O_NONE, O_LOAD, O_RUN, O_EXEC} opt4 : 2; 110 | u1 unused : 2 ; 111 | u1 sectors_lo; 112 | FILE_DETAILS fd[31]; 113 | } CATALOGUE ; 114 | string read_CATALOGUE(CATALOGUE &in) { 115 | local string out; 116 | SPrintf(out, "%s%s %d", in.title1, in.title2, in.count / 8); 117 | return out; 118 | } 119 | 120 | typedef struct (int index) { 121 | local quad _pos; 122 | _pos = FTell(); 123 | 124 | FSeek(index * 8 + 8); 125 | SetBackColor(0xe0e0e0); 126 | FILE_NAME n; 127 | 128 | FSeek(index * 8 + 8 + 0x100); 129 | SetBackColor(0xe0e0e0); 130 | FILE_DETAILS d; 131 | 132 | local u4 _start, _length, _padding; 133 | _start = ext10(d.start_lo, d.start_hi) * 0x100; 134 | _length = ext18(d.length_lo, d.length_hi); 135 | 136 | FSeek(_pos); 137 | 138 | if (_length > 0 && _start < _size) { 139 | if ((_start + _length) <= _size) { 140 | SetBackColor(0xc0ffc0); 141 | u1 data[_length]; 142 | 143 | if (_length & 0xff) { 144 | _padding = 0x100 - _length & 0xff; 145 | if (_start + _length + _padding > _size) { 146 | _padding = _size - _start - _length; 147 | } 148 | if (_padding > 0) { 149 | SetBackColor(0xf0fff0); 150 | u1 padding[_padding] ; 151 | } 152 | } 153 | } else { 154 | SetBackColor(0xf0fff0); 155 | u1 data[_size - _start] ; 156 | } 157 | } else { 158 | SetBackColor(0xc0c0c0); 159 | u1 data[1] ; 160 | } 161 | } FILE ; 162 | string read_FILE(FILE &in) { 163 | return read_FILE_NAME(in.n); 164 | } 165 | 166 | local int i; 167 | local quad _start, _length, _size; 168 | 169 | _size = FileSize(); 170 | 171 | DisplayFormatHex(); 172 | LittleEndian(); 173 | 174 | SetBackColor(0xc0c0c0); 175 | CATALOGUE c; 176 | 177 | for (i = 0; i < c.count / 8; i++) { 178 | _start = ext10(c.fd[i].start_lo, c.fd[i].start_hi) * 0x100; 179 | _length = ext18(c.fd[i].length_lo, c.fd[i].length_hi); 180 | 181 | if (_start < _size) { 182 | if (_start + _length > _size) { 183 | Warning("file end > image size: %d > %d", _start + _length, _size); 184 | Printf("file end > image size: %d > %d\n", _start + _length, _size); 185 | } 186 | FSeek(_start); 187 | } else { 188 | Warning("file start > image size: %d > %d", _start, _size); 189 | Printf("file start > image size: %d > %d\n", _start, _size); 190 | FSeek(0); 191 | } 192 | FILE f(i); 193 | } 194 | -------------------------------------------------------------------------------- /010 Templates/Shader.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: Shader.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Parse DX9 shader 8 | // Category: Programming 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2015-11-04 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | typedef struct { 26 | u1 minor ; 27 | u1 major ; 28 | u2 type; 29 | } HEADER ; 30 | string read_HEADER(HEADER &in) { 31 | local string out; 32 | if (in.type == 0xffff) { 33 | SPrintf(out, "ps_%d_%d", in.major, in.minor); 34 | } else if (in.type == 0xfffe) { 35 | SPrintf(out, "vs_%d_%d", in.major, in.minor); 36 | } else { 37 | SPrintf(out, "%d_%d", in.major, in.minor); 38 | } 39 | return out; 40 | } 41 | 42 | typedef struct (quad _start) { 43 | local quad _pos; 44 | 45 | u4 offset ; 46 | 47 | _pos = FTell(); 48 | 49 | FSeek(_start + offset); 50 | SetBackColor(0xffff98); 51 | string s; 52 | 53 | FSeek(_pos); 54 | } NAME ; 55 | string read_NAME(NAME &in) { 56 | return in.s; 57 | } 58 | 59 | typedef enum { 60 | OPCODE_NOP = 0, 61 | OPCODE_MOV, 62 | OPCODE_ADD, 63 | OPCODE_SUB, 64 | OPCODE_MAD, 65 | OPCODE_MUL, 66 | OPCODE_RCP, 67 | OPCODE_RSQ, 68 | OPCODE_DP3, 69 | OPCODE_DP4, 70 | OPCODE_MIN, 71 | OPCODE_MAX, 72 | OPCODE_SLT, 73 | OPCODE_SGE, 74 | OPCODE_EXP, 75 | OPCODE_LOG, 76 | OPCODE_LIT, 77 | OPCODE_DST, 78 | OPCODE_LRP, 79 | OPCODE_FRC, 80 | OPCODE_M4x4, 81 | OPCODE_M4x3, 82 | OPCODE_M3x4, 83 | OPCODE_M3x3, 84 | OPCODE_M3x2, 85 | OPCODE_CALL, 86 | OPCODE_CALLNZ, 87 | OPCODE_LOOP, 88 | OPCODE_RET, 89 | OPCODE_ENDLOOP, 90 | OPCODE_LABEL, 91 | OPCODE_DCL, 92 | OPCODE_POW, 93 | OPCODE_CRS, 94 | OPCODE_SGN, 95 | OPCODE_ABS, 96 | OPCODE_NRM, 97 | OPCODE_SINCOS, 98 | OPCODE_REP, 99 | OPCODE_ENDREP, 100 | OPCODE_IF, 101 | OPCODE_IFC, 102 | OPCODE_ELSE, 103 | OPCODE_ENDIF, 104 | OPCODE_BREAK, 105 | OPCODE_BREAKC, 106 | OPCODE_MOVA, 107 | OPCODE_DEFB, 108 | OPCODE_DEFI, 109 | 110 | OPCODE_TEXCOORD = 64, 111 | OPCODE_TEXKILL, 112 | OPCODE_TEX, 113 | OPCODE_TEXBEM, 114 | OPCODE_TEXBEML, 115 | OPCODE_TEXREG2AR, 116 | OPCODE_TEXREG2GB, 117 | OPCODE_TEXM3x2PAD, 118 | OPCODE_TEXM3x2TEX, 119 | OPCODE_TEXM3x3PAD, 120 | OPCODE_TEXM3x3TEX, 121 | OPCODE_RESERVED0, 122 | OPCODE_TEXM3x3SPEC, 123 | OPCODE_TEXM3x3VSPEC, 124 | OPCODE_EXPP, 125 | OPCODE_LOGP, 126 | OPCODE_CND, 127 | OPCODE_DEF, 128 | OPCODE_TEXREG2RGB, 129 | OPCODE_TEXDP3TEX, 130 | OPCODE_TEXM3x2DEPTH, 131 | OPCODE_TEXDP3, 132 | OPCODE_TEXM3x3, 133 | OPCODE_TEXDEPTH, 134 | OPCODE_CMP, 135 | OPCODE_BEM, 136 | OPCODE_DP2ADD, 137 | OPCODE_DSX, 138 | OPCODE_DSY, 139 | OPCODE_TEXLDD, 140 | OPCODE_SETP, 141 | OPCODE_TEXLDL, 142 | OPCODE_BREAKP, 143 | 144 | OPCODE_PHASE = 0xFFFD, 145 | OPCODE_COMMENT = 0xFFFE, 146 | OPCODE_END = 0xFFFF, 147 | } OPCODE_TYPE; 148 | 149 | typedef enum { 150 | RS_BOOL, 151 | RS_INT4, 152 | RS_FLOAT4, 153 | RS_SAMPLER, 154 | } REG_SET; 155 | 156 | typedef enum { 157 | CLASS_SCALAR, 158 | CLASS_VECTOR, 159 | CLASS_MATRIX_ROWS, 160 | CLASS_MATRIX_COLUMNS, 161 | CLASS_OBJECT, 162 | CLASS_STRUCT, 163 | } TYPE_CLASS; 164 | 165 | typedef enum { 166 | PT_VOID, 167 | PT_BOOL, 168 | PT_INT, 169 | PT_FLOAT, 170 | PT_STRING, 171 | PT_TEXTURE, 172 | PT_TEXTURE1D, 173 | PT_TEXTURE2D, 174 | PT_TEXTURE3D, 175 | PT_TEXTURECUBE, 176 | PT_SAMPLER, 177 | PT_SAMPLER1D, 178 | PT_SAMPLER2D, 179 | PT_SAMPLER3D, 180 | PT_SAMPLERCUBE, 181 | PT_PIXELSHADER, 182 | PT_VERTEXSHADER, 183 | PT_PIXELFRAGMENT, 184 | PT_VERTEXFRAGMENT, 185 | PT_UNSUPPORTED, 186 | } TYPE; 187 | 188 | typedef struct (quad _start) { 189 | local quad _pos; 190 | 191 | u4 typeinfo_offset ; 192 | u4 value_offset ; 193 | 194 | _pos = FTell(); 195 | 196 | FSeek(_start + typeinfo_offset); 197 | 198 | TYPE_CLASS type_class; 199 | TYPE type; 200 | u2 row_count ; 201 | u2 column_count ; 202 | u2 element_count ; 203 | u2 member_count ; 204 | u4 member_offset ; 205 | 206 | FSeek(_pos); 207 | } CTAB_type ; 208 | string read_CTAB_type(CTAB_type &in) { 209 | local string out; 210 | SPrintf(out, "%s %s", EnumToString(in.type_class), EnumToString(in.type)); 211 | return out; 212 | } 213 | 214 | typedef struct (quad _start) { 215 | NAME name(_start); 216 | REG_SET reg_set; 217 | u2 reg_index ; 218 | u2 reg_count ; 219 | u2 unknown; 220 | CTAB_type type(_start); 221 | } CTAB_constant ; 222 | string read_CTAB_constant(CTAB_constant &in) { 223 | local string out; 224 | SPrintf(out, "%s %s %d", in.name.s, EnumToString(in.reg_set), in.reg_count); 225 | return out; 226 | } 227 | 228 | typedef struct (int _size) { 229 | local quad _start, _end; 230 | local int i; 231 | 232 | char type[4]; 233 | 234 | _start = FTell(); 235 | _end = _start - 4 + _size * 4; 236 | 237 | u4 constant_size; 238 | NAME creator(_start); 239 | u4 version; 240 | u4 constant_count ; 241 | u4 constant_offset ; 242 | u4 flags; 243 | NAME target(_start); 244 | 245 | for (i = 0; i < constant_count; i++) { 246 | FSeek(_start + constant_offset + 20 * i); 247 | CTAB_constant v(_start); 248 | } 249 | 250 | FSeek(_end); 251 | } CTAB ; 252 | string read_CTAB(CTAB &in) { 253 | local string out; 254 | SPrintf(out, "%s %d", in.target.s, in.constant_count); 255 | return out; 256 | } 257 | 258 | struct TOKEN_COMMENT; 259 | struct TOKEN_END; 260 | struct TOKEN; 261 | typedef struct (int _size) { 262 | local quad _start, _end; 263 | 264 | char type[4]; 265 | 266 | _start = FTell(); 267 | _end = _start - 4 + _size * 4; 268 | 269 | u4 version; 270 | 271 | local u2 _opcode; 272 | local int _found_end = false; 273 | while ((FTell() < _end) && !_found_end) { 274 | _opcode = ReadUInt() & 0xffff; 275 | switch(_opcode) { 276 | case OPCODE_COMMENT: 277 | SetBackColor(0xc0c0ff); 278 | TOKEN_COMMENT t; 279 | break; 280 | case OPCODE_END: 281 | SetBackColor(0xc0c0c0); 282 | TOKEN_END t; 283 | _found_end = true; 284 | break; 285 | default: 286 | SetBackColor(0xc0ffc0); 287 | TOKEN t; 288 | break; 289 | } 290 | } 291 | 292 | FSeek(_end); 293 | } PRES; 294 | 295 | typedef struct (int _size) { 296 | local quad _start, _end; 297 | 298 | char type[4]; 299 | 300 | _start = FTell(); 301 | _end = _start - 4 + _size * 4; 302 | 303 | FSeek(_end); 304 | } PRSI; 305 | 306 | typedef struct (int _size) { 307 | local quad _start, _end; 308 | 309 | char type[4]; 310 | 311 | _start = FTell(); 312 | _end = _start - 4 + _size * 4; 313 | 314 | FSeek(_end); 315 | } CLIT; 316 | 317 | typedef struct (int _size) { 318 | local quad _start, _end; 319 | 320 | char type[4]; 321 | 322 | _start = FTell(); 323 | _end = _start - 4 + _size * 4; 324 | 325 | FSeek(_end); 326 | } FXLC; 327 | 328 | typedef struct { 329 | OPCODE_TYPE type; 330 | u2 unknown: 8 ; 331 | u2 size: 4 ; 332 | u2 unknown: 4 ; 333 | 334 | if (size) { 335 | u4 data[size]; 336 | } 337 | } TOKEN ; 338 | string read_TOKEN(TOKEN &in) { 339 | local string out; 340 | SPrintf(out, "%s %Xh", EnumToString(in.type), in.size); 341 | return out; 342 | } 343 | 344 | typedef struct { 345 | OPCODE_TYPE type; 346 | u2 unknown: 8 ; 347 | u2 size: 4 ; 348 | u2 unknown: 4 ; 349 | 350 | if (size) { 351 | u4 data[size]; 352 | } 353 | } TOKEN_END ; 354 | string read_TOKEN_END(TOKEN_END &in) { 355 | local string out; 356 | SPrintf(out, "%s %Xh", EnumToString(in.type), in.size); 357 | return out; 358 | } 359 | 360 | typedef struct { 361 | OPCODE_TYPE type; 362 | u2 unknown: 8 ; 363 | u2 size: 4 ; 364 | u2 unknown: 4 ; 365 | 366 | if (size) { 367 | u4 data[size]; 368 | } 369 | } TOKEN_PHASE ; 370 | string read_TOKEN_PHASE(TOKEN_PHASE &in) { 371 | local string out; 372 | SPrintf(out, "%s %Xh", EnumToString(in.type), in.size); 373 | return out; 374 | } 375 | 376 | typedef struct { 377 | OPCODE_TYPE type; 378 | u2 size: 15 ; 379 | u2 unknown: 1 ; 380 | 381 | local char _subtype[4]; 382 | ReadBytes(_subtype, FTell(), 4); 383 | 384 | if (size) { 385 | if (_subtype == "CTAB") { 386 | CTAB d(size); 387 | } else if (_subtype == "PRES") { 388 | PRES d(size); 389 | } else if (_subtype == "PRSI") { 390 | PRSI d(size); 391 | } else if (_subtype == "CLIT") { 392 | CLIT d(size); 393 | } else if (_subtype == "FXLC") { 394 | FXLC d(size); 395 | } else { 396 | u4 data[size]; 397 | } 398 | } 399 | } TOKEN_COMMENT ; 400 | string read_TOKEN_COMMENT(TOKEN_COMMENT &in) { 401 | local string out; 402 | SPrintf(out, "%s %s %Xh", EnumToString(in.type), in._subtype, in.size); 403 | return out; 404 | } 405 | 406 | LittleEndian(); 407 | 408 | SetBackColor(0xc0c0c0); 409 | HEADER h; 410 | 411 | if (h.type != 0xffff && h.type != 0xfffe) { 412 | Warning("Bad sig!"); 413 | Printf("Bad sig!\n"); 414 | return -1; 415 | } 416 | 417 | local u2 _opcode; 418 | local int _found_end = false; 419 | while (!FEof() && !_found_end) { 420 | _opcode = ReadUInt() & 0xffff; 421 | switch(_opcode) { 422 | case OPCODE_COMMENT: 423 | SetBackColor(0xc0c0ff); 424 | TOKEN_COMMENT t; 425 | break; 426 | case OPCODE_END: 427 | SetBackColor(0xc0c0c0); 428 | TOKEN_END t; 429 | _found_end = true; 430 | break; 431 | case OPCODE_PHASE: 432 | SetBackColor(0xc0c0ff); 433 | TOKEN_PHASE t; 434 | break; 435 | default: 436 | SetBackColor(0xc0ffc0); 437 | TOKEN t; 438 | break; 439 | } 440 | } 441 | -------------------------------------------------------------------------------- /010 Templates/TM2.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: TM2.bt 5 | // Authors: Andrew McRae 6 | // Version: 0.1 7 | // Purpose: Parse PS2 TIM2 textures 8 | // Category: Image 9 | // File Mask: *.tm2 10 | // ID Bytes: 54 49 4D 32 // TIM2 11 | // History: 12 | //------------------------------------------------ 13 | 14 | typedef uint64 u8; 15 | typedef uint32 u4; 16 | typedef uint16 u2; 17 | typedef ubyte u1; 18 | typedef int64 s8; 19 | typedef int32 s4; 20 | typedef int16 s2; 21 | typedef byte s1; 22 | 23 | 24 | typedef enum { 25 | TM2_FORMAT_UNKNOWN, 26 | TM2_FORMAT_RGBA5551, 27 | TM2_FORMAT_RGBA8880, 28 | TM2_FORMAT_RGBA8888, 29 | TM2_FORMAT_INDEX4, 30 | TM2_FORMAT_INDEX8 31 | } TM2_FORMAT; 32 | 33 | 34 | typedef struct { 35 | char sig[4]; 36 | 37 | u1 version ; 38 | u1 format ; 39 | u2 n_pictures ; 40 | 41 | u1 padding[8] ; 42 | } TM2HEADER; 43 | 44 | 45 | typedef struct { 46 | u4 total_size; 47 | u4 clut_size; 48 | u4 image_size; 49 | u2 header_size; 50 | u2 clut_colors ; 51 | u1 pict_format ; 52 | u1 n_mipmaps ; 53 | TM2_FORMAT clut_type ; 54 | TM2_FORMAT image_type ; 55 | u2 image_width ; 56 | u2 image_height ; 57 | u8 gs_tex0; 58 | u8 gs_tex1; 59 | u4 gs_regs; 60 | u4 gs_texclut; 61 | } TM2PICT; 62 | 63 | 64 | DisplayFormatHex(); 65 | LittleEndian(); 66 | 67 | Assert(ReadString(0, 4) == "TIM2", "Bad sig!"); 68 | 69 | SetBackColor(0xb0b0b0); 70 | TM2HEADER h; 71 | 72 | SetBackColor(0xffb0b0); 73 | TM2PICT p; 74 | -------------------------------------------------------------------------------- /010 Templates/UBNT.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: UBNT.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Ubiquiti firmware update 8 | // Category: Misc 9 | // History: 10 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 11 | // 0.1 2012-06-01 Andrew McRae: Initial revision 12 | //------------------------------------------------ 13 | 14 | DisplayFormatHex(); 15 | BigEndian(); 16 | 17 | typedef struct { 18 | char magic[4]; 19 | char name[16]; 20 | int padding1 ; 21 | int padding2 ; 22 | int padding3 ; 23 | int load_addr; 24 | int index; 25 | int base_addr; 26 | int entry_addr; 27 | int length; 28 | int max_size; 29 | 30 | char data[length]; 31 | 32 | int crc; 33 | int padding4 ; 34 | } s_PART ; 35 | 36 | string PART_read(s_PART &i) { 37 | return i.name; 38 | } 39 | 40 | typedef struct { 41 | char magic[4]; 42 | char version[256]; 43 | int crc; 44 | int padding1 ; 45 | } s_HEADER ; 46 | 47 | string HEADER_read(s_HEADER &i) { 48 | return i.version; 49 | } 50 | 51 | typedef struct { 52 | char magic[4]; 53 | int crc; 54 | int padding1 ; 55 | } s_END; 56 | 57 | local char cur_part[4]; 58 | 59 | while (!FEof()) { 60 | ReadBytes(cur_part, FTell(), 4); 61 | 62 | if (cur_part == "UBNT") s_HEADER p; 63 | if (cur_part == "OPEN") s_HEADER p; 64 | if (cur_part == "PART") s_PART p; 65 | if (cur_part == "END.") s_END p; 66 | } 67 | -------------------------------------------------------------------------------- /010 Templates/Unity.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: Unity.bt 5 | // Authors: Andrew McRae 6 | // Version: 0.1 7 | // Purpose: Parse unity asset file 8 | // Category: Archive 9 | // File Mask: *.asset 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | 14 | typedef uint64 u8; 15 | typedef uint32 u4; 16 | typedef uint16 u2; 17 | typedef ubyte u1; 18 | typedef int64 s8; 19 | typedef int32 s4; 20 | typedef int16 s2; 21 | typedef byte s1; 22 | 23 | 24 | typedef struct { 25 | SetBackColor(0xb0b0b0); 26 | u4 metadataSize; 27 | u4 fileSize; 28 | u4 version ; 29 | u4 dataOffset; 30 | u1 endianess ; 31 | local quad _padding; 32 | _padding = 4 - (FTell() & 3); 33 | if (_padding > 0 && _padding < 4) { 34 | u1 padding[_padding] ; 35 | } 36 | } SerializedFileHeader ; 37 | 38 | string read_SerializedFileHeader(SerializedFileHeader &in) { 39 | local string out; 40 | SPrintf(out, "%d %s", in.version, in.endianess?"BE":"LE"); 41 | return out; 42 | } 43 | 44 | 45 | typedef struct { 46 | u4 hash1; 47 | u4 hash2; 48 | u4 hash3; 49 | u4 hash4; 50 | } UnityHash128 ; 51 | 52 | string read_UnityHash128 (UnityHash128 &in) { 53 | local string out; 54 | SPrintf(out, "%08X%08X%08X%08X", in.hash4, in.hash3, in.hash2, in.hash1); 55 | return out; 56 | } 57 | 58 | 59 | typedef struct { 60 | s4 classID ; 61 | 62 | if (classID < 0) { 63 | UnityHash128 scriptID; 64 | } 65 | 66 | UnityHash128 oldTypeHash; 67 | } BaseClass ; 68 | 69 | string read_BaseClass(BaseClass &in) { 70 | local string out; 71 | SPrintf(out, "%d", in.classID); 72 | return out; 73 | } 74 | 75 | 76 | typedef struct { 77 | string revision; 78 | u4 attributes; 79 | u1 embedded ; 80 | u4 numBaseClasses ; 81 | if (numBaseClasses > 0) { 82 | BaseClass typeMap[numBaseClasses]; 83 | } 84 | } TypeTree ; 85 | 86 | string read_TypeTree(TypeTree &in) { 87 | local string out; 88 | SPrintf(out, "%d '%s'", in.numBaseClasses, in.revision); 89 | return out; 90 | } 91 | 92 | 93 | typedef struct { 94 | s8 objectID ; 95 | u4 byteStart; 96 | u4 byteSize; 97 | s4 typeID ; 98 | s2 classID ; 99 | s2 scriptTypeIndex; 100 | u1 stripped ; 101 | } ObjectInfo ; 102 | 103 | string read_ObjectInfo(ObjectInfo &in) { 104 | local string out; 105 | SPrintf(out, "%d %d 0x%X+0x%X", in.objectID, in.typeID, in.byteStart, in.byteSize); 106 | return out; 107 | } 108 | 109 | 110 | typedef struct { 111 | local int i, j; 112 | local quad _padding; 113 | u4 entries ; 114 | for (i = 0; i < entries; i++) { 115 | _padding = 4 - (FTell() & 3); 116 | if (_padding > 0 && _padding < 4) { 117 | for (j = 0; j < _padding; j++) { 118 | u1 padding ; 119 | } 120 | } 121 | ObjectInfo o; 122 | } 123 | } ObjectInfoTable ; 124 | 125 | string read_ObjectInfoTable(ObjectInfoTable &in) { 126 | local string out; 127 | SPrintf(out, "%d", in.entries); 128 | return out; 129 | } 130 | 131 | 132 | typedef struct { 133 | s4 serializedFileIndex ; 134 | s8 identifierInFile; 135 | } ObjectIdentifier; 136 | 137 | 138 | typedef struct { 139 | local int i; 140 | local quad _padding; 141 | u4 entries ; 142 | for (i = 0; i < entries; i++) { 143 | ObjectIdentifier o; 144 | _padding = 4 - (FTell() & 3); 145 | if (_padding > 0 && _padding < 4) { 146 | u1 padding[_padding] ; 147 | } 148 | } 149 | } ObjectIdentifierTable ; 150 | 151 | string read_ObjectIdentifierTable(ObjectIdentifierTable &in) { 152 | local string out; 153 | SPrintf(out, "%d", in.entries); 154 | return out; 155 | } 156 | 157 | 158 | typedef struct { 159 | string assetPath; 160 | UnityHash128 guid; 161 | s4 type ; 162 | string filePath; 163 | } FileIdentifier ; 164 | 165 | string read_FileIdentifier(FileIdentifier &in) { 166 | local string out; 167 | SPrintf(out, "'%s'", in.filePath); 168 | return out; 169 | } 170 | 171 | 172 | typedef struct { 173 | local int i; 174 | u4 entries ; 175 | for (i = 0; i < entries; i++) { 176 | FileIdentifier f; 177 | } 178 | } FileIdentifierTable ; 179 | 180 | string read_FileIdentifierTable(FileIdentifierTable &in) { 181 | local string out; 182 | SPrintf(out, "%d", in.entries); 183 | return out; 184 | } 185 | 186 | 187 | typedef struct { 188 | SetBackColor(0xb0b0ff); 189 | TypeTree typeTree; 190 | 191 | SetBackColor(0xb0ffb0); 192 | ObjectInfoTable objectInfoTable; 193 | 194 | SetBackColor(0xffb0b0); 195 | ObjectIdentifierTable objectIDTable; 196 | 197 | SetBackColor(0xffffb0); 198 | FileIdentifierTable externals; 199 | } SerializedFileMetadata; 200 | 201 | 202 | DisplayFormatHex(); 203 | BigEndian(); 204 | 205 | SerializedFileHeader h; 206 | 207 | LittleEndian(); 208 | 209 | SerializedFileMetadata m; 210 | -------------------------------------------------------------------------------- /010 Templates/XEX.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: XEX.bt 5 | // Author: Andrew McRae 6 | // Version: 0.2 7 | // Purpose: Xbox 360 executable 8 | // Category: Executable 9 | // File Mask: *.xex 10 | // ID Bytes: 58 45 58 32 // XEX2 11 | // History: 12 | // 0.2 2016-03-30 Andrew McRae: Updated header for repo 13 | // 0.1 2012-06-01 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | DisplayFormatHex(); 17 | 18 | typedef uint64 u8; 19 | typedef uint32 u4; 20 | typedef uint16 u2; 21 | typedef ubyte u1; 22 | typedef int64 s8; 23 | typedef int32 s4; 24 | typedef int16 s2; 25 | typedef byte s1; 26 | 27 | string header_type(u4 header_id) { 28 | string out; 29 | switch (header_id) { 30 | case 0x000002: 31 | out = "ResourceInfo"; 32 | break; 33 | case 0x000003: 34 | out = "BaseFileFormat"; 35 | break; 36 | case 0x000004: 37 | out = "BaseReference"; 38 | break; 39 | case 0x000005: 40 | out = "DeltaPatchDescriptor"; 41 | break; 42 | case 0x000080: 43 | out = "BoundingPath"; 44 | break; 45 | case 0x000081: 46 | out = "DeviceId"; 47 | break; 48 | case 0x000100: 49 | out = "OriginalBaseAddress"; 50 | break; 51 | case 0x000101: 52 | out = "EntryPoint"; 53 | break; 54 | case 0x000102: 55 | out = "ImageBaseAddress"; 56 | break; 57 | case 0x000103: 58 | out = "ImportLibraries"; 59 | break; 60 | case 0x000180: 61 | out = "ImageChecksumTimestamp"; 62 | break; 63 | case 0x000181: 64 | out = "EnabledForCallcap"; 65 | break; 66 | case 0x000182: 67 | out = "EnabledForFastcap"; 68 | break; 69 | case 0x000183: 70 | out = "OriginalPEImageName"; 71 | break; 72 | case 0x000200: 73 | out = "StaticLibraries"; 74 | break; 75 | case 0x000201: 76 | out = "TLSInfo"; 77 | break; 78 | case 0x000202: 79 | out = "DefaultStackSize"; 80 | break; 81 | case 0x000203: 82 | out = "DefaultFilesystemCacheSize"; 83 | break; 84 | case 0x000204: 85 | out = "DefaultHeapSize"; 86 | break; 87 | case 0x000280: 88 | out = "PageHeapSizeAndflags"; 89 | break; 90 | case 0x000300: 91 | out = "SystemFlags"; 92 | break; 93 | case 0x000400: 94 | out = "ExecutionID"; 95 | break; 96 | case 0x000401: 97 | out = "ServiceIDList"; 98 | break; 99 | case 0x000402: 100 | out = "TitleWorkspaceSize"; 101 | break; 102 | case 0x000403: 103 | out = "GameRatingsSpecified"; 104 | break; 105 | case 0x000404: 106 | out = "LANKey"; 107 | break; 108 | case 0x000405: 109 | out = "IncludesXbox360Logo"; 110 | break; 111 | case 0x000406: 112 | out = "MultidiscMediaIDs"; 113 | break; 114 | case 0x000407: 115 | out = "AlternateTitleIDs"; 116 | break; 117 | case 0x000408: 118 | out = "AdditionalTitleMemory"; 119 | break; 120 | case 0x00E104: 121 | out = "IncludesExportsByName"; 122 | break; 123 | default: 124 | SPrintf(out, "%X", header_id); 125 | break; 126 | } 127 | 128 | return out; 129 | } 130 | 131 | typedef struct { 132 | local quad cur_pos; 133 | 134 | SetBackColor(0xb0b0b0); 135 | 136 | u4 header_id : 24; 137 | u4 header_size : 8; 138 | 139 | if (header_size > 1) { 140 | u4 header_offset; 141 | 142 | if (header_size < 0xff) { 143 | SetBackColor(0xffa0a0); 144 | cur_pos = FTell(); 145 | FSeek(header_offset); 146 | u1 data[header_size << 2]; 147 | FSeek(cur_pos); 148 | } 149 | else { 150 | cur_pos = FTell(); 151 | FSeek(header_offset); 152 | SetBackColor(0xc0c0ff); 153 | u4 full_size; 154 | SetBackColor(0xa0a0ff); 155 | if (full_size - 4) { 156 | u1 header_data[full_size - 4]; 157 | } 158 | FSeek(cur_pos); 159 | } 160 | } 161 | else { 162 | u4 header_data; 163 | } 164 | 165 | } OPT_HEADER ; 166 | 167 | string read_OPT_HEADER(OPT_HEADER &in) { 168 | return header_type(in.header_id); 169 | } 170 | 171 | typedef struct { 172 | local int i; 173 | 174 | SetBackColor(0xc0c0c0); 175 | char signature[4]; 176 | u4 flags; 177 | u4 data_offset; 178 | u4 reserved; 179 | u4 sec_offset; 180 | u4 header_count; 181 | 182 | for (i = 0; i < header_count; i++) { 183 | OPT_HEADER opt; 184 | } 185 | } XEX_HEADER ; 186 | 187 | string read_XEX_HEADER(XEX_HEADER &in) { 188 | string out; 189 | return out; 190 | } 191 | 192 | typedef struct { 193 | SetBackColor(0xffffc0); 194 | u4 full_size; 195 | 196 | SetBackColor(0xffffa0); 197 | if (full_size - 4) { 198 | u1 sec_data[full_size - 4]; 199 | } 200 | } SEC_INFO; 201 | 202 | BigEndian(); 203 | 204 | local char sig[4]; 205 | ReadBytes(sig, 0, 4); 206 | 207 | if (sig[0] != 'X' || sig[1] != 'E' || sig[2] != 'X' || sig[3] != '2') { 208 | Printf("Incorrect signature\n"); 209 | Warning("Incorrect signature"); 210 | return -1; 211 | } 212 | 213 | XEX_HEADER h; 214 | 215 | FSeek(h.sec_offset); 216 | SEC_INFO s; 217 | -------------------------------------------------------------------------------- /010 Templates/XGS.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: XGS.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: XACT setting file 8 | // Category: Audio 9 | // File Mask: *.xgs 10 | // History: 11 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.2 2012-12-06 Andrew McRae: Merge changes 13 | // 0.1 2012-06-01 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | typedef struct { 26 | SetBackColor(0xff90ff); 27 | u4 name_offset; 28 | s2 hash ; 29 | 30 | local int cur_pos = FTell(); 31 | FSeek(name_offset); 32 | SetBackColor(0xffc0ff); 33 | string name; 34 | FSeek(cur_pos); 35 | } NAME_HASH ; 36 | 37 | typedef struct { 38 | SetBackColor(0xb8b8b8); 39 | 40 | char signature[4]; 41 | 42 | local u2 ver = ReadUShort(FTell()); 43 | if (ver > 41) { 44 | u2 content_version ; 45 | u2 header_version ; 46 | } 47 | else { 48 | u2 header_version ; 49 | } 50 | 51 | u2 crc; 52 | 53 | FILETIME last_modified; 54 | 55 | u1 platform; 56 | 57 | u2 num_category ; 58 | u2 num_variable ; 59 | u2 num_category_name_hash ; 60 | u2 num_variable_name_hash ; 61 | u2 num_rpc ; 62 | u2 num_dsp ; 63 | u2 num_dsp_param ; 64 | 65 | s4 off_category; 66 | s4 off_variable; 67 | s4 off_category_name_hash; 68 | s4 off_category_name_table; 69 | s4 off_variable_name_hash; 70 | s4 off_variable_name_table; 71 | s4 off_category_names; 72 | s4 off_variable_names; 73 | s4 off_rpc; 74 | s4 off_dsp; 75 | s4 off_dsp_param; 76 | } XGS_HEADER; 77 | 78 | typedef struct (int index) { 79 | local int name_index = index; 80 | SetBackColor(0xff9090); 81 | 82 | u1 max_instances ; 83 | u2 fade_in; 84 | u2 fade_out; 85 | enum {fLINEAR, fLOG, fEQL_POW} fade_type: 3; 86 | enum {iFAIL_TO_PLAY, iQUEUE, iREPLACE_OLDEST, iREPLACE_QUIETEST, iREPLACE_LOWEST} inst_flags: 5; 87 | s2 parent ; 88 | u1 volume; 89 | u1 bg_music: 1; 90 | u1 public: 1; 91 | u1 unknown_flags: 6; 92 | Assert(unknown_flags == 0, "Unknown flags in XGS_CATEGORY"); 93 | } XGS_CATEGORY ; 94 | 95 | string read_CATEGORY_parent(s2 &in) { 96 | if (in >= 0) { 97 | return cn[in].name; 98 | } 99 | else { 100 | return ""; 101 | } 102 | } 103 | 104 | string read_XGS_CATEGORY(XGS_CATEGORY &in) { 105 | return cn[in.name_index].name; 106 | } 107 | 108 | typedef struct (int index) { 109 | local int name_index = index; 110 | SetBackColor(0x90ff90); 111 | 112 | u1 public: 1; 113 | u1 read_only: 1; 114 | u1 cue_instance: 1; 115 | u1 reserved: 1; 116 | u1 unknown_flags: 4; 117 | Assert(unknown_flags == 0, "Unknown flags in XGS_VARIABLE"); 118 | 119 | float init_val; 120 | float min_val; 121 | float max_val; 122 | } XGS_VARIABLE ; 123 | 124 | string read_XGS_VARIABLE(XGS_VARIABLE &in) { 125 | return vn[in.name_index].name; 126 | } 127 | 128 | typedef struct { 129 | float x; 130 | float y; 131 | enum {cLINEAR, cFAST, cSLOW, cSINCOS} type; 132 | } RPC_POINT; 133 | 134 | typedef struct { 135 | SetBackColor(0x9090ff); 136 | 137 | u2 var_index ; 138 | u1 point_count; 139 | enum {pVOLUME=0x0, pPITCH, pREVERB_SEND, pFILTER_FREQ, pFILTER_Q, pR_REF_DELAY, pR_REV_DELAY, pR_POS_LEFT, 140 | pR_POS_RIGHT=0x8, pR_POS_LEFTM, pR_POS_RIGHTM, pR_EARLY_DIFF, pR_LATE_DIFF, pR_LOEQ_GAIN, pR_LOEQ_CUT, pR_HIEQ_GAIN, 141 | pR_HIEQ_CUT=0x10, pR_REAR_DELAY, pR_ROOM_FREQ, pR_ROOM_MAIN, pR_ROOM_HFREQ, pR_REF_GAIN, pR_REV_GAIN, pR_DECAY, 142 | pR_DENSITY=0x18, pR_ROOM_SIZE, pR_MIX} param; 143 | RPC_POINT points[point_count]; 144 | } XGS_RPC_CURVE ; 145 | 146 | string read_RPC_var(u2 &in) { 147 | return vn[in].name; 148 | } 149 | 150 | typedef struct { 151 | SetBackColor(0x90ffff); 152 | u1 global; 153 | u2 num_param; 154 | u2 unknown; 155 | Assert(unknown == 0); 156 | } XGS_DSP ; 157 | 158 | typedef struct { 159 | SetBackColor(0xffff90); 160 | u1 type; 161 | float init_val; 162 | float min_val; 163 | float max_val; 164 | u2 unknown; 165 | Assert(unknown == 0); 166 | } XGS_DSP_PARAM ; 167 | 168 | DisplayFormatHex(); 169 | LittleEndian(); 170 | BitfieldRightToLeft(); 171 | 172 | local uint sig; 173 | sig = ReadInt(0); 174 | 175 | if (sig == 0x58475346) { 176 | Warning("BigEndian"); 177 | BigEndian(); 178 | BitfieldRightToLeft(); 179 | sig = ReadInt(0); 180 | } 181 | 182 | if (sig != 0x46534758) { 183 | Printf("Incorrect signature\n"); 184 | Warning("Incorrect signature"); 185 | return -1; 186 | } 187 | 188 | XGS_HEADER h; 189 | 190 | local int i; 191 | 192 | if (h.num_category && h.off_category >= 0) { 193 | FSeek(h.off_category); 194 | for (i = 0; i < h.num_category; i++) { 195 | XGS_CATEGORY c(i); 196 | } 197 | } 198 | 199 | if (h.num_category_name_hash && h.off_category_name_hash >= 0) { 200 | FSeek(h.off_category_name_hash); 201 | SetBackColor(0xc0c0c0); 202 | s2 cnh[h.num_category_name_hash] ; 203 | } 204 | 205 | if (h.num_category && h.off_category_name_table >= 0) { 206 | FSeek(h.off_category_name_table); 207 | NAME_HASH cn[h.num_category] ; 208 | } 209 | 210 | if (h.num_variable && h.off_variable >= 0) { 211 | FSeek(h.off_variable); 212 | for (i = 0; i < h.num_variable; i++) { 213 | XGS_VARIABLE v(i); 214 | } 215 | } 216 | 217 | if (h.num_variable_name_hash && h.off_variable_name_hash >= 0) { 218 | FSeek(h.off_variable_name_hash); 219 | SetBackColor(0xc0c0c0); 220 | s2 vnh[h.num_variable_name_hash] ; 221 | } 222 | 223 | if (h.num_variable && h.off_variable_name_table >= 0) { 224 | FSeek(h.off_variable_name_table); 225 | NAME_HASH vn[h.num_variable] ; 226 | } 227 | 228 | if (h.num_rpc && h.off_rpc >= 0) { 229 | FSeek(h.off_rpc); 230 | XGS_RPC_CURVE r[h.num_rpc]; 231 | } 232 | 233 | if (h.num_dsp && h.off_dsp >= 0) { 234 | FSeek(h.off_dsp); 235 | XGS_DSP d[h.num_dsp]; 236 | } 237 | 238 | if (h.num_dsp_param && h.off_dsp_param >= 0) { 239 | FSeek(h.off_dsp_param); 240 | XGS_DSP_PARAM dp[h.num_dsp_param]; 241 | } 242 | -------------------------------------------------------------------------------- /010 Templates/XSB.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: XSB.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: XACT sound bank 8 | // Category: Audio 9 | // File Mask: *.xsb 10 | // History: 11 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.2 2012-12-21 Andrew McRae: Merge changes 13 | // 0.1 2012-11-30 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | typedef struct { 26 | SetBackColor(0xff90ff); 27 | u4 name_offset; 28 | s2 hash ; 29 | 30 | local int cur_pos = FTell(); 31 | FSeek(name_offset); 32 | SetBackColor(0xffc0ff); 33 | string name; 34 | FSeek(cur_pos); 35 | } NAME_HASH ; 36 | 37 | typedef struct { 38 | char name[64]; 39 | } NAME ; 40 | 41 | string read_NAME(NAME &in) { 42 | return in.name; 43 | } 44 | 45 | typedef struct { 46 | SetBackColor(0xb8b8b8); 47 | 48 | char signature[4]; 49 | 50 | u2 content_version ; 51 | 52 | u2 header_version ; 53 | u2 crc; 54 | 55 | FILETIME last_modified; 56 | 57 | u1 flags; 58 | 59 | u2 num_simple_cue ; 60 | u2 num_complex_cue ; 61 | u2 num_unknown1 ; 62 | u2 num_cue_hash ; 63 | u1 num_wavebank ; 64 | u2 num_sound ; 65 | 66 | u4 cue_names_len; 67 | 68 | s4 off_simple_cue; 69 | s4 off_complex_cue; 70 | s4 off_cue_names; 71 | s4 off_unknown1; 72 | s4 off_variation; 73 | s4 off_transition; 74 | s4 off_wavebank_name; 75 | s4 off_cue_name_hash; 76 | s4 off_cue_name_hash_entry; 77 | s4 off_sound; 78 | 79 | NAME name; 80 | } XSB_HEADER; 81 | 82 | typedef struct { 83 | u4 sound_offset; 84 | u1 weight_min; 85 | u1 weight_max; 86 | } VARIATION; 87 | 88 | typedef struct { 89 | u4 sound_offset; 90 | u1 weight; 91 | } VARIATION_SMALL; 92 | 93 | typedef struct { 94 | SetBackColor(0x90ff90); 95 | u4 count: 16; 96 | enum {tORDERED, tORDERED_RANDOM, tRANDOM, tRANDOM_NOREP, tSHUFFLE} variation_type: 3; 97 | u4 table_type: 3; 98 | u4 new_var_on_loop: 1; 99 | u4 unknown_flags: 9; 100 | Assert(unknown_flags == 0); 101 | 102 | u2 variable; 103 | u2 last_index; 104 | 105 | if (table_type) { 106 | VARIATION t[count]; 107 | } 108 | else { 109 | VARIATION_SMALL t[count]; 110 | } 111 | } XSB_VARIATION; 112 | 113 | typedef struct { 114 | u1 stop_cue: 1; 115 | u1 stop_immediate: 1; 116 | u1 unknown_flags: 6; 117 | Assert(unknown_flags == 0); 118 | } CLIP_EVENT_0; 119 | 120 | typedef struct { 121 | u1 loop_play_release: 1; 122 | u1 pan_enable: 1; 123 | u1 pan_center: 1; 124 | u1 pan_new: 1; 125 | u1 unknown_flags: 4; 126 | u2 track; 127 | u1 wavebank; 128 | u1 loop_count ; 129 | u2 pan_angle ; 130 | u2 pan_arc ; 131 | Assert(unknown_flags == 0); 132 | } CLIP_EVENT_1; 133 | 134 | typedef struct { 135 | s2 pitch_min ; 136 | s2 pitch_max ; 137 | u1 vol_min; 138 | u1 vol_max; 139 | float freq_min; 140 | float freq_max; 141 | float q_min; 142 | float q_max; 143 | u1 vol_add: 1; 144 | u1 unknown: 1; 145 | u1 pitch_add: 1; 146 | u1 unknown: 1; 147 | u1 freq_add: 1; 148 | u1 unknown: 1; 149 | u1 q_add: 1; 150 | u1 unknown: 1; 151 | u1 pitch_new: 1; 152 | u1 vol_new: 1; 153 | u1 freq_new: 1; 154 | u1 q_new: 1; 155 | u1 pitch_var: 1; 156 | u1 vol_var: 1; 157 | u1 freq_var: 1; 158 | u1 q_var: 1; 159 | } CLIP_EVENT_4; 160 | 161 | typedef struct { 162 | u1 type; 163 | if (type == 0) { 164 | u1 add: 1; 165 | u1 random: 1; 166 | u1 value: 1; 167 | u1 unknown_flags: 5; 168 | u2 unknown; 169 | s2 min ; 170 | u2 unknown; 171 | s2 max ; 172 | u2 unknown; 173 | u2 unknown; 174 | u1 unknown; 175 | } 176 | else { 177 | s2 unknown ; 178 | s2 initial ; 179 | float slope; 180 | float delta; 181 | s2 seconds ; 182 | } 183 | } CLIP_EVENT_7; 184 | 185 | typedef struct { 186 | u1 type; 187 | if (type == 0) { 188 | u1 add: 1; 189 | u1 random: 1; 190 | u1 value: 1; 191 | u1 unknown_flags: 5; 192 | u2 unknown; 193 | s2 min ; 194 | u2 unknown; 195 | s2 max ; 196 | u2 unknown; 197 | u2 unknown; 198 | u1 unknown; 199 | } 200 | else { 201 | s2 unknown ; 202 | s2 initial ; 203 | float slope; 204 | float delta; 205 | s2 seconds ; 206 | } 207 | } CLIP_EVENT_8; 208 | 209 | typedef struct { 210 | u4 marker; 211 | } CLIP_EVENT_9; 212 | 213 | typedef struct { 214 | u2 repeats ; 215 | u2 frequency ; 216 | } CLIP_EVENT_18; 217 | 218 | typedef struct { 219 | SetBackColor(0xfff0a0); 220 | 221 | u4 event_type: 5; 222 | u4 timestamp: 16 ; 223 | u4 unknown_flags: 8; 224 | u4 is_absolute: 1; 225 | u4 is_relative_start: 1; 226 | u4 is_random_recur: 1; 227 | Assert(unknown_flags == 0); 228 | u2 random_offset ; 229 | u1 unknown; 230 | 231 | switch (event_type) { 232 | case 0: 233 | CLIP_EVENT_0 e; 234 | break; 235 | case 1: 236 | CLIP_EVENT_1 e; 237 | break; 238 | case 4: 239 | CLIP_EVENT_1 e; 240 | CLIP_EVENT_4 e; 241 | break; 242 | case 7: 243 | CLIP_EVENT_7 e; 244 | break; 245 | case 8: 246 | CLIP_EVENT_8 e; 247 | break; 248 | case 9: 249 | CLIP_EVENT_9 e; 250 | break; 251 | case 18: 252 | CLIP_EVENT_9 e; 253 | CLIP_EVENT_18 e; 254 | break; 255 | default: 256 | break; 257 | } 258 | 259 | } CLIP_EVENT ; 260 | 261 | typedef struct { 262 | SetBackColor(0xfff0a0); 263 | 264 | u1 num_events; 265 | // Assert(num_events == 1); 266 | 267 | CLIP_EVENT events[num_events]; 268 | } SOUND_CLIP ; 269 | 270 | typedef struct { 271 | SetBackColor(0xffc090); 272 | 273 | u1 volume; 274 | u4 off_clip; 275 | u2 filter_enable: 1; 276 | enum {fLOW, fBAND, fHIGH} filter_type: 2; 277 | u2 filter_q: 13 ; 278 | u2 filter_freq ; 279 | 280 | local int cur_pos = FTell(); 281 | FSeek(off_clip); 282 | SOUND_CLIP clip; 283 | FSeek(cur_pos); 284 | } XSB_CLIP ; 285 | 286 | typedef struct { 287 | u1 var_num; 288 | if (var_num > 0) { 289 | u4 var_offset[var_num]; 290 | } 291 | cur_size += 1 + 4 * var_num; 292 | } VAR_OFFSETS ; 293 | 294 | typedef struct { 295 | SetBackColor(0xff9090); 296 | 297 | local int cur_pos = FTell(); 298 | 299 | u1 is_complex: 1; 300 | u1 has_sound_rpc: 1; 301 | u1 has_track_rpc: 1; 302 | u1 has_effect_rpc: 1; 303 | u1 has_dsp: 1; 304 | u1 unknown_flags: 3; 305 | Assert(unknown_flags == 0, "Unknown flags in XSB_SOUND"); 306 | u2 category; 307 | u1 volume; 308 | s2 pitch ; 309 | u1 priority; 310 | u2 entry_len; 311 | 312 | if (is_complex) { 313 | u1 num_tracks; 314 | } 315 | else { 316 | u2 track; 317 | u1 wavebank; 318 | } 319 | 320 | local int cur_size = 0; 321 | if (has_sound_rpc || has_track_rpc || has_effect_rpc) { 322 | local int rpc_pos = FTell(); 323 | SetBackColor(0xff90c0); 324 | u2 rpc_extra; 325 | cur_size = 2; 326 | 327 | if (has_effect_rpc) { 328 | VAR_OFFSETS effect_rpc; 329 | } 330 | if (has_sound_rpc) { 331 | VAR_OFFSETS sound_rpc; 332 | } 333 | if (has_track_rpc) { 334 | Assert(is_complex, "has_track_rpc set on simple sound"); 335 | VAR_OFFSETS track_rpc[num_clip]; 336 | } 337 | Assert(rpc_extra == cur_size); 338 | FSeek(rpc_pos + rpc_extra); 339 | } 340 | 341 | if (has_dsp) { 342 | local int dsp_pos = FTell(); 343 | SetBackColor(0xffa0f0); 344 | u2 dsp_extra; 345 | cur_size = 2; 346 | VAR_OFFSETS dsp; 347 | Assert(dsp_extra == cur_size); 348 | FSeek(dsp_pos + dsp_extra); 349 | } 350 | 351 | if (is_complex) { 352 | XSB_CLIP tracks[num_tracks]; 353 | } 354 | 355 | Assert(FTell() <= (cur_pos + entry_len)); 356 | FSeek(cur_pos + entry_len); 357 | } XSB_SOUND ; 358 | 359 | typedef struct (int index) { 360 | local int name_index = index; 361 | SetBackColor(0x90ff90); 362 | 363 | u1 is_complex: 1; 364 | u1 has_transition: 1; 365 | u1 has_sound: 1; 366 | u1 unknown_flags: 5; 367 | Assert(!is_complex); 368 | Assert(unknown_flags == 0); 369 | 370 | s4 sound_offset; 371 | } XSB_SIMPLE_CUE ; 372 | 373 | string read_XSB_SIMPLE_CUE(XSB_SIMPLE_CUE &in) { 374 | if (h.cue_names_len) { 375 | return cn[in.name_index].name; 376 | } 377 | else { 378 | return ""; 379 | } 380 | } 381 | 382 | typedef struct (int index) { 383 | local int name_index = index; 384 | SetBackColor(0x9090ff); 385 | 386 | u1 is_complex: 1; 387 | u1 has_transition: 1; 388 | u1 has_sound: 1; 389 | u1 unknown_flags: 5; 390 | Assert(is_complex); 391 | Assert(unknown_flags == 0); 392 | 393 | if (has_sound) { 394 | s4 off_sound; 395 | } 396 | else { 397 | s4 off_variation; 398 | } 399 | 400 | if (has_transition) { 401 | s4 off_transition; 402 | } 403 | else { 404 | s4 off_unknown; 405 | } 406 | 407 | u1 instance_limit ; 408 | u2 fade_in ; 409 | u2 fade_out ; 410 | enum {fLINEAR, fLOG, fEQL_POW} fade_type: 3; 411 | enum {iFAIL_TO_PLAY, iQUEUE, iREPLACE_OLDEST, iREPLACE_QUIETEST, iREPLACE_LOWEST} inst_flags: 5; 412 | 413 | local int cur_pos = FTell(); 414 | 415 | if (has_sound) { 416 | if (off_sound >= 0) { 417 | FSeek(off_sound); 418 | // XSB_SOUND 419 | FSeek(cur_pos); 420 | } 421 | } 422 | else { 423 | if (off_variation >= 0) { 424 | FSeek(off_variation); 425 | XSB_VARIATION v; 426 | FSeek(cur_pos); 427 | } 428 | } 429 | } XSB_COMPLEX_CUE ; 430 | 431 | string read_XSB_COMPLEX_CUE(XSB_COMPLEX_CUE &in) { 432 | if (h.cue_names_len) { 433 | return cn[in.name_index].name; 434 | } 435 | else { 436 | return ""; 437 | } 438 | } 439 | 440 | DisplayFormatHex(); 441 | LittleEndian(); 442 | BitfieldRightToLeft(); 443 | 444 | local uint sig; 445 | sig = ReadInt(0); 446 | 447 | if (sig == 0x5344424B) { 448 | Warning("BigEndian"); 449 | BigEndian(); 450 | BitfieldRightToLeft(); 451 | sig = ReadInt(0); 452 | } 453 | 454 | if (sig != 0x4B424453) { 455 | Printf("Incorrect signature\n"); 456 | Warning("Incorrect signature"); 457 | return -1; 458 | } 459 | 460 | XSB_HEADER h; 461 | 462 | local int i; 463 | 464 | if (h.num_wavebank && h.off_wavebank_name >= 0) { 465 | FSeek(h.off_wavebank_name); 466 | SetBackColor(0xd8d8d8); 467 | NAME wn[h.num_wavebank]; 468 | } 469 | 470 | if (h.num_sound && h.off_sound >= 0) { 471 | FSeek(h.off_sound); 472 | XSB_SOUND s[h.num_sound]; 473 | } 474 | 475 | local int cur_name_index = 0; 476 | if (h.num_simple_cue && h.off_simple_cue >= 0) { 477 | FSeek(h.off_simple_cue); 478 | for (i = 0; i < h.num_simple_cue; i++, cur_name_index++) { 479 | XSB_SIMPLE_CUE cs(cur_name_index); 480 | } 481 | } 482 | 483 | if (h.num_complex_cue && h.off_complex_cue >= 0) { 484 | FSeek(h.off_complex_cue); 485 | for (i = 0; i < h.num_complex_cue; i++, cur_name_index++) { 486 | XSB_COMPLEX_CUE cc(cur_name_index); 487 | } 488 | } 489 | 490 | if (h.num_cue_hash && h.off_cue_name_hash >= 0) { 491 | FSeek(h.off_cue_name_hash); 492 | SetBackColor(0xc0c0c0); 493 | s2 ch[h.num_cue_hash] ; 494 | } 495 | 496 | if (h.cue_names_len && h.off_cue_name_hash_entry >= 0) { 497 | FSeek(h.off_cue_name_hash_entry); 498 | NAME_HASH cn[h.num_simple_cue + h.num_complex_cue]; 499 | } 500 | -------------------------------------------------------------------------------- /010 Templates/XWB.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: XWB.bt 5 | // Author: Andrew McRae 6 | // Version: 0.3 7 | // Purpose: XACT wave bank 8 | // Category: Audio 9 | // File Mask: *.xwb 10 | // History: 11 | // 0.3 2016-03-30 Andrew McRae: Updated header for repo 12 | // 0.2 2014-01-24 Andrew McRae: Merge changes 13 | // 0.1 2012-06-01 Andrew McRae: Initial revision 14 | //------------------------------------------------ 15 | 16 | typedef uint64 u8; 17 | typedef uint32 u4; 18 | typedef uint16 u2; 19 | typedef ubyte u1; 20 | typedef int64 s8; 21 | typedef int32 s4; 22 | typedef int16 s2; 23 | typedef byte s1; 24 | 25 | typedef struct { 26 | char name[64]; 27 | } NAME ; 28 | 29 | string read_NAME(NAME &in) { 30 | return in.name; 31 | } 32 | 33 | typedef struct { 34 | u4 region_offset; 35 | u4 region_size; 36 | } XWB_Region ; 37 | 38 | string read_XWB_Region(XWB_Region &in) { 39 | string out; 40 | SPrintf(out, "%Xh+%Xh", in.region_offset, in.region_size); 41 | return out; 42 | } 43 | 44 | typedef struct { 45 | SetBackColor(0xb8b8b8); 46 | 47 | char signature[4]; 48 | 49 | u4 content_version ; 50 | global_version = content_version; 51 | 52 | if (global_version <= 3) { 53 | Warning("Nonhandled version"); 54 | Printf("Nonhandled version\n"); 55 | return -1; 56 | } 57 | 58 | if (global_version >= 42) { 59 | u4 header_version ; 60 | } 61 | 62 | XWB_Region r[5]; 63 | } XWB_Header; 64 | 65 | typedef struct (int size) { 66 | SetBackColor(0xb0ffb0); 67 | 68 | local quad start_pos = FTell(); 69 | 70 | u4 f_streaming: 1; 71 | u4 f_unknown1: 15; 72 | u4 f_entry_names: 1; 73 | u4 f_compact: 1; 74 | u4 f_sync_disabled: 1; 75 | u4 f_seek_tables: 1; 76 | u4 f_unknown2: 12; 77 | Assert(f_unknown1 == 0); 78 | Assert(f_unknown2 == 0); 79 | 80 | u4 entries; 81 | global_entries = entries; 82 | 83 | char bank_name[64]; 84 | 85 | u4 entry_metadata_element_size; 86 | u4 entry_name_element_size; 87 | u4 alignment; 88 | 89 | enum {ctPCM, ctXMA, ctADPCM, ctWMA} ch_format_tag: 2; 90 | u4 ch_channels: 3 ; 91 | u4 ch_samples_per_sec: 18 ; 92 | u4 ch_block_align: 8; 93 | u4 ch_bits_per_sample: 1 ; 94 | FILETIME build_time; 95 | 96 | if ((FTell() - start_pos) != size) { 97 | Warning("BankData size incorrect"); 98 | Printf("BankData size incorrect\n"); 99 | } 100 | } XWB_BankData ; 101 | 102 | typedef struct (int size) { 103 | SetBackColor(0xffb0b0); 104 | 105 | local quad start_pos = FTell(); 106 | 107 | u4 f_read_ahead: 1; 108 | u4 f_loop_cache: 1; 109 | u4 f_remove_loop_tail: 1; 110 | u4 f_ignore_loop: 1; 111 | u4 duration: 28 ; 112 | enum {tPCM, tXMA, tADPCM, tWMA} h_format_tag: 2; 113 | u4 h_channels: 3 ; 114 | u4 h_samples_per_sec: 18 ; 115 | u4 h_block_align: 8; 116 | u4 h_bits_per_sample: 1 ; 117 | 118 | XWB_Region wave_data; 119 | 120 | SetBackColor(0xffb0b0); 121 | XWB_Region loop_region; 122 | 123 | if ((FTell() - start_pos) != size) { 124 | Warning("EntryMetadata size incorrect"); 125 | Printf("EntryMetadata size incorrect\n"); 126 | } 127 | } EntryMetadata ; 128 | 129 | string read_EntryMetadata(EntryMetadata &in) { 130 | return EnumToString(in.h_format_tag); 131 | } 132 | 133 | typedef struct (int size) { 134 | SetBackColor(0xffb0b0); 135 | 136 | if ((bd.entry_metadata_element_size * global_entries) != size) { 137 | Warning("EntryMetadata size != size*entries"); 138 | Printf("EntryMetadata size != size*entries\n"); 139 | } 140 | 141 | if (global_entries > 0) { 142 | EntryMetadata em(bd.entry_metadata_element_size)[global_entries]; 143 | } 144 | } XWB_EntryMetadata ; 145 | 146 | typedef struct (int pos) { 147 | SetBackColor(0xb0b0ff); 148 | s4 offset; 149 | if (offset >= 0) { 150 | local int cur_pos = FTell(); 151 | FSeek(pos + offset); 152 | SetBackColor(0xd0d0ff); 153 | u4 size; 154 | if (size > 0) { 155 | u4 data[size]; 156 | } 157 | FSeek(cur_pos); 158 | } 159 | else { 160 | local int size = 0; 161 | } 162 | SetBackColor(0xb0b0ff); 163 | } SeekTable ; 164 | 165 | string read_SeekTable(SeekTable &in) { 166 | string out; 167 | SPrintf(out, "%d", in.size); 168 | return out; 169 | } 170 | 171 | typedef struct (int size) { 172 | SetBackColor(0xb0b0ff); 173 | 174 | if (global_entries > 0) { 175 | local int i; 176 | local int table_pos = FTell() + 4 * global_entries; 177 | for (i = 0; i < global_entries; i++) { 178 | SeekTable s(table_pos); 179 | } 180 | } 181 | } XWB_SeekTable ; 182 | 183 | typedef struct (int size) { 184 | SetBackColor(0xb0ffff); 185 | 186 | if ((64 * global_entries) != size) { 187 | Warning("EntryName size != size*entries"); 188 | Printf("EntryName size != size*entries\n"); 189 | } 190 | 191 | if (global_entries > 0) { 192 | NAME n[global_entries]; 193 | } 194 | } XWB_EntryName ; 195 | 196 | typedef struct (int size) { 197 | u1 d[size]; 198 | } Data ; 199 | 200 | typedef struct (int size) { 201 | SetBackColor(0xffb0ff); 202 | 203 | local int start_pos = h.r[4].region_offset; 204 | 205 | local int i; 206 | for (i = 0; i < global_entries; i++) { 207 | FSeek(start_pos + em.em[i].wave_data.region_offset); 208 | SetBackColor(0xffb0ff); 209 | Data wavedata(em.em[i].wave_data.region_size); 210 | } 211 | } XWB_EntryWaveData ; 212 | 213 | DisplayFormatHex(); 214 | LittleEndian(); 215 | 216 | local u4 global_version; 217 | local u4 global_entries; 218 | 219 | local int sig; 220 | sig = ReadInt(0); 221 | 222 | if (sig == 0x57424E44) { 223 | Warning("BigEndian"); 224 | BigEndian(); 225 | BitfieldRightToLeft(); 226 | sig = ReadInt(0); 227 | } 228 | 229 | if (sig != 0x444E4257) { 230 | Printf("Incorrect signature\n"); 231 | Warning("Incorrect signature"); 232 | return -1; 233 | } 234 | 235 | XWB_Header h; 236 | 237 | if (h.r[0].region_offset > 0 && h.r[0].region_size > 0) { 238 | FSeek(h.r[0].region_offset); 239 | XWB_BankData bd(h.r[0].region_size); 240 | } 241 | 242 | if (h.r[1].region_offset > 0 && h.r[1].region_size > 0) { 243 | FSeek(h.r[1].region_offset); 244 | XWB_EntryMetadata em(h.r[1].region_size); 245 | } 246 | 247 | if (h.r[2].region_offset > 0 && h.r[2].region_size > 0) { 248 | FSeek(h.r[2].region_offset); 249 | XWB_SeekTable st(h.r[2].region_size); 250 | } 251 | 252 | if (h.r[3].region_offset > 0 && h.r[3].region_size > 0) { 253 | FSeek(h.r[3].region_offset); 254 | XWB_EntryName en(h.r[3].region_size); 255 | } 256 | 257 | if (h.r[4].region_offset > 0 && h.r[4].region_size > 0) { 258 | FSeek(h.r[4].region_offset); 259 | XWB_EntryWaveData wd(h.r[4].region_size); 260 | } 261 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 010editor 2 | ========= 3 | 4 | Templates and scripts for 010 editor 5 | --------------------------------------------------------------------------------