1 /*********************************************************************
2 *
3 * WHMENU.C - menu code for Witchaven game
4 *
5 *********************************************************************/
6
7 #include "witchaven.h"
8 #include "player.h"
9 #include "sound.h"
10 #include "menu.h"
11 #include "input.h"
12 #include "keyboard.h"
13
asmwaitvrt(int parm1)14 void asmwaitvrt(int parm1)
15 {
16 }
17
asmsetpalette(uint8_t * pal)18 void asmsetpalette(uint8_t *pal)
19 {
20 }
21
22 int loopinstuff; //here it is
23
24 extern int musiclevel;
25 extern int digilevel;
26
27 extern int gameactivated;
28 extern int escapetomenu;
29
30 extern int mapon;
31 extern int thunderflash;
32 extern int thundertime;
33
34
35 int loadedgame = 0;
36 int loadgo = 0;
37
38 char typemessage[162], typemessageleng = 0, typemode = 0;
39
40
41 char scantoasc[128] = {
42 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0,
43 'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s',
44 'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v',
45 'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0,
46 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1',
47 '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,
48 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
49 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
50 };
51
52 char scantoascwithshift[128] = {
53 0,0,'!','@','#','$','%','^','&','*','(',')','_','+',0,0,
54 'Q','W','E','R','T','Y','U','I','O','P','{','}',0,0,'A','S',
55 'D','F','G','H','J','K','L',':',34,'~',0,'|','Z','X','C','V',
56 'B','N','M','<','>','?',0,'*',0,32,0,0,0,0,0,0,
57 0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1',
58 '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,
59 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
60 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
61 };
62
63 #define MAXSAVEDGAMES 5
64 char savedgamenames[MAXSAVEDGAMES][20];
65
66 extern int gameactivated;
67
68 //
69 // fancy font
70 //
71 // to use this function you will need to name the starting letter
72 // the function will then scan the string and display its chars
73
74 char fancy[41] = { 'a','b','c','d','e',
75 'f','g','h','i','j',
76 'k','l','m','n','o',
77 'p','q','r','s','t',
78 'u','v','w','x','y',
79 'z','0','1','2','3',
80 '4','5','6','7','8',
81 '9','!','?','-',':',' '};
82
83 #if 0
84 void loadsavetoscreen()
85 {
86 if (svga == 0)
87 permanentwritesprite(0L, 0, ZLOADSAVE, 0, 0, 0, 319, 199, 0);
88 else {
89 rotatesprite(0 << 16, 0 << 16, 65536, 0, VLOAD, 0, 0, 8 + 16, 0, 0, xdim - 1, ydim - 1);
90 rotatesprite(0 << 16, 240 << 16, 65536, 0, VSAVE, 0, 0, 8 + 16, 0, 0, xdim - 1, ydim - 1);
91 }
92 }
93
94 void menutoscreen()
95 {
96 if (svga == 0)
97 permanentwritesprite(0, 0, THEMAINMENUWITH, 0, 0, 0, 319, 199, 0);
98 else
99 rotatesprite(0 << 16, 0 << 16, 65536, 0, VMAIN, 0, 0, 8 + 16, 0, 0, xdim - 1, ydim - 1);
100 }
101
102 void menutoscreenblank()
103 {
104 permanentwritesprite(0, 0, THEMAINMENU, 0, 0, 0, 319, 199, 0);
105 }
106 #endif
107
itemtoscreen(int x,int y,short tilenum,int8_t shade,char pal)108 void itemtoscreen(int x, int y, short tilenum, int8_t shade, char pal)
109 {
110 overwritesprite(x, y, tilenum, shade, 2, pal);
111 //rotatesprite_fs(x, y, 65536, 0, dapic, dashade, dapal, 1024);
112 //permanentwritesprite(x, y, dapic, dashade, x, y, xdim - 1, ydim - 1, dapal);
113 }
114
playrandomsound()115 static void playrandomsound()
116 {
117 SND_Sound(rand() % 60);
118 }
119
fancyfont(int x,int y,short tilenum,char * string,char pal)120 void fancyfont(int x, int y, short tilenum, char* string, char pal)
121 {
122 int incr = 0;
123 int exit = 0;
124 int number;
125 char temp[40];
126
127 strcpy(temp, string);
128 Bstrlwr(temp);
129 int len = strlen(temp);
130
131 for (int i = 0; i < len; i++)
132 {
133 for (int j = 0; j < 40; j++)
134 {
135 if (temp[i] == fancy[j]) {
136 number = j;
137 }
138 }
139 if (i == 0)
140 {
141 overwritesprite(x, y, tilenum + number, 0, 2, pal);
142 incr += tilesiz[tilenum + number].x + 1;
143 }
144 else if (temp[i] != ' ')
145 {
146 overwritesprite(x + incr, y, tilenum + number, 0, 2, pal);
147 incr += tilesiz[tilenum + number].x + 1;
148 }
149 else {
150 incr += 8;
151 }
152 }
153 }
154
fancyfontscreen(int x,int y,short tilenum,char * string)155 void fancyfontscreen(int x, int y, short tilenum, char* string)
156 {
157 int incr = 0;
158 int exit = 0;
159 int number;
160 char temp[40];
161
162 strcpy(temp, string);
163 Bstrlwr(temp);
164 int len = strlen(temp);
165
166 for (int i = 0; i < len; i++)
167 {
168 for (int j = 0; j < 40; j++)
169 {
170 if (temp[i] == fancy[j]) {
171 number = j;
172 }
173 }
174 if (i == 0) {
175 overwritesprite(x, y, tilenum + number, 0, 0x02, 7);
176 incr += tilesiz[tilenum + number].x + 1;
177 }
178 else if (temp[i] != ' ') {
179 overwritesprite(x + incr, y, tilenum + number, 0, 0x02, 7);
180 incr += tilesiz[tilenum + number].x + 1;
181 }
182 else {
183 incr += 8;
184 }
185 }
186 }
187
menuscreen()188 int menuscreen()
189 {
190 videoClearScreen(0);
191
192 struct {
193 int x;
194 int y;
195 }redpic[5] = {
196 { 142,58 },
197 { 140,80 },
198 { 127,104 },
199 { 184,126 },
200 { 183,150 }
201 };
202
203 int exit = 0;
204 int select = 0;
205 short redpicnum;
206
207 if (netgame) {
208 return 0;
209 }
210
211 SND_CheckLoops();
212
213 redpicnum = NEWGAMEGREEN;
214
215 KB_FlushKeyboardQueue();
216 KB_ClearKeysDown();
217
218 int32_t goaltime = (int)totalclock + 10;
219
220 if (svga == 1) {
221 permanentwritesprite(0, 0, SVGAMENU, 0, 0, 0, 639, 239, 0);
222 permanentwritesprite(0, 240, SVGAMENU2, 0, 0, 240, 639, 479, 0);
223 }
224
225 while (!exit)
226 {
227 handleevents();
228
229 videoClearViewableArea(0);
230
231 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
232 overwritesprite(127, 58, MENUSELECTIONS, 0, 2, 0);
233
234 if (select < 5) {
235 redpicnum = NEWGAMEGREEN + select;
236 overwritesprite(redpic[select].x, redpic[select].y, redpicnum, 0, 2, 0);
237 }
238
239 videoNextPage();
240
241 if ((int)totalclock >= goaltime)
242 {
243 goaltime = (int)totalclock + 10;
244
245 if (keystatus[sc_DownArrow] || keystatus[sc_kpad_2])
246 {
247 playrandomsound();
248 select++;
249 if (select > 4)
250 select = 0;
251
252 keystatus[sc_DownArrow] = 0;
253 keystatus[sc_kpad_2] = 0;
254 }
255
256 if (keystatus[sc_UpArrow] || keystatus[sc_kpad_8])
257 {
258 playrandomsound();
259 select--;
260 if (select < 0)
261 select = 4;
262
263 keystatus[sc_UpArrow] = 0;
264 keystatus[sc_kpad_8] = 0;
265 }
266 if (keystatus[sc_Escape] > 0)
267 {
268 playrandomsound();
269
270 if (gameactivated == 1)
271 {
272 lockclock = (int)totalclock;
273 exit = 1;
274 }
275 else {
276 select = 4;
277 }
278 keystatus[sc_Escape] = 0;
279 }
280 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0)
281 {
282 keystatus[sc_Return] = 0;
283 keystatus[sc_kpad_Enter] = 0;
284
285 switch (select)
286 {
287 case 0:
288 {
289 gameactivated = 0;
290
291 SND_Sting(S_STING1);
292 SND_FadeMusic();
293 srand((int)totalclock & 30000);
294
295 startnewgame();
296 gameactivated = 1;
297 exit = 1;
298 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0; keystatus[sc_Escape] = 0;
299 break;
300 }
301 case 1:
302 {
303 playrandomsound();
304 loadsave();
305 if (loadgo == 1)
306 exit = 1;
307 loadgo = 0;
308 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0; keystatus[sc_Escape] = 0;
309 }
310 break;
311 case 2:
312 {
313 playrandomsound();
314 thedifficulty();
315 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0; keystatus[sc_Escape] = 0;
316 }
317 break;
318 case 3:
319 {
320 playrandomsound();
321 help();
322 }
323 break;
324 case 4:
325 {
326 playrandomsound();
327 quit();
328 }
329 break;
330 case 5:
331 {
332 lockclock = (int)totalclock;
333 exit = 1;
334 }
335 break;
336 }
337 }
338 }
339
340 // TEMP
341 int time = (int)totalclock + 2;
342 while ((int)totalclock < time)
343 {
344 handleevents();
345 }
346 }
347
348 escapetomenu = 0;
349
350 return 0;
351 }
352
help()353 void help()
354 {
355 struct {
356 int helpnames;
357 }thenames[] = { WEAPONS,
358 SPELLS,
359 POTIONS,
360 WALKING,
361 FLYING,
362 CREDIT1,
363 CREDIT2,
364 CREDIT3,
365 CREDIT4,
366 BETAPAGE };
367
368 int select = 0;
369 int32_t goaltime = 0;
370 int exit = 0;
371
372 while (!exit)
373 {
374 handleevents();
375
376 if ((int)totalclock >= goaltime)
377 {
378 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
379 overwritesprite(0, 0, thenames[select].helpnames, 0, 2, 0);
380
381 videoNextPage();
382
383 goaltime = (int)totalclock + 10;
384
385 if (keystatus[sc_DownArrow]
386 || keystatus[sc_RightArrow]
387 || keystatus[sc_kpad_2]
388 || keystatus[sc_kpad_6])
389 {
390 playrandomsound();
391 select++;
392 if (select > 9)
393 select = 9;
394
395 KB_ClearKeysDown();
396 }
397 if (keystatus[sc_UpArrow]
398 || keystatus[sc_LeftArrow]
399 || keystatus[sc_kpad_8]
400 || keystatus[sc_kpad_4])
401 {
402 playrandomsound();
403 select--;
404 if (select < 0)
405 select = 0;
406
407 KB_ClearKeysDown();
408 }
409 if (keystatus[sc_Escape] > 0) {
410 exit = 1;
411 keystatus[sc_Escape] = 0;
412 }
413 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0) {
414 exit = 2;
415 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
416 }
417 }
418 }
419 keystatus[sc_Escape] = keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
420 }
421
loadsave()422 void loadsave()
423 {
424 int exit = 0;
425 int select = 0;
426
427 int32_t goaltime = (int)totalclock + 10;
428 /*
429 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
430 overwritesprite(182, 80, LOADGREEN, 0, 2, 0);
431 overwritesprite(182, 119, SAVERED, 0, 2, 0);
432 */
433 while (!exit)
434 {
435 handleevents();
436
437 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
438 overwritesprite(182, 80, LOADGREEN, 0, 2, 0);
439 overwritesprite(182, 119, SAVERED, 0, 2, 0);
440
441 if (select == 0)
442 {
443 overwritesprite(182, 80, LOADGREEN, 0, 2, 0);
444 overwritesprite(182, 119, SAVERED, 0, 2, 0);
445 }
446 else
447 {
448 overwritesprite(182, 80, LOADRED, 0, 2, 0);
449 overwritesprite(182, 119, SAVEGREEN, 0, 2, 0);
450 }
451
452 if ((int)totalclock >= goaltime)
453 {
454 goaltime = (int)totalclock + 10;
455
456 if (keystatus[sc_DownArrow] || keystatus[sc_kpad_2])
457 {
458 playrandomsound();
459 select = 1;
460
461 keystatus[sc_DownArrow] = 0;
462 keystatus[sc_kpad_2] = 0;
463 }
464 if (keystatus[sc_UpArrow] || keystatus[sc_kpad_8])
465 {
466 playrandomsound();
467 select = 0;
468
469 keystatus[sc_UpArrow] = 0;
470 keystatus[sc_kpad_8] = 0;
471 }
472
473 if (keystatus[sc_Escape] > 0) {
474 exit = 1;
475 keystatus[sc_Escape] = 0;
476 }
477 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0)
478 {
479 exit = 2;
480 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
481 }
482 }
483 videoNextPage();
484 }
485
486 keystatus[sc_Escape] = 0;
487
488 if (exit == 2)
489 {
490 switch (select)
491 {
492 case 0:
493 {
494 loadgame();
495 }
496 break;
497 case 1:
498 {
499 if (gameactivated == 1) {
500 savegame();
501 }
502 }
503 break;
504 }
505 }
506 }
507
quit()508 void quit()
509 {
510 int exit = 0;
511
512 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
513 overwritesprite(123, 79, AREYOUSURE, 0, 2, 0);
514 videoNextPage();
515
516 while (!exit)
517 {
518 handleevents();
519
520 if (keystatus[sc_kpad_Enter] > 0 || keystatus[sc_Return] > 0 || keystatus[sc_Y] > 0) {
521 exit = 1;
522 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
523 }
524 if (keystatus[sc_Escape] > 0 || keystatus[sc_N] > 0) {
525 exit = 2;
526 keystatus[sc_Escape] = 0;
527 }
528 }
529
530 if (exit == 2) {
531 keystatus[sc_Escape] = 0;
532 }
533 else
534 {
535 if (svga == 1)
536 {
537 permanentwritesprite(0, 0, SVGAORDER1, 0, 0, 0, 639, 239, 0);
538 permanentwritesprite(0, 240, SVGAORDER2, 0, 0, 240, 639, 479, 0);
539 videoNextPage();
540
541 exit = 0;
542
543 while (!exit)
544 {
545 handleevents();
546
547 if (keystatus[sc_Space] > 0 || keystatus[sc_Escape] > 0) {
548 exit = 1;
549 }
550 }
551
552 keystatus[sc_Space] = 0;
553 keystatus[sc_Escape] = 0;
554 }
555 else
556 {
557 keystatus[sc_Space] = 0;
558 keystatus[sc_Escape] = 0;
559 exit = 0;
560
561 while (!exit)
562 {
563 handleevents();
564
565 if (keystatus[sc_Space] > 0 || keystatus[sc_Escape] > 0) {
566 exit = 1;
567 }
568
569 overwritesprite(0, 0, ORDER1, 0, 2, 0);
570 videoNextPage();
571 }
572
573 keystatus[sc_Space] = 0;
574 keystatus[sc_Escape] = 0;
575 exit = 0;
576 /*
577 while( !exit ){
578 if(keystatus[sc_Space] > 0 || keystatus[sc_Escape] > 0)
579 exit=1;
580 overwritesprite(0,0,ORDER2,0,0,0);
581 nextpage();
582 }
583 keystatus[sc_Space]=0;
584 keystatus[sc_Escape]=0;
585 exit=0;
586 */
587 }
588 shutdown();
589 }
590 }
591
thedifficulty()592 void thedifficulty()
593 {
594 struct {
595 int x;
596 int y;
597 }redpic[4] = {
598 { 148,146 },
599 { 181,146 },
600 { 215,144 },
601 { 257,143 }
602 };
603
604 int exit = 0;
605 int selected;
606 int select;
607 int select2 = 0;
608 int select3 = goreon;
609 int redpicnum;
610 int pickone = 0;
611
612 Player *plr = &player[pyrn];
613
614 select = difficulty - 1;
615 selected = select;
616
617 keystatus[sc_Escape] = 0;
618 keystatus[sc_Return] = 0;
619 keystatus[sc_kpad_Enter] = 0;
620
621 //loadtile(MAINMENU);
622 /*
623 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
624 overwritesprite(127, 58, BLOODGOREGREEN, 0, 2, 0);
625 overwritesprite(148, 114, DIFFICULTRED, 0, 2, 0);
626
627 if (goreon == 1) {
628 overwritesprite(180, 84, NOGORESHADOW, 0, 0x04, 0);
629 overwritesprite(214, 81, GORESOLID, 0, 0, 0);
630 }
631 else {
632 overwritesprite(180, 84, NOGORESOLID, 0, 0, 0);
633 overwritesprite(214, 81, GORESHADOW, 0, 0x04, 0);
634 }
635 */
636 int32_t goaltime = (int)totalclock + 10;
637
638 while (!exit)
639 {
640 handleevents();
641
642 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
643 /*
644 overwritesprite(127, 58, BLOODGOREGREEN, 0, 2, 0);
645 overwritesprite(148, 114, DIFFICULTRED, 0, 2, 0);
646
647 if (goreon == 1)
648 {
649 overwritesprite(180, 84, NOGORESHADOW, 0, 0x04, 0);
650 overwritesprite(214, 81, GORESOLID, 0, 0, 0);
651 }
652 else
653 {
654 overwritesprite(180, 84, NOGORESOLID, 0, 0, 0);
655 overwritesprite(214, 81, GORESHADOW, 0, 0x04, 0);
656 }
657 */
658 if ((int)totalclock >= goaltime)
659 {
660 goaltime = (int)totalclock + 10;
661
662 if (keystatus[sc_UpArrow] || keystatus[sc_kpad_8])
663 {
664 playrandomsound();
665 select2 = 0;
666
667 keystatus[sc_UpArrow] = 0;
668 keystatus[sc_kpad_8] = 0;
669 }
670 if (keystatus[sc_DownArrow] || keystatus[sc_kpad_2])
671 {
672 playrandomsound();
673 select2 = 1;
674
675 keystatus[sc_DownArrow] = 0;
676 keystatus[sc_kpad_2] = 0;
677 }
678
679 if (select2 == 0)
680 pickone = 0;
681 else
682 pickone = 1;
683
684 redpicnum = HORNYSKULL1 + select;
685
686 // overwritesprite(0, 0, MAINMENU, 0, 2, 0);
687
688 if (select2 == 0) {
689 overwritesprite(148, 114, DIFFICULTRED, 0, 2, 0);
690 overwritesprite(127, 58, BLOODGOREGREEN, 0, 2, 0);
691 }
692 else {
693 overwritesprite(148, 114, DIFFICULTGREEN, 0, 2, 0);
694 overwritesprite(127, 58, BLOODGORERED, 0, 2, 0);
695 }
696
697 overwritesprite(147, 143, HORNYBACK, 0, 2, 0);
698 overwritesprite(redpic[select].x, redpic[select].y, redpicnum, 0, 2, 0);
699
700 if (goreon == 1) {
701 overwritesprite(180, 84, NOGORESHADOW, 0, 0x06, 0);
702 overwritesprite(214, 81, GORESOLID, 0, 2, 0);
703 }
704 else {
705 overwritesprite(180, 84, NOGORESOLID, 0, 2, 0);
706 overwritesprite(214, 81, GORESHADOW, 0, 0x06, 0);
707 }
708
709 if (pickone == 1)
710 {
711 if (keystatus[sc_LeftArrow] || keystatus[sc_kpad_4])
712 {
713 playrandomsound();
714 select--;
715 if (select < 0)
716 select = 0;
717
718 keystatus[sc_LeftArrow] = 0;
719 keystatus[sc_kpad_4] = 0;
720 }
721 if (keystatus[sc_RightArrow] || keystatus[sc_kpad_6])
722 {
723 playrandomsound();
724 select++;
725 if (select > 3)
726 select = 3;
727
728 keystatus[sc_RightArrow] = 0;
729 keystatus[sc_kpad_6] = 0;
730 }
731
732 selected = select;
733 }
734 else
735 {
736 if (keystatus[sc_LeftArrow] || keystatus[sc_kpad_4])
737 {
738 playrandomsound();
739 select3 = 0;
740
741 keystatus[sc_LeftArrow] = 0;
742 keystatus[sc_kpad_4] = 0;
743 }
744 if (keystatus[sc_RightArrow] || keystatus[sc_kpad_6])
745 {
746 playrandomsound();
747 select3 = 1;
748
749 keystatus[sc_RightArrow] = 0;
750 keystatus[sc_kpad_6] = 0;
751 }
752
753 if (select3 == 0)
754 goreon = 0;
755 else
756 goreon = 1;
757 }
758 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0) {
759 exit = 1;
760 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
761 }
762 if (keystatus[sc_Escape] > 0) {
763 exit = 2;
764 keystatus[sc_Escape] = 0;
765 }
766
767 videoNextPage();
768 }
769 }
770
771 if (exit == 1)
772 {
773 switch (selected)
774 {
775 case 0:
776 difficulty = 1;
777 break;
778 case 1:
779 difficulty = 2;
780 break;
781 case 2:
782 difficulty = 3;
783 break;
784 case 3:
785 difficulty = 4;
786 break;
787 }
788 }
789 }
790
startnewgame()791 void startnewgame()
792 {
793 char tempshow2dsector[MAXSECTORS >> 3];
794 char tempshow2dwall[MAXWALLS >> 3];
795 char tempshow2dsprite[MAXSPRITES >> 3];
796 int i;
797
798 if (netgame) {
799 SND_StartMusic(mapon - 1);
800 //goto skip;
801 return;
802 }
803
804 if (loadedgame == 0)
805 {
806 sprintf(boardname, "level%d.map", mapon);
807 setupboard(boardname);
808
809 initplayersprite();
810
811 SND_StartMusic(mapon - 1);
812 }
813 else if (loadedgame == 1)
814 {
815 loadplayerstuff();
816 for (i = 0; i < (MAXSECTORS >> 3); i++) tempshow2dsector[i] = show2dsector[i];
817 for (i = 0; i < (MAXWALLS >> 3); i++) tempshow2dwall[i] = show2dwall[i];
818 for (i = 0; i < (MAXSPRITES >> 3); i++) tempshow2dsprite[i] = show2dsprite[i];
819 setupboard(boardname);
820 for (i = 0; i < (MAXSECTORS >> 3); i++) show2dsector[i] = tempshow2dsector[i];
821 for (i = 0; i < (MAXWALLS >> 3); i++) show2dwall[i] = tempshow2dwall[i];
822 for (i = 0; i < (MAXSPRITES >> 3); i++) show2dsprite[i] = tempshow2dsprite[i];
823 loadedgame = 0;
824 SND_StartMusic(mapon - 1);
825 }
826 #if 0
827 skip:
828 if (plr->screensize < 320)
829 permanentwritesprite(0, 0, BACKGROUND, 0, 0, 0, 319, 199, 0);
830
831 if (plr->screensize <= 320) {
832 permanentwritesprite(0, 200 - 46, NEWSTATUSBAR, 0, 0, 0, 319, 199, 0);
833 }
834 updatepics();
835 #endif
836 }
837
loadgame()838 void loadgame()
839 {
840 int select = 0;
841 int exit = 0;
842
843 int32_t goaltime = (int)totalclock + 10;
844
845 for (int i = 0; i < MAXSAVEDGAMES; i++)
846 {
847 if (!savedgamedat(i)) {
848 strcpy(savedgamenames[i], "empty");
849 }
850 }
851
852 while (!exit)
853 {
854 handleevents();
855
856 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
857 overwritesprite(138, 84, SAVENUMBERS, 0, 2, 0);
858 overwritesprite(190, 48, LOADPIC, 0, 2, 0);
859
860 for (int i = 0; i < MAXSAVEDGAMES; i++) {
861 fancyfont(154, 81 + (i * 17), THEFONT, savedgamenames[i], i == select ? 7 : 0);
862 }
863
864 videoNextPage();
865
866 if ((int)totalclock >= goaltime)
867 {
868 goaltime = (int)totalclock + 10;
869
870 if (keystatus[sc_UpArrow] || keystatus[sc_kpad_8])
871 {
872 select--;
873 if (select < 0)
874 select = 4;
875
876 keystatus[sc_UpArrow] = 0;
877 keystatus[sc_kpad_8] = 0;
878 }
879 if (keystatus[sc_DownArrow] || keystatus[sc_kpad_2])
880 {
881 select++;
882 if (select > 4)
883 select = 0;
884
885 keystatus[sc_DownArrow] = 0;
886 keystatus[sc_kpad_2] = 0;
887 }
888
889 if (keystatus[sc_Escape] > 0) {
890 exit = 1;
891 keystatus[sc_Escape] = 0;
892 }
893
894 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0)
895 {
896 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
897
898 if (strcmp(savedgamenames[select], "empty") == 0) {
899 exit = 0;
900 }
901 else {
902 exit = 2;
903 loadgo = 1;
904 }
905 }
906 }
907 }
908
909 if (exit == 2)
910 {
911 keystatus[sc_Escape] = keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
912
913 sprintf(boardname, "svgm%d.map", select);
914 sprintf(loadgamename, "svgn%d.dat", select);
915
916 loadedgame = 1;
917 gameactivated = 1;
918 startnewgame();
919 }
920 }
921
savegame()922 void savegame()
923 {
924 int exit = 0;
925 int i;
926 int select = 0;
927
928 for (i = 0; i < MAXSAVEDGAMES; i++)
929 {
930 if (!savedgamedat(i)) {
931 strcpy(savedgamenames[i], "EMPTY");
932 }
933 }
934
935 int32_t goaltime = (int)totalclock + 10L;
936
937 while (!exit)
938 {
939 handleevents();
940
941 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
942 overwritesprite(138, 84, SAVENUMBERS, 0, 2, 0);
943 overwritesprite(188, 50, SAVEPIC, 0, 2, 0);
944
945 for (i = 0; i < MAXSAVEDGAMES; i++) {
946 fancyfont(154, 81 + (i * 17), THEFONT, savedgamenames[i], i == select ? 7 : 0);
947 }
948
949 videoNextPage();
950
951 if ((int)totalclock >= goaltime)
952 {
953 goaltime = (int)totalclock + 10;
954
955 if (keystatus[sc_UpArrow] || keystatus[sc_kpad_8])
956 {
957 select--;
958 if (select < 0)
959 select = 4;
960
961 keystatus[sc_UpArrow] = 0;
962 keystatus[sc_kpad_8] = 0;
963 }
964
965 if (keystatus[sc_DownArrow] || keystatus[sc_kpad_2])
966 {
967 select++;
968 if (select > 4)
969 select = 0;
970
971 keystatus[sc_DownArrow] = 0;
972 keystatus[sc_kpad_2] = 0;
973 }
974
975 if (keystatus[sc_Escape] > 0) {
976 exit = 1;
977 keystatus[sc_Escape] = 0;
978 }
979
980 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0) {
981 exit = 2;
982 typemessageleng = 0;
983 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
984 savegametext(select);
985 }
986 }
987 }
988 }
989
savegametext(int select)990 void savegametext(int select)
991 {
992 int exit = 0;
993 int i, j;
994 char tempbuf[BMAX_PATH];
995 char temp[40];
996
997 int typemessageleng = 0;
998
999 Player *plr = &player[pyrn];
1000
1001 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
1002
1003 for (i = 0; i < 128; i++)
1004 keystatus[i] = 0;
1005
1006 strcpy(temp, "-");
1007
1008 while (!exit)
1009 {
1010 handleevents();
1011
1012 overwritesprite(0, 0, MAINMENU, 0, 2, 0);
1013 overwritesprite(138, 84, SAVENUMBERS, 0, 2, 0);
1014 overwritesprite(188, 50, SAVEPIC, 0, 2, 0);
1015
1016 for (i = 0; i < MAXSAVEDGAMES; i++)
1017 {
1018 if (i == select) {
1019 strcpy(tempbuf, temp);
1020 fancyfont(154, 81 + (i * 17), THEFONT, tempbuf, 7);
1021 }
1022 else {
1023 strcpy(tempbuf, savedgamenames[i]);
1024 fancyfont(154, 81 + (i * 17), THEFONT, tempbuf, 0);
1025 }
1026 }
1027
1028 if (keystatus[sc_BackSpace] > 0) // backspace
1029 {
1030 if (typemessageleng > 0) {
1031 temp[typemessageleng] = '\0';
1032 typemessageleng--;
1033 temp[typemessageleng] = '\0';
1034 }
1035 else {
1036 strcpy(temp, "-");
1037 typemessageleng = 0;
1038 }
1039 keystatus[sc_BackSpace] = 0;
1040 }
1041
1042 if (typemessageleng < 10)
1043 {
1044 for (i = 0; i < 128; i++)
1045 {
1046 if (keystatus[i] > 0
1047 && keystatus[sc_BackSpace] == 0
1048 && keystatus[sc_Escape] == 0
1049 && keystatus[sc_Return] == 0
1050 && keystatus[sc_kpad_Enter] == 0)
1051 {
1052 for (j = 0; j < 41; j++)
1053 {
1054 if (scantoasc[i] == ' ') {
1055 continue;
1056 }
1057 else if (scantoasc[i] == fancy[j])
1058 {
1059 temp[typemessageleng] = fancy[j];
1060 typemessageleng++;
1061 temp[typemessageleng] = '\0';
1062 keystatus[i] = 0;
1063 }
1064 else {
1065 keystatus[i] = 0;
1066 }
1067 }
1068 }
1069 }
1070 }
1071
1072 if (keystatus[sc_Escape] > 0) {
1073 exit = 1;
1074 keystatus[sc_Escape] = 0;
1075 }
1076
1077 if (keystatus[sc_Return] > 0 || keystatus[sc_kpad_Enter] > 0)
1078 {
1079 vec3_t pos;
1080 pos.x = plr->x;
1081 pos.y = plr->y;
1082 pos.z = plr->z;
1083
1084 if (typemessageleng > 0)
1085 {
1086 strcpy(savedgamenames[select], temp);
1087
1088 sprintf(tempbuf, "svgm%d.map", select);
1089
1090 saveboard(tempbuf, &pos, plr->ang, plr->sector);
1091 savedgamename(select);
1092 }
1093 else
1094 {
1095 sprintf(tempbuf, "svgm%d.map", select);
1096
1097 saveboard(tempbuf, &pos, plr->ang, plr->sector);
1098 savedgamename(select);
1099 }
1100 exit = 2;
1101 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
1102 }
1103 videoNextPage();
1104 }
1105
1106 if (exit == 2) {
1107 keystatus[sc_Return] = keystatus[sc_kpad_Enter] = 0;
1108 }
1109 }
1110
savedgamename(int gn)1111 int savedgamename(int gn)
1112 {
1113 int tmpanimateptr[MAXANIMATES];
1114 char savefilename[BMAX_PATH];
1115
1116 Player *plr = &player[pyrn];
1117
1118 plr->screensize = 320;
1119
1120 sprintf(savefilename, "svgn%d.dat", gn);
1121
1122 int file = open(savefilename, O_BINARY|O_TRUNC|O_CREAT|O_WRONLY, S_IREAD|S_IWRITE);
1123
1124 if (file != -1)
1125 {
1126 write(file, savedgamenames[gn], sizeof(savedgamenames[0]));
1127 write(file, &player[pyrn], sizeof(Player));
1128 write(file, &visibility, sizeof(visibility));
1129 write(file, &brightness, sizeof(brightness));
1130 write(file, &thunderflash, sizeof(thunderflash));
1131 write(file, &thundertime, sizeof(thundertime));
1132
1133 write(file, &mapon, sizeof(mapon));
1134
1135 write(file, &totalclock, sizeof(totalclock));
1136 write(file, &lockclock, sizeof(lockclock));
1137 write(file, &synctics, sizeof(synctics));
1138
1139 // Warning: only works if all pointers are in sector structures!
1140 for (int i = MAXANIMATES - 1; i >= 0; i--)
1141 tmpanimateptr[i] = (int)((intptr_t)animateptr[i] - (intptr_t)sector);
1142
1143 write(file, animateptr, MAXANIMATES << 2);
1144 write(file, animategoal, MAXANIMATES << 2);
1145 write(file, animatevel, MAXANIMATES << 2);
1146 write(file, &animatecnt, 4);
1147
1148 write(file, show2dsector, MAXSECTORS >> 3);
1149 write(file, show2dwall, MAXWALLS >> 3);
1150 write(file, show2dsprite, MAXSPRITES >> 3);
1151 write(file, &automapping, sizeof(automapping));
1152
1153 close(file);
1154 return 1;
1155 }
1156
1157 return 0;
1158 }
1159
savedgamedat(int gn)1160 int savedgamedat(int gn)
1161 {
1162 int fh = 0, nr = 0;
1163 char fname[BMAX_PATH];
1164 char fsname[BMAX_PATH];
1165
1166 sprintf(fname, "svgm%d.map", gn);
1167 sprintf(fsname, "svgn%d.dat", gn);
1168
1169 if (access(fname, F_OK) != 0)
1170 return 0;
1171
1172 if (access(fsname, F_OK) != 0)
1173 return 0;
1174
1175 fh = open(fsname, O_RDONLY | O_BINARY);
1176
1177 if (fh < 0)
1178 return 0;
1179
1180 nr = read(fh, savedgamenames[gn], sizeof(savedgamenames[0]));
1181
1182 close(fh);
1183
1184 if (nr != sizeof(savedgamenames[0]))
1185 return 0;
1186
1187 return 1;
1188 }
1189
loadplayerstuff()1190 void loadplayerstuff()
1191 {
1192 int tmpanimateptr[MAXANIMATES];
1193
1194 int fh = open(loadgamename, O_RDONLY | O_BINARY);
1195
1196 read(fh, savedgamenames[0], sizeof(savedgamenames[0]));
1197 read(fh, &player[pyrn], sizeof(Player));
1198 read(fh, &visibility, sizeof(visibility));
1199 read(fh, &brightness, sizeof(brightness));
1200 read(fh, &thunderflash, sizeof(thunderflash));
1201 read(fh, &thundertime, sizeof(thundertime));
1202
1203 read(fh, &mapon, sizeof(mapon));
1204
1205 read(fh, &totalclock, sizeof(totalclock));
1206 read(fh, &lockclock, sizeof(lockclock));
1207 read(fh, &synctics, sizeof(synctics));
1208
1209 // Warning: only works if all pointers are in sector structures!
1210 read(fh, tmpanimateptr, MAXANIMATES << 2);
1211 for (int i = MAXANIMATES - 1; i >= 0; i--)
1212 animateptr[i] = (int*)(tmpanimateptr[i] + (intptr_t)sector);
1213
1214 read(fh, animategoal, MAXANIMATES << 2);
1215 read(fh, animatevel, MAXANIMATES << 2);
1216 read(fh, &animatecnt, 4);
1217
1218 read(fh, show2dsector, MAXSECTORS >> 3);
1219 read(fh, show2dwall, MAXWALLS >> 3);
1220 read(fh, show2dsprite, MAXSPRITES >> 3);
1221 read(fh, &automapping, sizeof(automapping));
1222
1223 close(fh);
1224 }
1225
1226 /***************************************************************************
1227 * screen effects for TEKWAR follow...fades, palette stuff, etc.. *
1228 * *
1229 * 12/15/94 Jeff S. *
1230 ***************************************************************************/
1231
1232 char dofadein = 0;
1233
1234 #define DEADTIME 2 // # minutes of nothing happening
1235 #define FLASHINTERVAL 20
1236
1237 int32_t passlock, lastastep, lastbstep, astep, bstep;
1238
1239 extern char flashflag;
1240
1241
screenfx()1242 void screenfx()
1243 {
1244 updatepaletteshifts();
1245 }
1246
clearpal()1247 void clearpal()
1248 {
1249 #if 0
1250 short i;
1251
1252 outp(PEL_WRITE_ADR, 0);
1253 for (i = 0; i < 768; i++)
1254 outp(PEL_DATA, 0x00);
1255 #endif
1256 }
1257
1258
1259 uint8_t palette1[256][3], palette2[256][3];
1260
getpalette(uint8_t * palette)1261 void getpalette(uint8_t *palette)
1262 {
1263 #if 0 // TODO
1264 int i;
1265
1266 outp(PEL_READ_ADR,0);
1267 for( i=0; i<768; i++)
1268 *palette++ = inp(PEL_DATA);
1269 #endif
1270 }
1271
fillpalette(int red,int green,int blue)1272 void fillpalette(int red, int green, int blue)
1273 {
1274 #if 0 // TODO
1275 int i;
1276
1277 outp(PEL_WRITE_ADR,0);
1278 for( i=0; i<256; i++ ) {
1279 outp(PEL_DATA,red);
1280 outp(PEL_DATA,green);
1281 outp(PEL_DATA,blue);
1282 }
1283 #endif
1284 }
1285
1286
1287 bool foggy = false;
1288
fadeout(int start,int end,int red,int green,int blue,int steps)1289 void fadeout(int start, int end, int red, int green, int blue, int steps)
1290 {
1291 int orig, delta;
1292 uint8_t* origptr, * newptr;
1293
1294 asmwaitvrt(1);
1295 getpalette(&palette1[0][0]);
1296 memcpy(palette2, palette1, 768);
1297
1298 for (int i = 0; i < steps; i++)
1299 {
1300 origptr = &palette1[start][0];
1301 newptr = &palette2[start][0];
1302
1303 for (int j = start; j <= end; j++)
1304 {
1305 orig = *origptr++;
1306 delta = red - orig;
1307 *newptr++ = orig + delta * i / steps;
1308 orig = *origptr++;
1309 delta = green - orig;
1310 *newptr++ = orig + delta * i / steps;
1311 orig = *origptr++;
1312 delta = blue - orig;
1313 *newptr++ = orig + delta * i / steps;
1314 }
1315
1316 asmwaitvrt(1);
1317 asmsetpalette(&palette2[0][0]);
1318 }
1319
1320 if (!foggy) {
1321 fillpalette(red, green, blue);
1322 }
1323 }
1324
fadein(int start,int end,int steps)1325 void fadein(int start, int end, int steps)
1326 {
1327 int i, j, delta;
1328
1329 if (steps == 0) {
1330 return;
1331 }
1332
1333 asmwaitvrt(1);
1334 getpalette(&palette1[0][0]);
1335 memcpy(&palette2[0][0], &palette1[0][0], sizeof(palette1));
1336
1337 start *= 3;
1338 end = end * 3 + 2;
1339
1340 // fade through intermediate frames
1341 for (i = 0; i < steps; i++)
1342 {
1343 for (j = start; j <= end; j++)
1344 {
1345 delta = palette[j] - palette1[0][j];
1346 palette2[0][j] = palette1[0][j] + delta * i / steps;
1347 }
1348
1349 asmwaitvrt(1);
1350 asmsetpalette(&palette2[0][0]);
1351 }
1352
1353 // final color
1354 asmsetpalette(palette);
1355
1356 dofadein = 0;
1357 //clearkeys();
1358 }
1359
fog1()1360 void fog1()
1361 {
1362 if (!foggy) {
1363 foggy = true;
1364 fadeout(1, 254, 8, 8, 10, 2);
1365 }
1366 else {
1367 foggy = false;
1368 fadein(0, 255, 2);
1369 }
1370 }
1371
fog2()1372 void fog2()
1373 {
1374 char *lookptr = palookup[0];
1375 palookup[0] = palookup[1];
1376 palookup[1] = lookptr;
1377 }
1378
1379 #if 0 // not used?
1380 void makefxlookups()
1381 {
1382 char palbuf[256];
1383
1384 for (int i = 0; i < 256; i++) {
1385 palbuf[i] = *(palookup[0] + i);
1386 }
1387
1388 // TODO makepalookup(1, palbuf, 60, 60, 60, 1);
1389 }
1390 #endif
1391
1392 #define NUMWHITESHIFTS 3
1393 #define WHITESTEPS 20
1394 #define WHITETICS 6
1395
1396 #define NUMREDSHIFTS 4
1397 #define REDSTEPS 8
1398
1399 #define NUMGREENSHIFTS 4
1400 #define GREENSTEPS 8
1401
1402 #define NUMBLUESHIFTS 4
1403 #define BLUESTEPS 8
1404
1405 uint8_t whiteshifts[NUMREDSHIFTS][768];
1406 uint8_t redshifts[NUMREDSHIFTS][768];
1407 uint8_t greenshifts[NUMGREENSHIFTS][768];
1408 uint8_t blueshifts[NUMBLUESHIFTS][768];
1409
1410 int redcount, whitecount, greencount, bluecount;
1411 char palshifted;
1412
1413
initpaletteshifts()1414 void initpaletteshifts()
1415 {
1416 char* workptr;
1417 int delta;
1418 uint8_t *baseptr;
1419
1420 for (int i = 1; i <= NUMREDSHIFTS; i++)
1421 {
1422 workptr = (char*)&redshifts[i - 1][0];
1423 baseptr = &palette[0];
1424
1425 for (int j = 0; j <= 255; j++)
1426 {
1427 delta = 64 - *baseptr;
1428 *workptr++ = *baseptr++ + delta * i / REDSTEPS;
1429 delta = -*baseptr;
1430 *workptr++ = *baseptr++ + delta * i / REDSTEPS;
1431 delta = -*baseptr;
1432 *workptr++ = *baseptr++ + delta * i / REDSTEPS;
1433 }
1434 }
1435
1436 for (int i = 1; i <= NUMWHITESHIFTS; i++)
1437 {
1438 workptr = (char*)&whiteshifts[i - 1][0];
1439 baseptr = &palette[0];
1440
1441 for (int j = 0; j <= 255; j++)
1442 {
1443 delta = 64 - *baseptr;
1444 *workptr++ = *baseptr++ + delta * i / WHITESTEPS;
1445 delta = 62 - *baseptr;
1446 *workptr++ = *baseptr++ + delta * i / WHITESTEPS;
1447 delta = 0 - *baseptr;
1448 *workptr++ = *baseptr++ + delta * i / WHITESTEPS;
1449 }
1450 }
1451
1452 for (int i = 1; i <= NUMGREENSHIFTS; i++)
1453 {
1454 workptr = (char*)&greenshifts[i - 1][0];
1455 baseptr = &palette[0];
1456
1457 for (int j = 0; j <= 255; j++)
1458 {
1459 delta = -*baseptr;
1460 *workptr++ = *baseptr++ + delta * i / GREENSTEPS;
1461 delta = 64 - *baseptr;
1462 *workptr++ = *baseptr++ + delta * i / GREENSTEPS;
1463 delta = -*baseptr;
1464 *workptr++ = *baseptr++ + delta * i / GREENSTEPS;
1465 }
1466 }
1467
1468 for (int i = 1; i <= NUMBLUESHIFTS; i++)
1469 {
1470 workptr = (char*)&blueshifts[i - 1][0];
1471 baseptr = &palette[0];
1472
1473 for (int j = 0; j <= 255; j++)
1474 {
1475 delta = -*baseptr;
1476 *workptr++ = *baseptr++ + delta * i / BLUESTEPS;
1477 delta = -*baseptr;
1478 *workptr++ = *baseptr++ + delta * i / BLUESTEPS;
1479 delta = 64 - *baseptr;
1480 *workptr++ = *baseptr++ + delta * i / BLUESTEPS;
1481 }
1482 }
1483 }
1484
startgreenflash(int greentime)1485 void startgreenflash(int greentime)
1486 {
1487 greencount = 0;
1488
1489 greencount += greentime;
1490
1491 if (greencount < 0) {
1492 greencount = 0;
1493 }
1494 }
1495
startblueflash(int bluetime)1496 void startblueflash(int bluetime)
1497 {
1498 bluecount = 0;
1499
1500 bluecount += bluetime;
1501
1502 if (bluecount < 0) {
1503 bluecount = 0;
1504 }
1505 }
1506
startredflash(int damage)1507 void startredflash(int damage)
1508 {
1509 redcount = 0;
1510
1511 redcount += damage;
1512
1513 if (redcount < 0) {
1514 redcount = 0;
1515 }
1516 }
1517
startwhiteflash(int bonus)1518 void startwhiteflash(int bonus)
1519 {
1520 whitecount = 0;
1521
1522 whitecount += bonus;
1523
1524 if (whitecount < 0) {
1525 whitecount = 0;
1526 }
1527 }
1528
updatepaletteshifts()1529 void updatepaletteshifts()
1530 {
1531 int red, white, green, blue;
1532
1533 if (whitecount)
1534 {
1535 white = whitecount / WHITETICS + 1;
1536 if (white > NUMWHITESHIFTS)
1537 white = NUMWHITESHIFTS;
1538 whitecount -= synctics;
1539 if (whitecount < 0)
1540 whitecount = 0;
1541 }
1542 else {
1543 white = 0;
1544 }
1545
1546 if (redcount)
1547 {
1548 red = redcount / 10 + 1;
1549 if (red > NUMREDSHIFTS)
1550 red = NUMREDSHIFTS;
1551 redcount -= synctics;
1552 if (redcount < 0)
1553 redcount = 0;
1554 }
1555 else {
1556 red = 0;
1557 }
1558
1559 if (greencount)
1560 {
1561 green = greencount / 10 + 1;
1562 if (green > NUMGREENSHIFTS)
1563 green = NUMGREENSHIFTS;
1564 greencount -= synctics;
1565 if (greencount < 0)
1566 greencount = 0;
1567 }
1568 else {
1569 green = 0;
1570 }
1571
1572 if (bluecount)
1573 {
1574 blue = bluecount / 10 + 1;
1575 if (blue > NUMBLUESHIFTS)
1576 blue = NUMBLUESHIFTS;
1577 bluecount -= synctics;
1578 if (bluecount < 0)
1579 bluecount = 0;
1580 }
1581 else {
1582 blue = 0;
1583 }
1584
1585 if (red)
1586 {
1587 asmwaitvrt(1);
1588 //asmsetpalette(redshifts[red - 1]);
1589
1590 paletteSetColorTable(0, redshifts[red - 1]);
1591
1592 palshifted = 1;
1593 }
1594 else if (white)
1595 {
1596 asmwaitvrt(1);
1597 //asmsetpalette(whiteshifts[white - 1]);
1598
1599 paletteSetColorTable(0, whiteshifts[white - 1]);
1600
1601 palshifted = 1;
1602 }
1603 else if (green)
1604 {
1605 asmwaitvrt(1);
1606 //asmsetpalette(greenshifts[green - 1]);
1607
1608 paletteSetColorTable(0, greenshifts[green - 1]);
1609
1610 palshifted = 1;
1611 }
1612 else if (blue)
1613 {
1614 asmwaitvrt(1);
1615 //asmsetpalette(blueshifts[blue - 1]);
1616
1617 paletteSetColorTable(0, blueshifts[blue - 1]);
1618
1619 palshifted = 1;
1620 }
1621
1622 else if (palshifted)
1623 {
1624 asmwaitvrt(1);
1625 //asmsetpalette(&palette[0]); // back to normal
1626
1627 paletteSetColorTable(0, palette);
1628
1629 setbrightness(gbrightness);
1630 palshifted = 0;
1631 }
1632 }
1633
finishpaletteshifts()1634 void finishpaletteshifts()
1635 {
1636 if (palshifted == 1)
1637 {
1638 palshifted = 0;
1639 asmwaitvrt(1);
1640 // asmsetpalette(&palette[0]);
1641
1642 videoSetPalette(0, BASEPAL, 2 + 8); // TODO
1643 }
1644 }
1645