29 writtenSize += file->
Write( &length, 1 );
36 BYTE1( length ) = len;
37 writtenSize += file->
Write( &length, 2 );
40 writtenSize += file->
Write( data, dataSize );
61 writtenSize += file->
Write( &length, 1 );
67 BYTE1( length ) = len;
68 writtenSize += file->
Write( &length, 2 );
74 writtenSize += file->
Write( &offset, 1 );
78 auto _offset = offset;
80 BYTE1( offset ) = _offset;
81 writtenSize += file->
Write( &offset, 2 );
96 TBYTE* bufferPos = buffer;
97 TBYTE* bufferEnd = buffer + size;
99 auto initialPos = file->
Tell();
102 TSIZE compressedSize = 0;
106 while ( bufferPos < bufferEnd )
112 TBOOL hasOffset = compressor.
FUN_0068af10( bufferPos, uncompressedLeft, offset, dataSize );
114 if ( hasOffset ==
TFALSE || dataSize < 3 )
119 if ( chunkStart ==
TNULL ) chunkStart = bufferPos;
125 compressedSize += TCompress::Write( chunkSize, chunkStart, file );
134 if ( chunkStart !=
TNULL )
137 compressedSize += TCompress::Write( chunkSize, chunkStart, file );
142 compressedSize += TCompress::WriteOffset( dataSize, bufferPos - offset, bufferPos, file );
148 if ( chunkStart !=
TNULL )
151 compressedSize += TCompress::Write( chunkSize, chunkStart, file );
158 btecHeader.
Size = size;
162 btecHeader.
Magic = PARSEDWORD_BIG( btecHeader.
Magic );
165 btecHeader.
Size = PARSEDWORD_BIG( btecHeader.
Size );
172 return compressedSize;
@ BTECOffsetFlag_BigOffset
#define TOSHI_NAMESPACE_START
#define TVERSION(VER_MAJOR, VER_MINOR)
#define TOSHI_NAMESPACE_END
TFORCEINLINE constexpr TUINT32 TFourCC(const TCHAR str[4])
TFORCEINLINE const T & Min(const T &a, const T &b)
void FUN_0068ae40(size_t dataSize)
TBOOL FUN_0068af10(TBYTE *buffer, size_t bufferSize, TBYTE *&offset, size_t &dataSize)
void Initialize(TBYTE *buffer, size_t bufferSize, TINT maxoffset, TINT unk)
static constexpr TUINT32 HEADER_SIZE_12
static constexpr TINT maxlength
static size_t Compress(TFile *file, TBYTE *data, TUINT32 size, TUINT32 unused, TBOOL isBigEndian)
virtual TBOOL Seek(TINT a_iOffset, TSEEK a_eOrigin=TSEEK_CUR)=0
Shifts current file cursor based on the specified offset and origin.
virtual TSIZE Write(const void *a_pSrc, TSIZE a_uiSize)=0
Writes specified number of bytes to the file from the buffer.