18 |
|
#define int2 short |
19 |
|
#endif |
20 |
|
#ifndef int4 |
21 |
< |
#define int4 long |
21 |
> |
#define int4 int |
22 |
|
#endif |
23 |
|
|
24 |
|
#define DCINF (unsigned)((1L<<16)-1) /* special value for infinity */ |
45 |
|
typedef struct { |
46 |
|
short w; /* wall number */ |
47 |
|
short i[2]; /* index on wall grid */ |
48 |
< |
} BCOORD[2]; /* beam grid coordinates */ |
48 |
> |
} GCOORD; /* grid coordinates (two for beam) */ |
49 |
|
|
50 |
|
typedef struct { |
51 |
|
unsigned int4 nrd; /* number of beam rays bundled on disk */ |
57 |
|
unsigned long tick; /* clock tick for LRU replacement */ |
58 |
|
} BEAM; /* followed by nrm RAYVAL's */ |
59 |
|
|
60 |
< |
#define hdbray(bp) (RAYVAL *)((bp)+1) |
60 |
> |
#define hdbray(bp) ((RAYVAL *)((bp)+1)) |
61 |
|
#define hdbsiz(nr) (sizeof(BEAM)+(nr)*sizeof(RAYVAL)) |
62 |
|
|
63 |
|
typedef struct { |
73 |
|
int fd; /* file descriptor */ |
74 |
|
short dirty; /* beam index needs update to file */ |
75 |
|
double tlin; /* linear range for depth encoding */ |
76 |
< |
FVECT wn[3]; /* wall normals (derived) */ |
77 |
< |
double wo[6]; /* wall offsets (derived) */ |
78 |
< |
FVECT gv[3][2]; /* grid coordinate vectors (derived) */ |
76 |
> |
FVECT wg[3]; /* wall grid vectors (derived) */ |
77 |
> |
double wo[6]; /* wall grid offsets (derived) */ |
78 |
|
int wi[6]; /* wall super-indices (derived) */ |
79 |
|
char *priv; /* pointer to private client data */ |
80 |
|
BEAM **bl; /* beam pointers (memory cache) */ |
81 |
|
BEAMI bi[1]; /* beam index (extends struct) */ |
82 |
|
} HOLO; /* holodeck section */ |
83 |
|
|
84 |
+ |
typedef struct { |
85 |
+ |
HOLO *h; /* pointer to holodeck */ |
86 |
+ |
int b; /* beam index */ |
87 |
+ |
} HDBEAMI; /* holodeck beam index */ |
88 |
+ |
|
89 |
|
#define nbeams(hp) (2*((hp)->wi[5]-1)) |
90 |
|
#define biglob(hp) ((hp)->bi) |
91 |
|
#define blglob(hp) (*(hp)->bl) |
92 |
|
|
93 |
|
#define bnrays(hp,i) ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd) |
94 |
|
|
95 |
< |
#define hdflush(hp) (hdfreebeam(hp,0) && hdsync(hp)) |
95 |
> |
#define hdflush(hp) (hdfreebeam(hp,0) && hdsync(hp,0)) |
96 |
> |
#define hdclobber(hp) (hdkillbeam(hp,0) && hdsync(hp,0)) |
97 |
|
|
98 |
< |
extern HOLO *hdinit(); |
98 |
> |
extern HOLO *hdinit(), *hdalloc(); |
99 |
|
extern BEAM *hdgetbeam(); |
100 |
|
extern RAYVAL *hdnewrays(); |
101 |
< |
extern long hdmemuse(), hdfiluse(); |
101 |
> |
extern unsigned hdmemuse(); |
102 |
> |
extern long hdfiluse(), hdfilen(), hdallocfrag(); |
103 |
|
extern double hdray(), hdinter(); |
104 |
|
extern unsigned hdcode(); |
105 |
|
|
106 |
< |
extern int hdcachesize; /* target cache size (bytes) */ |
106 |
> |
extern unsigned hdcachesize; /* target cache size (bytes) */ |
107 |
|
extern unsigned long hdclock; /* holodeck system clock */ |
108 |
|
extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */ |
109 |
|
|
110 |
|
extern float hd_depthmap[]; /* depth conversion map */ |
111 |
|
|
112 |
+ |
extern int hdwg0[6]; /* wall grid 0 index */ |
113 |
+ |
extern int hdwg1[6]; /* wall grid 1 index */ |
114 |
+ |
|
115 |
|
#define hddepth(hp,dc) ( (dc) >= DCINF ? FHUGE : \ |
116 |
|
(hp)->tlin * ( (dc) >= DCLIN ? \ |
117 |
|
hd_depthmap[(dc)-DCLIN] : \ |
119 |
|
|
120 |
|
#define HOLOFMT "Holodeck" /* file format identifier */ |
121 |
|
#define HOLOVERS 0 /* file format version number */ |
122 |
< |
#define HOLOMAGIC (327+HOLOVERS) /* file magic number */ |
122 |
> |
#define HOLOMAGIC (323+sizeof(long)+8*HOLOVERS) /* file magic number */ |
123 |
|
|
124 |
|
/* |
125 |
|
* A holodeck file consists of an information header terminated by a |
126 |
|
* blank line, with "FORMAT=Holodeck" somewhere in it. |
127 |
|
* The first integer after the information header is the |
128 |
|
* above magic number, which includes the file format version number. |
129 |
< |
* The first longword after the magic number is the position |
130 |
< |
* of the SECOND holodeck section, or 0 if there is only one. |
129 |
> |
* The first longword after the magic number is a pointer to the pointer |
130 |
> |
* just before the SECOND holodeck section, or 0 if there is only one. |
131 |
|
* This longword is immediately followed by the first holodeck |
132 |
|
* section header and directory. |
133 |
|
* Similarly, every holodeck section in the file is preceeded by |