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