1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010 EDuke32 developers and contributors
4 
5 This file is part of EDuke32.
6 
7 EDuke32 is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License version 2
9 as published by the Free Software Foundation.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 
15 See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 */
21 //-------------------------------------------------------------------------
22 
23 #ifndef EDUKE32_MACROS_H_
24 #define EDUKE32_MACROS_H_
25 
26 #include "mmulti.h"
27 
28 // Macros, some from SW source
29 
30 #define BGSTRETCH (ud.bgstretch ? 1024 : 0)
31 
32 #define WIN_IS_PRESSED ( KB_KeyPressed( sc_RightWin ) || KB_KeyPressed( sc_LeftWin ) )
33 #define ALT_IS_PRESSED ( KB_KeyPressed( sc_RightAlt ) || KB_KeyPressed( sc_LeftAlt ) )
34 #define SHIFTS_IS_PRESSED ( KB_KeyPressed( sc_RightShift ) || KB_KeyPressed( sc_LeftShift ) )
35 
36 #define TRAVERSE_SPRITE_SECT(l, o, n)    (o) = (l); ((o) != -1) && ((n) = nextspritesect[o]); (o) = (n)
37 #define TRAVERSE_SPRITE_STAT(l, o, n)    (o) = (l); ((o) != -1) && ((n) = nextspritestat[o]); (o) = (n)
38 #define TRAVERSE_CONNECT(i)              i = 0; i != -1; i = connectpoint2[i]
39 
40 #define TEST(flags,mask) ((flags) & (mask))
41 #define SET(flags,mask) ((flags) |= (mask))
42 #define RESET(flags,mask) ((flags) &= ~(mask))
43 #define FLIP(flags,mask) ((flags) ^= (mask))
44 
45 // mask definitions
46 
47 #define BIT(shift)     (1u<<(shift))
48 
49 // rotatesprite flags
50 #define ROTATE_SPRITE_TRANSLUCENT   (BIT(0))
51 #define ROTATE_SPRITE_VIEW_CLIP     (BIT(1)) // clip to view
52 #define ROTATE_SPRITE_YFLIP         (BIT(2))
53 #define ROTATE_SPRITE_IGNORE_START_MOST (BIT(3)) // don't clip to startumost
54 #define ROTATE_SPRITE_SCREEN_CLIP   (BIT(1)|BIT(3)) // use window
55 #define ROTATE_SPRITE_CORNER        (BIT(4)) // place sprite from upper left corner
56 #define ROTATE_SPRITE_TRANS_FLIP    (BIT(5))
57 #define ROTATE_SPRITE_NON_MASK      (BIT(6)) // non masked sprites
58 #define ROTATE_SPRITE_ALL_PAGES     (BIT(7)) // copies to all pages
59 
60 #define RS_SCALE                    BIT(16)
61 
62 // system defines for status bits
63 #define CEILING_STAT_PLAX           BIT(0)
64 #define CEILING_STAT_SLOPE          BIT(1)
65 #define CEILING_STAT_SWAPXY         BIT(2)
66 #define CEILING_STAT_SMOOSH         BIT(3)
67 #define CEILING_STAT_XFLIP          BIT(4)
68 #define CEILING_STAT_YFLIP          BIT(5)
69 #define CEILING_STAT_RELATIVE       BIT(6)
70 #define CEILING_STAT_TYPE_MASK     (BIT(7)|BIT(8))
71 #define CEILING_STAT_MASKED         BIT(7)
72 #define CEILING_STAT_TRANS          BIT(8)
73 #define CEILING_STAT_TRANS_FLIP     (BIT(7)|BIT(8))
74 #define CEILING_STAT_FAF_BLOCK_HITSCAN      BIT(15)
75 
76 #define FLOOR_STAT_PLAX           BIT(0)
77 #define FLOOR_STAT_SLOPE          BIT(1)
78 #define FLOOR_STAT_SWAPXY         BIT(2)
79 #define FLOOR_STAT_SMOOSH         BIT(3)
80 #define FLOOR_STAT_XFLIP          BIT(4)
81 #define FLOOR_STAT_YFLIP          BIT(5)
82 #define FLOOR_STAT_RELATIVE       BIT(6)
83 #define FLOOR_STAT_TYPE_MASK     (BIT(7)|BIT(8))
84 #define FLOOR_STAT_MASKED         BIT(7)
85 #define FLOOR_STAT_TRANS          BIT(8)
86 #define FLOOR_STAT_TRANS_FLIP     (BIT(7)|BIT(8))
87 #define FLOOR_STAT_FAF_BLOCK_HITSCAN      BIT(15)
88 
89 
90 //cstat, bit 0: 1 = Blocking sprite (use with clipmove, getzrange)    "B"
91 //       bit 1: 1 = 50/50 transluscence, 0 = normal                   "T"
92 //       bit 2: 1 = x-flipped, 0 = normal                             "F"
93 //       bit 3: 1 = y-flipped, 0 = normal                             "F"
94 //       bits 5-4: 00 = FACE sprite (default)                         "R"
95 //                 01 = WALL sprite (like masked walls)
96 //                 10 = FLOOR sprite (parallel to ceilings&floors)
97 //                 11 = SPIN sprite (face sprite that can spin 2draw style - not done yet)
98 //       bit 6: 1 = 1-sided sprite, 0 = normal                        "1"
99 //       bit 7: 1 = Real centered centering, 0 = foot center          "C"
100 //       bit 8: 1 = Blocking sprite (use with hitscan)                "H"
101 //       bit 9: reserved
102 //       bit 10: reserved
103 //       bit 11: 1 = determine shade based only on its own shade member (see CON's spritenoshade command), i.e.
104 //                   don't take over shade from parallaxed ceiling/nonparallaxed floor
105 //                   (NOTE: implemented on the game side)
106 //       bit 12: reserved
107 //       bit 13: reserved
108 //       bit 14: reserved
109 //       bit 15: 1 = Invisible sprite, 0 = not invisible
110 #define CSTAT_SPRITE_NOSHADE        BIT(11)
111 #define CSTAT_SPRITE_BREAKABLE (CSTAT_SPRITE_BLOCK_HITSCAN)
112 
113 #define SP(i)  sprite[i].yvel
114 #define SX(i)  sprite[i].x
115 #define SY(i)  sprite[i].y
116 #define SZ(i)  sprite[i].z
117 #define SS(i)  sprite[i].shade
118 #define PN(i)  sprite[i].picnum
119 #define SA(i)  sprite[i].ang
120 //#define SV  sprite[i].xvel
121 //#define ZV  sprite[i].zvel
122 //#define RX  sprite[i].xrepeat
123 //#define RY  sprite[i].yrepeat
124 #define OW(i)  sprite[i].owner
125 #define CS(i)  sprite[i].cstat
126 #define SH(i)  sprite[i].extra
127 //#define CX  sprite[i].xoffset
128 //#define CY  sprite[i].yoffset
129 //#define CD  sprite[i].clipdist
130 //#define PL  sprite[i].pal
131 #define SLT(i)  sprite[i].lotag
132 #define SHT(i)  sprite[i].hitag
133 #define SECT(i) sprite[i].sectnum
134 
135 #endif
136