-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn+ssh://jay/var/svn/wolf/trunk@63 32837ae5-38f0-4cfd-8401-3ff76d8497c4
- Loading branch information
paul
committed
Aug 3, 2007
1 parent
07599d1
commit 3a5fb71
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,70 @@ | |||
#include "wl_def.h" | |||
|
|||
#include "huffman.h" | |||
|
|||
void CAL_HuffExpand(const byte *source, byte *dest, long length, | |||
const huffnode *htable) | |||
{ | |||
const huffnode *headptr; | |||
const huffnode *nodeon; | |||
byte mask = 0x01; | |||
word path; | |||
byte *endoff = dest + length; | |||
|
|||
nodeon = headptr = htable + 254; | |||
|
|||
do { | |||
if (*source & mask) | |||
path = 1; | |||
else | |||
path = 0; | |||
mask <<= 1; | |||
if (mask == 0x00) { | |||
mask = 0x01; | |||
source++; | |||
} | |||
if (path ? nodeon->flag1 : nodeon->flag0) { | |||
nodeon = (htable + nodeon->val[path]); | |||
} else { | |||
*dest = nodeon->val[path]; | |||
dest++; | |||
nodeon = headptr; | |||
} | |||
} while (dest != endoff); | |||
} | |||
|
|||
int main() | |||
{ | |||
byte *source; | |||
byte *p; | |||
int start; | |||
int end; | |||
int i; | |||
int size; | |||
int compressed; | |||
FILE *f = fopen("vgagraph.wl6", "rb"); | |||
if (!f) | |||
return 1; | |||
|
|||
start = grstarts[STRUCTPIC]; | |||
compressed = grstarts[STRUCTPIC + 1] - start; | |||
source = malloc(compressed); | |||
fread(source, 1, compressed, f); | |||
fclose(f); | |||
|
|||
size = source[0]|(source[1]<<8)|(source[2]<<16)|(source[3]<<24); | |||
source += 4; | |||
|
|||
p = malloc(size); | |||
CAL_HuffExpand(source, p, size, grhuffman); | |||
|
|||
printf("#include \"wl_def.h\"\n"); | |||
printf("const pictabletype pictable[%d] = {\n", size / 4); | |||
for (i = 0; i < size / 4; i++) | |||
{ | |||
printf("{%d,%d},\n", p[0] | (p[1] << 8), p[2] | (p[3] << 8)); | |||
p += 4; | |||
} | |||
printf("};\n"); | |||
return 0; | |||
} |