summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/wolf3d/wl_def.h
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2019-07-07 22:00:20 -0400
committerFranklin Wei <git@fwei.tk>2019-07-09 11:20:55 -0400
commit3f59fc8b771625aca9c3aefe03cf1038d8461963 (patch)
treee0623a323613baa0b0993411b38bcaed144b27ed /apps/plugins/sdl/progs/wolf3d/wl_def.h
parent439a0d1d91fa040d261fc39b87278bc9f5391dcc (diff)
downloadrockbox-3f59fc8b771625aca9c3aefe03cf1038d8461963.tar.gz
rockbox-3f59fc8b771625aca9c3aefe03cf1038d8461963.zip
Wolfenstein 3-D!
This is a port of Wolf4SDL, which is derived from the original id software source release. The port runs on top of the SDL plugin runtime and is loaded as an overlay. Licensing of the game code is not an issue, as discussed below (essentially, the Debian project treats Wolf4SDL as GPLv2, with an email from John Carmack backing it up): http://forums.rockbox.org/index.php?topic=52872 Included is a copy of MAME's Yamaha OPL sound chip emulator (fmopl_gpl.c). This file was not part of the original Wolf4SDL source (which includes a non-GPL'd version), but was rather rebased from from a later MAME source which had been relicensed to GPLv2. Change-Id: I64c2ba035e0be7e2f49252f40640641416613439
Diffstat (limited to 'apps/plugins/sdl/progs/wolf3d/wl_def.h')
-rw-r--r--apps/plugins/sdl/progs/wolf3d/wl_def.h1479
1 files changed, 1479 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/wolf3d/wl_def.h b/apps/plugins/sdl/progs/wolf3d/wl_def.h
new file mode 100644
index 0000000000..04bbb41bfb
--- /dev/null
+++ b/apps/plugins/sdl/progs/wolf3d/wl_def.h
@@ -0,0 +1,1479 @@
1#ifndef WL_DEF_H
2#define WL_DEF_H
3
4// Defines which version shall be built and configures supported extra features
5#include "version.h"
6
7#define SOUND_ENABLE
8
9#include "fixedpoint.h"
10#include <ctype.h>
11#include <stdint.h>
12#include <stdarg.h>
13#include <SDL.h>
14#include <SDL_mixer.h>
15
16#define open rb->open
17#define read(a, b, c) rb->read((a), (b), (c))
18#define write(a, b, c) rb->write((a), (b), (c))
19#define close(a) rb->close(a)
20
21#if !defined O_BINARY
22# define O_BINARY 0
23#endif
24
25#pragma pack(1)
26
27#if defined(_arch_dreamcast)
28#define YESBUTTONNAME "A"
29#define NOBUTTONNAME "B"
30#elif defined(GP2X)
31#define YESBUTTONNAME "Y"
32#define NOBUTTONNAME "B"
33#else
34#define YESBUTTONNAME "Y"
35#define NOBUTTONNAME "N"
36#endif
37
38#include "foreign.h"
39
40#ifndef SPEAR
41 #include "audiowl6.h"
42 #ifdef UPLOAD
43 #include "gfxv_apo.h"
44 #else
45 #ifdef GOODTIMES
46 #include "gfxv_wl6.h"
47 #else
48 #include "gfxv_apo.h"
49 #endif
50 #endif
51#else
52 #include "audiosod.h"
53 #include "gfxv_sod.h"
54 #include "f_spear.h"
55#endif
56
57typedef uint8_t byte;
58typedef uint16_t word;
59typedef int32_t fixed;
60typedef uint32_t longword;
61typedef int8_t boolean;
62typedef void * memptr;
63
64typedef struct
65{
66 int x,y;
67} Point;
68typedef struct
69{
70 Point ul,lr;
71} Rect;
72
73void Quit(const char *errorStr, ...);
74
75#include "id_pm.h"
76#include "id_sd.h"
77#include "id_in.h"
78#include "id_vl.h"
79#include "id_vh.h"
80#include "id_us.h"
81#include "id_ca.h"
82
83#include "wl_menu.h"
84
85#define MAPSPOT(x,y,plane) (mapsegs[plane][((y)<<mapshift)+(x)])
86
87#define SIGN(x) ((x)>0?1:-1)
88#define ABS(x) ((int)(x)>0?(x):-(x))
89#define LABS(x) ((int32_t)(x)>0?(x):-(x))
90
91#define abs(x) ABS(x)
92
93/*
94=============================================================================
95
96 GLOBAL CONSTANTS
97
98=============================================================================
99*/
100
101#define MAXTICS 10
102#define DEMOTICS 4
103
104#define MAXACTORS 150 // max number of nazis, etc / map
105#define MAXSTATS 400 // max number of lamps, bonus, etc
106#define MAXDOORS 64 // max number of sliding doors
107#define MAXWALLTILES 64 // max number of wall tiles
108
109//
110// tile constants
111//
112
113#define ICONARROWS 90
114#define PUSHABLETILE 98
115#define EXITTILE 99 // at end of castle
116#define AREATILE 107 // first of NUMAREAS floor tiles
117#define NUMAREAS 37
118#define ELEVATORTILE 21
119#define AMBUSHTILE 106
120#define ALTELEVATORTILE 107
121
122#define NUMBERCHARS 9
123
124
125//----------------
126
127#define EXTRAPOINTS 40000
128
129#define PLAYERSPEED 3000
130#define RUNSPEED 6000
131
132#define SCREENSEG 0xa000
133
134#define SCREENBWIDE 80
135
136#define HEIGHTRATIO 0.50 // also defined in id_mm.c
137
138#define BORDERCOLOR 3
139#define FLASHCOLOR 5
140#define FLASHTICS 4
141
142#ifndef SPEAR
143 #define LRpack 8 // # of levels to store in endgame
144#else
145 #define LRpack 20
146#endif
147
148#define PLAYERSIZE MINDIST // player radius
149#define MINACTORDIST 0x10000l // minimum dist from player center
150 // to any actor center
151
152#define NUMLATCHPICS 100
153
154#undef M_PI
155#define PI 3.141592657
156#define M_PI PI
157
158#define GLOBAL1 (1l<<16)
159#define TILEGLOBAL GLOBAL1
160#define PIXGLOBAL (GLOBAL1/64)
161#define TILESHIFT 16l
162#define UNSIGNEDSHIFT 8
163
164#define ANGLES 360 // must be divisable by 4
165#define ANGLEQUAD (ANGLES/4)
166#define FINEANGLES 3600
167#define ANG90 (FINEANGLES/4)
168#define ANG180 (ANG90*2)
169#define ANG270 (ANG90*3)
170#define ANG360 (ANG90*4)
171#define VANG90 (ANGLES/4)
172#define VANG180 (VANG90*2)
173#define VANG270 (VANG90*3)
174#define VANG360 (VANG90*4)
175
176#define MINDIST (0x5800l)
177
178#define mapshift 6
179#define MAPSIZE (1<<mapshift)
180#define maparea MAPSIZE*MAPSIZE
181
182#define mapheight MAPSIZE
183#define mapwidth MAPSIZE
184
185#ifdef USE_HIRES
186
187#define TEXTURESHIFT 7
188#define TEXTURESIZE (1<<TEXTURESHIFT)
189#define TEXTUREFROMFIXEDSHIFT 2
190#define TEXTUREMASK (TEXTURESIZE*(TEXTURESIZE-1))
191
192#define SPRITESCALEFACTOR 1
193
194#else
195
196#define TEXTURESHIFT 6
197#define TEXTURESIZE (1<<TEXTURESHIFT)
198#define TEXTUREFROMFIXEDSHIFT 4
199#define TEXTUREMASK (TEXTURESIZE*(TEXTURESIZE-1))
200
201#define SPRITESCALEFACTOR 2
202
203#endif
204
205#define NORTH 0
206#define EAST 1
207#define SOUTH 2
208#define WEST 3
209
210
211#define STATUSLINES 40
212
213#define SCREENSIZE (SCREENBWIDE*208)
214#define PAGE1START 0
215#define PAGE2START (SCREENSIZE)
216#define PAGE3START (SCREENSIZE*2u)
217#define FREESTART (SCREENSIZE*3u)
218
219
220#define PIXRADIUS 512
221
222#define STARTAMMO 8
223
224
225// object flag values
226
227typedef enum
228{
229 FL_SHOOTABLE = 0x00000001,
230 FL_BONUS = 0x00000002,
231 FL_NEVERMARK = 0x00000004,
232 FL_VISABLE = 0x00000008,
233 FL_ATTACKMODE = 0x00000010,
234 FL_FIRSTATTACK = 0x00000020,
235 FL_AMBUSH = 0x00000040,
236 FL_NONMARK = 0x00000080,
237 FL_FULLBRIGHT = 0x00000100,
238#ifdef USE_DIR3DSPR
239 // you can choose one of the following values in wl_act1.cpp
240 // to make a static sprite a directional 3d sprite
241 // (see example at the end of the statinfo array)
242 FL_DIR_HORIZ_MID = 0x00000200,
243 FL_DIR_HORIZ_FW = 0x00000400,
244 FL_DIR_HORIZ_BW = 0x00000600,
245 FL_DIR_VERT_MID = 0x00000a00,
246 FL_DIR_VERT_FW = 0x00000c00,
247 FL_DIR_VERT_BW = 0x00000e00,
248
249 // these values are just used to improve readability of code
250 FL_DIR_NONE = 0x00000000,
251 FL_DIR_POS_MID = 0x00000200,
252 FL_DIR_POS_FW = 0x00000400,
253 FL_DIR_POS_BW = 0x00000600,
254 FL_DIR_POS_MASK = 0x00000600,
255 FL_DIR_VERT_FLAG = 0x00000800,
256 FL_DIR_MASK = 0x00000e00,
257#endif
258 // next free bit is 0x00001000
259} objflag_t;
260
261
262//
263// sprite constants
264//
265
266enum
267{
268 SPR_DEMO,
269#ifndef APOGEE_1_0
270 SPR_DEATHCAM,
271#endif
272//
273// static sprites
274//
275 SPR_STAT_0,SPR_STAT_1,SPR_STAT_2,SPR_STAT_3,
276 SPR_STAT_4,SPR_STAT_5,SPR_STAT_6,SPR_STAT_7,
277
278 SPR_STAT_8,SPR_STAT_9,SPR_STAT_10,SPR_STAT_11,
279 SPR_STAT_12,SPR_STAT_13,SPR_STAT_14,SPR_STAT_15,
280
281 SPR_STAT_16,SPR_STAT_17,SPR_STAT_18,SPR_STAT_19,
282 SPR_STAT_20,SPR_STAT_21,SPR_STAT_22,SPR_STAT_23,
283
284 SPR_STAT_24,SPR_STAT_25,SPR_STAT_26,SPR_STAT_27,
285 SPR_STAT_28,SPR_STAT_29,SPR_STAT_30,SPR_STAT_31,
286
287 SPR_STAT_32,SPR_STAT_33,SPR_STAT_34,SPR_STAT_35,
288 SPR_STAT_36,SPR_STAT_37,SPR_STAT_38,SPR_STAT_39,
289
290 SPR_STAT_40,SPR_STAT_41,SPR_STAT_42,SPR_STAT_43,
291 SPR_STAT_44,SPR_STAT_45,SPR_STAT_46,SPR_STAT_47,
292
293#ifdef SPEAR
294 SPR_STAT_48,SPR_STAT_49,SPR_STAT_50,SPR_STAT_51,
295#endif
296
297//
298// guard
299//
300 SPR_GRD_S_1,SPR_GRD_S_2,SPR_GRD_S_3,SPR_GRD_S_4,
301 SPR_GRD_S_5,SPR_GRD_S_6,SPR_GRD_S_7,SPR_GRD_S_8,
302
303 SPR_GRD_W1_1,SPR_GRD_W1_2,SPR_GRD_W1_3,SPR_GRD_W1_4,
304 SPR_GRD_W1_5,SPR_GRD_W1_6,SPR_GRD_W1_7,SPR_GRD_W1_8,
305
306 SPR_GRD_W2_1,SPR_GRD_W2_2,SPR_GRD_W2_3,SPR_GRD_W2_4,
307 SPR_GRD_W2_5,SPR_GRD_W2_6,SPR_GRD_W2_7,SPR_GRD_W2_8,
308
309 SPR_GRD_W3_1,SPR_GRD_W3_2,SPR_G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_PINKY_W1,SPR_PINKY_W2,
414 SPR_CLYDE_W1,SPR_CLYDE_W2,SPR_INKY_W1,SPR_INKY_W2,
415
416//
417// hans
418//
419 SPR_BOSS_W1,SPR_BOSS_W2,SPR_BOSS_W3,SPR_BOSS_W4,
420 SPR_BOSS_SHOOT1,SPR_BOSS_SHOOT2,SPR_BOSS_SHOOT3,SPR_BOSS_DEAD,
421
422 SPR_BOSS_DIE1,SPR_BOSS_DIE2,SPR_BOSS_DIE3,
423
424//
425// schabbs
426//
427 SPR_SCHABB_W1,SPR_SCHABB_W2,SPR_SCHABB_W3,SPR_SCHABB_W4,
428 SPR_SCHABB_SHOOT1,SPR_SCHABB_SHOOT2,
429
430 SPR_SCHABB_DIE1,SPR_SCHABB_DIE2,SPR_SCHABB_DIE3,SPR_SCHABB_DEAD,
431 SPR_HYPO1,SPR_HYPO2,SPR_HYPO3,SPR_HYPO4,
432
433//
434// fake
435//
436 SPR_FAKE_W1,SPR_FAKE_W2,SPR_FAKE_W3,SPR_FAKE_W4,
437 SPR_FAKE_SHOOT,SPR_FIRE1,SPR_FIRE2,
438
439 SPR_FAKE_DIE1,SPR_FAKE_DIE2,SPR_FAKE_DIE3,SPR_FAKE_DIE4,
440 SPR_FAKE_DIE5,SPR_FAKE_DEAD,
441
442//
443// hitler
444//
445 SPR_MECHA_W1,SPR_MECHA_W2,SPR_MECHA_W3,SPR_MECHA_W4,
446 SPR_MECHA_SHOOT1,SPR_MECHA_SHOOT2,SPR_MECHA_SHOOT3,SPR_MECHA_DEAD,
447
448 SPR_MECHA_DIE1,SPR_MECHA_DIE2,SPR_MECHA_DIE3,
449
450 SPR_HITLER_W1,SPR_HITLER_W2,SPR_HITLER_W3,SPR_HITLER_W4,
451 SPR_HITLER_SHOOT1,SPR_HITLER_SHOOT2,SPR_HITLER_SHOOT3,SPR_HITLER_DEAD,
452
453 SPR_HITLER_DIE1,SPR_HITLER_DIE2,SPR_HITLER_DIE3,SPR_HITLER_DIE4,
454 SPR_HITLER_DIE5,SPR_HITLER_DIE6,SPR_HITLER_DIE7,
455
456//
457// giftmacher
458//
459 SPR_GIFT_W1,SPR_GIFT_W2,SPR_GIFT_W3,SPR_GIFT_W4,
460 SPR_GIFT_SHOOT1,SPR_GIFT_SHOOT2,
461
462 SPR_GIFT_DIE1,SPR_GIFT_DIE2,SPR_GIFT_DIE3,SPR_GIFT_DEAD,
463#endif
464//
465// Rocket, smoke and small explosion
466//
467 SPR_ROCKET_1,SPR_ROCKET_2,SPR_ROCKET_3,SPR_ROCKET_4,
468 SPR_ROCKET_5,SPR_ROCKET_6,SPR_ROCKET_7,SPR_ROCKET_8,
469
470 SPR_SMOKE_1,SPR_SMOKE_2,SPR_SMOKE_3,SPR_SMOKE_4,
471 SPR_BOOM_1,SPR_BOOM_2,SPR_BOOM_3,
472
473//
474// Angel of Death's DeathSparks(tm)
475//
476#ifdef SPEAR
477 SPR_HROCKET_1,SPR_HROCKET_2,SPR_HROCKET_3,SPR_HROCKET_4,
478 SPR_HROCKET_5,SPR_HROCKET_6,SPR_HROCKET_7,SPR_HROCKET_8,
479
480 SPR_HSMOKE_1,SPR_HSMOKE_2,SPR_HSMOKE_3,SPR_HSMOKE_4,
481 SPR_HBOOM_1,SPR_HBOOM_2,SPR_HBOOM_3,
482
483 SPR_SPARK1,SPR_SPARK2,SPR_SPARK3,SPR_SPARK4,
484#endif
485
486#ifndef SPEAR
487//
488// gretel
489//
490 SPR_GRETEL_W1,SPR_GRETEL_W2,SPR_GRETEL_W3,SPR_GRETEL_W4,
491 SPR_GRETEL_SHOOT1,SPR_GRETEL_SHOOT2,SPR_GRETEL_SHOOT3,SPR_GRETEL_DEAD,
492
493 SPR_GRETEL_DIE1,SPR_GRETEL_DIE2,SPR_GRETEL_DIE3,
494
495//
496// fat face
497//
498 SPR_FAT_W1,SPR_FAT_W2,SPR_FAT_W3,SPR_FAT_W4,
499 SPR_FAT_SHOOT1,SPR_FAT_SHOOT2,SPR_FAT_SHOOT3,SPR_FAT_SHOOT4,
500
501 SPR_FAT_DIE1,SPR_FAT_DIE2,SPR_FAT_DIE3,SPR_FAT_DEAD,
502
503//
504// bj
505//
506#ifdef APOGEE_1_0
507 SPR_BJ_W1=360,
508#elif defined(APOGEE_1_1) && defined(UPLOAD)
509 SPR_BJ_W1=406,
510#else
511 SPR_BJ_W1,
512#endif
513 SPR_BJ_W2,SPR_BJ_W3,SPR_BJ_W4,
514 SPR_BJ_JUMP1,SPR_BJ_JUMP2,SPR_BJ_JUMP3,SPR_BJ_JUMP4,
515#else
516//
517// THESE ARE FOR 'SPEAR OF DESTINY'
518//
519
520//
521// Trans Grosse
522//
523 SPR_TRANS_W1,SPR_TRANS_W2,SPR_TRANS_W3,SPR_TRANS_W4,
524 SPR_TRANS_SHOOT1,SPR_TRANS_SHOOT2,SPR_TRANS_SHOOT3,SPR_TRANS_DEAD,
525
526 SPR_TRANS_DIE1,SPR_TRANS_DIE2,SPR_TRANS_DIE3,
527
528//
529// Wilhelm
530//
531 SPR_WILL_W1,SPR_WILL_W2,SPR_WILL_W3,SPR_WILL_W4,
532 SPR_WILL_SHOOT1,SPR_WILL_SHOOT2,SPR_WILL_SHOOT3,SPR_WILL_SHOOT4,
533
534 SPR_WILL_DIE1,SPR_WILL_DIE2,SPR_WILL_DIE3,SPR_WILL_DEAD,
535
536//
537// UberMutant
538//
539 SPR_UBER_W1,SPR_UBER_W2,SPR_UBER_W3,SPR_UBER_W4,
540 SPR_UBER_SHOOT1,SPR_UBER_SHOOT2,SPR_UBER_SHOOT3,SPR_UBER_SHOOT4,
541
542 SPR_UBER_DIE1,SPR_UBER_DIE2,SPR_UBER_DIE3,SPR_UBER_DIE4,
543 SPR_UBER_DEAD,
544
545//
546// Death Knight
547//
548 SPR_DEATH_W1,SPR_DEATH_W2,SPR_DEATH_W3,SPR_DEATH_W4,
549 SPR_DEATH_SHOOT1,SPR_DEATH_SHOOT2,SPR_DEATH_SHOOT3,SPR_DEATH_SHOOT4,
550
551 SPR_DEATH_DIE1,SPR_DEATH_DIE2,SPR_DEATH_DIE3,SPR_DEATH_DIE4,
552 SPR_DEATH_DIE5,SPR_DEATH_DIE6,SPR_DEATH_DEAD,
553
554//
555// Ghost
556//
557 SPR_SPECTRE_W1,SPR_SPECTRE_W2,SPR_SPECTRE_W3,SPR_SPECTRE_W4,
558 SPR_SPECTRE_F1,SPR_SPECTRE_F2,SPR_SPECTRE_F3,SPR_SPECTRE_F4,
559
560//
561// Angel of Death
562//
563 SPR_ANGEL_W1,SPR_ANGEL_W2,SPR_ANGEL_W3,SPR_ANGEL_W4,
564 SPR_ANGEL_SHOOT1,SPR_ANGEL_SHOOT2,SPR_ANGEL_TIRED1,SPR_ANGEL_TIRED2,
565
566 SPR_ANGEL_DIE1,SPR_ANGEL_DIE2,SPR_ANGEL_DIE3,SPR_ANGEL_DIE4,
567 SPR_ANGEL_DIE5,SPR_ANGEL_DIE6,SPR_ANGEL_DIE7,SPR_ANGEL_DEAD,
568
569#endif
570
571//
572// player attack frames
573//
574 SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3,
575 SPR_KNIFEATK4,
576
577 SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3,
578 SPR_PISTOLATK4,
579
580 SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,MACHINEGUNATK3,
581 SPR_MACHINEGUNATK4,
582
583 SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
584 SPR_CHAINATK4,
585
586};
587
588
589/*
590=============================================================================
591
592 GLOBAL TYPES
593
594=============================================================================
595*/
596
597typedef enum {
598 di_north,
599 di_east,
600 di_south,
601 di_west
602} controldir_t;
603
604typedef enum {
605 dr_normal,
606 dr_lock1,
607 dr_lock2,
608 dr_lock3,
609 dr_lock4,
610 dr_elevator
611} door_t;
612
613typedef enum {
614 ac_badobject = -1,
615 ac_no,
616 ac_yes,
617 ac_allways
618} activetype;
619
620typedef enum {
621 nothing,
622 playerobj,
623 inertobj,
624 guardobj,
625 officerobj,
626 ssobj,
627 dogobj,
628 bossobj,
629 schabbobj,
630 fakeobj,
631 mechahitlerobj,
632 mutantobj,
633 needleobj,
634 fireobj,
635 bjobj,
636 ghostobj,
637 realhitlerobj,
638 gretelobj,
639 giftobj,
640 fatobj,
641 rocketobj,
642
643 spectreobj,
644 angelobj,
645 transobj,
646 uberobj,
647 willobj,
648 deathobj,
649 hrocketobj,
650 sparkobj
651} classtype;
652
653typedef enum {
654 none,
655 block,
656 bo_gibs,
657 bo_alpo,
658 bo_firstaid,
659 bo_key1,
660 bo_key2,
661 bo_key3,
662 bo_key4,
663 bo_cross,
664 bo_chalice,
665 bo_bible,
666 bo_crown,
667 bo_clip,
668 bo_clip2,
669 bo_machinegun,
670 bo_chaingun,
671 bo_food,
672 bo_fullheal,
673 bo_25clip,
674 bo_spear
675} wl_stat_t;
676
677typedef enum {
678 east,
679 northeast,
680 north,
681 northwest,
682 west,
683 southwest,
684 south,
685 southeast,
686 nodir
687} dirtype;
688
689
690#define NUMENEMIES 22
691typedef enum {
692 en_guard,
693 en_officer,
694 en_ss,
695 en_dog,
696 en_boss,
697 en_schabbs,
698 en_fake,
699 en_hitler,
700 en_mutant,
701 en_blinky,
702 en_clyde,
703 en_pinky,
704 en_inky,
705 en_gretel,
706 en_gift,
707 en_fat,
708 en_spectre,
709 en_angel,
710 en_trans,
711 en_uber,
712 en_will,
713 en_death
714} enemy_t;
715
716typedef void (* statefunc) (void *);
717
718typedef struct statestruct
719{
720 boolean rotate;
721 short shapenum; // a shapenum of -1 means get from ob->temp1
722 short tictime;
723 void (*think) (void *),(*action) (void *);
724 struct statestruct *next;
725} statetype;
726
727
728//---------------------
729//
730// trivial actor structure
731//
732//---------------------
733
734typedef struct statstruct
735{
736 byte tilex,tiley;
737 short shapenum; // if shapenum == -1 the obj has been removed
738 byte *visspot;
739 uint32_t flags;
740 byte itemnumber;
741} statobj_t;
742
743
744//---------------------
745//
746// door actor structure
747//
748//---------------------
749
750typedef enum
751{
752 dr_open,dr_closed,dr_opening,dr_closing
753} doortype;
754
755typedef struct doorstruct
756{
757 byte tilex,tiley;
758 boolean vertical;
759 byte lock;
760 doortype action;
761 short ticcount;
762} doorobj_t;
763
764
765//--------------------
766//
767// thinking actor structure
768//
769//--------------------
770
771typedef struct objstruct
772{
773 activetype active;
774 short ticcount;
775 classtype obclass;
776 statetype *state;
777
778 uint32_t flags; // FL_SHOOTABLE, etc
779
780 int32_t distance; // if negative, wait for that door to open
781 dirtype dir;
782
783 fixed x,y;
784 word tilex,tiley;
785 byte areanumber;
786
787 short viewx;
788 word viewheight;
789 fixed transx,transy; // in global coord
790
791 short angle;
792 short hitpoints;
793 int32_t speed;
794
795 short temp1,temp2,hidden;
796 struct objstruct *next,*prev;
797} objtype;
798
799enum
800{
801 bt_nobutton=-1,
802 bt_attack=0,
803 bt_strafe,
804 bt_run,
805 bt_use,
806 bt_readyknife,
807 bt_readypistol,
808 bt_readymachinegun,
809 bt_readychaingun,
810 bt_nextweapon,
811 bt_prevweapon,
812 bt_esc,
813 bt_pause,
814 bt_strafeleft,
815 bt_straferight,
816 bt_moveforward,
817 bt_movebackward,
818 bt_turnleft,
819 bt_turnright,
820 NUMBUTTONS
821};
822
823
824#define NUMWEAPONS 4
825typedef enum
826{
827 wp_knife,
828 wp_pistol,
829 wp_machinegun,
830 wp_chaingun
831} weapontype;
832
833
834enum
835{
836 gd_baby,
837 gd_easy,
838 gd_medium,
839 gd_hard
840};
841
842//---------------
843//
844// gamestate structure
845//
846//---------------
847
848typedef struct
849{
850 short difficulty;
851 short mapon;
852 int32_t oldscore,score,nextextra;
853 short lives;
854 short health;
855 short ammo;
856 short keys;
857 weapontype bestweapon,weapon,chosenweapon;
858
859 short faceframe;
860 short attackframe,attackcount,weaponframe;
861
862 short episode,secretcount,treasurecount,killcount,
863 secrettotal,treasuretotal,killtotal;
864 int32_t TimeCount;
865 int32_t killx,killy;
866 boolean victoryflag; // set during victory animations
867} gametype;
868
869
870typedef enum
871{
872 ex_stillplaying,
873 ex_completed,
874 ex_died,
875 ex_warped,
876 ex_resetgame,
877 ex_loadedgame,
878 ex_victorious,
879 ex_abort,
880 ex_demodone,
881 ex_secretlevel
882} exit_t;
883
884
885extern word *mapsegs[MAPPLANES];
886extern int mapon;
887
888/*
889=============================================================================
890
891 WL_MAIN DEFINITIONS
892
893=============================================================================
894*/
895
896extern boolean loadedgame;
897extern fixed focallength;
898extern int viewscreenx, viewscreeny;
899extern int viewwidth;
900extern int viewheight;
901extern short centerx;
902extern int32_t heightnumerator;
903extern fixed scale;
904
905extern int dirangle[9];
906
907extern int mouseadjustment;
908extern int shootdelta;
909extern unsigned screenofs;
910
911extern boolean startgame;
912extern char str[80];
913extern char configdir[256];
914extern char configname[13];
915
916//
917// Command line parameter variables
918//
919extern boolean param_debugmode;
920extern boolean param_nowait;
921extern int param_difficulty;
922extern int param_tedlevel;
923extern int param_joystickindex;
924extern int param_joystickhat;
925extern int param_samplerate;
926extern int param_audiobuffer;
927extern int param_mission;
928extern boolean param_goodtimes;
929extern boolean param_ignorenumchunks;
930
931
932void NewGame (int difficulty,int episode);
933void CalcProjection (int32_t focal);
934void NewViewSize (int width);
935boolean SetViewSize (unsigned width, unsigned height);
936boolean LoadTheGame(FILE *file,int x,int y);
937boolean SaveTheGame(FILE *file,int x,int y);
938void ShowViewSize (int width);
939void ShutdownId (void);
940
941
942/*
943=============================================================================
944
945 WL_GAME DEFINITIONS
946
947=============================================================================
948*/
949
950extern gametype gamestate;
951extern byte bordercol;
952extern SDL_Surface *latchpics[NUMLATCHPICS];
953extern char demoname[13];
954
955void SetupGameLevel (void);
956void GameLoop (void);
957void DrawPlayBorder (void);
958void DrawStatusBorder (byte color);
959void DrawPlayScreen (void);
960void DrawPlayBorderSides (void);
961void ShowActStatus();
962
963void PlayDemo (int demonumber);
964void RecordDemo (void);
965
966
967#ifdef SPEAR
968extern int32_t spearx,speary;
969extern unsigned spearangle;
970extern boolean spearflag;
971#endif
972
973
974#define ClearMemory SD_StopDigitized
975
976
977// JAB
978#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((int32_t)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((int32_t)ty << TILESHIFT) + (1L << (TILESHIFT - 1))))
979#define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y)
980void PlaySoundLocGlobal(word s,fixed gx,fixed gy);
981void UpdateSoundLoc(void);
982
983
984/*
985=============================================================================
986
987 WL_PLAY DEFINITIONS
988
989=============================================================================
990*/
991
992#define BASEMOVE 35
993#define RUNMOVE 70
994#define BASETURN 35
995#define RUNTURN 70
996
997#define JOYSCALE 2
998
999extern byte tilemap[MAPSIZE][MAPSIZE]; // wall values only
1000extern byte spotvis[MAPSIZE][MAPSIZE];
1001extern objtype *actorat[MAPSIZE][MAPSIZE];
1002
1003extern objtype *player;
1004
1005extern unsigned tics;
1006extern int viewsize;
1007
1008extern int lastgamemusicoffset;
1009
1010//
1011// current user input
1012//
1013extern int controlx,controly; // range from -100 to 100
1014extern boolean buttonstate[NUMBUTTONS];
1015extern objtype objlist[MAXACTORS];
1016extern boolean buttonheld[NUMBUTTONS];
1017extern exit_t playstate;
1018extern boolean madenoise;
1019extern statobj_t statobjlist[MAXSTATS];
1020extern statobj_t *laststatobj;
1021extern objtype *newobj,*killerobj;
1022extern doorobj_t doorobjlist[MAXDOORS];
1023extern doorobj_t *lastdoorobj;
1024extern int godmode;
1025
1026extern boolean demorecord,demoplayback;
1027extern int8_t *demoptr, *lastdemoptr;
1028extern memptr demobuffer;
1029
1030//
1031// control info
1032//
1033extern boolean mouseenabled,joystickenabled;
1034extern int dirscan[4];
1035extern int buttonscan[NUMBUTTONS];
1036extern int buttonmouse[4];
1037extern int buttonjoy[32];
1038
1039void InitActorList (void);
1040void GetNewActor (void);
1041void PlayLoop (void);
1042
1043void CenterWindow(word w,word h);
1044
1045void InitRedShifts (void);
1046void FinishPaletteShifts (void);
1047
1048void RemoveObj (objtype *gone);
1049void PollControls (void);
1050int StopMusic(void);
1051void StartMusic(void);
1052void ContinueMusic(int offs);
1053void StartDamageFlash (int damage);
1054void StartBonusFlash (void);
1055
1056#ifdef SPEAR
1057extern int32_t funnyticount; // FOR FUNNY BJ FACE
1058#endif
1059
1060extern objtype *objfreelist; // *obj,*player,*lastobj,
1061
1062extern boolean noclip,ammocheat;
1063extern int singlestep, extravbls;
1064
1065/*
1066=============================================================================
1067
1068 WL_INTER
1069
1070=============================================================================
1071*/
1072
1073void IntroScreen (void);
1074void PG13(void);
1075void DrawHighScores(void);
1076void CheckHighScore (int32_t score,word other);
1077void Victory (void);
1078void LevelCompleted (void);
1079void ClearSplitVWB (void);
1080
1081void PreloadGraphics(void);
1082
1083
1084/*
1085=============================================================================
1086
1087 WL_DEBUG
1088
1089=============================================================================
1090*/
1091
1092int DebugKeys (void);
1093
1094/*
1095=============================================================================
1096
1097 WL_DRAW DEFINITIONS
1098
1099=============================================================================
1100*/
1101
1102//
1103// math tables
1104//
1105extern short *pixelangle;
1106extern int32_t finetangent[FINEANGLES/4];
1107extern fixed sintable[];
1108extern fixed *costable;
1109extern int *wallheight;
1110extern word horizwall[],vertwall[];
1111extern int32_t lasttimecount;
1112extern int32_t frameon;
1113
1114extern unsigned screenloc[3];
1115
1116extern boolean fizzlein, fpscounter;
1117
1118extern fixed viewx,viewy; // the focal point
1119extern fixed viewsin,viewcos;
1120
1121void ThreeDRefresh (void);
1122void CalcTics (void);
1123
1124typedef struct
1125{
1126 word leftpix,rightpix;
1127 word dataofs[64];
1128// table data after dataofs[rightpix-leftpix+1]
1129} t_compshape;
1130
1131/*
1132=============================================================================
1133
1134 WL_STATE DEFINITIONS
1135
1136=============================================================================
1137*/
1138#define TURNTICS 10
1139#define SPDPATROL 512
1140#define SPDDOG 1500
1141
1142
1143void InitHitRect (objtype *ob, unsigned radius);
1144void SpawnNewObj (unsigned tilex, unsigned tiley, statetype *state);
1145void NewState (objtype *ob, statetype *state);
1146
1147boolean TryWalk (objtype *ob);
1148void SelectChaseDir (objtype *ob);
1149void SelectDodgeDir (objtype *ob);
1150void SelectRunDir (objtype *ob);
1151void MoveObj (objtype *ob, int32_t move);
1152boolean SightPlayer (objtype *ob);
1153
1154void KillActor (objtype *ob);
1155void DamageActor (objtype *ob, unsigned damage);
1156
1157boolean CheckLine (objtype *ob);
1158boolean CheckSight (objtype *ob);
1159
1160/*
1161=============================================================================
1162
1163 WL_AGENT DEFINITIONS
1164
1165=============================================================================
1166*/
1167
1168extern short anglefrac;
1169extern int facecount, facetimes;
1170extern word plux,pluy; // player coordinates scaled to unsigned
1171extern int32_t thrustspeed;
1172extern objtype *LastAttacker;
1173
1174void Thrust (int angle, int32_t speed);
1175void SpawnPlayer (int tilex, int tiley, int dir);
1176void TakeDamage (int points,objtype *attacker);
1177void GivePoints (int32_t points);
1178void GetBonus (statobj_t *check);
1179void GiveWeapon (int weapon);
1180void GiveAmmo (int ammo);
1181void GiveKey (int key);
1182
1183//
1184// player state info
1185//
1186
1187void StatusDrawFace(unsigned picnum);
1188void DrawFace (void);
1189void DrawHealth (void);
1190void HealSelf (int points);
1191void DrawLevel (void);
1192void DrawLives (void);
1193void GiveExtraMan (void);
1194void DrawScore (void);
1195void DrawWeapon (void);
1196void DrawKeys (void);
1197void DrawAmmo (void);
1198
1199
1200/*
1201=============================================================================
1202
1203 WL_ACT1 DEFINITIONS
1204
1205=============================================================================
1206*/
1207
1208extern doorobj_t doorobjlist[MAXDOORS];
1209extern doorobj_t *lastdoorobj;
1210extern short doornum;
1211
1212extern word doorposition[MAXDOORS];
1213
1214extern byte areaconnect[NUMAREAS][NUMAREAS];
1215
1216extern boolean areabyplayer[NUMAREAS];
1217
1218extern word pwallstate;
1219extern word pwallpos; // amount a pushable wall has been moved (0-63)
1220extern word pwallx,pwally;
1221extern byte pwalldir,pwalltile;
1222
1223
1224void InitDoorList (void);
1225void InitStaticList (void);
1226void SpawnStatic (int tilex, int tiley, int type);
1227void SpawnDoor (int tilex, int tiley, boolean vertical, int lock);
1228void MoveDoors (void);
1229void MovePWalls (void);
1230void OpenDoor (int door);
1231void PlaceItemType (int itemtype, int tilex, int tiley);
1232void PushWall (int checkx, int checky, int dir);
1233void OperateDoor (int door);
1234void InitAreas (void);
1235
1236/*
1237=============================================================================
1238
1239 WL_ACT2 DEFINITIONS
1240
1241=============================================================================
1242*/
1243
1244#define s_nakedbody s_static10
1245
1246extern statetype s_grddie1;
1247extern statetype s_dogdie1;
1248extern statetype s_ofcdie1;
1249extern statetype s_mutdie1;
1250extern statetype s_ssdie1;
1251extern statetype s_bossdie1;
1252extern statetype s_schabbdie1;
1253extern statetype s_fakedie1;
1254extern statetype s_mechadie1;
1255extern statetype s_hitlerdie1;
1256extern statetype s_greteldie1;
1257extern statetype s_giftdie1;
1258extern statetype s_fatdie1;
1259
1260extern statetype s_spectredie1;
1261extern statetype s_angeldie1;
1262extern statetype s_transdie0;
1263extern statetype s_uberdie0;
1264extern statetype s_willdie1;
1265extern statetype s_deathdie1;
1266
1267
1268extern statetype s_grdchase1;
1269extern statetype s_dogchase1;
1270extern statetype s_ofcchase1;
1271extern statetype s_sschase1;
1272extern statetype s_mutchase1;
1273extern statetype s_bosschase1;
1274extern statetype s_schabbchase1;
1275extern statetype s_fakechase1;
1276extern statetype s_mechachase1;
1277extern statetype s_gretelchase1;
1278extern statetype s_giftchase1;
1279extern statetype s_fatchase1;
1280
1281extern statetype s_spectrechase1;
1282extern statetype s_angelchase1;
1283extern statetype s_transchase1;
1284extern statetype s_uberchase1;
1285extern statetype s_willchase1;
1286extern statetype s_deathchase1;
1287
1288extern statetype s_blinkychase1;
1289extern statetype s_hitlerchase1;
1290
1291extern statetype s_grdpain;
1292extern statetype s_grdpain1;
1293extern statetype s_ofcpain;
1294extern statetype s_ofcpain1;
1295extern statetype s_sspain;
1296extern statetype s_sspain1;
1297extern statetype s_mutpain;
1298extern statetype s_mutpain1;
1299
1300extern statetype s_deathcam;
1301
1302extern statetype s_schabbdeathcam2;
1303extern statetype s_hitlerdeathcam2;
1304extern statetype s_giftdeathcam2;
1305extern statetype s_fatdeathcam2;
1306
1307void SpawnStand (enemy_t which, int tilex, int tiley, int dir);
1308void SpawnPatrol (enemy_t which, int tilex, int tiley, int dir);
1309void KillActor (objtype *ob);
1310
1311void SpawnDeadGuard (int tilex, int tiley);
1312void SpawnBoss (int tilex, int tiley);
1313void SpawnGretel (int tilex, int tiley);
1314void SpawnTrans (int tilex, int tiley);
1315void SpawnUber (int tilex, int tiley);
1316void SpawnWill (int tilex, int tiley);
1317void SpawnDeath (int tilex, int tiley);
1318void SpawnAngel (int tilex, int tiley);
1319void SpawnSpectre (int tilex, int tiley);
1320void SpawnGhosts (int which, int tilex, int tiley);
1321void SpawnSchabbs (int tilex, int tiley);
1322void SpawnGift (int tilex, int tiley);
1323void SpawnFat (int tilex, int tiley);
1324void SpawnFakeHitler (int tilex, int tiley);
1325void SpawnHitler (int tilex, int tiley);
1326
1327void A_DeathScream (objtype *ob);
1328void SpawnBJVictory (void);
1329
1330/*
1331=============================================================================
1332
1333 WL_TEXT DEFINITIONS
1334
1335=============================================================================
1336*/
1337
1338extern char helpfilename[],endfilename[];
1339
1340extern void HelpScreens(void);
1341extern void EndText(void);
1342
1343
1344/*
1345=============================================================================
1346
1347 GP2X DEFINITIONS
1348
1349=============================================================================
1350*/
1351
1352#if defined(GP2X)
1353
1354#if defined(GP2X_940)
1355void GP2X_MemoryInit(void);
1356void GP2X_Shutdown(void);
1357#endif
1358void GP2X_ButtonDown(int button);
1359void GP2X_ButtonUp(int button);
1360
1361#endif
1362
1363
1364/*
1365=============================================================================
1366
1367 MISC DEFINITIONS
1368
1369=============================================================================
1370*/
1371
1372static fixed FixedMul(fixed a, fixed b)
1373{
1374 return (fixed)(((int64_t)a * b + 0x8000) >> 16);
1375}
1376
1377#ifdef PLAYDEMOLIKEORIGINAL
1378 #define DEMOCHOOSE_ORIG_SDL(orig, sdl) ((demorecord || demoplayback) ? (orig) : (sdl))
1379 #define DEMOCOND_ORIG (demorecord || demoplayback)
1380 #define DEMOIF_SDL if(DEMOCOND_SDL)
1381#else
1382 #define DEMOCHOOSE_ORIG_SDL(orig, sdl) (sdl)
1383 #define DEMOCOND_ORIG false
1384 #define DEMOIF_SDL
1385#endif
1386#define DEMOCOND_SDL (!DEMOCOND_ORIG)
1387
1388#define GetTicks() ((SDL_GetTicks()*7)/100)
1389
1390#define ISPOINTER(x) ((((uintptr_t)(x)) & ~0xffff) != 0)
1391
1392#define CHECKMALLOCRESULT(x) if(!(x)) Quit("Out of memory at %s:%i", __FILE__, __LINE__)
1393
1394#ifdef _WIN32
1395 #define strcasecmp stricmp
1396 #define strncasecmp strnicmp
1397 #define snprintf _snprintf
1398#else
1399 static char* itoa(int value, char* string, int radix)
1400 {
1401 sprintf(string, "%d", value);
1402 return string;
1403 }
1404
1405 static char* ltoa(long value, char* string, int radix)
1406 {
1407 sprintf(string, "%ld", value);
1408 return string;
1409 }
1410#endif
1411
1412#define lengthof(x) (sizeof(x) / sizeof(*(x)))
1413#define endof(x) ((x) + lengthof(x))
1414
1415static word READWORD(byte **ptr)
1416{
1417 word val = (*ptr)[0] | (*ptr)[1] << 8;
1418 *ptr += 2;
1419 return val;
1420}
1421
1422static longword READLONGWORD(byte **ptr)
1423{
1424 longword val = (*ptr)[0] | (*ptr)[1] << 8 | (*ptr)[2] << 16 | (*ptr)[3] << 24;
1425 *ptr += 4;
1426 return val;
1427}
1428
1429
1430/*
1431=============================================================================
1432
1433 FEATURE DEFINITIONS
1434
1435=============================================================================
1436*/
1437
1438#ifdef USE_FEATUREFLAGS
1439 // The currently available feature flags
1440 #define FF_STARSKY 0x0001
1441 #define FF_PARALLAXSKY 0x0002
1442 #define FF_CLOUDSKY 0x0004
1443 #define FF_RAIN 0x0010
1444 #define FF_SNOW 0x0020
1445
1446 // The ffData... variables contain the 16-bit values of the according corners of the current level.
1447 // The corners are overwritten with adjacent tiles after initialization in SetupGameLevel
1448 // to avoid interpretation as e.g. doors.
1449 extern int ffDataTopLeft, ffDataTopRight, ffDataBottomLeft, ffDataBottomRight;
1450
1451 /*************************************************************
1452 * Current usage of ffData... variables:
1453 * ffDataTopLeft: lower 8-bit: ShadeDefID
1454 * ffDataTopRight: FeatureFlags
1455 * ffDataBottomLeft: CloudSkyDefID or ParallaxStartTexture
1456 * ffDataBottomRight: unused
1457 *************************************************************/
1458
1459 // The feature flags are stored as a wall in the upper right corner of each level
1460 static word GetFeatureFlags()
1461 {
1462 return ffDataTopRight;
1463 }
1464
1465#endif
1466
1467#ifdef USE_FLOORCEILINGTEX
1468 void DrawFloorAndCeiling(byte *vbuf, unsigned vbufPitch, int min_wallheight);
1469#endif
1470
1471#ifdef USE_PARALLAX
1472 void DrawParallax(byte *vbuf, unsigned vbufPitch);
1473#endif
1474
1475#ifdef USE_DIR3DSPR
1476 void Scale3DShape(byte *vbuf, unsigned vbufPitch, statobj_t *ob);
1477#endif
1478
1479#endif