Wow I haven't updated this in a long time.

This commit is contained in:
Marisa the Magician 2019-11-19 17:28:33 +01:00
commit 55010c8b48
15 changed files with 3980 additions and 23 deletions

View file

@ -149,7 +149,7 @@ int32_t readimport( void )
{
readindex();
readindex();
if ( head->pkgver >= 60 ) fpos += 4;
if ( head->pkgver >= 55 ) fpos += 4;
else readindex();
return readindex();
}
@ -170,7 +170,7 @@ void readimport2( int32_t *cpkg, int32_t *cname, int32_t *pkg, int32_t *name )
{
*cpkg = readindex();
*cname = readindex();
if ( head->pkgver >= 60 ) *pkg = readdword();
if ( head->pkgver >= 55 ) *pkg = readdword();
else *pkg = readindex();
*name = readindex();
}
@ -190,7 +190,7 @@ void readexport( int32_t *class, int32_t *ofs, int32_t *siz, int32_t *name )
{
*class = readindex();
readindex();
if ( head->pkgver >= 60 ) fpos += 4;
if ( head->pkgver >= 55 ) fpos += 4;
*name = readindex();
fpos += 4;
*siz = readindex();
@ -213,7 +213,7 @@ void readexport2( int32_t *class, int32_t *super, int32_t *pkg, int32_t *name,
{
*class = readindex();
*super = readindex();
if ( head->pkgver >= 60 ) *pkg = readdword();
if ( head->pkgver >= 55 ) *pkg = readdword();
else *pkg = readindex();
*name = readindex();
*flags = readdword();
@ -281,7 +281,7 @@ typedef struct
typedef struct
{
uint8_t texcount;
uint32_t texcount;
ufonttex_t *tex;
} ufonthdr_t;
@ -296,12 +296,14 @@ void savefont( int32_t namelen, char *name )
}
ufonthdr_t fhead;
memset(&fhead,0,sizeof(ufonthdr_t));
fhead.texcount = readbyte();
fhead.texcount = readindex();
fhead.tex = calloc(fhead.texcount,sizeof(ufonttex_t));
uint32_t tchars = 0;
for ( int i=0; i<fhead.texcount; i++ )
{
fhead.tex[i].texture = readindex();
fhead.tex[i].charcount = readindex();
tchars += fhead.tex[i].charcount;
fhead.tex[i].chars = calloc(fhead.tex[i].charcount,
sizeof(ufontchar_t));
for ( int j=0; j<fhead.tex[i].charcount; j++ )
@ -315,14 +317,13 @@ void savefont( int32_t namelen, char *name )
// save to text
snprintf(fname,256,"%.*s.txt",namelen,name);
f = fopen(fname,"w");
printf(" Dumping Font to %s in UTPT format\n",fname);
fprintf(f,"Character: TextureName (X,Y)-(Width,Height)\n"
"-------------------------------------------\n");
printf(" Dumping Font to %s\n",fname);
int cc = 0;
for ( int i=0; i<fhead.texcount; i++ )
for ( int j=0; j<fhead.tex[i].charcount; j++ )
{
fprintf(f,"0x%02x: ",cc);
if ( tchars > 256 ) fprintf(f,"0x%04x: ",cc);
else fprintf(f,"0x%02x: ",cc);
construct_fullname(f,fhead.tex[i].texture);
fprintf(f," (%d,%d)-(%d,%d)\n",fhead.tex[i].chars[j].x,
fhead.tex[i].chars[j].y,fhead.tex[i].chars[j].w,
@ -413,8 +414,10 @@ int main( int argc, char **argv )
// begin reading data
size_t prev = fpos;
fpos = ofs;
if ( head->pkgver < 40 ) fpos += 8;
if ( head->pkgver < 60 ) fpos += 16;
if ( head->pkgver < 45 ) fpos += 4;
if ( head->pkgver < 55 ) fpos += 16;
if ( head->pkgver <= 44 ) fpos -= 6; // ???
if ( head->pkgver <= 35 ) fpos += 8; // ???
int32_t prop = readindex();
if ( (uint32_t)prop >= head->nnames )
{
@ -427,6 +430,8 @@ retry:
if ( strncasecmp(pname,"none",l) )
{
uint8_t info = readbyte();
int array = info&0x80;
int type = info&0xf;
int psiz = (info>>4)&0x7;
switch ( psiz )
{
@ -455,6 +460,10 @@ retry:
psiz = readdword();
break;
}
if ( array && (type != 3) )
readindex();
if ( type == 10 )
readindex(); // skip struct name
fpos += psiz;
printf(" Skipping property %.*s\n",l,pname);
prop = readindex();