]> 4ch.mooo.com Git - 16.git/blob - 16/wf3d8086/wl_inter.c
code miraculously works on real hardware
[16.git] / 16 / wf3d8086 / wl_inter.c
1 // WL_INTER.C\r
2 \r
3 #include "WL_DEF.H"\r
4 #pragma hdrstop\r
5 \r
6 \r
7 //==========================================================================\r
8 \r
9 /*\r
10 ==================\r
11 =\r
12 = CLearSplitVWB\r
13 =\r
14 ==================\r
15 */\r
16 \r
17 void ClearSplitVWB (void)\r
18 {\r
19         memset (update,0,sizeof(update));\r
20         WindowX = 0;\r
21         WindowY = 0;\r
22         WindowW = 320;\r
23         WindowH = 160;\r
24 }\r
25 \r
26 \r
27 //==========================================================================\r
28 \r
29 #ifdef SPEAR\r
30 #ifndef SPEARDEMO\r
31 ////////////////////////////////////////////////////////\r
32 //\r
33 // End of Spear of Destiny\r
34 //\r
35 ////////////////////////////////////////////////////////\r
36 \r
37 void EndScreen (int palette, int screen)\r
38 {\r
39         CA_CacheScreen (screen);\r
40         VW_UpdateScreen ();\r
41         CA_CacheGrChunk (palette);\r
42         VL_FadeIn(0,255,grsegs[palette],30);\r
43         UNCACHEGRCHUNK (palette);\r
44         IN_ClearKeysDown ();\r
45         IN_Ack ();\r
46         VW_FadeOut ();\r
47 }\r
48 \r
49 \r
50 void EndSpear(void)\r
51 {\r
52         EndScreen (END1PALETTE, ENDSCREEN11PIC);\r
53 \r
54         CA_CacheScreen (ENDSCREEN3PIC);\r
55         VW_UpdateScreen ();\r
56         CA_CacheGrChunk (END3PALETTE);\r
57         VL_FadeIn(0,255,grsegs[END3PALETTE],30);\r
58         UNCACHEGRCHUNK (END3PALETTE);\r
59         fontnumber = 0;\r
60         fontcolor = 0xd0;\r
61         WindowX = 0;\r
62         WindowW = 320;\r
63         PrintX = 0;\r
64         PrintY = 180;\r
65         US_CPrint (STR_ENDGAME1"\n");\r
66         US_CPrint (STR_ENDGAME2);\r
67         VW_UpdateScreen ();\r
68         IN_StartAck ();\r
69         TimeCount = 0;\r
70         while (!IN_CheckAck () && TimeCount < 700);\r
71 \r
72         PrintX = 0;\r
73         PrintY = 180;\r
74         VWB_Bar(0,180,320,20,0);\r
75         US_CPrint (STR_ENDGAME3"\n");\r
76         US_CPrint (STR_ENDGAME4);\r
77         VW_UpdateScreen ();\r
78         IN_StartAck ();\r
79         TimeCount = 0;\r
80         while (!IN_CheckAck () && TimeCount < 700);\r
81 \r
82         VW_FadeOut ();\r
83 \r
84         EndScreen (END4PALETTE, ENDSCREEN4PIC);\r
85         EndScreen (END5PALETTE, ENDSCREEN5PIC);\r
86         EndScreen (END6PALETTE, ENDSCREEN6PIC);\r
87         EndScreen (END7PALETTE, ENDSCREEN7PIC);\r
88         EndScreen (END8PALETTE, ENDSCREEN8PIC);\r
89         EndScreen (END9PALETTE, ENDSCREEN9PIC);\r
90 \r
91         EndScreen (END2PALETTE, ENDSCREEN12PIC);\r
92 \r
93         MainMenu[savegame].active = 0;\r
94 }\r
95 #endif\r
96 #endif\r
97 \r
98 //==========================================================================\r
99 \r
100 /*\r
101 ==================\r
102 =\r
103 = Victory\r
104 =\r
105 ==================\r
106 */\r
107 \r
108 void Victory (void)\r
109 {\r
110 #ifndef SPEARDEMO\r
111         long    sec;\r
112         int i,min,kr,sr,tr,x;\r
113         char tempstr[8];\r
114 \r
115 #define RATIOX  6\r
116 #define RATIOY  14\r
117 #define TIMEX   14\r
118 #define TIMEY   8\r
119 \r
120 \r
121 #ifdef SPEAR\r
122         StartCPMusic (XTHEEND_MUS);\r
123 \r
124         CA_CacheGrChunk(BJCOLLAPSE1PIC);\r
125         CA_CacheGrChunk(BJCOLLAPSE2PIC);\r
126         CA_CacheGrChunk(BJCOLLAPSE3PIC);\r
127         CA_CacheGrChunk(BJCOLLAPSE4PIC);\r
128 \r
129         VWB_Bar(0,0,320,200,VIEWCOLOR);\r
130         VWB_DrawPic (124,44,BJCOLLAPSE1PIC);\r
131         VW_UpdateScreen ();\r
132         VW_FadeIn ();\r
133         VW_WaitVBL(2*70);\r
134         VWB_DrawPic (124,44,BJCOLLAPSE2PIC);\r
135         VW_UpdateScreen ();\r
136         VW_WaitVBL(105);\r
137         VWB_DrawPic (124,44,BJCOLLAPSE3PIC);\r
138         VW_UpdateScreen ();\r
139         VW_WaitVBL(105);\r
140         VWB_DrawPic (124,44,BJCOLLAPSE4PIC);\r
141         VW_UpdateScreen ();\r
142         VW_WaitVBL(3*70);\r
143 \r
144         UNCACHEGRCHUNK(BJCOLLAPSE1PIC);\r
145         UNCACHEGRCHUNK(BJCOLLAPSE2PIC);\r
146         UNCACHEGRCHUNK(BJCOLLAPSE3PIC);\r
147         UNCACHEGRCHUNK(BJCOLLAPSE4PIC);\r
148         VL_FadeOut (0,255,0,17,17,5);\r
149 #endif\r
150 \r
151         StartCPMusic (URAHERO_MUS);\r
152         ClearSplitVWB ();\r
153         CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);\r
154         CA_CacheGrChunk(STARTFONT);\r
155 \r
156 #ifndef SPEAR\r
157         CA_CacheGrChunk(C_TIMECODEPIC);\r
158 #endif\r
159 \r
160 \r
161         VWB_Bar (0,0,320,200-STATUSLINES,127);\r
162 #ifdef JAPAN\r
163 #ifndef JAPDEMO\r
164         CA_CacheGrChunk(C_ENDRATIOSPIC);\r
165         VWB_DrawPic(0,0,C_ENDRATIOSPIC);\r
166         UNCACHEGRCHUNK(C_ENDRATIOSPIC);\r
167 #endif\r
168 #else\r
169         Write(18,2,STR_YOUWIN);\r
170 \r
171         Write(TIMEX,TIMEY-2,STR_TOTALTIME);\r
172 \r
173         Write(12,RATIOY-2,"averages");\r
174 \r
175         #ifdef SPANISH\r
176         Write(RATIOX+2,  RATIOY,      STR_RATKILL);\r
177         Write(RATIOX+2,  RATIOY+2,  STR_RATSECRET);\r
178         Write(RATIOX+2,  RATIOY+4,STR_RATTREASURE);\r
179         #else\r
180         Write(RATIOX+8,RATIOY,      STR_RATKILL);\r
181         Write(RATIOX+4,RATIOY+2,  STR_RATSECRET);\r
182         Write(RATIOX,  RATIOY+4,STR_RATTREASURE);\r
183         #endif\r
184 \r
185 #endif\r
186 \r
187 #ifndef JAPDEMO\r
188         VWB_DrawPic (8,4,L_BJWINSPIC);\r
189 #endif\r
190 \r
191 \r
192 #ifndef SPEAR\r
193         for (kr = sr = tr = sec = i = 0;i < 8;i++)\r
194 #else\r
195         for (kr = sr = tr = sec = i = 0;i < 20;i++)\r
196 #endif\r
197         {\r
198                 sec += LevelRatios[i].time;\r
199                 kr += LevelRatios[i].kill;\r
200                 sr += LevelRatios[i].secret;\r
201                 tr += LevelRatios[i].treasure;\r
202         }\r
203 \r
204 #ifndef SPEAR\r
205         kr /= 8;\r
206         sr /= 8;\r
207         tr /= 8;\r
208 #else\r
209         kr /= 14;\r
210         sr /= 14;\r
211         tr /= 14;\r
212 #endif\r
213 \r
214         min = sec/60;\r
215         sec %= 60;\r
216 \r
217         if (min > 99)\r
218                 min = sec = 99;\r
219 \r
220         i = TIMEX*8+1;\r
221         VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min/10));\r
222         i += 2*8;\r
223         VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(min%10));\r
224         i += 2*8;\r
225         Write(i/8,TIMEY,":");\r
226         i += 1*8;\r
227         VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec/10));\r
228         i += 2*8;\r
229         VWB_DrawPic(i,TIMEY*8,L_NUM0PIC+(sec%10));\r
230         VW_UpdateScreen ();\r
231 \r
232         itoa(kr,tempstr,10);\r
233         x=RATIOX+24-strlen(tempstr)*2;\r
234         Write(x,RATIOY,tempstr);\r
235 \r
236         itoa(sr,tempstr,10);\r
237         x=RATIOX+24-strlen(tempstr)*2;\r
238         Write(x,RATIOY+2,tempstr);\r
239 \r
240         itoa(tr,tempstr,10);\r
241         x=RATIOX+24-strlen(tempstr)*2;\r
242         Write(x,RATIOY+4,tempstr);\r
243 \r
244 \r
245 #ifndef SPANISH\r
246 #ifndef UPLOAD\r
247 #ifndef SPEAR\r
248         //\r
249         // TOTAL TIME VERIFICATION CODE\r
250         //\r
251         if (gamestate.difficulty>=gd_medium)\r
252         {\r
253                 VWB_DrawPic (30*8,TIMEY*8,C_TIMECODEPIC);\r
254                 fontnumber = 0;\r
255                 fontcolor = READHCOLOR;\r
256                 PrintX = 30*8-3;\r
257                 PrintY = TIMEY*8+8;\r
258                 PrintX+=4;\r
259                 tempstr[0] = (((min/10)^(min%10))^0xa)+'A';\r
260                 tempstr[1] = (((sec/10)^(sec%10))^0xa)+'A';\r
261                 tempstr[2] = (tempstr[0]^tempstr[1])+'A';\r
262                 tempstr[3] = 0;\r
263                 US_Print(tempstr);\r
264         }\r
265 #endif\r
266 #endif\r
267 #endif\r
268 \r
269 \r
270         fontnumber = 1;\r
271 \r
272         VW_UpdateScreen ();\r
273         VW_FadeIn ();\r
274 \r
275         IN_Ack();\r
276 \r
277         #ifndef SPEAR\r
278         if (Keyboard[sc_P] && MS_CheckParm("goobers"))\r
279                 PicturePause();\r
280         #endif\r
281 \r
282         VW_FadeOut ();\r
283 \r
284 #ifndef SPEAR\r
285         UNCACHEGRCHUNK(C_TIMECODEPIC);\r
286 #endif\r
287         UnCacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);\r
288 \r
289 #ifndef SPEAR\r
290         EndText();\r
291 #else\r
292         EndSpear();\r
293 #endif\r
294 \r
295 #endif // SPEARDEMO\r
296 }\r
297 \r
298 \r
299 //==========================================================================\r
300 \r
301 #ifndef JAPAN\r
302 /*\r
303 ==================\r
304 =\r
305 = PG13\r
306 =\r
307 ==================\r
308 */\r
309 \r
310 void PG13 (void)\r
311 {\r
312         VW_FadeOut();\r
313         VWB_Bar(0,0,320,200,0x82);                      // background\r
314 \r
315         CA_CacheGrChunk (PG13PIC);\r
316         VWB_DrawPic (216,110,PG13PIC);\r
317         VW_UpdateScreen ();\r
318 \r
319         UNCACHEGRCHUNK (PG13PIC);\r
320 \r
321         VW_FadeIn();\r
322         IN_UserInput(TickBase*7);\r
323 \r
324         VW_FadeOut ();\r
325 }\r
326 #endif\r
327 \r
328 \r
329 //==========================================================================\r
330 \r
331 void Write(int x,int y,char *string)\r
332 {\r
333  int alpha[]={L_NUM0PIC,L_NUM1PIC,L_NUM2PIC,L_NUM3PIC,L_NUM4PIC,L_NUM5PIC,\r
334         L_NUM6PIC,L_NUM7PIC,L_NUM8PIC,L_NUM9PIC,L_COLONPIC,0,0,0,0,0,0,L_APIC,L_BPIC,\r
335         L_CPIC,L_DPIC,L_EPIC,L_FPIC,L_GPIC,L_HPIC,L_IPIC,L_JPIC,L_KPIC,\r
336         L_LPIC,L_MPIC,L_NPIC,L_OPIC,L_PPIC,L_QPIC,L_RPIC,L_SPIC,L_TPIC,\r
337         L_UPIC,L_VPIC,L_WPIC,L_XPIC,L_YPIC,L_ZPIC};\r
338 \r
339  int i,ox,nx,ny;\r
340  char ch;\r
341 \r
342 \r
343  ox=nx=x*8;\r
344  ny=y*8;\r
345  for (i=0;i<strlen(string);i++)\r
346    if (string[i]=='\n')\r
347    {\r
348         nx=ox;\r
349         ny+=16;\r
350    }\r
351    else\r
352    {\r
353         ch=string[i];\r
354         if (ch>='a')\r
355           ch-=('a'-'A');\r
356         ch-='0';\r
357 \r
358         switch(string[i])\r
359         {\r
360          case '!':\r
361            VWB_DrawPic(nx,ny,L_EXPOINTPIC);\r
362            nx+=8;\r
363            continue;\r
364 \r
365          case '\'':\r
366            VWB_DrawPic(nx,ny,L_APOSTROPHEPIC);\r
367            nx+=8;\r
368            continue;\r
369 \r
370          case ' ': break;\r
371          case 0x3a:     // ':'\r
372 \r
373            VWB_DrawPic(nx,ny,L_COLONPIC);\r
374            nx+=8;\r
375            continue;\r
376 \r
377          case '%':\r
378            VWB_DrawPic(nx,ny,L_PERCENTPIC);\r
379            break;\r
380 \r
381          default:\r
382            VWB_DrawPic(nx,ny,alpha[ch]);\r
383         }\r
384         nx+=16;\r
385    }\r
386 }\r
387 \r
388 \r
389 //\r
390 // Breathe Mr. BJ!!!\r
391 //\r
392 void BJ_Breathe(void)\r
393 {\r
394         static int which=0,max=10;\r
395         int pics[2]={L_GUYPIC,L_GUY2PIC};\r
396 \r
397 \r
398         if (TimeCount>max)\r
399         {\r
400                 which^=1;\r
401                 VWB_DrawPic(0,16,pics[which]);\r
402                 VW_UpdateScreen();\r
403                 TimeCount=0;\r
404                 max=35;\r
405         }\r
406 }\r
407 \r
408 \r
409 \r
410 /*\r
411 ==================\r
412 =\r
413 = LevelCompleted\r
414 =\r
415 = Entered with the screen faded out\r
416 = Still in split screen mode with the status bar\r
417 =\r
418 = Exit with the screen faded out\r
419 =\r
420 ==================\r
421 */\r
422 \r
423 #ifndef SPEAR\r
424 LRstruct LevelRatios[8];\r
425 #else\r
426 LRstruct LevelRatios[20];\r
427 #endif\r
428 \r
429 void LevelCompleted (void)\r
430 {\r
431         #define VBLWAIT 30\r
432         #define PAR_AMOUNT      500\r
433         #define PERCENT100AMT   10000\r
434         typedef struct {\r
435                         float time;\r
436                         char timestr[6];\r
437                         } times;\r
438 \r
439         int     x,i,min,sec,ratio,kr,sr,tr;\r
440         unsigned        temp;\r
441         char tempstr[10];\r
442         long bonus,timeleft=0;\r
443         times parTimes[]=\r
444         {\r
445 #ifndef SPEAR\r
446          //\r
447          // Episode One Par Times\r
448          //\r
449          {1.5,  "01:30"},\r
450          {2,    "02:00"},\r
451          {2,    "02:00"},\r
452          {3.5,  "03:30"},\r
453          {3,    "03:00"},\r
454          {3,    "03:00"},\r
455          {2.5,  "02:30"},\r
456          {2.5,  "02:30"},\r
457          {0,    "??:??"},       // Boss level\r
458          {0,    "??:??"},       // Secret level\r
459 \r
460          //\r
461          // Episode Two Par Times\r
462          //\r
463          {1.5,  "01:30"},\r
464          {3.5,  "03:30"},\r
465          {3,    "03:00"},\r
466          {2,    "02:00"},\r
467          {4,    "04:00"},\r
468          {6,    "06:00"},\r
469          {1,    "01:00"},\r
470          {3,    "03:00"},\r
471          {0,    "??:??"},\r
472          {0,    "??:??"},\r
473 \r
474          //\r
475          // Episode Three Par Times\r
476          //\r
477          {1.5,  "01:30"},\r
478          {1.5,  "01:30"},\r
479          {2.5,  "02:30"},\r
480          {2.5,  "02:30"},\r
481          {3.5,  "03:30"},\r
482          {2.5,  "02:30"},\r
483          {2,    "02:00"},\r
484          {6,    "06:00"},\r
485          {0,    "??:??"},\r
486          {0,    "??:??"},\r
487 \r
488          //\r
489          // Episode Four Par Times\r
490          //\r
491          {2,    "02:00"},\r
492          {2,    "02:00"},\r
493          {1.5,  "01:30"},\r
494          {1,    "01:00"},\r
495          {4.5,  "04:30"},\r
496          {3.5,  "03:30"},\r
497          {2,    "02:00"},\r
498          {4.5,  "04:30"},\r
499          {0,    "??:??"},\r
500          {0,    "??:??"},\r
501 \r
502          //\r
503          // Episode Five Par Times\r
504          //\r
505          {2.5,  "02:30"},\r
506          {1.5,  "01:30"},\r
507          {2.5,  "02:30"},\r
508          {2.5,  "02:30"},\r
509          {4,    "04:00"},\r
510          {3,    "03:00"},\r
511          {4.5,  "04:30"},\r
512          {3.5,  "03:30"},\r
513          {0,    "??:??"},\r
514          {0,    "??:??"},\r
515 \r
516          //\r
517          // Episode Six Par Times\r
518          //\r
519          {6.5,  "06:30"},\r
520          {4,    "04:00"},\r
521          {4.5,  "04:30"},\r
522          {6,    "06:00"},\r
523          {5,    "05:00"},\r
524          {5.5,  "05:30"},\r
525          {5.5,  "05:30"},\r
526          {8.5,  "08:30"},\r
527          {0,    "??:??"},\r
528          {0,    "??:??"}\r
529 #else\r
530          //\r
531          // SPEAR OF DESTINY TIMES\r
532          //\r
533          {1.5,  "01:30"},\r
534          {3.5,  "03:30"},\r
535          {2.75, "02:45"},\r
536          {3.5,  "03:30"},\r
537          {0,    "??:??"},       // Boss 1\r
538          {4.5,  "04:30"},\r
539          {3.25, "03:15"},\r
540          {2.75, "02:45"},\r
541          {4.75, "04:45"},\r
542          {0,    "??:??"},       // Boss 2\r
543          {6.5,  "06:30"},\r
544          {4.5,  "04:30"},\r
545          {2.75, "02:45"},\r
546          {4.5,  "04:30"},\r
547          {6,    "06:00"},\r
548          {0,    "??:??"},       // Boss 3\r
549          {6,    "06:00"},\r
550          {0,    "??:??"},       // Boss 4\r
551          {0,    "??:??"},       // Secret level 1\r
552          {0,    "??:??"},       // Secret level 2\r
553 #endif\r
554         };\r
555 \r
556 \r
557 \r
558         CacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);\r
559         ClearSplitVWB ();                       // set up for double buffering in split screen\r
560         VWB_Bar (0,0,320,200-STATUSLINES,127);\r
561         StartCPMusic(ENDLEVEL_MUS);\r
562 \r
563 //\r
564 // do the intermission\r
565 //\r
566         IN_ClearKeysDown();\r
567         IN_StartAck();\r
568 \r
569 #ifdef JAPAN\r
570         CA_CacheGrChunk(C_INTERMISSIONPIC);\r
571         VWB_DrawPic(0,0,C_INTERMISSIONPIC);\r
572         UNCACHEGRCHUNK(C_INTERMISSIONPIC);\r
573 #endif\r
574         VWB_DrawPic(0,16,L_GUYPIC);\r
575 \r
576 #ifndef SPEAR\r
577         if (mapon<8)\r
578 #else\r
579         if (mapon != 4 &&\r
580                 mapon != 9 &&\r
581                 mapon != 15 &&\r
582                 mapon < 17)\r
583 #endif\r
584         {\r
585 #ifndef JAPAN\r
586          #ifdef SPANISH\r
587          Write(14,2,"piso\ncompletado");\r
588          #else\r
589          Write(14,2,"floor\ncompleted");\r
590          #endif\r
591 \r
592          Write(14,7,STR_BONUS"     0");\r
593          Write(16,10,STR_TIME);\r
594          Write(16,12,STR_PAR);\r
595 \r
596          #ifdef SPANISH\r
597          Write(11,14,    STR_RAT2KILL);\r
598          Write(11,16,  STR_RAT2SECRET);\r
599          Write(11,18,STR_RAT2TREASURE);\r
600          #else\r
601          Write(9,14,    STR_RAT2KILL);\r
602          Write(5,16,  STR_RAT2SECRET);\r
603          Write(1,18,STR_RAT2TREASURE);\r
604          #endif\r
605 \r
606          Write(26,2,itoa(gamestate.mapon+1,tempstr,10));\r
607 #endif\r
608 \r
609          #ifdef SPANISH\r
610          Write(30,12,parTimes[gamestate.episode*10+mapon].timestr);\r
611          #else\r
612          Write(26,12,parTimes[gamestate.episode*10+mapon].timestr);\r
613          #endif\r
614 \r
615          //\r
616          // PRINT TIME\r
617          //\r
618          sec=gamestate.TimeCount/70;\r
619 \r
620          if (sec > 99*60)               // 99 minutes max\r
621            sec = 99*60;\r
622 \r
623          if (gamestate.TimeCount<parTimes[gamestate.episode*10+mapon].time*4200)\r
624                 timeleft=(parTimes[gamestate.episode*10+mapon].time*4200)/70-sec;\r
625 \r
626          min=sec/60;\r
627          sec%=60;\r
628 \r
629          #ifdef SPANISH\r
630          i=30*8;\r
631          #else\r
632          i=26*8;\r
633          #endif\r
634          VWB_DrawPic(i,10*8,L_NUM0PIC+(min/10));\r
635          i+=2*8;\r
636          VWB_DrawPic(i,10*8,L_NUM0PIC+(min%10));\r
637          i+=2*8;\r
638          Write(i/8,10,":");\r
639          i+=1*8;\r
640          VWB_DrawPic(i,10*8,L_NUM0PIC+(sec/10));\r
641          i+=2*8;\r
642          VWB_DrawPic(i,10*8,L_NUM0PIC+(sec%10));\r
643 \r
644          VW_UpdateScreen ();\r
645          VW_FadeIn ();\r
646 \r
647 \r
648          //\r
649          // FIGURE RATIOS OUT BEFOREHAND\r
650          //\r
651          kr = sr = tr = 0;\r
652          if (gamestate.killtotal)\r
653                 kr=(gamestate.killcount*100)/gamestate.killtotal;\r
654          if (gamestate.secrettotal)\r
655                 sr=(gamestate.secretcount*100)/gamestate.secrettotal;\r
656          if (gamestate.treasuretotal)\r
657                 tr=(gamestate.treasurecount*100)/gamestate.treasuretotal;\r
658 \r
659 \r
660          //\r
661          // PRINT TIME BONUS\r
662          //\r
663          bonus=timeleft*PAR_AMOUNT;\r
664          if (bonus)\r
665          {\r
666           for (i=0;i<=timeleft;i++)\r
667           {\r
668            ltoa((long)i*PAR_AMOUNT,tempstr,10);\r
669            x=36-strlen(tempstr)*2;\r
670            Write(x,7,tempstr);\r
671            if (!(i%(PAR_AMOUNT/10)))\r
672                  SD_PlaySound(ENDBONUS1SND);\r
673            VW_UpdateScreen();\r
674            while(SD_SoundPlaying())\r
675                  BJ_Breathe();\r
676            if (IN_CheckAck())\r
677                  goto done;\r
678           }\r
679 \r
680           VW_UpdateScreen();\r
681           SD_PlaySound(ENDBONUS2SND);\r
682           while(SD_SoundPlaying())\r
683                 BJ_Breathe();\r
684          }\r
685 \r
686 \r
687          #ifdef SPANISH\r
688          #define RATIOXX                33\r
689          #else\r
690          #define RATIOXX                37\r
691          #endif\r
692          //\r
693          // KILL RATIO\r
694          //\r
695          ratio=kr;\r
696          for (i=0;i<=ratio;i++)\r
697          {\r
698           itoa(i,tempstr,10);\r
699           x=RATIOXX-strlen(tempstr)*2;\r
700           Write(x,14,tempstr);\r
701           if (!(i%10))\r
702                 SD_PlaySound(ENDBONUS1SND);\r
703           VW_UpdateScreen ();\r
704           while(SD_SoundPlaying())\r
705                 BJ_Breathe();\r
706 \r
707           if (IN_CheckAck())\r
708                 goto done;\r
709          }\r
710          if (ratio==100)\r
711          {\r
712            VW_WaitVBL(VBLWAIT);\r
713            SD_StopSound();\r
714            bonus+=PERCENT100AMT;\r
715            ltoa(bonus,tempstr,10);\r
716            x=(RATIOXX-1)-strlen(tempstr)*2;\r
717            Write(x,7,tempstr);\r
718            VW_UpdateScreen();\r
719            SD_PlaySound(PERCENT100SND);\r
720          }\r
721          else\r
722          if (!ratio)\r
723          {\r
724            VW_WaitVBL(VBLWAIT);\r
725            SD_StopSound();\r
726            SD_PlaySound(NOBONUSSND);\r
727          }\r
728          else\r
729          SD_PlaySound(ENDBONUS2SND);\r
730 \r
731          VW_UpdateScreen();\r
732          while(SD_SoundPlaying())\r
733            BJ_Breathe();\r
734 \r
735 \r
736          //\r
737          // SECRET RATIO\r
738          //\r
739          ratio=sr;\r
740          for (i=0;i<=ratio;i++)\r
741          {\r
742           itoa(i,tempstr,10);\r
743           x=RATIOXX-strlen(tempstr)*2;\r
744           Write(x,16,tempstr);\r
745           if (!(i%10))\r
746                 SD_PlaySound(ENDBONUS1SND);\r
747           VW_UpdateScreen ();\r
748           while(SD_SoundPlaying())\r
749                 BJ_Breathe();\r
750           BJ_Breathe();\r
751 \r
752           if (IN_CheckAck())\r
753                 goto done;\r
754          }\r
755          if (ratio==100)\r
756          {\r
757            VW_WaitVBL(VBLWAIT);\r
758            SD_StopSound();\r
759            bonus+=PERCENT100AMT;\r
760            ltoa(bonus,tempstr,10);\r
761            x=(RATIOXX-1)-strlen(tempstr)*2;\r
762            Write(x,7,tempstr);\r
763            VW_UpdateScreen();\r
764            SD_PlaySound(PERCENT100SND);\r
765          }\r
766          else\r
767          if (!ratio)\r
768          {\r
769            VW_WaitVBL(VBLWAIT);\r
770            SD_StopSound();\r
771            SD_PlaySound(NOBONUSSND);\r
772          }\r
773          else\r
774            SD_PlaySound(ENDBONUS2SND);\r
775          VW_UpdateScreen();\r
776          while(SD_SoundPlaying())\r
777            BJ_Breathe();\r
778 \r
779 \r
780          //\r
781          // TREASURE RATIO\r
782          //\r
783          ratio=tr;\r
784          for (i=0;i<=ratio;i++)\r
785          {\r
786           itoa(i,tempstr,10);\r
787           x=RATIOXX-strlen(tempstr)*2;\r
788           Write(x,18,tempstr);\r
789           if (!(i%10))\r
790                 SD_PlaySound(ENDBONUS1SND);\r
791           VW_UpdateScreen ();\r
792           while(SD_SoundPlaying())\r
793                 BJ_Breathe();\r
794           if (IN_CheckAck())\r
795                 goto done;\r
796          }\r
797          if (ratio==100)\r
798          {\r
799            VW_WaitVBL(VBLWAIT);\r
800            SD_StopSound();\r
801            bonus+=PERCENT100AMT;\r
802            ltoa(bonus,tempstr,10);\r
803            x=(RATIOXX-1)-strlen(tempstr)*2;\r
804            Write(x,7,tempstr);\r
805            VW_UpdateScreen();\r
806            SD_PlaySound(PERCENT100SND);\r
807          }\r
808          else\r
809          if (!ratio)\r
810          {\r
811            VW_WaitVBL(VBLWAIT);\r
812            SD_StopSound();\r
813            SD_PlaySound(NOBONUSSND);\r
814          }\r
815          else\r
816          SD_PlaySound(ENDBONUS2SND);\r
817          VW_UpdateScreen();\r
818          while(SD_SoundPlaying())\r
819            BJ_Breathe();\r
820 \r
821 \r
822          //\r
823          // JUMP STRAIGHT HERE IF KEY PRESSED\r
824          //\r
825          done:\r
826 \r
827          itoa(kr,tempstr,10);\r
828          x=RATIOXX-strlen(tempstr)*2;\r
829          Write(x,14,tempstr);\r
830 \r
831          itoa(sr,tempstr,10);\r
832          x=RATIOXX-strlen(tempstr)*2;\r
833          Write(x,16,tempstr);\r
834 \r
835          itoa(tr,tempstr,10);\r
836          x=RATIOXX-strlen(tempstr)*2;\r
837          Write(x,18,tempstr);\r
838 \r
839          bonus=(long)timeleft*PAR_AMOUNT+\r
840                    (PERCENT100AMT*(kr==100))+\r
841                    (PERCENT100AMT*(sr==100))+\r
842                    (PERCENT100AMT*(tr==100));\r
843 \r
844          GivePoints(bonus);\r
845          ltoa(bonus,tempstr,10);\r
846          x=36-strlen(tempstr)*2;\r
847          Write(x,7,tempstr);\r
848 \r
849          //\r
850          // SAVE RATIO INFORMATION FOR ENDGAME\r
851          //\r
852          LevelRatios[mapon].kill=kr;\r
853          LevelRatios[mapon].secret=sr;\r
854          LevelRatios[mapon].treasure=tr;\r
855          LevelRatios[mapon].time=min*60+sec;\r
856         }\r
857         else\r
858         {\r
859 #ifdef SPEAR\r
860 #ifndef SPEARDEMO\r
861           switch(mapon)\r
862           {\r
863            case 4: Write(14,4," trans\n"\r
864                                                   " grosse\n"\r
865                                                   STR_DEFEATED); break;\r
866            case 9: Write(14,4,"barnacle\n"\r
867                                                   "wilhelm\n"\r
868                                                   STR_DEFEATED); break;\r
869            case 15: Write(14,4,"ubermutant\n"\r
870                                                    STR_DEFEATED); break;\r
871            case 17: Write(14,4," death\n"\r
872                                                    " knight\n"\r
873                                                    STR_DEFEATED); break;\r
874            case 18: Write(13,4,"secret tunnel\n"\r
875                                                    "    area\n"\r
876                                                    "  completed!"); break;\r
877            case 19: Write(13,4,"secret castle\n"\r
878                                                    "    area\n"\r
879                                                    "  completed!"); break;\r
880           }\r
881 #endif\r
882 #else\r
883           Write(14,4,"secret floor\n completed!");\r
884 #endif\r
885 \r
886           Write(10,16,"15000 bonus!");\r
887 \r
888           VW_UpdateScreen();\r
889           VW_FadeIn();\r
890 \r
891           GivePoints(15000);\r
892         }\r
893 \r
894 \r
895         DrawScore();\r
896         VW_UpdateScreen();\r
897 \r
898         TimeCount=0;\r
899         IN_StartAck();\r
900         while(!IN_CheckAck())\r
901           BJ_Breathe();\r
902 \r
903 //\r
904 // done\r
905 //\r
906 #ifdef SPEARDEMO\r
907         if (gamestate.mapon == 1)\r
908         {\r
909                 SD_PlaySound (BONUS1UPSND);\r
910 \r
911                 CA_CacheGrChunk (STARTFONT+1);\r
912                 Message ("This concludes your demo\n"\r
913                                  "of Spear of Destiny! Now,\n"\r
914                                  "go to your local software\n"\r
915                                  "store and buy it!");\r
916                 UNCACHEGRCHUNK (STARTFONT+1);\r
917 \r
918                 IN_ClearKeysDown();\r
919                 IN_Ack();\r
920         }\r
921 #endif\r
922 \r
923 #ifdef JAPDEMO\r
924         if (gamestate.mapon == 3)\r
925         {\r
926                 SD_PlaySound (BONUS1UPSND);\r
927 \r
928                 CA_CacheGrChunk (STARTFONT+1);\r
929                 Message ("This concludes your demo\n"\r
930                                  "of Wolfenstein 3-D! Now,\n"\r
931                                  "go to your local software\n"\r
932                                  "store and buy it!");\r
933                 UNCACHEGRCHUNK (STARTFONT+1);\r
934 \r
935                 IN_ClearKeysDown();\r
936                 IN_Ack();\r
937         }\r
938 #endif\r
939 \r
940         #ifndef SPEAR\r
941         if (Keyboard[sc_P] && MS_CheckParm("goobers"))\r
942                 PicturePause();\r
943         #endif\r
944 \r
945         VW_FadeOut ();\r
946         temp = bufferofs;\r
947         for (i=0;i<3;i++)\r
948         {\r
949                 bufferofs = screenloc[i];\r
950                 DrawPlayBorder ();\r
951         }\r
952         bufferofs = temp;\r
953 \r
954         UnCacheLump(LEVELEND_LUMP_START,LEVELEND_LUMP_END);\r
955 }\r
956 \r
957 \r
958 \r
959 //==========================================================================\r
960 \r
961 \r
962 /*\r
963 =================\r
964 =\r
965 = PreloadGraphics\r
966 =\r
967 = Fill the cache up\r
968 =\r
969 =================\r
970 */\r
971 \r
972 boolean PreloadUpdate(unsigned current, unsigned total)\r
973 {\r
974         unsigned w = WindowW - 10;\r
975 \r
976 \r
977         VWB_Bar(WindowX + 5,WindowY + WindowH - 3,w,2,BLACK);\r
978         w = ((long)w * current) / total;\r
979         if (w)\r
980         {\r
981          VWB_Bar(WindowX + 5,WindowY + WindowH - 3,w,2,0x37); //SECONDCOLOR);\r
982          VWB_Bar(WindowX + 5,WindowY + WindowH - 3,w-1,1,0x32);\r
983 \r
984         }\r
985         VW_UpdateScreen();\r
986 //      if (LastScan == sc_Escape)\r
987 //      {\r
988 //              IN_ClearKeysDown();\r
989 //              return(true);\r
990 //      }\r
991 //      else\r
992                 return(false);\r
993 }\r
994 \r
995 void PreloadGraphics(void)\r
996 {\r
997         DrawLevel ();\r
998         ClearSplitVWB ();                       // set up for double buffering in split screen\r
999 \r
1000         VWB_Bar (0,0,320,200-STATUSLINES,127);\r
1001 \r
1002         LatchDrawPic (20-14,80-3*8,GETPSYCHEDPIC);\r
1003 \r
1004         WindowX = 160-14*8;\r
1005         WindowY = 80-3*8;\r
1006         WindowW = 28*8;\r
1007         WindowH = 48;\r
1008         VW_UpdateScreen();\r
1009         VW_FadeIn ();\r
1010 \r
1011         PM_Preload (PreloadUpdate);\r
1012         IN_UserInput (70);\r
1013         VW_FadeOut ();\r
1014 \r
1015         DrawPlayBorder ();\r
1016         VW_UpdateScreen ();\r
1017 }\r
1018 \r
1019 \r
1020 //==========================================================================\r
1021 \r
1022 /*\r
1023 ==================\r
1024 =\r
1025 = DrawHighScores\r
1026 =\r
1027 ==================\r
1028 */\r
1029 \r
1030 void    DrawHighScores(void)\r
1031 {\r
1032         char            buffer[16],*str,buffer1[5];\r
1033         byte            temp,temp1,temp2,temp3;\r
1034         word            i,j,\r
1035                                 w,h,\r
1036                                 x,y;\r
1037         HighScore       *s;\r
1038 \r
1039 \r
1040         MM_SortMem ();\r
1041 \r
1042 #ifndef SPEAR\r
1043 //      CA_CacheGrChunk (C_CODEPIC);\r
1044         CA_CacheGrChunk (HIGHSCORESPIC);\r
1045         CA_CacheGrChunk (STARTFONT);\r
1046         CA_CacheGrChunk (C_LEVELPIC);\r
1047         CA_CacheGrChunk (C_SCOREPIC);\r
1048         CA_CacheGrChunk (C_NAMEPIC);\r
1049 \r
1050         ClearMScreen();\r
1051         DrawStripes(10);\r
1052 \r
1053         VWB_DrawPic(48,0,HIGHSCORESPIC);\r
1054         UNCACHEGRCHUNK (HIGHSCORESPIC);\r
1055 \r
1056         VWB_DrawPic(4*8,68,C_NAMEPIC);\r
1057         VWB_DrawPic(20*8,68,C_LEVELPIC);\r
1058         VWB_DrawPic(28*8,68,C_SCOREPIC);\r
1059 #ifndef UPLOAD\r
1060 //      VWB_DrawPic(35*8,68,C_CODEPIC);\r
1061 #endif\r
1062         fontnumber=0;\r
1063 \r
1064 #else\r
1065         CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
1066         ClearMScreen();\r
1067         DrawStripes(10);\r
1068         UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END);\r
1069 \r
1070         CacheLump (HIGHSCORES_LUMP_START,HIGHSCORES_LUMP_END);\r
1071         CA_CacheGrChunk (STARTFONT+1);\r
1072         VWB_DrawPic (0,0,HIGHSCORESPIC);\r
1073 \r
1074         fontnumber = 1;\r
1075 #endif\r
1076 \r
1077 \r
1078 #ifndef SPEAR\r
1079         SETFONTCOLOR(15,0x29);\r
1080 #else\r
1081         SETFONTCOLOR(HIGHLIGHT,0x29);\r
1082 #endif\r
1083 \r
1084         for (i = 0,s = Scores;i < MaxScores;i++,s++)\r
1085         {\r
1086                 PrintY = 76 + (16 * i);\r
1087 \r
1088                 //\r
1089                 // name\r
1090                 //\r
1091 #ifndef SPEAR\r
1092                 PrintX = 4*8;\r
1093 #else\r
1094                 PrintX = 16;\r
1095 #endif\r
1096                 US_Print(s->name);\r
1097 \r
1098                 //\r
1099                 // level\r
1100                 //\r
1101                 ultoa(s->completed,buffer,10);\r
1102 #ifndef SPEAR\r
1103                 for (str = buffer;*str;str++)\r
1104                         *str = *str + (129 - '0');      // Used fixed-width numbers (129...)\r
1105                 USL_MeasureString(buffer,&w,&h);\r
1106                 PrintX = (22 * 8)-w;\r
1107 #else\r
1108                 USL_MeasureString(buffer,&w,&h);\r
1109                 PrintX = 194 - w;\r
1110 #endif\r
1111 \r
1112 #ifndef UPLOAD\r
1113 #ifndef SPEAR\r
1114                 PrintX -= 6;\r
1115                 itoa(s->episode+1,buffer1,10);\r
1116                 US_Print("E");\r
1117                 US_Print(buffer1);\r
1118                 US_Print("/L");\r
1119 #endif\r
1120 #endif\r
1121 \r
1122 #ifdef SPEAR\r
1123                 if (s->completed == 21)\r
1124                         VWB_DrawPic (PrintX+8,PrintY-1,C_WONSPEARPIC);\r
1125                 else\r
1126 #endif\r
1127                 US_Print(buffer);\r
1128 \r
1129                 //\r
1130                 // score\r
1131                 //\r
1132                 ultoa(s->score,buffer,10);\r
1133 #ifndef SPEAR\r
1134                 for (str = buffer;*str;str++)\r
1135                         *str = *str + (129 - '0');      // Used fixed-width numbers (129...)\r
1136                 USL_MeasureString(buffer,&w,&h);\r
1137                 PrintX = (34 * 8) - 8 - w;\r
1138 #else\r
1139                 USL_MeasureString(buffer,&w,&h);\r
1140                 PrintX = 292 - w;\r
1141 #endif\r
1142                 US_Print(buffer);\r
1143 \r
1144                 #if 0\r
1145 #ifndef UPLOAD\r
1146 #ifndef SPEAR\r
1147                 //\r
1148                 // verification #\r
1149                 //\r
1150                 if (!i)\r
1151                 {\r
1152                  temp=(((s->score >> 28)& 0xf)^\r
1153                           ((s->score >> 24)& 0xf))+'A';\r
1154                  temp1=(((s->score >> 20)& 0xf)^\r
1155                            ((s->score >> 16)& 0xf))+'A';\r
1156                  temp2=(((s->score >> 12)& 0xf)^\r
1157                            ((s->score >> 8)& 0xf))+'A';\r
1158                  temp3=(((s->score >> 4)& 0xf)^\r
1159                            ((s->score >> 0)& 0xf))+'A';\r
1160 \r
1161                  SETFONTCOLOR(0x49,0x29);\r
1162                  PrintX = 35*8;\r
1163                  buffer[0]=temp;\r
1164                  buffer[1]=temp1;\r
1165                  buffer[2]=temp2;\r
1166                  buffer[3]=temp3;\r
1167                  buffer[4]=0;\r
1168                  US_Print(buffer);\r
1169                  SETFONTCOLOR(15,0x29);\r
1170                 }\r
1171 #endif\r
1172 #endif\r
1173                 #endif\r
1174         }\r
1175 \r
1176         VW_UpdateScreen ();\r
1177 \r
1178 #ifdef SPEAR\r
1179         UnCacheLump (HIGHSCORES_LUMP_START,HIGHSCORES_LUMP_END);\r
1180         fontnumber = 0;\r
1181 #endif\r
1182 }\r
1183 \r
1184 //===========================================================================\r
1185 \r
1186 \r
1187 /*\r
1188 =======================\r
1189 =\r
1190 = CheckHighScore\r
1191 =\r
1192 =======================\r
1193 */\r
1194 \r
1195 void    CheckHighScore (long score,word other)\r
1196 {\r
1197         word            i,j;\r
1198         int                     n;\r
1199         HighScore       myscore;\r
1200 \r
1201         strcpy(myscore.name,"");\r
1202         myscore.score = score;\r
1203         myscore.episode = gamestate.episode;\r
1204         myscore.completed = other;\r
1205 \r
1206         for (i = 0,n = -1;i < MaxScores;i++)\r
1207         {\r
1208                 if\r
1209                 (\r
1210                         (myscore.score > Scores[i].score)\r
1211                 ||      (\r
1212                                 (myscore.score == Scores[i].score)\r
1213                         &&      (myscore.completed > Scores[i].completed)\r
1214                         )\r
1215                 )\r
1216                 {\r
1217                         for (j = MaxScores;--j > i;)\r
1218                                 Scores[j] = Scores[j - 1];\r
1219                         Scores[i] = myscore;\r
1220                         n = i;\r
1221                         break;\r
1222                 }\r
1223         }\r
1224 \r
1225 #ifdef SPEAR\r
1226         StartCPMusic (XAWARD_MUS);\r
1227 #else\r
1228         StartCPMusic (ROSTER_MUS);\r
1229 #endif\r
1230         DrawHighScores ();\r
1231 \r
1232         VW_FadeIn ();\r
1233 \r
1234         if (n != -1)\r
1235         {\r
1236         //\r
1237         // got a high score\r
1238         //\r
1239                 PrintY = 76 + (16 * n);\r
1240 #ifndef SPEAR\r
1241                 PrintX = 4*8;\r
1242                 backcolor = BORDCOLOR;\r
1243                 fontcolor = 15;\r
1244                 US_LineInput(PrintX,PrintY,Scores[n].name,nil,true,MaxHighName,100);\r
1245 #else\r
1246                 PrintX = 16;\r
1247                 fontnumber = 1;\r
1248                 VWB_Bar (PrintX-2,PrintY-2,145,15,0x9c);\r
1249                 VW_UpdateScreen ();\r
1250                 backcolor = 0x9c;\r
1251                 fontcolor = 15;\r
1252                 US_LineInput(PrintX,PrintY,Scores[n].name,nil,true,MaxHighName,130);\r
1253 #endif\r
1254         }\r
1255         else\r
1256         {\r
1257                 IN_ClearKeysDown ();\r
1258                 IN_UserInput(500);\r
1259         }\r
1260 \r
1261 }\r
1262 \r
1263 \r
1264 #ifndef UPLOAD\r
1265 #ifndef SPEAR\r
1266 #ifndef JAPAN\r
1267 ////////////////////////////////////////////////////////\r
1268 //\r
1269 // NON-SHAREWARE NOTICE\r
1270 //\r
1271 ////////////////////////////////////////////////////////\r
1272 void NonShareware(void)\r
1273 {\r
1274         VW_FadeOut();\r
1275 \r
1276         ClearMScreen();\r
1277         DrawStripes(10);\r
1278 \r
1279         CA_CacheGrChunk(STARTFONT+1);\r
1280         fontnumber = 1;\r
1281 \r
1282         SETFONTCOLOR(READHCOLOR,BKGDCOLOR);\r
1283         PrintX=110;\r
1284         PrintY=15;\r
1285 \r
1286         #ifdef SPANISH\r
1287         US_Print("Atencion");\r
1288         #else\r
1289         US_Print("Attention");\r
1290         #endif\r
1291 \r
1292         SETFONTCOLOR(HIGHLIGHT,BKGDCOLOR);\r
1293         WindowX=PrintX=40;\r
1294         PrintY=60;\r
1295         #ifdef SPANISH\r
1296         US_Print("Este juego NO es gratis y\n");\r
1297         US_Print("NO es Shareware; favor de\n");\r
1298         US_Print("no distribuirlo.\n\n");\r
1299         #else\r
1300         US_Print("This game is NOT shareware.\n");\r
1301         US_Print("Please do not distribute it.\n");\r
1302         US_Print("Thanks.\n\n");\r
1303         #endif\r
1304         US_Print("        Id Software\n");\r
1305 \r
1306         VW_UpdateScreen ();\r
1307         VW_FadeIn();\r
1308         IN_Ack();\r
1309 }\r
1310 #endif\r
1311 #endif\r
1312 #endif\r
1313 \r
1314 #ifdef SPEAR\r
1315 #ifndef SPEARDEMO\r
1316 ////////////////////////////////////////////////////////\r
1317 //\r
1318 // COPY PROTECTION FOR FormGen\r
1319 //\r
1320 ////////////////////////////////////////////////////////\r
1321 char    far CopyProFailedStrs[][100] = {\r
1322                         STR_COPY1,\r
1323                         STR_COPY2,\r
1324 \r
1325                         STR_COPY3,\r
1326                         STR_COPY4,\r
1327 \r
1328                         STR_COPY5,\r
1329                         STR_COPY6,\r
1330 \r
1331                         STR_COPY7,\r
1332                         STR_COPY8,\r
1333 \r
1334                         STR_COPY9,\r
1335                         "",\r
1336 \r
1337                         STR_COPY10,\r
1338                         STR_COPY11,\r
1339 \r
1340                         STR_COPY12,\r
1341                         "",\r
1342 \r
1343                         STR_COPY13,\r
1344                         "",\r
1345 \r
1346                         STR_COPY14,\r
1347                         ""\r
1348                         },\r
1349 \r
1350                 far BackDoorStrs[5][16] = {\r
1351                         "a spoon?",\r
1352                         "bite me!",\r
1353                         "joshua",\r
1354                         "pelt",\r
1355 #ifdef BETA\r
1356                         "beta"\r
1357 #else\r
1358                         "snoops"\r
1359 #endif\r
1360                         },\r
1361 \r
1362                 far GoodBoyStrs[10][40] = {\r
1363                         "...is the CORRECT ANSWER!",\r
1364                         "",\r
1365 \r
1366                         "Consider yourself bitten, sir.",\r
1367                         "",\r
1368 \r
1369                         "Greetings Professor Falken, would you",\r
1370                         "like to play Spear of Destiny?",\r
1371 \r
1372                         "Do you have any gold spray paint?",\r
1373                         "",\r
1374 \r
1375 #ifdef BETA\r
1376                         "Beta testing approved.",\r
1377 #else\r
1378                         "I wish I had a 21\" monitor...",\r
1379 #endif\r
1380                         ""\r
1381                         },\r
1382 \r
1383                 far bossstrs[4][24] = {\r
1384                         "DEATH KNIGHT",\r
1385                         "BARNACLE WILHELM",\r
1386                         "UBERMUTANTUBER MUTANT",\r
1387                         "TRANS GROSSE"\r
1388                         },\r
1389 \r
1390                 far WordStr[5][20] = {\r
1391                         "New Game",\r
1392                         "Sound...F4",\r
1393                         "Control...F6",\r
1394                         "Change View...F5",\r
1395                         "Quit...F10"},\r
1396 \r
1397                 far     WordCorrect[5][2] = {"3","4","4","5","5"},\r
1398 \r
1399                 far MemberStr[10][40] = {\r
1400                         STR_COPY15,\r
1401                         "",\r
1402 \r
1403                         STR_COPY16,\r
1404                         "",\r
1405 \r
1406                         STR_COPY17,\r
1407                         STR_COPY18,\r
1408 \r
1409                         STR_COPY19,\r
1410                         STR_COPY20,\r
1411 \r
1412                         STR_COPY21,\r
1413                         STR_COPY22},\r
1414 \r
1415                 far MemberCorrect[5][24] = {\r
1416                         "adrian carmack",\r
1417                         "john carmackjohn romero",\r
1418                         "tom hall",\r
1419                         "jay wilbur",\r
1420                         "kevin cloud"},\r
1421 \r
1422                 far DosMessages[9][80] = {\r
1423                         STR_NOPE1,\r
1424                         STR_NOPE2,\r
1425                         STR_NOPE3,\r
1426                         STR_NOPE4,\r
1427                         STR_NOPE5,\r
1428                         STR_NOPE6,\r
1429                         STR_NOPE7,\r
1430                         STR_NOPE8,\r
1431                         STR_NOPE9},\r
1432 \r
1433                 far MiscTitle[4][20] = {\r
1434                         "BLOOD TEST",\r
1435                         "STRAIGHT-LACED",\r
1436                         "QUITE SHAPELY",\r
1437                         "I AM WHAT I AMMO"\r
1438                         },\r
1439 \r
1440                 far MiscStr[12][40] = {\r
1441                         STR_MISC1,\r
1442                         STR_MISC2,\r
1443                         "",\r
1444 \r
1445                         STR_MISC3,\r
1446                         STR_MISC4,\r
1447                         "",\r
1448 \r
1449                         STR_MISC5,\r
1450                         STR_MISC6,\r
1451                         "",\r
1452 \r
1453                         STR_MISC7,\r
1454                         STR_MISC8,\r
1455                         STR_MISC9\r
1456                         },\r
1457 \r
1458                 far MiscCorrect[4][5] = {"ss","8",STR_STAR,"45"};\r
1459 \r
1460 \r
1461 int  BackDoor(char *s)\r
1462 {\r
1463         int i;\r
1464 \r
1465 \r
1466         strlwr(s);\r
1467 \r
1468         for (i=0;i<5;i++)\r
1469                 if (!_fstrcmp(s,BackDoorStrs[i]))\r
1470                 {\r
1471                         SETFONTCOLOR(14,15);\r
1472                         fontnumber = 0;\r
1473                         PrintY = 175;\r
1474                         VWB_DrawPic (0,20*8,COPYPROTBOXPIC);\r
1475                         US_CPrint(GoodBoyStrs[i*2]);\r
1476                         US_CPrint(GoodBoyStrs[i*2+1]);\r
1477                         VW_UpdateScreen();\r
1478                         return 1;\r
1479                 }\r
1480 \r
1481         return 0;\r
1482 }\r
1483 \r
1484 \r
1485 void CopyProtection(void)\r
1486 {\r
1487 #define TYPEBOX_Y               177\r
1488 #define TYPEBOX_BKGD    0x9c\r
1489 #define PRINTCOLOR              HIGHLIGHT\r
1490 \r
1491         int     i,match,whichboss,bossnum,try,whichline,enemypicked[4]={0,0,0,0},\r
1492                 bosses[4] = { BOSSPIC1PIC,BOSSPIC2PIC,BOSSPIC3PIC,BOSSPIC4PIC },\r
1493                 whichone,whichpicked[4]={0,0,0,0},quiztype,whichmem,\r
1494                 memberpicked[5]={0,0,0,0,0},wordpicked[5]={0,0,0,0,0},whichword;\r
1495 \r
1496         char    inputbuffer[20],\r
1497                         message[80];\r
1498 \r
1499         enum\r
1500         {\r
1501                 debriefing,\r
1502                 checkmanual,\r
1503                 staffquiz,\r
1504                 miscquiz,\r
1505 \r
1506                 totaltypes\r
1507         };\r
1508 \r
1509 \r
1510 \r
1511         try = 0;\r
1512         VW_FadeOut();\r
1513         CA_CacheGrChunk(C_BACKDROPPIC);\r
1514         CacheLump(COPYPROT_LUMP_START,COPYPROT_LUMP_END);\r
1515         CA_CacheGrChunk(STARTFONT+1);\r
1516         CA_LoadAllSounds();\r
1517         StartCPMusic(COPYPRO_MUS);\r
1518         US_InitRndT(true);\r
1519 \r
1520         while (try<3)\r
1521         {\r
1522                 fontnumber = 1;\r
1523                 SETFONTCOLOR(PRINTCOLOR-2,15);\r
1524                 VWB_DrawPic (0,0,C_BACKDROPPIC);\r
1525                 VWB_DrawPic (0,0,COPYPROTTOPPIC);\r
1526                 VWB_DrawPic (0,20*8,COPYPROTBOXPIC);\r
1527                 WindowX = WindowY = 0;\r
1528                 WindowW = 320;\r
1529                 WindowH = 200;\r
1530                 PrintY = 65;\r
1531 \r
1532                 quiztype = US_RndT()%totaltypes;\r
1533                 switch(quiztype)\r
1534                 {\r
1535                         //\r
1536                         // BOSSES QUIZ\r
1537                         //\r
1538                         case debriefing:\r
1539                                 PrintX = 0;\r
1540                                 US_Print(STR_DEBRIEF);\r
1541                                 SETFONTCOLOR(PRINTCOLOR,15);\r
1542 \r
1543                                 while (enemypicked[whichboss = US_RndT()&3]);\r
1544                                 enemypicked[whichboss] = 1;\r
1545                                 bossnum = bosses[whichboss];\r
1546                                 VWB_DrawPic(128,60,bossnum);\r
1547                                 fontnumber = 0;\r
1548                                 PrintY = 130;\r
1549                                 US_CPrint(STR_ENEMY1"\n");\r
1550                                 US_CPrint(STR_ENEMY2"\n\n");\r
1551 \r
1552                                 VW_UpdateScreen();\r
1553                                 VW_FadeIn();\r
1554 \r
1555                                 PrintX = 100;\r
1556                                 fontcolor = 15;\r
1557                                 backcolor = TYPEBOX_BKGD;\r
1558                                 inputbuffer[0] = 0;\r
1559                                 PrintY = TYPEBOX_Y;\r
1560                                 fontnumber = 1;\r
1561                                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,20,100);\r
1562 \r
1563                                 match = 0;\r
1564                                 for (i=0;i<_fstrlen(bossstrs[whichboss]);i++)\r
1565                                         if (!_fstrnicmp(inputbuffer,bossstrs[whichboss]+i,strlen(inputbuffer)) &&\r
1566                                                 strlen(inputbuffer)>3)\r
1567                                                 match = 1;\r
1568 \r
1569                                 match += BackDoor(inputbuffer);\r
1570                                 break;\r
1571 \r
1572                         //\r
1573                         // MANUAL CHECK\r
1574                         //\r
1575                         case checkmanual:\r
1576                                 while (wordpicked[whichword = US_RndT()%5]);\r
1577                                 wordpicked[whichword] = 1;\r
1578                                 US_CPrint(STR_CHECKMAN);\r
1579                                 SETFONTCOLOR(PRINTCOLOR,15);\r
1580                                 PrintY += 25;\r
1581                                 US_CPrint(STR_MAN1);\r
1582                                 US_CPrint(STR_MAN2);\r
1583                                 _fstrcpy(message,STR_MAN3" \"");\r
1584                                 _fstrcat(message,WordStr[whichword]);\r
1585                                 _fstrcat(message,"\" "STR_MAN4);\r
1586                                 US_CPrint(message);\r
1587                                 VW_UpdateScreen();\r
1588                                 VW_FadeIn();\r
1589 \r
1590                                 PrintX = 146;\r
1591                                 fontcolor = 15;\r
1592                                 backcolor = TYPEBOX_BKGD;\r
1593                                 inputbuffer[0] = 0;\r
1594                                 PrintY = TYPEBOX_Y;\r
1595                                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,6,100);\r
1596 \r
1597                                 strlwr(inputbuffer);\r
1598                                 match = 1-(_fstrcmp(inputbuffer,WordCorrect[whichword])!=0);\r
1599                                 match += BackDoor(inputbuffer);\r
1600                                 break;\r
1601 \r
1602                         //\r
1603                         // STAFF QUIZ\r
1604                         //\r
1605                         case staffquiz:\r
1606                                 while (memberpicked[whichmem = US_RndT()%5]);\r
1607                                 memberpicked[whichmem] = 1;\r
1608                                 US_CPrint(STR_ID1);\r
1609                                 SETFONTCOLOR(PRINTCOLOR,15);\r
1610                                 PrintY += 25;\r
1611                                 US_CPrint(MemberStr[whichmem*2]);\r
1612                                 US_CPrint(MemberStr[whichmem*2+1]);\r
1613                                 VW_UpdateScreen();\r
1614                                 VW_FadeIn();\r
1615 \r
1616                                 PrintX = 100;\r
1617                                 fontcolor = 15;\r
1618                                 backcolor = TYPEBOX_BKGD;\r
1619                                 inputbuffer[0] = 0;\r
1620                                 PrintY = TYPEBOX_Y;\r
1621                                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,20,120);\r
1622 \r
1623                                 strlwr(inputbuffer);\r
1624                                 match = 0;\r
1625                                 for (i=0;i<_fstrlen(MemberCorrect[whichmem]);i++)\r
1626                                         if (!_fstrnicmp(inputbuffer,MemberCorrect[whichmem]+i,strlen(inputbuffer)) &&\r
1627                                                 strlen(inputbuffer)>2)\r
1628                                                         match = 1;\r
1629                                 match += BackDoor(inputbuffer);\r
1630                                 break;\r
1631 \r
1632                         //\r
1633                         // MISCELLANEOUS QUESTIONS\r
1634                         //\r
1635                         case miscquiz:\r
1636                                 while (whichpicked[whichone = US_RndT()&3]);\r
1637                                 whichpicked[whichone] = 1;\r
1638                                 US_CPrint(MiscTitle[whichone]);\r
1639                                 SETFONTCOLOR(PRINTCOLOR,15);\r
1640                                 PrintY += 25;\r
1641                                 US_CPrint(MiscStr[whichone*3]);\r
1642                                 US_CPrint(MiscStr[whichone*3+1]);\r
1643                                 US_CPrint(MiscStr[whichone*3+2]);\r
1644                                 VW_UpdateScreen();\r
1645                                 VW_FadeIn();\r
1646 \r
1647                                 PrintX = 146;\r
1648                                 fontcolor = 15;\r
1649                                 backcolor = TYPEBOX_BKGD;\r
1650                                 inputbuffer[0] = 0;\r
1651                                 PrintY = TYPEBOX_Y;\r
1652                                 US_LineInput(PrintX,PrintY,inputbuffer,nil,true,6,100);\r
1653 \r
1654                                 strlwr(inputbuffer);\r
1655                                 match = 1-(_fstrcmp(inputbuffer,MiscCorrect[whichone])!=0);\r
1656                                 match += BackDoor(inputbuffer);\r
1657                                 break;\r
1658                         }\r
1659 \r
1660                 //\r
1661                 // IF NO MATCH, WE'VE GOT A (MINOR) PROBLEM!\r
1662                 //\r
1663 \r
1664                 if (!match)\r
1665                 {\r
1666                         whichline = 2*(US_RndT()%9);\r
1667                         SETFONTCOLOR(14,15);\r
1668                         fontnumber = 0;\r
1669                         PrintY = 175;\r
1670                         VWB_DrawPic (0,20*8,COPYPROTBOXPIC);\r
1671                         US_CPrint(CopyProFailedStrs[whichline]);\r
1672                         US_CPrint(CopyProFailedStrs[whichline+1]);\r
1673 \r
1674                         VW_UpdateScreen();\r
1675                         SD_PlaySound(NOWAYSND);\r
1676                         IN_UserInput(TickBase*3);\r
1677                         VW_FadeOut();\r
1678                         try++;\r
1679                 }\r
1680                 else\r
1681                 {\r
1682                         int start;\r
1683 \r
1684 \r
1685                         SD_PlaySound(BONUS1UPSND);\r
1686                         SD_WaitSoundDone();\r
1687                         UNCACHEGRCHUNK (STARTFONT+1);\r
1688                         UNCACHEGRCHUNK (C_BACKDROPPIC);\r
1689                         UnCacheLump (COPYPROT_LUMP_START,COPYPROT_LUMP_END);\r
1690 \r
1691                         switch(SoundMode)\r
1692                         {\r
1693                                 case sdm_Off: return;\r
1694                                 case sdm_PC: start = STARTPCSOUNDS; break;\r
1695                                 case sdm_AdLib: start = STARTADLIBSOUNDS;\r
1696                         }\r
1697 \r
1698                         for (i=0;i<NUMSOUNDS;i++,start++)\r
1699                                 MM_FreePtr ((memptr *)&audiosegs[start]);\r
1700                         return;\r
1701                 }\r
1702         }\r
1703 \r
1704         ClearMemory();\r
1705         ShutdownId();\r
1706 \r
1707         _fstrcpy(message,DosMessages[US_RndT()%9]);\r
1708 \r
1709         _AX = 3;\r
1710         geninterrupt(0x10);\r
1711 \r
1712         printf("%s\n",message);\r
1713         exit(1);\r
1714 }\r
1715 \r
1716 #endif // SPEARDEMO\r
1717 #endif // SPEAR\r
1718 //===========================================================================\r