-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdoomdef.h
More file actions
1391 lines (1081 loc) · 34.4 KB
/
Copy pathdoomdef.h
File metadata and controls
1391 lines (1081 loc) · 34.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* DoomDef.h */
#ifndef DOOMDEF_H__
#define DOOMDEF_H__
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdatomic.h>
/* JAGUAR should be defined on the compiler command line for console builds */
/* if MARS isn't defined, assume jaguar version */
/*define MARS */
#define CINEMATIC_INTRO "VIDEO/IDLOGO.ROQ"
#define LZSS_BUF_SIZE 0x1000
/* if rangecheck is undefined, most parameter validation debugging code */
/* will not be compiled */
#define RANGECHECK
/* if SIMULATOR is defined, compile in extra code for things like console */
/* debugging aids */
#ifndef JAGUAR
#ifndef MARS
#define SIMULATOR
#endif
#endif
#define MARS_USE_SRAM_DEMO
#define MARS_SRAM_DEMO_OFS 0x800
#if defined(MARS_USE_SRAM_DEMO) && !defined(MARS)
#undef MARS_USE_SRAM_DEMO
#endif
typedef unsigned short pixel_t;
#ifdef MARS
typedef unsigned char inpixel_t;
#else
typedef unsigned short inpixel_t;
#endif
#ifdef MARS
#define __BYTEBOOL__
enum {false, true};
typedef char boolean;
typedef unsigned char byte;
#endif
#ifdef MARS
#define DATA_START_ADDRESS 0x06000000
#else
#define DATA_START_ADDRESS 0
#endif
/* the structure sizes are frozen at ints for jaguar asm code, but shrunk */
/* down for mars memory cramming */
#ifdef MARS
#define VINT short
#else
#define VINT int
#endif
#ifdef MARS
#define ATTR_DATA_OPTIMIZE_NONE __attribute__((section(".sdata"), optimize("O1")))
#define ATTR_DATA_CACHE_ALIGN __attribute__((section(".sdata"), optimize("Os")))
#define ATTR_OPTIMIZE_SIZE __attribute__((optimize("Os")))
#define ATTR_OPTIMIZE_EXTREME __attribute__((optimize("O3", "no-align-loops", "no-align-functions", "no-align-jumps", "no-align-labels")))
#else
#define ATTR_DATA_OPTIMIZE_NONE
#define ATTR_DATA_CACHE_ALIGN
#define ATTR_OPTIMIZE_SIZE
#define ATTR_OPTIMIZE_EXTREME
#endif
#ifdef MARS
#define SPTR uint16_t
#define LPTR_TO_SPTR(p) ((p) ? (uint16_t)(((uintptr_t)(p) - DATA_START_ADDRESS)>>2) : 0) // use with caution as pointer at the beginning of RAM address space will be mapped to a NULL pointer!
#define SPTR_TO_LPTR(p) ((p) ? (void*)(((uintptr_t)(p) << 2) + DATA_START_ADDRESS) : NULL)
#else
#define SPTR void *
#define LPTR_TO_SPTR(p) (p)
#define SPTR_TO_LPTR(p) (p)
#endif
/*============================================================================= */
/* all external data is defined here */
#include "doomdata.h"
/* header generated by multigen utility */
#include "info.h"
#define D_MAXCHAR ((char)0x7f)
#define D_MAXSHORT ((short)0x7fff)
#define D_MAXINT ((int)0x7fffffff) // max pos 32-bit int
#define D_MAXLONG ((long)0x7fffffff)
#define D_MINCHAR ((char)0x80)
#define D_MINSHORT ((short)0x8000)
#define D_MININT ((int)0x80000000) // max negative 32-bit integer
#define D_MINLONG ((long)0x80000000)
#ifndef NULL
#define NULL 0
#endif
int D_vsnprintf(char *str, size_t nmax, const char *format, va_list ap) __attribute__((nonnull));
int D_snprintf(char *buf, size_t nsize, const char *fmt, ...) __attribute__((nonnull));
void D_printf (char *str, ...) __attribute__((nonnull));
void D_isort(int* a, int len) __attribute__((nonnull)) ATTR_DATA_CACHE_ALIGN;
/*
===============================================================================
GLOBAL TYPES
===============================================================================
*/
#define MAXPLAYERS 2
#define TICRATE 15 /* number of tics / second */
#define TICVBLS (60/TICRATE) /* vblanks per tic */
/* change this to 'ticrate' if you want */
/* to use a different rate on PAL */
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
typedef int fixed_t;
#ifdef MARS
#define THINKERS_30HZ
#endif
#ifdef THINKERS_30HZ
#define THINKERS_TICS 2
#else
#define THINKERS_TICS 4
#endif
#define ANG45 0x20000000
#define ANG90 0x40000000
#define ANG180 0x80000000
#define ANG270 0xc0000000
typedef unsigned angle_t;
#define FINEANGLES 8192
#define FINEMASK (FINEANGLES-1)
#define ANGLETOFINESHIFT 19 /* 0x100000000 to 0x2000 */
#ifdef MARS
fixed_t finesine(angle_t angle) ATTR_DATA_CACHE_ALIGN;
#define finecosine(angle) finesine((angle) + FINEANGLES / 4)
#else
extern const fixed_t finesine_[5*FINEANGLES/4];
extern const fixed_t *finecosine_;
#define finesine(x) finesine_[x]
#define finecosine(x) finecosine_[x]
#endif
typedef enum
{
sk_baby,
sk_easy,
sk_medium,
sk_hard,
sk_nightmare
} skill_t;
typedef enum
{
ga_nothing,
ga_died,
ga_completed,
ga_secretexit,
ga_warped,
ga_exitdemo,
ga_startnew,
ga_quit,
ga_cinematic
} gameaction_t;
/* */
/* library replacements */
/* */
#define D_abs(x) ((x < 0) ? -(x) : x)
void D_memset (void *dest, int val, size_t count) __attribute__((nonnull));
void D_memcpy (void *dest, const void *src, size_t count) __attribute__((nonnull));
void D_strncpy (char *dest, const char *src, int maxcount) __attribute__((nonnull));
int D_strncasecmp (const char *s1, const char *s2, int len) __attribute__((nonnull));
int D_strcasecmp (const char *s1, const char *s2) __attribute__((nonnull));
int mystrlen(const char *string) __attribute__((nonnull));
int D_atoi(const char* str) __attribute__((nonnull));
char* D_strchr(const char* str, char chr) __attribute__((nonnull));
/*
===============================================================================
MAPOBJ DATA
===============================================================================
*/
struct mobj_s;
/* think_t is a function pointer to a routine to handle an actor */
typedef void (*think_t) ();
/* a latecall is a function that needs to be called after p_base is done */
typedef void (*latecall_t) (struct mobj_s *mo);
typedef struct thinker_s
{
struct thinker_s *prev, *next;
think_t function;
} thinker_t;
struct player_s;
typedef struct
{
unsigned short x, y;
unsigned short angle;
unsigned short type;
} spawnthing_t;
enum
{
LC_NONE,
LC_SKULL_BASH,
LC_MISSILE_HIT,
LC_EXPLODE_MISSILE,
LC_REMOVE_MOBJ,
LC_INVALID = 15
};
typedef struct mobj_s
{
fixed_t x, y, z;
struct mobj_s* prev, * next;
VINT tics; /* state tic counter */
VINT state;
union {
unsigned short thingid; /* thing id for respawning specials */
VINT player; /* only valid if type == MT_PLAYER */
SPTR extradata; /* for latecall functions */
};
VINT type;
/* info for drawing */
SPTR snext;
SPTR sprev; /* links in sector (if needed) */
/* interaction info */
SPTR bnext;
SPTR bprev; /* links in blocks (if needed) */
struct subsector_s *subsector;
fixed_t floorz, ceilingz; /* closest together of contacted secs */
int flags;
int16_t radius, height; /* for movement checking */
/* STATIC OBJECTS END HERE */
angle_t angle;
fixed_t momx, momy, momz; /* momentums */
VINT health;
uint16_t speed; /* mobjinfo[mobj->type].speed */
struct mobj_s *target; /* thing being chased/attacked (or NULL) */
/* also the originator for missiles */
unsigned char latecall:4;
unsigned char movedir:4; /* 0-7 */
char movecount; /* when 0, select a new dir */
unsigned char reactiontime;/* if non 0, don't attack yet */
/* used by player to freeze a bit after */
/* teleporting */
unsigned char threshold; /* if >0, the target will be chased */
/* no matter what (even if shot) */
} mobj_t
;
typedef struct degenmobj_s
{
fixed_t x, y, z;
void *prev, *next;
} degenmobj_t
;
#define static_mobj_size (offsetof(mobj_t,angle))
/* */
/* frame flags */
/* */
#define FF_FULLBRIGHT 0x8000 /* flag in thing->frame */
#define FF_FRAMEMASK 0x7fff
/* */
/* sprite lump flags */
/* */
#define SL_SINGLESIDED 0x8000
#define SL_FLIPPED 0x4000
#define SL_LUMPMASK 0x3fff
/* */
/* mobj flags */
/* */
#define MF_SPECIAL 1 /* call P_SpecialThing when touched */
#define MF_SOLID 2
#define MF_SHOOTABLE 4
#define MF_NOSECTOR 8 /* don't use the sector links */
/* (invisible but touchable) */
#define MF_NOBLOCKMAP 16 /* don't use the blocklinks */
/* (inert but displayable) */
#define MF_AMBUSH 32
#define MF_JUSTHIT 64 /* try to attack right back */
#define MF_JUSTATTACKED 128 /* take at least one step before attacking */
#define MF_SPAWNCEILING 256 /* hang from ceiling instead of floor */
#define MF_NOGRAVITY 512 /* don't apply gravity every tic */
/* movement flags */
#define MF_DROPOFF 0x400 /* allow jumps from high places */
#define MF_PICKUP 0x800 /* for players to pick up items */
#define MF_NOCLIP 0x1000 /* player cheat */
#define MF_SLIDE 0x2000 /* keep info about sliding along walls */
#define MF_FLOAT 0x4000 /* allow moves to any height, no gravity */
#define MF_TELEPORT 0x8000 /* don't cross lines or look at heights */
#define MF_MISSILE 0x10000 /* don't hit same species, explode on block */
#define MF_DROPPED 0x20000 /* dropped by a demon, not level spawned */
#define MF_SHADOW 0x40000 /* use fuzzy draw (shadow demons / invis) */
#define MF_NOBLOOD 0x80000 /* don't bleed when shot (use puff) */
#define MF_CORPSE 0x100000 /* don't stop moving halfway off a step */
#define MF_INFLOAT 0x200000 /* floating to a height for a move, don't */
/* auto float to target's height */
#define MF_COUNTKILL 0x400000 /* count towards intermission kill total */
#define MF_COUNTITEM 0x800000 /* count towards intermission item total */
#define MF_SKULLFLY 0x1000000 /* skull in flight */
#define MF_NOTDMATCH 0x2000000 /* don't spawn in death match (key cards) */
#define MF_SEETARGET 0x4000000 /* is target visible? */
#define MF_STATIC 0x8000000 /* can't move or think */
#define MF_COLORMAP2 0x10000000 /* hell knight colormap */
#define MF_COUNTCUBE 0x20000000
/*============================================================================= */
typedef enum
{
PST_LIVE, /* playing */
PST_DEAD, /* dead on the ground */
PST_REBORN /* ready to restart */
} playerstate_t;
/* psprites are scaled shapes directly on the view screen */
/* coordinates are given for a 320*200 view screen */
typedef enum
{
ps_weapon,
ps_flash,
NUMPSPRITES
} psprnum_t;
typedef struct
{
VINT state; /* a S_NULL state means not active */
VINT tics;
fixed_t sx, sy;
} pspdef_t;
typedef enum
{
it_bluecard,
it_yellowcard,
it_redcard,
it_blueskull,
it_yellowskull,
it_redskull,
NUMCARDS
} card_t;
typedef enum
{
wp_fist,
wp_pistol,
wp_shotgun,
wp_supershotgun,
wp_chaingun,
wp_missile,
wp_plasma,
wp_bfg,
wp_chainsaw,
NUMWEAPONS,
wp_nochange
} weapontype_t;
typedef enum
{
am_clip, /* pistol / chaingun */
am_shell, /* shotgun */
am_cell, /* BFG */
am_misl, /* missile launcher */
NUMAMMO,
am_noammo /* chainsaw / fist */
} ammotype_t;
typedef struct
{
ammotype_t ammo;
int upstate;
int downstate;
int readystate;
int atkstate;
int flashstate;
} weaponinfo_t;
extern const weaponinfo_t weaponinfo[NUMWEAPONS];
typedef enum
{
pw_invulnerability,
pw_strength,
pw_ironfeet,
pw_allmap,
pw_infrared,
pw_invisibility,
NUMPOWERS
} powertype_t;
#define INVULNTICS (30*15)
#define INVISTICS (60*15)
#define INFRATICS (120*15)
#define IRONTICS (60*15)
/*
================
=
= player_t
=
================
*/
typedef struct player_s
{
mobj_t *mo;
playerstate_t playerstate;
int ticbuttons;
int oldticbuttons;
VINT ticmousex, ticmousey;
fixed_t forwardmove, sidemove; /* built from ticbuttons */
angle_t angleturn; /* built from ticbuttons */
fixed_t viewz; /* focal origin above r.z */
fixed_t viewheight; /* base height above floor for viewz */
fixed_t deltaviewheight; /* squat speed */
fixed_t bob; /* bounded/scaled total momentum */
VINT health; /* only used between levels, mo->health */
/* is used during levels */
VINT armorpoints, armortype; /* armor type is 0-2 */
VINT powers[NUMPOWERS]; /* invinc and invis are tic counters */
char cards[NUMCARDS];
char backpack;
char refire; /* refired shots are less accurate */
VINT frags; /* kills of other player */
VINT readyweapon;
VINT pendingweapon; /* wp_nochange if not changing */
char weaponowned[NUMWEAPONS];
char attackdown, usedown; /* true if button down last tic */
VINT ammo[NUMAMMO];
VINT maxammo[NUMAMMO];
VINT cheats; /* bit flags */
VINT ticremainder;
VINT killcount, itemcount, secretcount; /* for intermission */
char *message; /* hint messages */
VINT damagecount, bonuscount;/* for screen flashing */
VINT extralight; /* so gun flashes light up areas */
mobj_t *attacker; /* who did damage (NULL for floors) */
pspdef_t psprites[NUMPSPRITES]; /* view sprites (gun, etc) */
void *lastsoundsector; /* don't flood noise every time */
int automapx, automapy, automapflags;
int turnheld; /* for accelerative turning */
} player_t;
// stuff player keeps between respawns in single player
typedef struct
{
VINT health;
VINT armorpoints, armortype;
VINT ammo[NUMAMMO];
VINT maxammo[NUMAMMO];
VINT cheats;
VINT weapon;
char weaponowned[NUMWEAPONS];
char backpack;
} playerresp_t;
#define CF_NOCLIP 1
#define CF_GODMODE 2
#define AF_ACTIVE 1 /* automap active */
#define AF_FOLLOW 2
#define AF_ALLLINES 4
#define AF_ALLMOBJ 8
#define AF_OPTIONSACTIVE 128 /* options screen running */
/*
===============================================================================
GLOBAL VARIABLES
===============================================================================
*/
/*================================== */
extern VINT ticrate; /* 4 for NTSC, 3 for PAL */
extern VINT ticsinframe; /* how many tics since last drawer */
extern int ticon;
extern int frameon;
extern int ticrealbuttons, oldticrealbuttons; /* buttons for the console player before reading the demo file */
extern boolean mousepresent;
int MiniLoop ( void (*start)(void), void (*stop)(void)
, int (*ticker)(void), void (*drawer)(void)
, void (*update)(void) );
int G_Ticker (void);
void G_Drawer (void);
void G_RunGame (void);
void G_LoadGame(int saveslot);
/*================================== */
#include "d_mapinfo.h"
extern VINT gameaction;
#define SBARHEIGHT 40 /* status bar height at bottom of screen */
typedef enum
{
gt_single,
gt_coop,
gt_deathmatch
} gametype_t;
extern VINT netgame;
extern boolean playeringame[MAXPLAYERS];
extern VINT consoleplayer; /* player taking events and displaying */
extern player_t *players;
extern playerresp_t *playersresp;
extern VINT maxammo[NUMAMMO];
extern VINT gameskill;
extern VINT totalkills, totalitems, totalsecret; /* for intermission */
extern const char *gamemaplump;
extern dgameinfo_t gameinfo;
extern dmapinfo_t **gamemaplist;
extern dmapinfo_t *gamemapinfo;
extern VINT gamemapcount;
extern int gametic;
extern int prevgametic;
#define MAXDMSTARTS 10
extern mapthing_t *deathmatchstarts, *deathmatch_p;
extern mapthing_t playerstarts[MAXPLAYERS];
#define BODYQUESIZE 4
extern VINT bodyqueslot;
extern boolean finale, secretexit;
/*
===============================================================================
GLOBAL FUNCTIONS
===============================================================================
*/
#ifdef MARS
#define FixedMul(a,b) (((int64_t)(a) * (b))>>16)
fixed_t FixedDiv (fixed_t a, fixed_t b);
fixed_t IDiv (fixed_t a, fixed_t b);
#else
fixed_t FixedMul (fixed_t a, fixed_t b);
fixed_t FixedDiv (fixed_t a, fixed_t b);
#define IDiv(a,b) ((a) / (b))
#endif
#define ACC_FIXEDMUL 4
#define ACC_FIXEDDIV 8
#define ACC_MULSI3 12
#define ACC_UDIVSI3 16
#if defined(JAGUAR) || (defined(MARS)&&!defined(NeXT))
#ifndef __BIG_ENDIAN__
#define __BIG_ENDIAN__
#endif
#endif
short ShortSwap (short dat);
long LongSwap (long dat);
#ifdef __BIG_ENDIAN__
#define BIGSHORT(x) (x)
#define BIGLONG(x) (x)
/*define LITTLESHORT(x) ShortSwap(x) */
#define LITTLESHORT(x) (short)((((x)&255)<<8)+(((x)>>8)&255))
#define LITTLELONG(x) LongSwap(x)
#else
#define BIGSHORT(x) ShortSwap(x)
#define BIGLONG(x) LongSwap(x)
#define LITTLESHORT(x) (x)
#define LITTLELONG(x) (x)
#endif
/*----------- */
/*MEMORY ZONE */
/*----------- */
/* tags < 100 are not overwritten until freed */
#define PU_STATIC 1 /* static entire execution time */
#define PU_SOUND 2 /* static while playing */
#define PU_MUSIC 3 /* static while playing */
#define PU_LEVEL 50 /* static until level exited */
#define PU_LEVSPEC 51 /* a special thinker in a level */
#define ZONEID 0x1d4a
typedef struct memblock_s
{
int size; /* including the header and possibly tiny fragments */
short tag; /* purgelevel */
short id; /* should be ZONEID */
#ifndef MARS
int lockframe; /* don't purge on the same frame */
#endif
struct memblock_s *next;
struct memblock_s *prev;
} memblock_t;
typedef struct
{
int size; /* total bytes malloced, including header */
memblock_t *rover;
memblock_t blocklist; /* start / end cap for linked list */
} memzone_t;
typedef void (*memblockcall_t) (void *, void*);
extern VINT framecount;
extern memzone_t *mainzone;
extern memzone_t *refzone;
void Z_Init (void);
memzone_t *Z_InitZone (byte *base, int size);
void *Z_Malloc2 (memzone_t *mainzone, int size, int tag, boolean err);
void Z_Free2 (memzone_t *mainzone,void *ptr);
#define Z_Malloc(x,y) Z_Malloc2(mainzone,x,y,true)
#define Z_Free(x) Z_Free2(mainzone,x)
void Z_FreeTags (memzone_t *mainzone);
void Z_CheckHeap (memzone_t *mainzone);
void Z_ChangeTag (void *ptr, int tag);
int Z_FreeMemory (memzone_t *mainzone);
int Z_LargestFreeBlock(memzone_t *mainzone);
void Z_ForEachBlock(memzone_t *mainzone, memblockcall_t cb, void *userp);
int Z_FreeBlocks(memzone_t* mainzone);
/*------- */
/*WADFILE */
/*------- */
enum
{
PWAD_NONE,
PWAD_CD,
MAXWADS,
};
extern char cd_pwad_name[64];
#define SOUNDS_PWAD_NAME "SOUNDS.WAD"
#define MAPDEV_PWAD_NAME "MAPDEV.WAD"
/*=============== */
/* TYPES */
/*=============== */
typedef struct
{
int filepos; /* also texture_t * for comp lumps */
int size;
char name[8];
} lumpinfo_t;
void W_Init (void);
void W_InitCDPWAD(int wawdnum, const char *name);
void W_LoadPWAD(int wadnum);
int W_CacheWADLumps (lumpinfo_t *li, int numlumps, VINT *lumps, boolean setpwad);
int W_CheckNumForName (const char *name);
#define W_GetNumForName(name) W_GetNumForName_(name,__func__)
int W_GetNumForName_ (const char *name, const char *func);
int W_CheckRangeForName (const char *name, int start, int end);
int W_LumpLength (int lump);
int W_ReadLump (int lump, void *dest);
void *W_CacheLumpNum (int lump, int tag);
void *W_CacheLumpName (const char *name, int tag);
boolean W_IsIWad(int lump);
boolean W_IsCompressed_(int lump, const char *func);
const char *W_GetNameForNum (int lump);
void * W_GetRawLumpData_(int lump, const char *func);
void * W_GetLumpData_(int lump, const char *func);
void * W_ReadLumpData_(int lump, const char *func, void *dest, boolean compressed);
#define W_GetRawLumpData(lump) W_GetRawLumpData_(lump,__func__)
#define W_GetLumpData(lump) W_GetLumpData_(lump,__func__)
#define W_ReadLumpData(lump,dest,compressed) W_ReadLumpData_(lump,__func__,dest,compressed)
#define W_POINTLUMPNUM(x) W_GetRawLumpData(x)
#define W_IsCompressed(lump) W_IsCompressed_(lump,__func__)
/*---------- */
/*BASE LEVEL */
/*---------- */
void D_DoomMain (void);
void D_DoomLoop (void);
extern boolean demoplayback, demorecording;
extern unsigned *demo_p, *demobuffer;
extern VINT startskill;
extern VINT startmap;
extern VINT starttype;
extern VINT startsave;
extern boolean startsplitscreen;
/*--------- */
/*SYSTEM IO */
/*--------- */
#define SCREENWIDTH 320
#define SCREENHEIGHT 180
void I_Init (void);
byte *I_WadBase (void);
byte *I_ZoneBase (int *size);
#ifdef ENABLE_SSF_MAPPER
void* I_RemapPtr (void* ptr) ATTR_DATA_CACHE_ALIGN;
int I_SetBankPage(int page) ATTR_DATA_CACHE_ALIGN;
int I_GetBankPage(void) ATTR_DATA_CACHE_ALIGN;
#else
#define I_RemapPtr(ptr) (ptr)
#define I_SetBankPage(page) (void)0
#define I_GetBankPage() (-1)
#endif
/* return a pointer to a 64k or so temp work buffer for level setup uses */
/*(non-displayed frame buffer) */
/* Vic: changed this to always return buffer memset to 0 */
byte *I_TempBuffer (int size);
/* temp work buffer which may contain garbage data */
byte *I_WorkBuffer (void);
void I_FreeWorkBuffer(void);
byte *I_AllocWorkBuffer(int size);
pixel_t *I_FrameBuffer (void);
pixel_t* I_OverwriteBuffer(void);
pixel_t *I_ViewportBuffer (void);
int I_ViewportYPos(void);
int I_FrameBufferHeight(void);
int I_IsPAL(void);
void I_ClearFrameBuffer(void);
void I_ClearWorkBuffer(int len);
void I_ResetLineTable(void);
void I_SetPalette (const byte *palette);
int I_ReadControls(void);
int I_ReadControls2(void);
int I_ReadMouse(int *pmx, int *pmy);
void I_NetSetup (void);
unsigned I_NetTransfer (unsigned buttons);
void I_NetStop(void);
void I_NetReady(void);
boolean I_RefreshCompleted (void);
boolean I_RefreshLatched (void);
int I_GetTime (void);
int I_GetFRTCounter (void);
void I_Update (void);
void I_Error (char *error, ...) __attribute__((noreturn));
void I_StoreScreenCopy(void);
void I_RestoreScreenCopy(void);
void I_SwapScreenCopy(void);
void HUD_AddMessage(const char *msg);
void HUD_Ticker(void);
void HUD_Init(void);
void HUD_Drawer(void);
#ifdef MARS
//#define USE_C_DRAW
#ifdef USE_C_DRAW
#define I_DrawColumnLow I_DrawColumnLowC
#define I_DrawFuzzColumnLow I_DrawFuzzColumnLowC
#define I_DrawColumnNPo2Low I_DrawColumnNPo2LowC
#define I_DrawSpanLow I_DrawSpanLowC
#define I_DrawSpanLowSwap I_DrawSpanLowSwapC
#define I_DrawColumn I_DrawColumnC
#define I_DrawColumnNPo2 I_DrawColumnNPo2C
#define I_DrawFuzzColumn I_DrawFuzzColumnC
#define I_DrawSpan I_DrawSpanC
#else
#define I_DrawColumnLow I_DrawColumnLowA
#define I_DrawFuzzColumnLow I_DrawFuzzColumnLowA
#define I_DrawColumnNPo2Low I_DrawColumnNPo2LowA
#define I_DrawSpanLow I_DrawSpanLowA
#define I_DrawSpanLowSwap I_DrawSpanLowSwapA
#define I_DrawColumn I_DrawColumnA
#define I_DrawColumnNPo2 I_DrawColumnNPo2A
#define I_DrawFuzzColumn I_DrawFuzzColumnA
#define I_DrawSpan I_DrawSpanA
#endif
#define I_Draw4bColumnLow I_Draw4bColumnLowA
#define I_Draw4bColumnNPo2Low I_Draw4bColumnNPo2LowA
#define I_Draw4bColumn I_Draw4bColumnA
#define I_Draw4bColumnNPo2 I_Draw4bColumnNPo2A
#endif
void I_DrawColumnLow(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_DrawColumnNPo2Low(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_DrawSpanLow(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_xfrac,
fixed_t ds_yfrac, fixed_t ds_xstep, fixed_t ds_ystep, inpixel_t* ds_source, int dc_texheight);
void I_DrawSpanLowSwap(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_xfrac,
fixed_t ds_yfrac, fixed_t ds_xstep, fixed_t ds_ystep, inpixel_t* ds_source, int dc_texheight);
void I_Draw4bColumnLow(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_Draw4bColumnNPo2Low(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_DrawColumn(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_DrawColumnNPo2(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_DrawSpan(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_xfrac,
fixed_t ds_yfrac, fixed_t ds_xstep, fixed_t ds_ystep, inpixel_t* ds_source, int dc_texheight);
void I_Draw4bColumn(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_Draw4bColumnNPo2(int dc_x, int dc_yl, int dc_yh, int light, fixed_t dc_iscale,
fixed_t dc_texturemid, inpixel_t* dc_source, int dc_texheight);
void I_DrawSpanPotato(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_xfrac,
fixed_t ds_yfrac, fixed_t ds_xstep, fixed_t ds_ystep, inpixel_t* ds_source, int dc_texheight)
ATTR_DATA_CACHE_ALIGN;
void I_DrawSpanPotatoLow(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_xfrac,
fixed_t ds_yfrac, fixed_t ds_xstep, fixed_t ds_ystep, inpixel_t* ds_source, int dc_texheight)
ATTR_DATA_CACHE_ALIGN;
void I_DrawFuzzColumn(int dc_x, int dc_yl, int dc_yh, int light, fixed_t frac_,
fixed_t fracstep, inpixel_t* dc_source, int dc_texheight);
void I_DrawFuzzColumnLow(int dc_x, int dc_yl, int dc_yh, int light, fixed_t frac_,
fixed_t fracstep, inpixel_t* dc_source, int dc_texheight);
void I_DrawColumnNoDraw(int dc_x, int dc_yl, int dc_yh, int light, fixed_t frac_,
fixed_t fracstep, inpixel_t* dc_source, int dc_texheight);
void I_DrawSpanNoDraw(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_xfrac,
fixed_t ds_yfrac, fixed_t ds_xstep, fixed_t ds_ystep, inpixel_t* ds_source, int dc_texheight);
void I_Print8 (int x, int y, const char *string);
int I_Print8Len(const char* string);
void I_DebugScreen (void);
/*---- */
/*GAME */
/*---- */
void G_DeathMatchSpawnPlayer (int playernum);
void G_Init(void);
void G_InitNew (skill_t skill, int map, gametype_t gametype, boolean splitscreen);
void G_ExitLevel (void);
void G_SecretExitLevel (void);
void G_WorldDone (void);
void G_RecordDemo (void);
int G_PlayDemoPtr (unsigned *demo);
dmapinfo_t *G_MapInfoForLumpName(const char *lumpName);
const char *G_LumpNameForMapNum(int map);
const char *G_MapNameForMapNum(int map);
void G_DeInit (void);
/*----- */
/*PLAY */
/*----- */
void P_SetupLevel (const char *lumpname, skill_t skill, const char *sky);
void P_Init (void);
void P_Start (void);
void P_Stop (void);
int P_Ticker (void);
void P_Drawer (void);
void P_Update (void);
void IN_Start (void);
void IN_Stop (void);
int IN_Ticker (void);
void IN_Drawer (void);
void M_Start (void);
void M_Start2(boolean startup);
void M_Stop (void);
int M_Ticker (void);
void M_Drawer (void);
void F_Start (void);
void F_Stop (void);