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 special "focus player" bitmasks */
116 #define BIT_SET_FOCUS 6
118 /* values for move directions and special "button" key bitmasks */
120 #define MV_LEFT (1 << MV_BIT_LEFT)
121 #define MV_RIGHT (1 << MV_BIT_RIGHT)
122 #define MV_UP (1 << MV_BIT_UP)
123 #define MV_DOWN (1 << MV_BIT_DOWN)
125 #define MV_UPLEFT (MV_UP | MV_LEFT)
126 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
127 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
128 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
130 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
131 #define MV_VERTICAL (MV_UP | MV_DOWN)
132 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
133 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
134 #define MV_NO_DIRECTION (MV_NONE)
136 #define KEY_BUTTON_1 (1 << BUTTON_1)
137 #define KEY_BUTTON_2 (1 << BUTTON_2)
138 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
139 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
140 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
142 #define SET_FOCUS (1 << BIT_SET_FOCUS)
144 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
145 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
146 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
147 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
148 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
151 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
152 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
153 (x) == MV_UP ? MV_BIT_UP : \
154 (x) == MV_DOWN ? MV_BIT_DOWN : \
155 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
156 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
157 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
158 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
161 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
162 (x) == MV_RIGHT ? MV_LEFT : \
163 (x) == MV_UP ? MV_DOWN : \
164 (x) == MV_DOWN ? MV_UP : \
165 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
166 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
167 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
168 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
171 /* values for animation mode (frame order and direction) */
173 #define ANIM_LOOP (1 << 0)
174 #define ANIM_LINEAR (1 << 1)
175 #define ANIM_PINGPONG (1 << 2)
176 #define ANIM_PINGPONG2 (1 << 3)
177 #define ANIM_RANDOM (1 << 4)
178 #define ANIM_CE_VALUE (1 << 5)
179 #define ANIM_CE_SCORE (1 << 6)
180 #define ANIM_REVERSE (1 << 7)
181 #define ANIM_OPAQUE_PLAYER (1 << 8)
183 /* values for special (non game element) animation modes */
184 #define ANIM_HORIZONTAL (1 << 9)
185 #define ANIM_VERTICAL (1 << 10)
186 #define ANIM_STATIC_PANEL (1 << 11)
188 #define ANIM_DEFAULT ANIM_LOOP
190 /* values for redraw_mask */
191 #define REDRAW_NONE (0)
192 #define REDRAW_ALL (1 << 0)
193 #define REDRAW_FIELD (1 << 1)
194 #define REDRAW_TILES (1 << 2)
195 #define REDRAW_DOOR_1 (1 << 3)
196 #define REDRAW_VIDEO_1 (1 << 4)
197 #define REDRAW_VIDEO_2 (1 << 5)
198 #define REDRAW_VIDEO_3 (1 << 6)
199 #define REDRAW_MICROLEVEL (1 << 7)
200 #define REDRAW_MICROLABEL (1 << 8)
201 #define REDRAW_FROM_BACKBUFFER (1 << 9)
202 #define REDRAW_DOOR_2 (REDRAW_VIDEO_1 | \
205 #define REDRAW_DOOR_3 (1 << 10)
206 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
209 #define REDRAW_MAIN (REDRAW_FIELD | \
212 #define REDRAW_FPS (1 << 11)
213 #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2)
215 #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
216 y >= gfx.sy && y < gfx.sy + gfx.sysize)
217 #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
218 y >= gfx.dy && y < gfx.dy + gfx.dysize)
219 #define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
220 y >= gfx.vy && y < gfx.vy + gfx.vysize)
222 /* values for mouse cursor */
223 #define CURSOR_DEFAULT 0
224 #define CURSOR_PLAYFIELD 1
226 /* fundamental game speed values */
227 #define ONE_SECOND_DELAY 1000 /* delay value for one second */
228 #define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
229 #define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
230 #define FRAMES_PER_SECOND (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
232 /* maximum playfield size supported by libgame functions */
233 #define MAX_PLAYFIELD_WIDTH 128
234 #define MAX_PLAYFIELD_HEIGHT 128
236 /* maximum number of parallel players supported by libgame functions */
237 #define MAX_PLAYERS 4
239 /* maximum allowed length of player name */
240 #define MAX_PLAYER_NAME_LEN 10
242 /* default name for empty highscore entry */
243 #define EMPTY_PLAYER_NAME "no name"
245 /* default name for unknown player names */
246 #define ANONYMOUS_NAME "anonymous"
248 /* default for other unknown names */
249 #define UNKNOWN_NAME "unknown"
251 /* default name for new levels */
252 #define NAMELESS_LEVEL_NAME "nameless level"
254 /* default text for non-existant artwork */
255 #define NOT_AVAILABLE "(not available)"
257 /* default value for undefined filename */
258 #define UNDEFINED_FILENAME "[NONE]"
260 /* default value for undefined parameter */
261 #define ARG_DEFAULT "[DEFAULT]"
263 /* default values for undefined configuration file parameters */
264 #define ARG_UNDEFINED "-1000000"
265 #define ARG_UNDEFINED_VALUE (atoi(ARG_UNDEFINED))
267 /* definitions for game sub-directories */
269 #define RO_GAME_DIR "."
273 #define RW_GAME_DIR "."
276 #define RO_BASE_PATH RO_GAME_DIR
277 #define RW_BASE_PATH RW_GAME_DIR
279 /* directory names */
280 #define GRAPHICS_DIRECTORY "graphics"
281 #define SOUNDS_DIRECTORY "sounds"
282 #define MUSIC_DIRECTORY "music"
283 #define LEVELS_DIRECTORY "levels"
284 #define TAPES_DIRECTORY "tapes"
285 #define SCORES_DIRECTORY "scores"
286 #define DOCS_DIRECTORY "docs"
288 #if !defined(PLATFORM_MSDOS)
289 #define GFX_CLASSIC_SUBDIR "gfx_classic"
290 #define SND_CLASSIC_SUBDIR "snd_classic"
291 #define MUS_CLASSIC_SUBDIR "mus_classic"
293 #define GFX_CLASSIC_SUBDIR "gfx_orig"
294 #define SND_CLASSIC_SUBDIR "snd_orig"
295 #define MUS_CLASSIC_SUBDIR "mus_orig"
298 /* file names and filename extensions */
299 #if !defined(PLATFORM_MSDOS)
300 #define LEVELSETUP_DIRECTORY "levelsetup"
301 #define SETUP_FILENAME "setup.conf"
302 #define LEVELSETUP_FILENAME "levelsetup.conf"
303 #define EDITORSETUP_FILENAME "editorsetup.conf"
304 #define EDITORCASCADE_FILENAME "editorcascade.conf"
305 #define HELPANIM_FILENAME "helpanim.conf"
306 #define HELPTEXT_FILENAME "helptext.conf"
307 #define LEVELINFO_FILENAME "levelinfo.conf"
308 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
309 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
310 #define MUSICINFO_FILENAME "musicinfo.conf"
311 #define LEVELFILE_EXTENSION "level"
312 #define TAPEFILE_EXTENSION "tape"
313 #define SCOREFILE_EXTENSION "score"
315 #define LEVELSETUP_DIRECTORY "lvlsetup"
316 #define SETUP_FILENAME "setup.cnf"
317 #define LEVELSETUP_FILENAME "lvlsetup.cnf"
318 #define EDITORSETUP_FILENAME "edsetup.cnf"
319 #define EDITORCASCADE_FILENAME "edcascad.conf"
320 #define HELPANIM_FILENAME "helpanim.cnf"
321 #define HELPTEXT_FILENAME "helptext.cnf"
322 #define LEVELINFO_FILENAME "lvlinfo.cnf"
323 #define GRAPHICSINFO_FILENAME "gfxinfo.cnf"
324 #define SOUNDSINFO_FILENAME "sndinfo.cnf"
325 #define MUSICINFO_FILENAME "musinfo.cnf"
326 #define LEVELFILE_EXTENSION "lvl"
327 #define TAPEFILE_EXTENSION "tap"
328 #define SCOREFILE_EXTENSION "sco"
332 /* areas in bitmap PIX_DOOR */
333 /* meaning in PIX_DB_DOOR: (3 PAGEs)
334 PAGEX1: 1. buffer for DOOR_1
335 PAGEX2: 2. buffer for DOOR_1
336 PAGEX3: buffer for animations
339 /* these values are hard-coded to be able to use them in initialization */
340 #define DOOR_GFX_PAGE_WIDTH 100 /* should be set to "gfx.dxsize" */
341 #define DOOR_GFX_PAGE_HEIGHT 280 /* should be set to "gfx.dysize" */
343 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
344 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
345 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
346 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
347 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
348 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
349 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
350 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
351 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
352 #define DOOR_GFX_PAGEY1 (0)
353 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
356 /* macros for version handling */
357 #define VERSION_MAJOR(x) ((x) / 1000000)
358 #define VERSION_MINOR(x) (((x) % 1000000) / 10000)
359 #define VERSION_PATCH(x) (((x) % 10000) / 100)
360 #define VERSION_BUILD(x) ((x) % 100)
361 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
364 /* macros for parent/child process identification */
365 #if defined(PLATFORM_UNIX)
366 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
367 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
368 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
370 #define IS_PARENT_PROCESS() TRUE
371 #define IS_CHILD_PROCESS() FALSE
372 #define HAS_CHILD_PROCESS() FALSE
376 /* values for artwork type */
377 #define ARTWORK_TYPE_GRAPHICS 0
378 #define ARTWORK_TYPE_SOUNDS 1
379 #define ARTWORK_TYPE_MUSIC 2
381 #define NUM_ARTWORK_TYPES 3
384 /* values for tree type (chosen to match artwork type) */
385 #define TREE_TYPE_UNDEFINED -1
386 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
387 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
388 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
389 #define TREE_TYPE_LEVEL_DIR 3
391 #define NUM_TREE_TYPES 4
394 /* values for artwork handling */
395 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
396 ((type) == ARTWORK_TYPE_GRAPHICS ? \
397 &(leveldir)->graphics_set : \
398 (type) == ARTWORK_TYPE_SOUNDS ? \
399 &(leveldir)->sounds_set : \
400 &(leveldir)->music_set)
402 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
403 ((type) == ARTWORK_TYPE_GRAPHICS ? \
404 (leveldir)->graphics_set : \
405 (type) == ARTWORK_TYPE_SOUNDS ? \
406 (leveldir)->sounds_set : \
407 (leveldir)->music_set)
409 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
410 ((type) == ARTWORK_TYPE_GRAPHICS ? \
411 &(leveldir)->graphics_path : \
412 (type) == ARTWORK_TYPE_SOUNDS ? \
413 &(leveldir)->sounds_path : \
414 &(leveldir)->music_path)
416 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
417 ((type) == ARTWORK_TYPE_GRAPHICS ? \
418 (leveldir)->graphics_path : \
419 (type) == ARTWORK_TYPE_SOUNDS ? \
420 (leveldir)->sounds_path : \
421 (leveldir)->music_path)
423 #define SETUP_ARTWORK_SET(setup, type) \
424 ((type) == ARTWORK_TYPE_GRAPHICS ? \
425 (setup).graphics_set : \
426 (type) == ARTWORK_TYPE_SOUNDS ? \
427 (setup).sounds_set : \
430 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
431 ((type) == ARTWORK_TYPE_GRAPHICS ? \
432 (setup).override_level_graphics : \
433 (type) == ARTWORK_TYPE_SOUNDS ? \
434 (setup).override_level_sounds : \
435 (setup).override_level_music)
437 #define ARTWORK_FIRST_NODE(artwork, type) \
438 ((type) == ARTWORK_TYPE_GRAPHICS ? \
439 (artwork).gfx_first : \
440 (type) == ARTWORK_TYPE_SOUNDS ? \
441 (artwork).snd_first : \
444 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
445 ((type) == ARTWORK_TYPE_GRAPHICS ? \
446 &(artwork).gfx_current_identifier : \
447 (type) == ARTWORK_TYPE_SOUNDS ? \
448 &(artwork).snd_current_identifier : \
449 &(artwork).mus_current_identifier)
451 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
452 ((type) == ARTWORK_TYPE_GRAPHICS ? \
453 (artwork).gfx_current_identifier : \
454 (type) == ARTWORK_TYPE_SOUNDS ? \
455 (artwork).snd_current_identifier : \
456 (artwork).mus_current_identifier)
458 #define ARTWORKINFO_FILENAME(type) \
459 ((type) == ARTWORK_TYPE_GRAPHICS ? \
460 GRAPHICSINFO_FILENAME : \
461 (type) == ARTWORK_TYPE_SOUNDS ? \
462 SOUNDSINFO_FILENAME : \
463 (type) == ARTWORK_TYPE_MUSIC ? \
464 MUSICINFO_FILENAME : "")
466 #define ARTWORK_DIRECTORY(type) \
467 ((type) == ARTWORK_TYPE_GRAPHICS ? \
468 GRAPHICS_DIRECTORY : \
469 (type) == ARTWORK_TYPE_SOUNDS ? \
471 (type) == ARTWORK_TYPE_MUSIC ? \
472 MUSIC_DIRECTORY : "")
474 #define OPTIONS_ARTWORK_DIRECTORY(type) \
475 ((type) == ARTWORK_TYPE_GRAPHICS ? \
476 options.graphics_directory : \
477 (type) == ARTWORK_TYPE_SOUNDS ? \
478 options.sounds_directory : \
479 (type) == ARTWORK_TYPE_MUSIC ? \
480 options.music_directory : "")
483 /* type definitions */
484 typedef int (*EventFilter)(const Event *);
487 /* structure definitions */
491 char *command_basepath; /* directory that contains the program */
492 char *command_basename; /* base filename of the program binary */
493 char *userdata_directory; /* personal user data directory */
499 char *x11_icon_filename;
500 char *x11_iconmask_filename;
501 char *msdos_cursor_filename;
504 char *filename_prefix; /* prefix to cut off from DOS filenames */
510 void (*exit_function)(int);
519 char *ro_base_directory;
520 char *rw_base_directory;
521 char *level_directory;
522 char *graphics_directory;
523 char *sounds_directory;
524 char *music_directory;
525 char *docs_directory;
526 char *execute_command;
534 struct VideoSystemInfo
537 int width, height, depth;
538 boolean fullscreen_available;
539 boolean fullscreen_enabled;
542 struct AudioSystemInfo
544 boolean sound_available;
545 boolean loops_available;
546 boolean music_available;
548 boolean sound_enabled;
549 boolean sound_deactivated; /* for temporarily disabling sound */
558 int first_sound_channel;
561 struct FontBitmapInfo
564 int src_x, src_y; /* start position of animation frames */
565 int width, height; /* width/height of each animation frame */
566 int draw_x, draw_y; /* offset for drawing font characters */
568 int num_chars_per_line;
570 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
571 Pixmap *clip_mask; /* single-char-only clip mask array for X11 */
579 int real_sx, real_sy;
580 int full_sxsize, full_sysize;
581 int scrollbuffer_width, scrollbuffer_height;
589 int draw_deactivation_mask;
590 int draw_background_mask;
592 Bitmap *field_save_buffer;
594 Bitmap *background_bitmap;
595 int background_bitmap_mask;
598 struct FontBitmapInfo *font_bitmap_info;
599 int (*select_font_function)(int);
601 int anim_random_frame;
607 int fd[MAX_PLAYERS]; /* file descriptor of player's joystick */
610 struct SetupJoystickInfo
612 char *device_name; /* device name of player's joystick */
614 int xleft, xmiddle, xright;
615 int yupper, ymiddle, ylower;
619 struct SetupKeyboardInfo
621 Key left, right, up, down;
625 struct SetupInputInfo
627 boolean use_joystick;
628 struct SetupJoystickInfo joy;
629 struct SetupKeyboardInfo key;
632 struct SetupEditorInfo
634 boolean el_boulderdash;
635 boolean el_emerald_mine;
636 boolean el_emerald_mine_club;
640 boolean el_diamond_caves;
641 boolean el_dx_boulderdash;
644 boolean el_user_defined;
647 boolean el_headlines;
650 struct SetupEditorCascadeInfo
667 struct SetupShortcutInfo
673 Key focus_player[MAX_PLAYERS];
674 Key focus_player_all;
677 struct SetupSystemInfo
679 char *sdl_audiodriver;
680 int audio_fragment_size;
690 boolean sound_simple;
692 boolean double_buffering;
693 boolean direct_draw; /* !double_buffering (redundant!) */
694 boolean scroll_delay;
695 boolean soft_scrolling;
704 boolean ask_on_escape;
705 boolean ask_on_escape_editor;
706 boolean quick_switch;
711 boolean override_level_graphics;
712 boolean override_level_sounds;
713 boolean override_level_music;
715 struct SetupEditorInfo editor;
716 struct SetupEditorCascadeInfo editor_cascade;
717 struct SetupShortcutInfo shortcut;
718 struct SetupInputInfo input[MAX_PLAYERS];
719 struct SetupSystemInfo system;
720 struct OptionInfo options;
725 struct TreeInfo **node_top; /* topmost node in tree */
726 struct TreeInfo *node_parent; /* parent level directory info */
727 struct TreeInfo *node_group; /* level group sub-directory info */
728 struct TreeInfo *next; /* next level series structure node */
730 int cl_first; /* internal control field for setup screen */
731 int cl_cursor; /* internal control field for setup screen */
733 int type; /* type of tree content */
735 /* fields for "type == TREE_TYPE_LEVEL_DIR" */
737 char *subdir; /* tree info sub-directory basename (may be ".") */
738 char *fullpath; /* complete path relative to tree base directory */
739 char *basepath; /* absolute base path of tree base directory */
740 char *identifier; /* identifier string for configuration files */
741 char *name; /* tree info name, as displayed in selection menues */
742 char *name_sorting; /* optional sorting name for correct name sorting */
743 char *author; /* level or artwork author name */
744 char *imported_from; /* optional comment for imported levels or artwork */
745 char *imported_by; /* optional comment for imported levels or artwork */
747 char *graphics_set; /* optional custom graphics set (level tree only) */
748 char *sounds_set; /* optional custom sounds set (level tree only) */
749 char *music_set; /* optional custom music set (level tree only) */
750 char *graphics_path; /* path to optional custom graphics set (level only) */
751 char *sounds_path; /* path to optional custom sounds set (level only) */
752 char *music_path; /* path to optional custom music set (level only) */
754 char *level_filename; /* filename of level file (for packed level file) */
755 char *level_filetype; /* type of levels in level directory or level file */
757 int levels; /* number of levels in level series */
758 int first_level; /* first level number (to allow start with 0 or 1) */
759 int last_level; /* last level number (automatically calculated) */
760 int sort_priority; /* sort levels by 'sort_priority' and then by name */
762 boolean latest_engine;/* force level set to use the latest game engine */
764 boolean level_group; /* directory contains more level series directories */
765 boolean parent_link; /* entry links back to parent directory */
766 boolean in_user_dir; /* user defined levels are stored in home directory */
767 boolean user_defined; /* levels in user directory and marked as "private" */
768 boolean readonly; /* readonly levels can not be changed with editor */
769 boolean handicap; /* level set has no handicap when set to "false" */
770 boolean skip_levels; /* levels can be skipped when set to "true" */
772 int color; /* color to use on selection screen for this level */
773 char *class_desc; /* description of level series class */
774 int handicap_level; /* number of the lowest unsolved level */
777 typedef struct TreeInfo TreeInfo;
778 typedef struct TreeInfo LevelDirTree;
779 typedef struct TreeInfo ArtworkDirTree;
780 typedef struct TreeInfo GraphicsDirTree;
781 typedef struct TreeInfo SoundsDirTree;
782 typedef struct TreeInfo MusicDirTree;
786 GraphicsDirTree *gfx_first;
787 GraphicsDirTree *gfx_current;
788 SoundsDirTree *snd_first;
789 SoundsDirTree *snd_current;
790 MusicDirTree *mus_first;
791 MusicDirTree *mus_current;
793 char *gfx_current_identifier;
794 char *snd_current_identifier;
795 char *mus_current_identifier;
810 struct ConfigTypeInfo
817 struct TokenIntPtrInfo
827 char *default_filename;
830 char **default_parameter; /* array of file parameters */
831 char **parameter; /* array of file parameters */
834 boolean fallback_to_default;
842 struct SetupFileList *next;
847 char *source_filename; /* primary key for node list */
851 struct PropertyMapping
861 struct ArtworkListInfo
863 int type; /* type of artwork */
865 int num_file_list_entries;
866 int num_dynamic_file_list_entries;
867 struct FileInfo *file_list; /* static artwork file array */
868 struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */
870 int num_suffix_list_entries;
871 struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */
873 int num_base_prefixes;
874 int num_ext1_suffixes;
875 int num_ext2_suffixes;
876 int num_ext3_suffixes;
877 char **base_prefixes; /* base token prefixes array */
878 char **ext1_suffixes; /* property suffixes array 1 */
879 char **ext2_suffixes; /* property suffixes array 2 */
880 char **ext3_suffixes; /* property suffixes array 3 */
882 int num_ignore_tokens;
883 char **ignore_tokens; /* file tokens to be ignored */
885 int num_property_mapping_entries;
886 struct PropertyMapping *property_mapping; /* mapping token -> artwork */
888 int sizeof_artwork_list_entry;
890 struct ListNodeInfo **artwork_list; /* static artwork node array */
891 struct ListNodeInfo **dynamic_artwork_list; /* dynamic artwrk node array */
892 struct ListNode *content_list; /* dynamic artwork node list */
894 void *(*load_artwork)(char *); /* constructor function */
895 void (*free_artwork)(void *); /* destructor function */
899 /* ========================================================================= */
900 /* exported variables */
901 /* ========================================================================= */
903 extern struct ProgramInfo program;
904 extern struct OptionInfo options;
905 extern struct VideoSystemInfo video;
906 extern struct AudioSystemInfo audio;
907 extern struct GfxInfo gfx;
908 extern struct AnimInfo anim;
909 extern struct ArtworkInfo artwork;
910 extern struct JoystickInfo joystick;
911 extern struct SetupInfo setup;
913 extern LevelDirTree *leveldir_first_all;
914 extern LevelDirTree *leveldir_first;
915 extern LevelDirTree *leveldir_current;
918 extern Display *display;
919 extern Visual *visual;
921 extern Colormap cmap;
923 extern DrawWindow *window;
924 extern DrawBuffer *backbuffer;
925 extern DrawBuffer *drawto;
927 extern int button_status;
928 extern boolean motion_status;
930 extern int redraw_mask;
931 extern int redraw_tiles;
933 extern int FrameCounter;
936 /* function definitions */
938 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
939 char *, char *, char *, int);
941 void InitExitFunction(void (*exit_function)(int));
942 void InitPlatformDependentStuff(void);
943 void ClosePlatformDependentStuff(void);
945 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
946 void InitGfxDoor1Info(int, int, int, int);
947 void InitGfxDoor2Info(int, int, int, int);
948 void InitGfxScrollbufferInfo(int, int);
949 void SetDrawDeactivationMask(int);
950 void SetDrawBackgroundMask(int);
951 void SetMainBackgroundBitmap(Bitmap *);
952 void SetDoorBackgroundBitmap(Bitmap *);
954 inline void InitVideoDisplay(void);
955 inline void CloseVideoDisplay(void);
956 inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
957 inline Bitmap *CreateBitmapStruct(void);
958 inline Bitmap *CreateBitmap(int, int, int);
959 inline void FreeBitmap(Bitmap *);
960 inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
961 inline void FillRectangle(Bitmap *, int, int, int, int, Pixel);
962 inline void ClearRectangle(Bitmap *, int, int, int, int);
963 inline void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
964 inline void SetClipMask(Bitmap *, GC, Pixmap);
965 inline void SetClipOrigin(Bitmap *, GC, int, int);
966 inline void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
967 inline boolean DrawingOnBackground(int, int);
968 inline void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int,
970 inline void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
971 inline void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
972 inline void DrawLines(Bitmap *, struct XY *, int, Pixel);
973 inline Pixel GetPixel(Bitmap *, int, int);
974 inline Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
975 inline Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
977 inline void FlushDisplay(void);
978 inline void SyncDisplay(void);
979 inline void KeyboardAutoRepeatOn(void);
980 inline void KeyboardAutoRepeatOff(void);
981 inline boolean PointerInWindow(DrawWindow *);
982 inline boolean SetVideoMode(boolean);
983 inline boolean ChangeVideoModeIfNeeded(boolean);
985 Bitmap *LoadImage(char *);
986 Bitmap *LoadCustomImage(char *);
987 void ReloadCustomImage(Bitmap *, char *);
989 Bitmap *ZoomBitmap(Bitmap *, int, int);
990 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
992 void SetMouseCursor(int);
994 inline void OpenAudio(void);
995 inline void CloseAudio(void);
996 inline void SetAudioMode(boolean);
998 inline void InitEventFilter(EventFilter);
999 inline boolean PendingEvent(void);
1000 inline void NextEvent(Event *event);
1001 inline void PeekEvent(Event *event);
1002 inline Key GetEventKey(KeyEvent *, boolean);
1003 inline KeyMod HandleKeyModState(Key, int);
1004 inline KeyMod GetKeyModState();
1005 inline boolean CheckCloseWindowEvent(ClientMessageEvent *);
1007 inline void InitJoysticks();
1008 inline boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1010 #endif /* SYSTEM_H */