prepared some tool functions for the following commit
[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 //                  http://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 : \
56                                          REDRAW_DOOR_2)
57
58 // for Request
59 #define REQ_ASK                 (1 << 0)
60 #define REQ_CONFIRM             (1 << 1)
61 #define REQ_PLAYER              (1 << 2)
62 #define REQ_STAY_OPEN           (1 << 3)
63 #define REQ_STAY_CLOSED         (1 << 4)
64 #define REQ_REOPEN              (1 << 5)
65
66 #define REQUEST_WAIT_FOR_INPUT  (REQ_ASK | REQ_CONFIRM | REQ_PLAYER)
67
68
69 int getFieldbufferOffsetX_RND(int, int);
70 int getFieldbufferOffsetY_RND(int, int);
71
72 int correctLevelPosX_EM(int);
73 int correctLevelPosY_EM(int);
74
75 int getLevelFromScreenX(int);
76 int getLevelFromScreenY(int);
77
78 void DumpTile(int, int);
79 void DumpTileFromScreen(int, int);
80
81 void DrawMaskedBorder_FIELD(void);
82 void DrawMaskedBorder_DOOR_1(void);
83 void DrawMaskedBorder_DOOR_2(void);
84 void DrawMaskedBorder_DOOR_3(void);
85 void DrawMaskedBorder_ALL(void);
86 void DrawMaskedBorder(int);
87 void DrawMaskedBorderToTarget(int);
88 void DrawTileCursor(int);
89
90 void SetDrawtoField(int);
91 void RedrawPlayfield(void);
92 void BlitScreenToBitmapExt_RND(Bitmap *, int, int);
93 void BlitScreenToBitmap_RND(Bitmap *);
94 void BlitScreenToBitmap(Bitmap *);
95 void BackToFront(void);
96 void BackToFront_WithFrameDelay(unsigned int);
97
98 void FadeIn(int);
99 void FadeOut(int);
100 void FadeSetEnterMenu(void);
101 void FadeSetLeaveMenu(void);
102 void FadeSetEnterScreen(void);
103 void FadeSetNextScreen(void);
104 void FadeSetLeaveScreen(void);
105 void FadeSetFromType(int);
106 void FadeSetDisabled(void);
107 void FadeSkipNextFadeIn(void);
108 void FadeSkipNextFadeOut(void);
109
110 Bitmap *getGlobalBorderBitmapFromStatus(int);
111
112 void ClearField(void);
113 void SetWindowBackgroundImageIfDefined(int);
114 void SetMainBackgroundImageIfDefined(int);
115 void SetDoorBackgroundImageIfDefined(int);
116 void SetWindowBackgroundImage(int);
117 void SetMainBackgroundImage(int);
118 void SetDoorBackgroundImage(int);
119 void SetPanelBackground(void);
120 void DrawBackground(int, int, int, int);
121 void DrawBackgroundForFont(int, int, int, int, int);
122 void DrawBackgroundForGraphic(int, int, int, int, int);
123 boolean CheckIfGlobalBorderHasChanged(void);
124 void RedrawGlobalBorder(void);
125
126 void MarkTileDirty(int, int);
127 void SetBorderElement(void);
128 void FloodFillLevel(int, int, int, short[][MAX_LEV_FIELDY], int, int);
129 void FloodFillLevelExt(int, int, int, int, int y, short field[][y], int, int);
130
131 void SetRandomAnimationValue(int, int);
132 int getGraphicAnimationFrame(int, int);
133
134 void DrawFixedGraphicAnimation(int, int, int);
135 void DrawFixedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int);
136
137 void DrawLevelGraphicAnimation(int, int, int);
138 void DrawLevelElementAnimation(int, int, int);
139 void DrawLevelGraphicAnimationIfNeeded(int, int, int);
140 void DrawLevelElementAnimationIfNeeded(int, int, int);
141
142 void DrawAllPlayers(void);
143 void DrawPlayerField(int, int);
144 void DrawPlayer(struct PlayerInfo *);
145
146 void getGraphicSourceBitmap(int, int, Bitmap **);
147 void getGraphicSourceXY(int, int, int *, int *, boolean);
148 void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean);
149 void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *);
150 void getFixedGraphicSource(int, int, Bitmap **, int *, int *);
151 void getMiniGraphicSource(int, Bitmap **, int *, int *);
152 void getGraphicSource(int, int, Bitmap **, int *, int *);
153
154 void DrawGraphic(int, int, int, int);
155 void DrawGraphicExt(DrawBuffer *, int, int, int, int);
156 void DrawGraphicThruMask(int, int, int, int);
157 void DrawGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
158
159 void DrawFixedGraphic(int, int, int, int);
160 void DrawFixedGraphicExt(DrawBuffer *, int, int, int, int);
161 void DrawFixedGraphicThruMask(int, int, int, int);
162 void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
163
164 void DrawSizedGraphic(int, int, int, int, int);
165 void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int);
166 void DrawSizedGraphicThruMask(int, int, int, int, int);
167 void DrawSizedGraphicThruMaskExt(DrawBuffer *, int, int, int, int, int);
168
169 void DrawMiniGraphic(int, int, int);
170 void DrawMiniGraphicExt(DrawBuffer *, int, int, int);
171
172 void DrawScreenElementExt(int, int, int, int, int, int, int);
173 void DrawLevelElementExt(int, int, int, int, int, int, int);
174 void DrawScreenElementShifted(int, int, int, int, int, int);
175 void DrawLevelElementShifted(int, int, int, int, int, int);
176 void DrawScreenElementThruMask(int, int, int);
177 void DrawLevelElementThruMask(int, int, int);
178 void DrawLevelFieldThruMask(int, int);
179 void DrawLevelFieldCrumbled(int, int);
180 void DrawLevelFieldCrumbledDigging(int, int, int, int);
181 void DrawLevelFieldCrumbledNeighbours(int, int);
182 void DrawScreenElement(int, int, int);
183 void DrawLevelElement(int, int, int);
184 void DrawScreenField(int, int);
185 void DrawLevelField(int, int);
186
187 void DrawSizedWallParts_MM(int, int, int, int, boolean, int);
188 void DrawSizedElement(int, int, int, int);
189 void DrawSizedElementThruMask(int, int, int, int);
190 void DrawSizedElementOrWall(int, int, int, int, int);
191
192 void DrawMiniElement(int, int, int);
193 void DrawMiniElementOrWall(int, int, int, int);
194
195 void ShowEnvelope(int);
196 void ShowEnvelopeDoor(char *text, int);
197
198 void DrawLevel(int);
199 void DrawSizedLevel(int, int, int, int, int);
200 void DrawMiniLevel(int, int, int, int);
201 void DrawPreviewPlayers(void);
202 void DrawPreviewLevelInitial(void);
203 void DrawPreviewLevelAnimation(void);
204
205 void DrawNetworkPlayers(void);
206 void ClearNetworkPlayers(void);
207
208 void WaitForEventToContinue(void);
209 boolean Request(char *, unsigned int);
210 void InitGraphicCompatibilityInfo_Doors(void);
211 void InitDoors(void);
212 unsigned int OpenDoor(unsigned int);
213 unsigned int CloseDoor(unsigned int);
214 unsigned int GetDoorState(void);
215 unsigned int SetDoorState(unsigned int);
216 unsigned int MoveDoor(unsigned int);
217
218 void DrawSpecialEditorDoor(void);
219 void UndrawSpecialEditorDoor(void);
220
221 void CreateToolButtons(void);
222 void FreeToolButtons(void);
223
224 int map_element_RND_to_EM(int);
225 int map_element_EM_to_RND(int);
226 int map_direction_RND_to_EM(int);
227 int map_direction_EM_to_RND(int);
228
229 void map_android_clone_elements_RND_to_EM(struct LevelInfo *);
230 void map_android_clone_elements_EM_to_RND(struct LevelInfo *);
231
232 int map_element_RND_to_SP(int);
233 int map_element_SP_to_RND(int);
234 int map_action_SP_to_RND(int);
235
236 int map_element_RND_to_MM(int);
237 int map_element_MM_to_RND(int);
238 int map_action_MM_to_RND(int);
239 int map_sound_MM_to_RND(int);
240 int map_mm_wall_element(int);
241 int map_mm_wall_element_editor(int);
242
243 int get_next_element(int);
244 int el_act_dir2img(int, int, int);
245 int el_act2img(int, int);
246 int el_dir2img(int, int);
247 int el2baseimg(int);
248 int el2img(int);
249 int el2edimg(int);
250 int el2preimg(int);
251 int el2panelimg(int);
252 int font2baseimg(int);
253
254 int getBeltNrFromBeltElement(int);
255 int getBeltNrFromBeltActiveElement(int);
256 int getBeltNrFromBeltSwitchElement(int);
257 int getBeltDirNrFromBeltElement(int);
258 int getBeltDirNrFromBeltSwitchElement(int);
259 int getBeltDirFromBeltElement(int);
260 int getBeltDirFromBeltSwitchElement(int);
261 int getBeltElementFromBeltNrAndBeltDirNr(int, int);
262 int getBeltElementFromBeltNrAndBeltDir(int, int);
263 int getBeltSwitchElementFromBeltNrAndBeltDirNr(int, int);
264 int getBeltSwitchElementFromBeltNrAndBeltDir(int, int);
265
266 unsigned int InitRND(int);
267 void InitGraphicInfo_EM(void);
268
269 void PlayMenuSoundExt(int);
270 void PlayMenuSound(void);
271 void PlayMenuSoundStereo(int, int);
272 void PlayMenuSoundIfLoopExt(int);
273 void PlayMenuSoundIfLoop(void);
274 void PlayMenuMusicExt(int);
275 void PlayMenuMusic(void);
276 void PlayMenuSoundsAndMusic(void);
277 void FadeMenuSoundsAndMusic(void);
278 void PlaySoundActivating(void);
279 void PlaySoundSelecting(void);
280
281 void SetAnimStatus(int);
282 void SetGameStatus(int);
283 void SetFontStatus(int);
284 void ResetFontStatus(void);
285
286 void SetLevelSetInfo(char *, int);
287
288 void ToggleFullscreenOrChangeWindowScalingIfNeeded(void);
289 void ChangeViewportPropertiesIfNeeded(void);
290
291 boolean CheckIfAllViewportsHaveChanged(void);
292 boolean CheckFadeAll(void);
293
294 #endif  // TOOLS_H