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
95 /* values for move directions */
97 #define MV_BIT_RIGHT 1
101 #define NUM_DIRECTIONS 4
103 /* diagonal movement directions are used in a different contect than buttons */
104 #define MV_BIT_UPLEFT 4
105 #define MV_BIT_UPRIGHT 5
106 #define MV_BIT_DOWNLEFT 6
107 #define MV_BIT_DOWNRIGHT 7
109 #define NUM_DIRECTIONS_FULL 8
111 /* values for special "button" bitmasks */
115 /* values for move directions and special "button" key bitmasks */
117 #define MV_LEFT (1 << MV_BIT_LEFT)
118 #define MV_RIGHT (1 << MV_BIT_RIGHT)
119 #define MV_UP (1 << MV_BIT_UP)
120 #define MV_DOWN (1 << MV_BIT_DOWN)
122 #define MV_UPLEFT (MV_UP | MV_LEFT)
123 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
124 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
125 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
127 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
128 #define MV_VERTICAL (MV_UP | MV_DOWN)
129 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
130 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
131 #define MV_NO_DIRECTION (MV_NONE)
133 #define KEY_BUTTON_1 (1 << BUTTON_1)
134 #define KEY_BUTTON_2 (1 << BUTTON_2)
135 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
136 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
137 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
139 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
140 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
141 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
142 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
143 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
146 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
147 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
148 (x) == MV_UP ? MV_BIT_UP : \
149 (x) == MV_DOWN ? MV_BIT_DOWN : \
150 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
151 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
152 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
153 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
156 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
157 (x) == MV_RIGHT ? MV_LEFT : \
158 (x) == MV_UP ? MV_DOWN : \
159 (x) == MV_DOWN ? MV_UP : \
160 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
161 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
162 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
163 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
166 /* values for animation mode (frame order and direction) */
168 #define ANIM_LOOP (1 << 0)
169 #define ANIM_LINEAR (1 << 1)
170 #define ANIM_PINGPONG (1 << 2)
171 #define ANIM_PINGPONG2 (1 << 3)
172 #define ANIM_RANDOM (1 << 4)
173 #define ANIM_CE_VALUE (1 << 5)
174 #define ANIM_CE_SCORE (1 << 6)
175 #define ANIM_REVERSE (1 << 7)
177 /* values for special (non game element) animation modes */
178 #define ANIM_HORIZONTAL (1 << 8)
179 #define ANIM_VERTICAL (1 << 9)
180 #define ANIM_STATIC_PANEL (1 << 10)
182 #define ANIM_DEFAULT ANIM_LOOP
184 /* values for redraw_mask */
185 #define REDRAW_NONE (0)
186 #define REDRAW_ALL (1 << 0)
187 #define REDRAW_FIELD (1 << 1)
188 #define REDRAW_TILES (1 << 2)
189 #define REDRAW_DOOR_1 (1 << 3)
190 #define REDRAW_VIDEO_1 (1 << 4)
191 #define REDRAW_VIDEO_2 (1 << 5)
192 #define REDRAW_VIDEO_3 (1 << 6)
193 #define REDRAW_MICROLEVEL (1 << 7)
194 #define REDRAW_MICROLABEL (1 << 8)
195 #define REDRAW_FROM_BACKBUFFER (1 << 9)
196 #define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
199 #define REDRAW_DOOR_3 (1 << 10)
200 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
203 #define REDRAW_MAIN (REDRAW_FIELD | \
206 #define REDRAW_FPS (1 << 11)
207 #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
209 #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
210 y >= gfx.sy && y < gfx.sy + gfx.sysize)
211 #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
212 y >= gfx.dy && y < gfx.dy + gfx.dysize)
213 #define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
214 y >= gfx.vy && y < gfx.vy + gfx.vysize)
216 /* values for mouse cursor */
217 #define CURSOR_DEFAULT 0
218 #define CURSOR_PLAYFIELD 1
221 /* maximum playfield size supported by libgame functions */
222 #define MAX_PLAYFIELD_WIDTH 128
223 #define MAX_PLAYFIELD_HEIGHT 128
225 /* maximum number of parallel players supported by libgame functions */
226 #define MAX_PLAYERS 4
228 /* maximum allowed length of player name */
229 #define MAX_PLAYER_NAME_LEN 10
231 /* default name for empty highscore entry */
232 #define EMPTY_PLAYER_NAME "no name"
234 /* default name for unknown player names */
235 #define ANONYMOUS_NAME "anonymous"
237 /* default for other unknown names */
238 #define UNKNOWN_NAME "unknown"
240 /* default name for new levels */
241 #define NAMELESS_LEVEL_NAME "nameless level"
243 /* default text for non-existant artwork */
244 #define NOT_AVAILABLE "(not available)"
246 /* default value for undefined filename */
247 #define UNDEFINED_FILENAME "[NONE]"
249 /* default value for undefined parameter */
250 #define ARG_DEFAULT "[DEFAULT]"
252 /* default values for undefined configuration file parameters */
253 #define ARG_UNDEFINED "-1000000"
254 #define ARG_UNDEFINED_VALUE (atoi(ARG_UNDEFINED))
256 /* definitions for game sub-directories */
258 #define RO_GAME_DIR "."
262 #define RW_GAME_DIR "."
265 #define RO_BASE_PATH RO_GAME_DIR
266 #define RW_BASE_PATH RW_GAME_DIR
268 /* directory names */
269 #define GRAPHICS_DIRECTORY "graphics"
270 #define SOUNDS_DIRECTORY "sounds"
271 #define MUSIC_DIRECTORY "music"
272 #define LEVELS_DIRECTORY "levels"
273 #define TAPES_DIRECTORY "tapes"
274 #define SCORES_DIRECTORY "scores"
275 #define DOCS_DIRECTORY "docs"
277 #if !defined(PLATFORM_MSDOS)
278 #define GFX_CLASSIC_SUBDIR "gfx_classic"
279 #define SND_CLASSIC_SUBDIR "snd_classic"
280 #define MUS_CLASSIC_SUBDIR "mus_classic"
282 #define GFX_CLASSIC_SUBDIR "gfx_orig"
283 #define SND_CLASSIC_SUBDIR "snd_orig"
284 #define MUS_CLASSIC_SUBDIR "mus_orig"
287 /* file names and filename extensions */
288 #if !defined(PLATFORM_MSDOS)
289 #define LEVELSETUP_DIRECTORY "levelsetup"
290 #define SETUP_FILENAME "setup.conf"
291 #define LEVELSETUP_FILENAME "levelsetup.conf"
292 #define EDITORSETUP_FILENAME "editorsetup.conf"
293 #define EDITORCASCADE_FILENAME "editorcascade.conf"
294 #define HELPANIM_FILENAME "helpanim.conf"
295 #define HELPTEXT_FILENAME "helptext.conf"
296 #define LEVELINFO_FILENAME "levelinfo.conf"
297 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
298 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
299 #define MUSICINFO_FILENAME "musicinfo.conf"
300 #define LEVELFILE_EXTENSION "level"
301 #define TAPEFILE_EXTENSION "tape"
302 #define SCOREFILE_EXTENSION "score"
304 #define LEVELSETUP_DIRECTORY "lvlsetup"
305 #define SETUP_FILENAME "setup.cnf"
306 #define LEVELSETUP_FILENAME "lvlsetup.cnf"
307 #define EDITORSETUP_FILENAME "edsetup.cnf"
308 #define EDITORCASCADE_FILENAME "edcascad.conf"
309 #define HELPANIM_FILENAME "helpanim.cnf"
310 #define HELPTEXT_FILENAME "helptext.cnf"
311 #define LEVELINFO_FILENAME "lvlinfo.cnf"
312 #define GRAPHICSINFO_FILENAME "gfxinfo.cnf"
313 #define SOUNDSINFO_FILENAME "sndinfo.cnf"
314 #define MUSICINFO_FILENAME "musinfo.cnf"
315 #define LEVELFILE_EXTENSION "lvl"
316 #define TAPEFILE_EXTENSION "tap"
317 #define SCOREFILE_EXTENSION "sco"
321 /* areas in bitmap PIX_DOOR */
322 /* meaning in PIX_DB_DOOR: (3 PAGEs)
323 PAGEX1: 1. buffer for DOOR_1
324 PAGEX2: 2. buffer for DOOR_1
325 PAGEX3: buffer for animations
328 /* these values are hard-coded to be able to use them in initialization */
329 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
330 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
332 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
333 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
334 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
335 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
336 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
337 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
338 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
339 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
340 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
341 #define DOOR_GFX_PAGEY1 (0)
342 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
345 /* macros for version handling */
346 #define VERSION_MAJOR(x) ((x) / 1000000)
347 #define VERSION_MINOR(x) (((x) % 1000000) / 10000)
348 #define VERSION_PATCH(x) (((x) % 10000) / 100)
349 #define VERSION_BUILD(x) ((x) % 100)
350 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
353 /* macros for parent/child process identification */
354 #if defined(PLATFORM_UNIX)
355 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
356 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
357 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
359 #define IS_PARENT_PROCESS() TRUE
360 #define IS_CHILD_PROCESS() FALSE
361 #define HAS_CHILD_PROCESS() FALSE
365 /* values for artwork type */
366 #define ARTWORK_TYPE_GRAPHICS 0
367 #define ARTWORK_TYPE_SOUNDS 1
368 #define ARTWORK_TYPE_MUSIC 2
370 #define NUM_ARTWORK_TYPES 3
373 /* values for tree type (chosen to match artwork type) */
374 #define TREE_TYPE_UNDEFINED -1
375 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
376 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
377 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
378 #define TREE_TYPE_LEVEL_DIR 3
380 #define NUM_TREE_TYPES 4
383 /* values for artwork handling */
384 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
385 ((type) == ARTWORK_TYPE_GRAPHICS ? \
386 &(leveldir)->graphics_set : \
387 (type) == ARTWORK_TYPE_SOUNDS ? \
388 &(leveldir)->sounds_set : \
389 &(leveldir)->music_set)
391 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
392 ((type) == ARTWORK_TYPE_GRAPHICS ? \
393 (leveldir)->graphics_set : \
394 (type) == ARTWORK_TYPE_SOUNDS ? \
395 (leveldir)->sounds_set : \
396 (leveldir)->music_set)
398 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
399 ((type) == ARTWORK_TYPE_GRAPHICS ? \
400 &(leveldir)->graphics_path : \
401 (type) == ARTWORK_TYPE_SOUNDS ? \
402 &(leveldir)->sounds_path : \
403 &(leveldir)->music_path)
405 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
406 ((type) == ARTWORK_TYPE_GRAPHICS ? \
407 (leveldir)->graphics_path : \
408 (type) == ARTWORK_TYPE_SOUNDS ? \
409 (leveldir)->sounds_path : \
410 (leveldir)->music_path)
412 #define SETUP_ARTWORK_SET(setup, type) \
413 ((type) == ARTWORK_TYPE_GRAPHICS ? \
414 (setup).graphics_set : \
415 (type) == ARTWORK_TYPE_SOUNDS ? \
416 (setup).sounds_set : \
419 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
420 ((type) == ARTWORK_TYPE_GRAPHICS ? \
421 (setup).override_level_graphics : \
422 (type) == ARTWORK_TYPE_SOUNDS ? \
423 (setup).override_level_sounds : \
424 (setup).override_level_music)
426 #define ARTWORK_FIRST_NODE(artwork, type) \
427 ((type) == ARTWORK_TYPE_GRAPHICS ? \
428 (artwork).gfx_first : \
429 (type) == ARTWORK_TYPE_SOUNDS ? \
430 (artwork).snd_first : \
433 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
434 ((type) == ARTWORK_TYPE_GRAPHICS ? \
435 &(artwork).gfx_current_identifier : \
436 (type) == ARTWORK_TYPE_SOUNDS ? \
437 &(artwork).snd_current_identifier : \
438 &(artwork).mus_current_identifier)
440 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
441 ((type) == ARTWORK_TYPE_GRAPHICS ? \
442 (artwork).gfx_current_identifier : \
443 (type) == ARTWORK_TYPE_SOUNDS ? \
444 (artwork).snd_current_identifier : \
445 (artwork).mus_current_identifier)
447 #define ARTWORKINFO_FILENAME(type) \
448 ((type) == ARTWORK_TYPE_GRAPHICS ? \
449 GRAPHICSINFO_FILENAME : \
450 (type) == ARTWORK_TYPE_SOUNDS ? \
451 SOUNDSINFO_FILENAME : \
452 (type) == ARTWORK_TYPE_MUSIC ? \
453 MUSICINFO_FILENAME : "")
455 #define ARTWORK_DIRECTORY(type) \
456 ((type) == ARTWORK_TYPE_GRAPHICS ? \
457 GRAPHICS_DIRECTORY : \
458 (type) == ARTWORK_TYPE_SOUNDS ? \
460 (type) == ARTWORK_TYPE_MUSIC ? \
461 MUSIC_DIRECTORY : "")
463 #define OPTIONS_ARTWORK_DIRECTORY(type) \
464 ((type) == ARTWORK_TYPE_GRAPHICS ? \
465 options.graphics_directory : \
466 (type) == ARTWORK_TYPE_SOUNDS ? \
467 options.sounds_directory : \
468 (type) == ARTWORK_TYPE_MUSIC ? \
469 options.music_directory : "")
472 /* type definitions */
473 typedef int (*EventFilter)(const Event *);
476 /* structure definitions */
480 char *command_basepath; /* directory that contains the program */
481 char *command_basename; /* base filename of the program binary */
482 char *userdata_directory; /* personal user data directory */
488 char *x11_icon_filename;
489 char *x11_iconmask_filename;
490 char *msdos_cursor_filename;
493 char *filename_prefix; /* prefix to cut off from DOS filenames */
499 void (*exit_function)(int);
508 char *ro_base_directory;
509 char *rw_base_directory;
510 char *level_directory;
511 char *graphics_directory;
512 char *sounds_directory;
513 char *music_directory;
514 char *docs_directory;
515 char *execute_command;
523 struct VideoSystemInfo
526 int width, height, depth;
527 boolean fullscreen_available;
528 boolean fullscreen_enabled;
531 struct AudioSystemInfo
533 boolean sound_available;
534 boolean loops_available;
535 boolean music_available;
537 boolean sound_enabled;
538 boolean sound_deactivated; /* for temporarily disabling sound */
547 int first_sound_channel;
550 struct FontBitmapInfo
553 int src_x, src_y; /* start position of animation frames */
554 int width, height; /* width/height of each animation frame */
555 int draw_x, draw_y; /* offset for drawing font characters */
557 int num_chars_per_line;
559 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
560 Pixmap *clip_mask; /* single-char-only clip mask array for X11 */
568 int real_sx, real_sy;
569 int full_sxsize, full_sysize;
570 int scrollbuffer_width, scrollbuffer_height;
578 int draw_deactivation_mask;
579 int draw_background_mask;
581 Bitmap *field_save_buffer;
583 Bitmap *background_bitmap;
584 int background_bitmap_mask;
587 struct FontBitmapInfo *font_bitmap_info;
588 int (*select_font_function)(int);
590 int anim_random_frame;
596 int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */
599 struct SetupJoystickInfo
601 char *device_name; /* device name of player's joystick */
603 int xleft, xmiddle, xright;
604 int yupper, ymiddle, ylower;
608 struct SetupKeyboardInfo
610 Key left, right, up, down;
614 struct SetupInputInfo
616 boolean use_joystick;
617 struct SetupJoystickInfo joy;
618 struct SetupKeyboardInfo key;
621 struct SetupEditorInfo
623 boolean el_boulderdash;
624 boolean el_emerald_mine;
625 boolean el_emerald_mine_club;
629 boolean el_diamond_caves;
630 boolean el_dx_boulderdash;
633 boolean el_user_defined;
636 boolean el_headlines;
639 struct SetupEditorCascadeInfo
656 struct SetupShortcutInfo
662 Key focus_player[MAX_PLAYERS];
663 Key focus_player_all;
666 struct SetupSystemInfo
668 char *sdl_audiodriver;
669 int audio_fragment_size;
679 boolean sound_simple;
681 boolean double_buffering;
682 boolean direct_draw; /* !double_buffering (redundant!) */
683 boolean scroll_delay;
684 boolean soft_scrolling;
693 boolean ask_on_escape;
694 boolean ask_on_escape_editor;
695 boolean quick_switch;
700 boolean override_level_graphics;
701 boolean override_level_sounds;
702 boolean override_level_music;
704 struct SetupEditorInfo editor;
705 struct SetupEditorCascadeInfo editor_cascade;
706 struct SetupShortcutInfo shortcut;
707 struct SetupInputInfo input[MAX_PLAYERS];
708 struct SetupSystemInfo system;
709 struct OptionInfo options;
714 struct TreeInfo **node_top; /* topmost node in tree */
715 struct TreeInfo *node_parent; /* parent level directory info */
716 struct TreeInfo *node_group; /* level group sub-directory info */
717 struct TreeInfo *next; /* next level series structure node */
719 int cl_first; /* internal control field for setup screen */
720 int cl_cursor; /* internal control field for setup screen */
722 int type; /* type of tree content */
724 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
726 char *subdir; /* tree info sub-directory basename (may be ".") */
727 char *fullpath; /* complete path relative to tree base directory */
728 char *basepath; /* absolute base path of tree base directory */
729 char *identifier; /* identifier string for configuration files */
730 char *name; /* tree info name, as displayed in selection menues */
731 char *name_sorting; /* optional sorting name for correct name sorting */
732 char *author; /* level or artwork author name */
733 char *imported_from; /* optional comment for imported levels or artwork */
734 char *imported_by; /* optional comment for imported levels or artwork */
736 char *graphics_set; /* optional custom graphics set (level tree only) */
737 char *sounds_set; /* optional custom sounds set (level tree only) */
738 char *music_set; /* optional custom music set (level tree only) */
739 char *graphics_path; /* path to optional custom graphics set (level only) */
740 char *sounds_path; /* path to optional custom sounds set (level only) */
741 char *music_path; /* path to optional custom music set (level only) */
743 char *level_filename; /* filename of level file (for packed level file) */
744 char *level_filetype; /* type of levels in level directory or level file */
746 int levels; /* number of levels in level series */
747 int first_level; /* first level number (to allow start with 0 or 1) */
748 int last_level; /* last level number (automatically calculated) */
749 int sort_priority; /* sort levels by 'sort_priority' and then by name */
751 boolean latest_engine;/* force level set to use the latest game engine */
753 boolean level_group; /* directory contains more level series directories */
754 boolean parent_link; /* entry links back to parent directory */
755 boolean in_user_dir; /* user defined levels are stored in home directory */
756 boolean user_defined; /* levels in user directory and marked as "private" */
757 boolean readonly; /* readonly levels can not be changed with editor */
758 boolean handicap; /* level set has no handicap when set to "false" */
759 boolean skip_levels; /* levels can be skipped when set to "true" */
761 int color; /* color to use on selection screen for this level */
762 char *class_desc; /* description of level series class */
763 int handicap_level; /* number of the lowest unsolved level */
766 typedef struct TreeInfo TreeInfo;
767 typedef struct TreeInfo LevelDirTree;
768 typedef struct TreeInfo ArtworkDirTree;
769 typedef struct TreeInfo GraphicsDirTree;
770 typedef struct TreeInfo SoundsDirTree;
771 typedef struct TreeInfo MusicDirTree;
775 GraphicsDirTree *gfx_first;
776 GraphicsDirTree *gfx_current;
777 SoundsDirTree *snd_first;
778 SoundsDirTree *snd_current;
779 MusicDirTree *mus_first;
780 MusicDirTree *mus_current;
782 char *gfx_current_identifier;
783 char *snd_current_identifier;
784 char *mus_current_identifier;
799 struct ConfigTypeInfo
806 struct TokenIntPtrInfo
816 char *default_filename;
819 char **default_parameter; /* array of file parameters */
820 char **parameter; /* array of file parameters */
823 boolean fallback_to_default;
831 struct SetupFileList *next;
836 char *source_filename; /* primary key for node list */
840 struct PropertyMapping
850 struct ArtworkListInfo
852 int type; /* type of artwork */
854 int num_file_list_entries;
855 int num_dynamic_file_list_entries;
856 struct FileInfo *file_list; /* static artwork file array */
857 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
859 int num_suffix_list_entries;
860 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
862 int num_base_prefixes;
863 int num_ext1_suffixes;
864 int num_ext2_suffixes;
865 int num_ext3_suffixes;
866 char **base_prefixes; /* base token prefixes array */
867 char **ext1_suffixes; /* property suffixes array 1 */
868 char **ext2_suffixes; /* property suffixes array 2 */
869 char **ext3_suffixes; /* property suffixes array 3 */
871 int num_ignore_tokens;
872 char **ignore_tokens; /* file tokens to be ignored */
874 int num_property_mapping_entries;
875 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
877 int sizeof_artwork_list_entry;
879 struct ListNodeInfo **artwork_list; /* static artwork node array */
880 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
881 struct ListNode *content_list; /* dynamic artwork node list */
883 void *(*load_artwork)(char *); /* constructor function */
884 void (*free_artwork)(void *); /* destructor function */
888 /* ========================================================================= */
889 /* exported variables */
890 /* ========================================================================= */
892 extern struct ProgramInfo program;
893 extern struct OptionInfo options;
894 extern struct VideoSystemInfo video;
895 extern struct AudioSystemInfo audio;
896 extern struct GfxInfo gfx;
897 extern struct AnimInfo anim;
898 extern struct ArtworkInfo artwork;
899 extern struct JoystickInfo joystick;
900 extern struct SetupInfo setup;
902 extern LevelDirTree *leveldir_first_all;
903 extern LevelDirTree *leveldir_first;
904 extern LevelDirTree *leveldir_current;
907 extern Display *display;
908 extern Visual *visual;
910 extern Colormap cmap;
912 extern DrawWindow *window;
913 extern DrawBuffer *backbuffer;
914 extern DrawBuffer *drawto;
916 extern int button_status;
917 extern boolean motion_status;
919 extern int redraw_mask;
920 extern int redraw_tiles;
922 extern int FrameCounter;
925 /* function definitions */
927 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
928 char *, char *, char *, int);
930 void InitExitFunction(void (*exit_function)(int));
931 void InitPlatformDependentStuff(void);
932 void ClosePlatformDependentStuff(void);
934 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
935 void InitGfxDoor1Info(int, int, int, int);
936 void InitGfxDoor2Info(int, int, int, int);
937 void InitGfxScrollbufferInfo(int, int);
938 void SetDrawDeactivationMask(int);
939 void SetDrawBackgroundMask(int);
940 void SetMainBackgroundBitmap(Bitmap *);
941 void SetDoorBackgroundBitmap(Bitmap *);
943 inline void InitVideoDisplay(void);
944 inline void CloseVideoDisplay(void);
945 inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
946 inline Bitmap *CreateBitmapStruct(void);
947 inline Bitmap *CreateBitmap(int, int, int);
948 inline void FreeBitmap(Bitmap *);
949 inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
950 inline void FillRectangle(Bitmap *, int, int, int, int, Pixel);
951 inline void ClearRectangle(Bitmap *, int, int, int, int);
952 inline void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
953 inline void SetClipMask(Bitmap *, GC, Pixmap);
954 inline void SetClipOrigin(Bitmap *, GC, int, int);
955 inline void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
956 inline boolean DrawingOnBackground(int, int);
957 inline void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int,
959 inline void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
960 inline void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
961 inline void DrawLines(Bitmap *, struct XY *, int, Pixel);
962 inline Pixel GetPixel(Bitmap *, int, int);
963 inline Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
964 inline Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
966 inline void FlushDisplay(void);
967 inline void SyncDisplay(void);
968 inline void KeyboardAutoRepeatOn(void);
969 inline void KeyboardAutoRepeatOff(void);
970 inline boolean PointerInWindow(DrawWindow *);
971 inline boolean SetVideoMode(boolean);
972 inline boolean ChangeVideoModeIfNeeded(boolean);
974 Bitmap *LoadImage(char *);
975 Bitmap *LoadCustomImage(char *);
976 void ReloadCustomImage(Bitmap *, char *);
978 Bitmap *ZoomBitmap(Bitmap *, int, int);
979 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
981 void SetMouseCursor(int);
983 inline void OpenAudio(void);
984 inline void CloseAudio(void);
985 inline void SetAudioMode(boolean);
987 inline void InitEventFilter(EventFilter);
988 inline boolean PendingEvent(void);
989 inline void NextEvent(Event *event);
990 inline void PeekEvent(Event *event);
991 inline Key GetEventKey(KeyEvent *, boolean);
992 inline KeyMod HandleKeyModState(Key, int);
993 inline KeyMod GetKeyModState();
994 inline boolean CheckCloseWindowEvent(ClientMessageEvent *);
996 inline void InitJoysticks();
997 inline boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
999 #endif /* SYSTEM_H */