--- ray/src/meta/meta2tga.c 2004/02/04 18:49:24 1.6 +++ ray/src/meta/meta2tga.c 2020/05/13 00:30:13 1.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: meta2tga.c,v 1.6 2004/02/04 18:49:24 greg Exp $"; +static const char RCSid[] = "$Id: meta2tga.c,v 1.9 2020/05/13 00:30:13 greg Exp $"; #endif /* * Program to convert meta-files to Targa 8-bit color-mapped format @@ -13,7 +13,7 @@ static const char RCSid[] = "$Id: meta2tga.c,v 1.6 200 #include "rast.h" #include "targa.h" -#define MAXALLOC 30000 +#define MAXALLOC 100000 #define DXSIZE 400 /* default x resolution */ #define DYSIZE 400 /* default y resolution */ #define XCOM "pexpand +vOCImsp -DP %s | psort +y" @@ -23,7 +23,7 @@ char *progname; SCANBLOCK outblock; -int dxsize = DXSIZE, dysize = DYSIZE; +int dxsiz = DXSIZE, dysiz = DYSIZE; int maxalloc = MAXALLOC; @@ -44,8 +44,7 @@ static int putthead(struct hdStruct *hp, char *ip, F char * -findtack(s) /* find place to tack on suffix */ -register char *s; +findtack(char *s) /* find place to tack on suffix */ { while (*s && *s != '.') s++; @@ -58,7 +57,6 @@ main( int argc, char **argv ) - { FILE *fp; char comargs[200], command[300]; @@ -83,11 +81,11 @@ main( argc--; break; case 'x': - dxsize = atoi(*++argv); + dxsiz = atoi(*++argv); argc--; break; case 'y': - dysize = atoi(*++argv); + dysiz = atoi(*++argv); argc--; break; case 'o': @@ -138,10 +136,9 @@ main( } return(0); - } +} - void thispage(void) /* rewind current file */ { @@ -153,15 +150,11 @@ thispage(void) /* rewind current file */ void initfile(void) /* initialize this file */ { - static int filenum = 0; - /* - static unsigned char cmap[24] = {255,255,255, 255,152,0, 0,188,0, 0,0,255, - 179,179,0, 255,0,255, 0,200,200, 0,0,0}; - */ - static unsigned char cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0, + static const unsigned char cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0, 0,200,200, 255,0,255, 179,179,0, 255,255,255}; + static int filenum = 0; struct hdStruct thead; - register int i; + int i; if (outtack != NULL) { sprintf(outtack, "%d.tga", ++filenum); @@ -176,8 +169,8 @@ initfile(void) /* initialize this file */ thead.CMapBits = 24; thead.XOffset = 0; thead.YOffset = 0; - thead.x = dxsize; - thead.y = dysize; + thead.x = dxsiz; + thead.y = dysiz; thead.dataBits = 8; thead.imType = 0; putthead(&thead, NULL, fout); @@ -188,16 +181,14 @@ initfile(void) /* initialize this file */ } - void nextpage(void) /* advance to next page */ - { if (lineno == 0) return; if (fout != NULL) { - while (lineno < dysize) { + while (lineno < dysiz) { nextblock(); outputblock(); } @@ -209,20 +200,18 @@ nextpage(void) /* advance to next page */ } - #define MINRUN 4 -extern void +void printblock(void) /* output scanline block to file */ - { int i, c2; - register unsigned char *scanline; - register int j, beg, cnt = 0; + unsigned char *scanline; + int j, beg, cnt = 0; if (lineno == 0) initfile(); - for (i = outblock.ybot; i <= outblock.ytop && i < dysize; i++) { + for (i = outblock.ybot; i <= outblock.ytop && i < dysiz; i++) { scanline = outblock.cols[i-outblock.ybot]; for (j = outblock.xleft; j <= outblock.xright; j += cnt) { for (beg = j; beg <= outblock.xright; beg += cnt) { @@ -252,8 +241,8 @@ printblock(void) /* output scanline block to file */ void putint2( /* put a 2-byte positive integer */ - register int i, - register FILE *fp + int i, + FILE *fp ) { putc(i&0xff, fp); @@ -265,7 +254,7 @@ int putthead( /* write header to output */ struct hdStruct *hp, char *ip, - register FILE *fp + FILE *fp ) { if (ip != NULL)