Rev 8655 | Rev 9097 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8655 | Rev 8664 | ||
---|---|---|---|
1 | // WL_MAIN.C |
1 | // WL_MAIN.C |
2 | 2 | ||
3 | #ifdef _WIN32 |
3 | #ifdef _WIN32 |
4 | #include |
4 | #include |
5 | #else |
5 | #else |
6 | #include |
6 | #include |
7 | #endif |
7 | #endif |
8 | 8 | ||
9 | #include "wl_def.h" |
9 | #include "wl_def.h" |
10 | #pragma hdrstop |
10 | #pragma hdrstop |
11 | #include "wl_atmos.h" |
11 | #include "wl_atmos.h" |
12 | #include |
12 | #include |
13 | 13 | ||
14 | /* |
14 | /* |
15 | ============================================================================= |
15 | ============================================================================= |
16 | 16 | ||
17 | WOLFENSTEIN 3-D |
17 | WOLFENSTEIN 3-D |
18 | 18 | ||
19 | An Id Software production |
19 | An Id Software production |
20 | 20 | ||
21 | by John Carmack |
21 | by John Carmack |
22 | 22 | ||
23 | ============================================================================= |
23 | ============================================================================= |
24 | */ |
24 | */ |
25 | 25 | ||
26 | extern byte signon[]; |
26 | extern byte signon[]; |
27 | extern void kolibri_set_win_center(); |
27 | extern void kolibri_set_win_center(); |
- | 28 | extern char* dirname(char* path); |
|
- | 29 | extern void setcwd(char* path); |
|
28 | /* |
30 | /* |
29 | ============================================================================= |
31 | ============================================================================= |
30 | 32 | ||
31 | LOCAL CONSTANTS |
33 | LOCAL CONSTANTS |
32 | 34 | ||
33 | ============================================================================= |
35 | ============================================================================= |
34 | */ |
36 | */ |
35 | 37 | ||
36 | 38 | ||
37 | #define FOCALLENGTH (0x5700l) // in global coordinates |
39 | #define FOCALLENGTH (0x5700l) // in global coordinates |
38 | #define VIEWGLOBAL 0x10000 // globals visable flush to wall |
40 | #define VIEWGLOBAL 0x10000 // globals visable flush to wall |
39 | 41 | ||
40 | #define VIEWWIDTH 256 // size of view window |
42 | #define VIEWWIDTH 256 // size of view window |
41 | #define VIEWHEIGHT 144 |
43 | #define VIEWHEIGHT 144 |
42 | 44 | ||
43 | /* |
45 | /* |
44 | ============================================================================= |
46 | ============================================================================= |
45 | 47 | ||
46 | GLOBAL VARIABLES |
48 | GLOBAL VARIABLES |
47 | 49 | ||
48 | ============================================================================= |
50 | ============================================================================= |
49 | */ |
51 | */ |
50 | 52 | ||
51 | char str[80]; |
53 | char str[80]; |
52 | int dirangle[9] = {0,ANGLES/8,2*ANGLES/8,3*ANGLES/8,4*ANGLES/8, |
54 | int dirangle[9] = {0,ANGLES/8,2*ANGLES/8,3*ANGLES/8,4*ANGLES/8, |
53 | 5*ANGLES/8,6*ANGLES/8,7*ANGLES/8,ANGLES}; |
55 | 5*ANGLES/8,6*ANGLES/8,7*ANGLES/8,ANGLES}; |
54 | 56 | ||
55 | // |
57 | // |
56 | // proejection variables |
58 | // proejection variables |
57 | // |
59 | // |
58 | fixed focallength; |
60 | fixed focallength; |
59 | unsigned screenofs; |
61 | unsigned screenofs; |
60 | int viewscreenx, viewscreeny; |
62 | int viewscreenx, viewscreeny; |
61 | int viewwidth; |
63 | int viewwidth; |
62 | int viewheight; |
64 | int viewheight; |
63 | short centerx; |
65 | short centerx; |
64 | int shootdelta; // pixels away from centerx a target can be |
66 | int shootdelta; // pixels away from centerx a target can be |
65 | fixed scale; |
67 | fixed scale; |
66 | int32_t heightnumerator; |
68 | int32_t heightnumerator; |
67 | 69 | ||
68 | 70 | ||
69 | void Quit (const char *error,...); |
71 | void Quit (const char *error,...); |
70 | 72 | ||
71 | boolean startgame; |
73 | boolean startgame; |
72 | boolean loadedgame; |
74 | boolean loadedgame; |
73 | int mouseadjustment; |
75 | int mouseadjustment; |
74 | 76 | ||
75 | char configdir[256] = ""; |
77 | char configdir[256] = ""; |
76 | char configname[13] = "config."; |
78 | char configname[13] = "config."; |
77 | 79 | ||
78 | // |
80 | // |
79 | // Command line parameter variables |
81 | // Command line parameter variables |
80 | // |
82 | // |
81 | boolean param_debugmode = false; |
83 | boolean param_debugmode = false; |
82 | boolean param_nowait = false; |
84 | boolean param_nowait = false; |
83 | int param_difficulty = 1; // default is "normal" |
85 | int param_difficulty = 1; // default is "normal" |
84 | int param_tedlevel = -1; // default is not to start a level |
86 | int param_tedlevel = -1; // default is not to start a level |
85 | int param_joystickindex = 0; |
87 | int param_joystickindex = 0; |
86 | 88 | ||
87 | #if defined(_arch_dreamcast) |
89 | #if defined(_arch_dreamcast) |
88 | int param_joystickhat = 0; |
90 | int param_joystickhat = 0; |
89 | int param_samplerate = 11025; // higher samplerates result in "out of memory" |
91 | int param_samplerate = 11025; // higher samplerates result in "out of memory" |
90 | int param_audiobuffer = 4096 / (44100 / param_samplerate); |
92 | int param_audiobuffer = 4096 / (44100 / param_samplerate); |
91 | #elif defined(GP2X_940) |
93 | #elif defined(GP2X_940) |
92 | int param_joystickhat = -1; |
94 | int param_joystickhat = -1; |
93 | int param_samplerate = 11025; // higher samplerates result in "out of memory" |
95 | int param_samplerate = 11025; // higher samplerates result in "out of memory" |
94 | int param_audiobuffer = 128; |
96 | int param_audiobuffer = 128; |
95 | #else |
97 | #else |
96 | int param_joystickhat = -1; |
98 | int param_joystickhat = -1; |
97 | int param_samplerate = 44100; |
99 | int param_samplerate = 44100; |
98 | int param_audiobuffer = 2048 / (44100 / param_samplerate); |
100 | int param_audiobuffer = 2048 / (44100 / param_samplerate); |
99 | #endif |
101 | #endif |
100 | 102 | ||
101 | int param_mission = 0; |
103 | int param_mission = 0; |
102 | boolean param_goodtimes = false; |
104 | boolean param_goodtimes = false; |
103 | boolean param_ignorenumchunks = false; |
105 | boolean param_ignorenumchunks = false; |
104 | 106 | ||
105 | /* |
107 | /* |
106 | ============================================================================= |
108 | ============================================================================= |
107 | 109 | ||
108 | LOCAL VARIABLES |
110 | LOCAL VARIABLES |
109 | 111 | ||
110 | ============================================================================= |
112 | ============================================================================= |
111 | */ |
113 | */ |
112 | 114 | ||
113 | 115 | ||
114 | /* |
116 | /* |
115 | ==================== |
117 | ==================== |
116 | = |
118 | = |
117 | = ReadConfig |
119 | = ReadConfig |
118 | = |
120 | = |
119 | ==================== |
121 | ==================== |
120 | */ |
122 | */ |
121 | 123 | ||
122 | void ReadConfig(void) |
124 | void ReadConfig(void) |
123 | { |
125 | { |
124 | SDMode sd; |
126 | SDMode sd; |
125 | SMMode sm; |
127 | SMMode sm; |
126 | SDSMode sds; |
128 | SDSMode sds; |
127 | 129 | ||
128 | char configpath[300]; |
130 | char configpath[300]; |
129 | 131 | ||
130 | #ifdef _arch_dreamcast |
132 | #ifdef _arch_dreamcast |
131 | DC_LoadFromVMU(configname); |
133 | DC_LoadFromVMU(configname); |
132 | #endif |
134 | #endif |
133 | 135 | ||
134 | if(configdir[0]) |
136 | if(configdir[0]) |
135 | snprintf(configpath, sizeof(configpath), "%s/%s", configdir, configname); |
137 | snprintf(configpath, sizeof(configpath), "%s/%s", configdir, configname); |
136 | else |
138 | else |
137 | strcpy(configpath, configname); |
139 | strcpy(configpath, configname); |
138 | 140 | ||
139 | const int file = open(configpath, O_RDONLY | O_BINARY); |
141 | const int file = open(configpath, O_RDONLY | O_BINARY); |
140 | if (file != -1) |
142 | if (file != -1) |
141 | { |
143 | { |
142 | // |
144 | // |
143 | // valid config file |
145 | // valid config file |
144 | // |
146 | // |
145 | word tmp; |
147 | word tmp; |
146 | read(file,&tmp,sizeof(tmp)); |
148 | read(file,&tmp,sizeof(tmp)); |
147 | if(tmp!=0xfefa) |
149 | if(tmp!=0xfefa) |
148 | { |
150 | { |
149 | close(file); |
151 | close(file); |
150 | goto noconfig; |
152 | goto noconfig; |
151 | } |
153 | } |
152 | read(file,Scores,sizeof(HighScore) * MaxScores); |
154 | read(file,Scores,sizeof(HighScore) * MaxScores); |
153 | 155 | ||
154 | read(file,&sd,sizeof(sd)); |
156 | read(file,&sd,sizeof(sd)); |
155 | read(file,&sm,sizeof(sm)); |
157 | read(file,&sm,sizeof(sm)); |
156 | read(file,&sds,sizeof(sds)); |
158 | read(file,&sds,sizeof(sds)); |
157 | 159 | ||
158 | read(file,&mouseenabled,sizeof(mouseenabled)); |
160 | read(file,&mouseenabled,sizeof(mouseenabled)); |
159 | read(file,&joystickenabled,sizeof(joystickenabled)); |
161 | read(file,&joystickenabled,sizeof(joystickenabled)); |
160 | boolean dummyJoypadEnabled; |
162 | boolean dummyJoypadEnabled; |
161 | read(file,&dummyJoypadEnabled,sizeof(dummyJoypadEnabled)); |
163 | read(file,&dummyJoypadEnabled,sizeof(dummyJoypadEnabled)); |
162 | boolean dummyJoystickProgressive; |
164 | boolean dummyJoystickProgressive; |
163 | read(file,&dummyJoystickProgressive,sizeof(dummyJoystickProgressive)); |
165 | read(file,&dummyJoystickProgressive,sizeof(dummyJoystickProgressive)); |
164 | int dummyJoystickPort = 0; |
166 | int dummyJoystickPort = 0; |
165 | read(file,&dummyJoystickPort,sizeof(dummyJoystickPort)); |
167 | read(file,&dummyJoystickPort,sizeof(dummyJoystickPort)); |
166 | 168 | ||
167 | read(file,dirscan,sizeof(dirscan)); |
169 | read(file,dirscan,sizeof(dirscan)); |
168 | read(file,buttonscan,sizeof(buttonscan)); |
170 | read(file,buttonscan,sizeof(buttonscan)); |
169 | read(file,buttonmouse,sizeof(buttonmouse)); |
171 | read(file,buttonmouse,sizeof(buttonmouse)); |
170 | read(file,buttonjoy,sizeof(buttonjoy)); |
172 | read(file,buttonjoy,sizeof(buttonjoy)); |
171 | 173 | ||
172 | read(file,&viewsize,sizeof(viewsize)); |
174 | read(file,&viewsize,sizeof(viewsize)); |
173 | read(file,&mouseadjustment,sizeof(mouseadjustment)); |
175 | read(file,&mouseadjustment,sizeof(mouseadjustment)); |
174 | 176 | ||
175 | close(file); |
177 | close(file); |
176 | 178 | ||
177 | if ((sd == sdm_AdLib || sm == smm_AdLib) && !AdLibPresent |
179 | if ((sd == sdm_AdLib || sm == smm_AdLib) && !AdLibPresent |
178 | && !SoundBlasterPresent) |
180 | && !SoundBlasterPresent) |
179 | { |
181 | { |
180 | sd = sdm_PC; |
182 | sd = sdm_PC; |
181 | sm = smm_Off; |
183 | sm = smm_Off; |
182 | } |
184 | } |
183 | 185 | ||
184 | if ((sds == sds_SoundBlaster && !SoundBlasterPresent)) |
186 | if ((sds == sds_SoundBlaster && !SoundBlasterPresent)) |
185 | sds = sds_Off; |
187 | sds = sds_Off; |
186 | 188 | ||
187 | // make sure values are correct |
189 | // make sure values are correct |
188 | 190 | ||
189 | if(mouseenabled) mouseenabled=true; |
191 | if(mouseenabled) mouseenabled=true; |
190 | if(joystickenabled) joystickenabled=true; |
192 | if(joystickenabled) joystickenabled=true; |
191 | 193 | ||
192 | if (!MousePresent) |
194 | if (!MousePresent) |
193 | mouseenabled = false; |
195 | mouseenabled = false; |
194 | if (!IN_JoyPresent()) |
196 | if (!IN_JoyPresent()) |
195 | joystickenabled = false; |
197 | joystickenabled = false; |
196 | 198 | ||
197 | if(mouseadjustment<0) mouseadjustment=0; |
199 | if(mouseadjustment<0) mouseadjustment=0; |
198 | else if(mouseadjustment>9) mouseadjustment=9; |
200 | else if(mouseadjustment>9) mouseadjustment=9; |
199 | 201 | ||
200 | if(viewsize<4) viewsize=4; |
202 | if(viewsize<4) viewsize=4; |
201 | else if(viewsize>21) viewsize=21; |
203 | else if(viewsize>21) viewsize=21; |
202 | 204 | ||
203 | MainMenu[6].active=1; |
205 | MainMenu[6].active=1; |
204 | MainItems.curpos=0; |
206 | MainItems.curpos=0; |
205 | } |
207 | } |
206 | else |
208 | else |
207 | { |
209 | { |
208 | // |
210 | // |
209 | // no config file, so select by hardware |
211 | // no config file, so select by hardware |
210 | // |
212 | // |
211 | noconfig: |
213 | noconfig: |
212 | if (SoundBlasterPresent || AdLibPresent) |
214 | if (SoundBlasterPresent || AdLibPresent) |
213 | { |
215 | { |
214 | sd = sdm_AdLib; |
216 | sd = sdm_AdLib; |
215 | sm = smm_AdLib; |
217 | sm = smm_AdLib; |
216 | } |
218 | } |
217 | else |
219 | else |
218 | { |
220 | { |
219 | sd = sdm_PC; |
221 | sd = sdm_PC; |
220 | sm = smm_Off; |
222 | sm = smm_Off; |
221 | } |
223 | } |
222 | 224 | ||
223 | if (SoundBlasterPresent) |
225 | if (SoundBlasterPresent) |
224 | sds = sds_SoundBlaster; |
226 | sds = sds_SoundBlaster; |
225 | else |
227 | else |
226 | sds = sds_Off; |
228 | sds = sds_Off; |
227 | 229 | ||
228 | if (MousePresent) |
230 | if (MousePresent) |
229 | mouseenabled = true; |
231 | mouseenabled = true; |
230 | 232 | ||
231 | if (IN_JoyPresent()) |
233 | if (IN_JoyPresent()) |
232 | joystickenabled = true; |
234 | joystickenabled = true; |
233 | 235 | ||
234 | viewsize = 19; // start with a good size |
236 | viewsize = 19; // start with a good size |
235 | mouseadjustment=5; |
237 | mouseadjustment=5; |
236 | } |
238 | } |
237 | 239 | ||
238 | SD_SetMusicMode (sm); |
240 | SD_SetMusicMode (sm); |
239 | SD_SetSoundMode (sd); |
241 | SD_SetSoundMode (sd); |
240 | SD_SetDigiDevice (sds); |
242 | SD_SetDigiDevice (sds); |
241 | } |
243 | } |
242 | 244 | ||
243 | /* |
245 | /* |
244 | ==================== |
246 | ==================== |
245 | = |
247 | = |
246 | = WriteConfig |
248 | = WriteConfig |
247 | = |
249 | = |
248 | ==================== |
250 | ==================== |
249 | */ |
251 | */ |
250 | 252 | ||
251 | void WriteConfig(void) |
253 | void WriteConfig(void) |
252 | { |
254 | { |
253 | char configpath[300]; |
255 | char configpath[300]; |
254 | 256 | ||
255 | #ifdef _arch_dreamcast |
257 | #ifdef _arch_dreamcast |
256 | fs_unlink(configname); |
258 | fs_unlink(configname); |
257 | #endif |
259 | #endif |
258 | 260 | ||
259 | if(configdir[0]) |
261 | if(configdir[0]) |
260 | snprintf(configpath, sizeof(configpath), "%s/%s", configdir, configname); |
262 | snprintf(configpath, sizeof(configpath), "%s/%s", configdir, configname); |
261 | else |
263 | else |
262 | strcpy(configpath, configname); |
264 | strcpy(configpath, configname); |
263 | 265 | ||
264 | const int file = open(configpath, O_CREAT | O_WRONLY | O_BINARY, 0644); |
266 | const int file = open(configpath, O_CREAT | O_WRONLY | O_BINARY, 0644); |
265 | if (file != -1) |
267 | if (file != -1) |
266 | { |
268 | { |
267 | word tmp=0xfefa; |
269 | word tmp=0xfefa; |
268 | write(file,&tmp,sizeof(tmp)); |
270 | write(file,&tmp,sizeof(tmp)); |
269 | write(file,Scores,sizeof(HighScore) * MaxScores); |
271 | write(file,Scores,sizeof(HighScore) * MaxScores); |
270 | 272 | ||
271 | write(file,&SoundMode,sizeof(SoundMode)); |
273 | write(file,&SoundMode,sizeof(SoundMode)); |
272 | write(file,&MusicMode,sizeof(MusicMode)); |
274 | write(file,&MusicMode,sizeof(MusicMode)); |
273 | write(file,&DigiMode,sizeof(DigiMode)); |
275 | write(file,&DigiMode,sizeof(DigiMode)); |
274 | 276 | ||
275 | write(file,&mouseenabled,sizeof(mouseenabled)); |
277 | write(file,&mouseenabled,sizeof(mouseenabled)); |
276 | write(file,&joystickenabled,sizeof(joystickenabled)); |
278 | write(file,&joystickenabled,sizeof(joystickenabled)); |
277 | boolean dummyJoypadEnabled = false; |
279 | boolean dummyJoypadEnabled = false; |
278 | write(file,&dummyJoypadEnabled,sizeof(dummyJoypadEnabled)); |
280 | write(file,&dummyJoypadEnabled,sizeof(dummyJoypadEnabled)); |
279 | boolean dummyJoystickProgressive = false; |
281 | boolean dummyJoystickProgressive = false; |
280 | write(file,&dummyJoystickProgressive,sizeof(dummyJoystickProgressive)); |
282 | write(file,&dummyJoystickProgressive,sizeof(dummyJoystickProgressive)); |
281 | int dummyJoystickPort = 0; |
283 | int dummyJoystickPort = 0; |
282 | write(file,&dummyJoystickPort,sizeof(dummyJoystickPort)); |
284 | write(file,&dummyJoystickPort,sizeof(dummyJoystickPort)); |
283 | 285 | ||
284 | write(file,dirscan,sizeof(dirscan)); |
286 | write(file,dirscan,sizeof(dirscan)); |
285 | write(file,buttonscan,sizeof(buttonscan)); |
287 | write(file,buttonscan,sizeof(buttonscan)); |
286 | write(file,buttonmouse,sizeof(buttonmouse)); |
288 | write(file,buttonmouse,sizeof(buttonmouse)); |
287 | write(file,buttonjoy,sizeof(buttonjoy)); |
289 | write(file,buttonjoy,sizeof(buttonjoy)); |
288 | 290 | ||
289 | write(file,&viewsize,sizeof(viewsize)); |
291 | write(file,&viewsize,sizeof(viewsize)); |
290 | write(file,&mouseadjustment,sizeof(mouseadjustment)); |
292 | write(file,&mouseadjustment,sizeof(mouseadjustment)); |
291 | 293 | ||
292 | close(file); |
294 | close(file); |
293 | } |
295 | } |
294 | #ifdef _arch_dreamcast |
296 | #ifdef _arch_dreamcast |
295 | DC_SaveToVMU(configname, NULL); |
297 | DC_SaveToVMU(configname, NULL); |
296 | #endif |
298 | #endif |
297 | } |
299 | } |
298 | 300 | ||
299 | 301 | ||
300 | //=========================================================================== |
302 | //=========================================================================== |
301 | 303 | ||
302 | /* |
304 | /* |
303 | ===================== |
305 | ===================== |
304 | = |
306 | = |
305 | = NewGame |
307 | = NewGame |
306 | = |
308 | = |
307 | = Set up new game to start from the beginning |
309 | = Set up new game to start from the beginning |
308 | = |
310 | = |
309 | ===================== |
311 | ===================== |
310 | */ |
312 | */ |
311 | 313 | ||
312 | void NewGame (int difficulty,int episode) |
314 | void NewGame (int difficulty,int episode) |
313 | { |
315 | { |
314 | memset (&gamestate,0,sizeof(gamestate)); |
316 | memset (&gamestate,0,sizeof(gamestate)); |
315 | gamestate.difficulty = difficulty; |
317 | gamestate.difficulty = difficulty; |
316 | gamestate.weapon = gamestate.bestweapon |
318 | gamestate.weapon = gamestate.bestweapon |
317 | = gamestate.chosenweapon = wp_pistol; |
319 | = gamestate.chosenweapon = wp_pistol; |
318 | gamestate.health = 100; |
320 | gamestate.health = 100; |
319 | gamestate.ammo = STARTAMMO; |
321 | gamestate.ammo = STARTAMMO; |
320 | gamestate.lives = 3; |
322 | gamestate.lives = 3; |
321 | gamestate.nextextra = EXTRAPOINTS; |
323 | gamestate.nextextra = EXTRAPOINTS; |
322 | gamestate.episode=episode; |
324 | gamestate.episode=episode; |
323 | 325 | ||
324 | startgame = true; |
326 | startgame = true; |
325 | } |
327 | } |
326 | 328 | ||
327 | //=========================================================================== |
329 | //=========================================================================== |
328 | 330 | ||
329 | void DiskFlopAnim(int x,int y) |
331 | void DiskFlopAnim(int x,int y) |
330 | { |
332 | { |
331 | static int8_t which=0; |
333 | static int8_t which=0; |
332 | if (!x && !y) |
334 | if (!x && !y) |
333 | return; |
335 | return; |
334 | VWB_DrawPic(x,y,C_DISKLOADING1PIC+which); |
336 | VWB_DrawPic(x,y,C_DISKLOADING1PIC+which); |
335 | VW_UpdateScreen(); |
337 | VW_UpdateScreen(); |
336 | which^=1; |
338 | which^=1; |
337 | } |
339 | } |
338 | 340 | ||
339 | 341 | ||
340 | int32_t DoChecksum(byte *source,unsigned size,int32_t checksum) |
342 | int32_t DoChecksum(byte *source,unsigned size,int32_t checksum) |
341 | { |
343 | { |
342 | unsigned i; |
344 | unsigned i; |
343 | 345 | ||
344 | for (i=0;i |
346 | for (i=0;i |
345 | checksum += source[i]^source[i+1]; |
347 | checksum += source[i]^source[i+1]; |
346 | 348 | ||
347 | return checksum; |
349 | return checksum; |
348 | } |
350 | } |
349 | 351 | ||
350 | 352 | ||
351 | /* |
353 | /* |
352 | ================== |
354 | ================== |
353 | = |
355 | = |
354 | = SaveTheGame |
356 | = SaveTheGame |
355 | = |
357 | = |
356 | ================== |
358 | ================== |
357 | */ |
359 | */ |
358 | 360 | ||
359 | extern statetype s_grdstand; |
361 | extern statetype s_grdstand; |
360 | extern statetype s_player; |
362 | extern statetype s_player; |
361 | 363 | ||
362 | boolean SaveTheGame(FILE *file,int x,int y) |
364 | boolean SaveTheGame(FILE *file,int x,int y) |
363 | { |
365 | { |
364 | // struct diskfree_t dfree; |
366 | // struct diskfree_t dfree; |
365 | // int32_t avail,size,checksum; |
367 | // int32_t avail,size,checksum; |
366 | int checksum; |
368 | int checksum; |
367 | objtype *ob; |
369 | objtype *ob; |
368 | objtype nullobj; |
370 | objtype nullobj; |
369 | statobj_t nullstat; |
371 | statobj_t nullstat; |
370 | 372 | ||
371 | /* if (_dos_getdiskfree(0,&dfree)) |
373 | /* if (_dos_getdiskfree(0,&dfree)) |
372 | Quit("Error in _dos_getdiskfree call"); |
374 | Quit("Error in _dos_getdiskfree call"); |
373 | 375 | ||
374 | avail = (int32_t)dfree.avail_clusters * |
376 | avail = (int32_t)dfree.avail_clusters * |
375 | dfree.bytes_per_sector * |
377 | dfree.bytes_per_sector * |
376 | dfree.sectors_per_cluster; |
378 | dfree.sectors_per_cluster; |
377 | 379 | ||
378 | size = 0; |
380 | size = 0; |
379 | for (ob = player; ob ; ob=ob->next) |
381 | for (ob = player; ob ; ob=ob->next) |
380 | size += sizeof(*ob); |
382 | size += sizeof(*ob); |
381 | size += sizeof(nullobj); |
383 | size += sizeof(nullobj); |
382 | 384 | ||
383 | size += sizeof(gamestate) + |
385 | size += sizeof(gamestate) + |
384 | sizeof(LRstruct)*LRpack + |
386 | sizeof(LRstruct)*LRpack + |
385 | sizeof(tilemap) + |
387 | sizeof(tilemap) + |
386 | sizeof(actorat) + |
388 | sizeof(actorat) + |
387 | sizeof(laststatobj) + |
389 | sizeof(laststatobj) + |
388 | sizeof(statobjlist) + |
390 | sizeof(statobjlist) + |
389 | sizeof(doorposition) + |
391 | sizeof(doorposition) + |
390 | sizeof(pwallstate) + |
392 | sizeof(pwallstate) + |
391 | sizeof(pwalltile) + |
393 | sizeof(pwalltile) + |
392 | sizeof(pwallx) + |
394 | sizeof(pwallx) + |
393 | sizeof(pwally) + |
395 | sizeof(pwally) + |
394 | sizeof(pwalldir) + |
396 | sizeof(pwalldir) + |
395 | sizeof(pwallpos); |
397 | sizeof(pwallpos); |
396 | 398 | ||
397 | if (avail < size) |
399 | if (avail < size) |
398 | { |
400 | { |
399 | Message(STR_NOSPACE1"\n"STR_NOSPACE2); |
401 | Message(STR_NOSPACE1"\n"STR_NOSPACE2); |
400 | return false; |
402 | return false; |
401 | }*/ |
403 | }*/ |
402 | 404 | ||
403 | checksum = 0; |
405 | checksum = 0; |
404 | 406 | ||
405 | DiskFlopAnim(x,y); |
407 | DiskFlopAnim(x,y); |
406 | fwrite(&gamestate,sizeof(gamestate),1,file); |
408 | fwrite(&gamestate,sizeof(gamestate),1,file); |
407 | checksum = DoChecksum((byte *)&gamestate,sizeof(gamestate),checksum); |
409 | checksum = DoChecksum((byte *)&gamestate,sizeof(gamestate),checksum); |
408 | 410 | ||
409 | DiskFlopAnim(x,y); |
411 | DiskFlopAnim(x,y); |
410 | fwrite(&LevelRatios[0],sizeof(LRstruct)*LRpack,1,file); |
412 | fwrite(&LevelRatios[0],sizeof(LRstruct)*LRpack,1,file); |
411 | checksum = DoChecksum((byte *)&LevelRatios[0],sizeof(LRstruct)*LRpack,checksum); |
413 | checksum = DoChecksum((byte *)&LevelRatios[0],sizeof(LRstruct)*LRpack,checksum); |
412 | 414 | ||
413 | DiskFlopAnim(x,y); |
415 | DiskFlopAnim(x,y); |
414 | fwrite(tilemap,sizeof(tilemap),1,file); |
416 | fwrite(tilemap,sizeof(tilemap),1,file); |
415 | checksum = DoChecksum((byte *)tilemap,sizeof(tilemap),checksum); |
417 | checksum = DoChecksum((byte *)tilemap,sizeof(tilemap),checksum); |
416 | DiskFlopAnim(x,y); |
418 | DiskFlopAnim(x,y); |
417 | 419 | ||
418 | int i; |
420 | int i; |
419 | for(i=0;i |
421 | for(i=0;i |
420 | { |
422 | { |
421 | for(int j=0;j |
423 | for(int j=0;j |
422 | { |
424 | { |
423 | word actnum; |
425 | word actnum; |
424 | objtype *objptr=actorat[i][j]; |
426 | objtype *objptr=actorat[i][j]; |
425 | if(ISPOINTER(objptr)) |
427 | if(ISPOINTER(objptr)) |
426 | actnum=0x8000 | (word)(objptr-objlist); |
428 | actnum=0x8000 | (word)(objptr-objlist); |
427 | else |
429 | else |
428 | actnum=(word)(uintptr_t)objptr; |
430 | actnum=(word)(uintptr_t)objptr; |
429 | fwrite(&actnum,sizeof(actnum),1,file); |
431 | fwrite(&actnum,sizeof(actnum),1,file); |
430 | checksum = DoChecksum((byte *)&actnum,sizeof(actnum),checksum); |
432 | checksum = DoChecksum((byte *)&actnum,sizeof(actnum),checksum); |
431 | } |
433 | } |
432 | } |
434 | } |
433 | 435 | ||
434 | fwrite (areaconnect,sizeof(areaconnect),1,file); |
436 | fwrite (areaconnect,sizeof(areaconnect),1,file); |
435 | fwrite (areabyplayer,sizeof(areabyplayer),1,file); |
437 | fwrite (areabyplayer,sizeof(areabyplayer),1,file); |
436 | 438 | ||
437 | // player object needs special treatment as it's in WL_AGENT.CPP and not in |
439 | // player object needs special treatment as it's in WL_AGENT.CPP and not in |
438 | // WL_ACT2.CPP which could cause problems for the relative addressing |
440 | // WL_ACT2.CPP which could cause problems for the relative addressing |
439 | 441 | ||
440 | ob = player; |
442 | ob = player; |
441 | DiskFlopAnim(x,y); |
443 | DiskFlopAnim(x,y); |
442 | memcpy(&nullobj,ob,sizeof(nullobj)); |
444 | memcpy(&nullobj,ob,sizeof(nullobj)); |
443 | nullobj.state=(statetype *) ((uintptr_t)nullobj.state-(uintptr_t)&s_player); |
445 | nullobj.state=(statetype *) ((uintptr_t)nullobj.state-(uintptr_t)&s_player); |
444 | fwrite(&nullobj,sizeof(nullobj),1,file); |
446 | fwrite(&nullobj,sizeof(nullobj),1,file); |
445 | ob = ob->next; |
447 | ob = ob->next; |
446 | 448 | ||
447 | DiskFlopAnim(x,y); |
449 | DiskFlopAnim(x,y); |
448 | for (; ob ; ob=ob->next) |
450 | for (; ob ; ob=ob->next) |
449 | { |
451 | { |
450 | memcpy(&nullobj,ob,sizeof(nullobj)); |
452 | memcpy(&nullobj,ob,sizeof(nullobj)); |
451 | nullobj.state=(statetype *) ((uintptr_t)nullobj.state-(uintptr_t)&s_grdstand); |
453 | nullobj.state=(statetype *) ((uintptr_t)nullobj.state-(uintptr_t)&s_grdstand); |
452 | fwrite(&nullobj,sizeof(nullobj),1,file); |
454 | fwrite(&nullobj,sizeof(nullobj),1,file); |
453 | } |
455 | } |
454 | nullobj.active = ac_badobject; // end of file marker |
456 | nullobj.active = ac_badobject; // end of file marker |
455 | DiskFlopAnim(x,y); |
457 | DiskFlopAnim(x,y); |
456 | fwrite(&nullobj,sizeof(nullobj),1,file); |
458 | fwrite(&nullobj,sizeof(nullobj),1,file); |
457 | 459 | ||
458 | DiskFlopAnim(x,y); |
460 | DiskFlopAnim(x,y); |
459 | word laststatobjnum=(word) (laststatobj-statobjlist); |
461 | word laststatobjnum=(word) (laststatobj-statobjlist); |
460 | fwrite(&laststatobjnum,sizeof(laststatobjnum),1,file); |
462 | fwrite(&laststatobjnum,sizeof(laststatobjnum),1,file); |
461 | checksum = DoChecksum((byte *)&laststatobjnum,sizeof(laststatobjnum),checksum); |
463 | checksum = DoChecksum((byte *)&laststatobjnum,sizeof(laststatobjnum),checksum); |
462 | 464 | ||
463 | DiskFlopAnim(x,y); |
465 | DiskFlopAnim(x,y); |
464 | for(i=0;i |
466 | for(i=0;i |
465 | { |
467 | { |
466 | memcpy(&nullstat,statobjlist+i,sizeof(nullstat)); |
468 | memcpy(&nullstat,statobjlist+i,sizeof(nullstat)); |
467 | nullstat.visspot=(byte *) ((uintptr_t) nullstat.visspot-(uintptr_t)spotvis); |
469 | nullstat.visspot=(byte *) ((uintptr_t) nullstat.visspot-(uintptr_t)spotvis); |
468 | fwrite(&nullstat,sizeof(nullstat),1,file); |
470 | fwrite(&nullstat,sizeof(nullstat),1,file); |
469 | checksum = DoChecksum((byte *)&nullstat,sizeof(nullstat),checksum); |
471 | checksum = DoChecksum((byte *)&nullstat,sizeof(nullstat),checksum); |
470 | } |
472 | } |
471 | 473 | ||
472 | DiskFlopAnim(x,y); |
474 | DiskFlopAnim(x,y); |
473 | fwrite (doorposition,sizeof(doorposition),1,file); |
475 | fwrite (doorposition,sizeof(doorposition),1,file); |
474 | checksum = DoChecksum((byte *)doorposition,sizeof(doorposition),checksum); |
476 | checksum = DoChecksum((byte *)doorposition,sizeof(doorposition),checksum); |
475 | DiskFlopAnim(x,y); |
477 | DiskFlopAnim(x,y); |
476 | fwrite (doorobjlist,sizeof(doorobjlist),1,file); |
478 | fwrite (doorobjlist,sizeof(doorobjlist),1,file); |
477 | checksum = DoChecksum((byte *)doorobjlist,sizeof(doorobjlist),checksum); |
479 | checksum = DoChecksum((byte *)doorobjlist,sizeof(doorobjlist),checksum); |
478 | 480 | ||
479 | DiskFlopAnim(x,y); |
481 | DiskFlopAnim(x,y); |
480 | fwrite (&pwallstate,sizeof(pwallstate),1,file); |
482 | fwrite (&pwallstate,sizeof(pwallstate),1,file); |
481 | checksum = DoChecksum((byte *)&pwallstate,sizeof(pwallstate),checksum); |
483 | checksum = DoChecksum((byte *)&pwallstate,sizeof(pwallstate),checksum); |
482 | fwrite (&pwalltile,sizeof(pwalltile),1,file); |
484 | fwrite (&pwalltile,sizeof(pwalltile),1,file); |
483 | checksum = DoChecksum((byte *)&pwalltile,sizeof(pwalltile),checksum); |
485 | checksum = DoChecksum((byte *)&pwalltile,sizeof(pwalltile),checksum); |
484 | fwrite (&pwallx,sizeof(pwallx),1,file); |
486 | fwrite (&pwallx,sizeof(pwallx),1,file); |
485 | checksum = DoChecksum((byte *)&pwallx,sizeof(pwallx),checksum); |
487 | checksum = DoChecksum((byte *)&pwallx,sizeof(pwallx),checksum); |
486 | fwrite (&pwally,sizeof(pwally),1,file); |
488 | fwrite (&pwally,sizeof(pwally),1,file); |
487 | checksum = DoChecksum((byte *)&pwally,sizeof(pwally),checksum); |
489 | checksum = DoChecksum((byte *)&pwally,sizeof(pwally),checksum); |
488 | fwrite (&pwalldir,sizeof(pwalldir),1,file); |
490 | fwrite (&pwalldir,sizeof(pwalldir),1,file); |
489 | checksum = DoChecksum((byte *)&pwalldir,sizeof(pwalldir),checksum); |
491 | checksum = DoChecksum((byte *)&pwalldir,sizeof(pwalldir),checksum); |
490 | fwrite (&pwallpos,sizeof(pwallpos),1,file); |
492 | fwrite (&pwallpos,sizeof(pwallpos),1,file); |
491 | checksum = DoChecksum((byte *)&pwallpos,sizeof(pwallpos),checksum); |
493 | checksum = DoChecksum((byte *)&pwallpos,sizeof(pwallpos),checksum); |
492 | 494 | ||
493 | // |
495 | // |
494 | // WRITE OUT CHECKSUM |
496 | // WRITE OUT CHECKSUM |
495 | // |
497 | // |
496 | fwrite (&checksum,sizeof(checksum),1,file); |
498 | fwrite (&checksum,sizeof(checksum),1,file); |
497 | 499 | ||
498 | fwrite (&lastgamemusicoffset,sizeof(lastgamemusicoffset),1,file); |
500 | fwrite (&lastgamemusicoffset,sizeof(lastgamemusicoffset),1,file); |
499 | 501 | ||
500 | return(true); |
502 | return(true); |
501 | } |
503 | } |
502 | 504 | ||
503 | //=========================================================================== |
505 | //=========================================================================== |
504 | 506 | ||
505 | /* |
507 | /* |
506 | ================== |
508 | ================== |
507 | = |
509 | = |
508 | = LoadTheGame |
510 | = LoadTheGame |
509 | = |
511 | = |
510 | ================== |
512 | ================== |
511 | */ |
513 | */ |
512 | 514 | ||
513 | boolean LoadTheGame(FILE *file,int x,int y) |
515 | boolean LoadTheGame(FILE *file,int x,int y) |
514 | { |
516 | { |
515 | int32_t checksum,oldchecksum; |
517 | int32_t checksum,oldchecksum; |
516 | objtype nullobj; |
518 | objtype nullobj; |
517 | statobj_t nullstat; |
519 | statobj_t nullstat; |
518 | 520 | ||
519 | checksum = 0; |
521 | checksum = 0; |
520 | 522 | ||
521 | DiskFlopAnim(x,y); |
523 | DiskFlopAnim(x,y); |
522 | fread (&gamestate,sizeof(gamestate),1,file); |
524 | fread (&gamestate,sizeof(gamestate),1,file); |
523 | checksum = DoChecksum((byte *)&gamestate,sizeof(gamestate),checksum); |
525 | checksum = DoChecksum((byte *)&gamestate,sizeof(gamestate),checksum); |
524 | 526 | ||
525 | DiskFlopAnim(x,y); |
527 | DiskFlopAnim(x,y); |
526 | fread (&LevelRatios[0],sizeof(LRstruct)*LRpack,1,file); |
528 | fread (&LevelRatios[0],sizeof(LRstruct)*LRpack,1,file); |
527 | checksum = DoChecksum((byte *)&LevelRatios[0],sizeof(LRstruct)*LRpack,checksum); |
529 | checksum = DoChecksum((byte *)&LevelRatios[0],sizeof(LRstruct)*LRpack,checksum); |
528 | 530 | ||
529 | DiskFlopAnim(x,y); |
531 | DiskFlopAnim(x,y); |
530 | SetupGameLevel (); |
532 | SetupGameLevel (); |
531 | 533 | ||
532 | DiskFlopAnim(x,y); |
534 | DiskFlopAnim(x,y); |
533 | fread (tilemap,sizeof(tilemap),1,file); |
535 | fread (tilemap,sizeof(tilemap),1,file); |
534 | checksum = DoChecksum((byte *)tilemap,sizeof(tilemap),checksum); |
536 | checksum = DoChecksum((byte *)tilemap,sizeof(tilemap),checksum); |
535 | 537 | ||
536 | DiskFlopAnim(x,y); |
538 | DiskFlopAnim(x,y); |
537 | 539 | ||
538 | int actnum=0, i; |
540 | int actnum=0, i; |
539 | for(i=0;i |
541 | for(i=0;i |
540 | { |
542 | { |
541 | for(int j=0;j |
543 | for(int j=0;j |
542 | { |
544 | { |
543 | fread (&actnum,sizeof(word),1,file); |
545 | fread (&actnum,sizeof(word),1,file); |
544 | checksum = DoChecksum((byte *) &actnum,sizeof(word),checksum); |
546 | checksum = DoChecksum((byte *) &actnum,sizeof(word),checksum); |
545 | if(actnum&0x8000) |
547 | if(actnum&0x8000) |
546 | actorat[i][j]=objlist+(actnum&0x7fff); |
548 | actorat[i][j]=objlist+(actnum&0x7fff); |
547 | else |
549 | else |
548 | actorat[i][j]=(objtype *)(uintptr_t) actnum; |
550 | actorat[i][j]=(objtype *)(uintptr_t) actnum; |
549 | } |
551 | } |
550 | } |
552 | } |
551 | 553 | ||
552 | fread (areaconnect,sizeof(areaconnect),1,file); |
554 | fread (areaconnect,sizeof(areaconnect),1,file); |
553 | fread (areabyplayer,sizeof(areabyplayer),1,file); |
555 | fread (areabyplayer,sizeof(areabyplayer),1,file); |
554 | 556 | ||
555 | InitActorList (); |
557 | InitActorList (); |
556 | DiskFlopAnim(x,y); |
558 | DiskFlopAnim(x,y); |
557 | fread (player,sizeof(*player),1,file); |
559 | fread (player,sizeof(*player),1,file); |
558 | player->state=(statetype *) ((uintptr_t)player->state+(uintptr_t)&s_player); |
560 | player->state=(statetype *) ((uintptr_t)player->state+(uintptr_t)&s_player); |
559 | 561 | ||
560 | while (1) |
562 | while (1) |
561 | { |
563 | { |
562 | DiskFlopAnim(x,y); |
564 | DiskFlopAnim(x,y); |
563 | fread (&nullobj,sizeof(nullobj),1,file); |
565 | fread (&nullobj,sizeof(nullobj),1,file); |
564 | if (nullobj.active == ac_badobject) |
566 | if (nullobj.active == ac_badobject) |
565 | break; |
567 | break; |
566 | GetNewActor (); |
568 | GetNewActor (); |
567 | nullobj.state=(statetype *) ((uintptr_t)nullobj.state+(uintptr_t)&s_grdstand); |
569 | nullobj.state=(statetype *) ((uintptr_t)nullobj.state+(uintptr_t)&s_grdstand); |
568 | // don't copy over the links |
570 | // don't copy over the links |
569 | memcpy (newobj,&nullobj,sizeof(nullobj)-8); |
571 | memcpy (newobj,&nullobj,sizeof(nullobj)-8); |
570 | } |
572 | } |
571 | 573 | ||
572 | DiskFlopAnim(x,y); |
574 | DiskFlopAnim(x,y); |
573 | word laststatobjnum; |
575 | word laststatobjnum; |
574 | fread (&laststatobjnum,sizeof(laststatobjnum),1,file); |
576 | fread (&laststatobjnum,sizeof(laststatobjnum),1,file); |
575 | laststatobj=statobjlist+laststatobjnum; |
577 | laststatobj=statobjlist+laststatobjnum; |
576 | checksum = DoChecksum((byte *)&laststatobjnum,sizeof(laststatobjnum),checksum); |
578 | checksum = DoChecksum((byte *)&laststatobjnum,sizeof(laststatobjnum),checksum); |
577 | 579 | ||
578 | DiskFlopAnim(x,y); |
580 | DiskFlopAnim(x,y); |
579 | for(i=0;i |
581 | for(i=0;i |
580 | { |
582 | { |
581 | fread(&nullstat,sizeof(nullstat),1,file); |
583 | fread(&nullstat,sizeof(nullstat),1,file); |
582 | checksum = DoChecksum((byte *)&nullstat,sizeof(nullstat),checksum); |
584 | checksum = DoChecksum((byte *)&nullstat,sizeof(nullstat),checksum); |
583 | nullstat.visspot=(byte *) ((uintptr_t)nullstat.visspot+(uintptr_t)spotvis); |
585 | nullstat.visspot=(byte *) ((uintptr_t)nullstat.visspot+(uintptr_t)spotvis); |
584 | memcpy(statobjlist+i,&nullstat,sizeof(nullstat)); |
586 | memcpy(statobjlist+i,&nullstat,sizeof(nullstat)); |
585 | } |
587 | } |
586 | 588 | ||
587 | DiskFlopAnim(x,y); |
589 | DiskFlopAnim(x,y); |
588 | fread (doorposition,sizeof(doorposition),1,file); |
590 | fread (doorposition,sizeof(doorposition),1,file); |
589 | checksum = DoChecksum((byte *)doorposition,sizeof(doorposition),checksum); |
591 | checksum = DoChecksum((byte *)doorposition,sizeof(doorposition),checksum); |
590 | DiskFlopAnim(x,y); |
592 | DiskFlopAnim(x,y); |
591 | fread (doorobjlist,sizeof(doorobjlist),1,file); |
593 | fread (doorobjlist,sizeof(doorobjlist),1,file); |
592 | checksum = DoChecksum((byte *)doorobjlist,sizeof(doorobjlist),checksum); |
594 | checksum = DoChecksum((byte *)doorobjlist,sizeof(doorobjlist),checksum); |
593 | 595 | ||
594 | DiskFlopAnim(x,y); |
596 | DiskFlopAnim(x,y); |
595 | fread (&pwallstate,sizeof(pwallstate),1,file); |
597 | fread (&pwallstate,sizeof(pwallstate),1,file); |
596 | checksum = DoChecksum((byte *)&pwallstate,sizeof(pwallstate),checksum); |
598 | checksum = DoChecksum((byte *)&pwallstate,sizeof(pwallstate),checksum); |
597 | fread (&pwalltile,sizeof(pwalltile),1,file); |
599 | fread (&pwalltile,sizeof(pwalltile),1,file); |
598 | checksum = DoChecksum((byte *)&pwalltile,sizeof(pwalltile),checksum); |
600 | checksum = DoChecksum((byte *)&pwalltile,sizeof(pwalltile),checksum); |
599 | fread (&pwallx,sizeof(pwallx),1,file); |
601 | fread (&pwallx,sizeof(pwallx),1,file); |
600 | checksum = DoChecksum((byte *)&pwallx,sizeof(pwallx),checksum); |
602 | checksum = DoChecksum((byte *)&pwallx,sizeof(pwallx),checksum); |
601 | fread (&pwally,sizeof(pwally),1,file); |
603 | fread (&pwally,sizeof(pwally),1,file); |
602 | checksum = DoChecksum((byte *)&pwally,sizeof(pwally),checksum); |
604 | checksum = DoChecksum((byte *)&pwally,sizeof(pwally),checksum); |
603 | fread (&pwalldir,sizeof(pwalldir),1,file); |
605 | fread (&pwalldir,sizeof(pwalldir),1,file); |
604 | checksum = DoChecksum((byte *)&pwalldir,sizeof(pwalldir),checksum); |
606 | checksum = DoChecksum((byte *)&pwalldir,sizeof(pwalldir),checksum); |
605 | fread (&pwallpos,sizeof(pwallpos),1,file); |
607 | fread (&pwallpos,sizeof(pwallpos),1,file); |
606 | checksum = DoChecksum((byte *)&pwallpos,sizeof(pwallpos),checksum); |
608 | checksum = DoChecksum((byte *)&pwallpos,sizeof(pwallpos),checksum); |
607 | 609 | ||
608 | if (gamestate.secretcount) // assign valid floorcodes under moved pushwalls |
610 | if (gamestate.secretcount) // assign valid floorcodes under moved pushwalls |
609 | { |
611 | { |
610 | word *map, *obj; word tile, sprite; |
612 | word *map, *obj; word tile, sprite; |
611 | map = mapsegs[0]; obj = mapsegs[1]; |
613 | map = mapsegs[0]; obj = mapsegs[1]; |
612 | for (y=0;y |
614 | for (y=0;y |
613 | for (x=0;x |
615 | for (x=0;x |
614 | { |
616 | { |
615 | tile = *map++; sprite = *obj++; |
617 | tile = *map++; sprite = *obj++; |
616 | if (sprite == PUSHABLETILE && !tilemap[x][y] |
618 | if (sprite == PUSHABLETILE && !tilemap[x][y] |
617 | && (tile < AREATILE || tile >= (AREATILE+NUMMAPS))) |
619 | && (tile < AREATILE || tile >= (AREATILE+NUMMAPS))) |
618 | { |
620 | { |
619 | if (*map >= AREATILE) |
621 | if (*map >= AREATILE) |
620 | tile = *map; |
622 | tile = *map; |
621 | if (*(map-1-mapwidth) >= AREATILE) |
623 | if (*(map-1-mapwidth) >= AREATILE) |
622 | tile = *(map-1-mapwidth); |
624 | tile = *(map-1-mapwidth); |
623 | if (*(map-1+mapwidth) >= AREATILE) |
625 | if (*(map-1+mapwidth) >= AREATILE) |
624 | tile = *(map-1+mapwidth); |
626 | tile = *(map-1+mapwidth); |
625 | if ( *(map-2) >= AREATILE) |
627 | if ( *(map-2) >= AREATILE) |
626 | tile = *(map-2); |
628 | tile = *(map-2); |
627 | 629 | ||
628 | *(map-1) = tile; *(obj-1) = 0; |
630 | *(map-1) = tile; *(obj-1) = 0; |
629 | } |
631 | } |
630 | } |
632 | } |
631 | } |
633 | } |
632 | 634 | ||
633 | Thrust(0,0); // set player->areanumber to the floortile you're standing on |
635 | Thrust(0,0); // set player->areanumber to the floortile you're standing on |
634 | 636 | ||
635 | fread (&oldchecksum,sizeof(oldchecksum),1,file); |
637 | fread (&oldchecksum,sizeof(oldchecksum),1,file); |
636 | 638 | ||
637 | fread (&lastgamemusicoffset,sizeof(lastgamemusicoffset),1,file); |
639 | fread (&lastgamemusicoffset,sizeof(lastgamemusicoffset),1,file); |
638 | if(lastgamemusicoffset<0) lastgamemusicoffset=0; |
640 | if(lastgamemusicoffset<0) lastgamemusicoffset=0; |
639 | 641 | ||
640 | 642 | ||
641 | if (oldchecksum != checksum) |
643 | if (oldchecksum != checksum) |
642 | { |
644 | { |
643 | Message(STR_SAVECHT1"\n" |
645 | Message(STR_SAVECHT1"\n" |
644 | STR_SAVECHT2"\n" |
646 | STR_SAVECHT2"\n" |
645 | STR_SAVECHT3"\n" |
647 | STR_SAVECHT3"\n" |
646 | STR_SAVECHT4); |
648 | STR_SAVECHT4); |
647 | 649 | ||
648 | IN_ClearKeysDown(); |
650 | IN_ClearKeysDown(); |
649 | IN_Ack(); |
651 | IN_Ack(); |
650 | 652 | ||
651 | gamestate.oldscore = gamestate.score = 0; |
653 | gamestate.oldscore = gamestate.score = 0; |
652 | gamestate.lives = 1; |
654 | gamestate.lives = 1; |
653 | gamestate.weapon = |
655 | gamestate.weapon = |
654 | gamestate.chosenweapon = |
656 | gamestate.chosenweapon = |
655 | gamestate.bestweapon = wp_pistol; |
657 | gamestate.bestweapon = wp_pistol; |
656 | gamestate.ammo = 8; |
658 | gamestate.ammo = 8; |
657 | } |
659 | } |
658 | 660 | ||
659 | return true; |
661 | return true; |
660 | } |
662 | } |
661 | 663 | ||
662 | //=========================================================================== |
664 | //=========================================================================== |
663 | 665 | ||
664 | /* |
666 | /* |
665 | ========================== |
667 | ========================== |
666 | = |
668 | = |
667 | = ShutdownId |
669 | = ShutdownId |
668 | = |
670 | = |
669 | = Shuts down all ID_?? managers |
671 | = Shuts down all ID_?? managers |
670 | = |
672 | = |
671 | ========================== |
673 | ========================== |
672 | */ |
674 | */ |
673 | 675 | ||
674 | void ShutdownId (void) |
676 | void ShutdownId (void) |
675 | { |
677 | { |
676 | US_Shutdown (); // This line is completely useless... |
678 | US_Shutdown (); // This line is completely useless... |
677 | SD_Shutdown (); |
679 | SD_Shutdown (); |
678 | PM_Shutdown (); |
680 | PM_Shutdown (); |
679 | IN_Shutdown (); |
681 | IN_Shutdown (); |
680 | VW_Shutdown (); |
682 | VW_Shutdown (); |
681 | CA_Shutdown (); |
683 | CA_Shutdown (); |
682 | #if defined(GP2X_940) |
684 | #if defined(GP2X_940) |
683 | GP2X_Shutdown(); |
685 | GP2X_Shutdown(); |
684 | #endif |
686 | #endif |
685 | } |
687 | } |
686 | 688 | ||
687 | 689 | ||
688 | //=========================================================================== |
690 | //=========================================================================== |
689 | 691 | ||
690 | /* |
692 | /* |
691 | ================== |
693 | ================== |
692 | = |
694 | = |
693 | = BuildTables |
695 | = BuildTables |
694 | = |
696 | = |
695 | = Calculates: |
697 | = Calculates: |
696 | = |
698 | = |
697 | = scale projection constant |
699 | = scale projection constant |
698 | = sintable/costable overlapping fractional tables |
700 | = sintable/costable overlapping fractional tables |
699 | = |
701 | = |
700 | ================== |
702 | ================== |
701 | */ |
703 | */ |
702 | 704 | ||
703 | const float radtoint = (float)(FINEANGLES/2/PI); |
705 | const float radtoint = (float)(FINEANGLES/2/PI); |
704 | 706 | ||
705 | void BuildTables (void) |
707 | void BuildTables (void) |
706 | { |
708 | { |
707 | // |
709 | // |
708 | // calculate fine tangents |
710 | // calculate fine tangents |
709 | // |
711 | // |
710 | 712 | ||
711 | int i; |
713 | int i; |
712 | for(i=0;i |
714 | for(i=0;i |
713 | { |
715 | { |
714 | double tang=tan((i+0.5)/radtoint); |
716 | double tang=tan((i+0.5)/radtoint); |
715 | finetangent[i]=(int32_t)(tang*GLOBAL1); |
717 | finetangent[i]=(int32_t)(tang*GLOBAL1); |
716 | finetangent[FINEANGLES/4-1-i]=(int32_t)((1/tang)*GLOBAL1); |
718 | finetangent[FINEANGLES/4-1-i]=(int32_t)((1/tang)*GLOBAL1); |
717 | } |
719 | } |
718 | 720 | ||
719 | // |
721 | // |
720 | // costable overlays sintable with a quarter phase shift |
722 | // costable overlays sintable with a quarter phase shift |
721 | // ANGLES is assumed to be divisable by four |
723 | // ANGLES is assumed to be divisable by four |
722 | // |
724 | // |
723 | 725 | ||
724 | float angle=0; |
726 | float angle=0; |
725 | float anglestep=(float)(PI/2/ANGLEQUAD); |
727 | float anglestep=(float)(PI/2/ANGLEQUAD); |
726 | for(i=0; i |
728 | for(i=0; i |
727 | { |
729 | { |
728 | fixed value=(int32_t)(GLOBAL1*sin(angle)); |
730 | fixed value=(int32_t)(GLOBAL1*sin(angle)); |
729 | sintable[i]=sintable[i+ANGLES]=sintable[ANGLES/2-i]=value; |
731 | sintable[i]=sintable[i+ANGLES]=sintable[ANGLES/2-i]=value; |
730 | sintable[ANGLES-i]=sintable[ANGLES/2+i]=-value; |
732 | sintable[ANGLES-i]=sintable[ANGLES/2+i]=-value; |
731 | angle+=anglestep; |
733 | angle+=anglestep; |
732 | } |
734 | } |
733 | sintable[ANGLEQUAD] = 65536; |
735 | sintable[ANGLEQUAD] = 65536; |
734 | sintable[3*ANGLEQUAD] = -65536; |
736 | sintable[3*ANGLEQUAD] = -65536; |
735 | 737 | ||
736 | #if defined(USE_STARSKY) || defined(USE_RAIN) || defined(USE_SNOW) |
738 | #if defined(USE_STARSKY) || defined(USE_RAIN) || defined(USE_SNOW) |
737 | Init3DPoints(); |
739 | Init3DPoints(); |
738 | #endif |
740 | #endif |
739 | } |
741 | } |
740 | 742 | ||
741 | //=========================================================================== |
743 | //=========================================================================== |
742 | 744 | ||
743 | 745 | ||
744 | /* |
746 | /* |
745 | ==================== |
747 | ==================== |
746 | = |
748 | = |
747 | = CalcProjection |
749 | = CalcProjection |
748 | = |
750 | = |
749 | = Uses focallength |
751 | = Uses focallength |
750 | = |
752 | = |
751 | ==================== |
753 | ==================== |
752 | */ |
754 | */ |
753 | 755 | ||
754 | void CalcProjection (int32_t focal) |
756 | void CalcProjection (int32_t focal) |
755 | { |
757 | { |
756 | int i; |
758 | int i; |
757 | int intang; |
759 | int intang; |
758 | float angle; |
760 | float angle; |
759 | double tang; |
761 | double tang; |
760 | int halfview; |
762 | int halfview; |
761 | double facedist; |
763 | double facedist; |
762 | 764 | ||
763 | focallength = focal; |
765 | focallength = focal; |
764 | facedist = focal+MINDIST; |
766 | facedist = focal+MINDIST; |
765 | halfview = viewwidth/2; // half view in pixels |
767 | halfview = viewwidth/2; // half view in pixels |
766 | 768 | ||
767 | // |
769 | // |
768 | // calculate scale value for vertical height calculations |
770 | // calculate scale value for vertical height calculations |
769 | // and sprite x calculations |
771 | // and sprite x calculations |
770 | // |
772 | // |
771 | scale = (fixed) (halfview*facedist/(VIEWGLOBAL/2)); |
773 | scale = (fixed) (halfview*facedist/(VIEWGLOBAL/2)); |
772 | 774 | ||
773 | // |
775 | // |
774 | // divide heightnumerator by a posts distance to get the posts height for |
776 | // divide heightnumerator by a posts distance to get the posts height for |
775 | // the heightbuffer. The pixel height is height>>2 |
777 | // the heightbuffer. The pixel height is height>>2 |
776 | // |
778 | // |
777 | heightnumerator = (TILEGLOBAL*scale)>>6; |
779 | heightnumerator = (TILEGLOBAL*scale)>>6; |
778 | 780 | ||
779 | // |
781 | // |
780 | // calculate the angle offset from view angle of each pixel's ray |
782 | // calculate the angle offset from view angle of each pixel's ray |
781 | // |
783 | // |
782 | 784 | ||
783 | for (i=0;i |
785 | for (i=0;i |
784 | { |
786 | { |
785 | // start 1/2 pixel over, so viewangle bisects two middle pixels |
787 | // start 1/2 pixel over, so viewangle bisects two middle pixels |
786 | tang = (int32_t)i*VIEWGLOBAL/viewwidth/facedist; |
788 | tang = (int32_t)i*VIEWGLOBAL/viewwidth/facedist; |
787 | angle = (float) atan(tang); |
789 | angle = (float) atan(tang); |
788 | intang = (int) (angle*radtoint); |
790 | intang = (int) (angle*radtoint); |
789 | pixelangle[halfview-1-i] = intang; |
791 | pixelangle[halfview-1-i] = intang; |
790 | pixelangle[halfview+i] = -intang; |
792 | pixelangle[halfview+i] = -intang; |
791 | } |
793 | } |
792 | } |
794 | } |
793 | 795 | ||
794 | 796 | ||
795 | 797 | ||
796 | //=========================================================================== |
798 | //=========================================================================== |
797 | 799 | ||
798 | /* |
800 | /* |
799 | =================== |
801 | =================== |
800 | = |
802 | = |
801 | = SetupWalls |
803 | = SetupWalls |
802 | = |
804 | = |
803 | = Map tile values to scaled pics |
805 | = Map tile values to scaled pics |
804 | = |
806 | = |
805 | =================== |
807 | =================== |
806 | */ |
808 | */ |
807 | 809 | ||
808 | void SetupWalls (void) |
810 | void SetupWalls (void) |
809 | { |
811 | { |
810 | int i; |
812 | int i; |
811 | 813 | ||
812 | horizwall[0]=0; |
814 | horizwall[0]=0; |
813 | vertwall[0]=0; |
815 | vertwall[0]=0; |
814 | 816 | ||
815 | for (i=1;i |
817 | for (i=1;i |
816 | { |
818 | { |
817 | horizwall[i]=(i-1)*2; |
819 | horizwall[i]=(i-1)*2; |
818 | vertwall[i]=(i-1)*2+1; |
820 | vertwall[i]=(i-1)*2+1; |
819 | } |
821 | } |
820 | } |
822 | } |
821 | 823 | ||
822 | //=========================================================================== |
824 | //=========================================================================== |
823 | 825 | ||
824 | /* |
826 | /* |
825 | ========================== |
827 | ========================== |
826 | = |
828 | = |
827 | = SignonScreen |
829 | = SignonScreen |
828 | = |
830 | = |
829 | ========================== |
831 | ========================== |
830 | */ |
832 | */ |
831 | 833 | ||
832 | void SignonScreen (void) // VGA version |
834 | void SignonScreen (void) // VGA version |
833 | { |
835 | { |
834 | VL_SetVGAPlaneMode (); |
836 | VL_SetVGAPlaneMode (); |
835 | 837 | ||
836 | VL_MungePic (signon,320,200); |
838 | VL_MungePic (signon,320,200); |
837 | VL_MemToScreen (signon,320,200,0,0); |
839 | VL_MemToScreen (signon,320,200,0,0); |
838 | } |
840 | } |
839 | 841 | ||
840 | 842 | ||
841 | /* |
843 | /* |
842 | ========================== |
844 | ========================== |
843 | = |
845 | = |
844 | = FinishSignon |
846 | = FinishSignon |
845 | = |
847 | = |
846 | ========================== |
848 | ========================== |
847 | */ |
849 | */ |
848 | 850 | ||
849 | void FinishSignon (void) |
851 | void FinishSignon (void) |
850 | { |
852 | { |
851 | #ifndef SPEAR |
853 | #ifndef SPEAR |
852 | VW_Bar (0,189,300,11,VL_GetPixel(0,0)); |
854 | VW_Bar (0,189,300,11,VL_GetPixel(0,0)); |
853 | WindowX = 0; |
855 | WindowX = 0; |
854 | WindowW = 320; |
856 | WindowW = 320; |
855 | PrintY = 190; |
857 | PrintY = 190; |
856 | 858 | ||
857 | #ifndef JAPAN |
859 | #ifndef JAPAN |
858 | SETFONTCOLOR(14,4); |
860 | SETFONTCOLOR(14,4); |
859 | 861 | ||
860 | #ifdef SPANISH |
862 | #ifdef SPANISH |
861 | US_CPrint ("Oprima una tecla"); |
863 | US_CPrint ("Oprima una tecla"); |
862 | #else |
864 | #else |
863 | US_CPrint ("Press a key"); |
865 | US_CPrint ("Press a key"); |
864 | #endif |
866 | #endif |
865 | 867 | ||
866 | #endif |
868 | #endif |
867 | 869 | ||
868 | VH_UpdateScreen(); |
870 | VH_UpdateScreen(); |
869 | 871 | ||
870 | if (!param_nowait) |
872 | if (!param_nowait) |
871 | IN_Ack (); |
873 | IN_Ack (); |
872 | 874 | ||
873 | #ifndef JAPAN |
875 | #ifndef JAPAN |
874 | VW_Bar (0,189,300,11,VL_GetPixel(0,0)); |
876 | VW_Bar (0,189,300,11,VL_GetPixel(0,0)); |
875 | 877 | ||
876 | PrintY = 190; |
878 | PrintY = 190; |
877 | SETFONTCOLOR(10,4); |
879 | SETFONTCOLOR(10,4); |
878 | 880 | ||
879 | #ifdef SPANISH |
881 | #ifdef SPANISH |
880 | US_CPrint ("pensando..."); |
882 | US_CPrint ("pensando..."); |
881 | #else |
883 | #else |
882 | US_CPrint ("Working..."); |
884 | US_CPrint ("Working..."); |
883 | #endif |
885 | #endif |
884 | 886 | ||
885 | VH_UpdateScreen(); |
887 | VH_UpdateScreen(); |
886 | #endif |
888 | #endif |
887 | 889 | ||
888 | SETFONTCOLOR(0,15); |
890 | SETFONTCOLOR(0,15); |
889 | #else |
891 | #else |
890 | VH_UpdateScreen(); |
892 | VH_UpdateScreen(); |
891 | 893 | ||
892 | if (!param_nowait) |
894 | if (!param_nowait) |
893 | VW_WaitVBL(3*70); |
895 | VW_WaitVBL(3*70); |
894 | #endif |
896 | #endif |
895 | } |
897 | } |
896 | 898 | ||
897 | //=========================================================================== |
899 | //=========================================================================== |
898 | 900 | ||
899 | /* |
901 | /* |
900 | ===================== |
902 | ===================== |
901 | = |
903 | = |
902 | = InitDigiMap |
904 | = InitDigiMap |
903 | = |
905 | = |
904 | ===================== |
906 | ===================== |
905 | */ |
907 | */ |
906 | 908 | ||
907 | // channel mapping: |
909 | // channel mapping: |
908 | // -1: any non reserved channel |
910 | // -1: any non reserved channel |
909 | // 0: player weapons |
911 | // 0: player weapons |
910 | // 1: boss weapons |
912 | // 1: boss weapons |
911 | 913 | ||
912 | static int wolfdigimap[] = |
914 | static int wolfdigimap[] = |
913 | { |
915 | { |
914 | // These first sounds are in the upload version |
916 | // These first sounds are in the upload version |
915 | #ifndef SPEAR |
917 | #ifndef SPEAR |
916 | HALTSND, 0, -1, |
918 | HALTSND, 0, -1, |
917 | DOGBARKSND, 1, -1, |
919 | DOGBARKSND, 1, -1, |
918 | CLOSEDOORSND, 2, -1, |
920 | CLOSEDOORSND, 2, -1, |
919 | OPENDOORSND, 3, -1, |
921 | OPENDOORSND, 3, -1, |
920 | ATKMACHINEGUNSND, 4, 0, |
922 | ATKMACHINEGUNSND, 4, 0, |
921 | ATKPISTOLSND, 5, 0, |
923 | ATKPISTOLSND, 5, 0, |
922 | ATKGATLINGSND, 6, 0, |
924 | ATKGATLINGSND, 6, 0, |
923 | SCHUTZADSND, 7, -1, |
925 | SCHUTZADSND, 7, -1, |
924 | GUTENTAGSND, 8, -1, |
926 | GUTENTAGSND, 8, -1, |
925 | MUTTISND, 9, -1, |
927 | MUTTISND, 9, -1, |
926 | BOSSFIRESND, 10, 1, |
928 | BOSSFIRESND, 10, 1, |
927 | SSFIRESND, 11, -1, |
929 | SSFIRESND, 11, -1, |
928 | DEATHSCREAM1SND, 12, -1, |
930 | DEATHSCREAM1SND, 12, -1, |
929 | DEATHSCREAM2SND, 13, -1, |
931 | DEATHSCREAM2SND, 13, -1, |
930 | DEATHSCREAM3SND, 13, -1, |
932 | DEATHSCREAM3SND, 13, -1, |
931 | TAKEDAMAGESND, 14, -1, |
933 | TAKEDAMAGESND, 14, -1, |
932 | PUSHWALLSND, 15, -1, |
934 | PUSHWALLSND, 15, -1, |
933 | 935 | ||
934 | LEBENSND, 20, -1, |
936 | LEBENSND, 20, -1, |
935 | NAZIFIRESND, 21, -1, |
937 | NAZIFIRESND, 21, -1, |
936 | SLURPIESND, 22, -1, |
938 | SLURPIESND, 22, -1, |
937 | 939 | ||
938 | YEAHSND, 32, -1, |
940 | YEAHSND, 32, -1, |
939 | 941 | ||
940 | #ifndef UPLOAD |
942 | #ifndef UPLOAD |
941 | // These are in all other episodes |
943 | // These are in all other episodes |
942 | DOGDEATHSND, 16, -1, |
944 | DOGDEATHSND, 16, -1, |
943 | AHHHGSND, 17, -1, |
945 | AHHHGSND, 17, -1, |
944 | DIESND, 18, -1, |
946 | DIESND, 18, -1, |
945 | EVASND, 19, -1, |
947 | EVASND, 19, -1, |
946 | 948 | ||
947 | TOT_HUNDSND, 23, -1, |
949 | TOT_HUNDSND, 23, -1, |
948 | MEINGOTTSND, 24, -1, |
950 | MEINGOTTSND, 24, -1, |
949 | SCHABBSHASND, 25, -1, |
951 | SCHABBSHASND, 25, -1, |
950 | HITLERHASND, 26, -1, |
952 | HITLERHASND, 26, -1, |
951 | SPIONSND, 27, -1, |
953 | SPIONSND, 27, -1, |
952 | NEINSOVASSND, 28, -1, |
954 | NEINSOVASSND, 28, -1, |
953 | DOGATTACKSND, 29, -1, |
955 | DOGATTACKSND, 29, -1, |
954 | LEVELDONESND, 30, -1, |
956 | LEVELDONESND, 30, -1, |
955 | MECHSTEPSND, 31, -1, |
957 | MECHSTEPSND, 31, -1, |
956 | 958 | ||
957 | SCHEISTSND, 33, -1, |
959 | SCHEISTSND, 33, -1, |
958 | DEATHSCREAM4SND, 34, -1, // AIIEEE |
960 | DEATHSCREAM4SND, 34, -1, // AIIEEE |
959 | DEATHSCREAM5SND, 35, -1, // DEE-DEE |
961 | DEATHSCREAM5SND, 35, -1, // DEE-DEE |
960 | DONNERSND, 36, -1, // EPISODE 4 BOSS DIE |
962 | DONNERSND, 36, -1, // EPISODE 4 BOSS DIE |
961 | EINESND, 37, -1, // EPISODE 4 BOSS SIGHTING |
963 | EINESND, 37, -1, // EPISODE 4 BOSS SIGHTING |
962 | ERLAUBENSND, 38, -1, // EPISODE 6 BOSS SIGHTING |
964 | ERLAUBENSND, 38, -1, // EPISODE 6 BOSS SIGHTING |
963 | DEATHSCREAM6SND, 39, -1, // FART |
965 | DEATHSCREAM6SND, 39, -1, // FART |
964 | DEATHSCREAM7SND, 40, -1, // GASP |
966 | DEATHSCREAM7SND, 40, -1, // GASP |
965 | DEATHSCREAM8SND, 41, -1, // GUH-BOY! |
967 | DEATHSCREAM8SND, 41, -1, // GUH-BOY! |
966 | DEATHSCREAM9SND, 42, -1, // AH GEEZ! |
968 | DEATHSCREAM9SND, 42, -1, // AH GEEZ! |
967 | KEINSND, 43, -1, // EPISODE 5 BOSS SIGHTING |
969 | KEINSND, 43, -1, // EPISODE 5 BOSS SIGHTING |
968 | MEINSND, 44, -1, // EPISODE 6 BOSS DIE |
970 | MEINSND, 44, -1, // EPISODE 6 BOSS DIE |
969 | ROSESND, 45, -1, // EPISODE 5 BOSS DIE |
971 | ROSESND, 45, -1, // EPISODE 5 BOSS DIE |
970 | 972 | ||
971 | #endif |
973 | #endif |
972 | #else |
974 | #else |
973 | // |
975 | // |
974 | // SPEAR OF DESTINY DIGISOUNDS |
976 | // SPEAR OF DESTINY DIGISOUNDS |
975 | // |
977 | // |
976 | HALTSND, 0, -1, |
978 | HALTSND, 0, -1, |
977 | CLOSEDOORSND, 2, -1, |
979 | CLOSEDOORSND, 2, -1, |
978 | OPENDOORSND, 3, -1, |
980 | OPENDOORSND, 3, -1, |
979 | ATKMACHINEGUNSND, 4, 0, |
981 | ATKMACHINEGUNSND, 4, 0, |
980 | ATKPISTOLSND, 5, 0, |
982 | ATKPISTOLSND, 5, 0, |
981 | ATKGATLINGSND, 6, 0, |
983 | ATKGATLINGSND, 6, 0, |
982 | SCHUTZADSND, 7, -1, |
984 | SCHUTZADSND, 7, -1, |
983 | BOSSFIRESND, 8, 1, |
985 | BOSSFIRESND, 8, 1, |
984 | SSFIRESND, 9, -1, |
986 | SSFIRESND, 9, -1, |
985 | DEATHSCREAM1SND, 10, -1, |
987 | DEATHSCREAM1SND, 10, -1, |
986 | DEATHSCREAM2SND, 11, -1, |
988 | DEATHSCREAM2SND, 11, -1, |
987 | TAKEDAMAGESND, 12, -1, |
989 | TAKEDAMAGESND, 12, -1, |
988 | PUSHWALLSND, 13, -1, |
990 | PUSHWALLSND, 13, -1, |
989 | AHHHGSND, 15, -1, |
991 | AHHHGSND, 15, -1, |
990 | LEBENSND, 16, -1, |
992 | LEBENSND, 16, -1, |
991 | NAZIFIRESND, 17, -1, |
993 | NAZIFIRESND, 17, -1, |
992 | SLURPIESND, 18, -1, |
994 | SLURPIESND, 18, -1, |
993 | LEVELDONESND, 22, -1, |
995 | LEVELDONESND, 22, -1, |
994 | DEATHSCREAM4SND, 23, -1, // AIIEEE |
996 | DEATHSCREAM4SND, 23, -1, // AIIEEE |
995 | DEATHSCREAM3SND, 23, -1, // DOUBLY-MAPPED!!! |
997 | DEATHSCREAM3SND, 23, -1, // DOUBLY-MAPPED!!! |
996 | DEATHSCREAM5SND, 24, -1, // DEE-DEE |
998 | DEATHSCREAM5SND, 24, -1, // DEE-DEE |
997 | DEATHSCREAM6SND, 25, -1, // FART |
999 | DEATHSCREAM6SND, 25, -1, // FART |
998 | DEATHSCREAM7SND, 26, -1, // GASP |
1000 | DEATHSCREAM7SND, 26, -1, // GASP |
999 | DEATHSCREAM8SND, 27, -1, // GUH-BOY! |
1001 | DEATHSCREAM8SND, 27, -1, // GUH-BOY! |
1000 | DEATHSCREAM9SND, 28, -1, // AH GEEZ! |
1002 | DEATHSCREAM9SND, 28, -1, // AH GEEZ! |
1001 | GETGATLINGSND, 38, -1, // Got Gat replacement |
1003 | GETGATLINGSND, 38, -1, // Got Gat replacement |
1002 | 1004 | ||
1003 | #ifndef SPEARDEMO |
1005 | #ifndef SPEARDEMO |
1004 | DOGBARKSND, 1, -1, |
1006 | DOGBARKSND, 1, -1, |
1005 | DOGDEATHSND, 14, -1, |
1007 | DOGDEATHSND, 14, -1, |
1006 | SPIONSND, 19, -1, |
1008 | SPIONSND, 19, -1, |
1007 | NEINSOVASSND, 20, -1, |
1009 | NEINSOVASSND, 20, -1, |
1008 | DOGATTACKSND, 21, -1, |
1010 | DOGATTACKSND, 21, -1, |
1009 | TRANSSIGHTSND, 29, -1, // Trans Sight |
1011 | TRANSSIGHTSND, 29, -1, // Trans Sight |
1010 | TRANSDEATHSND, 30, -1, // Trans Death |
1012 | TRANSDEATHSND, 30, -1, // Trans Death |
1011 | WILHELMSIGHTSND, 31, -1, // Wilhelm Sight |
1013 | WILHELMSIGHTSND, 31, -1, // Wilhelm Sight |
1012 | WILHELMDEATHSND, 32, -1, // Wilhelm Death |
1014 | WILHELMDEATHSND, 32, -1, // Wilhelm Death |
1013 | UBERDEATHSND, 33, -1, // Uber Death |
1015 | UBERDEATHSND, 33, -1, // Uber Death |
1014 | KNIGHTSIGHTSND, 34, -1, // Death Knight Sight |
1016 | KNIGHTSIGHTSND, 34, -1, // Death Knight Sight |
1015 | KNIGHTDEATHSND, 35, -1, // Death Knight Death |
1017 | KNIGHTDEATHSND, 35, -1, // Death Knight Death |
1016 | ANGELSIGHTSND, 36, -1, // Angel Sight |
1018 | ANGELSIGHTSND, 36, -1, // Angel Sight |
1017 | ANGELDEATHSND, 37, -1, // Angel Death |
1019 | ANGELDEATHSND, 37, -1, // Angel Death |
1018 | GETSPEARSND, 39, -1, // Got Spear replacement |
1020 | GETSPEARSND, 39, -1, // Got Spear replacement |
1019 | #endif |
1021 | #endif |
1020 | #endif |
1022 | #endif |
1021 | LASTSOUND |
1023 | LASTSOUND |
1022 | }; |
1024 | }; |
1023 | 1025 | ||
1024 | 1026 | ||
1025 | void InitDigiMap (void) |
1027 | void InitDigiMap (void) |
1026 | { |
1028 | { |
1027 | int *map; |
1029 | int *map; |
1028 | 1030 | ||
1029 | for (map = wolfdigimap; *map != LASTSOUND; map += 3) |
1031 | for (map = wolfdigimap; *map != LASTSOUND; map += 3) |
1030 | { |
1032 | { |
1031 | DigiMap[map[0]] = map[1]; |
1033 | DigiMap[map[0]] = map[1]; |
1032 | DigiChannel[map[1]] = map[2]; |
1034 | DigiChannel[map[1]] = map[2]; |
1033 | SD_PrepareSound(map[1]); |
1035 | SD_PrepareSound(map[1]); |
1034 | } |
1036 | } |
1035 | } |
1037 | } |
1036 | 1038 | ||
1037 | #ifndef SPEAR |
1039 | #ifndef SPEAR |
1038 | CP_iteminfo MusicItems={CTL_X,CTL_Y,6,0,32}; |
1040 | CP_iteminfo MusicItems={CTL_X,CTL_Y,6,0,32}; |
1039 | CP_itemtype MusicMenu[]= |
1041 | CP_itemtype MusicMenu[]= |
1040 | { |
1042 | { |
1041 | {1,"Get Them!",0}, |
1043 | {1,"Get Them!",0}, |
1042 | {1,"Searching",0}, |
1044 | {1,"Searching",0}, |
1043 | {1,"P.O.W.",0}, |
1045 | {1,"P.O.W.",0}, |
1044 | {1,"Suspense",0}, |
1046 | {1,"Suspense",0}, |
1045 | {1,"War March",0}, |
1047 | {1,"War March",0}, |
1046 | {1,"Around The Corner!",0}, |
1048 | {1,"Around The Corner!",0}, |
1047 | 1049 | ||
1048 | {1,"Nazi Anthem",0}, |
1050 | {1,"Nazi Anthem",0}, |
1049 | {1,"Lurking...",0}, |
1051 | {1,"Lurking...",0}, |
1050 | {1,"Going After Hitler",0}, |
1052 | {1,"Going After Hitler",0}, |
1051 | {1,"Pounding Headache",0}, |
1053 | {1,"Pounding Headache",0}, |
1052 | {1,"Into the Dungeons",0}, |
1054 | {1,"Into the Dungeons",0}, |
1053 | {1,"Ultimate Conquest",0}, |
1055 | {1,"Ultimate Conquest",0}, |
1054 | 1056 | ||
1055 | {1,"Kill the S.O.B.",0}, |
1057 | {1,"Kill the S.O.B.",0}, |
1056 | {1,"The Nazi Rap",0}, |
1058 | {1,"The Nazi Rap",0}, |
1057 | {1,"Twelfth Hour",0}, |
1059 | {1,"Twelfth Hour",0}, |
1058 | {1,"Zero Hour",0}, |
1060 | {1,"Zero Hour",0}, |
1059 | {1,"Ultimate Conquest",0}, |
1061 | {1,"Ultimate Conquest",0}, |
1060 | {1,"Wolfpack",0} |
1062 | {1,"Wolfpack",0} |
1061 | }; |
1063 | }; |
1062 | #else |
1064 | #else |
1063 | CP_iteminfo MusicItems={CTL_X,CTL_Y-20,9,0,32}; |
1065 | CP_iteminfo MusicItems={CTL_X,CTL_Y-20,9,0,32}; |
1064 | CP_itemtype MusicMenu[]= |
1066 | CP_itemtype MusicMenu[]= |
1065 | { |
1067 | { |
1066 | {1,"Funky Colonel Bill",0}, |
1068 | {1,"Funky Colonel Bill",0}, |
1067 | {1,"Death To The Nazis",0}, |
1069 | {1,"Death To The Nazis",0}, |
1068 | {1,"Tiptoeing Around",0}, |
1070 | {1,"Tiptoeing Around",0}, |
1069 | {1,"Is This THE END?",0}, |
1071 | {1,"Is This THE END?",0}, |
1070 | {1,"Evil Incarnate",0}, |
1072 | {1,"Evil Incarnate",0}, |
1071 | {1,"Jazzin' Them Nazis",0}, |
1073 | {1,"Jazzin' Them Nazis",0}, |
1072 | {1,"Puttin' It To The Enemy",0}, |
1074 | {1,"Puttin' It To The Enemy",0}, |
1073 | {1,"The SS Gonna Get You",0}, |
1075 | {1,"The SS Gonna Get You",0}, |
1074 | {1,"Towering Above",0} |
1076 | {1,"Towering Above",0} |
1075 | }; |
1077 | }; |
1076 | #endif |
1078 | #endif |
1077 | 1079 | ||
1078 | #ifndef SPEARDEMO |
1080 | #ifndef SPEARDEMO |
1079 | void DoJukebox(void) |
1081 | void DoJukebox(void) |
1080 | { |
1082 | { |
1081 | int which,lastsong=-1; |
1083 | int which,lastsong=-1; |
1082 | unsigned start; |
1084 | unsigned start; |
1083 | unsigned songs[]= |
1085 | unsigned songs[]= |
1084 | { |
1086 | { |
1085 | #ifndef SPEAR |
1087 | #ifndef SPEAR |
1086 | GETTHEM_MUS, |
1088 | GETTHEM_MUS, |
1087 | SEARCHN_MUS, |
1089 | SEARCHN_MUS, |
1088 | POW_MUS, |
1090 | POW_MUS, |
1089 | SUSPENSE_MUS, |
1091 | SUSPENSE_MUS, |
1090 | WARMARCH_MUS, |
1092 | WARMARCH_MUS, |
1091 | CORNER_MUS, |
1093 | CORNER_MUS, |
1092 | 1094 | ||
1093 | NAZI_OMI_MUS, |
1095 | NAZI_OMI_MUS, |
1094 | PREGNANT_MUS, |
1096 | PREGNANT_MUS, |
1095 | GOINGAFT_MUS, |
1097 | GOINGAFT_MUS, |
1096 | HEADACHE_MUS, |
1098 | HEADACHE_MUS, |
1097 | DUNGEON_MUS, |
1099 | DUNGEON_MUS, |
1098 | ULTIMATE_MUS, |
1100 | ULTIMATE_MUS, |
1099 | 1101 | ||
1100 | INTROCW3_MUS, |
1102 | INTROCW3_MUS, |
1101 | NAZI_RAP_MUS, |
1103 | NAZI_RAP_MUS, |
1102 | TWELFTH_MUS, |
1104 | TWELFTH_MUS, |
1103 | ZEROHOUR_MUS, |
1105 | ZEROHOUR_MUS, |
1104 | ULTIMATE_MUS, |
1106 | ULTIMATE_MUS, |
1105 | PACMAN_MUS |
1107 | PACMAN_MUS |
1106 | #else |
1108 | #else |
1107 | XFUNKIE_MUS, // 0 |
1109 | XFUNKIE_MUS, // 0 |
1108 | XDEATH_MUS, // 2 |
1110 | XDEATH_MUS, // 2 |
1109 | XTIPTOE_MUS, // 4 |
1111 | XTIPTOE_MUS, // 4 |
1110 | XTHEEND_MUS, // 7 |
1112 | XTHEEND_MUS, // 7 |
1111 | XEVIL_MUS, // 17 |
1113 | XEVIL_MUS, // 17 |
1112 | XJAZNAZI_MUS, // 18 |
1114 | XJAZNAZI_MUS, // 18 |
1113 | XPUTIT_MUS, // 21 |
1115 | XPUTIT_MUS, // 21 |
1114 | XGETYOU_MUS, // 22 |
1116 | XGETYOU_MUS, // 22 |
1115 | XTOWER2_MUS // 23 |
1117 | XTOWER2_MUS // 23 |
1116 | #endif |
1118 | #endif |
1117 | }; |
1119 | }; |
1118 | 1120 | ||
1119 | IN_ClearKeysDown(); |
1121 | IN_ClearKeysDown(); |
1120 | if (!AdLibPresent && !SoundBlasterPresent) |
1122 | if (!AdLibPresent && !SoundBlasterPresent) |
1121 | return; |
1123 | return; |
1122 | 1124 | ||
1123 | MenuFadeOut(); |
1125 | MenuFadeOut(); |
1124 | 1126 | ||
1125 | #ifndef SPEAR |
1127 | #ifndef SPEAR |
1126 | #ifndef UPLOAD |
1128 | #ifndef UPLOAD |
1127 | start = ((SDL_GetTicks()/10)%3)*6; |
1129 | start = ((SDL_GetTicks()/10)%3)*6; |
1128 | #else |
1130 | #else |
1129 | start = 0; |
1131 | start = 0; |
1130 | #endif |
1132 | #endif |
1131 | #else |
1133 | #else |
1132 | start = 0; |
1134 | start = 0; |
1133 | #endif |
1135 | #endif |
1134 | 1136 | ||
1135 | CA_CacheGrChunk (STARTFONT+1); |
1137 | CA_CacheGrChunk (STARTFONT+1); |
1136 | #ifdef SPEAR |
1138 | #ifdef SPEAR |
1137 | CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END); |
1139 | CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END); |
1138 | #else |
1140 | #else |
1139 | CacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END); |
1141 | CacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END); |
1140 | #endif |
1142 | #endif |
1141 | CA_LoadAllSounds (); |
1143 | CA_LoadAllSounds (); |
1142 | 1144 | ||
1143 | fontnumber=1; |
1145 | fontnumber=1; |
1144 | ClearMScreen (); |
1146 | ClearMScreen (); |
1145 | VWB_DrawPic(112,184,C_MOUSELBACKPIC); |
1147 | VWB_DrawPic(112,184,C_MOUSELBACKPIC); |
1146 | DrawStripes (10); |
1148 | DrawStripes (10); |
1147 | SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR); |
1149 | SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR); |
1148 | 1150 | ||
1149 | #ifndef SPEAR |
1151 | #ifndef SPEAR |
1150 | DrawWindow (CTL_X-2,CTL_Y-6,280,13*7,BKGDCOLOR); |
1152 | DrawWindow (CTL_X-2,CTL_Y-6,280,13*7,BKGDCOLOR); |
1151 | #else |
1153 | #else |
1152 | DrawWindow (CTL_X-2,CTL_Y-26,280,13*10,BKGDCOLOR); |
1154 | DrawWindow (CTL_X-2,CTL_Y-26,280,13*10,BKGDCOLOR); |
1153 | #endif |
1155 | #endif |
1154 | 1156 | ||
1155 | DrawMenu (&MusicItems,&MusicMenu[start]); |
1157 | DrawMenu (&MusicItems,&MusicMenu[start]); |
1156 | 1158 | ||
1157 | SETFONTCOLOR (READHCOLOR,BKGDCOLOR); |
1159 | SETFONTCOLOR (READHCOLOR,BKGDCOLOR); |
1158 | PrintY=15; |
1160 | PrintY=15; |
1159 | WindowX = 0; |
1161 | WindowX = 0; |
1160 | WindowY = 320; |
1162 | WindowY = 320; |
1161 | US_CPrint ("Robert's Jukebox"); |
1163 | US_CPrint ("Robert's Jukebox"); |
1162 | 1164 | ||
1163 | SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR); |
1165 | SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR); |
1164 | VW_UpdateScreen(); |
1166 | VW_UpdateScreen(); |
1165 | MenuFadeIn(); |
1167 | MenuFadeIn(); |
1166 | 1168 | ||
1167 | do |
1169 | do |
1168 | { |
1170 | { |
1169 | which = HandleMenu(&MusicItems,&MusicMenu[start],NULL); |
1171 | which = HandleMenu(&MusicItems,&MusicMenu[start],NULL); |
1170 | if (which>=0) |
1172 | if (which>=0) |
1171 | { |
1173 | { |
1172 | if (lastsong >= 0) |
1174 | if (lastsong >= 0) |
1173 | MusicMenu[start+lastsong].active = 1; |
1175 | MusicMenu[start+lastsong].active = 1; |
1174 | 1176 | ||
1175 | StartCPMusic(songs[start + which]); |
1177 | StartCPMusic(songs[start + which]); |
1176 | MusicMenu[start+which].active = 2; |
1178 | MusicMenu[start+which].active = 2; |
1177 | DrawMenu (&MusicItems,&MusicMenu[start]); |
1179 | DrawMenu (&MusicItems,&MusicMenu[start]); |
1178 | VW_UpdateScreen(); |
1180 | VW_UpdateScreen(); |
1179 | lastsong = which; |
1181 | lastsong = which; |
1180 | } |
1182 | } |
1181 | } while(which>=0); |
1183 | } while(which>=0); |
1182 | 1184 | ||
1183 | MenuFadeOut(); |
1185 | MenuFadeOut(); |
1184 | IN_ClearKeysDown(); |
1186 | IN_ClearKeysDown(); |
1185 | #ifdef SPEAR |
1187 | #ifdef SPEAR |
1186 | UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END); |
1188 | UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END); |
1187 | #else |
1189 | #else |
1188 | UnCacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END); |
1190 | UnCacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END); |
1189 | #endif |
1191 | #endif |
1190 | } |
1192 | } |
1191 | #endif |
1193 | #endif |
1192 | 1194 | ||
1193 | /* |
1195 | /* |
1194 | ========================== |
1196 | ========================== |
1195 | = |
1197 | = |
1196 | = InitGame |
1198 | = InitGame |
1197 | = |
1199 | = |
1198 | = Load a few things right away |
1200 | = Load a few things right away |
1199 | = |
1201 | = |
1200 | ========================== |
1202 | ========================== |
1201 | */ |
1203 | */ |
1202 | 1204 | ||
1203 | static void InitGame() |
1205 | static void InitGame() |
1204 | { |
1206 | { |
1205 | #ifndef SPEARDEMO |
1207 | #ifndef SPEARDEMO |
1206 | boolean didjukebox=false; |
1208 | boolean didjukebox=false; |
1207 | #endif |
1209 | #endif |
1208 | 1210 | ||
1209 | // initialize SDL |
1211 | // initialize SDL |
1210 | #if defined _WIN32 |
1212 | #if defined _WIN32 |
1211 | putenv("SDL_VIDEODRIVER=directx"); |
1213 | putenv("SDL_VIDEODRIVER=directx"); |
1212 | #endif |
1214 | #endif |
1213 | if(SDL_Init(SDL_INIT_VIDEO) < 0) |
1215 | if(SDL_Init(SDL_INIT_VIDEO) < 0) |
1214 | { |
1216 | { |
1215 | printf("Unable to init SDL: %s\n", SDL_GetError()); |
1217 | printf("Unable to init SDL: %s\n", SDL_GetError()); |
1216 | exit(1); |
1218 | exit(1); |
1217 | } |
1219 | } |
1218 | SDL_AudioInit(NULL); |
1220 | SDL_AudioInit(NULL); |
1219 | atexit(SDL_Quit); |
1221 | atexit(SDL_Quit); |
1220 | 1222 | ||
1221 | int numJoysticks = SDL_NumJoysticks(); |
1223 | int numJoysticks = SDL_NumJoysticks(); |
1222 | if(param_joystickindex && (param_joystickindex < -1 || param_joystickindex >= numJoysticks)) |
1224 | if(param_joystickindex && (param_joystickindex < -1 || param_joystickindex >= numJoysticks)) |
1223 | { |
1225 | { |
1224 | if(!numJoysticks) |
1226 | if(!numJoysticks) |
1225 | printf("No joysticks are available to SDL!\n"); |
1227 | printf("No joysticks are available to SDL!\n"); |
1226 | else |
1228 | else |
1227 | printf("The joystick index must be between -1 and %i!\n", numJoysticks - 1); |
1229 | printf("The joystick index must be between -1 and %i!\n", numJoysticks - 1); |
1228 | exit(1); |
1230 | exit(1); |
1229 | } |
1231 | } |
1230 | 1232 | ||
1231 | #if defined(GP2X_940) |
1233 | #if defined(GP2X_940) |
1232 | GP2X_MemoryInit(); |
1234 | GP2X_MemoryInit(); |
1233 | #endif |
1235 | #endif |
1234 | 1236 | ||
1235 | SignonScreen (); |
1237 | SignonScreen (); |
1236 | #ifdef _KOLIBRI |
1238 | #ifdef _KOLIBRI |
1237 | kolibri_set_win_center(); |
1239 | kolibri_set_win_center(); |
1238 | #endif |
1240 | #endif |
1239 | 1241 | ||
1240 | #if defined _WIN32 |
1242 | #if defined _WIN32 |
1241 | if(!fullscreen) |
1243 | if(!fullscreen) |
1242 | { |
1244 | { |
1243 | struct SDL_SysWMinfo wmInfo; |
1245 | struct SDL_SysWMinfo wmInfo; |
1244 | SDL_VERSION(&wmInfo.version); |
1246 | SDL_VERSION(&wmInfo.version); |
1245 | 1247 | ||
1246 | if(SDL_GetWMInfo(&wmInfo) != -1) |
1248 | if(SDL_GetWMInfo(&wmInfo) != -1) |
1247 | { |
1249 | { |
1248 | HWND hwndSDL = wmInfo.window; |
1250 | HWND hwndSDL = wmInfo.window; |
1249 | DWORD style = GetWindowLong(hwndSDL, GWL_STYLE) & ~WS_SYSMENU; |
1251 | DWORD style = GetWindowLong(hwndSDL, GWL_STYLE) & ~WS_SYSMENU; |
1250 | SetWindowLong(hwndSDL, GWL_STYLE, style); |
1252 | SetWindowLong(hwndSDL, GWL_STYLE, style); |
1251 | SetWindowPos(hwndSDL, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); |
1253 | SetWindowPos(hwndSDL, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); |
1252 | } |
1254 | } |
1253 | } |
1255 | } |
1254 | #endif |
1256 | #endif |
1255 | VW_UpdateScreen(); |
1257 | VW_UpdateScreen(); |
1256 | 1258 | ||
1257 | VH_Startup (); |
1259 | VH_Startup (); |
1258 | IN_Startup (); |
1260 | IN_Startup (); |
1259 | PM_Startup (); |
1261 | PM_Startup (); |
1260 | SD_Startup (); |
1262 | SD_Startup (); |
1261 | CA_Startup (); |
1263 | CA_Startup (); |
1262 | US_Startup (); |
1264 | US_Startup (); |
1263 | 1265 | ||
1264 | // TODO: Will any memory checking be needed someday?? |
1266 | // TODO: Will any memory checking be needed someday?? |
1265 | #ifdef NOTYET |
1267 | #ifdef NOTYET |
1266 | #ifndef SPEAR |
1268 | #ifndef SPEAR |
1267 | if (mminfo.mainmem < 235000L) |
1269 | if (mminfo.mainmem < 235000L) |
1268 | #else |
1270 | #else |
1269 | if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode")) |
1271 | if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode")) |
1270 | #endif |
1272 | #endif |
1271 | { |
1273 | { |
1272 | byte *screen; |
1274 | byte *screen; |
1273 | 1275 | ||
1274 | CA_CacheGrChunk (ERRORSCREEN); |
1276 | CA_CacheGrChunk (ERRORSCREEN); |
1275 | screen = grsegs[ERRORSCREEN]; |
1277 | screen = grsegs[ERRORSCREEN]; |
1276 | ShutdownId(); |
1278 | ShutdownId(); |
1277 | /* memcpy((byte *)0xb8000,screen+7+7*160,17*160); |
1279 | /* memcpy((byte *)0xb8000,screen+7+7*160,17*160); |
1278 | gotoxy (1,23);*/ |
1280 | gotoxy (1,23);*/ |
1279 | exit(1); |
1281 | exit(1); |
1280 | } |
1282 | } |
1281 | #endif |
1283 | #endif |
1282 | 1284 | ||
1283 | 1285 | ||
1284 | // |
1286 | // |
1285 | // build some tables |
1287 | // build some tables |
1286 | // |
1288 | // |
1287 | InitDigiMap (); |
1289 | InitDigiMap (); |
1288 | 1290 | ||
1289 | ReadConfig (); |
1291 | ReadConfig (); |
1290 | 1292 | ||
1291 | SetupSaveGames(); |
1293 | SetupSaveGames(); |
1292 | 1294 | ||
1293 | // |
1295 | // |
1294 | // HOLDING DOWN 'M' KEY? |
1296 | // HOLDING DOWN 'M' KEY? |
1295 | // |
1297 | // |
1296 | IN_ProcessEvents(); |
1298 | IN_ProcessEvents(); |
1297 | 1299 | ||
1298 | #ifndef SPEARDEMO |
1300 | #ifndef SPEARDEMO |
1299 | if (Keyboard[sc_M]) |
1301 | if (Keyboard[sc_M]) |
1300 | { |
1302 | { |
1301 | DoJukebox(); |
1303 | DoJukebox(); |
1302 | didjukebox=true; |
1304 | didjukebox=true; |
1303 | } |
1305 | } |
1304 | else |
1306 | else |
1305 | #endif |
1307 | #endif |
1306 | 1308 | ||
1307 | // |
1309 | // |
1308 | // draw intro screen stuff |
1310 | // draw intro screen stuff |
1309 | // |
1311 | // |
1310 | IntroScreen (); |
1312 | IntroScreen (); |
1311 | 1313 | ||
1312 | #ifdef _arch_dreamcast |
1314 | #ifdef _arch_dreamcast |
1313 | //TODO: VMU Selection Screen |
1315 | //TODO: VMU Selection Screen |
1314 | #endif |
1316 | #endif |
1315 | 1317 | ||
1316 | // |
1318 | // |
1317 | // load in and lock down some basic chunks |
1319 | // load in and lock down some basic chunks |
1318 | // |
1320 | // |
1319 | 1321 | ||
1320 | CA_CacheGrChunk(STARTFONT); |
1322 | CA_CacheGrChunk(STARTFONT); |
1321 | CA_CacheGrChunk(STATUSBARPIC); |
1323 | CA_CacheGrChunk(STATUSBARPIC); |
1322 | 1324 | ||
1323 | LoadLatchMem (); |
1325 | LoadLatchMem (); |
1324 | BuildTables (); // trig tables |
1326 | BuildTables (); // trig tables |
1325 | SetupWalls (); |
1327 | SetupWalls (); |
1326 | 1328 | ||
1327 | NewViewSize (viewsize); |
1329 | NewViewSize (viewsize); |
1328 | 1330 | ||
1329 | // |
1331 | // |
1330 | // initialize variables |
1332 | // initialize variables |
1331 | // |
1333 | // |
1332 | InitRedShifts (); |
1334 | InitRedShifts (); |
1333 | #ifndef SPEARDEMO |
1335 | #ifndef SPEARDEMO |
1334 | if(!didjukebox) |
1336 | if(!didjukebox) |
1335 | #endif |
1337 | #endif |
1336 | FinishSignon(); |
1338 | FinishSignon(); |
1337 | 1339 | ||
1338 | #ifdef NOTYET |
1340 | #ifdef NOTYET |
1339 | vdisp = (byte *) (0xa0000+PAGE1START); |
1341 | vdisp = (byte *) (0xa0000+PAGE1START); |
1340 | vbuf = (byte *) (0xa0000+PAGE2START); |
1342 | vbuf = (byte *) (0xa0000+PAGE2START); |
1341 | #endif |
1343 | #endif |
1342 | } |
1344 | } |
1343 | 1345 | ||
1344 | //=========================================================================== |
1346 | //=========================================================================== |
1345 | 1347 | ||
1346 | /* |
1348 | /* |
1347 | ========================== |
1349 | ========================== |
1348 | = |
1350 | = |
1349 | = SetViewSize |
1351 | = SetViewSize |
1350 | = |
1352 | = |
1351 | ========================== |
1353 | ========================== |
1352 | */ |
1354 | */ |
1353 | 1355 | ||
1354 | boolean SetViewSize (unsigned width, unsigned height) |
1356 | boolean SetViewSize (unsigned width, unsigned height) |
1355 | { |
1357 | { |
1356 | viewwidth = width&~15; // must be divisable by 16 |
1358 | viewwidth = width&~15; // must be divisable by 16 |
1357 | viewheight = height&~1; // must be even |
1359 | viewheight = height&~1; // must be even |
1358 | centerx = viewwidth/2-1; |
1360 | centerx = viewwidth/2-1; |
1359 | shootdelta = viewwidth/10; |
1361 | shootdelta = viewwidth/10; |
1360 | if((unsigned) viewheight == screenHeight) |
1362 | if((unsigned) viewheight == screenHeight) |
1361 | viewscreenx = viewscreeny = screenofs = 0; |
1363 | viewscreenx = viewscreeny = screenofs = 0; |
1362 | else |
1364 | else |
1363 | { |
1365 | { |
1364 | viewscreenx = (screenWidth-viewwidth) / 2; |
1366 | viewscreenx = (screenWidth-viewwidth) / 2; |
1365 | viewscreeny = (screenHeight-scaleFactor*STATUSLINES-viewheight)/2; |
1367 | viewscreeny = (screenHeight-scaleFactor*STATUSLINES-viewheight)/2; |
1366 | screenofs = viewscreeny*screenWidth+viewscreenx; |
1368 | screenofs = viewscreeny*screenWidth+viewscreenx; |
1367 | } |
1369 | } |
1368 | 1370 | ||
1369 | // |
1371 | // |
1370 | // calculate trace angles and projection constants |
1372 | // calculate trace angles and projection constants |
1371 | // |
1373 | // |
1372 | CalcProjection (FOCALLENGTH); |
1374 | CalcProjection (FOCALLENGTH); |
1373 | 1375 | ||
1374 | return true; |
1376 | return true; |
1375 | } |
1377 | } |
1376 | 1378 | ||
1377 | 1379 | ||
1378 | void ShowViewSize (int width) |
1380 | void ShowViewSize (int width) |
1379 | { |
1381 | { |
1380 | int oldwidth,oldheight; |
1382 | int oldwidth,oldheight; |
1381 | 1383 | ||
1382 | oldwidth = viewwidth; |
1384 | oldwidth = viewwidth; |
1383 | oldheight = viewheight; |
1385 | oldheight = viewheight; |
1384 | 1386 | ||
1385 | if(width == 21) |
1387 | if(width == 21) |
1386 | { |
1388 | { |
1387 | viewwidth = screenWidth; |
1389 | viewwidth = screenWidth; |
1388 | viewheight = screenHeight; |
1390 | viewheight = screenHeight; |
1389 | VWB_BarScaledCoord (0, 0, screenWidth, screenHeight, 0); |
1391 | VWB_BarScaledCoord (0, 0, screenWidth, screenHeight, 0); |
1390 | } |
1392 | } |
1391 | else if(width == 20) |
1393 | else if(width == 20) |
1392 | { |
1394 | { |
1393 | viewwidth = screenWidth; |
1395 | viewwidth = screenWidth; |
1394 | viewheight = screenHeight - scaleFactor*STATUSLINES; |
1396 | viewheight = screenHeight - scaleFactor*STATUSLINES; |
1395 | DrawPlayBorder (); |
1397 | DrawPlayBorder (); |
1396 | } |
1398 | } |
1397 | else |
1399 | else |
1398 | { |
1400 | { |
1399 | viewwidth = width*16*screenWidth/320; |
1401 | viewwidth = width*16*screenWidth/320; |
1400 | viewheight = (int) (width*16*HEIGHTRATIO*screenHeight/200); |
1402 | viewheight = (int) (width*16*HEIGHTRATIO*screenHeight/200); |
1401 | DrawPlayBorder (); |
1403 | DrawPlayBorder (); |
1402 | } |
1404 | } |
1403 | 1405 | ||
1404 | viewwidth = oldwidth; |
1406 | viewwidth = oldwidth; |
1405 | viewheight = oldheight; |
1407 | viewheight = oldheight; |
1406 | } |
1408 | } |
1407 | 1409 | ||
1408 | 1410 | ||
1409 | void NewViewSize (int width) |
1411 | void NewViewSize (int width) |
1410 | { |
1412 | { |
1411 | viewsize = width; |
1413 | viewsize = width; |
1412 | if(viewsize == 21) |
1414 | if(viewsize == 21) |
1413 | SetViewSize(screenWidth, screenHeight); |
1415 | SetViewSize(screenWidth, screenHeight); |
1414 | else if(viewsize == 20) |
1416 | else if(viewsize == 20) |
1415 | SetViewSize(screenWidth, screenHeight - scaleFactor * STATUSLINES); |
1417 | SetViewSize(screenWidth, screenHeight - scaleFactor * STATUSLINES); |
1416 | else |
1418 | else |
1417 | SetViewSize(width*16*screenWidth/320, (unsigned) (width*16*HEIGHTRATIO*screenHeight/200)); |
1419 | SetViewSize(width*16*screenWidth/320, (unsigned) (width*16*HEIGHTRATIO*screenHeight/200)); |
1418 | } |
1420 | } |
1419 | 1421 | ||
1420 | 1422 | ||
1421 | 1423 | ||
1422 | //=========================================================================== |
1424 | //=========================================================================== |
1423 | 1425 | ||
1424 | /* |
1426 | /* |
1425 | ========================== |
1427 | ========================== |
1426 | = |
1428 | = |
1427 | = Quit |
1429 | = Quit |
1428 | = |
1430 | = |
1429 | ========================== |
1431 | ========================== |
1430 | */ |
1432 | */ |
1431 | 1433 | ||
1432 | void Quit (const char *errorStr, ...) |
1434 | void Quit (const char *errorStr, ...) |
1433 | { |
1435 | { |
1434 | #ifdef NOTYET |
1436 | #ifdef NOTYET |
1435 | byte *screen; |
1437 | byte *screen; |
1436 | #endif |
1438 | #endif |
1437 | char error[256]; |
1439 | char error[256]; |
1438 | if(errorStr != NULL) |
1440 | if(errorStr != NULL) |
1439 | { |
1441 | { |
1440 | va_list vlist; |
1442 | va_list vlist; |
1441 | va_start(vlist, errorStr); |
1443 | va_start(vlist, errorStr); |
1442 | vsprintf(error, errorStr, vlist); |
1444 | vsprintf(error, errorStr, vlist); |
1443 | va_end(vlist); |
1445 | va_end(vlist); |
1444 | } |
1446 | } |
1445 | else error[0] = 0; |
1447 | else error[0] = 0; |
1446 | 1448 | ||
1447 | if (!pictable) // don't try to display the red box before it's loaded |
1449 | if (!pictable) // don't try to display the red box before it's loaded |
1448 | { |
1450 | { |
1449 | ShutdownId(); |
1451 | ShutdownId(); |
1450 | if (error && *error) |
1452 | if (error && *error) |
1451 | { |
1453 | { |
1452 | #ifdef NOTYET |
1454 | #ifdef NOTYET |
1453 | SetTextCursor(0,0); |
1455 | SetTextCursor(0,0); |
1454 | #endif |
1456 | #endif |
1455 | puts(error); |
1457 | puts(error); |
1456 | #ifdef NOTYET |
1458 | #ifdef NOTYET |
1457 | SetTextCursor(0,2); |
1459 | SetTextCursor(0,2); |
1458 | #endif |
1460 | #endif |
1459 | VW_WaitVBL(100); |
1461 | VW_WaitVBL(100); |
1460 | } |
1462 | } |
1461 | exit(1); |
1463 | exit(1); |
1462 | } |
1464 | } |
1463 | 1465 | ||
1464 | if (!error || !*error) |
1466 | if (!error || !*error) |
1465 | { |
1467 | { |
1466 | #ifdef NOTYET |
1468 | #ifdef NOTYET |
1467 | #ifndef JAPAN |
1469 | #ifndef JAPAN |
1468 | CA_CacheGrChunk (ORDERSCREEN); |
1470 | CA_CacheGrChunk (ORDERSCREEN); |
1469 | screen = grsegs[ORDERSCREEN]; |
1471 | screen = grsegs[ORDERSCREEN]; |
1470 | #endif |
1472 | #endif |
1471 | #endif |
1473 | #endif |
1472 | WriteConfig (); |
1474 | WriteConfig (); |
1473 | } |
1475 | } |
1474 | #ifdef NOTYET |
1476 | #ifdef NOTYET |
1475 | else |
1477 | else |
1476 | { |
1478 | { |
1477 | CA_CacheGrChunk (ERRORSCREEN); |
1479 | CA_CacheGrChunk (ERRORSCREEN); |
1478 | screen = grsegs[ERRORSCREEN]; |
1480 | screen = grsegs[ERRORSCREEN]; |
1479 | } |
1481 | } |
1480 | #endif |
1482 | #endif |
1481 | 1483 | ||
1482 | ShutdownId (); |
1484 | ShutdownId (); |
1483 | 1485 | ||
1484 | if (error && *error) |
1486 | if (error && *error) |
1485 | { |
1487 | { |
1486 | #ifdef NOTYET |
1488 | #ifdef NOTYET |
1487 | memcpy((byte *)0xb8000,screen+7,7*160); |
1489 | memcpy((byte *)0xb8000,screen+7,7*160); |
1488 | SetTextCursor(9,3); |
1490 | SetTextCursor(9,3); |
1489 | #endif |
1491 | #endif |
1490 | puts(error); |
1492 | puts(error); |
1491 | #ifdef NOTYET |
1493 | #ifdef NOTYET |
1492 | SetTextCursor(0,7); |
1494 | SetTextCursor(0,7); |
1493 | #endif |
1495 | #endif |
1494 | VW_WaitVBL(200); |
1496 | VW_WaitVBL(200); |
1495 | exit(1); |
1497 | exit(1); |
1496 | } |
1498 | } |
1497 | else |
1499 | else |
1498 | if (!error || !(*error)) |
1500 | if (!error || !(*error)) |
1499 | { |
1501 | { |
1500 | #ifdef NOTYET |
1502 | #ifdef NOTYET |
1501 | #ifndef JAPAN |
1503 | #ifndef JAPAN |
1502 | memcpy((byte *)0xb8000,screen+7,24*160); // 24 for SPEAR/UPLOAD compatibility |
1504 | memcpy((byte *)0xb8000,screen+7,24*160); // 24 for SPEAR/UPLOAD compatibility |
1503 | #endif |
1505 | #endif |
1504 | SetTextCursor(0,23); |
1506 | SetTextCursor(0,23); |
1505 | #endif |
1507 | #endif |
1506 | } |
1508 | } |
1507 | 1509 | ||
1508 | exit(0); |
1510 | exit(0); |
1509 | } |
1511 | } |
1510 | 1512 | ||
1511 | //=========================================================================== |
1513 | //=========================================================================== |
1512 | 1514 | ||
1513 | 1515 | ||
1514 | 1516 | ||
1515 | /* |
1517 | /* |
1516 | ===================== |
1518 | ===================== |
1517 | = |
1519 | = |
1518 | = DemoLoop |
1520 | = DemoLoop |
1519 | = |
1521 | = |
1520 | ===================== |
1522 | ===================== |
1521 | */ |
1523 | */ |
1522 | 1524 | ||
1523 | 1525 | ||
1524 | static void DemoLoop() |
1526 | static void DemoLoop() |
1525 | { |
1527 | { |
1526 | int LastDemo = 0; |
1528 | int LastDemo = 0; |
1527 | 1529 | ||
1528 | // |
1530 | // |
1529 | // check for launch from ted |
1531 | // check for launch from ted |
1530 | // |
1532 | // |
1531 | if (param_tedlevel != -1) |
1533 | if (param_tedlevel != -1) |
1532 | { |
1534 | { |
1533 | param_nowait = true; |
1535 | param_nowait = true; |
1534 | EnableEndGameMenuItem(); |
1536 | EnableEndGameMenuItem(); |
1535 | NewGame(param_difficulty,0); |
1537 | NewGame(param_difficulty,0); |
1536 | 1538 | ||
1537 | #ifndef SPEAR |
1539 | #ifndef SPEAR |
1538 | gamestate.episode = param_tedlevel/10; |
1540 | gamestate.episode = param_tedlevel/10; |
1539 | gamestate.mapon = param_tedlevel%10; |
1541 | gamestate.mapon = param_tedlevel%10; |
1540 | #else |
1542 | #else |
1541 | gamestate.episode = 0; |
1543 | gamestate.episode = 0; |
1542 | gamestate.mapon = param_tedlevel; |
1544 | gamestate.mapon = param_tedlevel; |
1543 | #endif |
1545 | #endif |
1544 | GameLoop(); |
1546 | GameLoop(); |
1545 | Quit (NULL); |
1547 | Quit (NULL); |
1546 | } |
1548 | } |
1547 | 1549 | ||
1548 | 1550 | ||
1549 | // |
1551 | // |
1550 | // main game cycle |
1552 | // main game cycle |
1551 | // |
1553 | // |
1552 | 1554 | ||
1553 | #ifndef DEMOTEST |
1555 | #ifndef DEMOTEST |
1554 | 1556 | ||
1555 | #ifndef UPLOAD |
1557 | #ifndef UPLOAD |
1556 | 1558 | ||
1557 | #ifndef GOODTIMES |
1559 | #ifndef GOODTIMES |
1558 | #ifndef SPEAR |
1560 | #ifndef SPEAR |
1559 | #ifndef JAPAN |
1561 | #ifndef JAPAN |
1560 | if (!param_nowait) |
1562 | if (!param_nowait) |
1561 | NonShareware(); |
1563 | NonShareware(); |
1562 | #endif |
1564 | #endif |
1563 | #else |
1565 | #else |
1564 | #ifndef GOODTIMES |
1566 | #ifndef GOODTIMES |
1565 | #ifndef SPEARDEMO |
1567 | #ifndef SPEARDEMO |
1566 | extern void CopyProtection(void); |
1568 | extern void CopyProtection(void); |
1567 | if(!param_goodtimes) |
1569 | if(!param_goodtimes) |
1568 | CopyProtection(); |
1570 | CopyProtection(); |
1569 | #endif |
1571 | #endif |
1570 | #endif |
1572 | #endif |
1571 | #endif |
1573 | #endif |
1572 | #endif |
1574 | #endif |
1573 | #endif |
1575 | #endif |
1574 | 1576 | ||
1575 | StartCPMusic(INTROSONG); |
1577 | StartCPMusic(INTROSONG); |
1576 | 1578 | ||
1577 | #ifndef JAPAN |
1579 | #ifndef JAPAN |
1578 | if (!param_nowait) |
1580 | if (!param_nowait) |
1579 | PG13 (); |
1581 | PG13 (); |
1580 | #endif |
1582 | #endif |
1581 | 1583 | ||
1582 | #endif |
1584 | #endif |
1583 | 1585 | ||
1584 | while (1) |
1586 | while (1) |
1585 | { |
1587 | { |
1586 | while (!param_nowait) |
1588 | while (!param_nowait) |
1587 | { |
1589 | { |
1588 | // |
1590 | // |
1589 | // title page |
1591 | // title page |
1590 | // |
1592 | // |
1591 | #ifndef DEMOTEST |
1593 | #ifndef DEMOTEST |
1592 | 1594 | ||
1593 | #ifdef SPEAR |
1595 | #ifdef SPEAR |
1594 | SDL_Color pal[256]; |
1596 | SDL_Color pal[256]; |
1595 | CA_CacheGrChunk (TITLEPALETTE); |
1597 | CA_CacheGrChunk (TITLEPALETTE); |
1596 | VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256); |
1598 | VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256); |
1597 | 1599 | ||
1598 | CA_CacheGrChunk (TITLE1PIC); |
1600 | CA_CacheGrChunk (TITLE1PIC); |
1599 | VWB_DrawPic (0,0,TITLE1PIC); |
1601 | VWB_DrawPic (0,0,TITLE1PIC); |
1600 | UNCACHEGRCHUNK (TITLE1PIC); |
1602 | UNCACHEGRCHUNK (TITLE1PIC); |
1601 | 1603 | ||
1602 | CA_CacheGrChunk (TITLE2PIC); |
1604 | CA_CacheGrChunk (TITLE2PIC); |
1603 | VWB_DrawPic (0,80,TITLE2PIC); |
1605 | VWB_DrawPic (0,80,TITLE2PIC); |
1604 | UNCACHEGRCHUNK (TITLE2PIC); |
1606 | UNCACHEGRCHUNK (TITLE2PIC); |
1605 | VW_UpdateScreen (); |
1607 | VW_UpdateScreen (); |
1606 | VL_FadeIn(0,255,pal,30); |
1608 | VL_FadeIn(0,255,pal,30); |
1607 | 1609 | ||
1608 | UNCACHEGRCHUNK (TITLEPALETTE); |
1610 | UNCACHEGRCHUNK (TITLEPALETTE); |
1609 | #else |
1611 | #else |
1610 | CA_CacheScreen (TITLEPIC); |
1612 | CA_CacheScreen (TITLEPIC); |
1611 | VW_UpdateScreen (); |
1613 | VW_UpdateScreen (); |
1612 | VW_FadeIn(); |
1614 | VW_FadeIn(); |
1613 | #endif |
1615 | #endif |
1614 | if (IN_UserInput(TickBase*15)) |
1616 | if (IN_UserInput(TickBase*15)) |
1615 | break; |
1617 | break; |
1616 | VW_FadeOut(); |
1618 | VW_FadeOut(); |
1617 | // |
1619 | // |
1618 | // credits page |
1620 | // credits page |
1619 | // |
1621 | // |
1620 | CA_CacheScreen (CREDITSPIC); |
1622 | CA_CacheScreen (CREDITSPIC); |
1621 | VW_UpdateScreen(); |
1623 | VW_UpdateScreen(); |
1622 | VW_FadeIn (); |
1624 | VW_FadeIn (); |
1623 | if (IN_UserInput(TickBase*10)) |
1625 | if (IN_UserInput(TickBase*10)) |
1624 | break; |
1626 | break; |
1625 | VW_FadeOut (); |
1627 | VW_FadeOut (); |
1626 | // |
1628 | // |
1627 | // high scores |
1629 | // high scores |
1628 | // |
1630 | // |
1629 | DrawHighScores (); |
1631 | DrawHighScores (); |
1630 | VW_UpdateScreen (); |
1632 | VW_UpdateScreen (); |
1631 | VW_FadeIn (); |
1633 | VW_FadeIn (); |
1632 | 1634 | ||
1633 | if (IN_UserInput(TickBase*10)) |
1635 | if (IN_UserInput(TickBase*10)) |
1634 | break; |
1636 | break; |
1635 | #endif |
1637 | #endif |
1636 | // |
1638 | // |
1637 | // demo |
1639 | // demo |
1638 | // |
1640 | // |
1639 | 1641 | ||
1640 | #ifndef SPEARDEMO |
1642 | #ifndef SPEARDEMO |
1641 | PlayDemo (LastDemo++%4); |
1643 | PlayDemo (LastDemo++%4); |
1642 | #else |
1644 | #else |
1643 | PlayDemo (0); |
1645 | PlayDemo (0); |
1644 | #endif |
1646 | #endif |
1645 | 1647 | ||
1646 | if (playstate == ex_abort) |
1648 | if (playstate == ex_abort) |
1647 | break; |
1649 | break; |
1648 | VW_FadeOut(); |
1650 | VW_FadeOut(); |
1649 | if(screenHeight % 200 != 0) |
1651 | if(screenHeight % 200 != 0) |
1650 | VL_ClearScreen(0); |
1652 | VL_ClearScreen(0); |
1651 | StartCPMusic(INTROSONG); |
1653 | StartCPMusic(INTROSONG); |
1652 | } |
1654 | } |
1653 | 1655 | ||
1654 | VW_FadeOut (); |
1656 | VW_FadeOut (); |
1655 | 1657 | ||
1656 | #ifdef DEBUGKEYS |
1658 | #ifdef DEBUGKEYS |
1657 | if (Keyboard[sc_Tab] && param_debugmode) |
1659 | if (Keyboard[sc_Tab] && param_debugmode) |
1658 | RecordDemo (); |
1660 | RecordDemo (); |
1659 | else |
1661 | else |
1660 | US_ControlPanel (0); |
1662 | US_ControlPanel (0); |
1661 | #else |
1663 | #else |
1662 | US_ControlPanel (0); |
1664 | US_ControlPanel (0); |
1663 | #endif |
1665 | #endif |
1664 | 1666 | ||
1665 | if (startgame || loadedgame) |
1667 | if (startgame || loadedgame) |
1666 | { |
1668 | { |
1667 | GameLoop (); |
1669 | GameLoop (); |
1668 | if(!param_nowait) |
1670 | if(!param_nowait) |
1669 | { |
1671 | { |
1670 | VW_FadeOut(); |
1672 | VW_FadeOut(); |
1671 | StartCPMusic(INTROSONG); |
1673 | StartCPMusic(INTROSONG); |
1672 | } |
1674 | } |
1673 | } |
1675 | } |
1674 | } |
1676 | } |
1675 | } |
1677 | } |
1676 | 1678 | ||
1677 | 1679 | ||
1678 | //=========================================================================== |
1680 | //=========================================================================== |
1679 | 1681 | ||
1680 | #define IFARG(str) if(!strcmp(arg, (str))) |
1682 | #define IFARG(str) if(!strcmp(arg, (str))) |
1681 | 1683 | ||
1682 | void CheckParameters(int argc, char *argv[]) |
1684 | void CheckParameters(int argc, char *argv[]) |
1683 | { |
1685 | { |
1684 | bool hasError = false, showHelp = false; |
1686 | bool hasError = false, showHelp = false; |
1685 | bool sampleRateGiven = false, audioBufferGiven = false; |
1687 | bool sampleRateGiven = false, audioBufferGiven = false; |
1686 | int defaultSampleRate = param_samplerate; |
1688 | int defaultSampleRate = param_samplerate; |
1687 | 1689 | ||
1688 | for(int i = 1; i < argc; i++) |
1690 | for(int i = 1; i < argc; i++) |
1689 | { |
1691 | { |
1690 | char *arg = argv[i]; |
1692 | char *arg = argv[i]; |
1691 | #ifndef SPEAR |
1693 | #ifndef SPEAR |
1692 | IFARG("--goobers") |
1694 | IFARG("--goobers") |
1693 | #else |
1695 | #else |
1694 | IFARG("--debugmode") |
1696 | IFARG("--debugmode") |
1695 | #endif |
1697 | #endif |
1696 | param_debugmode = true; |
1698 | param_debugmode = true; |
1697 | else IFARG("--baby") |
1699 | else IFARG("--baby") |
1698 | param_difficulty = 0; |
1700 | param_difficulty = 0; |
1699 | else IFARG("--easy") |
1701 | else IFARG("--easy") |
1700 | param_difficulty = 1; |
1702 | param_difficulty = 1; |
1701 | else IFARG("--normal") |
1703 | else IFARG("--normal") |
1702 | param_difficulty = 2; |
1704 | param_difficulty = 2; |
1703 | else IFARG("--hard") |
1705 | else IFARG("--hard") |
1704 | param_difficulty = 3; |
1706 | param_difficulty = 3; |
1705 | else IFARG("--nowait") |
1707 | else IFARG("--nowait") |
1706 | param_nowait = true; |
1708 | param_nowait = true; |
1707 | else IFARG("--tedlevel") |
1709 | else IFARG("--tedlevel") |
1708 | { |
1710 | { |
1709 | if(++i >= argc) |
1711 | if(++i >= argc) |
1710 | { |
1712 | { |
1711 | printf("The tedlevel option is missing the level argument!\n"); |
1713 | printf("The tedlevel option is missing the level argument!\n"); |
1712 | hasError = true; |
1714 | hasError = true; |
1713 | } |
1715 | } |
1714 | else param_tedlevel = atoi(argv[i]); |
1716 | else param_tedlevel = atoi(argv[i]); |
1715 | } |
1717 | } |
1716 | else IFARG("--windowed") |
1718 | else IFARG("--windowed") |
1717 | fullscreen = false; |
1719 | fullscreen = false; |
1718 | else IFARG("--windowed-mouse") |
1720 | else IFARG("--windowed-mouse") |
1719 | { |
1721 | { |
1720 | fullscreen = false; |
1722 | fullscreen = false; |
1721 | forcegrabmouse = true; |
1723 | forcegrabmouse = true; |
1722 | } |
1724 | } |
1723 | else IFARG("--res") |
1725 | else IFARG("--res") |
1724 | { |
1726 | { |
1725 | if(i + 2 >= argc) |
1727 | if(i + 2 >= argc) |
1726 | { |
1728 | { |
1727 | printf("The res option needs the width and/or the height argument!\n"); |
1729 | printf("The res option needs the width and/or the height argument!\n"); |
1728 | hasError = true; |
1730 | hasError = true; |
1729 | } |
1731 | } |
1730 | else |
1732 | else |
1731 | { |
1733 | { |
1732 | screenWidth = atoi(argv[++i]); |
1734 | screenWidth = atoi(argv[++i]); |
1733 | screenHeight = atoi(argv[++i]); |
1735 | screenHeight = atoi(argv[++i]); |
1734 | unsigned factor = screenWidth / 320; |
1736 | unsigned factor = screenWidth / 320; |
1735 | if(screenWidth % 320 || screenHeight != 200 * factor && screenHeight != 240 * factor) |
1737 | if(screenWidth % 320 || screenHeight != 200 * factor && screenHeight != 240 * factor) |
1736 | printf("Screen size must be a multiple of 320x200 or 320x240!\n"), hasError = true; |
1738 | printf("Screen size must be a multiple of 320x200 or 320x240!\n"), hasError = true; |
1737 | } |
1739 | } |
1738 | } |
1740 | } |
1739 | else IFARG("--resf") |
1741 | else IFARG("--resf") |
1740 | { |
1742 | { |
1741 | if(i + 2 >= argc) |
1743 | if(i + 2 >= argc) |
1742 | { |
1744 | { |
1743 | printf("The resf option needs the width and/or the height argument!\n"); |
1745 | printf("The resf option needs the width and/or the height argument!\n"); |
1744 | hasError = true; |
1746 | hasError = true; |
1745 | } |
1747 | } |
1746 | else |
1748 | else |
1747 | { |
1749 | { |
1748 | screenWidth = atoi(argv[++i]); |
1750 | screenWidth = atoi(argv[++i]); |
1749 | screenHeight = atoi(argv[++i]); |
1751 | screenHeight = atoi(argv[++i]); |
1750 | if(screenWidth < 320) |
1752 | if(screenWidth < 320) |
1751 | printf("Screen width must be at least 320!\n"), hasError = true; |
1753 | printf("Screen width must be at least 320!\n"), hasError = true; |
1752 | if(screenHeight < 200) |
1754 | if(screenHeight < 200) |
1753 | printf("Screen height must be at least 200!\n"), hasError = true; |
1755 | printf("Screen height must be at least 200!\n"), hasError = true; |
1754 | } |
1756 | } |
1755 | } |
1757 | } |
1756 | else IFARG("--bits") |
1758 | else IFARG("--bits") |
1757 | { |
1759 | { |
1758 | if(++i >= argc) |
1760 | if(++i >= argc) |
1759 | { |
1761 | { |
1760 | printf("The bits option is missing the color depth argument!\n"); |
1762 | printf("The bits option is missing the color depth argument!\n"); |
1761 | hasError = true; |
1763 | hasError = true; |
1762 | } |
1764 | } |
1763 | else |
1765 | else |
1764 | { |
1766 | { |
1765 | screenBits = atoi(argv[i]); |
1767 | screenBits = atoi(argv[i]); |
1766 | switch(screenBits) |
1768 | switch(screenBits) |
1767 | { |
1769 | { |
1768 | case 8: |
1770 | case 8: |
1769 | case 16: |
1771 | case 16: |
1770 | case 24: |
1772 | case 24: |
1771 | case 32: |
1773 | case 32: |
1772 | break; |
1774 | break; |
1773 | 1775 | ||
1774 | default: |
1776 | default: |
1775 | printf("Screen color depth must be 8, 16, 24, or 32!\n"); |
1777 | printf("Screen color depth must be 8, 16, 24, or 32!\n"); |
1776 | hasError = true; |
1778 | hasError = true; |
1777 | break; |
1779 | break; |
1778 | } |
1780 | } |
1779 | } |
1781 | } |
1780 | } |
1782 | } |
1781 | else IFARG("--nodblbuf") |
1783 | else IFARG("--nodblbuf") |
1782 | usedoublebuffering = false; |
1784 | usedoublebuffering = false; |
1783 | else IFARG("--extravbls") |
1785 | else IFARG("--extravbls") |
1784 | { |
1786 | { |
1785 | if(++i >= argc) |
1787 | if(++i >= argc) |
1786 | { |
1788 | { |
1787 | printf("The extravbls option is missing the vbls argument!\n"); |
1789 | printf("The extravbls option is missing the vbls argument!\n"); |
1788 | hasError = true; |
1790 | hasError = true; |
1789 | } |
1791 | } |
1790 | else |
1792 | else |
1791 | { |
1793 | { |
1792 | extravbls = atoi(argv[i]); |
1794 | extravbls = atoi(argv[i]); |
1793 | if(extravbls < 0) |
1795 | if(extravbls < 0) |
1794 | { |
1796 | { |
1795 | printf("Extravbls must be positive!\n"); |
1797 | printf("Extravbls must be positive!\n"); |
1796 | hasError = true; |
1798 | hasError = true; |
1797 | } |
1799 | } |
1798 | } |
1800 | } |
1799 | } |
1801 | } |
1800 | else IFARG("--joystick") |
1802 | else IFARG("--joystick") |
1801 | { |
1803 | { |
1802 | if(++i >= argc) |
1804 | if(++i >= argc) |
1803 | { |
1805 | { |
1804 | printf("The joystick option is missing the index argument!\n"); |
1806 | printf("The joystick option is missing the index argument!\n"); |
1805 | hasError = true; |
1807 | hasError = true; |
1806 | } |
1808 | } |
1807 | else param_joystickindex = atoi(argv[i]); // index is checked in InitGame |
1809 | else param_joystickindex = atoi(argv[i]); // index is checked in InitGame |
1808 | } |
1810 | } |
1809 | else IFARG("--joystickhat") |
1811 | else IFARG("--joystickhat") |
1810 | { |
1812 | { |
1811 | if(++i >= argc) |
1813 | if(++i >= argc) |
1812 | { |
1814 | { |
1813 | printf("The joystickhat option is missing the index argument!\n"); |
1815 | printf("The joystickhat option is missing the index argument!\n"); |
1814 | hasError = true; |
1816 | hasError = true; |
1815 | } |
1817 | } |
1816 | else param_joystickhat = atoi(argv[i]); |
1818 | else param_joystickhat = atoi(argv[i]); |
1817 | } |
1819 | } |
1818 | else IFARG("--samplerate") |
1820 | else IFARG("--samplerate") |
1819 | { |
1821 | { |
1820 | if(++i >= argc) |
1822 | if(++i >= argc) |
1821 | { |
1823 | { |
1822 | printf("The samplerate option is missing the rate argument!\n"); |
1824 | printf("The samplerate option is missing the rate argument!\n"); |
1823 | hasError = true; |
1825 | hasError = true; |
1824 | } |
1826 | } |
1825 | else param_samplerate = atoi(argv[i]); |
1827 | else param_samplerate = atoi(argv[i]); |
1826 | sampleRateGiven = true; |
1828 | sampleRateGiven = true; |
1827 | } |
1829 | } |
1828 | else IFARG("--audiobuffer") |
1830 | else IFARG("--audiobuffer") |
1829 | { |
1831 | { |
1830 | if(++i >= argc) |
1832 | if(++i >= argc) |
1831 | { |
1833 | { |
1832 | printf("The audiobuffer option is missing the size argument!\n"); |
1834 | printf("The audiobuffer option is missing the size argument!\n"); |
1833 | hasError = true; |
1835 | hasError = true; |
1834 | } |
1836 | } |
1835 | else param_audiobuffer = atoi(argv[i]); |
1837 | else param_audiobuffer = atoi(argv[i]); |
1836 | audioBufferGiven = true; |
1838 | audioBufferGiven = true; |
1837 | } |
1839 | } |
1838 | else IFARG("--mission") |
1840 | else IFARG("--mission") |
1839 | { |
1841 | { |
1840 | if(++i >= argc) |
1842 | if(++i >= argc) |
1841 | { |
1843 | { |
1842 | printf("The mission option is missing the mission argument!\n"); |
1844 | printf("The mission option is missing the mission argument!\n"); |
1843 | hasError = true; |
1845 | hasError = true; |
1844 | } |
1846 | } |
1845 | else |
1847 | else |
1846 | { |
1848 | { |
1847 | param_mission = atoi(argv[i]); |
1849 | param_mission = atoi(argv[i]); |
1848 | if(param_mission < 0 || param_mission > 3) |
1850 | if(param_mission < 0 || param_mission > 3) |
1849 | { |
1851 | { |
1850 | printf("The mission option must be between 0 and 3!\n"); |
1852 | printf("The mission option must be between 0 and 3!\n"); |
1851 | hasError = true; |
1853 | hasError = true; |
1852 | } |
1854 | } |
1853 | } |
1855 | } |
1854 | } |
1856 | } |
1855 | else IFARG("--configdir") |
1857 | else IFARG("--configdir") |
1856 | { |
1858 | { |
1857 | if(++i >= argc) |
1859 | if(++i >= argc) |
1858 | { |
1860 | { |
1859 | printf("The configdir option is missing the dir argument!\n"); |
1861 | printf("The configdir option is missing the dir argument!\n"); |
1860 | hasError = true; |
1862 | hasError = true; |
1861 | } |
1863 | } |
1862 | else |
1864 | else |
1863 | { |
1865 | { |
1864 | size_t len = strlen(argv[i]); |
1866 | size_t len = strlen(argv[i]); |
1865 | if(len + 2 > sizeof(configdir)) |
1867 | if(len + 2 > sizeof(configdir)) |
1866 | { |
1868 | { |
1867 | printf("The config directory is too long!\n"); |
1869 | printf("The config directory is too long!\n"); |
1868 | hasError = true; |
1870 | hasError = true; |
1869 | } |
1871 | } |
1870 | else |
1872 | else |
1871 | { |
1873 | { |
1872 | strcpy(configdir, argv[i]); |
1874 | strcpy(configdir, argv[i]); |
1873 | if(argv[i][len] != '/' && argv[i][len] != '\\') |
1875 | if(argv[i][len] != '/' && argv[i][len] != '\\') |
1874 | strcat(configdir, "/"); |
1876 | strcat(configdir, "/"); |
1875 | } |
1877 | } |
1876 | } |
1878 | } |
1877 | } |
1879 | } |
1878 | else IFARG("--goodtimes") |
1880 | else IFARG("--goodtimes") |
1879 | param_goodtimes = true; |
1881 | param_goodtimes = true; |
1880 | else IFARG("--ignorenumchunks") |
1882 | else IFARG("--ignorenumchunks") |
1881 | param_ignorenumchunks = true; |
1883 | param_ignorenumchunks = true; |
1882 | else IFARG("--help") |
1884 | else IFARG("--help") |
1883 | showHelp = true; |
1885 | showHelp = true; |
1884 | else hasError = true; |
1886 | else hasError = true; |
1885 | } |
1887 | } |
1886 | if(hasError || showHelp) |
1888 | if(hasError || showHelp) |
1887 | { |
1889 | { |
1888 | if(hasError) printf("\n"); |
1890 | if(hasError) printf("\n"); |
1889 | printf( |
1891 | printf( |
1890 | "Wolf4SDL v1.7\n" |
1892 | "Wolf4SDL v1.7\n" |
1891 | "Ported by Chaos-Software (http://www.chaos-software.de.vu)\n" |
1893 | "Ported by Chaos-Software (http://www.chaos-software.de.vu)\n" |
1892 | #ifdef _KOLIBRI |
1894 | #ifdef _KOLIBRI |
1893 | "Ported for KolibriOS by 'turbocat2001' and 'maxcodehack'\n" |
1895 | "Ported for KolibriOS by 'turbocat2001' and 'maxcodehack'\n" |
1894 | #endif |
1896 | #endif |
1895 | "Original Wolfenstein 3D by id Software\n\n" |
1897 | "Original Wolfenstein 3D by id Software\n\n" |
1896 | "Usage: Wolf4SDL [options]\n" |
1898 | "Usage: Wolf4SDL [options]\n" |
1897 | "Options:\n" |
1899 | "Options:\n" |
1898 | " --help This help page\n" |
1900 | " --help This help page\n" |
1899 | " --tedlevel |
1901 | " --tedlevel |
1900 | " --baby Sets the difficulty to baby for tedlevel\n" |
1902 | " --baby Sets the difficulty to baby for tedlevel\n" |
1901 | " --easy Sets the difficulty to easy for tedlevel\n" |
1903 | " --easy Sets the difficulty to easy for tedlevel\n" |
1902 | " --normal Sets the difficulty to normal for tedlevel\n" |
1904 | " --normal Sets the difficulty to normal for tedlevel\n" |
1903 | " --hard Sets the difficulty to hard for tedlevel\n" |
1905 | " --hard Sets the difficulty to hard for tedlevel\n" |
1904 | " --nowait Skips intro screens\n" |
1906 | " --nowait Skips intro screens\n" |
1905 | #ifndef _KOLIBRI |
1907 | #ifndef _KOLIBRI |
1906 | " --windowed[-mouse] Starts the game in a window [and grabs mouse]\n" |
1908 | " --windowed[-mouse] Starts the game in a window [and grabs mouse]\n" |
1907 | " --res |
1909 | " --res |
1908 | #endif |
1910 | #endif |
1909 | " (must be multiple of 320x200 or 320x240)\n" |
1911 | " (must be multiple of 320x200 or 320x240)\n" |
1910 | " --resf |
1912 | " --resf |
1911 | " (which may result in graphic errors)\n" |
1913 | " (which may result in graphic errors)\n" |
1912 | " --bits Sets the screen color depth\n" |
1914 | " --bits Sets the screen color depth\n" |
1913 | " (use this when you have palette/fading problems\n" |
1915 | " (use this when you have palette/fading problems\n" |
1914 | " allowed: 8, 16, 24, 32, default: \"best\" depth)\n" |
1916 | " allowed: 8, 16, 24, 32, default: \"best\" depth)\n" |
1915 | " --nodblbuf Don't use SDL's double buffering\n" |
1917 | " --nodblbuf Don't use SDL's double buffering\n" |
1916 | " --extravbls |
1918 | " --extravbls |
1917 | " reduce flickering (unit is currently 8 ms, default: 0)\n" |
1919 | " reduce flickering (unit is currently 8 ms, default: 0)\n" |
1918 | #ifndef _KOLIBRI |
1920 | #ifndef _KOLIBRI |
1919 | " --joystick |
1921 | " --joystick |
1920 | " (-1 to disable joystick, default: 0)\n" |
1922 | " (-1 to disable joystick, default: 0)\n" |
1921 | " --joystickhat |
1923 | " --joystickhat |
1922 | #endif |
1924 | #endif |
1923 | " --samplerate |
1925 | " --samplerate |
1924 | " --audiobuffer |
1926 | " --audiobuffer |
1925 | " (given in bytes, default: 2048 / (44100 / samplerate))\n" |
1927 | " (given in bytes, default: 2048 / (44100 / samplerate))\n" |
1926 | " --ignorenumchunks Ignores the number of chunks in VGAHEAD.*\n" |
1928 | " --ignorenumchunks Ignores the number of chunks in VGAHEAD.*\n" |
1927 | " (may be useful for some broken mods)\n" |
1929 | " (may be useful for some broken mods)\n" |
1928 | " --configdir |
1930 | " --configdir |
1929 | #if defined(_arch_dreamcast) || defined(_WIN32) |
1931 | #if defined(_arch_dreamcast) || defined(_WIN32) |
1930 | " (default: current directory)\n" |
1932 | " (default: current directory)\n" |
1931 | #endif |
1933 | #endif |
1932 | 1934 | ||
1933 | #ifdef _KOLIBRI |
1935 | #ifdef _KOLIBRI |
1934 | " (default: /tmp0/1/wolf4sdl)\n" |
1936 | " (default: /tmp0/1/wolf4sdl)\n" |
1935 | #else |
1937 | #else |
1936 | " (default: $HOME/.wolf4sdl)\n" |
1938 | " (default: $HOME/.wolf4sdl)\n" |
1937 | #endif |
1939 | #endif |
1938 | #if defined(SPEAR) && !defined(SPEARDEMO) |
1940 | #if defined(SPEAR) && !defined(SPEARDEMO) |
1939 | " --mission |
1941 | " --mission |
1940 | " (default: 0 -> .sod, 1-3 -> .sd*)\n" |
1942 | " (default: 0 -> .sod, 1-3 -> .sd*)\n" |
1941 | " --goodtimes Disable copy protection quiz\n" |
1943 | " --goodtimes Disable copy protection quiz\n" |
1942 | #endif |
1944 | #endif |
1943 | , defaultSampleRate |
1945 | , defaultSampleRate |
1944 | ); |
1946 | ); |
1945 | exit(1); |
1947 | exit(1); |
1946 | } |
1948 | } |
1947 | 1949 | ||
1948 | if(sampleRateGiven && !audioBufferGiven) |
1950 | if(sampleRateGiven && !audioBufferGiven) |
1949 | param_audiobuffer = 2048 / (44100 / param_samplerate); |
1951 | param_audiobuffer = 2048 / (44100 / param_samplerate); |
1950 | } |
1952 | } |
1951 | 1953 | ||
1952 | /* |
1954 | /* |
1953 | ========================== |
1955 | ========================== |
1954 | = |
1956 | = |
1955 | = main |
1957 | = main |
1956 | = |
1958 | = |
1957 | ========================== |
1959 | ========================== |
1958 | */ |
1960 | */ |
1959 | 1961 | ||
1960 | int main (int argc, char *argv[]) |
1962 | int main (int argc, char *argv[]) |
1961 | { |
1963 | { |
- | 1964 | #ifdef _KOLIBRI |
|
- | 1965 | setcwd(dirname(argv[0])); |
|
- | 1966 | #endif |
|
- | 1967 | ||
1962 | #if defined(_arch_dreamcast) |
1968 | #if defined(_arch_dreamcast) |
1963 | DC_Init(); |
1969 | DC_Init(); |
1964 | #else |
1970 | #else |
1965 | CheckParameters(argc, argv); |
1971 | CheckParameters(argc, argv); |
1966 | #endif |
1972 | #endif |
1967 | CheckForEpisodes(); |
1973 | CheckForEpisodes(); |
1968 | InitGame(); |
1974 | InitGame(); |
1969 | DemoLoop(); |
1975 | DemoLoop(); |
1970 | Quit("Demo loop exited???"); |
1976 | Quit("Demo loop exited???"); |
1971 | return 1; |
1977 | return 1; |
1972 | }>>>>>>>>> |
1978 | }>>>>>>>>> |
1973 | > |
1979 | > |
1974 | > |
1980 | > |
1975 | >0)>> |
1981 | >0)>> |
1976 | > |
1982 | > |
1977 | > |
1983 | > |
1978 | > |
1984 | > |
1979 | > |
1985 | > |
1980 | > |
1986 | > |
1981 | > |
1987 | > |
1982 | > |
1988 | > |
1983 | >> |
1989 | >> |
1984 | >4)>0)> |
1990 | >4)>0)> |