BLTE-Template
Jump to navigation
Jump to search
//Data Types typedef struct { BigEndian(); unsigned int _; LittleEndian(); }BE_uint32_t<read=readBE_uint32_t>; string readBE_uint32_t (BE_uint32_t& e) { local string a; SPrintf (a, "%u", e._); return a; } struct BE_uint8_t { BigEndian(); unsigned char _; LittleEndian(); }; typedef struct { unsigned char _0; unsigned char _1; unsigned char _2; local unsigned int __ = _2 | ((unsigned int)_1 << 8) | ((unsigned int)_0 << 16); } BE_uint24<read=read_int24, optimize=false, size=3>; int value_int24 (BE_uint24& ref) { int _0 = ref._0; int _1 = ref._1; int _2 = ref._2; int combined = _2 | (_1 << 8) | (_0 << 16); if (combined & 0x800000) { combined = combined | 0xFF000000; } return combined; } string read_int24 (BE_uint24& ref) { local string a; SPrintf (a, "%i", value_int24 (ref)); return a; } //Structs struct BLTE_FILE { local int id = 0; struct BLTE_Header { char FileSignature[4]; // 'BLTE'; BE_uint32_t headerSize; } header; struct BLTE_ChunkInfoEntry { BE_uint32_t compressedSize; BE_uint32_t decompressedSize; char checksum[16]; }; struct BLTE_ChunkInfo { BE_uint8_t unknownFlags; BE_uint24 chunkCount; BLTE_ChunkInfoEntry ChunkInfoEntry[chunkCount.__]<optimize=false>; } ChunkInfo; struct BLTE_Data_Chunk { char encodingMode; char data[ChunkInfo.ChunkInfoEntry[id].compressedSize._ - 1]; id++; } Chunk[ChunkInfo.chunkCount.__]<optimize=false>; } FILE;