added basic support for Mirror Magic game engine (first part)
[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_REDRAW       (1 << 7)
44 #define DOOR_GET_STATE          (1 << 8)
45 #define DOOR_SET_STATE          (1 << 9)
46
47 #define DOOR_1                  (DOOR_ACTION_1)
48 #define DOOR_2                  (DOOR_ACTION_2)
49 #define DOOR_OPEN               (DOOR_OPEN_ALL)
50 #define DOOR_CLOSE              (DOOR_CLOSE_ALL)
51
52 #define DOOR_INDEX_FROM_TOKEN(x)        ((x) == DOOR_1 ? 0 : 1)
53 #define DOOR_TOKEN_FROM_INDEX(x)        ((x) == 0 ? DOOR_1 ? : DOOR_2)
54 #define REDRAW_DOOR_FROM_TOKEN(x)       ((x) == DOOR_1 ? REDRAW_DOOR_1 : \
55                                          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 #define REQUEST_WAIT_FOR_INPUT  (REQ_ASK | REQ_CONFIRM | REQ_PLAYER)
66
67
68 int correctLevelPosX_EM(int);
69 int correctLevelPosY_EM(int);
70
71 int getLevelFromScreenX(int);
72 int getLevelFromScreenY(int);
73
74 void DumpTile(int, int);
75 void DumpTileFromScreen(int, int);
76
77 void DrawMaskedBorder_FIELD();
78 void DrawMaskedBorder_DOOR_1();
79 void DrawMaskedBorder_DOOR_2();
80 void DrawMaskedBorder_DOOR_3();
81 void DrawMaskedBorder_ALL();
82 void DrawMaskedBorder(int);
83 void DrawMaskedBorderToTarget(int);
84
85 void SetDrawtoField(int);
86 void RedrawPlayfield();
87 void BlitScreenToBitmap_RND(Bitmap *);
88 void BlitScreenToBitmap(Bitmap *);
89 void BackToFront();
90 void BackToFront_WithFrameDelay(unsigned int);
91
92 void FadeIn(int);
93 void FadeOut(int);
94 void FadeSetEnterMenu();
95 void FadeSetLeaveMenu();
96 void FadeSetEnterScreen();
97 void FadeSetNextScreen();
98 void FadeSetLeaveScreen();
99 void FadeSetFromType(int);
100 void FadeSetDisabled();
101 void FadeSkipNextFadeIn();
102 void FadeSkipNextFadeOut();
103
104 Bitmap *getGlobalBorderBitmapFromStatus(int);
105
106 void ClearField();
107 void SetWindowBackgroundImageIfDefined(int);
108 void SetMainBackgroundImageIfDefined(int);
109 void SetDoorBackgroundImageIfDefined(int);
110 void SetWindowBackgroundImage(int);
111 void SetMainBackgroundImage(int);
112 void SetDoorBackgroundImage(int);
113 void SetPanelBackground();
114 void DrawBackground(int, int, int, int);
115 void DrawBackgroundForFont(int, int, int, int, int);
116 void DrawBackgroundForGraphic(int, int, int, int, int);
117 boolean CheckIfGlobalBorderHasChanged();
118 void RedrawGlobalBorder();
119
120 void MarkTileDirty(int, int);
121 void SetBorderElement();
122 void FloodFillLevel(int, int, int, short[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
123                     int, int);
124
125 void SetRandomAnimationValue(int, int);
126 int getGraphicAnimationFrame(int, int);
127
128 void DrawFixedGraphicAnimation(int, int, int);
129 void DrawFixedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int);
130
131 void DrawLevelGraphicAnimation(int, int, int);
132 void DrawLevelElementAnimation(int, int, int);
133 void DrawLevelGraphicAnimationIfNeeded(int, int, int);
134 void DrawLevelElementAnimationIfNeeded(int, int, int);
135
136 void DrawAllPlayers(void);
137 void DrawPlayerField(int, int);
138 void DrawPlayer(struct PlayerInfo *);
139
140 void getGraphicSourceBitmap(int, int, Bitmap **);
141 void getGraphicSourceXY(int, int, int *, int *, boolean);
142 void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean);
143 void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *);
144 void getFixedGraphicSource(int, int, Bitmap **, int *, int *);
145 void getMiniGraphicSource(int, Bitmap **, int *, int *);
146 void getGraphicSource(int, int, Bitmap **, int *, int *);
147
148 void DrawGraphic(int, int, int, int);
149 void DrawGraphicExt(DrawBuffer *, int, int, int, int);
150 void DrawGraphicThruMask(int, int, int, int);
151 void DrawGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
152
153 void DrawFixedGraphic(int, int, int, int);
154 void DrawFixedGraphicExt(DrawBuffer *, int, int, int, int);
155 void DrawFixedGraphicThruMask(int, int, int, int);
156 void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
157
158 void DrawSizedGraphic(int, int, int, int, int);
159 void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int);
160
161 void DrawMiniGraphic(int, int, int);
162 void DrawMiniGraphicExt(DrawBuffer *, int, int, int);
163
164 void DrawScreenElementExt(int, int, int, int, int, int, int);
165 void DrawLevelElementExt(int, int, int, int, int, int, int);
166 void DrawScreenElementShifted(int, int, int, int, int, int);
167 void DrawLevelElementShifted(int, int, int, int, int, int);
168 void DrawScreenElementThruMask(int, int, int);
169 void DrawLevelElementThruMask(int, int, int);
170 void DrawLevelFieldThruMask(int, int);
171 void DrawLevelFieldCrumbled(int, int);
172 void DrawLevelFieldCrumbledDigging(int, int, int, int);
173 void DrawLevelFieldCrumbledNeighbours(int, int);
174 void DrawScreenElement(int, int, int);
175 void DrawLevelElement(int, int, int);
176 void DrawScreenField(int, int);
177 void DrawLevelField(int, int);
178
179 void DrawSizedElement(int, int, int, int);
180 void DrawSizedElementOrWall(int, int, int, int, int);
181
182 void DrawMiniElement(int, int, int);
183 void DrawMiniElementOrWall(int, int, int, int);
184
185 void ShowEnvelope(int);
186 void ShowEnvelopeDoor(char *text, int);
187
188 void DrawLevel(int);
189 void DrawSizedLevel(int, int, int, int, int);
190 void DrawMiniLevel(int, int, int, int);
191 void DrawPreviewLevelInitial(void);
192 void DrawPreviewLevelAnimation(void);
193
194 void WaitForEventToContinue(void);
195 boolean Request(char *, unsigned int);
196 void InitGraphicCompatibilityInfo_Doors(void);
197 void InitDoors(void);
198 unsigned int OpenDoor(unsigned int);
199 unsigned int CloseDoor(unsigned int);
200 unsigned int GetDoorState(void);
201 unsigned int SetDoorState(unsigned int);
202 unsigned int MoveDoor(unsigned int);
203
204 void DrawSpecialEditorDoor();
205 void UndrawSpecialEditorDoor();
206
207 void CreateToolButtons();
208 void FreeToolButtons();
209
210 int map_element_RND_to_EM(int);
211 int map_element_EM_to_RND(int);
212 int map_direction_RND_to_EM(int);
213 int map_direction_EM_to_RND(int);
214
215 void map_android_clone_elements_RND_to_EM(struct LevelInfo *);
216 void map_android_clone_elements_EM_to_RND(struct LevelInfo *);
217
218 int map_element_RND_to_SP(int);
219 int map_element_SP_to_RND(int);
220 int map_action_SP_to_RND(int);
221
222 int map_element_RND_to_MM(int);
223 int map_element_MM_to_RND(int);
224
225 int get_next_element(int);
226 int el_act_dir2img(int, int, int);
227 int el_act2img(int, int);
228 int el_dir2img(int, int);
229 int el2baseimg(int);
230 int el2img(int);
231 int el2edimg(int);
232 int el2preimg(int);
233 int el2panelimg(int);
234 int font2baseimg(int);
235
236 int getBeltNrFromBeltElement(int);
237 int getBeltNrFromBeltActiveElement(int);
238 int getBeltNrFromBeltSwitchElement(int);
239 int getBeltDirNrFromBeltElement(int);
240 int getBeltDirNrFromBeltSwitchElement(int);
241 int getBeltDirFromBeltElement(int);
242 int getBeltDirFromBeltSwitchElement(int);
243 int getBeltElementFromBeltNrAndBeltDirNr(int, int);
244 int getBeltElementFromBeltNrAndBeltDir(int, int);
245 int getBeltSwitchElementFromBeltNrAndBeltDirNr(int, int);
246 int getBeltSwitchElementFromBeltNrAndBeltDir(int, int);
247
248 unsigned int InitRND(int);
249 void InitGraphicInfo_EM(void);
250
251 void PlayMenuSoundExt(int);
252 void PlayMenuSound();
253 void PlayMenuSoundStereo(int, int);
254 void PlayMenuSoundIfLoopExt(int);
255 void PlayMenuSoundIfLoop();
256 void PlayMenuMusicExt(int);
257 void PlayMenuMusic();
258 void PlayMenuSoundsAndMusic();
259 void FadeMenuSoundsAndMusic();
260 void PlaySoundActivating();
261 void PlaySoundSelecting();
262
263 void SetAnimStatus(int);
264 void SetGameStatus(int);
265 void SetFontStatus(int);
266 void ResetFontStatus();
267
268 void ToggleFullscreenOrChangeWindowScalingIfNeeded();
269 void ChangeViewportPropertiesIfNeeded();
270
271 #endif  /* TOOLS_H */