90{
91 BTECCompressor compressor;
92
95
96 TBYTE* bufferPos = buffer;
97 TBYTE* bufferEnd = buffer + size;
98
99 auto initialPos = file->
Tell();
101
102 TSIZE compressedSize = 0;
105
106 while ( bufferPos < bufferEnd )
107 {
109
112 TBOOL hasOffset = compressor.
FUN_0068af10( bufferPos, uncompressedLeft, offset, dataSize );
113
114 if ( hasOffset ==
TFALSE || dataSize < 3 )
115 {
116 dataSize = 1;
117
118
119 if ( chunkStart ==
TNULL ) chunkStart = bufferPos;
120 chunkSize += 1;
121
123 {
124
125 compressedSize += TCompress::Write( chunkSize, chunkStart, file );
127 chunkSize = 0;
128 }
129
130 bufferPos += 1;
131 }
132 else
133 {
134 if ( chunkStart !=
TNULL )
135 {
136
137 compressedSize += TCompress::Write( chunkSize, chunkStart, file );
139 chunkSize = 0;
140 }
141
142 compressedSize += TCompress::WriteOffset( dataSize, bufferPos - offset, bufferPos, file );
143 }
144
146 }
147
148 if ( chunkStart !=
TNULL )
149 {
150
151 compressedSize += TCompress::Write( chunkSize, chunkStart, file );
152 }
153
154 TCompress::Header btecHeader;
158 btecHeader.
Size = size;
159
160 if ( isBigEndian )
161 {
162 btecHeader.
Magic = PARSEDWORD_BIG( btecHeader.
Magic );
165 btecHeader.
Size = PARSEDWORD_BIG( btecHeader.
Size );
166 }
167
171
172 return compressedSize;
173}
#define TVERSION(VER_MAJOR, VER_MINOR)
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
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.