rnd-20140224-1-src
[rocksndiamonds.git] / src / tools.h
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * tools.h                                                  *
12 ***********************************************************/
13
14 #ifndef TOOLS_H
15 #define TOOLS_H
16
17 #include "main.h"
18 #include "game.h"
19
20 /* for SetDrawtoField */
21 #define DRAW_BUFFERED           1
22 #define DRAW_BACKBUFFER         2
23
24 /* for DrawElementShifted */
25 #define NO_CUTTING              0
26 #define CUT_ABOVE               (1 << 0)
27 #define CUT_BELOW               (1 << 1)
28 #define CUT_LEFT                (1 << 2)
29 #define CUT_RIGHT               (1 << 3)
30
31 /* for masking functions */
32 #define NO_MASKING              0
33 #define USE_MASKING             1
34  
35 /* for MoveDoor */
36 #if 0
37 #define DOOR_1                  (1 << 0)
38 #define DOOR_2                  (1 << 1)
39 #define DOOR_OPEN               (1 << 2)
40 #define DOOR_CLOSE              (1 << 3)
41 #define DOOR_OPEN_1             (DOOR_1 | DOOR_OPEN)
42 #define DOOR_OPEN_2             (DOOR_2 | DOOR_OPEN)
43 #define DOOR_CLOSE_1            (DOOR_1 | DOOR_CLOSE)
44 #define DOOR_CLOSE_2            (DOOR_2 | DOOR_CLOSE)
45 #else
46 #define DOOR_OPEN_1             (1 << 0)
47 #define DOOR_OPEN_2             (1 << 1)
48 #define DOOR_CLOSE_1            (1 << 2)
49 #define DOOR_CLOSE_2            (1 << 3)
50 #endif
51 #define DOOR_OPEN_ALL           (DOOR_OPEN_1 | DOOR_OPEN_2)
52 #define DOOR_CLOSE_ALL          (DOOR_CLOSE_1 | DOOR_CLOSE_2)
53 #define DOOR_ACTION_1           (DOOR_OPEN_1 | DOOR_CLOSE_1)
54 #define DOOR_ACTION_2           (DOOR_OPEN_2 | DOOR_CLOSE_2)
55 #define DOOR_ACTION             (DOOR_ACTION_1 | DOOR_ACTION_2)
56 #define DOOR_COPY_BACK          (1 << 4)
57 #define DOOR_NO_COPY_BACK       (1 << 5)
58 #define DOOR_NO_DELAY           (1 << 6)
59 #define DOOR_FORCE_REDRAW       (1 << 7)
60 #define DOOR_GET_STATE          (1 << 8)
61 #define DOOR_SET_STATE          (1 << 9)
62
63 #define DOOR_1                  (DOOR_ACTION_1)
64 #define DOOR_2                  (DOOR_ACTION_2)
65 #define DOOR_OPEN               (DOOR_OPEN_ALL)
66 #define DOOR_CLOSE              (DOOR_CLOSE_ALL)
67
68 #define DOOR_INDEX_FROM_TOKEN(x)        ((x) == DOOR_1 ? 0 : 1)
69 #define DOOR_TOKEN_FROM_INDEX(x)        ((x) == 0 ? DOOR_1 ? : DOOR_2)
70 #define REDRAW_DOOR_FROM_TOKEN(x)       ((x) == DOOR_1 ? REDRAW_DOOR_1 : \
71                                          REDRAW_DOOR_2)
72
73 /* for Request */
74 #define REQ_ASK                 (1 << 0)
75 #define REQ_CONFIRM             (1 << 1)
76 #define REQ_PLAYER              (1 << 2)
77 #define REQ_STAY_OPEN           (1 << 3)
78 #define REQ_STAY_CLOSED         (1 << 4)
79 #define REQ_REOPEN              (1 << 5)
80
81 #define REQUEST_WAIT_FOR_INPUT  (REQ_ASK | REQ_CONFIRM | REQ_PLAYER)
82
83
84 void DumpTile(int, int);
85
86 void DrawMaskedBorder_FIELD();
87 void DrawMaskedBorder_DOOR_1();
88 void DrawMaskedBorder_DOOR_2();
89 void DrawMaskedBorder_DOOR_3();
90 void DrawMaskedBorder_ALL();
91 void DrawMaskedBorder(int);
92
93 void SetDrawtoField(int);
94 void RedrawPlayfield(boolean, int, int, int, int);
95 void BlitScreenToBitmap(Bitmap *);
96 void BackToFront();
97
98 void FadeIn(int);
99 void FadeOut(int);
100 void FadeSetEnterMenu();
101 void FadeSetLeaveMenu();
102 void FadeSetEnterScreen();
103 void FadeSetNextScreen();
104 void FadeSetLeaveScreen();
105 void FadeSetFromType(int);
106 void FadeSetDisabled();
107 void FadeSkipNextFadeIn();
108 void FadeSkipNextFadeOut();
109
110 void ClearField();
111 void SetWindowBackgroundImageIfDefined(int);
112 void SetMainBackgroundImageIfDefined(int);
113 void SetDoorBackgroundImageIfDefined(int);
114 void SetWindowBackgroundImage(int);
115 void SetMainBackgroundImage(int);
116 void SetDoorBackgroundImage(int);
117 void SetPanelBackground();
118 void DrawBackground(int, int, int, int);
119 void DrawBackgroundForFont(int, int, int, int, int);
120 void DrawBackgroundForGraphic(int, int, int, int, int);
121
122 void MarkTileDirty(int, int);
123 void SetBorderElement();
124 void FloodFillLevel(int, int, int, short[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
125                     int, int);
126
127 void SetRandomAnimationValue(int, int);
128 int getGraphicAnimationFrame(int, int);
129
130 void DrawGraphicAnimation(int, int, int);
131 void DrawGraphicAnimationExt(DrawBuffer *, int, int, int, int, int);
132
133 void DrawFixedGraphicAnimation(int, int, int);
134 void DrawFixedGraphicAnimationExt(DrawBuffer *, int, int, int, int, int);
135
136 void DrawLevelGraphicAnimation(int, int, int);
137 void DrawLevelElementAnimation(int, int, int);
138 void DrawLevelGraphicAnimationIfNeeded(int, int, int);
139 void DrawLevelElementAnimationIfNeeded(int, int, int);
140
141 void DrawAllPlayers(void);
142 void DrawPlayerField(int, int);
143 void DrawPlayer(struct PlayerInfo *);
144
145 void getSizedGraphicSourceExt(int, int, int, Bitmap **, int *, int *, boolean);
146 void getFixedGraphicSourceExt(int, int, Bitmap **, int *, int *, boolean);
147 void getSizedGraphicSource(int, int, int, Bitmap **, int *, int *);
148 void getFixedGraphicSource(int, int, Bitmap **, int *, int *);
149 void getMiniGraphicSource(int, Bitmap **, int *, int *);
150 void getGraphicSourceExt(int, int, Bitmap **, int *, int *, boolean);
151 void getGraphicSource(int, int, Bitmap **, int *, int *);
152
153 void DrawGraphic(int, int, int, int);
154 void DrawGraphicExt(DrawBuffer *, int, int, int, int);
155 void DrawGraphicThruMask(int, int, int, int);
156 void DrawGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
157
158 void DrawFixedGraphic(int, int, int, int);
159 void DrawFixedGraphicExt(DrawBuffer *, int, int, int, int);
160 void DrawFixedGraphicThruMask(int, int, int, int);
161 void DrawFixedGraphicThruMaskExt(DrawBuffer *, int, int, int, int);
162
163 void DrawSizedGraphic(int, int, int, int, int);
164 void DrawSizedGraphicExt(DrawBuffer *, int, int, int, int, int);
165
166 void DrawMiniGraphic(int, int, int);
167 void DrawMiniGraphicExt(DrawBuffer *, int, int, int);
168
169 void DrawScreenElementExt(int, int, int, int, int, int, int);
170 void DrawLevelElementExt(int, int, int, int, int, int, int);
171 void DrawScreenElementShifted(int, int, int, int, int, int);
172 void DrawLevelElementShifted(int, int, int, int, int, int);
173 void DrawScreenElementThruMask(int, int, int);
174 void DrawLevelElementThruMask(int, int, int);
175 void DrawLevelFieldThruMask(int, int);
176 void DrawLevelFieldCrumbled(int, int);
177 void DrawLevelFieldCrumbledDigging(int, int, int, int);
178 void DrawLevelFieldCrumbledNeighbours(int, int);
179 void DrawScreenElement(int, int, int);
180 void DrawLevelElement(int, int, int);
181 void DrawScreenField(int, int);
182 void DrawLevelField(int, int);
183
184 void DrawMiniElement(int, int, int);
185 void DrawMiniElementOrWall(int, int, int, int);
186
187 void ShowEnvelope(int);
188 void ShowEnvelopeDoor(char *text, int);
189
190 void DrawLevel(void);
191 void DrawMiniLevel(int, int, int, int);
192 void DrawPreviewLevelInitial(void);
193 void DrawPreviewLevelAnimation(void);
194
195 void WaitForEventToContinue();
196 boolean Request(char *, unsigned int);
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 get_next_element(int);
223 int el_act_dir2img(int, int, int);
224 int el_act2img(int, int);
225 int el_dir2img(int, int);
226 int el2baseimg(int);
227 int el2img(int);
228 int el2edimg(int);
229 int el2preimg(int);
230 int el2panelimg(int);
231 int font2baseimg(int);
232
233 int getBeltNrFromBeltElement(int);
234 int getBeltNrFromBeltActiveElement(int);
235 int getBeltNrFromBeltSwitchElement(int);
236 int getBeltDirNrFromBeltElement(int);
237 int getBeltDirNrFromBeltSwitchElement(int);
238 int getBeltDirFromBeltElement(int);
239 int getBeltDirFromBeltSwitchElement(int);
240 int getBeltElementFromBeltNrAndBeltDirNr(int, int);
241 int getBeltElementFromBeltNrAndBeltDir(int, int);
242 int getBeltSwitchElementFromBeltNrAndBeltDirNr(int, int);
243 int getBeltSwitchElementFromBeltNrAndBeltDir(int, int);
244
245 unsigned int InitRND(int);
246 void InitGraphicInfo_EM(void);
247
248 void PlayMenuSoundExt(int);
249 void PlayMenuSound();
250 void PlayMenuSoundStereo(int, int);
251 void PlayMenuSoundIfLoopExt(int);
252 void PlayMenuSoundIfLoop();
253 void PlayMenuMusicExt(int);
254 void PlayMenuMusic();
255 void PlaySoundActivating();
256 void PlaySoundSelecting();
257
258 void ToggleFullscreenOrChangeWindowScalingIfNeeded();
259 void ChangeViewportPropertiesIfNeeded();
260
261 #endif  /* TOOLS_H */