Merge branch 'master' into global-anims
[rocksndiamonds.git] / src / libgame / system.h
1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // system.h
10 // ============================================================================
11
12 #ifndef SYSTEM_H
13 #define SYSTEM_H
14
15 #include "platform.h"
16 #include "types.h"
17
18
19 #if defined(PLATFORM_MACOSX)
20 #include "macosx.h"
21 #elif defined(PLATFORM_WIN32)
22 #include "windows.h"
23 #elif defined(PLATFORM_ANDROID)
24 #include "android.h"
25 #endif
26
27 #include "sdl.h"
28
29
30 /* the additional 'b' is needed for Win32 to open files in binary mode */
31 #define MODE_READ                       "rb"
32 #define MODE_WRITE                      "wb"
33 #define MODE_APPEND                     "ab"
34
35 #define DEFAULT_DEPTH                   0
36
37 #define BLIT_OPAQUE                     0
38 #define BLIT_MASKED                     1
39 #define BLIT_INVERSE                    2
40 #define BLIT_ON_BACKGROUND              3
41
42 /* values for fullscreen status */
43 #define FULLSCREEN_NOT_AVAILABLE        FALSE
44 #define FULLSCREEN_AVAILABLE            TRUE
45
46 /* values for window scaling */
47 #define WINDOW_SCALING_NOT_AVAILABLE    FALSE
48 #define WINDOW_SCALING_AVAILABLE        TRUE
49
50 #define MIN_WINDOW_SCALING_PERCENT      50
51 #define STD_WINDOW_SCALING_PERCENT      100
52 #define MAX_WINDOW_SCALING_PERCENT      300
53 #define STEP_WINDOW_SCALING_PERCENT     10
54
55 /* values for window scaling quality */
56 #define SCALING_QUALITY_NEAREST         "nearest"
57 #define SCALING_QUALITY_LINEAR          "linear"
58 #define SCALING_QUALITY_BEST            "best"
59
60 #define SCALING_QUALITY_DEFAULT         SCALING_QUALITY_LINEAR
61
62 /* values for touch control */
63 #define TOUCH_CONTROL_VIRTUAL_BUTTONS   "virtual_buttons"
64 #define TOUCH_CONTROL_WIPE_GESTURES     "wipe_gestures"
65
66 #define TOUCH_CONTROL_DEFAULT           TOUCH_CONTROL_VIRTUAL_BUTTONS
67
68 #define TOUCH_MOVE_DISTANCE_DEFAULT     2
69 #define TOUCH_DROP_DISTANCE_DEFAULT     5
70
71
72 /* default input keys */
73 #define DEFAULT_KEY_LEFT                KSYM_Left
74 #define DEFAULT_KEY_RIGHT               KSYM_Right
75 #define DEFAULT_KEY_UP                  KSYM_Up
76 #define DEFAULT_KEY_DOWN                KSYM_Down
77 #if defined(PLATFORM_MACOSX)
78 #define DEFAULT_KEY_SNAP                KSYM_Control_L
79 #define DEFAULT_KEY_DROP                KSYM_KP_Enter
80 #else
81 #define DEFAULT_KEY_SNAP                KSYM_Control_L
82 #define DEFAULT_KEY_DROP                KSYM_Control_R
83 #endif
84 #define DEFAULT_KEY_OKAY                KSYM_Return
85 #define DEFAULT_KEY_CANCEL              KSYM_Escape
86
87 /* default shortcut keys */
88 #define DEFAULT_KEY_SAVE_GAME           KSYM_F1
89 #define DEFAULT_KEY_LOAD_GAME           KSYM_F2
90 #define DEFAULT_KEY_TOGGLE_PAUSE        KSYM_space
91 #define DEFAULT_KEY_FOCUS_PLAYER_1      KSYM_F5
92 #define DEFAULT_KEY_FOCUS_PLAYER_2      KSYM_F6
93 #define DEFAULT_KEY_FOCUS_PLAYER_3      KSYM_F7
94 #define DEFAULT_KEY_FOCUS_PLAYER_4      KSYM_F8
95 #define DEFAULT_KEY_FOCUS_PLAYER_ALL    KSYM_F9
96 #define DEFAULT_KEY_TAPE_EJECT          KSYM_UNDEFINED
97 #define DEFAULT_KEY_TAPE_EXTRA          KSYM_UNDEFINED
98 #define DEFAULT_KEY_TAPE_STOP           KSYM_UNDEFINED
99 #define DEFAULT_KEY_TAPE_PAUSE          KSYM_UNDEFINED
100 #define DEFAULT_KEY_TAPE_RECORD         KSYM_UNDEFINED
101 #define DEFAULT_KEY_TAPE_PLAY           KSYM_UNDEFINED
102 #define DEFAULT_KEY_SOUND_SIMPLE        KSYM_UNDEFINED
103 #define DEFAULT_KEY_SOUND_LOOPS         KSYM_UNDEFINED
104 #define DEFAULT_KEY_SOUND_MUSIC         KSYM_UNDEFINED
105 #define DEFAULT_KEY_SNAP_LEFT           KSYM_UNDEFINED
106 #define DEFAULT_KEY_SNAP_RIGHT          KSYM_UNDEFINED
107 #define DEFAULT_KEY_SNAP_UP             KSYM_UNDEFINED
108 #define DEFAULT_KEY_SNAP_DOWN           KSYM_UNDEFINED
109
110 /* values for key_status */
111 #define KEY_NOT_PRESSED                 FALSE
112 #define KEY_RELEASED                    FALSE
113 #define KEY_PRESSED                     TRUE
114
115 /* values for button status */
116 #define MB_NOT_PRESSED                  FALSE
117 #define MB_NOT_RELEASED                 TRUE
118 #define MB_RELEASED                     FALSE
119 #define MB_PRESSED                      TRUE
120 #define MB_MENU_CHOICE                  FALSE
121 #define MB_MENU_MARK                    TRUE
122 #define MB_MENU_INITIALIZE              (-1)
123 #define MB_MENU_LEAVE                   (-2)
124 #define MB_LEFTBUTTON                   1
125 #define MB_MIDDLEBUTTON                 2
126 #define MB_RIGHTBUTTON                  3
127 #define MB_WHEEL_UP                     4
128 #define MB_WHEEL_DOWN                   5
129 #define MB_WHEEL_LEFT                   6
130 #define MB_WHEEL_RIGHT                  7
131 #define IS_WHEEL_BUTTON_VERTICAL(b)     ((b) >= MB_WHEEL_UP &&          \
132                                          (b) <= MB_WHEEL_DOWN)
133 #define IS_WHEEL_BUTTON_HORIZONTAL(b)   ((b) >= MB_WHEEL_LEFT &&        \
134                                          (b) <= MB_WHEEL_RIGHT)
135 #define IS_WHEEL_BUTTON(b)              ((b) >= MB_WHEEL_UP &&          \
136                                          (b) <= MB_WHEEL_DOWN)
137 #define DEFAULT_WHEEL_STEPS             3
138
139 #define BUTTON_STEPSIZE(b)              ((b) == MB_LEFTBUTTON   ?  1 :  \
140                                          (b) == MB_MIDDLEBUTTON ?  5 :  \
141                                          (b) == MB_RIGHTBUTTON  ? 10 : 1)
142
143 /* values for move directions */
144 #define MV_BIT_LEFT                     0
145 #define MV_BIT_RIGHT                    1
146 #define MV_BIT_UP                       2
147 #define MV_BIT_DOWN                     3
148
149 #define NUM_DIRECTIONS                  4
150
151 /* diagonal movement directions are used in a different contect than buttons */
152 #define MV_BIT_UPLEFT                   4
153 #define MV_BIT_UPRIGHT                  5
154 #define MV_BIT_DOWNLEFT                 6
155 #define MV_BIT_DOWNRIGHT                7
156
157 #define NUM_DIRECTIONS_FULL             8
158
159 /* values for special "button" bitmasks */
160 #define BUTTON_1                        4
161 #define BUTTON_2                        5
162
163 #define NUM_PLAYER_ACTIONS              6
164
165 /* values for special "focus player" bitmasks */
166 #define BIT_SET_FOCUS                   6
167
168 /* values for drawing stages for global animations */
169 #define DRAW_GLOBAL_ANIM_STAGE_1        1
170 #define DRAW_GLOBAL_ANIM_STAGE_2        2
171
172 /* values for move directions and special "button" key bitmasks */
173 #define MV_NONE                 0
174 #define MV_LEFT                 (1 << MV_BIT_LEFT)
175 #define MV_RIGHT                (1 << MV_BIT_RIGHT)
176 #define MV_UP                   (1 << MV_BIT_UP)
177 #define MV_DOWN                 (1 << MV_BIT_DOWN)
178
179 #define MV_UPLEFT               (MV_UP   | MV_LEFT)
180 #define MV_UPRIGHT              (MV_UP   | MV_RIGHT)
181 #define MV_DOWNLEFT             (MV_DOWN | MV_LEFT)
182 #define MV_DOWNRIGHT            (MV_DOWN | MV_RIGHT)
183
184 #define MV_HORIZONTAL           (MV_LEFT | MV_RIGHT)
185 #define MV_VERTICAL             (MV_UP   | MV_DOWN)
186 #define MV_ALL_DIRECTIONS       (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
187 #define MV_ANY_DIRECTION        (MV_ALL_DIRECTIONS)
188 #define MV_NO_DIRECTION         (MV_NONE)
189
190 #define KEY_BUTTON_1            (1 << BUTTON_1)
191 #define KEY_BUTTON_2            (1 << BUTTON_2)
192 #define KEY_BUTTON_SNAP         KEY_BUTTON_1
193 #define KEY_BUTTON_DROP         KEY_BUTTON_2
194 #define KEY_MOTION              (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
195 #define KEY_BUTTON              (KEY_BUTTON_1 | KEY_BUTTON_2)
196 #define KEY_ACTION              (KEY_MOTION | KEY_BUTTON)
197
198 #define KEY_SET_FOCUS           (1 << BIT_SET_FOCUS)
199
200 #define MV_DIR_FROM_BIT(x)      ((x) < NUM_DIRECTIONS ? 1 << (x) :        \
201                                  (x) == MV_BIT_UPLEFT    ? MV_UPLEFT    : \
202                                  (x) == MV_BIT_UPRIGHT   ? MV_UPRIGHT   : \
203                                  (x) == MV_BIT_DOWNLEFT  ? MV_DOWNLEFT  : \
204                                  (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
205                                  MV_NONE)
206
207 #define MV_DIR_TO_BIT(x)        ((x) == MV_LEFT      ? MV_BIT_LEFT      : \
208                                  (x) == MV_RIGHT     ? MV_BIT_RIGHT     : \
209                                  (x) == MV_UP        ? MV_BIT_UP        : \
210                                  (x) == MV_DOWN      ? MV_BIT_DOWN      : \
211                                  (x) == MV_UPLEFT    ? MV_BIT_UPLEFT    : \
212                                  (x) == MV_UPRIGHT   ? MV_BIT_UPRIGHT   : \
213                                  (x) == MV_DOWNLEFT  ? MV_BIT_DOWNLEFT  : \
214                                  (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
215                                  MV_BIT_DOWN)
216
217 #define MV_DIR_OPPOSITE(x)      ((x) == MV_LEFT      ? MV_RIGHT     : \
218                                  (x) == MV_RIGHT     ? MV_LEFT      : \
219                                  (x) == MV_UP        ? MV_DOWN      : \
220                                  (x) == MV_DOWN      ? MV_UP        : \
221                                  (x) == MV_UPLEFT    ? MV_DOWNRIGHT : \
222                                  (x) == MV_UPRIGHT   ? MV_DOWNLEFT  : \
223                                  (x) == MV_DOWNLEFT  ? MV_UPRIGHT   : \
224                                  (x) == MV_DOWNRIGHT ? MV_UPLEFT    : \
225                                  MV_NONE)
226
227 /* values for animation mode (frame order and direction) */
228 #define ANIM_NONE               0
229 #define ANIM_LOOP               (1 << 0)
230 #define ANIM_LINEAR             (1 << 1)
231 #define ANIM_PINGPONG           (1 << 2)
232 #define ANIM_PINGPONG2          (1 << 3)
233 #define ANIM_RANDOM             (1 << 4)
234 #define ANIM_CE_VALUE           (1 << 5)
235 #define ANIM_CE_SCORE           (1 << 6)
236 #define ANIM_CE_DELAY           (1 << 7)
237 #define ANIM_REVERSE            (1 << 8)
238 #define ANIM_OPAQUE_PLAYER      (1 << 9)
239
240 /* values for special (non game element) animation modes */
241 #define ANIM_HORIZONTAL         (1 << 10)
242 #define ANIM_VERTICAL           (1 << 11)
243 #define ANIM_CENTERED           (1 << 12)
244 #define ANIM_STATIC_PANEL       (1 << 13)
245 #define ANIM_ALL                (1 << 14)
246
247 #define ANIM_DEFAULT            ANIM_LOOP
248
249 /* values for special drawing styles (currently only for crumbled graphics) */
250 #define STYLE_NONE              0
251 #define STYLE_ACCURATE_BORDERS  (1 << 0)
252 #define STYLE_INNER_CORNERS     (1 << 1)
253
254 #define STYLE_DEFAULT           STYLE_NONE
255
256 /* values for fade mode */
257 #define FADE_TYPE_NONE          0
258 #define FADE_TYPE_FADE_IN       (1 << 0)
259 #define FADE_TYPE_FADE_OUT      (1 << 1)
260 #define FADE_TYPE_TRANSFORM     (1 << 2)
261 #define FADE_TYPE_CROSSFADE     (1 << 3)
262 #define FADE_TYPE_MELT          (1 << 4)
263 #define FADE_TYPE_CURTAIN       (1 << 5)
264 #define FADE_TYPE_SKIP          (1 << 6)
265
266 #define FADE_MODE_NONE          (FADE_TYPE_NONE)
267 #define FADE_MODE_FADE_IN       (FADE_TYPE_FADE_IN)
268 #define FADE_MODE_FADE_OUT      (FADE_TYPE_FADE_OUT)
269 #define FADE_MODE_FADE          (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT)
270 #define FADE_MODE_TRANSFORM     (FADE_TYPE_TRANSFORM | FADE_TYPE_FADE_IN)
271 #define FADE_MODE_CROSSFADE     (FADE_MODE_TRANSFORM | FADE_TYPE_CROSSFADE)
272 #define FADE_MODE_MELT          (FADE_MODE_TRANSFORM | FADE_TYPE_MELT)
273 #define FADE_MODE_CURTAIN       (FADE_MODE_TRANSFORM | FADE_TYPE_CURTAIN)
274 #define FADE_MODE_SKIP_FADE_IN  (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN)
275 #define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT)
276
277 #define FADE_MODE_DEFAULT       FADE_MODE_FADE
278
279 /* values for toon positions */
280 #define POS_UNDEFINED           -1
281 #define POS_LEFT                0
282 #define POS_RIGHT               1
283 #define POS_TOP                 2
284 #define POS_UPPER               3
285 #define POS_MIDDLE              4
286 #define POS_LOWER               5
287 #define POS_BOTTOM              6
288 #define POS_ANY                 7
289
290 /* values for text alignment */
291 #define ALIGN_LEFT              (1 << 0)
292 #define ALIGN_RIGHT             (1 << 1)
293 #define ALIGN_CENTER            (1 << 2)
294 #define ALIGN_DEFAULT           ALIGN_LEFT
295
296 #define VALIGN_TOP              (1 << 0)
297 #define VALIGN_BOTTOM           (1 << 1)
298 #define VALIGN_MIDDLE           (1 << 2)
299 #define VALIGN_DEFAULT          VALIGN_TOP
300
301 #define ALIGNED_XPOS(x,w,a)     ((a) == ALIGN_CENTER  ? (x) - (w) / 2 : \
302                                  (a) == ALIGN_RIGHT   ? (x) - (w) : (x))
303 #define ALIGNED_YPOS(y,h,v)     ((v) == VALIGN_MIDDLE ? (y) - (h) / 2 : \
304                                  (v) == VALIGN_BOTTOM ? (y) - (h) : (y))
305 #define ALIGNED_TEXT_XPOS(p)    ALIGNED_XPOS((p)->x, (p)->width,  (p)->align)
306 #define ALIGNED_TEXT_YPOS(p)    ALIGNED_YPOS((p)->y, (p)->height, (p)->valign)
307
308 /* values for redraw_mask */
309 #define REDRAW_NONE             (0)
310 #define REDRAW_ALL              (1 << 0)
311 #define REDRAW_FIELD            (1 << 1)
312 #define REDRAW_DOOR_1           (1 << 2)
313 #define REDRAW_DOOR_2           (1 << 3)
314 #define REDRAW_DOOR_3           (1 << 4)
315 #define REDRAW_FPS              (1 << 5)
316
317 #define REDRAW_DOORS            (REDRAW_DOOR_1 | \
318                                  REDRAW_DOOR_2 | \
319                                  REDRAW_DOOR_3)
320
321 #define IN_GFX_FIELD_PLAY(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
322                                  y >= gfx.sy && y < gfx.sy + gfx.sysize)
323 #define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \
324                                  x <  gfx.real_sx + gfx.full_sxsize && \
325                                  y >= gfx.real_sy && \
326                                  y <  gfx.real_sy + gfx.full_sysize)
327 #define IN_GFX_DOOR_1(x, y)     (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
328                                  y >= gfx.dy && y < gfx.dy + gfx.dysize)
329 #define IN_GFX_DOOR_2(x, y)     (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
330                                  y >= gfx.vy && y < gfx.vy + gfx.vysize)
331 #define IN_GFX_DOOR_3(x, y)     (x >= gfx.ex && x < gfx.ex + gfx.exsize && \
332                                  y >= gfx.ey && y < gfx.ey + gfx.eysize)
333
334 /* values for mouse cursor */
335 #define CURSOR_DEFAULT          0
336 #define CURSOR_NONE             1
337 #define CURSOR_PLAYFIELD        2
338
339 /* fundamental game speed values */
340 #define ONE_SECOND_DELAY        1000    /* delay value for one second */
341 #define GAME_FRAME_DELAY        20      /* frame delay in milliseconds */
342 #define FFWD_FRAME_DELAY        10      /* 200% speed for fast forward */
343 #define FRAMES_PER_SECOND       (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
344 #define FRAMES_PER_SECOND_SP    35
345
346 /* maximum playfield size supported by libgame functions */
347 #define MAX_PLAYFIELD_WIDTH     128
348 #define MAX_PLAYFIELD_HEIGHT    128
349
350 /* maximum number of parallel players supported by libgame functions */
351 #define MAX_PLAYERS             4
352
353 /* maximum allowed length of player name */
354 #define MAX_PLAYER_NAME_LEN     10
355
356 /* maximum number of levels in a level set */
357 #define MAX_LEVELS              1000
358
359 /* default name for empty highscore entry */
360 #define EMPTY_PLAYER_NAME       "no name"
361
362 /* default name for unknown player names */
363 #define ANONYMOUS_NAME          "anonymous"
364
365 /* default for other unknown names */
366 #define UNKNOWN_NAME            "unknown"
367
368 /* default name for new levels */
369 #define NAMELESS_LEVEL_NAME     "nameless level"
370
371 /* default text for non-existant artwork */
372 #define NOT_AVAILABLE           "(not available)"
373
374 /* default value for undefined filename */
375 #define UNDEFINED_FILENAME      "[NONE]"
376
377 /* default value for undefined levelset */
378 #define UNDEFINED_LEVELSET      "[NONE]"
379
380 /* default value for undefined parameter */
381 #define ARG_DEFAULT             "[DEFAULT]"
382
383 /* default values for undefined configuration file parameters */
384 #define ARG_UNDEFINED           "-1000000"
385 #define ARG_UNDEFINED_VALUE     (-1000000)
386
387 /* default value for off-screen positions */
388 #define POS_OFFSCREEN           (-1000000)
389
390 /* definitions for game sub-directories */
391 #ifndef RO_GAME_DIR
392 #define RO_GAME_DIR             "."
393 #endif
394
395 #ifndef RW_GAME_DIR
396 #define RW_GAME_DIR             "."
397 #endif
398
399 #define RO_BASE_PATH            RO_GAME_DIR
400 #define RW_BASE_PATH            RW_GAME_DIR
401
402 /* directory names */
403 #define GRAPHICS_DIRECTORY      "graphics"
404 #define SOUNDS_DIRECTORY        "sounds"
405 #define MUSIC_DIRECTORY         "music"
406 #define LEVELS_DIRECTORY        "levels"
407 #define TAPES_DIRECTORY         "tapes"
408 #define SCORES_DIRECTORY        "scores"
409 #define DOCS_DIRECTORY          "docs"
410 #define CACHE_DIRECTORY         "cache"
411
412 #define GFX_CLASSIC_SUBDIR      "gfx_classic"
413 #define SND_CLASSIC_SUBDIR      "snd_classic"
414 #define MUS_CLASSIC_SUBDIR      "mus_classic"
415
416 #define GFX_DEFAULT_SUBDIR      (setup.internal.default_graphics_set)
417 #define SND_DEFAULT_SUBDIR      (setup.internal.default_sounds_set)
418 #define MUS_DEFAULT_SUBDIR      (setup.internal.default_music_set)
419
420 #define GFX_FALLBACK_FILENAME   (setup.internal.fallback_graphics_file)
421 #define SND_FALLBACK_FILENAME   (setup.internal.fallback_sounds_file)
422 #define MUS_FALLBACK_FILENAME   (setup.internal.fallback_music_file)
423
424 #define DEFAULT_LEVELSET        (setup.internal.default_level_series)
425
426 /* file names and filename extensions */
427 #define LEVELSETUP_DIRECTORY    "levelsetup"
428 #define SETUP_FILENAME          "setup.conf"
429 #define LEVELSETUP_FILENAME     "levelsetup.conf"
430 #define EDITORSETUP_FILENAME    "editorsetup.conf"
431 #define EDITORCASCADE_FILENAME  "editorcascade.conf"
432 #define HELPANIM_FILENAME       "helpanim.conf"
433 #define HELPTEXT_FILENAME       "helptext.conf"
434 #define LEVELINFO_FILENAME      "levelinfo.conf"
435 #define GRAPHICSINFO_FILENAME   "graphicsinfo.conf"
436 #define SOUNDSINFO_FILENAME     "soundsinfo.conf"
437 #define MUSICINFO_FILENAME      "musicinfo.conf"
438 #define ARTWORKINFO_CACHE_FILE  "artworkinfo.cache"
439 #define LEVELFILE_EXTENSION     "level"
440 #define TAPEFILE_EXTENSION      "tape"
441 #define SCOREFILE_EXTENSION     "score"
442
443 #define LOG_OUT_BASENAME        "stdout.txt"
444 #define LOG_ERR_BASENAME        "stderr.txt"
445
446 #define LOG_OUT_ID              0
447 #define LOG_ERR_ID              1
448 #define NUM_LOGS                2
449
450 #define STRING_PARENT_DIRECTORY         ".."
451 #define STRING_TOP_DIRECTORY            "/"
452
453 #define CHAR_PATH_SEPARATOR_UNIX        '/'
454 #define CHAR_PATH_SEPARATOR_DOS         '\\'
455
456 #define STRING_PATH_SEPARATOR_UNIX      "/"
457 #define STRING_PATH_SEPARATOR_DOS       "\\"
458
459 #define STRING_NEWLINE_UNIX             "\n"
460 #define STRING_NEWLINE_DOS              "\r\n"
461
462 #if defined(PLATFORM_WIN32)
463 #define CHAR_PATH_SEPARATOR     CHAR_PATH_SEPARATOR_DOS
464 #define STRING_PATH_SEPARATOR   STRING_PATH_SEPARATOR_DOS
465 #define STRING_NEWLINE          STRING_NEWLINE_DOS
466 #else
467 #define CHAR_PATH_SEPARATOR     CHAR_PATH_SEPARATOR_UNIX
468 #define STRING_PATH_SEPARATOR   STRING_PATH_SEPARATOR_UNIX
469 #define STRING_NEWLINE          STRING_NEWLINE_UNIX
470 #endif
471
472
473 /* areas in bitmap PIX_DOOR */
474 /* meaning in PIX_DB_DOOR: (3 PAGEs)
475    PAGEX1: 1. buffer for DOOR_1
476    PAGEX2: 2. buffer for DOOR_1
477    PAGEX3: buffer for animations
478 */
479
480 /* these values are hard-coded to be able to use them in initialization */
481 #define DOOR_GFX_PAGE_WIDTH     100     /* should be set to "gfx.dxsize" */
482 #define DOOR_GFX_PAGE_HEIGHT    280     /* should be set to "gfx.dysize" */
483
484 #define DOOR_GFX_PAGESIZE       (DOOR_GFX_PAGE_WIDTH)
485 #define DOOR_GFX_PAGEX1         (0 * DOOR_GFX_PAGESIZE)
486 #define DOOR_GFX_PAGEX2         (1 * DOOR_GFX_PAGESIZE)
487 #define DOOR_GFX_PAGEX3         (2 * DOOR_GFX_PAGESIZE)
488 #define DOOR_GFX_PAGEX4         (3 * DOOR_GFX_PAGESIZE)
489 #define DOOR_GFX_PAGEX5         (4 * DOOR_GFX_PAGESIZE)
490 #define DOOR_GFX_PAGEX6         (5 * DOOR_GFX_PAGESIZE)
491 #define DOOR_GFX_PAGEX7         (6 * DOOR_GFX_PAGESIZE)
492 #define DOOR_GFX_PAGEX8         (7 * DOOR_GFX_PAGESIZE)
493 #define DOOR_GFX_PAGEY1         (0)
494 #define DOOR_GFX_PAGEY2         (DOOR_GFX_PAGE_HEIGHT)
495
496
497 /* macros for version handling */
498 #define VERSION_MAJOR(x)        ((x) / 1000000)
499 #define VERSION_MINOR(x)        (((x) % 1000000) / 10000)
500 #define VERSION_PATCH(x)        (((x) % 10000) / 100)
501 #define VERSION_BUILD(x)        ((x) % 100)
502 #define VERSION_IDENT(a,b,c,d)  ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
503
504
505 /* macros for parent/child process identification */
506 #if defined(PLATFORM_UNIX)
507 #define IS_PARENT_PROCESS()     (audio.mixer_pid != getpid())
508 #define IS_CHILD_PROCESS()      (audio.mixer_pid == getpid())
509 #define HAS_CHILD_PROCESS()     (audio.mixer_pid > 0)
510 #else
511 #define IS_PARENT_PROCESS()     TRUE
512 #define IS_CHILD_PROCESS()      FALSE
513 #define HAS_CHILD_PROCESS()     FALSE
514 #endif
515
516
517 /* values for artwork type */
518 #define ARTWORK_TYPE_GRAPHICS   0
519 #define ARTWORK_TYPE_SOUNDS     1
520 #define ARTWORK_TYPE_MUSIC      2
521
522 #define NUM_ARTWORK_TYPES       3
523
524
525 /* values for tree type (chosen to match artwork type) */
526 #define TREE_TYPE_UNDEFINED     -1
527 #define TREE_TYPE_GRAPHICS_DIR  ARTWORK_TYPE_GRAPHICS
528 #define TREE_TYPE_SOUNDS_DIR    ARTWORK_TYPE_SOUNDS
529 #define TREE_TYPE_MUSIC_DIR     ARTWORK_TYPE_MUSIC
530 #define TREE_TYPE_LEVEL_DIR     3
531 #define TREE_TYPE_LEVEL_NR      4
532
533 #define NUM_TREE_TYPES          5
534
535 #define INFOTEXT_UNDEFINED      ""
536 #define INFOTEXT_GRAPHICS_DIR   "Custom Graphics"
537 #define INFOTEXT_SOUNDS_DIR     "Custom Sounds"
538 #define INFOTEXT_MUSIC_DIR      "Custom Music"
539 #define INFOTEXT_LEVEL_DIR      "Level Sets"
540 #define INFOTEXT_LEVEL_NR       "Levels"
541
542 #define TREE_INFOTEXT(t)        ((t) == TREE_TYPE_LEVEL_NR ?            \
543                                  INFOTEXT_LEVEL_NR :                    \
544                                  (t) == TREE_TYPE_LEVEL_DIR ?           \
545                                  INFOTEXT_LEVEL_DIR :                   \
546                                  (t) == TREE_TYPE_GRAPHICS_DIR ?        \
547                                  INFOTEXT_GRAPHICS_DIR :                \
548                                  (t) == TREE_TYPE_SOUNDS_DIR ?          \
549                                  INFOTEXT_SOUNDS_DIR :                  \
550                                  (t) == TREE_TYPE_MUSIC_DIR ?           \
551                                  INFOTEXT_MUSIC_DIR :                   \
552                                  INFOTEXT_UNDEFINED)
553
554 /* values for artwork handling */
555 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type)                        \
556                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
557                                  &(leveldir)->graphics_set :            \
558                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
559                                  &(leveldir)->sounds_set :              \
560                                  &(leveldir)->music_set)
561
562 #define LEVELDIR_ARTWORK_SET(leveldir, type)                            \
563                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
564                                  (leveldir)->graphics_set :             \
565                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
566                                  (leveldir)->sounds_set :               \
567                                  (leveldir)->music_set)
568
569 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type)                       \
570                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
571                                  &(leveldir)->graphics_path :           \
572                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
573                                  &(leveldir)->sounds_path :             \
574                                  &(leveldir)->music_path)
575
576 #define LEVELDIR_ARTWORK_PATH(leveldir, type)                           \
577                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
578                                  (leveldir)->graphics_path :            \
579                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
580                                  (leveldir)->sounds_path :              \
581                                  (leveldir)->music_path)
582
583 #define SETUP_ARTWORK_SET(setup, type)                                  \
584                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
585                                  (setup).graphics_set :                 \
586                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
587                                  (setup).sounds_set :                   \
588                                  (setup).music_set)
589
590 #define SETUP_OVERRIDE_ARTWORK(setup, type)                             \
591                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
592                                  (setup).override_level_graphics :      \
593                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
594                                  (setup).override_level_sounds :        \
595                                  (setup).override_level_music)
596
597 #define GFX_OVERRIDE_ARTWORK(type)                                      \
598                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
599                                  gfx.override_level_graphics :          \
600                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
601                                  gfx.override_level_sounds :            \
602                                  gfx.override_level_music)
603
604 #define ARTWORK_FIRST_NODE(artwork, type)                               \
605                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
606                                  (artwork).gfx_first :                  \
607                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
608                                  (artwork).snd_first :                  \
609                                  (artwork).mus_first)
610
611 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type)                   \
612                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
613                                  &(artwork).gfx_current_identifier :    \
614                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
615                                  &(artwork).snd_current_identifier :    \
616                                  &(artwork).mus_current_identifier)
617
618 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type)                       \
619                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
620                                  (artwork).gfx_current_identifier :     \
621                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
622                                  (artwork).snd_current_identifier :     \
623                                  (artwork).mus_current_identifier)
624
625 #define ARTWORKINFO_FILENAME(type)                                      \
626                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
627                                  GRAPHICSINFO_FILENAME :                \
628                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
629                                  SOUNDSINFO_FILENAME :                  \
630                                  (type) == ARTWORK_TYPE_MUSIC ?         \
631                                  MUSICINFO_FILENAME : "")
632
633 #define ARTWORK_DIRECTORY(type)                                         \
634                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
635                                  GRAPHICS_DIRECTORY :                   \
636                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
637                                  SOUNDS_DIRECTORY :                     \
638                                  (type) == ARTWORK_TYPE_MUSIC ?         \
639                                  MUSIC_DIRECTORY : "")
640
641 #define OPTIONS_ARTWORK_DIRECTORY(type)                                 \
642                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
643                                  options.graphics_directory :           \
644                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
645                                  options.sounds_directory :             \
646                                  (type) == ARTWORK_TYPE_MUSIC ?         \
647                                  options.music_directory : "")
648
649 #define UPDATE_BUSY_STATE()                     \
650 {                                               \
651   if (gfx.draw_busy_anim_function != NULL)      \
652     gfx.draw_busy_anim_function();              \
653 }
654
655
656 /* type definitions */
657 #if defined(TARGET_SDL2)
658 typedef int (*EventFilter)(void *, Event *);
659 #else
660 typedef int (*EventFilter)(const Event *);
661 #endif
662
663
664 /* structure definitions */
665
666 struct ProgramInfo
667 {
668   char *command_basepath;       /* path to the program binary */
669   char *command_basename;       /* base filename of the program binary */
670
671   char *config_filename;        /* optional global program config filename */
672
673   char *maindata_path;          /* main game data (installation) directory */
674
675   char *userdata_subdir;        /* personal user game data directory */
676   char *userdata_path;          /* resulting full path to game data directory */
677
678   char *program_title;
679   char *window_title;
680   char *icon_title;
681
682   char *icon_filename;
683
684   char *cookie_prefix;
685
686   char *log_filename[NUM_LOGS];         /* log filenames for out/err messages */
687   FILE *log_file[NUM_LOGS];             /* log file handles for out/err files */
688   FILE *log_file_default[NUM_LOGS];     /* default log file handles (out/err) */
689
690   int version_major;
691   int version_minor;
692   int version_patch;
693   int version_build;
694   int version_ident;
695
696   char *(*window_title_function)(void);
697   void (*exit_message_function)(char *, va_list);
698   void (*exit_function)(int);
699 };
700
701 struct OptionInfo
702 {
703   char *display_name;
704   char *server_host;
705   int server_port;
706
707   char *ro_base_directory;
708   char *rw_base_directory;
709   char *level_directory;
710   char *graphics_directory;
711   char *sounds_directory;
712   char *music_directory;
713   char *docs_directory;
714
715   char *execute_command;
716
717   char *special_flags;
718
719   boolean serveronly;
720   boolean network;
721   boolean verbose;
722   boolean debug;
723 };
724
725 struct ScreenModeInfo
726 {
727   int width, height;
728 };
729
730 struct VideoSystemInfo
731 {
732   int default_depth;
733   int width, height, depth;
734   int window_width, window_height;
735
736   boolean fullscreen_available;
737   boolean fullscreen_enabled;
738   boolean fullscreen_initial;
739   struct ScreenModeInfo *fullscreen_modes;
740   char *fullscreen_mode_current;
741
742   boolean window_scaling_available;
743   int window_scaling_percent;
744   char *window_scaling_quality;
745
746   boolean initialized;
747 };
748
749 struct AudioSystemInfo
750 {
751   boolean sound_available;
752   boolean loops_available;
753   boolean music_available;
754
755   boolean sound_enabled;
756   boolean sound_deactivated;    /* for temporarily disabling sound */
757
758   int mixer_pipe[2];
759   int mixer_pid;
760   char *device_name;
761   int device_fd;
762
763   int num_channels;
764   int music_channel;
765   int first_sound_channel;
766 };
767
768 struct FontBitmapInfo
769 {
770   Bitmap *bitmap;
771
772   int src_x, src_y;             /* start position of animation frames */
773   int width, height;            /* width/height of each animation frame */
774
775   int draw_xoffset;             /* offset for drawing font characters */
776   int draw_yoffset;             /* offset for drawing font characters */
777
778   int num_chars;
779   int num_chars_per_line;
780 };
781
782 struct GfxInfo
783 {
784   int sx, sy;
785   int sxsize, sysize;
786   int real_sx, real_sy;
787   int full_sxsize, full_sysize;
788   int scrollbuffer_width, scrollbuffer_height;
789
790   int game_tile_size, standard_tile_size;
791
792   int dx, dy;
793   int dxsize, dysize;
794
795   int vx, vy;
796   int vxsize, vysize;
797
798   int ex, ey;
799   int exsize, eysize;
800
801   int win_xsize, win_ysize;
802
803   int draw_deactivation_mask;
804   int draw_background_mask;
805
806   Bitmap *field_save_buffer;
807
808   Bitmap *background_bitmap;
809   int background_bitmap_mask;
810
811 #if USE_FINAL_SCREEN_BITMAP
812   Bitmap *final_screen_bitmap;
813 #endif
814
815   boolean clipping_enabled;
816   int clip_x, clip_y;
817   int clip_width, clip_height;
818
819   boolean override_level_graphics;
820   boolean override_level_sounds;
821   boolean override_level_music;
822
823   boolean draw_init_text;
824
825   int num_fonts;
826   struct FontBitmapInfo *font_bitmap_info;
827   int (*select_font_function)(int);
828   int (*get_font_from_token_function)(char *);
829
830   int anim_random_frame;
831
832   void (*draw_busy_anim_function)(void);
833   void (*draw_global_anim_function)(int);
834   void (*draw_global_border_function)(int);
835
836   int cursor_mode;
837 };
838
839 struct JoystickInfo
840 {
841   int status;
842   int fd[MAX_PLAYERS];          /* file descriptor of player's joystick */
843 };
844
845 struct SetupJoystickInfo
846 {
847   char *device_name;            /* device name of player's joystick */
848
849   int xleft, xmiddle, xright;
850   int yupper, ymiddle, ylower;
851   int snap, drop;
852 };
853
854 struct SetupKeyboardInfo
855 {
856   Key left, right, up, down;
857   Key snap, drop;
858 };
859
860 struct SetupTouchInfo
861 {
862   char *control_type;
863   int move_distance;
864   int drop_distance;
865 };
866
867 struct SetupInputInfo
868 {
869   boolean use_joystick;
870   struct SetupJoystickInfo joy;
871   struct SetupKeyboardInfo key;
872 };
873
874 struct SetupEditorInfo
875 {
876   boolean el_boulderdash;
877   boolean el_emerald_mine;
878   boolean el_emerald_mine_club;
879   boolean el_more;
880   boolean el_sokoban;
881   boolean el_supaplex;
882   boolean el_diamond_caves;
883   boolean el_dx_boulderdash;
884   boolean el_chars;
885   boolean el_steel_chars;
886   boolean el_custom;
887   boolean el_user_defined;
888   boolean el_dynamic;
889
890   boolean el_headlines;
891
892   boolean el_by_game;
893   boolean el_by_type;
894
895   boolean show_element_token;
896 };
897
898 struct SetupEditorCascadeInfo
899 {
900   boolean el_bd;
901   boolean el_em;
902   boolean el_emc;
903   boolean el_rnd;
904   boolean el_sb;
905   boolean el_sp;
906   boolean el_dc;
907   boolean el_dx;
908   boolean el_chars;
909   boolean el_steel_chars;
910   boolean el_ce;
911   boolean el_ge;
912   boolean el_ref;
913   boolean el_user;
914   boolean el_dynamic;
915 };
916
917 struct SetupShortcutInfo
918 {
919   Key save_game;
920   Key load_game;
921   Key toggle_pause;
922
923   Key focus_player[MAX_PLAYERS];
924   Key focus_player_all;
925
926   Key tape_eject;
927   Key tape_extra;
928   Key tape_stop;
929   Key tape_pause;
930   Key tape_record;
931   Key tape_play;
932
933   Key sound_simple;
934   Key sound_loops;
935   Key sound_music;
936
937   Key snap_left;
938   Key snap_right;
939   Key snap_up;
940   Key snap_down;
941 };
942
943 struct SetupSystemInfo
944 {
945   char *sdl_videodriver;
946   char *sdl_audiodriver;
947   int audio_fragment_size;
948 };
949
950 struct SetupInternalInfo
951 {
952   char *program_title;
953   char *program_author;
954   char *program_email;
955   char *program_website;
956   char *program_copyright;
957   char *program_company;
958
959   char *program_icon_file;
960
961   char *default_graphics_set;
962   char *default_sounds_set;
963   char *default_music_set;
964
965   char *fallback_graphics_file;
966   char *fallback_sounds_file;
967   char *fallback_music_file;
968
969   char *default_level_series;
970
971   boolean choose_from_top_leveldir;
972 };
973
974 struct SetupInfo
975 {
976   char *player_name;
977
978   boolean sound;
979   boolean sound_loops;
980   boolean sound_music;
981   boolean sound_simple;
982   boolean toons;
983   boolean scroll_delay;
984   boolean scroll_delay_value;
985   char *engine_snapshot_mode;
986   boolean fade_screens;
987   boolean autorecord;
988   boolean show_titlescreen;
989   boolean quick_doors;
990   boolean team_mode;
991   boolean handicap;
992   boolean skip_levels;
993   boolean time_limit;
994   boolean fullscreen;
995   char *fullscreen_mode;
996   int window_scaling_percent;
997   char *window_scaling_quality;
998   boolean ask_on_escape;
999   boolean ask_on_escape_editor;
1000   boolean quick_switch;
1001   boolean input_on_focus;
1002   boolean prefer_aga_graphics;
1003   int game_frame_delay;
1004   boolean sp_show_border_elements;
1005   boolean small_game_graphics;
1006   boolean show_snapshot_buttons;
1007
1008   char *graphics_set;
1009   char *sounds_set;
1010   char *music_set;
1011   int override_level_graphics;          /* not boolean -- can also be "AUTO" */
1012   int override_level_sounds;            /* not boolean -- can also be "AUTO" */
1013   int override_level_music;             /* not boolean -- can also be "AUTO" */
1014
1015   int volume_simple;
1016   int volume_loops;
1017   int volume_music;
1018
1019   struct SetupEditorInfo editor;
1020   struct SetupEditorCascadeInfo editor_cascade;
1021   struct SetupShortcutInfo shortcut;
1022   struct SetupInputInfo input[MAX_PLAYERS];
1023   struct SetupTouchInfo touch;
1024   struct SetupSystemInfo system;
1025   struct SetupInternalInfo internal;
1026   struct OptionInfo options;
1027 };
1028
1029 struct TreeInfo
1030 {
1031   struct TreeInfo **node_top;           /* topmost node in tree */
1032   struct TreeInfo *node_parent;         /* parent level directory info */
1033   struct TreeInfo *node_group;          /* level group sub-directory info */
1034   struct TreeInfo *next;                /* next level series structure node */
1035
1036   int cl_first;         /* internal control field for setup screen */
1037   int cl_cursor;        /* internal control field for setup screen */
1038
1039   int type;             /* type of tree content */
1040
1041   /* fields for "type == TREE_TYPE_LEVEL_DIR" */
1042
1043   char *subdir;         /* tree info sub-directory basename (may be ".") */
1044   char *fullpath;       /* complete path relative to tree base directory */
1045   char *basepath;       /* absolute base path of tree base directory */
1046   char *identifier;     /* identifier string for configuration files */
1047   char *name;           /* tree info name, as displayed in selection menues */
1048   char *name_sorting;   /* optional sorting name for correct name sorting */
1049   char *author;         /* level or artwork author name */
1050   char *year;           /* optional year of creation for levels or artwork */
1051   char *imported_from;  /* optional comment for imported levels or artwork */
1052   char *imported_by;    /* optional comment for imported levels or artwork */
1053   char *tested_by;      /* optional comment to name people who tested a set */
1054
1055   char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */
1056   char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */
1057   char *graphics_set;   /* optional custom graphics set (level tree only) */
1058   char *sounds_set;     /* optional custom sounds set (level tree only) */
1059   char *music_set;      /* optional custom music set (level tree only) */
1060   char *graphics_path;  /* path to optional custom graphics set (level only) */
1061   char *sounds_path;    /* path to optional custom sounds set (level only) */
1062   char *music_path;     /* path to optional custom music set (level only) */
1063
1064   char *level_filename; /* filename of level file (for packed level file) */
1065   char *level_filetype; /* type of levels in level directory or level file */
1066
1067   char *special_flags;  /* flags for special actions performed on level file */
1068
1069   int levels;           /* number of levels in level series */
1070   int first_level;      /* first level number (to allow start with 0 or 1) */
1071   int last_level;       /* last level number (automatically calculated) */
1072   int sort_priority;    /* sort levels by 'sort_priority' and then by name */
1073
1074   boolean latest_engine;/* force level set to use the latest game engine */
1075
1076   boolean level_group;  /* directory contains more level series directories */
1077   boolean parent_link;  /* entry links back to parent directory */
1078   boolean in_user_dir;  /* user defined levels are stored in home directory */
1079   boolean user_defined; /* levels in user directory and marked as "private" */
1080   boolean readonly;     /* readonly levels can not be changed with editor */
1081   boolean handicap;     /* level set has no handicap when set to "false" */
1082   boolean skip_levels;  /* levels can be skipped when set to "true" */
1083
1084   int color;            /* color to use on selection screen for this level */
1085   char *class_desc;     /* description of level series class */
1086   int handicap_level;   /* number of the lowest unsolved level */
1087
1088   char *infotext;       /* optional text to describe the tree type (headline) */
1089 };
1090
1091 typedef struct TreeInfo TreeInfo;
1092 typedef struct TreeInfo LevelDirTree;
1093 typedef struct TreeInfo ArtworkDirTree;
1094 typedef struct TreeInfo GraphicsDirTree;
1095 typedef struct TreeInfo SoundsDirTree;
1096 typedef struct TreeInfo MusicDirTree;
1097
1098 struct ArtworkInfo
1099 {
1100   GraphicsDirTree *gfx_first;
1101   GraphicsDirTree *gfx_current;
1102   SoundsDirTree *snd_first;
1103   SoundsDirTree *snd_current;
1104   MusicDirTree *mus_first;
1105   MusicDirTree *mus_current;
1106
1107   char *gfx_current_identifier;
1108   char *snd_current_identifier;
1109   char *mus_current_identifier;
1110 };
1111
1112 struct ValueTextInfo
1113 {
1114   int value;
1115   char *text;
1116 };
1117
1118 struct ConfigInfo
1119 {
1120   char *token;
1121   char *value;
1122 };
1123
1124 struct ConfigTypeInfo
1125 {
1126   char *token;
1127   char *value;
1128   int type;
1129 };
1130
1131 struct TokenIntPtrInfo
1132 {
1133   char *token;
1134   int *value;
1135 };
1136
1137 struct FileInfo
1138 {
1139   char *token;
1140
1141   char *default_filename;
1142   char *filename;
1143
1144   char **default_parameter;                     /* array of file parameters */
1145   char **parameter;                             /* array of file parameters */
1146
1147   boolean redefined;
1148   boolean fallback_to_default;
1149   boolean default_is_cloned;
1150 };
1151
1152 struct SetupFileList
1153 {
1154   char *token;
1155   char *value;
1156
1157   struct SetupFileList *next;
1158 };
1159
1160 struct ListNodeInfo
1161 {
1162   char *source_filename;                        /* primary key for node list */
1163   int num_references;
1164 };
1165
1166 struct PropertyMapping
1167 {
1168   int base_index;
1169   int ext1_index;
1170   int ext2_index;
1171   int ext3_index;
1172
1173   int artwork_index;
1174 };
1175
1176 struct ArtworkListInfo
1177 {
1178   int type;                                     /* type of artwork */
1179
1180   int num_file_list_entries;
1181   int num_dynamic_file_list_entries;
1182   struct FileInfo *file_list;                   /* static artwork file array */
1183   struct FileInfo *dynamic_file_list;           /* dynamic artwrk file array */
1184
1185   int num_suffix_list_entries;
1186   struct ConfigTypeInfo *suffix_list;           /* parameter suffixes array */
1187
1188   int num_base_prefixes;
1189   int num_ext1_suffixes;
1190   int num_ext2_suffixes;
1191   int num_ext3_suffixes;
1192   char **base_prefixes;                         /* base token prefixes array */
1193   char **ext1_suffixes;                         /* property suffixes array 1 */
1194   char **ext2_suffixes;                         /* property suffixes array 2 */
1195   char **ext3_suffixes;                         /* property suffixes array 3 */
1196
1197   int num_ignore_tokens;
1198   char **ignore_tokens;                         /* file tokens to be ignored */
1199
1200   int num_property_mapping_entries;
1201   struct PropertyMapping *property_mapping;     /* mapping token -> artwork */
1202
1203   int sizeof_artwork_list_entry;
1204
1205   struct ListNodeInfo **artwork_list;           /* static artwork node array */
1206   struct ListNodeInfo **dynamic_artwork_list;   /* dynamic artwrk node array */
1207   struct ListNode *content_list;                /* dynamic artwork node list */
1208
1209   void *(*load_artwork)(char *);                /* constructor function */
1210   void (*free_artwork)(void *);                 /* destructor function */
1211 };
1212
1213 struct XY
1214 {
1215   int x, y;
1216 };
1217
1218 struct Rect
1219 {
1220   int x, y;
1221   int width, height;
1222 };
1223
1224 struct RectWithBorder
1225 {
1226   int x, y;
1227   int width, height;
1228   int border_size;
1229 };
1230
1231 struct MenuPosInfo
1232 {
1233   int x, y;
1234   int width, height;
1235   int align, valign;
1236 };
1237
1238 struct DoorPartPosInfo
1239 {
1240   int x, y;
1241   int step_xoffset;
1242   int step_yoffset;
1243   int step_delay;
1244   int start_step;
1245   int start_step_opening;
1246   int start_step_closing;
1247   boolean draw_masked;
1248   int sort_priority;
1249 };
1250
1251 struct TextPosInfo
1252 {
1253   int x, y;
1254   int xoffset;                  /* special case for tape date and time */
1255   int xoffset2;                 /* special case for tape date */
1256   int width, height;
1257   int align, valign;
1258   int size;                     /* also used for suffix ".digits" */
1259   int font, font_alt;
1260   boolean draw_masked;
1261   boolean draw_player;          /* special case for network player buttons */
1262   int sort_priority;            /* also used for suffix ".draw_order" */
1263   int id;
1264 };
1265
1266 struct LevelStats
1267 {
1268   int played;
1269   int solved;
1270 };
1271
1272
1273 /* ========================================================================= */
1274 /* exported variables                                                        */
1275 /* ========================================================================= */
1276
1277 extern struct ProgramInfo       program;
1278 extern struct OptionInfo        options;
1279 extern struct VideoSystemInfo   video;
1280 extern struct AudioSystemInfo   audio;
1281 extern struct GfxInfo           gfx;
1282 extern struct AnimInfo          anim;
1283 extern struct ArtworkInfo       artwork;
1284 extern struct JoystickInfo      joystick;
1285 extern struct SetupInfo         setup;
1286
1287 extern LevelDirTree            *leveldir_first_all;
1288 extern LevelDirTree            *leveldir_first;
1289 extern LevelDirTree            *leveldir_current;
1290 extern int                      level_nr;
1291
1292 extern struct LevelStats        level_stats[];
1293
1294 extern DrawWindow              *window;
1295 extern DrawBuffer              *backbuffer;
1296 extern DrawBuffer              *drawto;
1297
1298 extern int                      button_status;
1299 extern boolean                  motion_status;
1300 #if defined(TARGET_SDL2)
1301 extern boolean                  keyrepeat_status;
1302 #endif
1303
1304 extern int                      redraw_mask;
1305
1306 extern int                      FrameCounter;
1307
1308
1309 /* function definitions */
1310
1311 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1312                      int);
1313
1314 void SetWindowTitle();
1315
1316 void InitWindowTitleFunction(char *(*window_title_function)(void));
1317 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
1318 void InitExitFunction(void (*exit_function)(int));
1319 void InitPlatformDependentStuff(void);
1320 void ClosePlatformDependentStuff(void);
1321
1322 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1323 void InitGfxTileSizeInfo(int, int);
1324 void InitGfxDoor1Info(int, int, int, int);
1325 void InitGfxDoor2Info(int, int, int, int);
1326 void InitGfxDoor3Info(int, int, int, int);
1327 void InitGfxWindowInfo(int, int);
1328 void InitGfxScrollbufferInfo(int, int);
1329 void InitGfxClipRegion(boolean, int, int, int, int);
1330 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
1331 void InitGfxDrawGlobalAnimFunction(void (*draw_global_anim_function)(int));
1332 void InitGfxDrawGlobalBorderFunction(void (*draw_global_border_function)(int));
1333 void InitGfxCustomArtworkInfo();
1334 void InitGfxOtherSettings();
1335 void SetDrawDeactivationMask(int);
1336 void SetDrawBackgroundMask(int);
1337 void SetWindowBackgroundBitmap(Bitmap *);
1338 void SetMainBackgroundBitmap(Bitmap *);
1339 void SetDoorBackgroundBitmap(Bitmap *);
1340 void SetRedrawMaskFromArea(int, int, int, int);
1341
1342 void LimitScreenUpdates(boolean);
1343
1344 void InitVideoDisplay(void);
1345 void CloseVideoDisplay(void);
1346 void InitVideoBuffer(int, int, int, boolean);
1347 Bitmap *CreateBitmapStruct(void);
1348 Bitmap *CreateBitmap(int, int, int);
1349 void ReCreateBitmap(Bitmap **, int, int, int);
1350 void FreeBitmap(Bitmap *);
1351 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1352 void BlitBitmapTiled(Bitmap *, Bitmap *, int, int, int, int, int, int, int,int);
1353 void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int,
1354                    void (*draw_border_function)(void));
1355 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1356 void ClearRectangle(Bitmap *, int, int, int, int);
1357 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1358 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1359 boolean DrawingOnBackground(int, int);
1360 boolean DrawingAreaChanged();
1361 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1362 void BlitTexture(Bitmap *, int, int, int, int, int, int);
1363 void BlitTextureMasked(Bitmap *, int, int, int, int, int, int);
1364 void BlitToScreen(Bitmap *, int, int, int, int, int, int);
1365 void BlitToScreenMasked(Bitmap *, int, int, int, int, int, int);
1366 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1367 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1368 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1369 Pixel GetPixel(Bitmap *, int, int);
1370 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1371 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1372
1373 void KeyboardAutoRepeatOn(void);
1374 void KeyboardAutoRepeatOff(void);
1375 boolean SetVideoMode(boolean);
1376 boolean ChangeVideoModeIfNeeded(boolean);
1377
1378 Bitmap *LoadImage(char *);
1379 Bitmap *LoadCustomImage(char *);
1380 void ReloadCustomImage(Bitmap *, char *);
1381
1382 Bitmap *ZoomBitmap(Bitmap *, int, int);
1383 void ReCreateGameTileSizeBitmap(Bitmap **);
1384 void CreateBitmapWithSmallBitmaps(Bitmap **, int, int);
1385 void CreateBitmapTextures(Bitmap **);
1386 void FreeBitmapTextures(Bitmap **);
1387 void ScaleBitmap(Bitmap **, int);
1388
1389 void SetMouseCursor(int);
1390
1391 void OpenAudio(void);
1392 void CloseAudio(void);
1393 void SetAudioMode(boolean);
1394
1395 void InitEventFilter(EventFilter);
1396 boolean PendingEvent(void);
1397 void NextEvent(Event *event);
1398 void PeekEvent(Event *event);
1399 Key GetEventKey(KeyEvent *, boolean);
1400 KeyMod HandleKeyModState(Key, int);
1401 KeyMod GetKeyModState();
1402 KeyMod GetKeyModStateFromEvents();
1403 boolean CheckCloseWindowEvent(ClientMessageEvent *);
1404
1405 void InitJoysticks();
1406 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1407
1408 #endif /* SYSTEM_H */