13 #include once "crt.bi"
15 declare function fb_hEncode
lib "fbgfx" alias "fb_hEncode" _
17 byval as const ubyte ptr, _
20 byval as integer ptr _
30 dim shared as Entry entries(0
to ...) = _
32 (
"FONT_8" ,
"fnt08x08.fnt" ), _
33 (
"FONT_14",
"fnt08x14.fnt" ), _
34 (
"FONT_16",
"fnt08x16.fnt" ), _
35 (
"PAL_2" ,
"pal002.pal" ), _
36 (
"PAL_16" ,
"pal016.pal" ), _
37 (
"PAL_64" ,
"pal064.pal" ), _
38 (
"PAL_256",
"pal256.pal" ) _
42 for i
as integer = 0
to ubound( entries )
44 dim as string filename =
exepath( ) +
"/" + .file
46 dim as integer f =
freefile()
47 open filename
for binary access read as #f
50 .p =
allocate( .size )
51 get #f, , *.p, .size, .size
54 print "loading: '" + filename +
"' (" & .size &
" bytes)"
61 dim as integer rawsize = 0
62 for i
as integer = 0
to ubound( entries )
63 rawsize += entries(i).size
67 dim as ubyte ptr raw =
allocate( rawsize )
69 dim as integer offset = 0
70 for i
as integer = 0
to ubound( entries )
72 memcpy( raw + offset, .p, .size )
81 dim as integer f =
freefile( )
82 open exepath( ) +
"/data.dat" for binary access write as #f
83 put #f, , *raw, rawsize
89 dim as integer compressedsize = rawsize
90 dim as ubyte ptr compressed =
allocate( rawsize )
91 fb_hEncode( raw, rawsize, compressed, @compressedsize )
93 print rawsize, compressedsize
96 ccode += !
"/* Automatically created by makedata, to be used by data.c */\n"
97 ccode += !
"/* Compressed internal font/palette data for FB graphics */\n"
102 dim as integer offset = 0
103 for i
as integer = 0
to ubound( entries )
105 ccode +=
"#define DATA_" + .
name +
" 0x" +
hex( offset, 8 ) + !
"\n"
112 ccode += !
"\nstatic const unsigned char compressed_data[] = {\n"
114 for i
as integer = 0
to compressedsize - 1
115 if( (i
mod 16) = 0 )
then
119 ccode +=
"0x" +
hex( compressed[i], 2 )
121 if( i < (compressedsize - 1) )
then
124 if( ((i + 1)
mod 16) = 0 )
then
136 ccode += !
"#define DATA_SIZE " & rawsize & !
"\n"
140 dim as integer f =
freefile( )
141 open exepath( ) +
"/../gfxdata_inline.h" for output as #f
146 print rawsize &
" bytes in, " & compressedsize &
" bytes out " & _
147 "(" & (rawsize / compressedsize) &
":1 ratio)"