/
dd_share.h
1459 lines (1285 loc) · 44.5 KB
/
dd_share.h
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
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2007 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2008 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* dd_share.h: Shared Macros and Constants
*
* Macros and constants used by the engine and games.
*/
#ifndef __DOOMSDAY_SHARED_H__
#define __DOOMSDAY_SHARED_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include "../portable/include/dd_version.h"
#include "dd_types.h"
#include "dd_maptypes.h"
#include "../portable/include/p_think.h" // \todo Not officially a public header file!
#include "../portable/include/def_share.h" // \todo Not officially a public header file!
//------------------------------------------------------------------------
//
// General Definitions and Macros
//
//------------------------------------------------------------------------
#define DDMAXPLAYERS 16
// The case-independent strcmps have different names.
#ifdef WIN32
# define strcasecmp stricmp
# define strncasecmp strnicmp
#endif
#ifdef UNIX
# define stricmp strcasecmp
# define strnicmp strncasecmp
/**
* There are manual implementations for these string handling
* routines:
*/
char *strupr(char *string);
char *strlwr(char *string);
#endif
// We need to use _vsnprintf, _snprintf in Windows
#if WIN32
# if(_MSC_VER < 1500)
# define vsnprintf _vsnprintf
# endif
# define snprintf _snprintf
#endif
// Format checking for printf-like functions in GCC2
#if defined(__GNUC__) && __GNUC__ >= 2
# define PRINTF_F(f,v) __attribute__ ((format (printf, f, v)))
#else
# define PRINTF_F(f,v)
#endif
#ifdef __BIG_ENDIAN__
short ShortSwap(short);
long LongSwap(long);
float FloatSwap(float);
#define SHORT(x) ShortSwap(x)
#define LONG(x) LongSwap(x)
#define FLOAT(x) FloatSwap(x)
// In these, x is evaluated multiple times, so increments and decrements
// cannot be used.
#define MACRO_SHORT(x) ((short)(( ((short)(x)) & 0xff ) << 8) | (( ((short)(x)) & 0xff00) >> 8))
#define MACRO_LONG(x) ((long)((( ((long)(x)) & 0xff) << 24) | (( ((long)(x)) & 0xff00) << 8) | \
(( ((long)(x)) & 0xff0000) >> 8) | (( ((long)(x)) & 0xff000000) >> 24) ))
#else
// Little-endian.
#define SHORT(x) (x)
#define LONG(x) (x)
#define FLOAT(x) (x)
#define MACRO_SHORT(x) (x)
#define MACRO_LONG(x) (x)
#endif
#define USHORT(x) ((unsigned short) SHORT(x))
#define ULONG(x) ((unsigned long) LONG(x))
#define MAX_OF(x, y) ((x) > (y)? (x) : (y))
#define MIN_OF(x, y) ((x) < (y)? (x) : (y))
#define MINMAX_OF(a, x, b) ((x) < (a)? (a) : (x) > (b)? (b) : (x))
#define SIGN_OF(x) ((x) > 0? +1 : (x) < 0? -1 : 0)
#define ROUND(x) ((int) (((x) < 0.0f)? ((x) - 0.5f) : ((x) + 0.5f)))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
// Used to replace /255 as *reciprocal255 is less expensive with CPU cycles.
// Note that this should err on the side of being < 1/255 to prevent result
// exceeding 255 (e.g. 255 * reciprocal255).
#define reciprocal255 0.003921568627f
typedef enum // Value types.
{
DDVT_NONE = -1, // Not a read/writeable value type.
DDVT_BOOL,
DDVT_BYTE,
DDVT_SHORT,
DDVT_INT, // 32 or 64
DDVT_UINT,
DDVT_FIXED,
DDVT_ANGLE,
DDVT_FLOAT,
DDVT_LONG,
DDVT_ULONG,
DDVT_PTR,
DDVT_FLAT_INDEX,
DDVT_BLENDMODE,
DDVT_VERT_IDX,
DDVT_LINE_IDX,
DDVT_SIDE_IDX,
DDVT_SECT_IDX,
DDVT_SEG_IDX
} valuetype_t;
enum {
// TexFilterMode targets
DD_TEXTURES = 0,
DD_RAWSCREENS,
// Filter/mipmap modes
DD_NEAREST = 0,
DD_LINEAR,
DD_NEAREST_MIPMAP_NEAREST,
DD_LINEAR_MIPMAP_NEAREST,
DD_NEAREST_MIPMAP_LINEAR,
DD_LINEAR_MIPMAP_LINEAR,
// Music devices
DD_MUSIC_NONE = 0,
DD_MUSIC_MIDI,
DD_MUSIC_CDROM,
// Integer values for Set/Get
DD_FIRST_VALUE = -1,
DD_NETGAME,
DD_SERVER,
DD_CLIENT,
DD_ALLOW_FRAMES,
DD_GAMETIC,
DD_VIEWWINDOW_X,
DD_VIEWWINDOW_Y,
DD_VIEWWINDOW_WIDTH,
DD_VIEWWINDOW_HEIGHT,
DD_CONSOLEPLAYER,
DD_DISPLAYPLAYER,
DD_MUSIC_DEVICE,
DD_MIPMAPPING,
DD_SMOOTH_IMAGES,
DD_DEFAULT_RES_X,
DD_DEFAULT_RES_Y,
DD_SKY_DETAIL,
DD_SFX_VOLUME,
DD_MUSIC_VOLUME,
DD_MOUSE_INVERSE_Y,
DD_QUERY_RESULT,
DD_FULLBRIGHT, // Render everything fullbright?
DD_CCMD_RETURN,
DD_GAME_READY,
DD_OPENRANGE,
DD_OPENTOP,
DD_OPENBOTTOM,
DD_LOWFLOOR,
DD_DEDICATED,
DD_NOVIDEO,
DD_NUMMOBJTYPES,
DD_GOTFRAME,
DD_PLAYBACK,
DD_NUMSOUNDS,
DD_NUMMUSIC,
DD_NUMLUMPS,
DD_CLIENT_PAUSED,
DD_WEAPON_OFFSET_SCALE_Y, // 1000x
DD_MONOCHROME_PATCHES, // DJS - convert patch image data to monochrome. 1= linear 2= weighted
DD_GAME_DATA_FORMAT,
DD_GAME_DRAW_HUD_HINT, // Doomsday advises not to draw the HUD
DD_UPSCALE_AND_SHARPEN_PATCHES,
DD_LAST_VALUE,
// General constants (not to be used with Get/Set).
DD_NEW = -2,
DD_SKY = -1,
DD_DISABLE,
DD_ENABLE,
DD_MASK,
DD_YES,
DD_NO,
DD_MATERIAL,
DD_OFFSET,
DD_HEIGHT,
DD_COLUMNS,
DD_ROWS,
DD_COLOR_LIMIT,
DD_PRE,
DD_POST,
DD_VERSION_SHORT,
DD_VERSION_LONG,
DD_PROTOCOL,
DD_NUM_SERVERS,
DD_TCPIP_ADDRESS,
DD_TCPIP_PORT,
DD_COM_PORT,
DD_BAUD_RATE,
DD_STOP_BITS,
DD_PARITY,
DD_FLOW_CONTROL,
DD_MODEM,
DD_PHONE_NUMBER,
DD_HORIZON,
DD_GAME_ID,
DD_DEF_MOBJ,
DD_DEF_MOBJ_BY_NAME,
DD_DEF_STATE,
DD_DEF_SPRITE,
DD_DEF_SOUND,
DD_DEF_MUSIC,
DD_DEF_MAP_INFO,
DD_DEF_TEXT,
DD_DEF_VALUE,
DD_DEF_LINE_TYPE,
DD_DEF_SECTOR_TYPE,
DD_PSPRITE_BOB_X,
DD_PSPRITE_BOB_Y,
DD_ALT_MOBJ_THINKER,
DD_DEF_FINALE_AFTER,
DD_DEF_FINALE_BEFORE,
DD_RENDER_RESTART_PRE,
DD_RENDER_RESTART_POST,
DD_DEF_SOUND_BY_NAME,
DD_DEF_SOUND_LUMPNAME,
DD_ID,
DD_LUMP,
DD_CD_TRACK,
DD_GAME_MODE, // 16 chars max (swdoom, doom1, udoom, tnt, heretic...)
DD_GAME_CONFIG, // String: dm/co-op, jumping, etc.
DD_DEF_FINALE,
DD_GAME_NAME, // (eg jDoom, jHeretic...)
DD_GAME_DMUAPI_VER, // Version of the DMU API the game is using.
// Queries
DD_TEXTURE_HEIGHT_QUERY = 0x2000,
DD_NET_QUERY,
DD_SERVER_DATA_QUERY,
DD_MODEM_DATA_QUERY,
// Non-integer/special values for Set/Get
DD_SKYMASKMATERIAL_NAME = 0x4000,
DD_SKYMASKMATERIAL_NUM,
DD_TRANSLATIONTABLES_ADDRESS,
DD_TRACE_ADDRESS, // divline 'trace' used by PathTraverse.
DD_SPRITE_REPLACEMENT, // Sprite <-> model replacement.
DD_ACTION_LINK, // State action routine addresses.
DD_MAP_NAME,
DD_MAP_AUTHOR,
DD_MAP_MUSIC,
DD_MAP_MIN_X,
DD_MAP_MIN_Y,
DD_MAP_MAX_X,
DD_MAP_MAX_Y,
DD_WINDOW_WIDTH,
DD_WINDOW_HEIGHT,
DD_WINDOW_HANDLE,
DD_DYNLIGHT_TEXTURE,
DD_SECTOR_COUNT,
DD_LINE_COUNT,
DD_SIDE_COUNT,
DD_VERTEX_COUNT,
DD_SEG_COUNT,
DD_SUBSECTOR_COUNT,
DD_NODE_COUNT,
DD_POLYOBJ_COUNT,
DD_XGFUNC_LINK, // XG line classes
DD_SHARED_FIXED_TRIGGER,
DD_VIEWX,
DD_VIEWY,
DD_VIEWZ,
DD_VIEWX_OFFSET,
DD_VIEWY_OFFSET,
DD_VIEWZ_OFFSET,
DD_VIEWANGLE,
DD_VIEWANGLE_OFFSET,
DD_CPLAYER_THRUST_MUL,
DD_GRAVITY,
DD_PSPRITE_OFFSET_X, // 10x
DD_PSPRITE_OFFSET_Y, // 10x
DD_TORCH_RED,
DD_TORCH_GREEN,
DD_TORCH_BLUE,
DD_TORCH_ADDITIVE
};
// Bounding box coordinates.
enum {
BOXTOP = 0,
BOXBOTTOM = 1,
BOXLEFT = 2,
BOXRIGHT = 3,
BOXFLOOR = 4,
BOXCEILING = 5
};
//------------------------------------------------------------------------
//
// Fixed-Point Math
//
//------------------------------------------------------------------------
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
#define FINEANGLES 8192
#define FINEMASK (FINEANGLES-1)
#define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000
#define ANGLE_45 0x20000000
#define ANGLE_90 0x40000000
#define ANGLE_180 0x80000000
#define ANGLE_MAX 0xffffffff
#define ANGLE_1 (ANGLE_45/45)
#define ANGLE_60 (ANGLE_180/3)
#define ANG45 0x20000000
#define ANG90 0x40000000
#define ANG180 0x80000000
#define ANG270 0xc0000000
#define FIX2FLT(x) ( (x) / (float) FRACUNIT )
#define Q_FIX2FLT(x) ( (float)((x)>>FRACBITS) )
#define FLT2FIX(x) ( (fixed_t) ((x)*FRACUNIT) )
#if !defined( NO_FIXED_ASM ) && !defined( GNU_X86_FIXED_ASM )
/* *INDENT-OFF* */
__inline fixed_t FixedMul(fixed_t a, fixed_t b) {
__asm {
// The parameters in eax and ebx.
mov eax, a
mov ebx, b
// The multiplying.
imul ebx
shrd eax, edx, 16
// eax should hold the return value.
}
// A value is returned regardless of the compiler warning.
}
__inline fixed_t FixedDiv2(fixed_t a, fixed_t b) {
__asm {
// The parameters.
mov eax, a
mov ebx, b
// The operation.
cdq
shld edx, eax, 16
sal eax, 16
idiv ebx
// And the value returns in eax.
}
// A value is returned regardless of the compiler warning.
}
/* *INDENT-ON* */
#else
// Don't use inline assembler in fixed-point calculations.
// (link with Src/Common/m_fixed.c)
fixed_t FixedMul(fixed_t a, fixed_t b);
fixed_t FixedDiv2(fixed_t a, fixed_t b);
#endif
// This one is always in Src/Common/m_fixed.c.
fixed_t FixedDiv(fixed_t a, fixed_t b);
//------------------------------------------------------------------------
//
// Key Codes
//
//------------------------------------------------------------------------
// Most key data is simple ASCII.
#define DDKEY_ESCAPE 27
#define DDKEY_RETURN 13
#define DDKEY_TAB 9
#define DDKEY_BACKSPACE 127
#define DDKEY_EQUALS 0x3d
#define DDKEY_MINUS 0x2d
#define DDKEY_BACKSLASH 0x5C
// Extended keys (above 127).
enum {
DDKEY_RIGHTARROW = 0x80,
DDKEY_LEFTARROW,
DDKEY_UPARROW,
DDKEY_DOWNARROW,
DDKEY_F1,
DDKEY_F2,
DDKEY_F3,
DDKEY_F4,
DDKEY_F5,
DDKEY_F6,
DDKEY_F7,
DDKEY_F8,
DDKEY_F9,
DDKEY_F10,
DDKEY_F11,
DDKEY_F12,
DDKEY_NUMLOCK,
DDKEY_SCROLL,
DDKEY_NUMPAD7,
DDKEY_NUMPAD8,
DDKEY_NUMPAD9,
DDKEY_NUMPAD4,
DDKEY_NUMPAD5,
DDKEY_NUMPAD6,
DDKEY_NUMPAD1,
DDKEY_NUMPAD2,
DDKEY_NUMPAD3,
DDKEY_NUMPAD0,
DDKEY_DECIMAL,
DDKEY_PAUSE,
DDKEY_RSHIFT,
DDKEY_LSHIFT = DDKEY_RSHIFT,
DDKEY_RCTRL,
DDKEY_LCTRL = DDKEY_RCTRL,
DDKEY_RALT,
DDKEY_LALT = DDKEY_RALT,
DDKEY_INS,
DDKEY_DEL,
DDKEY_PGUP,
DDKEY_PGDN,
DDKEY_HOME,
DDKEY_END,
DDKEY_SUBTRACT, /* - on numeric keypad */
DDKEY_ADD, /* + on numeric keypad */
DD_HIGHEST_KEYCODE
};
//------------------------------------------------------------------------
//
// Events
//
//------------------------------------------------------------------------
typedef enum {
EV_KEY,
EV_MOUSE_AXIS,
EV_MOUSE_BUTTON,
EV_JOY_AXIS, // Joystick main axes (xyz + Rxyz)
EV_JOY_SLIDER, // Joystick sliders
EV_JOY_BUTTON,
EV_POV,
NUM_EVENT_TYPES
} evtype_t;
typedef enum {
EVS_DOWN,
EVS_UP,
EVS_REPEAT,
NUM_EVENT_STATES
} evstate_t;
typedef struct {
evtype_t type;
evstate_t state; // only used with digital controls
int data1; // keys/mouse/joystick buttons
int data2; // mouse/joystick x move
int data3; // mouse/joystick y move
int data4;
int data5;
int data6;
} event_t;
// The mouse wheel is considered two extra mouse buttons.
#define DD_MWHEEL_UP 3
#define DD_MWHEEL_DOWN 4
#define DD_MICKEY_ACCURACY 1000
// Control classes.
typedef enum
{
CC_AXIS,
CC_TOGGLE,
CC_IMPULSE,
NUM_CONTROL_CLASSES
} ctlclass_t;
//------------------------------------------------------------------------
//
// Purge Levels
//
//------------------------------------------------------------------------
#define PU_STATIC 1 // static entire execution time
#define PU_SOUND 2 // static while playing
#define PU_MUSIC 3 // static while playing
#define PU_USER1 40
#define PU_USER2 41
#define PU_USER3 42
#define PU_USER4 43
#define PU_USER5 44
#define PU_USER6 45
#define PU_USER7 46
#define PU_USER8 47
#define PU_USER9 48
#define PU_USER10 49
#define PU_LEVEL 50 // static until level exited (may be freed
// during the level, though)
#define PU_LEVSPEC 51 // a special thinker in a level
// tags >= 100 are purgable whenever needed
#define PU_LEVELSTATIC 52 // not freed until level exited
#define PU_PURGELEVEL 100
#define PU_CACHE 101
// Special purgelevel.
#define PU_GETNAME 100000L
//------------------------------------------------------------------------
//
// Map Data
//
//------------------------------------------------------------------------
#define DMUAPI_VER 1 // Public DMU API version number.
// Requested by the engine during init.
// Map Update constants.
enum /* Do not change the numerical values of the constants! */
{
// Flags. OR'ed with a DMU property constant. The most significant
// byte is used for the flags.
DMU_FLAG_MASK = 0xff000000,
DMU_SIDEDEF1_OF_LINE = 0x80000000,
DMU_SIDEDEF0_OF_LINE = 0x40000000,
DMU_TOP_OF_SIDEDEF = 0x20000000,
DMU_MIDDLE_OF_SIDEDEF = 0x10000000,
DMU_BOTTOM_OF_SIDEDEF = 0x08000000,
DMU_FLOOR_OF_SECTOR = 0x04000000,
DMU_CEILING_OF_SECTOR = 0x02000000,
// (1 bits left)
DMU_NONE = 0,
DMU_VERTEX = 1,
DMU_SEG,
DMU_LINEDEF,
DMU_SIDEDEF,
DMU_NODE,
DMU_SUBSECTOR,
DMU_SECTOR,
DMU_PLANE,
DMU_SURFACE,
DMU_POLYOBJ,
DMU_LINEDEF_BY_TAG,
DMU_SECTOR_BY_TAG,
DMU_LINEDEF_BY_ACT_TAG,
DMU_SECTOR_BY_ACT_TAG,
DMU_X,
DMU_Y,
DMU_XY,
DMU_VERTEX0,
DMU_VERTEX1,
DMU_FRONT_SECTOR,
DMU_BACK_SECTOR,
DMU_SIDEDEF0,
DMU_SIDEDEF1,
DMU_FLAGS,
DMU_DX,
DMU_DY,
DMU_LENGTH,
DMU_SLOPE_TYPE,
DMU_ANGLE,
DMU_OFFSET,
DMU_MATERIAL,
DMU_MATERIAL_OFFSET_X,
DMU_MATERIAL_OFFSET_Y,
DMU_MATERIAL_OFFSET_XY,
DMU_VALID_COUNT,
DMU_LINEDEF_COUNT,
DMU_COLOR, // RGB
DMU_COLOR_RED, // red component
DMU_COLOR_GREEN, // green component
DMU_COLOR_BLUE, // blue component
DMU_ALPHA,
DMU_BLENDMODE,
DMU_LIGHT_LEVEL,
DMT_MOBJS, // pointer to start of sector mobjList
DMU_BOUNDING_BOX, // float[4]
DMU_SOUND_ORIGIN,
DMU_HEIGHT,
DMU_TARGET_HEIGHT,
DMU_SEG_COUNT,
DMU_TAG,
DMU_START_SPOT, // degenmobj_t
DMU_START_SPOT_X,
DMU_START_SPOT_Y,
DMU_START_SPOT_XY,
DMU_DESTINATION_X,
DMU_DESTINATION_Y,
DMU_DESTINATION_XY,
DMU_DESTINATION_ANGLE,
DMU_SPEED,
DMU_ANGLE_SPEED,
DMU_SEQUENCE_TYPE,
DMU_CRUSH, // boolean
DMU_SPECIAL_DATA
};
// Linedef flags:
// For use with P_Set/Get(DMU_LINEDEF, n, DMU_FLAGS)
#define DDLF_BLOCKING 0x0001
#define DDLF_DONTPEGTOP 0x0002
#define DDLF_DONTPEGBOTTOM 0x0004
// Map Update status code constants.
// Sent to the game when various map update events occur.
enum /* do not change the numerical values of the constants */
{
DMUSC_SECTOR_ISBENIGN,
DMUSC_LINE_FIRSTRENDERED
};
// Fixed-point vertex position. Utility struct for the game, not
// used by the engine.
typedef struct ddvertex_s {
fixed_t pos[2];
} ddvertex_t;
// Floating-point vertex position. Utility struct for the game,
// not used by the engine.
typedef struct ddvertexf_s {
float pos[2];
} ddvertexf_t;
// SetupLevel modes.
enum
{
DDSLM_AFTER_LOADING, // After loading a savegame...
DDSLM_FINALIZE, // After everything else is done.
DDSLM_INITIALIZE, // Before anything else if done.
DDSLM_AFTER_BUSY // After leaving busy mode, which was used during setup.
};
enum // Sector reverb data indices.
{
SRD_VOLUME,
SRD_SPACE,
SRD_DECAY,
SRD_DAMPING,
NUM_REVERB_DATA
};
// each sector has a degenmobj_t in it's center for sound origin purposes
typedef struct {
thinker_t thinker; // not used for anything
float pos[3];
} degenmobj_t;
typedef struct {
fixed_t pos[2], dX, dY;
} divline_t;
typedef struct {
float pos[2], dX, dY;
} fdivline_t;
// For PathTraverse.
#define PT_ADDLINES 1
#define PT_ADDMOBJS 2
#define PT_EARLYOUT 4
//// \todo This stuff is obsolete and needs to be removed!
#define MAPBLOCKUNITS 128
#define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT)
#define MAPBLOCKSHIFT (FRACBITS+7)
#define MAPBMASK (MAPBLOCKSIZE-1)
#define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS)
typedef enum {
ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE
} slopetype_t;
// For (un)linking.
#define DDLINK_SECTOR 0x1
#define DDLINK_BLOCKMAP 0x2
#define DDLINK_NOLINE 0x4
typedef enum intercepttype_e {
ICPT_MOBJ,
ICPT_LINE
} intercepttype_t;
typedef struct intercept_s {
float frac; // Along trace line.
intercepttype_t type;
union {
struct mobj_s *mo;
struct linedef_s *lineDef;
} d;
} intercept_t;
typedef boolean (*traverser_t) (intercept_t * in);
#define NO_INDEX 0xffffffff
//------------------------------------------------------------------------
//
// Mobjs
//
//------------------------------------------------------------------------
/**
* Linknodes are used when linking mobjs to lines. Each mobj has a ring
* of linknodes, each node pointing to a line the mobj has been linked to.
* Correspondingly each line has a ring of nodes, with pointers to the
* mobjs that are linked to that particular line. This way it is possible
* that a single mobj is linked simultaneously to multiple lines (which
* is common).
*
* All these rings are maintained by P_(Un)LinkMobj().
*/
typedef struct linknode_s {
nodeindex_t prev, next;
void *ptr;
int data;
} linknode_t;
// State flags.
#define STF_FULLBRIGHT 0x00000001
#define STF_NOAUTOLIGHT 0x00000002 // Don't automatically add light if fullbright
// Doomsday mobj flags.
#define DDMF_DONTDRAW 0x00000001
#define DDMF_SHADOW 0x00000002
#define DDMF_ALTSHADOW 0x00000004
#define DDMF_BRIGHTSHADOW 0x00000008
#define DDMF_VIEWALIGN 0x00000010
#define DDMF_FITTOP 0x00000020 // Don't let the sprite go into the ceiling.
#define DDMF_NOFITBOTTOM 0x00000040
#define DDMF_LIGHTSCALE 0x00000180 // Light scale (0: full, 3: 1/4).
#define DDMF_LIGHTOFFSET 0x0000f000 // How to offset light (along Z axis)
#define DDMF_RESERVED 0x00030000 // don't touch these!! (translation class)
#define DDMF_BOB 0x00040000 // Bob the Z coord up and down.
#define DDMF_LOWGRAVITY 0x00080000 // 1/8th gravity (predict)
#define DDMF_MISSILE 0x00100000 // client removes mobj upon impact
#define DDMF_FLY 0x00200000 // flying object (doesn't matter if airborne)
#define DDMF_NOGRAVITY 0x00400000 // isn't affected by gravity (predict)
#define DDMF_ALWAYSLIT 0x00800000 // Always process DL even if hidden
#define DDMF_TRANSLATION 0x1c000000 // use a translation table (>>MF_TRANSHIFT)
#define DDMF_SOLID 0x20000000 // Solid on client side.
#define DDMF_LOCAL 0x40000000
#define DDMF_REMOTE 0x80000000 // This mobj is really on the server.
// Clear masks (flags the Game DLL is not allowed to touch).
#define DDMF_CLEAR_MASK 0xc0000000
#define DDMF_TRANSSHIFT 26 // table for player colormaps
#define DDMF_CLASSTRSHIFT 16
#define DDMF_LIGHTSCALESHIFT 7
#define DDMF_LIGHTOFFSETSHIFT 12
// The high byte of the selector is not used for modeldef selecting.
// 1110 0000 = alpha level (0: opaque => 7: transparent 7/8)
#define DDMOBJ_SELECTOR_MASK 0x00ffffff
#define DDMOBJ_SELECTOR_SHIFT 24
#define VISIBLE 1
#define INVISIBLE -1
enum { MX, MY, MZ }; // Momentum axis indices.
// Base mobj_t elements. Games MUST use this as the basis for mobj_t.
#define DD_BASE_MOBJ_ELEMENTS() \
thinker_t thinker; /* thinker node */ \
float pos[3]; /* position [x,y,z] */ \
\
struct mobj_s *bNext, *bPrev; /* links in blocks (if needed) */ \
nodeindex_t lineRoot; /* lines to which this is linked */ \
struct mobj_s *sNext, **sPrev; /* links in sector (if needed) */ \
\
struct subsector_s *subsector; /* subsector in which this resides */ \
float mom[3]; \
angle_t angle; \
spritenum_t sprite; /* used to find patch_t and \
* flip value */ \
int frame; /* might be ord with FF_FULLBRIGHT */ \
float radius; \
float height; \
int ddFlags; /* Doomsday mobj flags (DDMF_*) */ \
float floorClip; /* value to use for floor clipping */ \
int valid; /* if == valid, already checked */ \
int type; /* mobj type */ \
struct state_s *state; \
int tics; /* state tic counter */ \
float floorZ; /* highest contacted floor */ \
float ceilingZ; /* lowest contacted ceiling */ \
struct mobj_s* onMobj; /* the mobj this one is on top of. */ \
boolean wallHit; /* the mobj is hitting a wall. */ \
struct ddplayer_s *dPlayer; /* NULL if not a player mobj. */ \
float srvo[3]; /* short-range visual offset (xyz) */ \
short visAngle; /* visual angle ("angle-servo") */ \
int selector; /* multipurpose info */ \
int validCount; /* used in iterating */ \
unsigned int light; /* index+1 of the lumobj/bias source, or 0 */ \
byte haloFactor; /* strength of halo */ \
byte translucency; /* default = 0 = opaque */ \
short visTarget; /* -1 = mobj is becoming less visible, */ \
/* 0 = no change, 2= mobj is becoming more visible */ \
int reactionTime; /* if not zero, freeze controls */
typedef struct ddmobj_base_s {
DD_BASE_MOBJ_ELEMENTS()} ddmobj_base_t;
//------------------------------------------------------------------------
//
// Refresh
//
//------------------------------------------------------------------------
#define TICRATE 35 // number of tics / second
#define TICSPERSEC 35
#define SCREENWIDTH 320
#define SCREENHEIGHT 200
//------------------------------------------------------------------------
//
// Rendering
//
//------------------------------------------------------------------------
// Types.
typedef unsigned char DGLubyte;
typedef unsigned int DGLuint;
typedef struct gl_vertex_s {
float xyz[4]; // The fourth is padding.
} gl_vertex_t;
typedef struct gl_texcoord_s {
float st[2];
} gl_texcoord_t;
typedef struct gl_color_s {
byte rgba[4];
} gl_color_t;
typedef struct {
DGLubyte rgb[3];
} gl_rgb_t;
typedef struct {
DGLubyte rgba[4];
} gl_rgba_t;
// A 2-vertex with texture coordinates, using floats
typedef struct {
float pos[2];
float tex[2];
} gl_ft2vertex_t;
// A 3-vertex with texture coordinates, using floats
typedef struct {
float pos[3];
float tex[2];
} gl_ft3vertex_t;
// A 3-vertex with texture coordinates and a color, using floats
typedef struct {
float pos[3];
float tex[2];
float color[4];
} gl_fct3vertex_t;
// A colored 3-vertex, using floats
typedef struct {
float pos[3];
float color[4];
} gl_fc3vertex_t;
// GL texture formats:
typedef enum gltexformat_e {
DGL_RGB,
DGL_RGBA,
DGL_COLOR_INDEX_8,
DGL_COLOR_INDEX_8_PLUS_A8,
DGL_LUMINANCE,
DGL_DEPTH_COMPONENT,
DGL_LUMINANCE_PLUS_A8
} gltexformat_t;
typedef enum glprimtype_e {
DGL_LINES,
DGL_TRIANGLES,
DGL_TRIANGLE_FAN,
DGL_TRIANGLE_STRIP,
DGL_QUADS,
DGL_QUAD_STRIP,
DGL_POINTS
} glprimtype_t;
enum {
// Values
DGL_COLOR_BITS,
DGL_MAX_TEXTURE_SIZE,
DGL_SCISSOR_BOX,
DGL_POLY_COUNT,
DGL_TEXTURE_BINDING,
DGL_MAX_TEXTURE_UNITS,
DGL_ACTIVE_TEXTURE,
DGL_CURRENT_COLOR_R,
DGL_CURRENT_COLOR_G,
DGL_CURRENT_COLOR_B,
DGL_CURRENT_COLOR_A,
DGL_CURRENT_COLOR_RGBA,
// Matrices
DGL_MODELVIEW = 0x4000,
DGL_PROJECTION,
DGL_TEXTURE,
// Caps
DGL_TEXTURING = 0x5000,
DGL_SCISSOR_TEST = 0x5004,
DGL_FOG = 0x5008,
DGL_PALETTED_TEXTURES = 0x5009,
DGL_PALETTED_GENMIPS = 0x500B,
DGL_MODULATE_ADD_COMBINE = 0x500C,
DGL_MODULATE_TEXTURE = 0x500D,
DGL_TEXTURE_COMPRESSION = 0x500F,
DGL_VSYNC = 0x5011,
// Blending functions
DGL_ZERO = 0x6000,
DGL_ONE,
DGL_DST_COLOR,
DGL_ONE_MINUS_DST_COLOR,
DGL_DST_ALPHA,
DGL_ONE_MINUS_DST_ALPHA,
DGL_SRC_COLOR,
DGL_ONE_MINUS_SRC_COLOR,
DGL_SRC_ALPHA,
DGL_ONE_MINUS_SRC_ALPHA,
DGL_SRC_ALPHA_SATURATE,
DGL_ADD,
DGL_SUBTRACT,
DGL_REVERSE_SUBTRACT,
// Miscellaneous
DGL_MIN_FILTER = 0xF000,
DGL_MAG_FILTER,
DGL_ANISO_FILTER,
DGL_NEAREST,
DGL_LINEAR,
DGL_NEAREST_MIPMAP_NEAREST,
DGL_LINEAR_MIPMAP_NEAREST,
DGL_NEAREST_MIPMAP_LINEAR,
DGL_LINEAR_MIPMAP_LINEAR,
DGL_CLAMP,