2
Copyright (C) 1994-1995 Apogee Software, Ltd.
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
See the GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
41
#define NUMSINANGLES FINEANGLES+FINEANGLEQUAD+1
43
fixed pangle[PANGLES];
44
long sintable[NUMSINANGLES];
45
short tantable[FINEANGLES];
46
byte gammatable[GAMMAENTRIES];
56
= For abnormal program terminations
61
void Error (char *error, ...)
65
va_start (argptr,error);
66
vprintf (error,argptr);
73
int SafeOpenWrite (char *_filename)
76
char filename[MAX_PATH];
77
strncpy(filename, _filename, sizeof (filename));
78
filename[sizeof (filename) - 1] = '\0';
79
FixFilePath(filename);
81
handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC
82
, S_IREAD | S_IWRITE);
85
Error ("Error opening %s: %s",filename,strerror(errno));
91
void SafeWrite (int handle, void *buffer, long count)
97
iocount = count > 0x8000 ? 0x8000 : count;
98
if (write (handle,buffer,iocount) != iocount)
99
Error ("File write failure");
100
buffer = (void *)( (byte *)buffer + iocount );
108
void CalcPixelAngles ( void )
115
const double radtoint = (double)FINEANGLES/2/PI;
118
for (i=0;i<PANGLES;i++)
120
// start 1/2 pixel over, so viewangle bisects two middle pixels
121
tang = ((((double)i*160.0)+80.0)/(FPFOCALWIDTH*(double)PANGLES));
123
intang = ((long)(angle*radtoint));
130
void BuildSinTable (void)
133
double angle,anglestep;
138
anglestep = (double)(PI/2/FINEANGLEQUAD);
139
for (i=0;i<=FINEANGLEQUAD;i++)
142
value=(fixed)((double)GLOBAL1*sinangle);
144
sintable[i+FINEANGLES] =
145
sintable[FINEANGLES/2-i] = value;
146
sintable[FINEANGLES-i] = -value;
147
sintable[FINEANGLES/2+i] = -value;
152
void BuildTanTable (void)
155
double angle,anglestep;
160
anglestep = (double)(PI*2/FINEANGLES);
161
for (i=0;i<FINEANGLES;i++)
164
value=(fixed)((double)GLOBAL1*tanangle);
165
tantable[i] =(short) (value>>1);
170
void BuildGammaTable (void)
176
for (l=0 ; l<NUMGAMMALEVELS ; l++,gGamma+=32)
178
double nGamma = (double)256 / gGamma;
179
double nScale = (double)63 / pow(63, nGamma);
181
for ( i = 0; i < 64; i++ )
183
inf = pow(i, nGamma) * nScale;
200
printf("LOOKUPS -- Apogee Software (c) 1994\n");
201
printf("\n USAGE: lookups <name.dat>\n");
204
handle=SafeOpenWrite (_argv[1]);
210
SafeWrite(handle,&size,sizeof(int));
211
SafeWrite(handle,&pangle[0],sizeof(fixed)*size);
213
SafeWrite(handle,&size,sizeof(int));
214
SafeWrite(handle,&sintable[0],sizeof(fixed)*size);
216
SafeWrite(handle,&size,sizeof(int));
217
SafeWrite(handle,&tantable[0],sizeof(short)*size);
219
SafeWrite(handle,&size,sizeof(int));
220
SafeWrite(handle,&gammatable[0],sizeof(byte)*size);