5 |
|
* Copy data into a holodeck file |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "platform.h" |
9 |
+ |
#include "rterror.h" |
10 |
|
#include "holo.h" |
11 |
|
#include "view.h" |
12 |
|
|
22 |
|
|
23 |
|
char *progname; /* global argv[0] */ |
24 |
|
|
25 |
+ |
struct phead { |
26 |
+ |
VIEW vw; |
27 |
+ |
double expos; |
28 |
+ |
short gotview; |
29 |
+ |
short badfmt; |
30 |
+ |
short altprims; |
31 |
+ |
}; |
32 |
+ |
static int openholo(char *fname, int append); |
33 |
+ |
static void addray(FVECT ro, FVECT rd, double d, COLR cv); |
34 |
+ |
static int holheadline(char *s, int *hf); |
35 |
+ |
static int bpcmp(const void *b1p, const void *b2p); |
36 |
+ |
static int addclump(HOLO *hp, int *bq, int nb); |
37 |
+ |
static void addholo(char *hdf); |
38 |
+ |
static int picheadline(char *s, struct phead *ph); |
39 |
+ |
static void addpicz(char *pcf, char *zbf); |
40 |
|
|
41 |
< |
main(argc, argv) |
42 |
< |
int argc; |
43 |
< |
char *argv[]; |
41 |
> |
|
42 |
> |
|
43 |
> |
int |
44 |
> |
main( |
45 |
> |
int argc, |
46 |
> |
char *argv[] |
47 |
> |
) |
48 |
|
{ |
49 |
|
int i; |
50 |
|
|
96 |
|
#define H_OBSF 04 |
97 |
|
|
98 |
|
int |
99 |
< |
holheadline(s, hf) /* check holodeck header line */ |
100 |
< |
register char *s; |
101 |
< |
int *hf; |
99 |
> |
holheadline( /* check holodeck header line */ |
100 |
> |
register char *s, |
101 |
> |
int *hf |
102 |
> |
) |
103 |
|
{ |
104 |
|
char fmt[32]; |
105 |
|
|
125 |
|
} |
126 |
|
|
127 |
|
int |
128 |
< |
openholo(fname, append) /* open existing holodeck file for i/o */ |
129 |
< |
char *fname; |
130 |
< |
int append; |
128 |
> |
openholo( /* open existing holodeck file for i/o */ |
129 |
> |
char *fname, |
130 |
> |
int append |
131 |
> |
) |
132 |
|
{ |
133 |
|
FILE *fp; |
134 |
|
int fd; |
151 |
|
nextloc = ftell(fp); /* get stdio position */ |
152 |
|
fclose(fp); /* done with stdio */ |
153 |
|
for (n = 0; nextloc > 0L; n++) { /* initialize each section */ |
154 |
< |
lseek(fd, (off_t)nextloc, 0); |
154 |
> |
lseek(fd, (off_t)nextloc, SEEK_SET); |
155 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
156 |
|
hdinit(fd, NULL)->priv = hflags&H_OBST ? &obstr : |
157 |
|
hflags&H_OBSF ? &unobstr : (char *)NULL; |
164 |
|
#undef H_OBSF |
165 |
|
|
166 |
|
|
167 |
< |
addray(ro, rd, d, cv) /* add a ray to our output holodeck */ |
168 |
< |
FVECT ro, rd; |
169 |
< |
double d; |
170 |
< |
COLR cv; |
167 |
> |
void |
168 |
> |
addray( /* add a ray to our output holodeck */ |
169 |
> |
FVECT ro, |
170 |
> |
FVECT rd, |
171 |
> |
double d, |
172 |
> |
COLR cv |
173 |
> |
) |
174 |
|
{ |
175 |
|
int sn, bi, n; |
176 |
|
register HOLO *hp; |
217 |
|
static BEAMI *beamdir; |
218 |
|
|
219 |
|
static int |
220 |
< |
bpcmp(b1p, b2p) /* compare beam positions on disk */ |
221 |
< |
int *b1p, *b2p; |
220 |
> |
bpcmp( /* compare beam positions on disk */ |
221 |
> |
const void *b1p, |
222 |
> |
const void *b2p |
223 |
> |
) |
224 |
|
{ |
225 |
< |
register off_t pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; |
225 |
> |
register off_t pdif = beamdir[*(int*)b1p].fo - beamdir[*(int*)b2p].fo; |
226 |
|
|
227 |
|
if (pdif > 0L) return(1); |
228 |
|
if (pdif < 0L) return(-1); |
230 |
|
} |
231 |
|
|
232 |
|
static int |
233 |
< |
addclump(hp, bq, nb) /* transfer the given clump and free */ |
234 |
< |
HOLO *hp; |
235 |
< |
int *bq, nb; |
233 |
> |
addclump( /* transfer the given clump and free */ |
234 |
> |
HOLO *hp, |
235 |
> |
int *bq, |
236 |
> |
int nb |
237 |
> |
) |
238 |
|
{ |
239 |
|
GCOORD gc[2]; |
240 |
|
FVECT ro, rd; |
264 |
|
return(0); |
265 |
|
} |
266 |
|
|
267 |
< |
addholo(hdf) /* add a holodeck file */ |
268 |
< |
char *hdf; |
267 |
> |
|
268 |
> |
void |
269 |
> |
addholo( /* add a holodeck file */ |
270 |
> |
char *hdf |
271 |
> |
) |
272 |
|
{ |
273 |
|
int fd; |
274 |
|
/* open the holodeck for reading */ |
284 |
|
} |
285 |
|
|
286 |
|
|
254 |
– |
struct phead { |
255 |
– |
VIEW vw; |
256 |
– |
double expos; |
257 |
– |
short gotview; |
258 |
– |
short badfmt; |
259 |
– |
short altprims; |
260 |
– |
}; |
287 |
|
|
262 |
– |
|
288 |
|
int |
289 |
< |
picheadline(s, ph) /* process picture header line */ |
290 |
< |
char *s; |
291 |
< |
struct phead *ph; |
289 |
> |
picheadline( /* process picture header line */ |
290 |
> |
char *s, |
291 |
> |
struct phead *ph |
292 |
> |
) |
293 |
|
{ |
294 |
|
char fmt[32]; |
295 |
|
|
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
< |
addpicz(pcf, zbf) /* add a picture + depth-buffer */ |
317 |
< |
char *pcf, *zbf; |
316 |
> |
void |
317 |
> |
addpicz( /* add a picture + depth-buffer */ |
318 |
> |
char *pcf, |
319 |
> |
char *zbf |
320 |
> |
) |
321 |
|
{ |
322 |
|
FILE *pfp; |
323 |
|
int zfd; |
422 |
|
|
423 |
|
|
424 |
|
void |
425 |
< |
eputs(s) /* put error message to stderr */ |
426 |
< |
register char *s; |
425 |
> |
eputs( /* put error message to stderr */ |
426 |
> |
register char *s |
427 |
> |
) |
428 |
|
{ |
429 |
|
static int midline = 0; |
430 |
|
|
443 |
|
|
444 |
|
|
445 |
|
void |
446 |
< |
quit(code) /* exit the program gracefully */ |
447 |
< |
int code; |
446 |
> |
quit( /* exit the program gracefully */ |
447 |
> |
int code |
448 |
> |
) |
449 |
|
{ |
450 |
|
hdsync(NULL, 1); /* write out any buffered data */ |
451 |
|
exit(code); |