1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
21 #if defined(PLATFORM_MACOSX)
23 #elif defined(PLATFORM_WIN32)
25 #elif defined(PLATFORM_ANDROID)
29 #if defined(TARGET_SDL)
31 #elif defined(TARGET_X11)
36 /* the additional 'b' is needed for Win32 to open files in binary mode */
37 #define MODE_READ "rb"
38 #define MODE_WRITE "wb"
39 #define MODE_APPEND "ab"
41 #define DEFAULT_DEPTH 0
45 #define BLIT_INVERSE 2
46 #define BLIT_ON_BACKGROUND 3
48 /* values for fullscreen status */
49 #define FULLSCREEN_NOT_AVAILABLE FALSE
50 #define FULLSCREEN_AVAILABLE TRUE
52 /* values for window scaling */
53 #define WINDOW_SCALING_NOT_AVAILABLE FALSE
54 #define WINDOW_SCALING_AVAILABLE TRUE
56 #define MIN_WINDOW_SCALING_PERCENT 50
57 #define STD_WINDOW_SCALING_PERCENT 100
58 #define MAX_WINDOW_SCALING_PERCENT 300
59 #define STEP_WINDOW_SCALING_PERCENT 10
61 /* values for window scaling quality */
62 #define SCALING_QUALITY_NEAREST "nearest"
63 #define SCALING_QUALITY_LINEAR "linear"
64 #define SCALING_QUALITY_BEST "best"
66 #define SCALING_QUALITY_DEFAULT SCALING_QUALITY_LINEAR
68 /* values for touch control */
69 #define TOUCH_CONTROL_VIRTUAL_BUTTONS "virtual_buttons"
70 #define TOUCH_CONTROL_WIPE_GESTURES "wipe_gestures"
72 #define TOUCH_CONTROL_DEFAULT TOUCH_CONTROL_VIRTUAL_BUTTONS
74 #define TOUCH_MOVE_DISTANCE_DEFAULT 2
75 #define TOUCH_DROP_DISTANCE_DEFAULT 5
78 /* default input keys */
79 #define DEFAULT_KEY_LEFT KSYM_Left
80 #define DEFAULT_KEY_RIGHT KSYM_Right
81 #define DEFAULT_KEY_UP KSYM_Up
82 #define DEFAULT_KEY_DOWN KSYM_Down
83 #if defined(PLATFORM_MACOSX)
84 #define DEFAULT_KEY_SNAP KSYM_Control_L
85 #define DEFAULT_KEY_DROP KSYM_KP_Enter
87 #define DEFAULT_KEY_SNAP KSYM_Control_L
88 #define DEFAULT_KEY_DROP KSYM_Control_R
90 #define DEFAULT_KEY_OKAY KSYM_Return
91 #define DEFAULT_KEY_CANCEL KSYM_Escape
93 /* default shortcut keys */
94 #define DEFAULT_KEY_SAVE_GAME KSYM_F1
95 #define DEFAULT_KEY_LOAD_GAME KSYM_F2
96 #define DEFAULT_KEY_TOGGLE_PAUSE KSYM_space
97 #define DEFAULT_KEY_FOCUS_PLAYER_1 KSYM_F5
98 #define DEFAULT_KEY_FOCUS_PLAYER_2 KSYM_F6
99 #define DEFAULT_KEY_FOCUS_PLAYER_3 KSYM_F7
100 #define DEFAULT_KEY_FOCUS_PLAYER_4 KSYM_F8
101 #define DEFAULT_KEY_FOCUS_PLAYER_ALL KSYM_F9
102 #define DEFAULT_KEY_TAPE_EJECT KSYM_UNDEFINED
103 #define DEFAULT_KEY_TAPE_EXTRA KSYM_UNDEFINED
104 #define DEFAULT_KEY_TAPE_STOP KSYM_UNDEFINED
105 #define DEFAULT_KEY_TAPE_PAUSE KSYM_UNDEFINED
106 #define DEFAULT_KEY_TAPE_RECORD KSYM_UNDEFINED
107 #define DEFAULT_KEY_TAPE_PLAY KSYM_UNDEFINED
108 #define DEFAULT_KEY_SOUND_SIMPLE KSYM_UNDEFINED
109 #define DEFAULT_KEY_SOUND_LOOPS KSYM_UNDEFINED
110 #define DEFAULT_KEY_SOUND_MUSIC KSYM_UNDEFINED
111 #define DEFAULT_KEY_SNAP_LEFT KSYM_UNDEFINED
112 #define DEFAULT_KEY_SNAP_RIGHT KSYM_UNDEFINED
113 #define DEFAULT_KEY_SNAP_UP KSYM_UNDEFINED
114 #define DEFAULT_KEY_SNAP_DOWN KSYM_UNDEFINED
116 /* values for key_status */
117 #define KEY_NOT_PRESSED FALSE
118 #define KEY_RELEASED FALSE
119 #define KEY_PRESSED TRUE
121 /* values for button status */
122 #define MB_NOT_PRESSED FALSE
123 #define MB_NOT_RELEASED TRUE
124 #define MB_RELEASED FALSE
125 #define MB_PRESSED TRUE
126 #define MB_MENU_CHOICE FALSE
127 #define MB_MENU_MARK TRUE
128 #define MB_MENU_INITIALIZE (-1)
129 #define MB_MENU_LEAVE (-2)
130 #define MB_LEFTBUTTON 1
131 #define MB_MIDDLEBUTTON 2
132 #define MB_RIGHTBUTTON 3
133 #define MB_WHEEL_UP 4
134 #define MB_WHEEL_DOWN 5
135 #define MB_WHEEL_LEFT 6
136 #define MB_WHEEL_RIGHT 7
137 #define IS_WHEEL_BUTTON_VERTICAL(b) ((b) >= MB_WHEEL_UP && \
138 (b) <= MB_WHEEL_DOWN)
139 #define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) >= MB_WHEEL_LEFT && \
140 (b) <= MB_WHEEL_RIGHT)
141 #define IS_WHEEL_BUTTON(b) ((b) >= MB_WHEEL_UP && \
142 (b) <= MB_WHEEL_DOWN)
143 #define DEFAULT_WHEEL_STEPS 3
145 /* values for move directions */
146 #define MV_BIT_LEFT 0
147 #define MV_BIT_RIGHT 1
149 #define MV_BIT_DOWN 3
151 #define NUM_DIRECTIONS 4
153 /* diagonal movement directions are used in a different contect than buttons */
154 #define MV_BIT_UPLEFT 4
155 #define MV_BIT_UPRIGHT 5
156 #define MV_BIT_DOWNLEFT 6
157 #define MV_BIT_DOWNRIGHT 7
159 #define NUM_DIRECTIONS_FULL 8
161 /* values for special "button" bitmasks */
165 #define NUM_PLAYER_ACTIONS 6
167 /* values for special "focus player" bitmasks */
168 #define BIT_SET_FOCUS 6
170 /* values for move directions and special "button" key bitmasks */
172 #define MV_LEFT (1 << MV_BIT_LEFT)
173 #define MV_RIGHT (1 << MV_BIT_RIGHT)
174 #define MV_UP (1 << MV_BIT_UP)
175 #define MV_DOWN (1 << MV_BIT_DOWN)
177 #define MV_UPLEFT (MV_UP | MV_LEFT)
178 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
179 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
180 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
182 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
183 #define MV_VERTICAL (MV_UP | MV_DOWN)
184 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
185 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
186 #define MV_NO_DIRECTION (MV_NONE)
188 #define KEY_BUTTON_1 (1 << BUTTON_1)
189 #define KEY_BUTTON_2 (1 << BUTTON_2)
190 #define KEY_BUTTON_SNAP KEY_BUTTON_1
191 #define KEY_BUTTON_DROP KEY_BUTTON_2
192 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
193 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
194 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
196 #define KEY_SET_FOCUS (1 << BIT_SET_FOCUS)
198 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
199 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
200 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
201 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
202 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
205 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
206 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
207 (x) == MV_UP ? MV_BIT_UP : \
208 (x) == MV_DOWN ? MV_BIT_DOWN : \
209 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
210 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
211 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
212 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
215 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
216 (x) == MV_RIGHT ? MV_LEFT : \
217 (x) == MV_UP ? MV_DOWN : \
218 (x) == MV_DOWN ? MV_UP : \
219 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
220 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
221 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
222 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
225 /* values for animation mode (frame order and direction) */
227 #define ANIM_LOOP (1 << 0)
228 #define ANIM_LINEAR (1 << 1)
229 #define ANIM_PINGPONG (1 << 2)
230 #define ANIM_PINGPONG2 (1 << 3)
231 #define ANIM_RANDOM (1 << 4)
232 #define ANIM_CE_VALUE (1 << 5)
233 #define ANIM_CE_SCORE (1 << 6)
234 #define ANIM_CE_DELAY (1 << 7)
235 #define ANIM_REVERSE (1 << 8)
236 #define ANIM_OPAQUE_PLAYER (1 << 9)
238 /* values for special (non game element) animation modes */
239 #define ANIM_HORIZONTAL (1 << 10)
240 #define ANIM_VERTICAL (1 << 11)
241 #define ANIM_CENTERED (1 << 12)
242 #define ANIM_STATIC_PANEL (1 << 13)
244 #define ANIM_DEFAULT ANIM_LOOP
246 /* values for special drawing styles (currently only for crumbled graphics) */
248 #define STYLE_ACCURATE_BORDERS (1 << 0)
249 #define STYLE_INNER_CORNERS (1 << 1)
251 #define STYLE_DEFAULT STYLE_NONE
253 /* values for fade mode */
254 #define FADE_TYPE_NONE 0
255 #define FADE_TYPE_FADE_IN (1 << 0)
256 #define FADE_TYPE_FADE_OUT (1 << 1)
257 #define FADE_TYPE_TRANSFORM (1 << 2)
258 #define FADE_TYPE_CROSSFADE (1 << 3)
259 #define FADE_TYPE_MELT (1 << 4)
260 #define FADE_TYPE_SKIP (1 << 5)
262 #define FADE_MODE_NONE (FADE_TYPE_NONE)
263 #define FADE_MODE_FADE_IN (FADE_TYPE_FADE_IN)
264 #define FADE_MODE_FADE_OUT (FADE_TYPE_FADE_OUT)
265 #define FADE_MODE_FADE (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT)
266 #define FADE_MODE_TRANSFORM (FADE_TYPE_TRANSFORM | FADE_TYPE_FADE_IN)
267 #define FADE_MODE_CROSSFADE (FADE_MODE_TRANSFORM | FADE_TYPE_CROSSFADE)
268 #define FADE_MODE_MELT (FADE_MODE_TRANSFORM | FADE_TYPE_MELT)
269 #define FADE_MODE_SKIP_FADE_IN (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN)
270 #define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT)
272 #define FADE_MODE_DEFAULT FADE_MODE_FADE
274 /* values for text alignment */
275 #define ALIGN_LEFT (1 << 0)
276 #define ALIGN_RIGHT (1 << 1)
277 #define ALIGN_CENTER (1 << 2)
278 #define ALIGN_DEFAULT ALIGN_LEFT
280 #define VALIGN_TOP (1 << 0)
281 #define VALIGN_BOTTOM (1 << 1)
282 #define VALIGN_MIDDLE (1 << 2)
283 #define VALIGN_DEFAULT VALIGN_TOP
285 #define ALIGNED_XPOS(x,w,a) ((a) == ALIGN_CENTER ? (x) - (w) / 2 : \
286 (a) == ALIGN_RIGHT ? (x) - (w) : (x))
287 #define ALIGNED_YPOS(y,h,v) ((v) == VALIGN_MIDDLE ? (y) - (h) / 2 : \
288 (v) == VALIGN_BOTTOM ? (y) - (h) : (y))
289 #define ALIGNED_TEXT_XPOS(p) ALIGNED_XPOS((p)->x, (p)->width, (p)->align)
290 #define ALIGNED_TEXT_YPOS(p) ALIGNED_YPOS((p)->y, (p)->height, (p)->valign)
292 /* values for redraw_mask */
293 #define REDRAW_NONE (0)
294 #define REDRAW_ALL (1 << 0)
295 #define REDRAW_FIELD (1 << 1)
296 #define REDRAW_TILES (1 << 2)
297 #define REDRAW_DOOR_1 (1 << 3)
298 #define REDRAW_VIDEO_1 (1 << 4)
299 #define REDRAW_VIDEO_2 (1 << 5)
300 #define REDRAW_VIDEO_3 (1 << 6)
301 #define REDRAW_MICROLEVEL (1 << 7)
302 #define REDRAW_MICROLABEL (1 << 8)
303 #define REDRAW_FROM_BACKBUFFER (1 << 9)
304 #define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
307 #define REDRAW_DOOR_3 (1 << 10)
308 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
311 #define REDRAW_MAIN (REDRAW_FIELD | \
314 #define REDRAW_FPS (1 << 11)
316 #if defined(TARGET_X11)
317 /* on old-style, classic and potentially slow graphics systems, redraw single
318 tiles instead of the whole playfield unless a certain threshold is reached;
319 when using the X11 target, this method should still be fast on all systems */
320 #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
322 /* on modern graphics systems and when using the SDL target, this tile redraw
323 optimization can slow things down a lot due to many small blits compared to
324 one single playfield-sized blit (especially observed on Mac OS X with SDL) */
325 #define REDRAWTILES_THRESHOLD 0
328 #define IN_GFX_FIELD_PLAY(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
329 y >= gfx.sy && y < gfx.sy + gfx.sysize)
330 #define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \
331 x < gfx.real_sx + gfx.full_sxsize && \
332 y >= gfx.real_sy && \
333 y < gfx.real_sy + gfx.full_sysize)
334 #define IN_GFX_DOOR_1(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
335 y >= gfx.dy && y < gfx.dy + gfx.dysize)
336 #define IN_GFX_DOOR_2(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
337 y >= gfx.vy && y < gfx.vy + gfx.vysize)
338 #define IN_GFX_DOOR_3(x, y) (x >= gfx.ex && x < gfx.ex + gfx.exsize && \
339 y >= gfx.ey && y < gfx.ey + gfx.eysize)
341 /* values for mouse cursor */
342 #define CURSOR_DEFAULT 0
343 #define CURSOR_NONE 1
344 #define CURSOR_PLAYFIELD 2
346 /* fundamental game speed values */
347 #define ONE_SECOND_DELAY 1000 /* delay value for one second */
348 #define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
349 #define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
350 #define FRAMES_PER_SECOND (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
351 #define FRAMES_PER_SECOND_SP 35
353 /* maximum playfield size supported by libgame functions */
354 #define MAX_PLAYFIELD_WIDTH 128
355 #define MAX_PLAYFIELD_HEIGHT 128
357 /* maximum number of parallel players supported by libgame functions */
358 #define MAX_PLAYERS 4
360 /* maximum allowed length of player name */
361 #define MAX_PLAYER_NAME_LEN 10
363 /* maximum number of levels in a level set */
364 #define MAX_LEVELS 1000
366 /* default name for empty highscore entry */
367 #define EMPTY_PLAYER_NAME "no name"
369 /* default name for unknown player names */
370 #define ANONYMOUS_NAME "anonymous"
372 /* default for other unknown names */
373 #define UNKNOWN_NAME "unknown"
375 /* default name for new levels */
376 #define NAMELESS_LEVEL_NAME "nameless level"
378 /* default text for non-existant artwork */
379 #define NOT_AVAILABLE "(not available)"
381 /* default value for undefined filename */
382 #define UNDEFINED_FILENAME "[NONE]"
384 /* default value for undefined parameter */
385 #define ARG_DEFAULT "[DEFAULT]"
387 /* default values for undefined configuration file parameters */
388 #define ARG_UNDEFINED "-1000000"
389 #define ARG_UNDEFINED_VALUE (-1000000)
391 /* default value for off-screen positions */
392 #define POS_OFFSCREEN (-1000000)
394 /* definitions for game sub-directories */
396 #define RO_GAME_DIR "."
400 #define RW_GAME_DIR "."
403 #define RO_BASE_PATH RO_GAME_DIR
404 #define RW_BASE_PATH RW_GAME_DIR
406 /* directory names */
407 #define GRAPHICS_DIRECTORY "graphics"
408 #define SOUNDS_DIRECTORY "sounds"
409 #define MUSIC_DIRECTORY "music"
410 #define LEVELS_DIRECTORY "levels"
411 #define TAPES_DIRECTORY "tapes"
412 #define SCORES_DIRECTORY "scores"
413 #define DOCS_DIRECTORY "docs"
414 #define CACHE_DIRECTORY "cache"
416 #define GFX_CLASSIC_SUBDIR "gfx_classic"
417 #define SND_CLASSIC_SUBDIR "snd_classic"
418 #define MUS_CLASSIC_SUBDIR "mus_classic"
420 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
421 #define GFX_DEFAULT_SUBDIR "jue0"
422 #define SND_DEFAULT_SUBDIR "jue0"
423 #define MUS_DEFAULT_SUBDIR "jue0"
425 #define GFX_DEFAULT_SUBDIR GFX_CLASSIC_SUBDIR
426 #define SND_DEFAULT_SUBDIR SND_CLASSIC_SUBDIR
427 #define MUS_DEFAULT_SUBDIR MUS_CLASSIC_SUBDIR
430 #if defined(CREATE_SPECIAL_EDITION)
431 #define GFX_FALLBACK_FILENAME "fallback.pcx"
432 #define SND_FALLBACK_FILENAME "fallback.wav"
433 #define MUS_FALLBACK_FILENAME "fallback.wav"
436 /* file names and filename extensions */
437 #define LEVELSETUP_DIRECTORY "levelsetup"
438 #define SETUP_FILENAME "setup.conf"
439 #define LEVELSETUP_FILENAME "levelsetup.conf"
440 #define EDITORSETUP_FILENAME "editorsetup.conf"
441 #define EDITORCASCADE_FILENAME "editorcascade.conf"
442 #define HELPANIM_FILENAME "helpanim.conf"
443 #define HELPTEXT_FILENAME "helptext.conf"
444 #define LEVELINFO_FILENAME "levelinfo.conf"
445 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
446 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
447 #define MUSICINFO_FILENAME "musicinfo.conf"
448 #define ARTWORKINFO_CACHE_FILE "artworkinfo.cache"
449 #define LEVELFILE_EXTENSION "level"
450 #define TAPEFILE_EXTENSION "tape"
451 #define SCOREFILE_EXTENSION "score"
453 #define ERROR_BASENAME "stderr.txt"
455 #define CHAR_PATH_SEPARATOR_UNIX '/'
456 #define CHAR_PATH_SEPARATOR_DOS '\\'
458 #define STRING_PATH_SEPARATOR_UNIX "/"
459 #define STRING_PATH_SEPARATOR_DOS "\\"
461 #define STRING_NEWLINE_UNIX "\n"
462 #define STRING_NEWLINE_DOS "\r\n"
464 #if defined(PLATFORM_WIN32)
465 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_DOS
466 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_DOS
467 #define STRING_NEWLINE STRING_NEWLINE_DOS
469 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_UNIX
470 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_UNIX
471 #define STRING_NEWLINE STRING_NEWLINE_UNIX
475 /* areas in bitmap PIX_DOOR */
476 /* meaning in PIX_DB_DOOR: (3 PAGEs)
477 PAGEX1: 1. buffer for DOOR_1
478 PAGEX2: 2. buffer for DOOR_1
479 PAGEX3: buffer for animations
482 /* these values are hard-coded to be able to use them in initialization */
483 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
484 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
486 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
487 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
488 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
489 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
490 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
491 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
492 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
493 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
494 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
495 #define DOOR_GFX_PAGEY1 (0)
496 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
499 /* macros for version handling */
500 #define VERSION_MAJOR(x) ((x) / 1000000)
501 #define VERSION_MINOR(x) (((x) % 1000000) / 10000)
502 #define VERSION_PATCH(x) (((x) % 10000) / 100)
503 #define VERSION_BUILD(x) ((x) % 100)
504 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
507 /* macros for parent/child process identification */
508 #if defined(PLATFORM_UNIX)
509 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
510 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
511 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
513 #define IS_PARENT_PROCESS() TRUE
514 #define IS_CHILD_PROCESS() FALSE
515 #define HAS_CHILD_PROCESS() FALSE
519 /* values for artwork type */
520 #define ARTWORK_TYPE_GRAPHICS 0
521 #define ARTWORK_TYPE_SOUNDS 1
522 #define ARTWORK_TYPE_MUSIC 2
524 #define NUM_ARTWORK_TYPES 3
527 /* values for tree type (chosen to match artwork type) */
528 #define TREE_TYPE_UNDEFINED -1
529 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
530 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
531 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
532 #define TREE_TYPE_LEVEL_DIR 3
533 #define TREE_TYPE_LEVEL_NR 4
535 #define NUM_TREE_TYPES 5
537 #define INFOTEXT_UNDEFINED ""
538 #define INFOTEXT_GRAPHICS_DIR "Custom Graphics"
539 #define INFOTEXT_SOUNDS_DIR "Custom Sounds"
540 #define INFOTEXT_MUSIC_DIR "Custom Music"
541 #define INFOTEXT_LEVEL_DIR "Level Sets"
542 #define INFOTEXT_LEVEL_NR "Levels"
544 #define TREE_INFOTEXT(t) ((t) == TREE_TYPE_LEVEL_NR ? \
545 INFOTEXT_LEVEL_NR : \
546 (t) == TREE_TYPE_LEVEL_DIR ? \
547 INFOTEXT_LEVEL_DIR : \
548 (t) == TREE_TYPE_GRAPHICS_DIR ? \
549 INFOTEXT_GRAPHICS_DIR : \
550 (t) == TREE_TYPE_SOUNDS_DIR ? \
551 INFOTEXT_SOUNDS_DIR : \
552 (t) == TREE_TYPE_MUSIC_DIR ? \
553 INFOTEXT_MUSIC_DIR : \
556 /* values for artwork handling */
557 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
558 ((type) == ARTWORK_TYPE_GRAPHICS ? \
559 &(leveldir)->graphics_set : \
560 (type) == ARTWORK_TYPE_SOUNDS ? \
561 &(leveldir)->sounds_set : \
562 &(leveldir)->music_set)
564 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
565 ((type) == ARTWORK_TYPE_GRAPHICS ? \
566 (leveldir)->graphics_set : \
567 (type) == ARTWORK_TYPE_SOUNDS ? \
568 (leveldir)->sounds_set : \
569 (leveldir)->music_set)
571 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
572 ((type) == ARTWORK_TYPE_GRAPHICS ? \
573 &(leveldir)->graphics_path : \
574 (type) == ARTWORK_TYPE_SOUNDS ? \
575 &(leveldir)->sounds_path : \
576 &(leveldir)->music_path)
578 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
579 ((type) == ARTWORK_TYPE_GRAPHICS ? \
580 (leveldir)->graphics_path : \
581 (type) == ARTWORK_TYPE_SOUNDS ? \
582 (leveldir)->sounds_path : \
583 (leveldir)->music_path)
585 #define SETUP_ARTWORK_SET(setup, type) \
586 ((type) == ARTWORK_TYPE_GRAPHICS ? \
587 (setup).graphics_set : \
588 (type) == ARTWORK_TYPE_SOUNDS ? \
589 (setup).sounds_set : \
592 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
593 ((type) == ARTWORK_TYPE_GRAPHICS ? \
594 (setup).override_level_graphics : \
595 (type) == ARTWORK_TYPE_SOUNDS ? \
596 (setup).override_level_sounds : \
597 (setup).override_level_music)
599 #define GFX_OVERRIDE_ARTWORK(type) \
600 ((type) == ARTWORK_TYPE_GRAPHICS ? \
601 gfx.override_level_graphics : \
602 (type) == ARTWORK_TYPE_SOUNDS ? \
603 gfx.override_level_sounds : \
604 gfx.override_level_music)
606 #define ARTWORK_FIRST_NODE(artwork, type) \
607 ((type) == ARTWORK_TYPE_GRAPHICS ? \
608 (artwork).gfx_first : \
609 (type) == ARTWORK_TYPE_SOUNDS ? \
610 (artwork).snd_first : \
613 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
614 ((type) == ARTWORK_TYPE_GRAPHICS ? \
615 &(artwork).gfx_current_identifier : \
616 (type) == ARTWORK_TYPE_SOUNDS ? \
617 &(artwork).snd_current_identifier : \
618 &(artwork).mus_current_identifier)
620 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
621 ((type) == ARTWORK_TYPE_GRAPHICS ? \
622 (artwork).gfx_current_identifier : \
623 (type) == ARTWORK_TYPE_SOUNDS ? \
624 (artwork).snd_current_identifier : \
625 (artwork).mus_current_identifier)
627 #define ARTWORKINFO_FILENAME(type) \
628 ((type) == ARTWORK_TYPE_GRAPHICS ? \
629 GRAPHICSINFO_FILENAME : \
630 (type) == ARTWORK_TYPE_SOUNDS ? \
631 SOUNDSINFO_FILENAME : \
632 (type) == ARTWORK_TYPE_MUSIC ? \
633 MUSICINFO_FILENAME : "")
635 #define ARTWORK_DIRECTORY(type) \
636 ((type) == ARTWORK_TYPE_GRAPHICS ? \
637 GRAPHICS_DIRECTORY : \
638 (type) == ARTWORK_TYPE_SOUNDS ? \
640 (type) == ARTWORK_TYPE_MUSIC ? \
641 MUSIC_DIRECTORY : "")
643 #define OPTIONS_ARTWORK_DIRECTORY(type) \
644 ((type) == ARTWORK_TYPE_GRAPHICS ? \
645 options.graphics_directory : \
646 (type) == ARTWORK_TYPE_SOUNDS ? \
647 options.sounds_directory : \
648 (type) == ARTWORK_TYPE_MUSIC ? \
649 options.music_directory : "")
651 #define UPDATE_BUSY_STATE() \
653 if (gfx.draw_busy_anim_function != NULL) \
654 gfx.draw_busy_anim_function(); \
658 /* type definitions */
659 #if defined(TARGET_SDL2)
660 typedef int (*EventFilter)(void *, Event *);
662 typedef int (*EventFilter)(const Event *);
666 /* structure definitions */
670 char *command_basepath; /* path to the program binary */
671 char *command_basename; /* base filename of the program binary */
673 char *maindata_path; /* main game data (installation) directory */
675 char *userdata_subdir; /* personal user game data directory */
676 char *userdata_subdir_unix; /* personal user game data directory (Unix) */
677 char *userdata_path; /* resulting full path to game data directory */
683 char *x11_icon_filename;
684 char *x11_iconmask_filename;
685 char *sdl_icon_filename;
688 char *filename_prefix; /* prefix to cut off from DOS filenames */
690 char *error_filename; /* filename where to write error messages to */
691 FILE *error_file; /* (used instead of 'stderr' on some systems) */
697 char *(*window_title_function)(void);
698 void (*exit_message_function)(char *, va_list);
699 void (*exit_function)(int);
708 char *ro_base_directory;
709 char *rw_base_directory;
710 char *level_directory;
711 char *graphics_directory;
712 char *sounds_directory;
713 char *music_directory;
714 char *docs_directory;
716 char *execute_command;
724 boolean debug_x11_sync;
727 struct ScreenModeInfo
732 struct VideoSystemInfo
735 int width, height, depth;
736 int window_width, window_height;
738 boolean fullscreen_available;
739 boolean fullscreen_enabled;
740 boolean fullscreen_initial;
741 struct ScreenModeInfo *fullscreen_modes;
742 char *fullscreen_mode_current;
744 boolean window_scaling_available;
745 int window_scaling_percent;
746 char *window_scaling_quality;
749 struct AudioSystemInfo
751 boolean sound_available;
752 boolean loops_available;
753 boolean music_available;
755 boolean sound_enabled;
756 boolean sound_deactivated; /* for temporarily disabling sound */
765 int first_sound_channel;
768 struct FontBitmapInfo
772 int src_x, src_y; /* start position of animation frames */
773 int width, height; /* width/height of each animation frame */
775 int draw_xoffset; /* offset for drawing font characters */
776 int draw_yoffset; /* offset for drawing font characters */
779 int num_chars_per_line;
781 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
782 Pixmap *clip_mask; /* single-char-only clip mask array for X11 */
790 int real_sx, real_sy;
791 int full_sxsize, full_sysize;
792 int scrollbuffer_width, scrollbuffer_height;
803 int win_xsize, win_ysize;
805 int draw_deactivation_mask;
806 int draw_background_mask;
808 Bitmap *field_save_buffer;
810 Bitmap *background_bitmap;
811 int background_bitmap_mask;
813 boolean clipping_enabled;
815 int clip_width, clip_height;
817 boolean override_level_graphics;
818 boolean override_level_sounds;
819 boolean override_level_music;
821 boolean draw_init_text;
824 struct FontBitmapInfo *font_bitmap_info;
825 int (*select_font_function)(int);
826 int (*get_font_from_token_function)(char *);
828 int anim_random_frame;
830 void (*draw_busy_anim_function)(void);
836 int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */
839 struct SetupJoystickInfo
841 char *device_name; /* device name of player's joystick */
843 int xleft, xmiddle, xright;
844 int yupper, ymiddle, ylower;
848 struct SetupKeyboardInfo
850 Key left, right, up, down;
854 struct SetupTouchInfo
861 struct SetupInputInfo
863 boolean use_joystick;
864 struct SetupJoystickInfo joy;
865 struct SetupKeyboardInfo key;
868 struct SetupEditorInfo
870 boolean el_boulderdash;
871 boolean el_emerald_mine;
872 boolean el_emerald_mine_club;
876 boolean el_diamond_caves;
877 boolean el_dx_boulderdash;
879 boolean el_steel_chars;
881 boolean el_user_defined;
884 boolean el_headlines;
889 boolean show_element_token;
892 struct SetupEditorCascadeInfo
903 boolean el_steel_chars;
911 struct SetupShortcutInfo
917 Key focus_player[MAX_PLAYERS];
918 Key focus_player_all;
937 struct SetupSystemInfo
939 char *sdl_videodriver;
940 char *sdl_audiodriver;
941 int audio_fragment_size;
951 boolean sound_simple;
953 boolean scroll_delay;
954 boolean scroll_delay_value;
955 boolean soft_scrolling;
956 boolean fade_screens;
958 boolean show_titlescreen;
965 char *fullscreen_mode;
966 int window_scaling_percent;
967 char *window_scaling_quality;
968 boolean ask_on_escape;
969 boolean ask_on_escape_editor;
970 boolean quick_switch;
971 boolean input_on_focus;
972 boolean prefer_aga_graphics;
973 int game_frame_delay;
974 boolean sp_show_border_elements;
975 boolean small_game_graphics;
980 int override_level_graphics; /* not boolean -- can also be "AUTO" */
981 int override_level_sounds; /* not boolean -- can also be "AUTO" */
982 int override_level_music; /* not boolean -- can also be "AUTO" */
988 struct SetupEditorInfo editor;
989 struct SetupEditorCascadeInfo editor_cascade;
990 struct SetupShortcutInfo shortcut;
991 struct SetupInputInfo input[MAX_PLAYERS];
992 struct SetupTouchInfo touch;
993 struct SetupSystemInfo system;
994 struct OptionInfo options;
999 struct TreeInfo **node_top; /* topmost node in tree */
1000 struct TreeInfo *node_parent; /* parent level directory info */
1001 struct TreeInfo *node_group; /* level group sub-directory info */
1002 struct TreeInfo *next; /* next level series structure node */
1004 int cl_first; /* internal control field for setup screen */
1005 int cl_cursor; /* internal control field for setup screen */
1007 int type; /* type of tree content */
1009 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
1011 char *subdir; /* tree info sub-directory basename (may be ".") */
1012 char *fullpath; /* complete path relative to tree base directory */
1013 char *basepath; /* absolute base path of tree base directory */
1014 char *identifier; /* identifier string for configuration files */
1015 char *name; /* tree info name, as displayed in selection menues */
1016 char *name_sorting; /* optional sorting name for correct name sorting */
1017 char *author; /* level or artwork author name */
1018 char *year; /* optional year of creation for levels or artwork */
1019 char *imported_from; /* optional comment for imported levels or artwork */
1020 char *imported_by; /* optional comment for imported levels or artwork */
1021 char *tested_by; /* optional comment to name people who tested a set */
1023 char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */
1024 char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */
1025 char *graphics_set; /* optional custom graphics set (level tree only) */
1026 char *sounds_set; /* optional custom sounds set (level tree only) */
1027 char *music_set; /* optional custom music set (level tree only) */
1028 char *graphics_path; /* path to optional custom graphics set (level only) */
1029 char *sounds_path; /* path to optional custom sounds set (level only) */
1030 char *music_path; /* path to optional custom music set (level only) */
1032 char *level_filename; /* filename of level file (for packed level file) */
1033 char *level_filetype; /* type of levels in level directory or level file */
1035 char *special_flags; /* flags for special actions performed on level file */
1037 int levels; /* number of levels in level series */
1038 int first_level; /* first level number (to allow start with 0 or 1) */
1039 int last_level; /* last level number (automatically calculated) */
1040 int sort_priority; /* sort levels by 'sort_priority' and then by name */
1042 boolean latest_engine;/* force level set to use the latest game engine */
1044 boolean level_group; /* directory contains more level series directories */
1045 boolean parent_link; /* entry links back to parent directory */
1046 boolean in_user_dir; /* user defined levels are stored in home directory */
1047 boolean user_defined; /* levels in user directory and marked as "private" */
1048 boolean readonly; /* readonly levels can not be changed with editor */
1049 boolean handicap; /* level set has no handicap when set to "false" */
1050 boolean skip_levels; /* levels can be skipped when set to "true" */
1052 int color; /* color to use on selection screen for this level */
1053 char *class_desc; /* description of level series class */
1054 int handicap_level; /* number of the lowest unsolved level */
1056 char *infotext; /* optional text to describe the tree type (headline) */
1059 typedef struct TreeInfo TreeInfo;
1060 typedef struct TreeInfo LevelDirTree;
1061 typedef struct TreeInfo ArtworkDirTree;
1062 typedef struct TreeInfo GraphicsDirTree;
1063 typedef struct TreeInfo SoundsDirTree;
1064 typedef struct TreeInfo MusicDirTree;
1068 GraphicsDirTree *gfx_first;
1069 GraphicsDirTree *gfx_current;
1070 SoundsDirTree *snd_first;
1071 SoundsDirTree *snd_current;
1072 MusicDirTree *mus_first;
1073 MusicDirTree *mus_current;
1075 char *gfx_current_identifier;
1076 char *snd_current_identifier;
1077 char *mus_current_identifier;
1080 struct ValueTextInfo
1092 struct ConfigTypeInfo
1099 struct TokenIntPtrInfo
1109 char *default_filename;
1112 char **default_parameter; /* array of file parameters */
1113 char **parameter; /* array of file parameters */
1116 boolean fallback_to_default;
1117 boolean default_is_cloned;
1120 struct SetupFileList
1125 struct SetupFileList *next;
1130 char *source_filename; /* primary key for node list */
1134 struct PropertyMapping
1144 struct ArtworkListInfo
1146 int type; /* type of artwork */
1148 int num_file_list_entries;
1149 int num_dynamic_file_list_entries;
1150 struct FileInfo *file_list; /* static artwork file array */
1151 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
1153 int num_suffix_list_entries;
1154 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
1156 int num_base_prefixes;
1157 int num_ext1_suffixes;
1158 int num_ext2_suffixes;
1159 int num_ext3_suffixes;
1160 char **base_prefixes; /* base token prefixes array */
1161 char **ext1_suffixes; /* property suffixes array 1 */
1162 char **ext2_suffixes; /* property suffixes array 2 */
1163 char **ext3_suffixes; /* property suffixes array 3 */
1165 int num_ignore_tokens;
1166 char **ignore_tokens; /* file tokens to be ignored */
1168 int num_property_mapping_entries;
1169 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
1171 int sizeof_artwork_list_entry;
1173 struct ListNodeInfo **artwork_list; /* static artwork node array */
1174 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
1175 struct ListNode *content_list; /* dynamic artwork node list */
1177 void *(*load_artwork)(char *); /* constructor function */
1178 void (*free_artwork)(void *); /* destructor function */
1192 struct RectWithBorder
1206 struct DoorPartPosInfo
1213 int start_step_opening;
1214 int start_step_closing;
1215 boolean draw_masked;
1226 boolean draw_masked;
1227 boolean draw_player; /* special case for network player buttons */
1239 /* ========================================================================= */
1240 /* exported variables */
1241 /* ========================================================================= */
1243 extern struct ProgramInfo program;
1244 extern struct OptionInfo options;
1245 extern struct VideoSystemInfo video;
1246 extern struct AudioSystemInfo audio;
1247 extern struct GfxInfo gfx;
1248 extern struct AnimInfo anim;
1249 extern struct ArtworkInfo artwork;
1250 extern struct JoystickInfo joystick;
1251 extern struct SetupInfo setup;
1253 extern LevelDirTree *leveldir_first_all;
1254 extern LevelDirTree *leveldir_first;
1255 extern LevelDirTree *leveldir_current;
1256 extern int level_nr;
1258 extern struct LevelStats level_stats[];
1260 extern Display *display;
1261 extern Visual *visual;
1263 extern Colormap cmap;
1265 extern DrawWindow *window;
1266 extern DrawBuffer *backbuffer;
1267 extern DrawBuffer *drawto;
1269 extern int button_status;
1270 extern boolean motion_status;
1271 #if defined(TARGET_SDL2)
1272 extern boolean keyrepeat_status;
1275 extern int redraw_mask;
1276 extern int redraw_tiles;
1278 extern int FrameCounter;
1281 /* function definitions */
1284 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1285 char *, char *, char *, int);
1287 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1288 char *, char *, char *, char *, char *, int);
1291 void SetWindowTitle();
1293 void InitWindowTitleFunction(char *(*window_title_function)(void));
1294 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
1295 void InitExitFunction(void (*exit_function)(int));
1296 void InitPlatformDependentStuff(void);
1297 void ClosePlatformDependentStuff(void);
1299 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1300 void InitGfxDoor1Info(int, int, int, int);
1301 void InitGfxDoor2Info(int, int, int, int);
1302 void InitGfxDoor3Info(int, int, int, int);
1303 void InitGfxWindowInfo(int, int);
1304 void InitGfxScrollbufferInfo(int, int);
1305 void InitGfxClipRegion(boolean, int, int, int, int);
1306 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
1307 void InitGfxCustomArtworkInfo();
1308 void SetDrawDeactivationMask(int);
1309 void SetDrawBackgroundMask(int);
1310 void SetWindowBackgroundBitmap(Bitmap *);
1311 void SetMainBackgroundBitmap(Bitmap *);
1312 void SetDoorBackgroundBitmap(Bitmap *);
1314 void LimitScreenUpdates(boolean);
1316 void InitVideoDisplay(void);
1317 void CloseVideoDisplay(void);
1318 void InitVideoBuffer(int, int, int, boolean);
1319 Bitmap *CreateBitmapStruct(void);
1320 Bitmap *CreateBitmap(int, int, int);
1321 void ReCreateBitmap(Bitmap **, int, int, int);
1322 void FreeBitmap(Bitmap *);
1323 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1324 void BlitBitmapTiled(Bitmap *, Bitmap *, int, int, int, int, int, int, int,int);
1325 void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int,
1326 void (*draw_border_function)(void));
1327 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1328 void ClearRectangle(Bitmap *, int, int, int, int);
1329 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1330 void SetClipMask(Bitmap *, GC, Pixmap);
1331 void SetClipOrigin(Bitmap *, GC, int, int);
1332 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1333 boolean DrawingOnBackground(int, int);
1334 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1335 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1336 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1337 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1338 Pixel GetPixel(Bitmap *, int, int);
1339 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1340 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1342 void FlushDisplay(void);
1343 void SyncDisplay(void);
1344 void KeyboardAutoRepeatOn(void);
1345 void KeyboardAutoRepeatOff(void);
1346 boolean PointerInWindow(DrawWindow *);
1347 boolean SetVideoMode(boolean);
1348 boolean ChangeVideoModeIfNeeded(boolean);
1350 Bitmap *LoadImage(char *);
1351 Bitmap *LoadCustomImage(char *);
1352 void ReloadCustomImage(Bitmap *, char *);
1354 Bitmap *ZoomBitmap(Bitmap *, int, int);
1355 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
1356 void ScaleBitmap(Bitmap *, int);
1358 void SetMouseCursor(int);
1360 void OpenAudio(void);
1361 void CloseAudio(void);
1362 void SetAudioMode(boolean);
1364 void InitEventFilter(EventFilter);
1365 boolean PendingEvent(void);
1366 void NextEvent(Event *event);
1367 void PeekEvent(Event *event);
1368 Key GetEventKey(KeyEvent *, boolean);
1369 KeyMod HandleKeyModState(Key, int);
1370 KeyMod GetKeyModState();
1371 KeyMod GetKeyModStateFromEvents();
1372 boolean CheckCloseWindowEvent(ClientMessageEvent *);
1374 void InitJoysticks();
1375 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1377 #endif /* SYSTEM_H */