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