Windows WIP.

This commit is contained in:
Steven Fuller 2008-05-09 02:11:36 -07:00 committed by Patryk Obara
parent c51b91cfe7
commit e9788e390d
14 changed files with 476 additions and 282 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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"