diff options
| author | Steven Fuller <relnev@icculus.org> | 2008-05-09 02:11:36 -0700 |
|---|---|---|
| committer | Patryk Obara <dreamer.tan@gmail.com> | 2019-08-20 02:22:37 +0200 |
| commit | e9788e390d5fe0e326a39762a04c628111bc0e84 (patch) | |
| tree | 65175f0dfe53aa821efad1bd47cb70df2416458a /src/win95 | |
| parent | c51b91cfe79a1ffd5da3f6a6ce202982cdfcdf85 (diff) | |
Windows WIP.
Diffstat (limited to 'src/win95')
| -rw-r--r-- | src/win95/awtexld.cpp | 2 | ||||
| -rw-r--r-- | src/win95/huffman.cpp | 33 | ||||
| -rw-r--r-- | src/win95/huffman.hpp | 4 |
3 files changed, 18 insertions, 21 deletions
diff --git a/src/win95/awtexld.cpp b/src/win95/awtexld.cpp index 18ae500..03ef1db 100644 --- a/src/win95/awtexld.cpp +++ b/src/win95/awtexld.cpp @@ -539,7 +539,7 @@ AwTl::SurfUnion AwBackupTexture::CreateTexture(AwTl::CreateTextureParms const & y = m_nHeight-1; } - for (int i, rowcount = m_nHeight; rowcount; --rowcount, i++) + for (int i = 0, rowcount = m_nHeight; rowcount; --rowcount, i++) { PtrUnion src_rowP = GetRowPtr(y); db_assert1(src_rowP.voidP); diff --git a/src/win95/huffman.cpp b/src/win95/huffman.cpp index f641071..4347959 100644 --- a/src/win95/huffman.cpp +++ b/src/win95/huffman.cpp @@ -61,11 +61,8 @@ static HuffEncode EncodingTable[257]; /* KJL 17:16:03 17/09/98 - Compression */ static void PerformSymbolCensus(unsigned char *sourcePtr, int length); -#ifdef __WATCOMC__ static int HuffItemsSortSub(const void *cmp1, const void *cmp2); -#else static int __cdecl HuffItemsSortSub(const void *cmp1, const void *cmp2); -#endif static void SortCensusData(void); static void BuildHuffmanTree(void); static void MakeHuffTreeFromHuffItems(HuffNode *base, HuffItem *source, int count); @@ -125,11 +122,7 @@ static void PerformSymbolCensus(unsigned char *sourcePtr, int length) while (--length); } -#ifdef __WATCOMC__ -static int HuffItemsSortSub(const void *cmp1, const void *cmp2) -#else static int __cdecl HuffItemsSortSub(const void *cmp1, const void *cmp2) -#endif { if (((HuffItem *)cmp1)->Count > ((HuffItem *)cmp2)->Count) return 1; @@ -321,6 +314,7 @@ static int HuffEncodeBytes(int *dest, unsigned char *source, int count, HuffEnco if (!count) return 0; + accum = 0; start = dest; sourcelim = sourceend = source + count; available = 32; @@ -387,7 +381,7 @@ lpstart: val = *source++; } } *dest++ = accum >> available; - return (dest - start) * 4; + return (int)((dest - start) * 4); } @@ -398,11 +392,11 @@ lpstart: val = *source++; /* KJL 17:16:24 17/09/98 - Decompression */ static int DecodeTable[1<<MAX_DEPTH]; -static void MakeHuffmanDecodeTable(int *depth, int depthmax, unsigned char *list); -static int HuffmanDecode(unsigned char *dest, int *source, int *table, int length); +static void MakeHuffmanDecodeTable(const int *depth, int depthmax, const unsigned char *list); +static int HuffmanDecode(unsigned char *dest, const int *source, const int *table, int length); -extern char *HuffmanDecompress(HuffmanPackage *inpackage) +extern char *HuffmanDecompress(const HuffmanPackage *inpackage) { unsigned char *uncompressedData = NULL; // Step 1: Make the decoding table @@ -418,12 +412,12 @@ extern char *HuffmanDecompress(HuffmanPackage *inpackage) return (char*)uncompressedData; } -static void MakeHuffmanDecodeTable(int *depth, int depthmax, unsigned char *list) +static void MakeHuffmanDecodeTable(const int *depth, int depthmax, const unsigned char *list) { int thisdepth, depthbit, repcount, repspace, lenbits, temp, count; int *outp; int o = 0; - unsigned char *p; + const unsigned char *p; int *outtbl = DecodeTable; lenbits = 0; @@ -431,7 +425,7 @@ static void MakeHuffmanDecodeTable(int *depth, int depthmax, unsigned char *list repspace = 1; thisdepth = 0; depthbit = 4; - p = (unsigned char *)list + 255; + p = list + 255; while (1) { do @@ -476,17 +470,18 @@ static void MakeHuffmanDecodeTable(int *depth, int depthmax, unsigned char *list #define EDXMASK ((((1 << (MAX_DEPTH + 1)) - 1) ^ 1) ^ -1) -static int HuffmanDecode(unsigned char *dest, int *source, int *table, int length) +static int HuffmanDecode(unsigned char *dest, const int *source, const int *table, int length) { unsigned char *start; int available, reserve, fill, wid; unsigned int bits=0, resbits; - unsigned char *p; + const unsigned char *p; start = dest; available = 0; reserve = 0; - wid = 0; + wid = 0; + resbits = 0; do { available += wid; @@ -512,11 +507,11 @@ static int HuffmanDecode(unsigned char *dest, int *source, int *table, int lengt { bits >>= wid; *dest++ = p[1]; -lpent: p = (unsigned char *)(((short *)table)+(bits & ~EDXMASK)); +lpent: p = (const unsigned char *)(((const short *)table)+(bits & ~EDXMASK)); } while ((available -= (wid = *p)) >= 0 && (dest-start)!=length); } while (available > -32 && (dest-start)!=length); - return dest - start; + return (int)(dest - start); } diff --git a/src/win95/huffman.hpp b/src/win95/huffman.hpp index 607ff8b..bf0bdf5 100644 --- a/src/win95/huffman.hpp +++ b/src/win95/huffman.hpp @@ -7,6 +7,7 @@ #endif #define MAX_DEPTH 11 + typedef struct { char Identifier[8]; @@ -16,11 +17,12 @@ typedef struct unsigned char ByteAssignment[256]; } HuffmanPackage; + /* KJL 17:16:03 17/09/98 - Compression */ extern HuffmanPackage *HuffmanCompression(unsigned char *sourcePtr, int length); /* KJL 16:53:53 19/09/98 - Decompression */ -extern char *HuffmanDecompress(HuffmanPackage *inpackage); +extern char *HuffmanDecompress(const HuffmanPackage *inpackage); #define COMPRESSED_RIF_IDENTIFIER "REBCRIF1" |
