]> 4ch.mooo.com Git - 16.git/blob - 16/wf3d8086/wl_game.c
update todo list with new stuff
[16.git] / 16 / wf3d8086 / wl_game.c
1 // WL_GAME.C\r
2 \r
3 #include "WL_DEF.H"\r
4 #pragma hdrstop\r
5 \r
6 #ifdef MYPROFILE\r
7 #include <TIME.H>\r
8 #endif\r
9 \r
10 \r
11 /*\r
12 =============================================================================\r
13 \r
14                                                  LOCAL CONSTANTS\r
15 \r
16 =============================================================================\r
17 */\r
18 \r
19 \r
20 /*\r
21 =============================================================================\r
22 \r
23                                                  GLOBAL VARIABLES\r
24 \r
25 =============================================================================\r
26 */\r
27 \r
28 boolean         ingame,fizzlein;\r
29 unsigned        latchpics[NUMLATCHPICS];\r
30 gametype        gamestate;\r
31 \r
32 long            spearx,speary;\r
33 unsigned        spearangle;\r
34 boolean         spearflag;\r
35 \r
36 //\r
37 // ELEVATOR BACK MAPS - REMEMBER (-1)!!\r
38 //\r
39 int ElevatorBackTo[]={1,1,7,3,5,3};\r
40 \r
41 void ScanInfoPlane (void);\r
42 void SetupGameLevel (void);\r
43 void DrawPlayScreen (void);\r
44 void LoadLatchMem (void);\r
45 void GameLoop (void);\r
46 \r
47 /*\r
48 =============================================================================\r
49 \r
50                                                  LOCAL VARIABLES\r
51 \r
52 =============================================================================\r
53 */\r
54 \r
55 \r
56 \r
57 //===========================================================================\r
58 //===========================================================================\r
59 \r
60 \r
61 /*\r
62 ==========================\r
63 =\r
64 = SetSoundLoc - Given the location of an object (in terms of global\r
65 =       coordinates, held in globalsoundx and globalsoundy), munges the values\r
66 =       for an approximate distance from the left and right ear, and puts\r
67 =       those values into leftchannel and rightchannel.\r
68 =\r
69 = JAB\r
70 =\r
71 ==========================\r
72 */\r
73 \r
74         fixed   globalsoundx,globalsoundy;\r
75         int             leftchannel,rightchannel;\r
76 #define ATABLEMAX 15\r
77 byte righttable[ATABLEMAX][ATABLEMAX * 2] = {\r
78 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 0, 0, 0, 0, 0, 1, 3, 5, 8, 8, 8, 8, 8, 8, 8, 8},\r
79 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 4, 0, 0, 0, 0, 0, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},\r
80 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 4, 1, 0, 0, 0, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8},\r
81 { 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 6, 5, 4, 2, 1, 0, 1, 2, 3, 5, 7, 8, 8, 8, 8, 8, 8, 8, 8},\r
82 { 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 5, 4, 3, 2, 2, 3, 3, 5, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
83 { 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 4, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
84 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 5, 5, 6, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
85 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 6, 6, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
86 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
87 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
88 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
89 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
90 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
91 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
92 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}\r
93 };\r
94 byte lefttable[ATABLEMAX][ATABLEMAX * 2] = {\r
95 { 8, 8, 8, 8, 8, 8, 8, 8, 5, 3, 1, 0, 0, 0, 0, 0, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8},\r
96 { 8, 8, 8, 8, 8, 8, 8, 8, 6, 4, 2, 0, 0, 0, 0, 0, 4, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8},\r
97 { 8, 8, 8, 8, 8, 8, 8, 8, 6, 4, 2, 1, 0, 0, 0, 1, 4, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8},\r
98 { 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 3, 2, 1, 0, 1, 2, 4, 5, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8},\r
99 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 5, 3, 3, 2, 2, 3, 4, 5, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8},\r
100 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 4, 4, 4, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8},\r
101 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 6, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
102 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
103 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
104 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
105 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
106 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
107 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
108 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\r
109 { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}\r
110 };\r
111 \r
112 void\r
113 SetSoundLoc(fixed gx,fixed gy)\r
114 {\r
115         fixed   xt,yt;\r
116         int             x,y;\r
117 \r
118 //\r
119 // translate point to view centered coordinates\r
120 //\r
121         gx -= viewx;\r
122         gy -= viewy;\r
123 \r
124 //\r
125 // calculate newx\r
126 //\r
127         xt = FixedByFrac(gx,viewcos);\r
128         yt = FixedByFrac(gy,viewsin);\r
129         x = (xt - yt) >> TILESHIFT;\r
130 \r
131 //\r
132 // calculate newy\r
133 //\r
134         xt = FixedByFrac(gx,viewsin);\r
135         yt = FixedByFrac(gy,viewcos);\r
136         y = (yt + xt) >> TILESHIFT;\r
137 \r
138         if (y >= ATABLEMAX)\r
139                 y = ATABLEMAX - 1;\r
140         else if (y <= -ATABLEMAX)\r
141                 y = -ATABLEMAX;\r
142         if (x < 0)\r
143                 x = -x;\r
144         if (x >= ATABLEMAX)\r
145                 x = ATABLEMAX - 1;\r
146         leftchannel  =  lefttable[x][y + ATABLEMAX];\r
147         rightchannel = righttable[x][y + ATABLEMAX];\r
148 \r
149 #if 0\r
150         CenterWindow(8,1);\r
151         US_PrintSigned(leftchannel);\r
152         US_Print(",");\r
153         US_PrintSigned(rightchannel);\r
154         VW_UpdateScreen();\r
155 #endif\r
156 }\r
157 \r
158 /*\r
159 ==========================\r
160 =\r
161 = SetSoundLocGlobal - Sets up globalsoundx & globalsoundy and then calls\r
162 =       UpdateSoundLoc() to transform that into relative channel volumes. Those\r
163 =       values are then passed to the Sound Manager so that they'll be used for\r
164 =       the next sound played (if possible).\r
165 =\r
166 = JAB\r
167 =\r
168 ==========================\r
169 */\r
170 void PlaySoundLocGlobal(word s,fixed gx,fixed gy)\r
171 {\r
172         SetSoundLoc(gx,gy);\r
173         SD_PositionSound(leftchannel,rightchannel);\r
174         if (SD_PlaySound(s))\r
175         {\r
176                 globalsoundx = gx;\r
177                 globalsoundy = gy;\r
178         }\r
179 }\r
180 \r
181 void UpdateSoundLoc(void)\r
182 {\r
183         if (SoundPositioned)\r
184         {\r
185                 SetSoundLoc(globalsoundx,globalsoundy);\r
186                 SD_SetPosition(leftchannel,rightchannel);\r
187         }\r
188 }\r
189 \r
190 /*\r
191 **      JAB End\r
192 */\r
193 \r
194 \r
195 /*\r
196 ==========================\r
197 =\r
198 = ClearMemory\r
199 =\r
200 ==========================\r
201 */\r
202 \r
203 void ClearMemory (void)\r
204 {\r
205         PM_UnlockMainMem();\r
206         SD_StopDigitized();\r
207         MM_SortMem ();\r
208 }\r
209 \r
210 \r
211 /*\r
212 ==========================\r
213 =\r
214 = ScanInfoPlane\r
215 =\r
216 = Spawn all actors and mark down special places\r
217 =\r
218 ==========================\r
219 */\r
220 \r
221 void ScanInfoPlane (void)\r
222 {\r
223         unsigned        x,y,i,j;\r
224         int                     tile;\r
225         unsigned        far     *start;\r
226 \r
227         start = mapsegs[1];\r
228         for (y=0;y<mapheight;y++)\r
229                 for (x=0;x<mapwidth;x++)\r
230                 {\r
231                         tile = *start++;\r
232                         if (!tile)\r
233                                 continue;\r
234 \r
235                         switch (tile)\r
236                         {\r
237                         case 19:\r
238                         case 20:\r
239                         case 21:\r
240                         case 22:\r
241                                 SpawnPlayer(x,y,NORTH+tile-19);\r
242                                 break;\r
243 \r
244                         case 23:\r
245                         case 24:\r
246                         case 25:\r
247                         case 26:\r
248                         case 27:\r
249                         case 28:\r
250                         case 29:\r
251                         case 30:\r
252 \r
253                         case 31:\r
254                         case 32:\r
255                         case 33:\r
256                         case 34:\r
257                         case 35:\r
258                         case 36:\r
259                         case 37:\r
260                         case 38:\r
261 \r
262                         case 39:\r
263                         case 40:\r
264                         case 41:\r
265                         case 42:\r
266                         case 43:\r
267                         case 44:\r
268                         case 45:\r
269                         case 46:\r
270 \r
271                         case 47:\r
272                         case 48:\r
273                         case 49:\r
274                         case 50:\r
275                         case 51:\r
276                         case 52:\r
277                         case 53:\r
278                         case 54:\r
279 \r
280                         case 55:\r
281                         case 56:\r
282                         case 57:\r
283                         case 58:\r
284                         case 59:\r
285                         case 60:\r
286                         case 61:\r
287                         case 62:\r
288 \r
289                         case 63:\r
290                         case 64:\r
291                         case 65:\r
292                         case 66:\r
293                         case 67:\r
294                         case 68:\r
295                         case 69:\r
296                         case 70:\r
297                         case 71:\r
298                         case 72:\r
299                         case 73:                                                // TRUCK AND SPEAR!\r
300                         case 74:\r
301 \r
302                                 SpawnStatic(x,y,tile-23);\r
303                                 break;\r
304 \r
305 //\r
306 // P wall\r
307 //\r
308                         case 98:\r
309                                 if (!loadedgame)\r
310                                   gamestate.secrettotal++;\r
311                                 break;\r
312 \r
313 //\r
314 // guard\r
315 //\r
316                         case 180:\r
317                         case 181:\r
318                         case 182:\r
319                         case 183:\r
320                                 if (gamestate.difficulty<gd_hard)\r
321                                         break;\r
322                                 tile -= 36;\r
323                         case 144:\r
324                         case 145:\r
325                         case 146:\r
326                         case 147:\r
327                                 if (gamestate.difficulty<gd_medium)\r
328                                         break;\r
329                                 tile -= 36;\r
330                         case 108:\r
331                         case 109:\r
332                         case 110:\r
333                         case 111:\r
334                                 SpawnStand(en_guard,x,y,tile-108);\r
335                                 break;\r
336 \r
337 \r
338                         case 184:\r
339                         case 185:\r
340                         case 186:\r
341                         case 187:\r
342                                 if (gamestate.difficulty<gd_hard)\r
343                                         break;\r
344                                 tile -= 36;\r
345                         case 148:\r
346                         case 149:\r
347                         case 150:\r
348                         case 151:\r
349                                 if (gamestate.difficulty<gd_medium)\r
350                                         break;\r
351                                 tile -= 36;\r
352                         case 112:\r
353                         case 113:\r
354                         case 114:\r
355                         case 115:\r
356                                 SpawnPatrol(en_guard,x,y,tile-112);\r
357                                 break;\r
358 \r
359                         case 124:\r
360                                 SpawnDeadGuard (x,y);\r
361                                 break;\r
362 //\r
363 // officer\r
364 //\r
365                         case 188:\r
366                         case 189:\r
367                         case 190:\r
368                         case 191:\r
369                                 if (gamestate.difficulty<gd_hard)\r
370                                         break;\r
371                                 tile -= 36;\r
372                         case 152:\r
373                         case 153:\r
374                         case 154:\r
375                         case 155:\r
376                                 if (gamestate.difficulty<gd_medium)\r
377                                         break;\r
378                                 tile -= 36;\r
379                         case 116:\r
380                         case 117:\r
381                         case 118:\r
382                         case 119:\r
383                                 SpawnStand(en_officer,x,y,tile-116);\r
384                                 break;\r
385 \r
386 \r
387                         case 192:\r
388                         case 193:\r
389                         case 194:\r
390                         case 195:\r
391                                 if (gamestate.difficulty<gd_hard)\r
392                                         break;\r
393                                 tile -= 36;\r
394                         case 156:\r
395                         case 157:\r
396                         case 158:\r
397                         case 159:\r
398                                 if (gamestate.difficulty<gd_medium)\r
399                                         break;\r
400                                 tile -= 36;\r
401                         case 120:\r
402                         case 121:\r
403                         case 122:\r
404                         case 123:\r
405                                 SpawnPatrol(en_officer,x,y,tile-120);\r
406                                 break;\r
407 \r
408 \r
409 //\r
410 // ss\r
411 //\r
412                         case 198:\r
413                         case 199:\r
414                         case 200:\r
415                         case 201:\r
416                                 if (gamestate.difficulty<gd_hard)\r
417                                         break;\r
418                                 tile -= 36;\r
419                         case 162:\r
420                         case 163:\r
421                         case 164:\r
422                         case 165:\r
423                                 if (gamestate.difficulty<gd_medium)\r
424                                         break;\r
425                                 tile -= 36;\r
426                         case 126:\r
427                         case 127:\r
428                         case 128:\r
429                         case 129:\r
430                                 SpawnStand(en_ss,x,y,tile-126);\r
431                                 break;\r
432 \r
433 \r
434                         case 202:\r
435                         case 203:\r
436                         case 204:\r
437                         case 205:\r
438                                 if (gamestate.difficulty<gd_hard)\r
439                                         break;\r
440                                 tile -= 36;\r
441                         case 166:\r
442                         case 167:\r
443                         case 168:\r
444                         case 169:\r
445                                 if (gamestate.difficulty<gd_medium)\r
446                                         break;\r
447                                 tile -= 36;\r
448                         case 130:\r
449                         case 131:\r
450                         case 132:\r
451                         case 133:\r
452                                 SpawnPatrol(en_ss,x,y,tile-130);\r
453                                 break;\r
454 \r
455 //\r
456 // dogs\r
457 //\r
458                         case 206:\r
459                         case 207:\r
460                         case 208:\r
461                         case 209:\r
462                                 if (gamestate.difficulty<gd_hard)\r
463                                         break;\r
464                                 tile -= 36;\r
465                         case 170:\r
466                         case 171:\r
467                         case 172:\r
468                         case 173:\r
469                                 if (gamestate.difficulty<gd_medium)\r
470                                         break;\r
471                                 tile -= 36;\r
472                         case 134:\r
473                         case 135:\r
474                         case 136:\r
475                         case 137:\r
476                                 SpawnStand(en_dog,x,y,tile-134);\r
477                                 break;\r
478 \r
479 \r
480                         case 210:\r
481                         case 211:\r
482                         case 212:\r
483                         case 213:\r
484                                 if (gamestate.difficulty<gd_hard)\r
485                                         break;\r
486                                 tile -= 36;\r
487                         case 174:\r
488                         case 175:\r
489                         case 176:\r
490                         case 177:\r
491                                 if (gamestate.difficulty<gd_medium)\r
492                                         break;\r
493                                 tile -= 36;\r
494                         case 138:\r
495                         case 139:\r
496                         case 140:\r
497                         case 141:\r
498                                 SpawnPatrol(en_dog,x,y,tile-138);\r
499                                 break;\r
500 \r
501 //\r
502 // boss\r
503 //\r
504 #ifndef SPEAR\r
505                         case 214:\r
506                                 SpawnBoss (x,y);\r
507                                 break;\r
508                         case 197:\r
509                                 SpawnGretel (x,y);\r
510                                 break;\r
511                         case 215:\r
512                                 SpawnGift (x,y);\r
513                                 break;\r
514                         case 179:\r
515                                 SpawnFat (x,y);\r
516                                 break;\r
517                         case 196:\r
518                                 SpawnSchabbs (x,y);\r
519                                 break;\r
520                         case 160:\r
521                                 SpawnFakeHitler (x,y);\r
522                                 break;\r
523                         case 178:\r
524                                 SpawnHitler (x,y);\r
525                                 break;\r
526 #else\r
527                         case 106:\r
528                                 SpawnSpectre (x,y);\r
529                                 break;\r
530                         case 107:\r
531                                 SpawnAngel (x,y);\r
532                                 break;\r
533                         case 125:\r
534                                 SpawnTrans (x,y);\r
535                                 break;\r
536                         case 142:\r
537                                 SpawnUber (x,y);\r
538                                 break;\r
539                         case 143:\r
540                                 SpawnWill (x,y);\r
541                                 break;\r
542                         case 161:\r
543                                 SpawnDeath (x,y);\r
544                                 break;\r
545 \r
546 #endif\r
547 \r
548 //\r
549 // mutants\r
550 //\r
551                         case 252:\r
552                         case 253:\r
553                         case 254:\r
554                         case 255:\r
555                                 if (gamestate.difficulty<gd_hard)\r
556                                         break;\r
557                                 tile -= 18;\r
558                         case 234:\r
559                         case 235:\r
560                         case 236:\r
561                         case 237:\r
562                                 if (gamestate.difficulty<gd_medium)\r
563                                         break;\r
564                                 tile -= 18;\r
565                         case 216:\r
566                         case 217:\r
567                         case 218:\r
568                         case 219:\r
569                                 SpawnStand(en_mutant,x,y,tile-216);\r
570                                 break;\r
571 \r
572                         case 256:\r
573                         case 257:\r
574                         case 258:\r
575                         case 259:\r
576                                 if (gamestate.difficulty<gd_hard)\r
577                                         break;\r
578                                 tile -= 18;\r
579                         case 238:\r
580                         case 239:\r
581                         case 240:\r
582                         case 241:\r
583                                 if (gamestate.difficulty<gd_medium)\r
584                                         break;\r
585                                 tile -= 18;\r
586                         case 220:\r
587                         case 221:\r
588                         case 222:\r
589                         case 223:\r
590                                 SpawnPatrol(en_mutant,x,y,tile-220);\r
591                                 break;\r
592 \r
593 //\r
594 // ghosts\r
595 //\r
596 #ifndef SPEAR\r
597                         case 224:\r
598                                 SpawnGhosts (en_blinky,x,y);\r
599                                 break;\r
600                         case 225:\r
601                                 SpawnGhosts (en_clyde,x,y);\r
602                                 break;\r
603                         case 226:\r
604                                 SpawnGhosts (en_pinky,x,y);\r
605                                 break;\r
606                         case 227:\r
607                                 SpawnGhosts (en_inky,x,y);\r
608                                 break;\r
609 #endif\r
610                         }\r
611 \r
612                 }\r
613 }\r
614 \r
615 //==========================================================================\r
616 \r
617 /*\r
618 ==================\r
619 =\r
620 = SetupGameLevel\r
621 =\r
622 ==================\r
623 */\r
624 \r
625 void SetupGameLevel (void)\r
626 {\r
627         int     x,y,i;\r
628         unsigned        far *map,tile,spot;\r
629 \r
630 \r
631         if (!loadedgame)\r
632         {\r
633          gamestate.TimeCount=\r
634          gamestate.secrettotal=\r
635          gamestate.killtotal=\r
636          gamestate.treasuretotal=\r
637          gamestate.secretcount=\r
638          gamestate.killcount=\r
639          gamestate.treasurecount=0;\r
640         }\r
641 \r
642         if (demoplayback || demorecord)\r
643                 US_InitRndT (false);\r
644         else\r
645                 US_InitRndT (true);\r
646 \r
647 //\r
648 // load the level\r
649 //\r
650         CA_CacheMap (gamestate.mapon+10*gamestate.episode);\r
651         mapon-=gamestate.episode*10;\r
652 \r
653         mapwidth = mapheaderseg[mapon]->width;\r
654         mapheight = mapheaderseg[mapon]->height;\r
655 \r
656         if (mapwidth != 64 || mapheight != 64)\r
657                 Quit ("Map not 64*64!");\r
658 \r
659 \r
660 //\r
661 // copy the wall data to a data segment array\r
662 //\r
663         memset (tilemap,0,sizeof(tilemap));\r
664         memset (actorat,0,sizeof(actorat));\r
665         map = mapsegs[0];\r
666         for (y=0;y<mapheight;y++)\r
667                 for (x=0;x<mapwidth;x++)\r
668                 {\r
669                         tile = *map++;\r
670                         if (tile<AREATILE)\r
671                         {\r
672                         // solid wall\r
673                                 tilemap[x][y] = tile;\r
674                                 (unsigned)actorat[x][y] = tile;\r
675                         }\r
676                         else\r
677                         {\r
678                         // area floor\r
679                                 tilemap[x][y] = 0;\r
680                                 (unsigned)actorat[x][y] = 0;\r
681                         }\r
682                 }\r
683 \r
684 //\r
685 // spawn doors\r
686 //\r
687         InitActorList ();                       // start spawning things with a clean slate\r
688         InitDoorList ();\r
689         InitStaticList ();\r
690 \r
691         map = mapsegs[0];\r
692         for (y=0;y<mapheight;y++)\r
693                 for (x=0;x<mapwidth;x++)\r
694                 {\r
695                         tile = *map++;\r
696                         if (tile >= 90 && tile <= 101)\r
697                         {\r
698                         // door\r
699                                 switch (tile)\r
700                                 {\r
701                                 case 90:\r
702                                 case 92:\r
703                                 case 94:\r
704                                 case 96:\r
705                                 case 98:\r
706                                 case 100:\r
707                                         SpawnDoor (x,y,1,(tile-90)/2);\r
708                                         break;\r
709                                 case 91:\r
710                                 case 93:\r
711                                 case 95:\r
712                                 case 97:\r
713                                 case 99:\r
714                                 case 101:\r
715                                         SpawnDoor (x,y,0,(tile-91)/2);\r
716                                         break;\r
717                                 }\r
718                         }\r
719                 }\r
720 \r
721 //\r
722 // spawn actors\r
723 //\r
724         ScanInfoPlane ();\r
725 \r
726 //\r
727 // take out the ambush markers\r
728 //\r
729         map = mapsegs[0];\r
730         for (y=0;y<mapheight;y++)\r
731                 for (x=0;x<mapwidth;x++)\r
732                 {\r
733                         tile = *map++;\r
734                         if (tile == AMBUSHTILE)\r
735                         {\r
736                                 tilemap[x][y] = 0;\r
737                                 if ( (unsigned)actorat[x][y] == AMBUSHTILE)\r
738                                         actorat[x][y] = NULL;\r
739 \r
740                                 if (*map >= AREATILE)\r
741                                         tile = *map;\r
742                                 if (*(map-1-mapwidth) >= AREATILE)\r
743                                         tile = *(map-1-mapwidth);\r
744                                 if (*(map-1+mapwidth) >= AREATILE)\r
745                                         tile = *(map-1+mapwidth);\r
746                                 if ( *(map-2) >= AREATILE)\r
747                                         tile = *(map-2);\r
748 \r
749                                 *(map-1) = tile;\r
750                         }\r
751                 }\r
752 \r
753 \r
754 \r
755 //\r
756 // have the caching manager load and purge stuff to make sure all marks\r
757 // are in memory\r
758 //\r
759         CA_LoadAllSounds ();\r
760 \r
761 }\r
762 \r
763 \r
764 //==========================================================================\r
765 \r
766 \r
767 /*\r
768 ===================\r
769 =\r
770 = DrawPlayBorderSides\r
771 =\r
772 = To fix window overwrites\r
773 =\r
774 ===================\r
775 */\r
776 \r
777 void DrawPlayBorderSides (void)\r
778 {\r
779         int     xl,yl;\r
780 \r
781         xl = 160-viewwidth/2;\r
782         yl = (200-STATUSLINES-viewheight)/2;\r
783 \r
784         VWB_Bar (0,0,xl-1,200-STATUSLINES,127);\r
785         VWB_Bar (xl+viewwidth+1,0,xl-2,200-STATUSLINES,127);\r
786 \r
787         VWB_Vlin (yl-1,yl+viewheight,xl-1,0);\r
788         VWB_Vlin (yl-1,yl+viewheight,xl+viewwidth,125);\r
789 }\r
790 \r
791 \r
792 /*\r
793 ===================\r
794 =\r
795 = DrawAllPlayBorderSides\r
796 =\r
797 ===================\r
798 */\r
799 \r
800 void DrawAllPlayBorderSides (void)\r
801 {\r
802         unsigned        i,temp;\r
803 \r
804         temp = bufferofs;\r
805         for (i=0;i<3;i++)\r
806         {\r
807                 bufferofs = screenloc[i];\r
808                 DrawPlayBorderSides ();\r
809         }\r
810         bufferofs = temp;\r
811 }\r
812 \r
813 /*\r
814 ===================\r
815 =\r
816 = DrawPlayBorder\r
817 =\r
818 ===================\r
819 */\r
820 void DrawAllPlayBorder (void)\r
821 {\r
822         unsigned        i,temp;\r
823 \r
824         temp = bufferofs;\r
825         for (i=0;i<3;i++)\r
826         {\r
827                 bufferofs = screenloc[i];\r
828                 DrawPlayBorder ();\r
829         }\r
830         bufferofs = temp;\r
831 }\r
832 \r
833 /*\r
834 ===================\r
835 =\r
836 = DrawPlayBorder\r
837 =\r
838 ===================\r
839 */\r
840 \r
841 void DrawPlayBorder (void)\r
842 {\r
843         int     xl,yl;\r
844 \r
845         VWB_Bar (0,0,320,200-STATUSLINES,127);\r
846 \r
847         xl = 160-viewwidth/2;\r
848         yl = (200-STATUSLINES-viewheight)/2;\r
849         VWB_Bar (xl,yl,viewwidth,viewheight,0);\r
850 \r
851         VWB_Hlin (xl-1,xl+viewwidth,yl-1,0);\r
852         VWB_Hlin (xl-1,xl+viewwidth,yl+viewheight,125);\r
853         VWB_Vlin (yl-1,yl+viewheight,xl-1,0);\r
854         VWB_Vlin (yl-1,yl+viewheight,xl+viewwidth,125);\r
855         VWB_Plot (xl-1,yl+viewheight,124);\r
856 }\r
857 \r
858 \r
859 \r
860 /*\r
861 ===================\r
862 =\r
863 = DrawPlayScreen\r
864 =\r
865 ===================\r
866 */\r
867 \r
868 void DrawPlayScreen (void)\r
869 {\r
870         int     i,j,p,m;\r
871         unsigned        temp;\r
872 \r
873         VW_FadeOut ();\r
874 \r
875         temp = bufferofs;\r
876 \r
877         CA_CacheGrChunk (STATUSBARPIC);\r
878 \r
879         for (i=0;i<3;i++)\r
880         {\r
881                 bufferofs = screenloc[i];\r
882                 DrawPlayBorder ();\r
883                 VWB_DrawPic (0,200-STATUSLINES,STATUSBARPIC);\r
884         }\r
885 \r
886         bufferofs = temp;\r
887 \r
888         UNCACHEGRCHUNK (STATUSBARPIC);\r
889 \r
890         DrawFace ();\r
891         DrawHealth ();\r
892         DrawLives ();\r
893         DrawLevel ();\r
894         DrawAmmo ();\r
895         DrawKeys ();\r
896         DrawWeapon ();\r
897         DrawScore ();\r
898 }\r
899 \r
900 \r
901 \r
902 //==========================================================================\r
903 \r
904 /*\r
905 ==================\r
906 =\r
907 = StartDemoRecord\r
908 =\r
909 ==================\r
910 */\r
911 \r
912 #define MAXDEMOSIZE     8192\r
913 \r
914 void StartDemoRecord (int levelnumber)\r
915 {\r
916         MM_GetPtr (&demobuffer,MAXDEMOSIZE);\r
917         MM_SetLock (&demobuffer,true);\r
918         demoptr = (char far *)demobuffer;\r
919         lastdemoptr = demoptr+MAXDEMOSIZE;\r
920 \r
921         *demoptr = levelnumber;\r
922         demoptr += 4;                           // leave space for length\r
923         demorecord = true;\r
924 }\r
925 \r
926 \r
927 /*\r
928 ==================\r
929 =\r
930 = FinishDemoRecord\r
931 =\r
932 ==================\r
933 */\r
934 \r
935 char    demoname[13] = "DEMO?.";\r
936 \r
937 void FinishDemoRecord (void)\r
938 {\r
939         long    length,level;\r
940 \r
941         demorecord = false;\r
942 \r
943         length = demoptr - (char far *)demobuffer;\r
944 \r
945         demoptr = ((char far *)demobuffer)+1;\r
946         *(unsigned far *)demoptr = length;\r
947 \r
948         CenterWindow(24,3);\r
949         PrintY+=6;\r
950         US_Print(" Demo number (0-9):");\r
951         VW_UpdateScreen();\r
952 \r
953         if (US_LineInput (px,py,str,NULL,true,2,0))\r
954         {\r
955                 level = atoi (str);\r
956                 if (level>=0 && level<=9)\r
957                 {\r
958                         demoname[4] = '0'+level;\r
959                         CA_WriteFile (demoname,(void far *)demobuffer,length);\r
960                 }\r
961         }\r
962 \r
963 \r
964         MM_FreePtr (&demobuffer);\r
965 }\r
966 \r
967 //==========================================================================\r
968 \r
969 /*\r
970 ==================\r
971 =\r
972 = RecordDemo\r
973 =\r
974 = Fades the screen out, then starts a demo.  Exits with the screen faded\r
975 =\r
976 ==================\r
977 */\r
978 \r
979 void RecordDemo (void)\r
980 {\r
981         int level,esc;\r
982 \r
983         CenterWindow(26,3);\r
984         PrintY+=6;\r
985         CA_CacheGrChunk(STARTFONT);\r
986         fontnumber=0;\r
987         US_Print("  Demo which level(1-10):");\r
988         VW_UpdateScreen();\r
989         VW_FadeIn ();\r
990         esc = !US_LineInput (px,py,str,NULL,true,2,0);\r
991         if (esc)\r
992                 return;\r
993 \r
994         level = atoi (str);\r
995         level--;\r
996 \r
997         SETFONTCOLOR(0,15);\r
998         VW_FadeOut ();\r
999 \r
1000 #ifndef SPEAR\r
1001         NewGame (gd_hard,level/10);\r
1002         gamestate.mapon = level%10;\r
1003 #else\r
1004         NewGame (gd_hard,0);\r
1005         gamestate.mapon = level;\r
1006 #endif\r
1007 \r
1008         StartDemoRecord (level);\r
1009 \r
1010         DrawPlayScreen ();\r
1011         VW_FadeIn ();\r
1012 \r
1013         startgame = false;\r
1014         demorecord = true;\r
1015 \r
1016         SetupGameLevel ();\r
1017         StartMusic ();\r
1018         PM_CheckMainMem ();\r
1019         fizzlein = true;\r
1020 \r
1021         PlayLoop ();\r
1022 \r
1023         demoplayback = false;\r
1024 \r
1025         StopMusic ();\r
1026         VW_FadeOut ();\r
1027         ClearMemory ();\r
1028 \r
1029         FinishDemoRecord ();\r
1030 }\r
1031 \r
1032 //==========================================================================\r
1033 \r
1034 /*\r
1035 ==================\r
1036 =\r
1037 = PlayDemo\r
1038 =\r
1039 = Fades the screen out, then starts a demo.  Exits with the screen faded\r
1040 =\r
1041 ==================\r
1042 */\r
1043 \r
1044 void PlayDemo (int demonumber)\r
1045 {\r
1046         int length;\r
1047 \r
1048 #ifdef DEMOSEXTERN\r
1049 // debug: load chunk\r
1050 #ifndef SPEARDEMO\r
1051         int dems[4]={T_DEMO0,T_DEMO1,T_DEMO2,T_DEMO3};\r
1052 #else\r
1053         int dems[1]={T_DEMO0};\r
1054 #endif\r
1055 \r
1056         CA_CacheGrChunk(dems[demonumber]);\r
1057         demoptr = grsegs[dems[demonumber]];\r
1058         MM_SetLock (&grsegs[dems[demonumber]],true);\r
1059 #else\r
1060         demoname[4] = '0'+demonumber;\r
1061         CA_LoadFile (demoname,&demobuffer);\r
1062         MM_SetLock (&demobuffer,true);\r
1063         demoptr = (char far *)demobuffer;\r
1064 #endif\r
1065 \r
1066         NewGame (1,0);\r
1067         gamestate.mapon = *demoptr++;\r
1068         gamestate.difficulty = gd_hard;\r
1069         length = *((unsigned far *)demoptr)++;\r
1070         demoptr++;\r
1071         lastdemoptr = demoptr-4+length;\r
1072 \r
1073         VW_FadeOut ();\r
1074 \r
1075         SETFONTCOLOR(0,15);\r
1076         DrawPlayScreen ();\r
1077         VW_FadeIn ();\r
1078 \r
1079         startgame = false;\r
1080         demoplayback = true;\r
1081 \r
1082         SetupGameLevel ();\r
1083         StartMusic ();\r
1084         PM_CheckMainMem ();\r
1085         fizzlein = true;\r
1086 \r
1087         PlayLoop ();\r
1088 \r
1089 #ifdef DEMOSEXTERN\r
1090         UNCACHEGRCHUNK(dems[demonumber]);\r
1091 #else\r
1092         MM_FreePtr (&demobuffer);\r
1093 #endif\r
1094 \r
1095         demoplayback = false;\r
1096 \r
1097         StopMusic ();\r
1098         VW_FadeOut ();\r
1099         ClearMemory ();\r
1100 }\r
1101 \r
1102 //==========================================================================\r
1103 \r
1104 /*\r
1105 ==================\r
1106 =\r
1107 = Died\r
1108 =\r
1109 ==================\r
1110 */\r
1111 \r
1112 #define DEATHROTATE 2\r
1113 \r
1114 void Died (void)\r
1115 {\r
1116         float   fangle;\r
1117         long    dx,dy;\r
1118         int             iangle,curangle,clockwise,counter,change;\r
1119 \r
1120         gamestate.weapon = -1;                  // take away weapon\r
1121         SD_PlaySound (PLAYERDEATHSND);\r
1122 //\r
1123 // swing around to face attacker\r
1124 //\r
1125         dx = killerobj->x - player->x;\r
1126         dy = player->y - killerobj->y;\r
1127 \r
1128         fangle = atan2(dy,dx);                  // returns -pi to pi\r
1129         if (fangle<0)\r
1130                 fangle = M_PI*2+fangle;\r
1131 \r
1132         iangle = fangle/(M_PI*2)*ANGLES;\r
1133 \r
1134         if (player->angle > iangle)\r
1135         {\r
1136                 counter = player->angle - iangle;\r
1137                 clockwise = ANGLES-player->angle + iangle;\r
1138         }\r
1139         else\r
1140         {\r
1141                 clockwise = iangle - player->angle;\r
1142                 counter = player->angle + ANGLES-iangle;\r
1143         }\r
1144 \r
1145         curangle = player->angle;\r
1146 \r
1147         if (clockwise<counter)\r
1148         {\r
1149         //\r
1150         // rotate clockwise\r
1151         //\r
1152                 if (curangle>iangle)\r
1153                         curangle -= ANGLES;\r
1154                 do\r
1155                 {\r
1156                         change = tics*DEATHROTATE;\r
1157                         if (curangle + change > iangle)\r
1158                                 change = iangle-curangle;\r
1159 \r
1160                         curangle += change;\r
1161                         player->angle += change;\r
1162                         if (player->angle >= ANGLES)\r
1163                                 player->angle -= ANGLES;\r
1164 \r
1165                         ThreeDRefresh ();\r
1166                         CalcTics ();\r
1167                 } while (curangle != iangle);\r
1168         }\r
1169         else\r
1170         {\r
1171         //\r
1172         // rotate counterclockwise\r
1173         //\r
1174                 if (curangle<iangle)\r
1175                         curangle += ANGLES;\r
1176                 do\r
1177                 {\r
1178                         change = -tics*DEATHROTATE;\r
1179                         if (curangle + change < iangle)\r
1180                                 change = iangle-curangle;\r
1181 \r
1182                         curangle += change;\r
1183                         player->angle += change;\r
1184                         if (player->angle < 0)\r
1185                                 player->angle += ANGLES;\r
1186 \r
1187                         ThreeDRefresh ();\r
1188                         CalcTics ();\r
1189                 } while (curangle != iangle);\r
1190         }\r
1191 \r
1192 //\r
1193 // fade to red\r
1194 //\r
1195         FinishPaletteShifts ();\r
1196 \r
1197         bufferofs += screenofs;\r
1198         VW_Bar (0,0,viewwidth,viewheight,4);\r
1199         IN_ClearKeysDown ();\r
1200         FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,70,false);\r
1201         bufferofs -= screenofs;\r
1202         IN_UserInput(100);\r
1203         SD_WaitSoundDone ();\r
1204 \r
1205         if (tedlevel == false)  // SO'S YA DON'T GET KILLED WHILE LAUNCHING!\r
1206           gamestate.lives--;\r
1207 \r
1208         if (gamestate.lives > -1)\r
1209         {\r
1210                 gamestate.health = 100;\r
1211                 gamestate.weapon = gamestate.bestweapon\r
1212                         = gamestate.chosenweapon = wp_pistol;\r
1213                 gamestate.ammo = STARTAMMO;\r
1214                 gamestate.keys = 0;\r
1215                 gamestate.attackframe = gamestate.attackcount =\r
1216                 gamestate.weaponframe = 0;\r
1217 \r
1218                 DrawKeys ();\r
1219                 DrawWeapon ();\r
1220                 DrawAmmo ();\r
1221                 DrawHealth ();\r
1222                 DrawFace ();\r
1223                 DrawLives ();\r
1224         }\r
1225 \r
1226 }\r
1227 \r
1228 //==========================================================================\r
1229 \r
1230 /*\r
1231 ===================\r
1232 =\r
1233 = GameLoop\r
1234 =\r
1235 ===================\r
1236 */\r
1237 \r
1238 void GameLoop (void)\r
1239 {\r
1240         int i,xl,yl,xh,yh;\r
1241         char num[20];\r
1242         boolean died;\r
1243 #ifdef MYPROFILE\r
1244         clock_t start,end;\r
1245 #endif\r
1246 \r
1247 restartgame:\r
1248         ClearMemory ();\r
1249         SETFONTCOLOR(0,15);\r
1250         DrawPlayScreen ();\r
1251         died = false;\r
1252 restart:\r
1253         do\r
1254         {\r
1255                 if (!loadedgame)\r
1256                   gamestate.score = gamestate.oldscore;\r
1257                 DrawScore();\r
1258 \r
1259                 startgame = false;\r
1260                 if (loadedgame)\r
1261                         loadedgame = false;\r
1262                 else\r
1263                         SetupGameLevel ();\r
1264 \r
1265 #ifdef SPEAR\r
1266                 if (gamestate.mapon == 20)      // give them the key allways\r
1267                 {\r
1268                         gamestate.keys |= 1;\r
1269                         DrawKeys ();\r
1270                 }\r
1271 #endif\r
1272 \r
1273                 ingame = true;\r
1274                 StartMusic ();\r
1275                 PM_CheckMainMem ();\r
1276                 if (!died)\r
1277                         PreloadGraphics ();\r
1278                 else\r
1279                         died = false;\r
1280 \r
1281                 fizzlein = true;\r
1282                 DrawLevel ();\r
1283 \r
1284 startplayloop:\r
1285                 PlayLoop ();\r
1286 \r
1287 #ifdef SPEAR\r
1288                 if (spearflag)\r
1289                 {\r
1290                         SD_StopSound();\r
1291                         SD_PlaySound(GETSPEARSND);\r
1292                         if (DigiMode != sds_Off)\r
1293                         {\r
1294                                 long lasttimecount = TimeCount;\r
1295 \r
1296                                 while(TimeCount < lasttimecount+150)\r
1297                                 //while(DigiPlaying!=false)\r
1298                                         SD_Poll();\r
1299                         }\r
1300                         else\r
1301                                 SD_WaitSoundDone();\r
1302 \r
1303                         ClearMemory ();\r
1304                         gamestate.oldscore = gamestate.score;\r
1305                         gamestate.mapon = 20;\r
1306                         SetupGameLevel ();\r
1307                         StartMusic ();\r
1308                         PM_CheckMainMem ();\r
1309                         player->x = spearx;\r
1310                         player->y = speary;\r
1311                         player->angle = spearangle;\r
1312                         spearflag = false;\r
1313                         Thrust (0,0);\r
1314                         goto startplayloop;\r
1315                 }\r
1316 #endif\r
1317 \r
1318                 StopMusic ();\r
1319                 ingame = false;\r
1320 \r
1321                 if (demorecord && playstate != ex_warped)\r
1322                         FinishDemoRecord ();\r
1323 \r
1324                 if (startgame || loadedgame)\r
1325                         goto restartgame;\r
1326 \r
1327                 switch (playstate)\r
1328                 {\r
1329                 case ex_completed:\r
1330                 case ex_secretlevel:\r
1331                         gamestate.keys = 0;\r
1332                         DrawKeys ();\r
1333                         VW_FadeOut ();\r
1334 \r
1335                         ClearMemory ();\r
1336 \r
1337                         LevelCompleted ();              // do the intermission\r
1338 #ifdef SPEARDEMO\r
1339                         if (gamestate.mapon == 1)\r
1340                         {\r
1341                                 died = true;                    // don't "get psyched!"\r
1342 \r
1343                                 VW_FadeOut ();\r
1344 \r
1345                                 ClearMemory ();\r
1346 \r
1347                                 CheckHighScore (gamestate.score,gamestate.mapon+1);\r
1348 \r
1349                                 #pragma warn -sus\r
1350                                 #ifndef JAPAN\r
1351                                 _fstrcpy(MainMenu[viewscores].string,STR_VS);\r
1352                                 #endif\r
1353                                 MainMenu[viewscores].routine = CP_ViewScores;\r
1354                                 #pragma warn +sus\r
1355 \r
1356                                 return;\r
1357                         }\r
1358 #endif\r
1359 \r
1360 #ifdef JAPDEMO\r
1361                         if (gamestate.mapon == 3)\r
1362                         {\r
1363                                 died = true;                    // don't "get psyched!"\r
1364 \r
1365                                 VW_FadeOut ();\r
1366 \r
1367                                 ClearMemory ();\r
1368 \r
1369                                 CheckHighScore (gamestate.score,gamestate.mapon+1);\r
1370 \r
1371                                 #pragma warn -sus\r
1372                                 #ifndef JAPAN\r
1373                                 _fstrcpy(MainMenu[viewscores].string,STR_VS);\r
1374                                 #endif\r
1375                                 MainMenu[viewscores].routine = CP_ViewScores;\r
1376                                 #pragma warn +sus\r
1377 \r
1378                                 return;\r
1379                         }\r
1380 #endif\r
1381 \r
1382                         gamestate.oldscore = gamestate.score;\r
1383 \r
1384 #ifndef SPEAR\r
1385                         //\r
1386                         // COMING BACK FROM SECRET LEVEL\r
1387                         //\r
1388                         if (gamestate.mapon == 9)\r
1389                                 gamestate.mapon = ElevatorBackTo[gamestate.episode];    // back from secret\r
1390                         else\r
1391                         //\r
1392                         // GOING TO SECRET LEVEL\r
1393                         //\r
1394                         if (playstate == ex_secretlevel)\r
1395                                 gamestate.mapon = 9;\r
1396 #else\r
1397 \r
1398 #define FROMSECRET1             3\r
1399 #define FROMSECRET2             11\r
1400 \r
1401                         //\r
1402                         // GOING TO SECRET LEVEL\r
1403                         //\r
1404                         if (playstate == ex_secretlevel)\r
1405                                 switch(gamestate.mapon)\r
1406                                 {\r
1407                                  case FROMSECRET1: gamestate.mapon = 18; break;\r
1408                                  case FROMSECRET2: gamestate.mapon = 19; break;\r
1409                                 }\r
1410                         else\r
1411                         //\r
1412                         // COMING BACK FROM SECRET LEVEL\r
1413                         //\r
1414                         if (gamestate.mapon == 18 || gamestate.mapon == 19)\r
1415                                 switch(gamestate.mapon)\r
1416                                 {\r
1417                                  case 18: gamestate.mapon = FROMSECRET1+1; break;\r
1418                                  case 19: gamestate.mapon = FROMSECRET2+1; break;\r
1419                                 }\r
1420 #endif\r
1421                         else\r
1422                         //\r
1423                         // GOING TO NEXT LEVEL\r
1424                         //\r
1425                                 gamestate.mapon++;\r
1426 \r
1427 \r
1428                         break;\r
1429 \r
1430                 case ex_died:\r
1431                         Died ();\r
1432                         died = true;                    // don't "get psyched!"\r
1433 \r
1434                         if (gamestate.lives > -1)\r
1435                                 break;                          // more lives left\r
1436 \r
1437                         VW_FadeOut ();\r
1438 \r
1439                         ClearMemory ();\r
1440 \r
1441                         CheckHighScore (gamestate.score,gamestate.mapon+1);\r
1442 \r
1443                         #pragma warn -sus\r
1444                         #ifndef JAPAN\r
1445                         _fstrcpy(MainMenu[viewscores].string,STR_VS);\r
1446                         #endif\r
1447                         MainMenu[viewscores].routine = CP_ViewScores;\r
1448                         #pragma warn +sus\r
1449 \r
1450                         return;\r
1451 \r
1452                 case ex_victorious:\r
1453 \r
1454 #ifndef SPEAR\r
1455                         VW_FadeOut ();\r
1456 #else\r
1457                         VL_FadeOut (0,255,0,17,17,300);\r
1458 #endif\r
1459                         ClearMemory ();\r
1460 \r
1461                         Victory ();\r
1462 \r
1463                         ClearMemory ();\r
1464 \r
1465                         CheckHighScore (gamestate.score,gamestate.mapon+1);\r
1466 \r
1467                         #pragma warn -sus\r
1468                         #ifndef JAPAN\r
1469                         _fstrcpy(MainMenu[viewscores].string,STR_VS);\r
1470                         #endif\r
1471                         MainMenu[viewscores].routine = CP_ViewScores;\r
1472                         #pragma warn +sus\r
1473 \r
1474                         return;\r
1475 \r
1476                 default:\r
1477                         ClearMemory ();\r
1478                         break;\r
1479                 }\r
1480 \r
1481         } while (1);\r
1482 \r
1483 }\r
1484 \r