OpenBarnyard
 
Loading...
Searching...
No Matches
TCompress.h
Go to the documentation of this file.
1#pragma once
2#include "Toshi/TVersion.h"
3#include "File/TFile.h"
4
6
15
22
28
30{
31public:
32 //-----------------------------------------------------------------------------
33 // General Information
34 //-----------------------------------------------------------------------------
35
44
45 // Size of header that is common for any BTEC version
46 static constexpr TUINT32 HEADER_SIZE_12 = sizeof( Header ) - sizeof( Header::XorValue );
47
48 // Size of header that is common for BTEC 1.3
49 static constexpr TUINT32 HEADER_SIZE_13 = sizeof( Header );
50
51 // Custom variable used to help the compressor/decompressor decide which byte order it should use
52 inline static TBOOL ms_bIsBigEndian = TFALSE;
53
54public:
55 //-----------------------------------------------------------------------------
56 // Compressor
57 //-----------------------------------------------------------------------------
58
59 static constexpr TINT maxlength = 0x4000;
61
62public:
63 static size_t Compress( TFile* file, TBYTE* data, TUINT32 size, TUINT32 unused, TBOOL isBigEndian );
64
65private:
66 static TINT WriteOffset( TUINT32 length, TINT offset, TBYTE*& data, TFile* file );
67 static TINT Write( TUINT32 length, TBYTE*& data, TFile* file );
68
69public:
70 //-----------------------------------------------------------------------------
71 // Decompressor
72 //-----------------------------------------------------------------------------
73
74 static uintptr_t Decompress( TFile* file, TCompress::Header* header, TBYTE* buffer, TUINT32 bufferSize );
75 static int8_t GetHeader( TFile* file, TCompress::Header& btecHeader );
76 static TINT GetCommand( TFile* file, TBOOL& hasOffset, TUINT32& size, TINT& offset );
77};
78
TCOMPRESS_ERROR
Definition TCompress.h:8
@ TCOMPRESS_ERROR_WRONG_MAGIC
Definition TCompress.h:10
@ TCOMPRESS_ERROR_WRONG_HEADERSIZE
Definition TCompress.h:13
@ TCOMPRESS_ERROR_WRONG_SIZE
Definition TCompress.h:12
@ TCOMPRESS_ERROR_OK
Definition TCompress.h:9
@ TCOMPRESS_ERROR_WRONG_VERSION
Definition TCompress.h:11
BTECSizeFlag
Definition TCompress.h:17
@ BTECSizeFlag_NoOffset
Definition TCompress.h:19
@ BTECSizeFlag_BigSize
Definition TCompress.h:18
@ BTECSizeFlag_SizeMask
Definition TCompress.h:20
BTECOffsetFlag
Definition TCompress.h:24
@ BTECOffsetFlag_BigOffset
Definition TCompress.h:25
@ BTECOffsetFlag_OffsetMask
Definition TCompress.h:26
Core file system interface for the Toshi engine.
#define BITFLAG(x)
Definition Defines.h:10
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
bool TBOOL
Definition Typedefs.h:6
uint8_t TBYTE
Definition Typedefs.h:19
static constexpr TUINT32 HEADER_SIZE_13
Definition TCompress.h:49
static TINT GetCommand(TFile *file, TBOOL &hasOffset, TUINT32 &size, TINT &offset)
static TBOOL ms_bIsBigEndian
Definition TCompress.h:52
static constexpr TUINT32 HEADER_SIZE_12
Definition TCompress.h:46
static constexpr TINT maxlength
Definition TCompress.h:59
static uintptr_t Decompress(TFile *file, TCompress::Header *header, TBYTE *buffer, TUINT32 bufferSize)
static int8_t GetHeader(TFile *file, TCompress::Header &btecHeader)
static size_t Compress(TFile *file, TBYTE *data, TUINT32 size, TUINT32 unused, TBOOL isBigEndian)
static TINT usemaxoffset
Definition TCompress.h:60
TVersion Version
Definition TCompress.h:39
TUINT32 CompressedSize
Definition TCompress.h:40
Definition TFile.h:128