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_MSDOS)
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 #define FULLSCREEN_NOT_AVAILABLE FALSE
49 #define FULLSCREEN_AVAILABLE TRUE
51 /* default input keys */
52 #define DEFAULT_KEY_LEFT KSYM_Left
53 #define DEFAULT_KEY_RIGHT KSYM_Right
54 #define DEFAULT_KEY_UP KSYM_Up
55 #define DEFAULT_KEY_DOWN KSYM_Down
56 #if defined(PLATFORM_MACOSX)
57 #define DEFAULT_KEY_SNAP KSYM_Control_L
58 #define DEFAULT_KEY_DROP KSYM_KP_Enter
60 #define DEFAULT_KEY_SNAP KSYM_Control_L
61 #define DEFAULT_KEY_DROP KSYM_Control_R
63 #define DEFAULT_KEY_OKAY KSYM_Return
64 #define DEFAULT_KEY_CANCEL KSYM_Escape
66 /* default shortcut keys */
67 #define DEFAULT_KEY_SAVE_GAME KSYM_F1
68 #define DEFAULT_KEY_LOAD_GAME KSYM_F2
69 #define DEFAULT_KEY_TOGGLE_PAUSE KSYM_space
70 #define DEFAULT_KEY_FOCUS_PLAYER_1 KSYM_F5
71 #define DEFAULT_KEY_FOCUS_PLAYER_2 KSYM_F6
72 #define DEFAULT_KEY_FOCUS_PLAYER_3 KSYM_F7
73 #define DEFAULT_KEY_FOCUS_PLAYER_4 KSYM_F8
74 #define DEFAULT_KEY_FOCUS_PLAYER_ALL KSYM_F9
76 /* values for key_status */
77 #define KEY_NOT_PRESSED FALSE
78 #define KEY_RELEASED FALSE
79 #define KEY_PRESSED TRUE
81 /* values for button status */
82 #define MB_NOT_PRESSED FALSE
83 #define MB_NOT_RELEASED TRUE
84 #define MB_RELEASED FALSE
85 #define MB_PRESSED TRUE
86 #define MB_MENU_CHOICE FALSE
87 #define MB_MENU_MARK TRUE
88 #define MB_MENU_INITIALIZE (-1)
89 #define MB_MENU_LEAVE (-2)
90 #define MB_LEFTBUTTON 1
91 #define MB_MIDDLEBUTTON 2
92 #define MB_RIGHTBUTTON 3
94 #define MB_WHEEL_DOWN 5
95 #define MB_WHEEL_LEFT 6
96 #define MB_WHEEL_RIGHT 7
97 #define IS_WHEEL_BUTTON_VERTICAL(b) ((b) >= MB_WHEEL_UP && \
99 #define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) >= MB_WHEEL_LEFT && \
100 (b) <= MB_WHEEL_RIGHT)
101 #define IS_WHEEL_BUTTON(b) ((b) >= MB_WHEEL_UP && \
102 (b) <= MB_WHEEL_DOWN)
103 #define DEFAULT_WHEEL_STEPS 3
105 /* values for move directions */
106 #define MV_BIT_LEFT 0
107 #define MV_BIT_RIGHT 1
109 #define MV_BIT_DOWN 3
111 #define NUM_DIRECTIONS 4
113 /* diagonal movement directions are used in a different contect than buttons */
114 #define MV_BIT_UPLEFT 4
115 #define MV_BIT_UPRIGHT 5
116 #define MV_BIT_DOWNLEFT 6
117 #define MV_BIT_DOWNRIGHT 7
119 #define NUM_DIRECTIONS_FULL 8
121 /* values for special "button" bitmasks */
125 /* values for special "focus player" bitmasks */
126 #define BIT_SET_FOCUS 6
128 /* values for move directions and special "button" key bitmasks */
130 #define MV_LEFT (1 << MV_BIT_LEFT)
131 #define MV_RIGHT (1 << MV_BIT_RIGHT)
132 #define MV_UP (1 << MV_BIT_UP)
133 #define MV_DOWN (1 << MV_BIT_DOWN)
135 #define MV_UPLEFT (MV_UP | MV_LEFT)
136 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
137 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
138 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
140 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
141 #define MV_VERTICAL (MV_UP | MV_DOWN)
142 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
143 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
144 #define MV_NO_DIRECTION (MV_NONE)
146 #define KEY_BUTTON_1 (1 << BUTTON_1)
147 #define KEY_BUTTON_2 (1 << BUTTON_2)
148 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
149 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
150 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
152 #define KEY_SET_FOCUS (1 << BIT_SET_FOCUS)
154 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
155 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
156 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
157 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
158 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
161 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
162 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
163 (x) == MV_UP ? MV_BIT_UP : \
164 (x) == MV_DOWN ? MV_BIT_DOWN : \
165 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
166 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
167 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
168 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
171 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
172 (x) == MV_RIGHT ? MV_LEFT : \
173 (x) == MV_UP ? MV_DOWN : \
174 (x) == MV_DOWN ? MV_UP : \
175 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
176 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
177 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
178 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
181 /* values for animation mode (frame order and direction) */
183 #define ANIM_LOOP (1 << 0)
184 #define ANIM_LINEAR (1 << 1)
185 #define ANIM_PINGPONG (1 << 2)
186 #define ANIM_PINGPONG2 (1 << 3)
187 #define ANIM_RANDOM (1 << 4)
188 #define ANIM_CE_VALUE (1 << 5)
189 #define ANIM_CE_SCORE (1 << 6)
190 #define ANIM_CE_DELAY (1 << 7)
191 #define ANIM_REVERSE (1 << 8)
192 #define ANIM_OPAQUE_PLAYER (1 << 9)
194 /* values for special (non game element) animation modes */
195 #define ANIM_HORIZONTAL (1 << 10)
196 #define ANIM_VERTICAL (1 << 11)
197 #define ANIM_CENTERED (1 << 12)
198 #define ANIM_STATIC_PANEL (1 << 13)
199 #define ANIM_FADE (1 << 14)
200 #define ANIM_CROSSFADE (1 << 15)
202 #define ANIM_DEFAULT ANIM_LOOP
204 /* values for text alignment */
205 #define ALIGN_LEFT (1 << 0)
206 #define ALIGN_RIGHT (1 << 1)
207 #define ALIGN_CENTER (1 << 2)
209 #define ALIGN_DEFAULT ALIGN_LEFT
211 #define ALIGNED_XPOS(x,w,a) ((a) == ALIGN_CENTER ? (x) - (w) / 2 : \
212 (a) == ALIGN_RIGHT ? (x) - (w) : (x))
213 #define ALIGNED_MENU_XPOS(p) ALIGNED_XPOS((p)->x, (p)->width, (p)->align)
214 #define ALIGNED_MENU_YPOS(p) ((p)->y)
216 /* values for redraw_mask */
217 #define REDRAW_NONE (0)
218 #define REDRAW_ALL (1 << 0)
219 #define REDRAW_FIELD (1 << 1)
220 #define REDRAW_TILES (1 << 2)
221 #define REDRAW_DOOR_1 (1 << 3)
222 #define REDRAW_VIDEO_1 (1 << 4)
223 #define REDRAW_VIDEO_2 (1 << 5)
224 #define REDRAW_VIDEO_3 (1 << 6)
225 #define REDRAW_MICROLEVEL (1 << 7)
226 #define REDRAW_MICROLABEL (1 << 8)
227 #define REDRAW_FROM_BACKBUFFER (1 << 9)
228 #define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
231 #define REDRAW_DOOR_3 (1 << 10)
232 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
235 #define REDRAW_MAIN (REDRAW_FIELD | \
238 #define REDRAW_FPS (1 << 11)
239 #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
241 #define FADE_MODE_FADE_IN 0
242 #define FADE_MODE_FADE_OUT 1
243 #define FADE_MODE_CROSSFADE 2
245 #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
246 y >= gfx.sy && y < gfx.sy + gfx.sysize)
247 #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
248 y >= gfx.dy && y < gfx.dy + gfx.dysize)
249 #define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
250 y >= gfx.vy && y < gfx.vy + gfx.vysize)
252 /* values for mouse cursor */
253 #define CURSOR_DEFAULT 0
254 #define CURSOR_PLAYFIELD 1
256 /* fundamental game speed values */
257 #define ONE_SECOND_DELAY 1000 /* delay value for one second */
258 #define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
259 #define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
260 #define FRAMES_PER_SECOND (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
262 /* maximum playfield size supported by libgame functions */
263 #define MAX_PLAYFIELD_WIDTH 128
264 #define MAX_PLAYFIELD_HEIGHT 128
266 /* maximum number of parallel players supported by libgame functions */
267 #define MAX_PLAYERS 4
269 /* maximum allowed length of player name */
270 #define MAX_PLAYER_NAME_LEN 10
272 /* default name for empty highscore entry */
273 #define EMPTY_PLAYER_NAME "no name"
275 /* default name for unknown player names */
276 #define ANONYMOUS_NAME "anonymous"
278 /* default for other unknown names */
279 #define UNKNOWN_NAME "unknown"
281 /* default name for new levels */
282 #define NAMELESS_LEVEL_NAME "nameless level"
284 /* default text for non-existant artwork */
285 #define NOT_AVAILABLE "(not available)"
287 /* default value for undefined filename */
288 #define UNDEFINED_FILENAME "[NONE]"
290 /* default value for undefined parameter */
291 #define ARG_DEFAULT "[DEFAULT]"
293 /* default values for undefined configuration file parameters */
294 #define ARG_UNDEFINED "-1000000"
295 #define ARG_UNDEFINED_VALUE (atoi(ARG_UNDEFINED))
297 /* definitions for game sub-directories */
299 #define RO_GAME_DIR "."
303 #define RW_GAME_DIR "."
306 #define RO_BASE_PATH RO_GAME_DIR
307 #define RW_BASE_PATH RW_GAME_DIR
309 /* directory names */
310 #define GRAPHICS_DIRECTORY "graphics"
311 #define SOUNDS_DIRECTORY "sounds"
312 #define MUSIC_DIRECTORY "music"
313 #define LEVELS_DIRECTORY "levels"
314 #define TAPES_DIRECTORY "tapes"
315 #define SCORES_DIRECTORY "scores"
316 #define DOCS_DIRECTORY "docs"
317 #define CACHE_DIRECTORY "cache"
319 #if !defined(PLATFORM_MSDOS)
320 #define GFX_CLASSIC_SUBDIR "gfx_classic"
321 #define SND_CLASSIC_SUBDIR "snd_classic"
322 #define MUS_CLASSIC_SUBDIR "mus_classic"
324 #define GFX_CLASSIC_SUBDIR "gfx_orig"
325 #define SND_CLASSIC_SUBDIR "snd_orig"
326 #define MUS_CLASSIC_SUBDIR "mus_orig"
329 /* file names and filename extensions */
330 #if !defined(PLATFORM_MSDOS)
331 #define LEVELSETUP_DIRECTORY "levelsetup"
332 #define SETUP_FILENAME "setup.conf"
333 #define LEVELSETUP_FILENAME "levelsetup.conf"
334 #define EDITORSETUP_FILENAME "editorsetup.conf"
335 #define EDITORCASCADE_FILENAME "editorcascade.conf"
336 #define HELPANIM_FILENAME "helpanim.conf"
337 #define HELPTEXT_FILENAME "helptext.conf"
338 #define LEVELINFO_FILENAME "levelinfo.conf"
339 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
340 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
341 #define MUSICINFO_FILENAME "musicinfo.conf"
342 #define ARTWORKINFO_CACHE_FILE "artworkinfo.cache"
343 #define LEVELFILE_EXTENSION "level"
344 #define TAPEFILE_EXTENSION "tape"
345 #define SCOREFILE_EXTENSION "score"
347 #define LEVELSETUP_DIRECTORY "lvlsetup"
348 #define SETUP_FILENAME "setup.cnf"
349 #define LEVELSETUP_FILENAME "lvlsetup.cnf"
350 #define EDITORSETUP_FILENAME "edsetup.cnf"
351 #define EDITORCASCADE_FILENAME "edcascad.conf"
352 #define HELPANIM_FILENAME "helpanim.cnf"
353 #define HELPTEXT_FILENAME "helptext.cnf"
354 #define LEVELINFO_FILENAME "lvlinfo.cnf"
355 #define GRAPHICSINFO_FILENAME "gfxinfo.cnf"
356 #define SOUNDSINFO_FILENAME "sndinfo.cnf"
357 #define MUSICINFO_FILENAME "musinfo.cnf"
358 #define ARTWORKINFO_CACHE_FILE "artinfo.cac"
359 #define LEVELFILE_EXTENSION "lvl"
360 #define TAPEFILE_EXTENSION "tap"
361 #define SCOREFILE_EXTENSION "sco"
364 #define ERROR_BASENAME "stderr.txt"
366 #define CHAR_PATH_SEPARATOR_UNIX '/'
367 #define CHAR_PATH_SEPARATOR_DOS '\\'
369 #define STRING_PATH_SEPARATOR_UNIX "/"
370 #define STRING_PATH_SEPARATOR_DOS "\\"
372 #define STRING_NEWLINE_UNIX "\n"
373 #define STRING_NEWLINE_DOS "\r\n"
375 #if defined(PLATFORM_WIN32) || defined(PLATFORM_MSDOS)
376 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_DOS
377 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_DOS
378 #define STRING_NEWLINE STRING_NEWLINE_DOS
380 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_UNIX
381 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_UNIX
382 #define STRING_NEWLINE STRING_NEWLINE_UNIX
386 /* areas in bitmap PIX_DOOR */
387 /* meaning in PIX_DB_DOOR: (3 PAGEs)
388 PAGEX1: 1. buffer for DOOR_1
389 PAGEX2: 2. buffer for DOOR_1
390 PAGEX3: buffer for animations
393 /* these values are hard-coded to be able to use them in initialization */
394 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
395 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
397 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
398 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
399 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
400 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
401 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
402 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
403 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
404 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
405 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
406 #define DOOR_GFX_PAGEY1 (0)
407 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
410 /* macros for version handling */
411 #define VERSION_MAJOR(x) ((x) / 1000000)
412 #define VERSION_MINOR(x) (((x) % 1000000) / 10000)
413 #define VERSION_PATCH(x) (((x) % 10000) / 100)
414 #define VERSION_BUILD(x) ((x) % 100)
415 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
418 /* macros for parent/child process identification */
419 #if defined(PLATFORM_UNIX)
420 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
421 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
422 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
424 #define IS_PARENT_PROCESS() TRUE
425 #define IS_CHILD_PROCESS() FALSE
426 #define HAS_CHILD_PROCESS() FALSE
430 /* values for artwork type */
431 #define ARTWORK_TYPE_GRAPHICS 0
432 #define ARTWORK_TYPE_SOUNDS 1
433 #define ARTWORK_TYPE_MUSIC 2
435 #define NUM_ARTWORK_TYPES 3
438 /* values for tree type (chosen to match artwork type) */
439 #define TREE_TYPE_UNDEFINED -1
440 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
441 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
442 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
443 #define TREE_TYPE_LEVEL_DIR 3
445 #define NUM_TREE_TYPES 4
447 #define INFOTEXT_UNDEFINED ""
448 #define INFOTEXT_GRAPHICS_DIR "Custom Graphics"
449 #define INFOTEXT_SOUNDS_DIR "Custom Sounds"
450 #define INFOTEXT_MUSIC_DIR "Custom Music"
451 #define INFOTEXT_LEVEL_DIR "Level Sets"
453 #define TREE_INFOTEXT(t) ((t) == TREE_TYPE_LEVEL_DIR ? \
454 INFOTEXT_LEVEL_DIR : \
455 (t) == TREE_TYPE_GRAPHICS_DIR ? \
456 INFOTEXT_GRAPHICS_DIR : \
457 (t) == TREE_TYPE_SOUNDS_DIR ? \
458 INFOTEXT_SOUNDS_DIR : \
459 (t) == TREE_TYPE_MUSIC_DIR ? \
460 INFOTEXT_MUSIC_DIR : \
463 /* values for artwork handling */
464 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
465 ((type) == ARTWORK_TYPE_GRAPHICS ? \
466 &(leveldir)->graphics_set : \
467 (type) == ARTWORK_TYPE_SOUNDS ? \
468 &(leveldir)->sounds_set : \
469 &(leveldir)->music_set)
471 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
472 ((type) == ARTWORK_TYPE_GRAPHICS ? \
473 (leveldir)->graphics_set : \
474 (type) == ARTWORK_TYPE_SOUNDS ? \
475 (leveldir)->sounds_set : \
476 (leveldir)->music_set)
478 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
479 ((type) == ARTWORK_TYPE_GRAPHICS ? \
480 &(leveldir)->graphics_path : \
481 (type) == ARTWORK_TYPE_SOUNDS ? \
482 &(leveldir)->sounds_path : \
483 &(leveldir)->music_path)
485 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
486 ((type) == ARTWORK_TYPE_GRAPHICS ? \
487 (leveldir)->graphics_path : \
488 (type) == ARTWORK_TYPE_SOUNDS ? \
489 (leveldir)->sounds_path : \
490 (leveldir)->music_path)
492 #define SETUP_ARTWORK_SET(setup, type) \
493 ((type) == ARTWORK_TYPE_GRAPHICS ? \
494 (setup).graphics_set : \
495 (type) == ARTWORK_TYPE_SOUNDS ? \
496 (setup).sounds_set : \
499 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
500 ((type) == ARTWORK_TYPE_GRAPHICS ? \
501 (setup).override_level_graphics : \
502 (type) == ARTWORK_TYPE_SOUNDS ? \
503 (setup).override_level_sounds : \
504 (setup).override_level_music)
506 #define ARTWORK_FIRST_NODE(artwork, type) \
507 ((type) == ARTWORK_TYPE_GRAPHICS ? \
508 (artwork).gfx_first : \
509 (type) == ARTWORK_TYPE_SOUNDS ? \
510 (artwork).snd_first : \
513 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
514 ((type) == ARTWORK_TYPE_GRAPHICS ? \
515 &(artwork).gfx_current_identifier : \
516 (type) == ARTWORK_TYPE_SOUNDS ? \
517 &(artwork).snd_current_identifier : \
518 &(artwork).mus_current_identifier)
520 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
521 ((type) == ARTWORK_TYPE_GRAPHICS ? \
522 (artwork).gfx_current_identifier : \
523 (type) == ARTWORK_TYPE_SOUNDS ? \
524 (artwork).snd_current_identifier : \
525 (artwork).mus_current_identifier)
527 #define ARTWORKINFO_FILENAME(type) \
528 ((type) == ARTWORK_TYPE_GRAPHICS ? \
529 GRAPHICSINFO_FILENAME : \
530 (type) == ARTWORK_TYPE_SOUNDS ? \
531 SOUNDSINFO_FILENAME : \
532 (type) == ARTWORK_TYPE_MUSIC ? \
533 MUSICINFO_FILENAME : "")
535 #define ARTWORK_DIRECTORY(type) \
536 ((type) == ARTWORK_TYPE_GRAPHICS ? \
537 GRAPHICS_DIRECTORY : \
538 (type) == ARTWORK_TYPE_SOUNDS ? \
540 (type) == ARTWORK_TYPE_MUSIC ? \
541 MUSIC_DIRECTORY : "")
543 #define OPTIONS_ARTWORK_DIRECTORY(type) \
544 ((type) == ARTWORK_TYPE_GRAPHICS ? \
545 options.graphics_directory : \
546 (type) == ARTWORK_TYPE_SOUNDS ? \
547 options.sounds_directory : \
548 (type) == ARTWORK_TYPE_MUSIC ? \
549 options.music_directory : "")
552 /* type definitions */
553 typedef int (*EventFilter)(const Event *);
556 /* structure definitions */
560 char *command_basepath; /* directory that contains the program */
561 char *command_basename; /* base filename of the program binary */
563 char *userdata_subdir; /* personal user game data directory */
564 char *userdata_subdir_unix; /* personal user game data directory (Unix) */
565 char *userdata_path; /* resulting full path to game data directory */
571 char *x11_icon_filename;
572 char *x11_iconmask_filename;
573 char *sdl_icon_filename;
574 char *msdos_cursor_filename;
577 char *filename_prefix; /* prefix to cut off from DOS filenames */
579 char *error_filename; /* filename where to write error messages to */
580 FILE *error_file; /* (used instead of 'stderr' on some systems) */
586 void (*exit_function)(int);
595 char *ro_base_directory;
596 char *rw_base_directory;
597 char *level_directory;
598 char *graphics_directory;
599 char *sounds_directory;
600 char *music_directory;
601 char *docs_directory;
602 char *execute_command;
610 struct ScreenModeInfo
615 struct VideoSystemInfo
618 int width, height, depth;
620 boolean fullscreen_available;
621 boolean fullscreen_enabled;
622 struct ScreenModeInfo *fullscreen_modes;
623 char *fullscreen_mode_current;
626 struct AudioSystemInfo
628 boolean sound_available;
629 boolean loops_available;
630 boolean music_available;
632 boolean sound_enabled;
633 boolean sound_deactivated; /* for temporarily disabling sound */
642 int first_sound_channel;
645 struct FontBitmapInfo
649 int src_x, src_y; /* start position of animation frames */
650 int width, height; /* width/height of each animation frame */
652 int draw_xoffset; /* offset for drawing font characters */
653 int draw_yoffset; /* offset for drawing font characters */
656 int num_chars_per_line;
658 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
659 Pixmap *clip_mask; /* single-char-only clip mask array for X11 */
667 int real_sx, real_sy;
668 int full_sxsize, full_sysize;
669 int scrollbuffer_width, scrollbuffer_height;
677 int draw_deactivation_mask;
678 int draw_background_mask;
680 Bitmap *field_save_buffer;
682 Bitmap *background_bitmap;
683 int background_bitmap_mask;
686 struct FontBitmapInfo *font_bitmap_info;
687 int (*select_font_function)(int);
689 int anim_random_frame;
695 int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */
698 struct SetupJoystickInfo
700 char *device_name; /* device name of player's joystick */
702 int xleft, xmiddle, xright;
703 int yupper, ymiddle, ylower;
707 struct SetupKeyboardInfo
709 Key left, right, up, down;
713 struct SetupInputInfo
715 boolean use_joystick;
716 struct SetupJoystickInfo joy;
717 struct SetupKeyboardInfo key;
720 struct SetupEditorInfo
722 boolean el_boulderdash;
723 boolean el_emerald_mine;
724 boolean el_emerald_mine_club;
728 boolean el_diamond_caves;
729 boolean el_dx_boulderdash;
731 boolean el_steel_chars;
733 boolean el_user_defined;
736 boolean el_headlines;
741 boolean show_element_token;
744 struct SetupEditorCascadeInfo
755 boolean el_steel_chars;
763 struct SetupShortcutInfo
769 Key focus_player[MAX_PLAYERS];
770 Key focus_player_all;
773 struct SetupSystemInfo
775 char *sdl_audiodriver;
776 int audio_fragment_size;
786 boolean sound_simple;
788 boolean double_buffering;
789 boolean direct_draw; /* !double_buffering (redundant!) */
790 boolean scroll_delay;
791 boolean soft_scrolling;
792 boolean fade_screens;
794 boolean show_titlescreen;
801 char *fullscreen_mode;
802 boolean ask_on_escape;
803 boolean ask_on_escape_editor;
804 boolean quick_switch;
805 boolean input_on_focus;
806 boolean prefer_aga_graphics;
811 boolean override_level_graphics;
812 boolean override_level_sounds;
813 boolean override_level_music;
815 struct SetupEditorInfo editor;
816 struct SetupEditorCascadeInfo editor_cascade;
817 struct SetupShortcutInfo shortcut;
818 struct SetupInputInfo input[MAX_PLAYERS];
819 struct SetupSystemInfo system;
820 struct OptionInfo options;
825 struct TreeInfo **node_top; /* topmost node in tree */
826 struct TreeInfo *node_parent; /* parent level directory info */
827 struct TreeInfo *node_group; /* level group sub-directory info */
828 struct TreeInfo *next; /* next level series structure node */
830 int cl_first; /* internal control field for setup screen */
831 int cl_cursor; /* internal control field for setup screen */
833 int type; /* type of tree content */
835 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
837 char *subdir; /* tree info sub-directory basename (may be ".") */
838 char *fullpath; /* complete path relative to tree base directory */
839 char *basepath; /* absolute base path of tree base directory */
840 char *identifier; /* identifier string for configuration files */
841 char *name; /* tree info name, as displayed in selection menues */
842 char *name_sorting; /* optional sorting name for correct name sorting */
843 char *author; /* level or artwork author name */
844 char *imported_from; /* optional comment for imported levels or artwork */
845 char *imported_by; /* optional comment for imported levels or artwork */
847 char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */
848 char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */
849 char *graphics_set; /* optional custom graphics set (level tree only) */
850 char *sounds_set; /* optional custom sounds set (level tree only) */
851 char *music_set; /* optional custom music set (level tree only) */
852 char *graphics_path; /* path to optional custom graphics set (level only) */
853 char *sounds_path; /* path to optional custom sounds set (level only) */
854 char *music_path; /* path to optional custom music set (level only) */
856 char *level_filename; /* filename of level file (for packed level file) */
857 char *level_filetype; /* type of levels in level directory or level file */
859 int levels; /* number of levels in level series */
860 int first_level; /* first level number (to allow start with 0 or 1) */
861 int last_level; /* last level number (automatically calculated) */
862 int sort_priority; /* sort levels by 'sort_priority' and then by name */
864 boolean latest_engine;/* force level set to use the latest game engine */
866 boolean level_group; /* directory contains more level series directories */
867 boolean parent_link; /* entry links back to parent directory */
868 boolean in_user_dir; /* user defined levels are stored in home directory */
869 boolean user_defined; /* levels in user directory and marked as "private" */
870 boolean readonly; /* readonly levels can not be changed with editor */
871 boolean handicap; /* level set has no handicap when set to "false" */
872 boolean skip_levels; /* levels can be skipped when set to "true" */
874 int color; /* color to use on selection screen for this level */
875 char *class_desc; /* description of level series class */
876 int handicap_level; /* number of the lowest unsolved level */
878 char *infotext; /* optional text to describe the tree type (headline) */
881 typedef struct TreeInfo TreeInfo;
882 typedef struct TreeInfo LevelDirTree;
883 typedef struct TreeInfo ArtworkDirTree;
884 typedef struct TreeInfo GraphicsDirTree;
885 typedef struct TreeInfo SoundsDirTree;
886 typedef struct TreeInfo MusicDirTree;
890 GraphicsDirTree *gfx_first;
891 GraphicsDirTree *gfx_current;
892 SoundsDirTree *snd_first;
893 SoundsDirTree *snd_current;
894 MusicDirTree *mus_first;
895 MusicDirTree *mus_current;
897 char *gfx_current_identifier;
898 char *snd_current_identifier;
899 char *mus_current_identifier;
914 struct ConfigTypeInfo
921 struct TokenIntPtrInfo
931 char *default_filename;
934 char **default_parameter; /* array of file parameters */
935 char **parameter; /* array of file parameters */
938 boolean fallback_to_default;
946 struct SetupFileList *next;
951 char *source_filename; /* primary key for node list */
955 struct PropertyMapping
965 struct ArtworkListInfo
967 int type; /* type of artwork */
969 int num_file_list_entries;
970 int num_dynamic_file_list_entries;
971 struct FileInfo *file_list; /* static artwork file array */
972 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
974 int num_suffix_list_entries;
975 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
977 int num_base_prefixes;
978 int num_ext1_suffixes;
979 int num_ext2_suffixes;
980 int num_ext3_suffixes;
981 char **base_prefixes; /* base token prefixes array */
982 char **ext1_suffixes; /* property suffixes array 1 */
983 char **ext2_suffixes; /* property suffixes array 2 */
984 char **ext3_suffixes; /* property suffixes array 3 */
986 int num_ignore_tokens;
987 char **ignore_tokens; /* file tokens to be ignored */
989 int num_property_mapping_entries;
990 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
992 int sizeof_artwork_list_entry;
994 struct ListNodeInfo **artwork_list; /* static artwork node array */
995 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
996 struct ListNode *content_list; /* dynamic artwork node list */
998 void *(*load_artwork)(char *); /* constructor function */
999 void (*free_artwork)(void *); /* destructor function */
1031 /* ========================================================================= */
1032 /* exported variables */
1033 /* ========================================================================= */
1035 extern struct ProgramInfo program;
1036 extern struct OptionInfo options;
1037 extern struct VideoSystemInfo video;
1038 extern struct AudioSystemInfo audio;
1039 extern struct GfxInfo gfx;
1040 extern struct AnimInfo anim;
1041 extern struct ArtworkInfo artwork;
1042 extern struct JoystickInfo joystick;
1043 extern struct SetupInfo setup;
1045 extern LevelDirTree *leveldir_first_all;
1046 extern LevelDirTree *leveldir_first;
1047 extern LevelDirTree *leveldir_current;
1048 extern int level_nr;
1050 extern Display *display;
1051 extern Visual *visual;
1053 extern Colormap cmap;
1055 extern DrawWindow *window;
1056 extern DrawBuffer *backbuffer;
1057 extern DrawBuffer *drawto;
1059 extern int button_status;
1060 extern boolean motion_status;
1062 extern int redraw_mask;
1063 extern int redraw_tiles;
1065 extern int FrameCounter;
1068 /* function definitions */
1070 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1071 char *, char *, char *, char *, char *, int);
1073 void InitExitFunction(void (*exit_function)(int));
1074 void InitPlatformDependentStuff(void);
1075 void ClosePlatformDependentStuff(void);
1077 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1078 void InitGfxDoor1Info(int, int, int, int);
1079 void InitGfxDoor2Info(int, int, int, int);
1080 void InitGfxScrollbufferInfo(int, int);
1081 void SetDrawDeactivationMask(int);
1082 void SetDrawBackgroundMask(int);
1083 void SetWindowBackgroundBitmap(Bitmap *);
1084 void SetMainBackgroundBitmap(Bitmap *);
1085 void SetDoorBackgroundBitmap(Bitmap *);
1087 void InitVideoDisplay(void);
1088 void CloseVideoDisplay(void);
1089 void InitVideoBuffer(int, int, int, boolean);
1090 Bitmap *CreateBitmapStruct(void);
1091 Bitmap *CreateBitmap(int, int, int);
1092 void FreeBitmap(Bitmap *);
1093 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1094 void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int,
1095 void (*draw_border_function)(void));
1096 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1097 void ClearRectangle(Bitmap *, int, int, int, int);
1098 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1099 void SetClipMask(Bitmap *, GC, Pixmap);
1100 void SetClipOrigin(Bitmap *, GC, int, int);
1101 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1102 boolean DrawingOnBackground(int, int);
1103 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1104 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1105 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1106 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1107 Pixel GetPixel(Bitmap *, int, int);
1108 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1109 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1111 void FlushDisplay(void);
1112 void SyncDisplay(void);
1113 void KeyboardAutoRepeatOn(void);
1114 void KeyboardAutoRepeatOff(void);
1115 boolean PointerInWindow(DrawWindow *);
1116 boolean SetVideoMode(boolean);
1117 boolean ChangeVideoModeIfNeeded(boolean);
1119 Bitmap *LoadImage(char *);
1120 Bitmap *LoadCustomImage(char *);
1121 void ReloadCustomImage(Bitmap *, char *);
1123 Bitmap *ZoomBitmap(Bitmap *, int, int);
1124 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
1125 void ScaleBitmap(Bitmap *, int);
1127 void SetMouseCursor(int);
1129 void OpenAudio(void);
1130 void CloseAudio(void);
1131 void SetAudioMode(boolean);
1133 void InitEventFilter(EventFilter);
1134 boolean PendingEvent(void);
1135 void NextEvent(Event *event);
1136 void PeekEvent(Event *event);
1137 Key GetEventKey(KeyEvent *, boolean);
1138 KeyMod HandleKeyModState(Key, int);
1139 KeyMod GetKeyModState();
1140 KeyMod GetKeyModStateFromEvents();
1141 boolean CheckCloseWindowEvent(ClientMessageEvent *);
1143 void InitJoysticks();
1144 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1146 #endif /* SYSTEM_H */