1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 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_STATIC_PANEL (1 << 12)
199 #define ANIM_DEFAULT ANIM_LOOP
201 /* values for redraw_mask */
202 #define REDRAW_NONE (0)
203 #define REDRAW_ALL (1 << 0)
204 #define REDRAW_FIELD (1 << 1)
205 #define REDRAW_TILES (1 << 2)
206 #define REDRAW_DOOR_1 (1 << 3)
207 #define REDRAW_VIDEO_1 (1 << 4)
208 #define REDRAW_VIDEO_2 (1 << 5)
209 #define REDRAW_VIDEO_3 (1 << 6)
210 #define REDRAW_MICROLEVEL (1 << 7)
211 #define REDRAW_MICROLABEL (1 << 8)
212 #define REDRAW_FROM_BACKBUFFER (1 << 9)
213 #define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
216 #define REDRAW_DOOR_3 (1 << 10)
217 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
220 #define REDRAW_MAIN (REDRAW_FIELD | \
223 #define REDRAW_FPS (1 << 11)
224 #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
226 #define FADE_MODE_FADE_IN 0
227 #define FADE_MODE_FADE_OUT 1
228 #define FADE_MODE_CROSSFADE 2
230 #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
231 y >= gfx.sy && y < gfx.sy + gfx.sysize)
232 #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
233 y >= gfx.dy && y < gfx.dy + gfx.dysize)
234 #define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
235 y >= gfx.vy && y < gfx.vy + gfx.vysize)
237 /* values for mouse cursor */
238 #define CURSOR_DEFAULT 0
239 #define CURSOR_PLAYFIELD 1
241 /* fundamental game speed values */
242 #define ONE_SECOND_DELAY 1000 /* delay value for one second */
243 #define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
244 #define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
245 #define FRAMES_PER_SECOND (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
247 /* maximum playfield size supported by libgame functions */
248 #define MAX_PLAYFIELD_WIDTH 128
249 #define MAX_PLAYFIELD_HEIGHT 128
251 /* maximum number of parallel players supported by libgame functions */
252 #define MAX_PLAYERS 4
254 /* maximum allowed length of player name */
255 #define MAX_PLAYER_NAME_LEN 10
257 /* default name for empty highscore entry */
258 #define EMPTY_PLAYER_NAME "no name"
260 /* default name for unknown player names */
261 #define ANONYMOUS_NAME "anonymous"
263 /* default for other unknown names */
264 #define UNKNOWN_NAME "unknown"
266 /* default name for new levels */
267 #define NAMELESS_LEVEL_NAME "nameless level"
269 /* default text for non-existant artwork */
270 #define NOT_AVAILABLE "(not available)"
272 /* default value for undefined filename */
273 #define UNDEFINED_FILENAME "[NONE]"
275 /* default value for undefined parameter */
276 #define ARG_DEFAULT "[DEFAULT]"
278 /* default values for undefined configuration file parameters */
279 #define ARG_UNDEFINED "-1000000"
280 #define ARG_UNDEFINED_VALUE (atoi(ARG_UNDEFINED))
282 /* definitions for game sub-directories */
284 #define RO_GAME_DIR "."
288 #define RW_GAME_DIR "."
291 #define RO_BASE_PATH RO_GAME_DIR
292 #define RW_BASE_PATH RW_GAME_DIR
294 /* directory names */
295 #define GRAPHICS_DIRECTORY "graphics"
296 #define SOUNDS_DIRECTORY "sounds"
297 #define MUSIC_DIRECTORY "music"
298 #define LEVELS_DIRECTORY "levels"
299 #define TAPES_DIRECTORY "tapes"
300 #define SCORES_DIRECTORY "scores"
301 #define DOCS_DIRECTORY "docs"
303 #if !defined(PLATFORM_MSDOS)
304 #define GFX_CLASSIC_SUBDIR "gfx_classic"
305 #define SND_CLASSIC_SUBDIR "snd_classic"
306 #define MUS_CLASSIC_SUBDIR "mus_classic"
308 #define GFX_CLASSIC_SUBDIR "gfx_orig"
309 #define SND_CLASSIC_SUBDIR "snd_orig"
310 #define MUS_CLASSIC_SUBDIR "mus_orig"
313 /* file names and filename extensions */
314 #if !defined(PLATFORM_MSDOS)
315 #define LEVELSETUP_DIRECTORY "levelsetup"
316 #define SETUP_FILENAME "setup.conf"
317 #define LEVELSETUP_FILENAME "levelsetup.conf"
318 #define EDITORSETUP_FILENAME "editorsetup.conf"
319 #define EDITORCASCADE_FILENAME "editorcascade.conf"
320 #define HELPANIM_FILENAME "helpanim.conf"
321 #define HELPTEXT_FILENAME "helptext.conf"
322 #define LEVELINFO_FILENAME "levelinfo.conf"
323 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
324 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
325 #define MUSICINFO_FILENAME "musicinfo.conf"
326 #define LEVELFILE_EXTENSION "level"
327 #define TAPEFILE_EXTENSION "tape"
328 #define SCOREFILE_EXTENSION "score"
330 #define LEVELSETUP_DIRECTORY "lvlsetup"
331 #define SETUP_FILENAME "setup.cnf"
332 #define LEVELSETUP_FILENAME "lvlsetup.cnf"
333 #define EDITORSETUP_FILENAME "edsetup.cnf"
334 #define EDITORCASCADE_FILENAME "edcascad.conf"
335 #define HELPANIM_FILENAME "helpanim.cnf"
336 #define HELPTEXT_FILENAME "helptext.cnf"
337 #define LEVELINFO_FILENAME "lvlinfo.cnf"
338 #define GRAPHICSINFO_FILENAME "gfxinfo.cnf"
339 #define SOUNDSINFO_FILENAME "sndinfo.cnf"
340 #define MUSICINFO_FILENAME "musinfo.cnf"
341 #define LEVELFILE_EXTENSION "lvl"
342 #define TAPEFILE_EXTENSION "tap"
343 #define SCOREFILE_EXTENSION "sco"
346 #define ERROR_BASENAME "stderr.txt"
348 #define CHAR_PATH_SEPARATOR_UNIX '/'
349 #define CHAR_PATH_SEPARATOR_DOS '\\'
351 #define STRING_PATH_SEPARATOR_UNIX "/"
352 #define STRING_PATH_SEPARATOR_DOS "\\"
354 #define STRING_NEWLINE_UNIX "\n"
355 #define STRING_NEWLINE_DOS "\r\n"
357 #if defined(PLATFORM_WIN32) || defined(PLATFORM_MSDOS)
358 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_DOS
359 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_DOS
360 #define STRING_NEWLINE STRING_NEWLINE_DOS
362 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_UNIX
363 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_UNIX
364 #define STRING_NEWLINE STRING_NEWLINE_UNIX
368 /* areas in bitmap PIX_DOOR */
369 /* meaning in PIX_DB_DOOR: (3 PAGEs)
370 PAGEX1: 1. buffer for DOOR_1
371 PAGEX2: 2. buffer for DOOR_1
372 PAGEX3: buffer for animations
375 /* these values are hard-coded to be able to use them in initialization */
376 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
377 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
379 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
380 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
381 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
382 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
383 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
384 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
385 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
386 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
387 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
388 #define DOOR_GFX_PAGEY1 (0)
389 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
392 /* macros for version handling */
393 #define VERSION_MAJOR(x) ((x) / 1000000)
394 #define VERSION_MINOR(x) (((x) % 1000000) / 10000)
395 #define VERSION_PATCH(x) (((x) % 10000) / 100)
396 #define VERSION_BUILD(x) ((x) % 100)
397 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
400 /* macros for parent/child process identification */
401 #if defined(PLATFORM_UNIX)
402 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
403 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
404 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
406 #define IS_PARENT_PROCESS() TRUE
407 #define IS_CHILD_PROCESS() FALSE
408 #define HAS_CHILD_PROCESS() FALSE
412 /* values for artwork type */
413 #define ARTWORK_TYPE_GRAPHICS 0
414 #define ARTWORK_TYPE_SOUNDS 1
415 #define ARTWORK_TYPE_MUSIC 2
417 #define NUM_ARTWORK_TYPES 3
420 /* values for tree type (chosen to match artwork type) */
421 #define TREE_TYPE_UNDEFINED -1
422 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
423 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
424 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
425 #define TREE_TYPE_LEVEL_DIR 3
427 #define NUM_TREE_TYPES 4
430 /* values for artwork handling */
431 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
432 ((type) == ARTWORK_TYPE_GRAPHICS ? \
433 &(leveldir)->graphics_set : \
434 (type) == ARTWORK_TYPE_SOUNDS ? \
435 &(leveldir)->sounds_set : \
436 &(leveldir)->music_set)
438 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
439 ((type) == ARTWORK_TYPE_GRAPHICS ? \
440 (leveldir)->graphics_set : \
441 (type) == ARTWORK_TYPE_SOUNDS ? \
442 (leveldir)->sounds_set : \
443 (leveldir)->music_set)
445 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
446 ((type) == ARTWORK_TYPE_GRAPHICS ? \
447 &(leveldir)->graphics_path : \
448 (type) == ARTWORK_TYPE_SOUNDS ? \
449 &(leveldir)->sounds_path : \
450 &(leveldir)->music_path)
452 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
453 ((type) == ARTWORK_TYPE_GRAPHICS ? \
454 (leveldir)->graphics_path : \
455 (type) == ARTWORK_TYPE_SOUNDS ? \
456 (leveldir)->sounds_path : \
457 (leveldir)->music_path)
459 #define SETUP_ARTWORK_SET(setup, type) \
460 ((type) == ARTWORK_TYPE_GRAPHICS ? \
461 (setup).graphics_set : \
462 (type) == ARTWORK_TYPE_SOUNDS ? \
463 (setup).sounds_set : \
466 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
467 ((type) == ARTWORK_TYPE_GRAPHICS ? \
468 (setup).override_level_graphics : \
469 (type) == ARTWORK_TYPE_SOUNDS ? \
470 (setup).override_level_sounds : \
471 (setup).override_level_music)
473 #define ARTWORK_FIRST_NODE(artwork, type) \
474 ((type) == ARTWORK_TYPE_GRAPHICS ? \
475 (artwork).gfx_first : \
476 (type) == ARTWORK_TYPE_SOUNDS ? \
477 (artwork).snd_first : \
480 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
481 ((type) == ARTWORK_TYPE_GRAPHICS ? \
482 &(artwork).gfx_current_identifier : \
483 (type) == ARTWORK_TYPE_SOUNDS ? \
484 &(artwork).snd_current_identifier : \
485 &(artwork).mus_current_identifier)
487 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
488 ((type) == ARTWORK_TYPE_GRAPHICS ? \
489 (artwork).gfx_current_identifier : \
490 (type) == ARTWORK_TYPE_SOUNDS ? \
491 (artwork).snd_current_identifier : \
492 (artwork).mus_current_identifier)
494 #define ARTWORKINFO_FILENAME(type) \
495 ((type) == ARTWORK_TYPE_GRAPHICS ? \
496 GRAPHICSINFO_FILENAME : \
497 (type) == ARTWORK_TYPE_SOUNDS ? \
498 SOUNDSINFO_FILENAME : \
499 (type) == ARTWORK_TYPE_MUSIC ? \
500 MUSICINFO_FILENAME : "")
502 #define ARTWORK_DIRECTORY(type) \
503 ((type) == ARTWORK_TYPE_GRAPHICS ? \
504 GRAPHICS_DIRECTORY : \
505 (type) == ARTWORK_TYPE_SOUNDS ? \
507 (type) == ARTWORK_TYPE_MUSIC ? \
508 MUSIC_DIRECTORY : "")
510 #define OPTIONS_ARTWORK_DIRECTORY(type) \
511 ((type) == ARTWORK_TYPE_GRAPHICS ? \
512 options.graphics_directory : \
513 (type) == ARTWORK_TYPE_SOUNDS ? \
514 options.sounds_directory : \
515 (type) == ARTWORK_TYPE_MUSIC ? \
516 options.music_directory : "")
519 /* type definitions */
520 typedef int (*EventFilter)(const Event *);
523 /* structure definitions */
527 char *command_basepath; /* directory that contains the program */
528 char *command_basename; /* base filename of the program binary */
530 char *userdata_subdir; /* personal user game data directory */
531 char *userdata_subdir_unix; /* personal user game data directory (Unix) */
532 char *userdata_path; /* resulting full path to game data directory */
538 char *x11_icon_filename;
539 char *x11_iconmask_filename;
540 char *msdos_cursor_filename;
543 char *filename_prefix; /* prefix to cut off from DOS filenames */
545 char *error_filename; /* filename where to write error messages to */
546 FILE *error_file; /* (used instead of 'stderr' on some systems) */
552 void (*exit_function)(int);
561 char *ro_base_directory;
562 char *rw_base_directory;
563 char *level_directory;
564 char *graphics_directory;
565 char *sounds_directory;
566 char *music_directory;
567 char *docs_directory;
568 char *execute_command;
576 struct VideoSystemInfo
579 int width, height, depth;
580 boolean fullscreen_available;
581 boolean fullscreen_enabled;
584 struct AudioSystemInfo
586 boolean sound_available;
587 boolean loops_available;
588 boolean music_available;
590 boolean sound_enabled;
591 boolean sound_deactivated; /* for temporarily disabling sound */
600 int first_sound_channel;
603 struct FontBitmapInfo
607 int src_x, src_y; /* start position of animation frames */
608 int width, height; /* width/height of each animation frame */
610 int draw_xoffset; /* offset for drawing font characters */
611 int draw_yoffset; /* offset for drawing font characters */
614 int num_chars_per_line;
616 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
617 Pixmap *clip_mask; /* single-char-only clip mask array for X11 */
625 int real_sx, real_sy;
626 int full_sxsize, full_sysize;
627 int scrollbuffer_width, scrollbuffer_height;
635 int draw_deactivation_mask;
636 int draw_background_mask;
638 Bitmap *field_save_buffer;
640 Bitmap *background_bitmap;
641 int background_bitmap_mask;
644 struct FontBitmapInfo *font_bitmap_info;
645 int (*select_font_function)(int);
647 int anim_random_frame;
653 int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */
656 struct SetupJoystickInfo
658 char *device_name; /* device name of player's joystick */
660 int xleft, xmiddle, xright;
661 int yupper, ymiddle, ylower;
665 struct SetupKeyboardInfo
667 Key left, right, up, down;
671 struct SetupInputInfo
673 boolean use_joystick;
674 struct SetupJoystickInfo joy;
675 struct SetupKeyboardInfo key;
678 struct SetupEditorInfo
680 boolean el_boulderdash;
681 boolean el_emerald_mine;
682 boolean el_emerald_mine_club;
686 boolean el_diamond_caves;
687 boolean el_dx_boulderdash;
690 boolean el_user_defined;
693 boolean el_headlines;
698 boolean show_element_token;
701 struct SetupEditorCascadeInfo
719 struct SetupShortcutInfo
725 Key focus_player[MAX_PLAYERS];
726 Key focus_player_all;
729 struct SetupSystemInfo
731 char *sdl_audiodriver;
732 int audio_fragment_size;
742 boolean sound_simple;
744 boolean double_buffering;
745 boolean direct_draw; /* !double_buffering (redundant!) */
746 boolean scroll_delay;
747 boolean soft_scrolling;
750 boolean show_titlescreen;
757 boolean ask_on_escape;
758 boolean ask_on_escape_editor;
759 boolean quick_switch;
760 boolean input_on_focus;
761 boolean prefer_aga_graphics;
766 boolean override_level_graphics;
767 boolean override_level_sounds;
768 boolean override_level_music;
770 struct SetupEditorInfo editor;
771 struct SetupEditorCascadeInfo editor_cascade;
772 struct SetupShortcutInfo shortcut;
773 struct SetupInputInfo input[MAX_PLAYERS];
774 struct SetupSystemInfo system;
775 struct OptionInfo options;
780 struct TreeInfo **node_top; /* topmost node in tree */
781 struct TreeInfo *node_parent; /* parent level directory info */
782 struct TreeInfo *node_group; /* level group sub-directory info */
783 struct TreeInfo *next; /* next level series structure node */
785 int cl_first; /* internal control field for setup screen */
786 int cl_cursor; /* internal control field for setup screen */
788 int type; /* type of tree content */
790 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
792 char *subdir; /* tree info sub-directory basename (may be ".") */
793 char *fullpath; /* complete path relative to tree base directory */
794 char *basepath; /* absolute base path of tree base directory */
795 char *identifier; /* identifier string for configuration files */
796 char *name; /* tree info name, as displayed in selection menues */
797 char *name_sorting; /* optional sorting name for correct name sorting */
798 char *author; /* level or artwork author name */
799 char *imported_from; /* optional comment for imported levels or artwork */
800 char *imported_by; /* optional comment for imported levels or artwork */
802 char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */
803 char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */
804 char *graphics_set; /* optional custom graphics set (level tree only) */
805 char *sounds_set; /* optional custom sounds set (level tree only) */
806 char *music_set; /* optional custom music set (level tree only) */
807 char *graphics_path; /* path to optional custom graphics set (level only) */
808 char *sounds_path; /* path to optional custom sounds set (level only) */
809 char *music_path; /* path to optional custom music set (level only) */
811 char *level_filename; /* filename of level file (for packed level file) */
812 char *level_filetype; /* type of levels in level directory or level file */
814 int levels; /* number of levels in level series */
815 int first_level; /* first level number (to allow start with 0 or 1) */
816 int last_level; /* last level number (automatically calculated) */
817 int sort_priority; /* sort levels by 'sort_priority' and then by name */
819 boolean latest_engine;/* force level set to use the latest game engine */
821 boolean level_group; /* directory contains more level series directories */
822 boolean parent_link; /* entry links back to parent directory */
823 boolean in_user_dir; /* user defined levels are stored in home directory */
824 boolean user_defined; /* levels in user directory and marked as "private" */
825 boolean readonly; /* readonly levels can not be changed with editor */
826 boolean handicap; /* level set has no handicap when set to "false" */
827 boolean skip_levels; /* levels can be skipped when set to "true" */
829 int color; /* color to use on selection screen for this level */
830 char *class_desc; /* description of level series class */
831 int handicap_level; /* number of the lowest unsolved level */
834 typedef struct TreeInfo TreeInfo;
835 typedef struct TreeInfo LevelDirTree;
836 typedef struct TreeInfo ArtworkDirTree;
837 typedef struct TreeInfo GraphicsDirTree;
838 typedef struct TreeInfo SoundsDirTree;
839 typedef struct TreeInfo MusicDirTree;
843 GraphicsDirTree *gfx_first;
844 GraphicsDirTree *gfx_current;
845 SoundsDirTree *snd_first;
846 SoundsDirTree *snd_current;
847 MusicDirTree *mus_first;
848 MusicDirTree *mus_current;
850 char *gfx_current_identifier;
851 char *snd_current_identifier;
852 char *mus_current_identifier;
867 struct ConfigTypeInfo
874 struct TokenIntPtrInfo
884 char *default_filename;
887 char **default_parameter; /* array of file parameters */
888 char **parameter; /* array of file parameters */
891 boolean fallback_to_default;
899 struct SetupFileList *next;
904 char *source_filename; /* primary key for node list */
908 struct PropertyMapping
918 struct ArtworkListInfo
920 int type; /* type of artwork */
922 int num_file_list_entries;
923 int num_dynamic_file_list_entries;
924 struct FileInfo *file_list; /* static artwork file array */
925 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
927 int num_suffix_list_entries;
928 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
930 int num_base_prefixes;
931 int num_ext1_suffixes;
932 int num_ext2_suffixes;
933 int num_ext3_suffixes;
934 char **base_prefixes; /* base token prefixes array */
935 char **ext1_suffixes; /* property suffixes array 1 */
936 char **ext2_suffixes; /* property suffixes array 2 */
937 char **ext3_suffixes; /* property suffixes array 3 */
939 int num_ignore_tokens;
940 char **ignore_tokens; /* file tokens to be ignored */
942 int num_property_mapping_entries;
943 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
945 int sizeof_artwork_list_entry;
947 struct ListNodeInfo **artwork_list; /* static artwork node array */
948 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
949 struct ListNode *content_list; /* dynamic artwork node list */
951 void *(*load_artwork)(char *); /* constructor function */
952 void (*free_artwork)(void *); /* destructor function */
956 /* ========================================================================= */
957 /* exported variables */
958 /* ========================================================================= */
960 extern struct ProgramInfo program;
961 extern struct OptionInfo options;
962 extern struct VideoSystemInfo video;
963 extern struct AudioSystemInfo audio;
964 extern struct GfxInfo gfx;
965 extern struct AnimInfo anim;
966 extern struct ArtworkInfo artwork;
967 extern struct JoystickInfo joystick;
968 extern struct SetupInfo setup;
970 extern LevelDirTree *leveldir_first_all;
971 extern LevelDirTree *leveldir_first;
972 extern LevelDirTree *leveldir_current;
975 extern Display *display;
976 extern Visual *visual;
978 extern Colormap cmap;
980 extern DrawWindow *window;
981 extern DrawBuffer *backbuffer;
982 extern DrawBuffer *drawto;
984 extern int button_status;
985 extern boolean motion_status;
987 extern int redraw_mask;
988 extern int redraw_tiles;
990 extern int FrameCounter;
993 /* function definitions */
995 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
996 char *, char *, char *, char *, int);
998 void InitExitFunction(void (*exit_function)(int));
999 void InitPlatformDependentStuff(void);
1000 void ClosePlatformDependentStuff(void);
1002 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1003 void InitGfxDoor1Info(int, int, int, int);
1004 void InitGfxDoor2Info(int, int, int, int);
1005 void InitGfxScrollbufferInfo(int, int);
1006 void SetDrawDeactivationMask(int);
1007 void SetDrawBackgroundMask(int);
1008 void SetMainBackgroundBitmap(Bitmap *);
1009 void SetDoorBackgroundBitmap(Bitmap *);
1011 void InitVideoDisplay(void);
1012 void CloseVideoDisplay(void);
1013 void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
1014 Bitmap *CreateBitmapStruct(void);
1015 Bitmap *CreateBitmap(int, int, int);
1016 void FreeBitmap(Bitmap *);
1017 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1018 void FadeScreen(Bitmap *bitmap, int, int, int);
1019 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1020 void ClearRectangle(Bitmap *, int, int, int, int);
1021 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1022 void SetClipMask(Bitmap *, GC, Pixmap);
1023 void SetClipOrigin(Bitmap *, GC, int, int);
1024 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1025 boolean DrawingOnBackground(int, int);
1026 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1027 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1028 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1029 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1030 Pixel GetPixel(Bitmap *, int, int);
1031 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1032 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1034 void FlushDisplay(void);
1035 void SyncDisplay(void);
1036 void KeyboardAutoRepeatOn(void);
1037 void KeyboardAutoRepeatOff(void);
1038 boolean PointerInWindow(DrawWindow *);
1039 boolean SetVideoMode(boolean);
1040 boolean ChangeVideoModeIfNeeded(boolean);
1042 Bitmap *LoadImage(char *);
1043 Bitmap *LoadCustomImage(char *);
1044 void ReloadCustomImage(Bitmap *, char *);
1046 Bitmap *ZoomBitmap(Bitmap *, int, int);
1047 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
1048 void ScaleBitmap(Bitmap *, int);
1050 void SetMouseCursor(int);
1052 void OpenAudio(void);
1053 void CloseAudio(void);
1054 void SetAudioMode(boolean);
1056 void InitEventFilter(EventFilter);
1057 boolean PendingEvent(void);
1058 void NextEvent(Event *event);
1059 void PeekEvent(Event *event);
1060 Key GetEventKey(KeyEvent *, boolean);
1061 KeyMod HandleKeyModState(Key, int);
1062 KeyMod GetKeyModState();
1063 boolean CheckCloseWindowEvent(ClientMessageEvent *);
1065 void InitJoysticks();
1066 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1068 #endif /* SYSTEM_H */