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