added support for BD game engine to Makefile for Android
[rocksndiamonds.git] / src / tools.h
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // tools.h
10 // ============================================================================
11
12 #ifndef TOOLS_H
13 #define TOOLS_H
14
15 #include "main.h"
16 #include "game.h"
17
18
19 // for DrawElementShifted
20 #define NO_CUTTING                      0
21 #define CUT_ABOVE                       (1 << 0)
22 #define CUT_BELOW                       (1 << 1)
23 #define CUT_LEFT                        (1 << 2)
24 #define CUT_RIGHT                       (1 << 3)
25
26 // for masking functions
27 #define NO_MASKING                      0
28 #define USE_MASKING                     1
29  
30 // for MoveDoor
31 #define DOOR_OPEN_1                     (1 << 0)
32 #define DOOR_OPEN_2                     (1 << 1)
33 #define DOOR_CLOSE_1                    (1 << 2)
34 #define DOOR_CLOSE_2                    (1 << 3)
35 #define DOOR_OPEN_ALL                   (DOOR_OPEN_1 | DOOR_OPEN_2)
36 #define DOOR_CLOSE_ALL                  (DOOR_CLOSE_1 | DOOR_CLOSE_2)
37 #define DOOR_ACTION_1                   (DOOR_OPEN_1 | DOOR_CLOSE_1)
38 #define DOOR_ACTION_2                   (DOOR_OPEN_2 | DOOR_CLOSE_2)
39 #define DOOR_ACTION                     (DOOR_ACTION_1 | DOOR_ACTION_2)
40 #define DOOR_COPY_BACK                  (1 << 4)
41 #define DOOR_NO_COPY_BACK               (1 << 5)
42 #define DOOR_NO_DELAY                   (1 << 6)
43 #define DOOR_FORCE_ANIM                 (1 << 7)
44 #define DOOR_FORCE_REDRAW               (1 << 8)
45 #define DOOR_GET_STATE                  (1 << 9)
46 #define DOOR_SET_STATE                  (1 << 10)
47
48 #define DOOR_1                          (DOOR_ACTION_1)
49 #define DOOR_2                          (DOOR_ACTION_2)
50 #define DOOR_OPEN                       (DOOR_OPEN_ALL)
51 #define DOOR_CLOSE                      (DOOR_CLOSE_ALL)
52
53 #define DOOR_INDEX_FROM_TOKEN(x)        ((x) == DOOR_1 ? 0 : 1)
54 #define DOOR_TOKEN_FROM_INDEX(x)        ((x) == 0 ? DOOR_1 ? : DOOR_2)
55 #define REDRAW_DOOR_FROM_TOKEN(x)       ((x) == DOOR_1 ? REDRAW_DOOR_1 : REDRAW_DOOR_2)
56
57 // for Request
58 #define REQ_ASK                         (1 << 0)
59 #define REQ_CONFIRM                     (1 << 1)
60 #define REQ_PLAYER                      (1 << 2)
61 #define REQ_STAY_OPEN                   (1 << 3)
62 #define REQ_STAY_CLOSED                 (1 << 4)
63 #define REQ_REOPEN                      (1 << 5)
64
65
66 int getFieldbufferOffsetX_RND(int, int);
67 int getFieldbufferOffsetY_RND(int, int);
68
69 int getLevelFromScreenX(int);
70 int getLevelFromScreenY(int);
71
72 int getScreenFieldSizeX(void);
73 int getScreenFieldSizeY(void);
74
75 void DumpTile(int, int);
76 void DumpTileFromScreen(int, int);
77
78 void DrawMaskedBorder_FIELD(void);
79 void DrawMaskedBorder_DOOR_1(void);
80 void DrawMaskedBorder_DOOR_2(void);
81 void DrawMaskedBorder_DOOR_3(void);
82 void DrawMaskedBorder_ALL(void);
83 void DrawMaskedBorder(int);
84 void DrawMaskedBorderToTarget(int);
85 void DrawTileCursor(int, int);
86
87 void SetDrawtoField(int);
88 int GetDrawtoField(void);
89 void RedrawPlayfield(void);
90 void BlitScreenToBitmapExt_RND(Bitmap *, int, int);
91 void BlitScreenToBitmap_RND(Bitmap *);
92 void BlitScreenToBitmap(Bitmap *);
93 void BackToFront(void);
94 void BackToFront_WithFrameDelay(unsigned int);
95
96 void FadeIn(int);
97 void FadeOut(int);
98 void FadeSetEnterMenu(void);
99 void FadeSetLeaveMenu(void);
100 void FadeSetEnterScreen(void);
101 void FadeSetNextScreen(void);
102 void FadeSetLeaveScreen(void);
103 void FadeSetFromType(int);
104 void FadeSetDisabled(void);
105 void FadeSkipNextFadeIn(void);
106 void FadeSkipNextFadeOut(void);
107
108 int getImageFromGraphicOrDefault(int, int);
109 Bitmap *getGlobalBorderBitmapFromStatus(int);
110
111 void ClearField(void);
112
113 void SetBackgroundImage(int, int);
114 void SetWindowBackgroundImageIfDefined(int);
115 void SetMainBackgroundImageIfDefined(int);
116 void SetDoorBackgroundImageIfDefined(int);
117 void SetWindowBackgroundImage(int);
118 void SetMainBackgroundImage(int);
119 void SetDoorBackgroundImage(int);
120 void SetPanelBackground(void);
121 void DrawBackground(int, int, int, int);
122 void DrawBackgroundForFont(int, int, int, int, int);
123 void DrawBackgroundForGraphic(int, int, int, int, int);
124 boolean CheckIfGlobalBorderHasChanged(void);
125 void RedrawGlobalBorder(void);
126
127 void MarkTileDirty(int, int);
128 void SetBorderElement(void);
129 void FloodFillLevel(int, int, int, short[MAX_LEV_FIELDX][MAX_LEV_FIELDY], int, int);
130 void FloodFillLevelExt(int, int, int, int x, int y, short field[x][y], int, int);
131
132 void SetRandomAnimationValue(int, int);
133 void SetAnimationFirstLevel(int);
134 int getGraphicAnimationFrame(int, int);
135 int getGraphicAnimationFrameXY(int, int, int);
136
137 void DrawFixedGraphicAnimation(int, int, int);
138 void DrawFixedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int);
139 void DrawSizedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int, int);
140
141 void DrawLevelGraphicAnimation(int, int, int);
142 void DrawLevelElementAnimation(int, int, int);
143 void DrawLevelGraphicAnimationIfNeeded(int, int, int);
144 void DrawLevelElementAnimationIfNeeded(int, int, int);
145
146 void DrawAllPlayers(void);
147 void DrawPlayerField(int, int);
148 void DrawPlayer(struct PlayerInfo *);
149
150 void getGraphicSourceBitmap(int, int, Bitmap **);
151 void getGraphicSourceXY(int, int, int *, int *, boolean);
152 void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean);
153 void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *);
154 void getFixedGraphicSource(int, int, Bitmap **, int *, int *);
155 void getMiniGraphicSource(int, Bitmap **, int *, int *);
156 void getGlobalAnimGraphicSource(int, int, Bitmap **, int *, int *);
157 void getGraphicSource(int, int, Bitmap **, int *, int *);
158
159 void DrawGraphic(int, int, int, int);
160 void DrawGraphicExt(DrawBuffer *, int, int, int, int);
161 void DrawGraphicThruMask(int, int, int, int);
162 void DrawGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
163
164 void DrawFixedGraphic(int, int, int, int);
165 void DrawFixedGraphicExt(DrawBuffer *, int, int, int, int);
166 void DrawFixedGraphicThruMask(int, int, int, int);
167 void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
168
169 void DrawSizedGraphic(int, int, int, int, int);
170 void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int);
171 void DrawSizedGraphicThruMask(int, int, int, int, int);
172 void DrawSizedGraphicThruMaskExt(DrawBuffer *, int, int, int, int, int);
173
174 void DrawMiniGraphic(int, int, int);
175 void DrawMiniGraphicExt(DrawBuffer *, int, int, int);
176
177 void DrawScreenElementExt(int, int, int, int, int, int, int);
178 void DrawLevelElementExt(int, int, int, int, int, int, int);
179 void DrawScreenElementShifted(int, int, int, int, int, int);
180 void DrawLevelElementShifted(int, int, int, int, int, int);
181 void DrawScreenElementThruMask(int, int, int);
182 void DrawLevelElementThruMask(int, int, int);
183 void DrawLevelFieldThruMask(int, int);
184 void DrawLevelFieldCrumbled(int, int);
185 void DrawLevelFieldCrumbledDigging(int, int, int, int);
186 void DrawLevelFieldCrumbledNeighbours(int, int);
187 void DrawScreenGraphic(int, int, int, int);
188 void DrawLevelGraphic(int, int, int, int);
189 void DrawScreenElement(int, int, int);
190 void DrawLevelElement(int, int, int);
191 void DrawScreenField(int, int);
192 void DrawLevelField(int, int);
193
194 void DrawSizedWallParts_MM(int, int, int, int, boolean, int);
195 void DrawSizedElement(int, int, int, int);
196 void DrawSizedElementThruMask(int, int, int, int);
197 void DrawSizedElementOrWall(int, int, int, int, int);
198
199 void DrawMiniElement(int, int, int);
200 void DrawMiniElementOrWall(int, int, int, int);
201
202 void ShowEnvelope(int);
203 void ShowEnvelopeDoor(char *, int);
204 void DrawEnvelopeRequestToScreen(int);
205
206 void DrawLevel(int);
207 void DrawSizedLevel(int, int, int, int, int);
208 void DrawMiniLevel(int, int, int, int);
209 void DrawPreviewPlayers(void);
210 void DrawPreviewLevelInitial(void);
211 void DrawPreviewLevelAnimation(void);
212
213 void DrawNetworkPlayers(void);
214 void ClearNetworkPlayers(void);
215
216 void WaitForEventToContinue(void);
217 int Request(char *, unsigned int);
218 void InitGraphicCompatibilityInfo_Doors(void);
219 void InitDoors(void);
220 unsigned int OpenDoor(unsigned int);
221 unsigned int CloseDoor(unsigned int);
222 unsigned int GetDoorState(void);
223 unsigned int SetDoorState(unsigned int);
224 unsigned int MoveDoor(unsigned int);
225
226 void DrawSpecialEditorDoor(void);
227 void UndrawSpecialEditorDoor(void);
228
229 void CreateToolButtons(void);
230 void FreeToolButtons(void);
231
232 int getEngineElement(int);
233 int getDrawingElement(int);
234
235 int map_element_RND_to_BD_cave(int);
236 int map_element_RND_to_BD_effect(int, int);
237 int map_element_BD_to_RND_cave(int);
238 int map_element_BD_to_RND_game(int);
239
240 int map_element_RND_to_EM_cave(int);
241 int map_element_EM_to_RND_cave(int);
242 int map_element_EM_to_RND_game(int);
243 int map_direction_RND_to_EM(int);
244 int map_direction_EM_to_RND(int);
245
246 void map_android_clone_elements_RND_to_EM(struct LevelInfo *);
247 void map_android_clone_elements_EM_to_RND(struct LevelInfo *);
248
249 int map_element_RND_to_SP(int);
250 int map_element_SP_to_RND(int);
251 int map_action_SP_to_RND(int);
252
253 int map_element_RND_to_MM(int);
254 int map_element_MM_to_RND(int);
255 int map_action_MM_to_RND(int);
256 int map_sound_MM_to_RND(int);
257 int map_mm_wall_element(int);
258 int map_mm_wall_element_editor(int);
259
260 int get_next_element(int);
261 int el_act_dir2img(int, int, int);
262 int el_act2img(int, int);
263 int el_dir2img(int, int);
264 int el2baseimg(int);
265 int el2img(int);
266 int el2edimg(int);
267 int el2edimg_with_frame(int, int *, int *);
268 int el2preimg(int);
269 int el2panelimg(int);
270 int font2baseimg(int);
271
272 int getBeltNrFromBeltElement(int);
273 int getBeltNrFromBeltActiveElement(int);
274 int getBeltNrFromBeltSwitchElement(int);
275 int getBeltDirNrFromBeltElement(int);
276 int getBeltDirNrFromBeltSwitchElement(int);
277 int getBeltDirFromBeltElement(int);
278 int getBeltDirFromBeltSwitchElement(int);
279 int getBeltElementFromBeltNrAndBeltDirNr(int, int);
280 int getBeltElementFromBeltNrAndBeltDir(int, int);
281 int getBeltSwitchElementFromBeltNrAndBeltDirNr(int, int);
282 int getBeltSwitchElementFromBeltNrAndBeltDir(int, int);
283
284 unsigned int InitRND(int);
285
286 void InitGraphicInfo_BD(void);
287 void InitGraphicInfo_EM(void);
288
289 void PlayMenuSoundExt(int);
290 void PlayMenuSound(void);
291 void PlayMenuSoundStereo(int, int);
292 void PlayMenuSoundIfLoopExt(int);
293 void PlayMenuSoundIfLoop(void);
294 void PlayMenuMusicExt(int);
295 void PlayMenuMusic(void);
296 void PlayMenuSoundsAndMusic(void);
297 void FadeMenuSoundsAndMusic(void);
298 void PlaySoundActivating(void);
299 void PlaySoundSelecting(void);
300
301 void SetAnimStatus(int);
302 void SetGameStatus(int);
303 void SetFontStatus(int);
304 void ResetFontStatus(void);
305
306 void SetLevelSetInfo(char *, int);
307
308 void ToggleAudioSampleRateIfNeeded(void);
309 void ToggleFullscreenIfNeeded(void);
310 void ChangeWindowScalingIfNeeded(void);
311 void ChangeVsyncModeIfNeeded(void);
312 void ChangeViewportPropertiesIfNeeded(void);
313
314 boolean CheckIfAllViewportsHaveChanged(void);
315 boolean CheckFadeAll(void);
316
317 void OpenURL(char *);
318 void OpenURLFromHash(SetupFileHash *, int);
319
320 void TestGeneratingUUIDs(void);
321
322 #endif  // TOOLS_H