1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
19 #if defined(PLATFORM_MACOSX)
21 #elif defined(PLATFORM_WIN32)
23 #elif defined(PLATFORM_ANDROID)
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"
35 #define DEFAULT_DEPTH 0
39 #define BLIT_INVERSE 2
40 #define BLIT_ON_BACKGROUND 3
42 /* values for fullscreen status */
43 #define FULLSCREEN_NOT_AVAILABLE FALSE
44 #define FULLSCREEN_AVAILABLE TRUE
46 /* values for window scaling */
47 #define WINDOW_SCALING_NOT_AVAILABLE FALSE
48 #define WINDOW_SCALING_AVAILABLE TRUE
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
55 /* values for window scaling quality */
56 #define SCALING_QUALITY_NEAREST "nearest"
57 #define SCALING_QUALITY_LINEAR "linear"
58 #define SCALING_QUALITY_BEST "best"
60 #define SCALING_QUALITY_DEFAULT SCALING_QUALITY_LINEAR
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"
68 #if defined(TARGET_SDL2)
69 #define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_DOUBLE
71 #define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_BITMAP
74 #define SPECIAL_RENDERING_OFF 0
75 #define SPECIAL_RENDERING_BITMAP 1
76 #define SPECIAL_RENDERING_TARGET 2
77 #define SPECIAL_RENDERING_DOUBLE 3
79 #if defined(TARGET_SDL2)
80 #define SPECIAL_RENDERING_DEFAULT SPECIAL_RENDERING_DOUBLE
82 #define SPECIAL_RENDERING_DEFAULT SPECIAL_RENDERING_BITMAP
85 /* values for touch control */
86 #define TOUCH_CONTROL_OFF "off"
87 #define TOUCH_CONTROL_VIRTUAL_BUTTONS "virtual_buttons"
88 #define TOUCH_CONTROL_WIPE_GESTURES "wipe_gestures"
89 #define TOUCH_CONTROL_FOLLOW_FINGER "follow_finger"
91 #if defined(PLATFORM_ANDROID)
92 #define TOUCH_CONTROL_DEFAULT TOUCH_CONTROL_VIRTUAL_BUTTONS
94 #define TOUCH_CONTROL_DEFAULT TOUCH_CONTROL_OFF
97 #define TOUCH_MOVE_DISTANCE_DEFAULT 2
98 #define TOUCH_DROP_DISTANCE_DEFAULT 5
99 #define TOUCH_TRANSPARENCY_DEFAULT 50
101 #define ALPHA_FROM_TRANSPARENCY(x) ((100 - x) * SDL_ALPHA_OPAQUE / 100)
102 #define ALPHA_FADING_STEPSIZE(x) ((x) / 25)
104 /* values for special settings for mobile devices */
105 #if defined(PLATFORM_ANDROID)
106 #define USE_TOUCH_INPUT_OVERLAY
107 #define USE_COMPLETE_DISPLAY
108 #define HAS_SCREEN_KEYBOARD
109 #define SCREEN_KEYBOARD_POS(h) ((h) / 2)
112 /* default input keys */
113 #define DEFAULT_KEY_LEFT KSYM_Left
114 #define DEFAULT_KEY_RIGHT KSYM_Right
115 #define DEFAULT_KEY_UP KSYM_Up
116 #define DEFAULT_KEY_DOWN KSYM_Down
117 #if defined(PLATFORM_MACOSX)
118 #define DEFAULT_KEY_SNAP KSYM_Control_L
119 #define DEFAULT_KEY_DROP KSYM_KP_Enter
121 #define DEFAULT_KEY_SNAP KSYM_Control_L
122 #define DEFAULT_KEY_DROP KSYM_Control_R
124 #define DEFAULT_KEY_OKAY KSYM_Return
125 #define DEFAULT_KEY_CANCEL KSYM_Escape
127 /* default shortcut keys */
128 #define DEFAULT_KEY_SAVE_GAME KSYM_F1
129 #define DEFAULT_KEY_LOAD_GAME KSYM_F2
130 #define DEFAULT_KEY_TOGGLE_PAUSE KSYM_space
131 #define DEFAULT_KEY_FOCUS_PLAYER_1 KSYM_F5
132 #define DEFAULT_KEY_FOCUS_PLAYER_2 KSYM_F6
133 #define DEFAULT_KEY_FOCUS_PLAYER_3 KSYM_F7
134 #define DEFAULT_KEY_FOCUS_PLAYER_4 KSYM_F8
135 #define DEFAULT_KEY_FOCUS_PLAYER_ALL KSYM_F9
136 #define DEFAULT_KEY_TAPE_EJECT KSYM_UNDEFINED
137 #define DEFAULT_KEY_TAPE_EXTRA KSYM_UNDEFINED
138 #define DEFAULT_KEY_TAPE_STOP KSYM_UNDEFINED
139 #define DEFAULT_KEY_TAPE_PAUSE KSYM_UNDEFINED
140 #define DEFAULT_KEY_TAPE_RECORD KSYM_UNDEFINED
141 #define DEFAULT_KEY_TAPE_PLAY KSYM_UNDEFINED
142 #define DEFAULT_KEY_SOUND_SIMPLE KSYM_UNDEFINED
143 #define DEFAULT_KEY_SOUND_LOOPS KSYM_UNDEFINED
144 #define DEFAULT_KEY_SOUND_MUSIC KSYM_UNDEFINED
145 #define DEFAULT_KEY_SNAP_LEFT KSYM_UNDEFINED
146 #define DEFAULT_KEY_SNAP_RIGHT KSYM_UNDEFINED
147 #define DEFAULT_KEY_SNAP_UP KSYM_UNDEFINED
148 #define DEFAULT_KEY_SNAP_DOWN KSYM_UNDEFINED
150 /* default debug setup keys and values */
151 #define DEFAULT_FRAME_DELAY_0 20 // 100 % speed
152 #define DEFAULT_FRAME_DELAY_1 500 // 4 % speed
153 #define DEFAULT_FRAME_DELAY_2 250 // 8 % speed
154 #define DEFAULT_FRAME_DELAY_3 125 // 16 % speed
155 #define DEFAULT_FRAME_DELAY_4 60 // 33 % speed
156 #define DEFAULT_FRAME_DELAY_5 40 // 50 % speed
157 #define DEFAULT_FRAME_DELAY_6 30 // 66 % speed
158 #define DEFAULT_FRAME_DELAY_7 10 // 200 % speed
159 #define DEFAULT_FRAME_DELAY_8 5 // 400 % speed
160 #define DEFAULT_FRAME_DELAY_9 0 // maximum speed
162 #define DEFAULT_KEY_FRAME_DELAY_0 KSYM_0
163 #define DEFAULT_KEY_FRAME_DELAY_1 KSYM_1
164 #define DEFAULT_KEY_FRAME_DELAY_2 KSYM_2
165 #define DEFAULT_KEY_FRAME_DELAY_3 KSYM_3
166 #define DEFAULT_KEY_FRAME_DELAY_4 KSYM_4
167 #define DEFAULT_KEY_FRAME_DELAY_5 KSYM_5
168 #define DEFAULT_KEY_FRAME_DELAY_6 KSYM_6
169 #define DEFAULT_KEY_FRAME_DELAY_7 KSYM_7
170 #define DEFAULT_KEY_FRAME_DELAY_8 KSYM_8
171 #define DEFAULT_KEY_FRAME_DELAY_9 KSYM_9
173 #define NUM_DEBUG_FRAME_DELAY_KEYS 10
175 #define DEFAULT_FRAME_DELAY_USE_MOD_KEY FALSE
176 #define DEFAULT_FRAME_DELAY_GAME_ONLY TRUE
178 /* values for key_status */
179 #define KEY_NOT_PRESSED FALSE
180 #define KEY_RELEASED FALSE
181 #define KEY_PRESSED TRUE
183 /* values for button status */
184 #define MB_NOT_PRESSED FALSE
185 #define MB_NOT_RELEASED TRUE
186 #define MB_RELEASED FALSE
187 #define MB_PRESSED TRUE
188 #define MB_MENU_CHOICE FALSE
189 #define MB_MENU_MARK TRUE
190 #define MB_MENU_INITIALIZE (-1)
191 #define MB_MENU_LEAVE (-2)
192 #define MB_LEFTBUTTON 1
193 #define MB_MIDDLEBUTTON 2
194 #define MB_RIGHTBUTTON 3
195 #define MB_WHEEL_UP 4
196 #define MB_WHEEL_DOWN 5
197 #define MB_WHEEL_LEFT 6
198 #define MB_WHEEL_RIGHT 7
199 #define IS_WHEEL_BUTTON_VERTICAL(b) ((b) == MB_WHEEL_UP || \
200 (b) == MB_WHEEL_DOWN)
201 #define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) == MB_WHEEL_LEFT || \
202 (b) == MB_WHEEL_RIGHT)
203 #define IS_WHEEL_BUTTON(b) (IS_WHEEL_BUTTON_VERTICAL(b) || \
204 IS_WHEEL_BUTTON_HORIZONTAL(b))
205 #define DEFAULT_WHEEL_STEPS 3
207 #define BUTTON_STEPSIZE(b) ((b) == MB_LEFTBUTTON ? 1 : \
208 (b) == MB_MIDDLEBUTTON ? 5 : \
209 (b) == MB_RIGHTBUTTON ? 10 : 1)
211 /* values for move directions */
212 #define MV_BIT_LEFT 0
213 #define MV_BIT_RIGHT 1
215 #define MV_BIT_DOWN 3
217 #define NUM_DIRECTIONS 4
219 /* diagonal movement directions are used in a different contect than buttons */
220 #define MV_BIT_UPLEFT 4
221 #define MV_BIT_UPRIGHT 5
222 #define MV_BIT_DOWNLEFT 6
223 #define MV_BIT_DOWNRIGHT 7
225 #define NUM_DIRECTIONS_FULL 8
227 /* values for special "button" bitmasks */
231 #define NUM_PLAYER_ACTIONS 6
233 /* values for special "focus player" bitmasks */
234 #define BIT_SET_FOCUS 6
236 /* values for drawing stages for global animations */
237 #define DRAW_GLOBAL_ANIM_STAGE_1 1
238 #define DRAW_GLOBAL_ANIM_STAGE_2 2
240 /* values for drawing target (various functions) */
241 #define DRAW_TO_BACKBUFFER 0
242 #define DRAW_TO_FIELDBUFFER 1
243 #define DRAW_TO_SCREEN 2
244 #define DRAW_TO_FADE_SOURCE 3
245 #define DRAW_TO_FADE_TARGET 4
247 /* values for move directions and special "button" key bitmasks */
249 #define MV_LEFT (1 << MV_BIT_LEFT)
250 #define MV_RIGHT (1 << MV_BIT_RIGHT)
251 #define MV_UP (1 << MV_BIT_UP)
252 #define MV_DOWN (1 << MV_BIT_DOWN)
254 #define MV_UPLEFT (MV_UP | MV_LEFT)
255 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
256 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
257 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
259 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
260 #define MV_VERTICAL (MV_UP | MV_DOWN)
261 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
262 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
263 #define MV_NO_DIRECTION (MV_NONE)
265 #define KEY_BUTTON_1 (1 << BUTTON_1)
266 #define KEY_BUTTON_2 (1 << BUTTON_2)
267 #define KEY_BUTTON_SNAP KEY_BUTTON_1
268 #define KEY_BUTTON_DROP KEY_BUTTON_2
269 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
270 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
271 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
273 #define KEY_SET_FOCUS (1 << BIT_SET_FOCUS)
275 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
276 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
277 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
278 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
279 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
282 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
283 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
284 (x) == MV_UP ? MV_BIT_UP : \
285 (x) == MV_DOWN ? MV_BIT_DOWN : \
286 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
287 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
288 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
289 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
292 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
293 (x) == MV_RIGHT ? MV_LEFT : \
294 (x) == MV_UP ? MV_DOWN : \
295 (x) == MV_DOWN ? MV_UP : \
296 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
297 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
298 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
299 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
302 /* values for animation mode (frame order and direction) */
303 /* (stored in level files -- never change existing values) */
305 #define ANIM_LOOP (1 << 0)
306 #define ANIM_LINEAR (1 << 1)
307 #define ANIM_PINGPONG (1 << 2)
308 #define ANIM_PINGPONG2 (1 << 3)
309 #define ANIM_RANDOM (1 << 4)
310 #define ANIM_CE_VALUE (1 << 5)
311 #define ANIM_CE_SCORE (1 << 6)
312 #define ANIM_CE_DELAY (1 << 7)
313 #define ANIM_REVERSE (1 << 8)
314 #define ANIM_OPAQUE_PLAYER (1 << 9)
316 /* values for special (non game element) animation modes */
317 /* (not stored in level files -- can be changed, if needed) */
318 #define ANIM_HORIZONTAL (1 << 10)
319 #define ANIM_VERTICAL (1 << 11)
320 #define ANIM_CENTERED (1 << 12)
321 #define ANIM_STATIC_PANEL (1 << 13)
322 #define ANIM_ALL (1 << 14)
323 #define ANIM_ONCE (1 << 15)
325 #define ANIM_DEFAULT ANIM_LOOP
327 /* values for special drawing styles (currently only for crumbled graphics) */
329 #define STYLE_ACCURATE_BORDERS (1 << 0)
330 #define STYLE_INNER_CORNERS (1 << 1)
331 #define STYLE_REVERSE (1 << 2)
333 #define STYLE_DEFAULT STYLE_NONE
335 /* values for special global animation events */
336 #define ANIM_EVENT_NONE 0
337 #define ANIM_EVENT_SELF (1 << 16)
338 #define ANIM_EVENT_ANY (1 << 17)
340 #define ANIM_EVENT_ANIM_BIT 0
341 #define ANIM_EVENT_PART_BIT 8
343 #define ANIM_EVENT_ANIM_MASK (0xff << ANIM_EVENT_ANIM_BIT)
344 #define ANIM_EVENT_PART_MASK (0xff << ANIM_EVENT_PART_BIT)
346 #define ANIM_EVENT_DEFAULT ANIM_EVENT_NONE
348 /* values for fade mode */
349 #define FADE_TYPE_NONE 0
350 #define FADE_TYPE_FADE_IN (1 << 0)
351 #define FADE_TYPE_FADE_OUT (1 << 1)
352 #define FADE_TYPE_TRANSFORM (1 << 2)
353 #define FADE_TYPE_CROSSFADE (1 << 3)
354 #define FADE_TYPE_MELT (1 << 4)
355 #define FADE_TYPE_CURTAIN (1 << 5)
356 #define FADE_TYPE_SKIP (1 << 6)
358 #define FADE_MODE_NONE (FADE_TYPE_NONE)
359 #define FADE_MODE_FADE_IN (FADE_TYPE_FADE_IN)
360 #define FADE_MODE_FADE_OUT (FADE_TYPE_FADE_OUT)
361 #define FADE_MODE_FADE (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT)
362 #define FADE_MODE_TRANSFORM (FADE_TYPE_TRANSFORM | FADE_TYPE_FADE_IN)
363 #define FADE_MODE_CROSSFADE (FADE_MODE_TRANSFORM | FADE_TYPE_CROSSFADE)
364 #define FADE_MODE_MELT (FADE_MODE_TRANSFORM | FADE_TYPE_MELT)
365 #define FADE_MODE_CURTAIN (FADE_MODE_TRANSFORM | FADE_TYPE_CURTAIN)
366 #define FADE_MODE_SKIP_FADE_IN (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN)
367 #define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT)
369 #define FADE_MODE_DEFAULT FADE_MODE_FADE
371 /* values for toon positions */
372 #define POS_UNDEFINED -1
383 /* values for text alignment */
384 #define ALIGN_LEFT (1 << 0)
385 #define ALIGN_RIGHT (1 << 1)
386 #define ALIGN_CENTER (1 << 2)
387 #define ALIGN_DEFAULT ALIGN_LEFT
389 #define VALIGN_TOP (1 << 0)
390 #define VALIGN_BOTTOM (1 << 1)
391 #define VALIGN_MIDDLE (1 << 2)
392 #define VALIGN_DEFAULT VALIGN_TOP
394 #define ALIGNED_XPOS(x,w,a) ((a) == ALIGN_CENTER ? (x) - (w) / 2 : \
395 (a) == ALIGN_RIGHT ? (x) - (w) : (x))
396 #define ALIGNED_YPOS(y,h,v) ((v) == VALIGN_MIDDLE ? (y) - (h) / 2 : \
397 (v) == VALIGN_BOTTOM ? (y) - (h) : (y))
398 #define ALIGNED_TEXT_XPOS(p) ALIGNED_XPOS((p)->x, (p)->width, (p)->align)
399 #define ALIGNED_TEXT_YPOS(p) ALIGNED_YPOS((p)->y, (p)->height, (p)->valign)
401 /* values for redraw_mask */
402 #define REDRAW_NONE (0)
403 #define REDRAW_ALL (1 << 0)
404 #define REDRAW_FIELD (1 << 1)
405 #define REDRAW_DOOR_1 (1 << 2)
406 #define REDRAW_DOOR_2 (1 << 3)
407 #define REDRAW_DOOR_3 (1 << 4)
408 #define REDRAW_FPS (1 << 5)
410 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
414 #define IN_GFX_FIELD_PLAY(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
415 y >= gfx.sy && y < gfx.sy + gfx.sysize)
416 #define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \
417 x < gfx.real_sx + gfx.full_sxsize && \
418 y >= gfx.real_sy && \
419 y < gfx.real_sy + gfx.full_sysize)
420 #define IN_GFX_DOOR_1(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
421 y >= gfx.dy && y < gfx.dy + gfx.dysize)
422 #define IN_GFX_DOOR_2(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
423 y >= gfx.vy && y < gfx.vy + gfx.vysize)
424 #define IN_GFX_DOOR_3(x, y) (x >= gfx.ex && x < gfx.ex + gfx.exsize && \
425 y >= gfx.ey && y < gfx.ey + gfx.eysize)
427 /* values for mouse cursor */
428 #define CURSOR_DEFAULT 0
429 #define CURSOR_NONE 1
430 #define CURSOR_PLAYFIELD 2
432 /* fundamental game speed values */
433 #define ONE_SECOND_DELAY 1000 /* delay value for one second */
434 #define MENU_FRAME_DELAY 20 /* frame delay in milliseconds */
435 #define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
436 #define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
437 #define FRAMES_PER_SECOND (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
438 #define FRAMES_PER_SECOND_SP 35
440 /* maximum playfield size supported by libgame functions */
441 #define MAX_PLAYFIELD_WIDTH 128
442 #define MAX_PLAYFIELD_HEIGHT 128
444 /* maximum number of parallel players supported by libgame functions */
445 #define MAX_PLAYERS 4
447 /* maximum allowed length of player name */
448 #define MAX_PLAYER_NAME_LEN 10
450 /* maximum number of levels in a level set */
451 #define MAX_LEVELS 1000
453 /* maximum number of global animation and parts */
454 #define MAX_GLOBAL_ANIMS 32
455 #define MAX_GLOBAL_ANIM_PARTS 32
457 /* minimum/maximum/default x/y grid size for virtual buttons */
458 #define MIN_GRID_XSIZE 3
459 #define MIN_GRID_YSIZE 3
460 #define MAX_GRID_XSIZE 32
461 #define MAX_GRID_YSIZE 32
462 #define GRID_REAL_WIDTH MAX(1, MAX(video.screen_width, \
463 video.screen_height))
464 #define GRID_REAL_HEIGHT MAX(1, MIN(video.screen_width, \
465 video.screen_height))
466 #define DEFAULT_GRID_XSIZE_0 18
467 #define DEFAULT_GRID_YSIZE_0 MIN(MAX(MIN_GRID_YSIZE, \
468 DEFAULT_GRID_XSIZE_0 * \
472 #define DEFAULT_GRID_XSIZE_1 13
473 #define DEFAULT_GRID_YSIZE_1 MIN(MAX(MIN_GRID_YSIZE, \
474 DEFAULT_GRID_XSIZE_1 * \
479 #define DEFAULT_GRID_XSIZE(n) (n == 0 ? DEFAULT_GRID_XSIZE_0 : \
480 DEFAULT_GRID_XSIZE_1)
481 #define DEFAULT_GRID_YSIZE(n) (n == 0 ? DEFAULT_GRID_YSIZE_0 : \
482 DEFAULT_GRID_YSIZE_1)
484 #define GRID_ACTIVE_NR() (video.screen_width > \
485 video.screen_height ? 0 : 1)
487 /* values for grid button characters for virtual buttons */
488 #define CHAR_GRID_BUTTON_NONE ' '
489 #define CHAR_GRID_BUTTON_LEFT '<'
490 #define CHAR_GRID_BUTTON_RIGHT '>'
491 #define CHAR_GRID_BUTTON_UP '^'
492 #define CHAR_GRID_BUTTON_DOWN 'v'
493 #define CHAR_GRID_BUTTON_SNAP '1'
494 #define CHAR_GRID_BUTTON_DROP '2'
496 /* default name for empty highscore entry */
497 #define EMPTY_PLAYER_NAME "no name"
499 /* default name for unknown player names */
500 #define ANONYMOUS_NAME "anonymous"
502 /* default for other unknown names */
503 #define UNKNOWN_NAME "unknown"
505 /* default name for new levels */
506 #define NAMELESS_LEVEL_NAME "nameless level"
508 /* default text for non-existant artwork */
509 #define NOT_AVAILABLE "(not available)"
511 /* default value for undefined filename */
512 #define UNDEFINED_FILENAME "[NONE]"
514 /* default value for undefined levelset */
515 #define UNDEFINED_LEVELSET "[NONE]"
517 /* default value for undefined parameter */
518 #define ARG_DEFAULT "[DEFAULT]"
520 /* default values for undefined configuration file parameters */
521 #define ARG_UNDEFINED "-1000000"
522 #define ARG_UNDEFINED_VALUE (-1000000)
524 /* default value for off-screen positions */
525 #define POS_OFFSCREEN (-1000000)
527 /* definitions for game sub-directories */
529 #define RO_GAME_DIR "."
533 #define RW_GAME_DIR "."
536 #define RO_BASE_PATH RO_GAME_DIR
537 #define RW_BASE_PATH RW_GAME_DIR
539 /* directory names */
540 #define GRAPHICS_DIRECTORY "graphics"
541 #define SOUNDS_DIRECTORY "sounds"
542 #define MUSIC_DIRECTORY "music"
543 #define LEVELS_DIRECTORY "levels"
544 #define TAPES_DIRECTORY "tapes"
545 #define SCORES_DIRECTORY "scores"
546 #define DOCS_DIRECTORY "docs"
547 #define CACHE_DIRECTORY "cache"
548 #define CONF_DIRECTORY "conf"
550 #define GFX_CLASSIC_SUBDIR "gfx_classic"
551 #define SND_CLASSIC_SUBDIR "snd_classic"
552 #define MUS_CLASSIC_SUBDIR "mus_classic"
554 #define GFX_DEFAULT_SUBDIR (setup.internal.default_graphics_set)
555 #define SND_DEFAULT_SUBDIR (setup.internal.default_sounds_set)
556 #define MUS_DEFAULT_SUBDIR (setup.internal.default_music_set)
558 #define GFX_FALLBACK_FILENAME (setup.internal.fallback_graphics_file)
559 #define SND_FALLBACK_FILENAME (setup.internal.fallback_sounds_file)
560 #define MUS_FALLBACK_FILENAME (setup.internal.fallback_music_file)
562 #define DEFAULT_LEVELSET (setup.internal.default_level_series)
564 /* file names and filename extensions */
565 #define LEVELSETUP_DIRECTORY "levelsetup"
566 #define SETUP_FILENAME "setup.conf"
567 #define AUTOSETUP_FILENAME "autosetup.conf"
568 #define LEVELSETUP_FILENAME "levelsetup.conf"
569 #define EDITORSETUP_FILENAME "editorsetup.conf"
570 #define EDITORCASCADE_FILENAME "editorcascade.conf"
571 #define HELPANIM_FILENAME "helpanim.conf"
572 #define HELPTEXT_FILENAME "helptext.conf"
573 #define LEVELINFO_FILENAME "levelinfo.conf"
574 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
575 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
576 #define MUSICINFO_FILENAME "musicinfo.conf"
577 #define ARTWORKINFO_CACHE_FILE "artworkinfo.cache"
578 #define LEVELTEMPLATE_FILENAME "template.level"
579 #define LEVELFILE_EXTENSION "level"
580 #define TAPEFILE_EXTENSION "tape"
581 #define SCOREFILE_EXTENSION "score"
583 #define GAMECONTROLLER_BASENAME "gamecontrollerdb.txt"
585 #define LOG_OUT_BASENAME "stdout.txt"
586 #define LOG_ERR_BASENAME "stderr.txt"
592 #define STRING_PARENT_DIRECTORY ".."
593 #define STRING_TOP_DIRECTORY "/"
595 #define CHAR_PATH_SEPARATOR_UNIX '/'
596 #define CHAR_PATH_SEPARATOR_DOS '\\'
598 #define STRING_PATH_SEPARATOR_UNIX "/"
599 #define STRING_PATH_SEPARATOR_DOS "\\"
601 #define STRING_NEWLINE_UNIX "\n"
602 #define STRING_NEWLINE_DOS "\r\n"
604 #if defined(PLATFORM_WIN32)
605 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_DOS
606 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_DOS
607 #define STRING_NEWLINE STRING_NEWLINE_DOS
609 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_UNIX
610 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_UNIX
611 #define STRING_NEWLINE STRING_NEWLINE_UNIX
615 /* areas in bitmap PIX_DOOR */
616 /* meaning in PIX_DB_DOOR: (3 PAGEs)
617 PAGEX1: 1. buffer for DOOR_1
618 PAGEX2: 2. buffer for DOOR_1
619 PAGEX3: buffer for animations
622 /* these values are hard-coded to be able to use them in initialization */
623 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
624 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
626 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
627 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
628 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
629 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
630 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
631 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
632 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
633 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
634 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
635 #define DOOR_GFX_PAGEY1 (0)
636 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
639 /* macros for version handling */
640 #define VERSION_PART_1(x) ((x) / 1000000)
641 #define VERSION_PART_2(x) (((x) % 1000000) / 10000)
642 #define VERSION_PART_3(x) (((x) % 10000) / 100)
643 #define VERSION_PART_4(x) ((x) % 100)
645 #define VERSION_SUPER(x) VERSION_PART_1(x)
646 #define VERSION_MAJOR(x) VERSION_PART_2(x)
647 #define VERSION_MINOR(x) VERSION_PART_3(x)
648 #define VERSION_PATCH(x) VERSION_PART_4(x)
649 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
652 /* macros for parent/child process identification */
653 #if defined(PLATFORM_UNIX)
654 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
655 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
656 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
658 #define IS_PARENT_PROCESS() TRUE
659 #define IS_CHILD_PROCESS() FALSE
660 #define HAS_CHILD_PROCESS() FALSE
664 /* values for artwork type */
665 #define ARTWORK_TYPE_GRAPHICS 0
666 #define ARTWORK_TYPE_SOUNDS 1
667 #define ARTWORK_TYPE_MUSIC 2
669 #define NUM_ARTWORK_TYPES 3
672 /* values for tree type (chosen to match artwork type) */
673 #define TREE_TYPE_UNDEFINED -1
674 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
675 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
676 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
677 #define TREE_TYPE_LEVEL_DIR 3
678 #define TREE_TYPE_LEVEL_NR 4
680 #define NUM_TREE_TYPES 5
682 #define INFOTEXT_UNDEFINED ""
683 #define INFOTEXT_GRAPHICS_DIR "Custom Graphics"
684 #define INFOTEXT_SOUNDS_DIR "Custom Sounds"
685 #define INFOTEXT_MUSIC_DIR "Custom Music"
686 #define INFOTEXT_LEVEL_DIR "Level Sets"
687 #define INFOTEXT_LEVEL_NR "Levels"
689 #define TREE_INFOTEXT(t) ((t) == TREE_TYPE_LEVEL_NR ? \
690 INFOTEXT_LEVEL_NR : \
691 (t) == TREE_TYPE_LEVEL_DIR ? \
692 INFOTEXT_LEVEL_DIR : \
693 (t) == TREE_TYPE_GRAPHICS_DIR ? \
694 INFOTEXT_GRAPHICS_DIR : \
695 (t) == TREE_TYPE_SOUNDS_DIR ? \
696 INFOTEXT_SOUNDS_DIR : \
697 (t) == TREE_TYPE_MUSIC_DIR ? \
698 INFOTEXT_MUSIC_DIR : \
701 /* values for artwork handling */
702 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
703 ((type) == ARTWORK_TYPE_GRAPHICS ? \
704 &(leveldir)->graphics_set : \
705 (type) == ARTWORK_TYPE_SOUNDS ? \
706 &(leveldir)->sounds_set : \
707 &(leveldir)->music_set)
709 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
710 ((type) == ARTWORK_TYPE_GRAPHICS ? \
711 (leveldir)->graphics_set : \
712 (type) == ARTWORK_TYPE_SOUNDS ? \
713 (leveldir)->sounds_set : \
714 (leveldir)->music_set)
716 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
717 ((type) == ARTWORK_TYPE_GRAPHICS ? \
718 &(leveldir)->graphics_path : \
719 (type) == ARTWORK_TYPE_SOUNDS ? \
720 &(leveldir)->sounds_path : \
721 &(leveldir)->music_path)
723 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
724 ((type) == ARTWORK_TYPE_GRAPHICS ? \
725 (leveldir)->graphics_path : \
726 (type) == ARTWORK_TYPE_SOUNDS ? \
727 (leveldir)->sounds_path : \
728 (leveldir)->music_path)
730 #define SETUP_ARTWORK_SET(setup, type) \
731 ((type) == ARTWORK_TYPE_GRAPHICS ? \
732 (setup).graphics_set : \
733 (type) == ARTWORK_TYPE_SOUNDS ? \
734 (setup).sounds_set : \
737 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
738 ((type) == ARTWORK_TYPE_GRAPHICS ? \
739 (setup).override_level_graphics : \
740 (type) == ARTWORK_TYPE_SOUNDS ? \
741 (setup).override_level_sounds : \
742 (setup).override_level_music)
744 #define GFX_OVERRIDE_ARTWORK(type) \
745 ((type) == ARTWORK_TYPE_GRAPHICS ? \
746 gfx.override_level_graphics : \
747 (type) == ARTWORK_TYPE_SOUNDS ? \
748 gfx.override_level_sounds : \
749 gfx.override_level_music)
751 #define ARTWORK_FIRST_NODE(artwork, type) \
752 ((type) == ARTWORK_TYPE_GRAPHICS ? \
753 (artwork).gfx_first : \
754 (type) == ARTWORK_TYPE_SOUNDS ? \
755 (artwork).snd_first : \
758 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
759 ((type) == ARTWORK_TYPE_GRAPHICS ? \
760 &(artwork).gfx_current_identifier : \
761 (type) == ARTWORK_TYPE_SOUNDS ? \
762 &(artwork).snd_current_identifier : \
763 &(artwork).mus_current_identifier)
765 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
766 ((type) == ARTWORK_TYPE_GRAPHICS ? \
767 (artwork).gfx_current_identifier : \
768 (type) == ARTWORK_TYPE_SOUNDS ? \
769 (artwork).snd_current_identifier : \
770 (artwork).mus_current_identifier)
772 #define ARTWORKINFO_FILENAME(type) \
773 ((type) == ARTWORK_TYPE_GRAPHICS ? \
774 GRAPHICSINFO_FILENAME : \
775 (type) == ARTWORK_TYPE_SOUNDS ? \
776 SOUNDSINFO_FILENAME : \
777 (type) == ARTWORK_TYPE_MUSIC ? \
778 MUSICINFO_FILENAME : "")
780 #define ARTWORK_DIRECTORY(type) \
781 ((type) == ARTWORK_TYPE_GRAPHICS ? \
782 GRAPHICS_DIRECTORY : \
783 (type) == ARTWORK_TYPE_SOUNDS ? \
785 (type) == ARTWORK_TYPE_MUSIC ? \
786 MUSIC_DIRECTORY : "")
788 #define OPTIONS_ARTWORK_DIRECTORY(type) \
789 ((type) == ARTWORK_TYPE_GRAPHICS ? \
790 options.graphics_directory : \
791 (type) == ARTWORK_TYPE_SOUNDS ? \
792 options.sounds_directory : \
793 (type) == ARTWORK_TYPE_MUSIC ? \
794 options.music_directory : "")
796 #define UPDATE_BUSY_STATE() \
798 if (gfx.draw_busy_anim_function != NULL) \
799 gfx.draw_busy_anim_function(); \
803 /* structure definitions */
807 char *command_basepath; /* path to the program binary */
808 char *command_basename; /* base filename of the program binary */
810 char *config_filename; /* optional global program config filename */
812 char *maindata_path; /* main game data (installation) directory */
814 char *userdata_subdir; /* personal user game data directory */
815 char *userdata_path; /* resulting full path to game data directory */
825 char *log_filename[NUM_LOGS]; /* log filenames for out/err messages */
826 FILE *log_file[NUM_LOGS]; /* log file handles for out/err files */
827 FILE *log_file_default[NUM_LOGS]; /* default log file handles (out/err) */
835 char *version_string;
837 char *(*window_title_function)(void);
838 void (*exit_message_function)(char *, va_list);
839 void (*exit_function)(int);
841 boolean global_scores;
842 boolean many_scores_per_name;
852 char *ro_base_directory;
853 char *rw_base_directory;
854 char *level_directory;
855 char *graphics_directory;
856 char *sounds_directory;
857 char *music_directory;
858 char *docs_directory;
859 char *conf_directory;
861 char *execute_command;
872 struct VideoSystemInfo
875 int width, height, depth;
876 int window_width, window_height;
877 int display_width, display_height;
878 int screen_width, screen_height;
879 int screen_xoffset, screen_yoffset;
881 boolean fullscreen_available;
882 boolean fullscreen_enabled;
883 boolean fullscreen_initial;
885 boolean window_scaling_available;
886 int window_scaling_percent;
887 char *window_scaling_quality;
888 int screen_rendering_mode;
890 unsigned int frame_delay;
891 unsigned int frame_delay_value;
895 int shifted_up_pos_last;
896 unsigned int shifted_up_delay;
897 unsigned int shifted_up_delay_value;
902 struct AudioSystemInfo
904 boolean sound_available;
905 boolean loops_available;
906 boolean music_available;
908 boolean sound_enabled;
909 boolean sound_deactivated; /* for temporarily disabling sound */
918 int first_sound_channel;
921 struct FontBitmapInfo
925 int src_x, src_y; /* start position of font characters */
926 int width, height; /* width / height of font characters */
928 int offset_x; /* offset to next font character */
929 int offset_y; /* offset to next font character */
931 int draw_xoffset; /* offset for drawing font characters */
932 int draw_yoffset; /* offset for drawing font characters */
935 int num_chars_per_line;
942 int real_sx, real_sy;
943 int full_sxsize, full_sysize;
944 int scrollbuffer_width, scrollbuffer_height;
946 int game_tile_size, standard_tile_size;
957 int win_xsize, win_ysize;
959 int draw_deactivation_mask;
960 int draw_background_mask;
962 Bitmap *field_save_buffer;
964 Bitmap *background_bitmap;
965 int background_bitmap_mask;
967 Bitmap *fade_bitmap_backup;
968 Bitmap *fade_bitmap_source;
969 Bitmap *fade_bitmap_target;
970 Bitmap *fade_bitmap_black;
972 int fade_border_source_status;
973 int fade_border_target_status;
974 Bitmap *masked_border_bitmap_ptr;
976 Bitmap *final_screen_bitmap;
978 boolean clipping_enabled;
980 int clip_width, clip_height;
982 boolean override_level_graphics;
983 boolean override_level_sounds;
984 boolean override_level_music;
986 boolean draw_init_text;
989 struct FontBitmapInfo *font_bitmap_info;
990 int (*select_font_function)(int);
991 int (*get_font_from_token_function)(char *);
993 int anim_random_frame;
995 void (*draw_busy_anim_function)(void);
996 void (*draw_global_anim_function)(int, int);
997 void (*draw_global_border_function)(int);
998 void (*draw_tile_cursor_function)(int);
1003 struct TileCursorInfo
1005 boolean enabled; /* tile cursor generally enabled or disabled */
1006 boolean active; /* tile cursor activated (depending on game) */
1007 boolean moving; /* tile cursor moving to target position */
1009 int xpos, ypos; /* tile cursor level playfield position */
1010 int x, y; /* tile cursor current screen position */
1011 int target_x, target_y; /* tile cursor target screen position */
1013 int sx, sy; /* tile cursor screen start position */
1018 boolean enabled; /* overlay generally enabled or disabled */
1019 boolean active; /* overlay activated (depending on game mode) */
1026 char grid_button[MAX_GRID_XSIZE][MAX_GRID_YSIZE];
1027 char grid_button_highlight;
1033 int nr[MAX_PLAYERS]; /* joystick number for each player */
1036 struct SetupJoystickInfo
1038 char *device_name; /* device name of player's joystick */
1040 int xleft, xmiddle, xright;
1041 int yupper, ymiddle, ylower;
1045 struct SetupKeyboardInfo
1047 Key left, right, up, down;
1051 struct SetupTouchInfo
1060 char grid_button[2][MAX_GRID_XSIZE][MAX_GRID_YSIZE];
1062 int transparency; /* in percent (0 == opaque, 100 == invisible) */
1064 boolean grid_initialized;
1067 struct SetupInputInfo
1069 boolean use_joystick;
1070 struct SetupJoystickInfo joy;
1071 struct SetupKeyboardInfo key;
1074 struct SetupEditorInfo
1076 boolean el_boulderdash;
1077 boolean el_emerald_mine;
1078 boolean el_emerald_mine_club;
1081 boolean el_supaplex;
1082 boolean el_diamond_caves;
1083 boolean el_dx_boulderdash;
1085 boolean el_mirror_magic;
1086 boolean el_deflektor;
1089 boolean el_steel_chars;
1093 boolean el_user_defined;
1096 boolean el_headlines;
1101 boolean show_element_token;
1103 boolean use_template_for_new_levels;
1106 struct SetupAutoSetupInfo
1108 int editor_zoom_tilesize;
1111 struct SetupEditorCascadeInfo
1124 boolean el_steel_chars;
1132 struct SetupShortcutInfo
1138 Key focus_player[MAX_PLAYERS];
1139 Key focus_player_all;
1158 struct SetupSystemInfo
1160 char *sdl_videodriver;
1161 char *sdl_audiodriver;
1162 int audio_fragment_size;
1165 struct SetupInternalInfo
1167 char *program_title;
1168 char *program_version;
1169 char *program_author;
1170 char *program_email;
1171 char *program_website;
1172 char *program_copyright;
1173 char *program_company;
1175 char *program_icon_file;
1177 char *default_graphics_set;
1178 char *default_sounds_set;
1179 char *default_music_set;
1181 char *fallback_graphics_file;
1182 char *fallback_sounds_file;
1183 char *fallback_music_file;
1185 char *default_level_series;
1187 int default_window_width;
1188 int default_window_height;
1190 boolean choose_from_top_leveldir;
1191 boolean show_scaling_in_title;
1194 struct SetupDebugInfo
1196 int frame_delay[10];
1197 Key frame_delay_key[10];
1198 boolean frame_delay_use_mod_key;
1199 boolean frame_delay_game_only;
1200 boolean show_frames_per_second;
1208 boolean sound_loops;
1209 boolean sound_music;
1210 boolean sound_simple;
1212 boolean scroll_delay;
1213 boolean scroll_delay_value;
1214 char *engine_snapshot_mode;
1215 int engine_snapshot_memory;
1216 boolean fade_screens;
1218 boolean show_titlescreen;
1219 boolean quick_doors;
1222 boolean skip_levels;
1223 boolean increment_levels;
1226 int window_scaling_percent;
1227 char *window_scaling_quality;
1228 char *screen_rendering_mode;
1229 boolean ask_on_escape;
1230 boolean ask_on_escape_editor;
1231 boolean quick_switch;
1232 boolean input_on_focus;
1233 boolean prefer_aga_graphics;
1234 int game_frame_delay;
1235 boolean sp_show_border_elements;
1236 boolean small_game_graphics;
1237 boolean show_snapshot_buttons;
1242 int override_level_graphics; /* not boolean -- can also be "AUTO" */
1243 int override_level_sounds; /* not boolean -- can also be "AUTO" */
1244 int override_level_music; /* not boolean -- can also be "AUTO" */
1250 struct SetupAutoSetupInfo auto_setup;
1251 struct SetupEditorInfo editor;
1252 struct SetupEditorCascadeInfo editor_cascade;
1253 struct SetupShortcutInfo shortcut;
1254 struct SetupInputInfo input[MAX_PLAYERS];
1255 struct SetupTouchInfo touch;
1256 struct SetupSystemInfo system;
1257 struct SetupInternalInfo internal;
1258 struct SetupDebugInfo debug;
1260 struct OptionInfo options;
1265 struct TreeInfo **node_top; /* topmost node in tree */
1266 struct TreeInfo *node_parent; /* parent level directory info */
1267 struct TreeInfo *node_group; /* level group sub-directory info */
1268 struct TreeInfo *next; /* next level series structure node */
1270 int cl_first; /* internal control field for setup screen */
1271 int cl_cursor; /* internal control field for setup screen */
1273 int type; /* type of tree content */
1275 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
1277 char *subdir; /* tree info sub-directory basename (may be ".") */
1278 char *fullpath; /* complete path relative to tree base directory */
1279 char *basepath; /* absolute base path of tree base directory */
1280 char *identifier; /* identifier string for configuration files */
1281 char *name; /* tree info name, as displayed in selection menues */
1282 char *name_sorting; /* optional sorting name for correct name sorting */
1283 char *author; /* level or artwork author name */
1284 char *year; /* optional year of creation for levels or artwork */
1286 char *program_title; /* optional alternative text for program title */
1287 char *program_copyright; /* optional alternative text for program copyright */
1288 char *program_company; /* optional alternative text for program company */
1290 char *imported_from; /* optional comment for imported levels or artwork */
1291 char *imported_by; /* optional comment for imported levels or artwork */
1292 char *tested_by; /* optional comment to name people who tested a set */
1294 char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */
1295 char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */
1296 char *graphics_set; /* optional custom graphics set (level tree only) */
1297 char *sounds_set; /* optional custom sounds set (level tree only) */
1298 char *music_set; /* optional custom music set (level tree only) */
1299 char *graphics_path; /* path to optional custom graphics set (level only) */
1300 char *sounds_path; /* path to optional custom sounds set (level only) */
1301 char *music_path; /* path to optional custom music set (level only) */
1303 char *level_filename; /* filename of level file (for packed level file) */
1304 char *level_filetype; /* type of levels in level directory or level file */
1306 char *special_flags; /* flags for special actions performed on level file */
1308 int levels; /* number of levels in level series */
1309 int first_level; /* first level number (to allow start with 0 or 1) */
1310 int last_level; /* last level number (automatically calculated) */
1311 int sort_priority; /* sort levels by 'sort_priority' and then by name */
1313 boolean latest_engine;/* force level set to use the latest game engine */
1315 boolean level_group; /* directory contains more level series directories */
1316 boolean parent_link; /* entry links back to parent directory */
1317 boolean in_user_dir; /* user defined levels are stored in home directory */
1318 boolean user_defined; /* levels in user directory and marked as "private" */
1319 boolean readonly; /* readonly levels can not be changed with editor */
1320 boolean handicap; /* level set has no handicap when set to "false" */
1321 boolean skip_levels; /* levels can be skipped when set to "true" */
1323 int color; /* color to use on selection screen for this level */
1324 char *class_desc; /* description of level series class */
1325 int handicap_level; /* number of the lowest unsolved level */
1327 char *infotext; /* optional text to describe the tree type (headline) */
1330 typedef struct TreeInfo TreeInfo;
1331 typedef struct TreeInfo LevelDirTree;
1332 typedef struct TreeInfo ArtworkDirTree;
1333 typedef struct TreeInfo GraphicsDirTree;
1334 typedef struct TreeInfo SoundsDirTree;
1335 typedef struct TreeInfo MusicDirTree;
1339 GraphicsDirTree *gfx_first;
1340 GraphicsDirTree *gfx_current;
1341 SoundsDirTree *snd_first;
1342 SoundsDirTree *snd_current;
1343 MusicDirTree *mus_first;
1344 MusicDirTree *mus_current;
1346 char *gfx_current_identifier;
1347 char *snd_current_identifier;
1348 char *mus_current_identifier;
1351 struct ValueTextInfo
1363 struct ConfigTypeInfo
1370 struct TokenIntPtrInfo
1380 char *default_filename;
1383 char **default_parameter; /* array of file parameters */
1384 char **parameter; /* array of file parameters */
1387 boolean fallback_to_default;
1388 boolean default_is_cloned;
1391 struct SetupFileList
1396 struct SetupFileList *next;
1401 char *source_filename; /* primary key for node list */
1405 struct PropertyMapping
1415 struct ArtworkListInfo
1417 int type; /* type of artwork */
1419 int num_file_list_entries;
1420 int num_dynamic_file_list_entries;
1421 struct FileInfo *file_list; /* static artwork file array */
1422 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
1424 int num_suffix_list_entries;
1425 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
1427 int num_base_prefixes;
1428 int num_ext1_suffixes;
1429 int num_ext2_suffixes;
1430 int num_ext3_suffixes;
1431 char **base_prefixes; /* base token prefixes array */
1432 char **ext1_suffixes; /* property suffixes array 1 */
1433 char **ext2_suffixes; /* property suffixes array 2 */
1434 char **ext3_suffixes; /* property suffixes array 3 */
1436 int num_ignore_tokens;
1437 char **ignore_tokens; /* file tokens to be ignored */
1439 int num_property_mapping_entries;
1440 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
1442 int sizeof_artwork_list_entry;
1444 struct ListNodeInfo **artwork_list; /* static artwork node array */
1445 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
1446 struct ListNode *content_list; /* dynamic artwork node list */
1448 void *(*load_artwork)(char *); /* constructor function */
1449 void (*free_artwork)(void *); /* destructor function */
1469 struct RectWithBorder
1483 struct DoorPartPosInfo
1490 int start_step_opening;
1491 int start_step_closing;
1492 boolean draw_masked;
1499 int xoffset; /* special case for tape date and time */
1500 int xoffset2; /* special case for tape date */
1503 int size; /* also used for suffix ".digits" */
1505 boolean draw_masked;
1506 boolean draw_player; /* special case for network player buttons */
1507 int sort_priority; /* also used for suffix ".draw_order" */
1510 int direction; /* needed for panel time/health graphics */
1511 int class; /* needed for panel time/health graphics */
1512 int style; /* needed for panel time/health graphics */
1515 struct MouseActionInfo
1529 /* ========================================================================= */
1530 /* exported variables */
1531 /* ========================================================================= */
1533 extern struct ProgramInfo program;
1534 extern struct OptionInfo options;
1535 extern struct VideoSystemInfo video;
1536 extern struct AudioSystemInfo audio;
1537 extern struct GfxInfo gfx;
1538 extern struct TileCursorInfo tile_cursor;
1539 extern struct OverlayInfo overlay;
1540 extern struct AnimInfo anim;
1541 extern struct ArtworkInfo artwork;
1542 extern struct JoystickInfo joystick;
1543 extern struct SetupInfo setup;
1545 extern LevelDirTree *leveldir_first_all;
1546 extern LevelDirTree *leveldir_first;
1547 extern LevelDirTree *leveldir_current;
1548 extern int level_nr;
1550 extern struct LevelStats level_stats[];
1552 extern DrawWindow *window;
1553 extern DrawBuffer *backbuffer;
1554 extern DrawBuffer *drawto;
1556 extern int button_status;
1557 extern boolean motion_status;
1558 extern int wheel_steps;
1559 #if defined(TARGET_SDL2)
1560 extern boolean keyrepeat_status;
1563 extern int redraw_mask;
1565 extern int FrameCounter;
1568 /* function definitions */
1570 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1573 void InitScoresInfo();
1574 void SetWindowTitle();
1576 void InitWindowTitleFunction(char *(*window_title_function)(void));
1577 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
1578 void InitExitFunction(void (*exit_function)(int));
1579 void InitPlatformDependentStuff(void);
1580 void ClosePlatformDependentStuff(void);
1582 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1583 void InitGfxTileSizeInfo(int, int);
1584 void InitGfxDoor1Info(int, int, int, int);
1585 void InitGfxDoor2Info(int, int, int, int);
1586 void InitGfxDoor3Info(int, int, int, int);
1587 void InitGfxWindowInfo(int, int);
1588 void InitGfxScrollbufferInfo(int, int);
1589 void InitGfxClipRegion(boolean, int, int, int, int);
1590 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
1591 void InitGfxDrawGlobalAnimFunction(void (*draw_global_anim_function)(int, int));
1592 void InitGfxDrawGlobalBorderFunction(void (*draw_global_border_function)(int));
1593 void InitGfxDrawTileCursorFunction(void (*draw_tile_cursor_function)(int));
1594 void InitGfxCustomArtworkInfo();
1595 void InitGfxOtherSettings();
1596 void InitTileCursorInfo();
1597 void InitOverlayInfo();
1598 void SetTileCursorEnabled(boolean);
1599 void SetTileCursorActive(boolean);
1600 void SetTileCursorTargetXY(int, int);
1601 void SetTileCursorXY(int, int);
1602 void SetTileCursorSXSY(int, int);
1603 void SetOverlayEnabled(boolean);
1604 void SetOverlayActive(boolean);
1605 void SetOverlayShowGrid(boolean);
1606 boolean GetOverlayActive();
1607 void SetDrawDeactivationMask(int);
1608 int GetDrawDeactivationMask(void);
1609 void SetDrawBackgroundMask(int);
1610 void SetWindowBackgroundBitmap(Bitmap *);
1611 void SetMainBackgroundBitmap(Bitmap *);
1612 void SetDoorBackgroundBitmap(Bitmap *);
1613 void SetRedrawMaskFromArea(int, int, int, int);
1615 void LimitScreenUpdates(boolean);
1617 void InitVideoDefaults(void);
1618 void InitVideoDisplay(void);
1619 void CloseVideoDisplay(void);
1620 void InitVideoBuffer(int, int, int, boolean);
1621 Bitmap *CreateBitmapStruct(void);
1622 Bitmap *CreateBitmap(int, int, int);
1623 void ReCreateBitmap(Bitmap **, int, int);
1624 void FreeBitmap(Bitmap *);
1625 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1626 void BlitBitmapTiled(Bitmap *, Bitmap *, int, int, int, int, int, int, int,int);
1627 void FadeRectangle(int, int, int, int, int, int, int,
1628 void (*draw_border_function)(void));
1629 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1630 void ClearRectangle(Bitmap *, int, int, int, int);
1631 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1632 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1633 boolean DrawingDeactivatedField(void);
1634 boolean DrawingDeactivated(int, int, int, int);
1635 boolean DrawingOnBackground(int, int);
1636 boolean DrawingAreaChanged();
1637 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1638 void BlitTexture(Bitmap *, int, int, int, int, int, int);
1639 void BlitTextureMasked(Bitmap *, int, int, int, int, int, int);
1640 void BlitToScreen(Bitmap *, int, int, int, int, int, int);
1641 void BlitToScreenMasked(Bitmap *, int, int, int, int, int, int);
1642 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1643 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1644 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1645 Pixel GetPixel(Bitmap *, int, int);
1646 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1647 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1649 void KeyboardAutoRepeatOn(void);
1650 void KeyboardAutoRepeatOff(void);
1651 boolean SetVideoMode(boolean);
1652 void SetVideoFrameDelay(unsigned int);
1653 unsigned int GetVideoFrameDelay();
1654 boolean ChangeVideoModeIfNeeded(boolean);
1656 Bitmap *LoadImage(char *);
1657 Bitmap *LoadCustomImage(char *);
1658 void ReloadCustomImage(Bitmap *, char *);
1660 void ReCreateGameTileSizeBitmap(Bitmap **);
1661 void CreateBitmapWithSmallBitmaps(Bitmap **, int, int);
1662 void CreateBitmapTextures(Bitmap **);
1663 void FreeBitmapTextures(Bitmap **);
1664 void ScaleBitmap(Bitmap **, int);
1666 void SetMouseCursor(int);
1668 void OpenAudio(void);
1669 void CloseAudio(void);
1670 void SetAudioMode(boolean);
1672 boolean PendingEvent(void);
1673 void WaitEvent(Event *event);
1674 void PeekEvent(Event *event);
1675 void CheckQuitEvent(void);
1676 Key GetEventKey(KeyEvent *, boolean);
1677 KeyMod HandleKeyModState(Key, int);
1678 KeyMod GetKeyModState();
1679 KeyMod GetKeyModStateFromEvents();
1680 void StartTextInput(int, int, int, int);
1681 void StopTextInput();
1682 boolean CheckCloseWindowEvent(ClientMessageEvent *);
1684 void InitJoysticks();
1685 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1686 boolean CheckJoystickOpened(int);
1687 void ClearJoystickState();
1689 #endif /* SYSTEM_H */