fixed indentation
[rocksndiamonds.git] / src / game_sp / Globals.h
1 // ----------------------------------------------------------------------------
2 // Globals.h
3 // ----------------------------------------------------------------------------
4
5 #ifndef GLOBALS_H
6 #define GLOBALS_H
7
8 #include "global.h"
9
10
11 #ifndef False
12 #define False                           0
13 #define True                            (!False)
14 #endif
15
16 #define ScrollDelta                     ((int)1)
17
18 #define ZoomFactor                      (2)
19
20 #define StretchWidth                    (ZoomFactor * 16)
21 #define TwoPixels                       (ZoomFactor * 2)
22
23
24 // ----------------------------------------------------------------------------
25 // elements (stored in file and playfield)
26 // ----------------------------------------------------------------------------
27
28 #define fiSpace                         (0)
29 #define fiZonk                          (1)
30 #define fiBase                          (2)
31 #define fiMurphy                        (3)
32 #define fiInfotron                      (4)
33 #define fiRAM                           (5)
34 #define fiHardWare                      (6)
35 #define fiExit                          (7)
36 #define fiOrangeDisk                    (8)
37 #define fiPortRight                     (9)
38 #define fiPortDown                      (10)
39 #define fiPortLeft                      (11)
40 #define fiPortUp                        (12)
41 #define fiSpPortRight                   (13)
42 #define fiSpPortDown                    (14)
43 #define fiSpPortLeft                    (15)
44 #define fiSpPortUp                      (16)
45 #define fiSnikSnak                      (17)
46 #define fiYellowDisk                    (18)
47 #define fiTerminal                      (19)
48 #define fiRedDisk                       (20)
49 #define fiPortUpAndDown                 (21)
50 #define fiPortLeftAndRight              (22)
51 #define fiPortAllDirections             (23)
52 #define fiElectron                      (24)
53 #define fiBug                           (25)
54 #define fiRAMLeft                       (26)
55 #define fiRAMRight                      (27)
56 #define fiHWFirst                       (28)
57 #define fiHW0                           (fiHWFirst + 0)         // fiHWFirst
58 #define fiHW1                           (fiHWFirst + 1)
59 #define fiHW2                           (fiHWFirst + 2)
60 #define fiHW3                           (fiHWFirst + 3)
61 #define fiHW4                           (fiHWFirst + 4)
62 #define fiHW5                           (fiHWFirst + 5)
63 #define fiHW6                           (fiHWFirst + 6)
64 #define fiHW7                           (fiHWFirst + 7)
65 #define fiHW8                           (fiHWFirst + 8)
66 #define fiHW9                           (fiHWFirst + 9)         // fiHWLast
67 #define fiHWLast                        (37)
68 #define fiRAMTop                        (38)
69 #define fiRAMBottom                     (39)
70 #define fiWallSpace                     (40)
71
72 #define fiExplosion                     (0x1F)
73
74 #define fiFirst                         (0)
75 #define fiLast                          (40)
76
77
78 // ----------------------------------------------------------------------------
79 // graphics and animations (used at runtime to display the elements)
80 // ----------------------------------------------------------------------------
81
82 // graphics and animations directly related to file elements
83
84 #define aniSpace                        IMG_EMPTY_SPACE
85 #define aniZonk                         IMG_SP_ZONK
86 #define aniBase                         IMG_SP_BASE
87 #define aniMurphy                       IMG_SP_MURPHY
88 #define aniInfotron                     IMG_SP_INFOTRON
89 #define aniRAM                          IMG_SP_CHIP_SINGLE
90 #define aniHardWare                     IMG_SP_HARDWARE_GRAY
91 #define aniExit                         IMG_SP_EXIT_CLOSED
92 #define aniOrangeDisk                   IMG_SP_DISK_ORANGE
93 #define aniPortRight                    IMG_SP_PORT_RIGHT
94 #define aniPortDown                     IMG_SP_PORT_DOWN
95 #define aniPortLeft                     IMG_SP_PORT_LEFT
96 #define aniPortUp                       IMG_SP_PORT_UP
97 #define aniSpPortRight                  IMG_SP_GRAVITY_PORT_RIGHT
98 #define aniSpPortDown                   IMG_SP_GRAVITY_PORT_DOWN
99 #define aniSpPortLeft                   IMG_SP_GRAVITY_PORT_LEFT
100 #define aniSpPortUp                     IMG_SP_GRAVITY_PORT_UP
101 #define aniSnikSnak                     IMG_SP_SNIKSNAK
102 #define aniYellowDisk                   IMG_SP_DISK_YELLOW
103 #define aniTerminal                     IMG_SP_TERMINAL
104 #define aniRedDisk                      IMG_SP_DISK_RED
105 #define aniPortUpAndDown                IMG_SP_PORT_VERTICAL
106 #define aniPortLeftAndRight             IMG_SP_PORT_HORIZONTAL
107 #define aniPortAllDirections            IMG_SP_PORT_ANY
108 #define aniElectron                     IMG_SP_ELECTRON
109 #define aniBug                          IMG_SP_BUGGY_BASE
110 #define aniRAMLeft                      IMG_SP_CHIP_LEFT
111 #define aniRAMRight                     IMG_SP_CHIP_RIGHT
112 #define aniHWFirst                      IMG_SP_HARDWARE_BASE_1
113 #define aniHW0                          IMG_SP_HARDWARE_BASE_1
114 #define aniHW1                          IMG_SP_HARDWARE_GREEN
115 #define aniHW2                          IMG_SP_HARDWARE_BLUE
116 #define aniHW3                          IMG_SP_HARDWARE_RED
117 #define aniHW4                          IMG_SP_HARDWARE_YELLOW
118 #define aniHW5                          IMG_SP_HARDWARE_BASE_2
119 #define aniHW6                          IMG_SP_HARDWARE_BASE_3
120 #define aniHW7                          IMG_SP_HARDWARE_BASE_4
121 #define aniHW8                          IMG_SP_HARDWARE_BASE_5
122 #define aniHW9                          IMG_SP_HARDWARE_BASE_6
123 #define aniHWLast                       IMG_SP_HARDWARE_BASE_6
124 #define aniRAMTop                       IMG_SP_CHIP_TOP
125 #define aniRAMBottom                    IMG_SP_CHIP_BOTTOM
126 #define aniWallSpace                    IMG_INVISIBLE_WALL
127 #define aniHWTrash1                     
128 #define aniHWTrash2                     
129 #define aniHWMurphy                     
130
131
132 // graphics and animations related to in-game animations for element actions
133
134 #define aniMurphyDropping               IMG_SP_MURPHY_DROPPING
135
136 #define aniMurphySleepLeft              IMG_SP_MURPHY_SLEEPING_LEFT
137 #define aniMurphySleepRight             IMG_SP_MURPHY_SLEEPING_RIGHT
138 #define aniMurphyTouchLeft              IMG_SP_MURPHY_SNAPPING_LEFT
139 #define aniMurphyTouchRight             IMG_SP_MURPHY_SNAPPING_RIGHT
140 #define aniMurphyTouchUp                IMG_SP_MURPHY_SNAPPING_UP
141 #define aniMurphyTouchDown              IMG_SP_MURPHY_SNAPPING_DOWN
142 #define aniMurphyYawn                   IMG_SP_MURPHY_BORING_1
143 #define aniPushLeft                     IMG_SP_MURPHY_PUSHING_LEFT
144 #define aniPushRight                    IMG_SP_MURPHY_PUSHING_RIGHT
145
146 #define aniBugActivating                IMG_SP_BUGGY_BASE_ACTIVATING
147 #define aniBugDeactivating              IMG_SP_BUGGY_BASE_ACTIVATING
148 #define aniBugActive                    IMG_SP_BUGGY_BASE_ACTIVE
149 #define aniZonkRollLeft                 IMG_SP_ZONK_MOVING_LEFT
150 #define aniZonkRollRight                IMG_SP_ZONK_MOVING_RIGHT
151 #define aniEatInfotronLeft              IMG_SP_MURPHY_COLLECTING_LEFT
152 #define aniEatInfotronRight             IMG_SP_MURPHY_COLLECTING_RIGHT
153 #define aniInfotronRollLeft             IMG_SP_INFOTRON_MOVING_LEFT
154 #define aniInfotronRollRight            IMG_SP_INFOTRON_MOVING_RIGHT
155 #define aniMurphyMoveLeft               IMG_SP_MURPHY_MOVING_LEFT
156 #define aniMurphyMoveRight              IMG_SP_MURPHY_MOVING_RIGHT
157 #define aniMurphyMoveUpLeft             IMG_SP_MURPHY_MOVING_LEFT
158 #define aniMurphyMoveUpRight            IMG_SP_MURPHY_MOVING_RIGHT
159 #define aniMurphyDigLeft                IMG_SP_MURPHY_DIGGING_LEFT
160 #define aniMurphyDigRight               IMG_SP_MURPHY_DIGGING_RIGHT
161 #define aniMurphyDigUpLeft              IMG_SP_MURPHY_DIGGING_LEFT
162 #define aniMurphyDigUpRight             IMG_SP_MURPHY_DIGGING_RIGHT
163 #define aniMurphyEatLeft                IMG_SP_MURPHY_COLLECTING_LEFT
164 #define aniMurphyEatRight               IMG_SP_MURPHY_COLLECTING_RIGHT
165 #define aniMurphyEatUpLeft              IMG_SP_MURPHY_COLLECTING_LEFT
166 #define aniMurphyEatUpRight             IMG_SP_MURPHY_COLLECTING_RIGHT
167 #define aniSplitUpDown                  IMG_SP_MURPHY
168 #define aniMurphyExit                   IMG_SP_MURPHY_SHRINKING
169 #define aniElectron                     IMG_SP_ELECTRON
170 #define aniExplosion                    IMG_SP_DEFAULT_EXPLODING
171 #define aniTouchBase                    IMG_SP_BASE_SNAPPING
172 #define aniTouchInfotron                IMG_SP_INFOTRON_COLLECTING
173 #define aniTouchRedDisk                 IMG_SP_DISK_RED_COLLECTING
174 #define aniYellowDisk                   IMG_SP_DISK_YELLOW
175 #define aniOrangeDisk                   IMG_SP_DISK_ORANGE
176 #define aniRedDisk                      IMG_SP_DISK_RED
177
178 #define aniSnikSnakDown                 IMG_SP_SNIKSNAK_DOWN
179 #define aniSnikSnakLeft                 IMG_SP_SNIKSNAK_LEFT
180 #define aniSnikSnakRight                IMG_SP_SNIKSNAK_RIGHT
181 #define aniSnikSnakUp                   IMG_SP_SNIKSNAK_UP
182
183 #define aniSnikSnakTurnLeftToUp         IMG_SP_SNIKSNAK_TURNING_FROM_LEFT_UP
184 #define aniSnikSnakTurnLeftToDown       IMG_SP_SNIKSNAK_TURNING_FROM_LEFT_DOWN
185 #define aniSnikSnakTurnRightToUp        IMG_SP_SNIKSNAK_TURNING_FROM_RIGHT_UP
186 #define aniSnikSnakTurnRightToDown      IMG_SP_SNIKSNAK_TURNING_FROM_RIGHT_DOWN
187 #define aniSnikSnakTurnUpToLeft         IMG_SP_SNIKSNAK_TURNING_FROM_UP_LEFT
188 #define aniSnikSnakTurnUpToRight        IMG_SP_SNIKSNAK_TURNING_FROM_UP_RIGHT
189 #define aniSnikSnakTurnDownToLeft       IMG_SP_SNIKSNAK_TURNING_FROM_DOWN_LEFT
190 #define aniSnikSnakTurnDownToRight      IMG_SP_SNIKSNAK_TURNING_FROM_DOWN_RIGHT
191
192 #define aniTerminalActive               IMG_SP_TERMINAL_ACTIVE
193
194 #define aniDefaultExplosion             IMG_SP_DEFAULT_EXPLODING
195 #define aniElectronExplosion            IMG_SP_ELECTRON_EXPLODING
196
197 #define imgFrameCorner                  IMG_SP_FRAME_CORNER
198 #define imgFrameHorizontal              IMG_SP_FRAME_HORIZONTAL
199 #define imgFrameVertical                IMG_SP_FRAME_VERTICAL
200
201
202 // ----------------------------------------------------------------------------
203 // input keys
204 // ----------------------------------------------------------------------------
205
206 #define keyNone                         (0)
207 #define keyUp                           (1)
208 #define keyLeft                         (2)
209 #define keyDown                         (3)
210 #define keyRight                        (4)
211 #define keySpaceUp                      (5)
212 #define keySpaceLeft                    (6)
213 #define keySpaceDown                    (7)
214 #define keySpaceRight                   (8)
215 #define keySpace                        (9)
216
217
218 // ----------------------------------------------------------------------------
219 // data structures
220 // ----------------------------------------------------------------------------
221
222 #ifndef HAS_LevelDescriptor
223 typedef struct
224 {
225   int Width;
226   int Height;
227   int OffSet;
228   int Size;
229 } LevelDescriptor;
230 #define HAS_LevelDescriptor
231 #endif
232
233 #ifndef HAS_SpecialPortType
234 typedef struct
235 {
236   short PortLocation; // = 2*(x+(y*60))
237   byte Gravity; // 1 = turn on, anything else (0) = turn off
238   byte FreezeZonks; // 2 = turn on, anything else (0) = turn off  (1=off!)
239   byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off
240   byte UnUsed;
241 } SpecialPortType;
242 #define HAS_SpecialPortType
243 #endif
244
245 #ifndef HAS_LevelInfoType
246 typedef struct
247 {
248   byte UnUsed[4];
249   byte InitialGravity; // 1=on, anything else (0) = off
250   byte Version; // SpeedFixVersion XOR &H20
251   char LevelTitle[23];
252   byte InitialFreezeZonks; // 2=on, anything else (0) = off.  (1=off too!)
253   byte InfotronsNeeded;
254
255   // Number of Infotrons needed. 0 means that Supaplex will count the total
256   // amount of Infotrons in the level, and use the low byte of that number.
257   // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!)
258   byte SpecialPortCount; // Maximum 10 allowed!
259   SpecialPortType SpecialPort[10];
260   byte SpeedByte; // = Speed XOR Highbyte(RandomSeed)
261   byte CheckSumByte; // = CheckSum XOR SpeedByte
262   short DemoRandomSeed;
263 } LevelInfoType;
264 #define HAS_LevelInfoType
265 #endif
266
267
268 extern int GetSI(int X, int Y);
269 extern int GetStretchX(int si);
270 extern int GetStretchY(int si);
271 extern int GetX(int si);
272 extern int GetY(int si);
273 extern void InitGlobals();
274
275 extern void PrepareLevel();
276
277 extern int getSequenceLength(int sequence);
278 extern boolean isSnappingSequence(int sequence);
279
280 extern int Min(int A, int B);
281 extern int Max(int A, int B);
282
283 extern int fiGraphic[];
284 extern int aniSnikSnakTurningLeft[];
285 extern int aniSnikSnakTurningRight[];
286
287 extern boolean LevelLoaded;
288
289 extern boolean DemoAvailable;
290 extern boolean menBorder;
291
292 extern int *PlayField16;
293 extern byte *PlayField8;
294 extern byte DisPlayField[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
295
296 extern int FieldHeight;
297 extern int FieldMax, LevelMax;
298 extern int FieldWidth;
299 extern int FreezeZonks;
300 extern int HeaderSize;
301 extern int TimerVar;
302 extern short RandomSeed;
303
304 extern LevelInfoType LInfo;
305 extern int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY;
306 extern int ScrollX, ScrollY;
307
308 extern int AllowRedDiskCheat, AllowEatRightRedDiskBug;
309 extern int Data_SubRest, Data_SubRstFlg;
310 extern int DemoKeyCode;
311 extern int GameBusyFlag;
312 extern int InfotronsNeeded, TotalInfotronsNeeded;
313 extern int KillMurphyFlag, MurphyMoveCounter;
314 extern int MurphyExplodePos, SplitMoveFlag, RedDiskReleaseMurphyPos;
315 extern int MurphyPosIndex, MurphyXPos, MurphyYPos;
316 extern int MurphyScreenXPos, MurphyScreenYPos;
317 extern int MurphyVarFaceLeft;
318 extern int RedDiskCount;
319 extern int RedDiskReleaseFlag, MovingPictureSequencePhase;
320 extern int RedDiskReleasePhase;
321 extern int ScratchGravity, GravityFlag;
322 extern int SnikSnaksElectronsFrozen;
323 extern int YellowDisksExploded;
324 extern int YawnSleepCounter;
325
326 #endif /* GLOBALS_H */