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
71 /* values for key_status */
72 #define KEY_NOT_PRESSED FALSE
73 #define KEY_RELEASED FALSE
74 #define KEY_PRESSED TRUE
76 /* values for button status */
77 #define MB_NOT_PRESSED FALSE
78 #define MB_NOT_RELEASED TRUE
79 #define MB_RELEASED FALSE
80 #define MB_PRESSED TRUE
81 #define MB_MENU_CHOICE FALSE
82 #define MB_MENU_MARK TRUE
83 #define MB_MENU_INITIALIZE (-1)
84 #define MB_MENU_LEAVE (-2)
85 #define MB_LEFTBUTTON 1
86 #define MB_MIDDLEBUTTON 2
87 #define MB_RIGHTBUTTON 3
90 /* values for move directions */
92 #define MV_BIT_RIGHT 1
96 #define NUM_DIRECTIONS 4
98 /* diagonal movement directions are used in a different contect than buttons */
99 #define MV_BIT_UPLEFT 4
100 #define MV_BIT_UPRIGHT 5
101 #define MV_BIT_DOWNLEFT 6
102 #define MV_BIT_DOWNRIGHT 7
104 #define NUM_DIRECTIONS_FULL 8
106 /* values for special "button" bitmasks */
110 /* values for move directions and special "button" key bitmasks */
112 #define MV_LEFT (1 << MV_BIT_LEFT)
113 #define MV_RIGHT (1 << MV_BIT_RIGHT)
114 #define MV_UP (1 << MV_BIT_UP)
115 #define MV_DOWN (1 << MV_BIT_DOWN)
117 #define MV_UPLEFT (MV_UP | MV_LEFT)
118 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
119 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
120 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
122 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
123 #define MV_VERTICAL (MV_UP | MV_DOWN)
124 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
125 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
126 #define MV_NO_DIRECTION (MV_NONE)
128 #define KEY_BUTTON_1 (1 << BUTTON_1)
129 #define KEY_BUTTON_2 (1 << BUTTON_2)
130 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
131 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
132 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
134 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
135 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
136 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
137 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
138 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
141 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
142 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
143 (x) == MV_UP ? MV_BIT_UP : \
144 (x) == MV_DOWN ? MV_BIT_DOWN : \
145 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
146 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
147 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
148 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
151 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
152 (x) == MV_RIGHT ? MV_LEFT : \
153 (x) == MV_UP ? MV_DOWN : \
154 (x) == MV_DOWN ? MV_UP : \
155 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
156 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
157 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
158 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
161 /* values for animation mode (frame order and direction) */
163 #define ANIM_LOOP (1 << 0)
164 #define ANIM_LINEAR (1 << 1)
165 #define ANIM_PINGPONG (1 << 2)
166 #define ANIM_PINGPONG2 (1 << 3)
167 #define ANIM_RANDOM (1 << 4)
168 #define ANIM_CE_VALUE (1 << 5)
169 #define ANIM_CE_SCORE (1 << 6)
170 #define ANIM_REVERSE (1 << 7)
172 /* values for special (non game element) animation modes */
173 #define ANIM_HORIZONTAL (1 << 8)
174 #define ANIM_VERTICAL (1 << 9)
175 #define ANIM_STATIC_PANEL (1 << 10)
177 #define ANIM_DEFAULT ANIM_LOOP
179 /* values for redraw_mask */
180 #define REDRAW_NONE (0)
181 #define REDRAW_ALL (1 << 0)
182 #define REDRAW_FIELD (1 << 1)
183 #define REDRAW_TILES (1 << 2)
184 #define REDRAW_DOOR_1 (1 << 3)
185 #define REDRAW_VIDEO_1 (1 << 4)
186 #define REDRAW_VIDEO_2 (1 << 5)
187 #define REDRAW_VIDEO_3 (1 << 6)
188 #define REDRAW_MICROLEVEL (1 << 7)
189 #define REDRAW_MICROLABEL (1 << 8)
190 #define REDRAW_FROM_BACKBUFFER (1 << 9)
191 #define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
194 #define REDRAW_DOOR_3 (1 << 10)
195 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
198 #define REDRAW_MAIN (REDRAW_FIELD | \
201 #define REDRAW_FPS (1 << 11)
202 #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
204 #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
205 y >= gfx.sy && y < gfx.sy + gfx.sysize)
206 #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
207 y >= gfx.dy && y < gfx.dy + gfx.dysize)
208 #define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
209 y >= gfx.vy && y < gfx.vy + gfx.vysize)
211 /* values for mouse cursor */
212 #define CURSOR_DEFAULT 0
213 #define CURSOR_PLAYFIELD 1
216 /* maximum number of parallel players supported by libgame functions */
217 #define MAX_PLAYERS 4
219 /* maximum allowed length of player name */
220 #define MAX_PLAYER_NAME_LEN 10
222 /* default name for empty highscore entry */
223 #define EMPTY_PLAYER_NAME "no name"
225 /* default name for unknown player names */
226 #define ANONYMOUS_NAME "anonymous"
228 /* default for other unknown names */
229 #define UNKNOWN_NAME "unknown"
231 /* default name for new levels */
232 #define NAMELESS_LEVEL_NAME "nameless level"
234 /* default text for non-existant artwork */
235 #define NOT_AVAILABLE "(not available)"
237 /* default value for undefined filename */
238 #define UNDEFINED_FILENAME "[NONE]"
240 /* default value for undefined parameter */
241 #define ARG_DEFAULT "[DEFAULT]"
243 /* default values for undefined configuration file parameters */
244 #define ARG_UNDEFINED "-1000000"
245 #define ARG_UNDEFINED_VALUE (atoi(ARG_UNDEFINED))
247 /* definitions for game sub-directories */
249 #define RO_GAME_DIR "."
253 #define RW_GAME_DIR "."
256 #define RO_BASE_PATH RO_GAME_DIR
257 #define RW_BASE_PATH RW_GAME_DIR
259 /* directory names */
260 #define GRAPHICS_DIRECTORY "graphics"
261 #define SOUNDS_DIRECTORY "sounds"
262 #define MUSIC_DIRECTORY "music"
263 #define LEVELS_DIRECTORY "levels"
264 #define TAPES_DIRECTORY "tapes"
265 #define SCORES_DIRECTORY "scores"
266 #define DOCS_DIRECTORY "docs"
268 #if !defined(PLATFORM_MSDOS)
269 #define GFX_CLASSIC_SUBDIR "gfx_classic"
270 #define SND_CLASSIC_SUBDIR "snd_classic"
271 #define MUS_CLASSIC_SUBDIR "mus_classic"
273 #define GFX_CLASSIC_SUBDIR "gfx_orig"
274 #define SND_CLASSIC_SUBDIR "snd_orig"
275 #define MUS_CLASSIC_SUBDIR "mus_orig"
278 /* file names and filename extensions */
279 #if !defined(PLATFORM_MSDOS)
280 #define LEVELSETUP_DIRECTORY "levelsetup"
281 #define SETUP_FILENAME "setup.conf"
282 #define LEVELSETUP_FILENAME "levelsetup.conf"
283 #define EDITORSETUP_FILENAME "editorsetup.conf"
284 #define EDITORCASCADE_FILENAME "editorcascade.conf"
285 #define HELPANIM_FILENAME "helpanim.conf"
286 #define HELPTEXT_FILENAME "helptext.conf"
287 #define LEVELINFO_FILENAME "levelinfo.conf"
288 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
289 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
290 #define MUSICINFO_FILENAME "musicinfo.conf"
291 #define LEVELFILE_EXTENSION "level"
292 #define TAPEFILE_EXTENSION "tape"
293 #define SCOREFILE_EXTENSION "score"
295 #define LEVELSETUP_DIRECTORY "lvlsetup"
296 #define SETUP_FILENAME "setup.cnf"
297 #define LEVELSETUP_FILENAME "lvlsetup.cnf"
298 #define EDITORSETUP_FILENAME "edsetup.cnf"
299 #define EDITORCASCADE_FILENAME "edcascad.conf"
300 #define HELPANIM_FILENAME "helpanim.cnf"
301 #define HELPTEXT_FILENAME "helptext.cnf"
302 #define LEVELINFO_FILENAME "lvlinfo.cnf"
303 #define GRAPHICSINFO_FILENAME "gfxinfo.cnf"
304 #define SOUNDSINFO_FILENAME "sndinfo.cnf"
305 #define MUSICINFO_FILENAME "musinfo.cnf"
306 #define LEVELFILE_EXTENSION "lvl"
307 #define TAPEFILE_EXTENSION "tap"
308 #define SCOREFILE_EXTENSION "sco"
312 /* areas in bitmap PIX_DOOR */
313 /* meaning in PIX_DB_DOOR: (3 PAGEs)
314 PAGEX1: 1. buffer for DOOR_1
315 PAGEX2: 2. buffer for DOOR_1
316 PAGEX3: buffer for animations
319 /* these values are hard-coded to be able to use them in initialization */
320 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
321 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
323 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
324 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
325 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
326 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
327 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
328 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
329 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
330 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
331 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
332 #define DOOR_GFX_PAGEY1 (0)
333 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
336 /* macros for version handling */
337 #define VERSION_MAJOR(x) ((x) / 1000000)
338 #define VERSION_MINOR(x) (((x) % 1000000) / 10000)
339 #define VERSION_PATCH(x) (((x) % 10000) / 100)
340 #define VERSION_BUILD(x) ((x) % 100)
341 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
344 /* macros for parent/child process identification */
345 #if defined(PLATFORM_UNIX)
346 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
347 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
348 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
350 #define IS_PARENT_PROCESS() TRUE
351 #define IS_CHILD_PROCESS() FALSE
352 #define HAS_CHILD_PROCESS() FALSE
356 /* values for artwork type */
357 #define ARTWORK_TYPE_GRAPHICS 0
358 #define ARTWORK_TYPE_SOUNDS 1
359 #define ARTWORK_TYPE_MUSIC 2
361 #define NUM_ARTWORK_TYPES 3
364 /* values for tree type (chosen to match artwork type) */
365 #define TREE_TYPE_UNDEFINED -1
366 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
367 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
368 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
369 #define TREE_TYPE_LEVEL_DIR 3
371 #define NUM_TREE_TYPES 4
374 /* values for artwork handling */
375 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
376 ((type) == ARTWORK_TYPE_GRAPHICS ? \
377 &(leveldir)->graphics_set : \
378 (type) == ARTWORK_TYPE_SOUNDS ? \
379 &(leveldir)->sounds_set : \
380 &(leveldir)->music_set)
382 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
383 ((type) == ARTWORK_TYPE_GRAPHICS ? \
384 (leveldir)->graphics_set : \
385 (type) == ARTWORK_TYPE_SOUNDS ? \
386 (leveldir)->sounds_set : \
387 (leveldir)->music_set)
389 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
390 ((type) == ARTWORK_TYPE_GRAPHICS ? \
391 &(leveldir)->graphics_path : \
392 (type) == ARTWORK_TYPE_SOUNDS ? \
393 &(leveldir)->sounds_path : \
394 &(leveldir)->music_path)
396 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
397 ((type) == ARTWORK_TYPE_GRAPHICS ? \
398 (leveldir)->graphics_path : \
399 (type) == ARTWORK_TYPE_SOUNDS ? \
400 (leveldir)->sounds_path : \
401 (leveldir)->music_path)
403 #define SETUP_ARTWORK_SET(setup, type) \
404 ((type) == ARTWORK_TYPE_GRAPHICS ? \
405 (setup).graphics_set : \
406 (type) == ARTWORK_TYPE_SOUNDS ? \
407 (setup).sounds_set : \
410 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
411 ((type) == ARTWORK_TYPE_GRAPHICS ? \
412 (setup).override_level_graphics : \
413 (type) == ARTWORK_TYPE_SOUNDS ? \
414 (setup).override_level_sounds : \
415 (setup).override_level_music)
417 #define ARTWORK_FIRST_NODE(artwork, type) \
418 ((type) == ARTWORK_TYPE_GRAPHICS ? \
419 (artwork).gfx_first : \
420 (type) == ARTWORK_TYPE_SOUNDS ? \
421 (artwork).snd_first : \
424 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
425 ((type) == ARTWORK_TYPE_GRAPHICS ? \
426 &(artwork).gfx_current_identifier : \
427 (type) == ARTWORK_TYPE_SOUNDS ? \
428 &(artwork).snd_current_identifier : \
429 &(artwork).mus_current_identifier)
431 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
432 ((type) == ARTWORK_TYPE_GRAPHICS ? \
433 (artwork).gfx_current_identifier : \
434 (type) == ARTWORK_TYPE_SOUNDS ? \
435 (artwork).snd_current_identifier : \
436 (artwork).mus_current_identifier)
438 #define ARTWORKINFO_FILENAME(type) \
439 ((type) == ARTWORK_TYPE_GRAPHICS ? \
440 GRAPHICSINFO_FILENAME : \
441 (type) == ARTWORK_TYPE_SOUNDS ? \
442 SOUNDSINFO_FILENAME : \
443 (type) == ARTWORK_TYPE_MUSIC ? \
444 MUSICINFO_FILENAME : "")
446 #define ARTWORK_DIRECTORY(type) \
447 ((type) == ARTWORK_TYPE_GRAPHICS ? \
448 GRAPHICS_DIRECTORY : \
449 (type) == ARTWORK_TYPE_SOUNDS ? \
451 (type) == ARTWORK_TYPE_MUSIC ? \
452 MUSIC_DIRECTORY : "")
454 #define OPTIONS_ARTWORK_DIRECTORY(type) \
455 ((type) == ARTWORK_TYPE_GRAPHICS ? \
456 options.graphics_directory : \
457 (type) == ARTWORK_TYPE_SOUNDS ? \
458 options.sounds_directory : \
459 (type) == ARTWORK_TYPE_MUSIC ? \
460 options.music_directory : "")
463 /* type definitions */
464 typedef int (*EventFilter)(const Event *);
467 /* structure definitions */
471 char *command_basepath; /* directory that contains the program */
472 char *command_basename; /* base filename of the program binary */
473 char *userdata_directory; /* personal user data directory */
479 char *x11_icon_filename;
480 char *x11_iconmask_filename;
481 char *msdos_cursor_filename;
484 char *filename_prefix; /* prefix to cut off from DOS filenames */
490 void (*exit_function)(int);
499 char *ro_base_directory;
500 char *rw_base_directory;
501 char *level_directory;
502 char *graphics_directory;
503 char *sounds_directory;
504 char *music_directory;
505 char *docs_directory;
506 char *execute_command;
514 struct VideoSystemInfo
517 int width, height, depth;
518 boolean fullscreen_available;
519 boolean fullscreen_enabled;
522 struct AudioSystemInfo
524 boolean sound_available;
525 boolean loops_available;
526 boolean music_available;
528 boolean sound_enabled;
529 boolean sound_deactivated; /* for temporarily disabling sound */
538 int first_sound_channel;
541 struct FontBitmapInfo
544 int src_x, src_y; /* start position of animation frames */
545 int width, height; /* width/height of each animation frame */
546 int draw_x, draw_y; /* offset for drawing font characters */
548 int num_chars_per_line;
550 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
551 Pixmap *clip_mask; /* single-char-only clip mask array for X11 */
559 int real_sx, real_sy;
560 int full_sxsize, full_sysize;
561 int scrollbuffer_width, scrollbuffer_height;
569 int draw_deactivation_mask;
570 int draw_background_mask;
572 Bitmap *field_save_buffer;
574 Bitmap *background_bitmap;
575 int background_bitmap_mask;
578 struct FontBitmapInfo *font_bitmap_info;
579 int (*select_font_function)(int);
581 int anim_random_frame;
587 int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */
590 struct SetupJoystickInfo
592 char *device_name; /* device name of player's joystick */
594 int xleft, xmiddle, xright;
595 int yupper, ymiddle, ylower;
599 struct SetupKeyboardInfo
601 Key left, right, up, down;
605 struct SetupInputInfo
607 boolean use_joystick;
608 struct SetupJoystickInfo joy;
609 struct SetupKeyboardInfo key;
612 struct SetupEditorInfo
614 boolean el_boulderdash;
615 boolean el_emerald_mine;
616 boolean el_emerald_mine_club;
620 boolean el_diamond_caves;
621 boolean el_dx_boulderdash;
624 boolean el_user_defined;
627 boolean el_headlines;
630 struct SetupEditorCascadeInfo
648 struct SetupShortcutInfo
655 struct SetupSystemInfo
657 char *sdl_audiodriver;
658 int audio_fragment_size;
668 boolean sound_simple;
670 boolean double_buffering;
671 boolean direct_draw; /* !double_buffering (redundant!) */
672 boolean scroll_delay;
673 boolean soft_scrolling;
682 boolean ask_on_escape;
687 boolean override_level_graphics;
688 boolean override_level_sounds;
689 boolean override_level_music;
691 struct SetupEditorInfo editor;
692 struct SetupEditorCascadeInfo editor_cascade;
693 struct SetupShortcutInfo shortcut;
694 struct SetupInputInfo input[MAX_PLAYERS];
695 struct SetupSystemInfo system;
696 struct OptionInfo options;
701 struct TreeInfo **node_top; /* topmost node in tree */
702 struct TreeInfo *node_parent; /* parent level directory info */
703 struct TreeInfo *node_group; /* level group sub-directory info */
704 struct TreeInfo *next; /* next level series structure node */
706 int cl_first; /* internal control field for setup screen */
707 int cl_cursor; /* internal control field for setup screen */
709 int type; /* type of tree content */
711 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
713 char *subdir; /* tree info sub-directory basename (may be ".") */
714 char *fullpath; /* complete path relative to tree base directory */
715 char *basepath; /* absolute base path of tree base directory */
716 char *identifier; /* identifier string for configuration files */
717 char *name; /* tree info name, as displayed in selection menues */
718 char *name_sorting; /* optional sorting name for correct name sorting */
719 char *author; /* level or artwork author name */
720 char *imported_from; /* optional comment for imported levels or artwork */
721 char *imported_by; /* optional comment for imported levels or artwork */
723 char *graphics_set; /* optional custom graphics set (level tree only) */
724 char *sounds_set; /* optional custom sounds set (level tree only) */
725 char *music_set; /* optional custom music set (level tree only) */
726 char *graphics_path; /* path to optional custom graphics set (level only) */
727 char *sounds_path; /* path to optional custom sounds set (level only) */
728 char *music_path; /* path to optional custom music set (level only) */
730 char *level_filename; /* filename of level file (for packed level file) */
731 char *level_filetype; /* type of levels in level directory or level file */
733 int levels; /* number of levels in level series */
734 int first_level; /* first level number (to allow start with 0 or 1) */
735 int last_level; /* last level number (automatically calculated) */
736 int sort_priority; /* sort levels by 'sort_priority' and then by name */
738 boolean latest_engine;/* force level set to use the latest game engine */
740 boolean level_group; /* directory contains more level series directories */
741 boolean parent_link; /* entry links back to parent directory */
742 boolean in_user_dir; /* user defined levels are stored in home directory */
743 boolean user_defined; /* levels in user directory and marked as "private" */
744 boolean readonly; /* readonly levels can not be changed with editor */
745 boolean handicap; /* level set has no handicap when set to "false" */
746 boolean skip_levels; /* levels can be skipped when set to "true" */
748 int color; /* color to use on selection screen for this level */
749 char *class_desc; /* description of level series class */
750 int handicap_level; /* number of the lowest unsolved level */
753 typedef struct TreeInfo TreeInfo;
754 typedef struct TreeInfo LevelDirTree;
755 typedef struct TreeInfo ArtworkDirTree;
756 typedef struct TreeInfo GraphicsDirTree;
757 typedef struct TreeInfo SoundsDirTree;
758 typedef struct TreeInfo MusicDirTree;
762 GraphicsDirTree *gfx_first;
763 GraphicsDirTree *gfx_current;
764 SoundsDirTree *snd_first;
765 SoundsDirTree *snd_current;
766 MusicDirTree *mus_first;
767 MusicDirTree *mus_current;
769 char *gfx_current_identifier;
770 char *snd_current_identifier;
771 char *mus_current_identifier;
786 struct ConfigTypeInfo
793 struct TokenIntPtrInfo
803 char *default_filename;
806 char **default_parameter; /* array of file parameters */
807 char **parameter; /* array of file parameters */
810 boolean fallback_to_default;
818 struct SetupFileList *next;
823 char *source_filename; /* primary key for node list */
827 struct PropertyMapping
837 struct ArtworkListInfo
839 int type; /* type of artwork */
841 int num_file_list_entries;
842 int num_dynamic_file_list_entries;
843 struct FileInfo *file_list; /* static artwork file array */
844 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
846 int num_suffix_list_entries;
847 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
849 int num_base_prefixes;
850 int num_ext1_suffixes;
851 int num_ext2_suffixes;
852 int num_ext3_suffixes;
853 char **base_prefixes; /* base token prefixes array */
854 char **ext1_suffixes; /* property suffixes array 1 */
855 char **ext2_suffixes; /* property suffixes array 2 */
856 char **ext3_suffixes; /* property suffixes array 3 */
858 int num_ignore_tokens;
859 char **ignore_tokens; /* file tokens to be ignored */
861 int num_property_mapping_entries;
862 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
864 int sizeof_artwork_list_entry;
866 struct ListNodeInfo **artwork_list; /* static artwork node array */
867 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
868 struct ListNode *content_list; /* dynamic artwork node list */
870 void *(*load_artwork)(char *); /* constructor function */
871 void (*free_artwork)(void *); /* destructor function */
875 /* ========================================================================= */
876 /* exported variables */
877 /* ========================================================================= */
879 extern struct ProgramInfo program;
880 extern struct OptionInfo options;
881 extern struct VideoSystemInfo video;
882 extern struct AudioSystemInfo audio;
883 extern struct GfxInfo gfx;
884 extern struct AnimInfo anim;
885 extern struct ArtworkInfo artwork;
886 extern struct JoystickInfo joystick;
887 extern struct SetupInfo setup;
889 extern LevelDirTree *leveldir_first;
890 extern LevelDirTree *leveldir_current;
893 extern Display *display;
894 extern Visual *visual;
896 extern Colormap cmap;
898 extern DrawWindow *window;
899 extern DrawBuffer *backbuffer;
900 extern DrawBuffer *drawto;
902 extern int button_status;
903 extern boolean motion_status;
905 extern int redraw_mask;
906 extern int redraw_tiles;
908 extern int FrameCounter;
911 /* function definitions */
913 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
914 char *, char *, char *, int);
916 void InitExitFunction(void (*exit_function)(int));
917 void InitPlatformDependentStuff(void);
918 void ClosePlatformDependentStuff(void);
920 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
921 void InitGfxDoor1Info(int, int, int, int);
922 void InitGfxDoor2Info(int, int, int, int);
923 void InitGfxScrollbufferInfo(int, int);
924 void SetDrawDeactivationMask(int);
925 void SetDrawBackgroundMask(int);
926 void SetMainBackgroundBitmap(Bitmap *);
927 void SetDoorBackgroundBitmap(Bitmap *);
929 inline void InitVideoDisplay(void);
930 inline void CloseVideoDisplay(void);
931 inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
932 inline Bitmap *CreateBitmapStruct(void);
933 inline Bitmap *CreateBitmap(int, int, int);
934 inline void FreeBitmap(Bitmap *);
935 inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
936 inline void FillRectangle(Bitmap *, int, int, int, int, Pixel);
937 inline void ClearRectangle(Bitmap *, int, int, int, int);
938 inline void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
939 inline void SetClipMask(Bitmap *, GC, Pixmap);
940 inline void SetClipOrigin(Bitmap *, GC, int, int);
941 inline void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
942 inline boolean DrawingOnBackground(int, int);
943 inline void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int,
945 inline void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
946 inline void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
947 inline void DrawLines(Bitmap *, struct XY *, int, Pixel);
948 inline Pixel GetPixel(Bitmap *, int, int);
949 inline Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
950 inline Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
952 inline void FlushDisplay(void);
953 inline void SyncDisplay(void);
954 inline void KeyboardAutoRepeatOn(void);
955 inline void KeyboardAutoRepeatOff(void);
956 inline boolean PointerInWindow(DrawWindow *);
957 inline boolean SetVideoMode(boolean);
958 inline boolean ChangeVideoModeIfNeeded(boolean);
960 Bitmap *LoadImage(char *);
961 Bitmap *LoadCustomImage(char *);
962 void ReloadCustomImage(Bitmap *, char *);
964 Bitmap *ZoomBitmap(Bitmap *, int, int);
965 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
967 void SetMouseCursor(int);
969 inline void OpenAudio(void);
970 inline void CloseAudio(void);
971 inline void SetAudioMode(boolean);
973 inline void InitEventFilter(EventFilter);
974 inline boolean PendingEvent(void);
975 inline void NextEvent(Event *event);
976 inline void PeekEvent(Event *event);
977 inline Key GetEventKey(KeyEvent *, boolean);
978 inline KeyMod HandleKeyModState(Key, int);
979 inline KeyMod GetKeyModState();
980 inline boolean CheckCloseWindowEvent(ClientMessageEvent *);
982 inline void InitJoysticks();
983 inline boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
985 #endif /* SYSTEM_H */