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