| 5 |
|
* Program to convert meta-files to Targa 8-bit color-mapped format |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
+ |
#include "copyright.h" |
| 9 |
|
|
| 10 |
< |
#define MAXALLOC 5000 |
| 10 |
< |
|
| 11 |
< |
#define DXSIZE 400 /* default x resolution */ |
| 12 |
< |
|
| 13 |
< |
#define DYSIZE 400 /* default y resolution */ |
| 14 |
< |
|
| 15 |
< |
#define XCOM "pexpand +vOCImsp -DP %s | psort +y" |
| 16 |
< |
|
| 17 |
< |
|
| 18 |
< |
|
| 19 |
< |
|
| 10 |
> |
#include "rtprocess.h" |
| 11 |
|
#include "meta.h" |
| 21 |
– |
|
| 12 |
|
#include "plot.h" |
| 23 |
– |
|
| 13 |
|
#include "rast.h" |
| 25 |
– |
|
| 14 |
|
#include "targa.h" |
| 15 |
|
|
| 16 |
+ |
#define MAXALLOC 100000 |
| 17 |
+ |
#define DXSIZE 400 /* default x resolution */ |
| 18 |
+ |
#define DYSIZE 400 /* default y resolution */ |
| 19 |
+ |
#define XCOM "pexpand +vOCImsp -DP %s | psort +y" |
| 20 |
|
|
| 21 |
|
|
| 30 |
– |
|
| 22 |
|
char *progname; |
| 23 |
|
|
| 24 |
|
SCANBLOCK outblock; |
| 25 |
|
|
| 26 |
< |
int dxsize = DXSIZE, dysize = DYSIZE; |
| 26 |
> |
int dxsiz = DXSIZE, dysiz = DYSIZE; |
| 27 |
|
|
| 28 |
|
int maxalloc = MAXALLOC; |
| 29 |
|
|
| 39 |
|
static short condonly = FALSE, |
| 40 |
|
conditioned = FALSE; |
| 41 |
|
|
| 42 |
+ |
static int putthead(struct hdStruct *hp, char *ip, FILE *fp); |
| 43 |
+ |
|
| 44 |
+ |
|
| 45 |
+ |
|
| 46 |
|
char * |
| 47 |
< |
findtack(s) /* find place to tack on suffix */ |
| 53 |
< |
register char *s; |
| 47 |
> |
findtack(char *s) /* find place to tack on suffix */ |
| 48 |
|
{ |
| 49 |
|
while (*s && *s != '.') |
| 50 |
|
s++; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
< |
main(argc, argv) |
| 56 |
< |
|
| 57 |
< |
int argc; |
| 58 |
< |
char **argv; |
| 59 |
< |
|
| 55 |
> |
int |
| 56 |
> |
main( |
| 57 |
> |
int argc, |
| 58 |
> |
char **argv |
| 59 |
> |
) |
| 60 |
|
{ |
| 61 |
|
FILE *fp; |
| 68 |
– |
FILE *popen(); |
| 62 |
|
char comargs[200], command[300]; |
| 63 |
|
|
| 64 |
|
fout = stdout; |
| 81 |
|
argc--; |
| 82 |
|
break; |
| 83 |
|
case 'x': |
| 84 |
< |
dxsize = atoi(*++argv); |
| 84 |
> |
dxsiz = atoi(*++argv); |
| 85 |
|
argc--; |
| 86 |
|
break; |
| 87 |
|
case 'y': |
| 88 |
< |
dysize = atoi(*++argv); |
| 88 |
> |
dysiz = atoi(*++argv); |
| 89 |
|
argc--; |
| 90 |
|
break; |
| 91 |
|
case 'o': |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
return(0); |
| 139 |
< |
} |
| 139 |
> |
} |
| 140 |
|
|
| 141 |
|
|
| 142 |
< |
|
| 143 |
< |
|
| 151 |
< |
|
| 152 |
< |
|
| 153 |
< |
thispage() /* rewind current file */ |
| 142 |
> |
void |
| 143 |
> |
thispage(void) /* rewind current file */ |
| 144 |
|
{ |
| 145 |
|
if (lineno) |
| 146 |
|
error(USER, "cannot restart page in thispage"); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
< |
|
| 151 |
< |
initfile() /* initialize this file */ |
| 150 |
> |
void |
| 151 |
> |
initfile(void) /* initialize this file */ |
| 152 |
|
{ |
| 153 |
< |
static int filenum = 0; |
| 164 |
< |
/* |
| 165 |
< |
static unsigned char cmap[24] = {255,255,255, 255,152,0, 0,188,0, 0,0,255, |
| 166 |
< |
179,179,0, 255,0,255, 0,200,200, 0,0,0}; |
| 167 |
< |
*/ |
| 168 |
< |
static unsigned char cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0, |
| 153 |
> |
static const unsigned char cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0, |
| 154 |
|
0,200,200, 255,0,255, 179,179,0, 255,255,255}; |
| 155 |
+ |
static int filenum = 0; |
| 156 |
|
struct hdStruct thead; |
| 157 |
< |
register int i; |
| 157 |
> |
int i; |
| 158 |
|
|
| 159 |
|
if (outtack != NULL) { |
| 160 |
|
sprintf(outtack, "%d.tga", ++filenum); |
| 169 |
|
thead.CMapBits = 24; |
| 170 |
|
thead.XOffset = 0; |
| 171 |
|
thead.YOffset = 0; |
| 172 |
< |
thead.x = dxsize; |
| 173 |
< |
thead.y = dysize; |
| 172 |
> |
thead.x = dxsiz; |
| 173 |
> |
thead.y = dysiz; |
| 174 |
|
thead.dataBits = 8; |
| 175 |
|
thead.imType = 0; |
| 176 |
|
putthead(&thead, NULL, fout); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
|
| 184 |
< |
|
| 185 |
< |
|
| 200 |
< |
nextpage() /* advance to next page */ |
| 201 |
< |
|
| 184 |
> |
void |
| 185 |
> |
nextpage(void) /* advance to next page */ |
| 186 |
|
{ |
| 187 |
|
|
| 188 |
|
if (lineno == 0) |
| 189 |
|
return; |
| 190 |
|
if (fout != NULL) { |
| 191 |
< |
while (lineno < dysize) { |
| 191 |
> |
while (lineno < dysiz) { |
| 192 |
|
nextblock(); |
| 193 |
|
outputblock(); |
| 194 |
|
} |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
|
| 219 |
– |
|
| 203 |
|
#define MINRUN 4 |
| 204 |
|
|
| 205 |
< |
|
| 206 |
< |
printblock() /* output scanline block to file */ |
| 224 |
< |
|
| 205 |
> |
void |
| 206 |
> |
printblock(void) /* output scanline block to file */ |
| 207 |
|
{ |
| 208 |
|
int i, c2; |
| 209 |
< |
register unsigned char *scanline; |
| 210 |
< |
register int j, beg, cnt; |
| 209 |
> |
unsigned char *scanline; |
| 210 |
> |
int j, beg, cnt = 0; |
| 211 |
|
|
| 212 |
|
if (lineno == 0) |
| 213 |
|
initfile(); |
| 214 |
< |
for (i = outblock.ybot; i <= outblock.ytop && i < dysize; i++) { |
| 214 |
> |
for (i = outblock.ybot; i <= outblock.ytop && i < dysiz; i++) { |
| 215 |
|
scanline = outblock.cols[i-outblock.ybot]; |
| 216 |
|
for (j = outblock.xleft; j <= outblock.xright; j += cnt) { |
| 217 |
|
for (beg = j; beg <= outblock.xright; beg += cnt) { |
| 239 |
|
} |
| 240 |
|
|
| 241 |
|
|
| 242 |
< |
putint2(i, fp) /* put a 2-byte positive integer */ |
| 243 |
< |
register int i; |
| 244 |
< |
register FILE *fp; |
| 242 |
> |
void |
| 243 |
> |
putint2( /* put a 2-byte positive integer */ |
| 244 |
> |
int i, |
| 245 |
> |
FILE *fp |
| 246 |
> |
) |
| 247 |
|
{ |
| 248 |
|
putc(i&0xff, fp); |
| 249 |
|
putc(i>>8&0xff, fp); |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
|
| 253 |
< |
putthead(hp, ip, fp) /* write header to output */ |
| 254 |
< |
struct hdStruct *hp; |
| 255 |
< |
char *ip; |
| 256 |
< |
register FILE *fp; |
| 253 |
> |
int |
| 254 |
> |
putthead( /* write header to output */ |
| 255 |
> |
struct hdStruct *hp, |
| 256 |
> |
char *ip, |
| 257 |
> |
FILE *fp |
| 258 |
> |
) |
| 259 |
|
{ |
| 260 |
|
if (ip != NULL) |
| 261 |
|
putc(strlen(ip), fp); |