rnd-20050627-1-src
[rocksndiamonds.git] / src / libgame / system.h
1 /***********************************************************
2 * Artsoft Retro-Game Library                               *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * system.h                                                 *
12 ***********************************************************/
13
14 #ifndef SYSTEM_H
15 #define SYSTEM_H
16
17 #include "platform.h"
18 #include "types.h"
19
20
21 #if defined(PLATFORM_MACOSX)
22 #include "macosx.h"
23 #elif defined(PLATFORM_WIN32)
24 #include "windows.h"
25 #elif defined(PLATFORM_MSDOS)
26 #include "msdos.h"
27 #endif
28
29 #if defined(TARGET_SDL)
30 #include "sdl.h"
31 #elif defined(TARGET_X11)
32 #include "x11.h"
33 #endif
34
35
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"
40
41 #define DEFAULT_DEPTH           0
42
43 #define BLIT_OPAQUE             0
44 #define BLIT_MASKED             1
45 #define BLIT_INVERSE            2
46 #define BLIT_ON_BACKGROUND      3
47
48 #define FULLSCREEN_NOT_AVAILABLE FALSE
49 #define FULLSCREEN_AVAILABLE     TRUE
50
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
59 #else
60 #define DEFAULT_KEY_SNAP        KSYM_Control_L
61 #define DEFAULT_KEY_DROP        KSYM_Control_R
62 #endif
63 #define DEFAULT_KEY_OKAY        KSYM_Return
64 #define DEFAULT_KEY_CANCEL      KSYM_Escape
65
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
71 /* values for key_status */
72 #define KEY_NOT_PRESSED         FALSE
73 #define KEY_RELEASED            FALSE
74 #define KEY_PRESSED             TRUE
75
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
88
89
90 /* values for move directions */
91 #define MV_BIT_LEFT             0
92 #define MV_BIT_RIGHT            1
93 #define MV_BIT_UP               2
94 #define MV_BIT_DOWN             3
95
96 #define NUM_DIRECTIONS          4
97
98 /* values for special "button" bitmasks */
99 #define BUTTON_1                4
100 #define BUTTON_2                5
101
102 /* values for move directions and special "button" key bitmasks */
103 #define MV_NO_MOVING            0
104 #define MV_LEFT                 (1 << MV_BIT_LEFT)
105 #define MV_RIGHT                (1 << MV_BIT_RIGHT)
106 #define MV_UP                   (1 << MV_BIT_UP)
107 #define MV_DOWN                 (1 << MV_BIT_DOWN)
108
109 #define MV_HORIZONTAL           (MV_LEFT | MV_RIGHT)
110 #define MV_VERTICAL             (MV_UP   | MV_DOWN)
111 #define MV_ALL_DIRECTIONS       (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
112 #define MV_ANY_DIRECTION        (MV_ALL_DIRECTIONS)
113 #define MV_NO_DIRECTIONS        (MV_NO_MOVING)
114
115 #define KEY_BUTTON_1            (1 << BUTTON_1)
116 #define KEY_BUTTON_2            (1 << BUTTON_2)
117 #define KEY_MOTION              (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
118 #define KEY_BUTTON              (KEY_BUTTON_1 | KEY_BUTTON_2)
119 #define KEY_ACTION              (KEY_MOTION | KEY_BUTTON)
120
121 #define MV_DIR_BIT(x)           ((x) == MV_LEFT  ? MV_BIT_LEFT  :       \
122                                  (x) == MV_RIGHT ? MV_BIT_RIGHT :       \
123                                  (x) == MV_UP    ? MV_BIT_UP    : MV_BIT_DOWN)
124
125 #define MV_DIR_OPPOSITE(x)      ((x) == MV_LEFT  ? MV_RIGHT :           \
126                                  (x) == MV_RIGHT ? MV_LEFT  :           \
127                                  (x) == MV_UP    ? MV_DOWN  :           \
128                                  (x) == MV_DOWN  ? MV_UP    : MV_NO_MOVING)
129
130
131 /* values for animation mode (frame order and direction) */
132 #define ANIM_NONE               0
133 #define ANIM_LOOP               (1 << 0)
134 #define ANIM_LINEAR             (1 << 1)
135 #define ANIM_PINGPONG           (1 << 2)
136 #define ANIM_PINGPONG2          (1 << 3)
137 #define ANIM_RANDOM             (1 << 4)
138 #define ANIM_REVERSE            (1 << 5)
139
140 /* values for special (non game element) animation modes */
141 #define ANIM_HORIZONTAL         (1 << 6)
142 #define ANIM_VERTICAL           (1 << 7)
143
144 #define ANIM_DEFAULT            ANIM_LOOP
145
146 /* values for redraw_mask */
147 #define REDRAW_NONE             (0)
148 #define REDRAW_ALL              (1 << 0)
149 #define REDRAW_FIELD            (1 << 1)
150 #define REDRAW_TILES            (1 << 2)
151 #define REDRAW_DOOR_1           (1 << 3)
152 #define REDRAW_VIDEO_1          (1 << 4)
153 #define REDRAW_VIDEO_2          (1 << 5)
154 #define REDRAW_VIDEO_3          (1 << 6)
155 #define REDRAW_MICROLEVEL       (1 << 7)
156 #define REDRAW_MICROLABEL       (1 << 8)
157 #define REDRAW_FROM_BACKBUFFER  (1 << 9)
158 #define REDRAW_DOOR_2           (REDRAW_VIDEO_1 | \
159                                  REDRAW_VIDEO_2 | \
160                                  REDRAW_VIDEO_3)
161 #define REDRAW_DOOR_3           (1 << 10)
162 #define REDRAW_DOORS            (REDRAW_DOOR_1 | \
163                                  REDRAW_DOOR_2 | \
164                                  REDRAW_DOOR_3)
165 #define REDRAW_MAIN             (REDRAW_FIELD | \
166                                  REDRAW_TILES | \
167                                  REDRAW_MICROLEVEL)
168 #define REDRAW_FPS              (1 << 11)
169 #define REDRAWTILES_THRESHOLD   (SCR_FIELDX * SCR_FIELDY / 2)
170
171 #define IN_GFX_SCREEN(x, y)     (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
172                                  y >= gfx.sy && y < gfx.sy + gfx.sysize)
173 #define IN_GFX_DOOR(x, y)       (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
174                                  y >= gfx.dy && y < gfx.dy + gfx.dysize)
175 #define IN_GFX_VIDEO(x, y)      (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
176                                  y >= gfx.vy && y < gfx.vy + gfx.vysize)
177
178 /* values for mouse cursor */
179 #define CURSOR_DEFAULT          0
180 #define CURSOR_PLAYFIELD        1
181
182
183 /* maximum number of parallel players supported by libgame functions */
184 #define MAX_PLAYERS             4
185
186 /* maximum allowed length of player name */
187 #define MAX_PLAYER_NAME_LEN     10
188
189 /* default name for empty highscore entry */
190 #define EMPTY_PLAYER_NAME       "no name"
191
192 /* default name for unknown player names */
193 #define ANONYMOUS_NAME          "anonymous"
194
195 /* default for other unknown names */
196 #define UNKNOWN_NAME            "unknown"
197
198 /* default name for new levels */
199 #define NAMELESS_LEVEL_NAME     "nameless level"
200
201 /* default text for non-existant artwork */
202 #define NOT_AVAILABLE           "(not available)"
203
204 /* default value for undefined filename */
205 #define UNDEFINED_FILENAME      "[NONE]"
206
207 /* default value for undefined parameter */
208 #define ARG_DEFAULT             "[DEFAULT]"
209
210 /* default values for undefined configuration file parameters */
211 #define ARG_UNDEFINED           "-1000000"
212 #define ARG_UNDEFINED_VALUE     (atoi(ARG_UNDEFINED))
213
214 /* definitions for game sub-directories */
215 #ifndef RO_GAME_DIR
216 #define RO_GAME_DIR             "."
217 #endif
218
219 #ifndef RW_GAME_DIR
220 #define RW_GAME_DIR             "."
221 #endif
222
223 #define RO_BASE_PATH            RO_GAME_DIR
224 #define RW_BASE_PATH            RW_GAME_DIR
225
226 /* directory names */
227 #define GRAPHICS_DIRECTORY      "graphics"
228 #define SOUNDS_DIRECTORY        "sounds"
229 #define MUSIC_DIRECTORY         "music"
230 #define LEVELS_DIRECTORY        "levels"
231 #define TAPES_DIRECTORY         "tapes"
232 #define SCORES_DIRECTORY        "scores"
233 #define DOCS_DIRECTORY          "docs"
234
235 #if !defined(PLATFORM_MSDOS)
236 #define GFX_CLASSIC_SUBDIR      "gfx_classic"
237 #define SND_CLASSIC_SUBDIR      "snd_classic"
238 #define MUS_CLASSIC_SUBDIR      "mus_classic"
239 #else
240 #define GFX_CLASSIC_SUBDIR      "gfx_orig"
241 #define SND_CLASSIC_SUBDIR      "snd_orig"
242 #define MUS_CLASSIC_SUBDIR      "mus_orig"
243 #endif
244
245 /* file names and filename extensions */
246 #if !defined(PLATFORM_MSDOS)
247 #define LEVELSETUP_DIRECTORY    "levelsetup"
248 #define SETUP_FILENAME          "setup.conf"
249 #define LEVELSETUP_FILENAME     "levelsetup.conf"
250 #define EDITORSETUP_FILENAME    "editorsetup.conf"
251 #define HELPANIM_FILENAME       "helpanim.conf"
252 #define HELPTEXT_FILENAME       "helptext.conf"
253 #define LEVELINFO_FILENAME      "levelinfo.conf"
254 #define GRAPHICSINFO_FILENAME   "graphicsinfo.conf"
255 #define SOUNDSINFO_FILENAME     "soundsinfo.conf"
256 #define MUSICINFO_FILENAME      "musicinfo.conf"
257 #define LEVELFILE_EXTENSION     "level"
258 #define TAPEFILE_EXTENSION      "tape"
259 #define SCOREFILE_EXTENSION     "score"
260 #else
261 #define LEVELSETUP_DIRECTORY    "lvlsetup"
262 #define SETUP_FILENAME          "setup.cnf"
263 #define LEVELSETUP_FILENAME     "lvlsetup.cnf"
264 #define EDITORSETUP_FILENAME    "edsetup.cnf"
265 #define HELPANIM_FILENAME       "helpanim.cnf"
266 #define HELPTEXT_FILENAME       "helptext.cnf"
267 #define LEVELINFO_FILENAME      "lvlinfo.cnf"
268 #define GRAPHICSINFO_FILENAME   "gfxinfo.cnf"
269 #define SOUNDSINFO_FILENAME     "sndinfo.cnf"
270 #define MUSICINFO_FILENAME      "musinfo.cnf"
271 #define LEVELFILE_EXTENSION     "lvl"
272 #define TAPEFILE_EXTENSION      "tap"
273 #define SCOREFILE_EXTENSION     "sco"
274 #endif
275
276
277 /* areas in bitmap PIX_DOOR */
278 /* meaning in PIX_DB_DOOR: (3 PAGEs)
279    PAGEX1: 1. buffer for DOOR_1
280    PAGEX2: 2. buffer for DOOR_1
281    PAGEX3: buffer for animations
282 */
283
284 /* these values are hard-coded to be able to use them in initialization */
285 #define DOOR_GFX_PAGE_WIDTH     100     /* should be set to "gfx.dxsize" */
286 #define DOOR_GFX_PAGE_HEIGHT    280     /* should be set to "gfx.dysize" */
287
288 #define DOOR_GFX_PAGESIZE       (DOOR_GFX_PAGE_WIDTH)
289 #define DOOR_GFX_PAGEX1         (0 * DOOR_GFX_PAGESIZE)
290 #define DOOR_GFX_PAGEX2         (1 * DOOR_GFX_PAGESIZE)
291 #define DOOR_GFX_PAGEX3         (2 * DOOR_GFX_PAGESIZE)
292 #define DOOR_GFX_PAGEX4         (3 * DOOR_GFX_PAGESIZE)
293 #define DOOR_GFX_PAGEX5         (4 * DOOR_GFX_PAGESIZE)
294 #define DOOR_GFX_PAGEX6         (5 * DOOR_GFX_PAGESIZE)
295 #define DOOR_GFX_PAGEX7         (6 * DOOR_GFX_PAGESIZE)
296 #define DOOR_GFX_PAGEX8         (7 * DOOR_GFX_PAGESIZE)
297 #define DOOR_GFX_PAGEY1         (0)
298 #define DOOR_GFX_PAGEY2         (DOOR_GFX_PAGE_HEIGHT)
299
300
301 /* macros for version handling */
302 #define VERSION_MAJOR(x)        ((x) / 1000000)
303 #define VERSION_MINOR(x)        (((x) % 1000000) / 10000)
304 #define VERSION_PATCH(x)        (((x) % 10000) / 100)
305 #define VERSION_BUILD(x)        ((x) % 100)
306 #define VERSION_IDENT(a,b,c,d)  ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
307
308
309 /* macros for parent/child process identification */
310 #if defined(PLATFORM_UNIX)
311 #define IS_PARENT_PROCESS()     (audio.mixer_pid != getpid())
312 #define IS_CHILD_PROCESS()      (audio.mixer_pid == getpid())
313 #define HAS_CHILD_PROCESS()     (audio.mixer_pid > 0)
314 #else
315 #define IS_PARENT_PROCESS()     TRUE
316 #define IS_CHILD_PROCESS()      FALSE
317 #define HAS_CHILD_PROCESS()     FALSE
318 #endif
319
320
321 /* values for artwork type */
322 #define ARTWORK_TYPE_GRAPHICS   0
323 #define ARTWORK_TYPE_SOUNDS     1
324 #define ARTWORK_TYPE_MUSIC      2
325
326 #define NUM_ARTWORK_TYPES       3
327
328
329 /* values for tree type (chosen to match artwork type) */
330 #define TREE_TYPE_UNDEFINED     -1
331 #define TREE_TYPE_GRAPHICS_DIR  ARTWORK_TYPE_GRAPHICS
332 #define TREE_TYPE_SOUNDS_DIR    ARTWORK_TYPE_SOUNDS
333 #define TREE_TYPE_MUSIC_DIR     ARTWORK_TYPE_MUSIC
334 #define TREE_TYPE_LEVEL_DIR     3
335
336 #define NUM_TREE_TYPES          4
337
338
339 /* values for artwork handling */
340 #define LEVELDIR_ARTWORK_SET(leveldir, type)                            \
341                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
342                                  (leveldir)->graphics_set :             \
343                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
344                                  (leveldir)->sounds_set :               \
345                                  (leveldir)->music_set)
346
347 #define LEVELDIR_ARTWORK_PATH(leveldir, type)                           \
348                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
349                                  (leveldir)->graphics_path :            \
350                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
351                                  (leveldir)->sounds_path :              \
352                                  (leveldir)->music_path)
353
354 #define SETUP_ARTWORK_SET(setup, type)                                  \
355                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
356                                  (setup).graphics_set :                 \
357                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
358                                  (setup).sounds_set :                   \
359                                  (setup).music_set)
360
361 #define SETUP_OVERRIDE_ARTWORK(setup, type)                             \
362                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
363                                  (setup).override_level_graphics :      \
364                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
365                                  (setup).override_level_sounds :        \
366                                  (setup).override_level_music)
367
368 #define ARTWORK_FIRST_NODE(artwork, type)                               \
369                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
370                                  (artwork).gfx_first :  \
371                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
372                                  (artwork).snd_first :  \
373                                  (artwork).mus_first)
374
375 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type)                       \
376                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
377                                  (artwork).gfx_current_identifier :     \
378                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
379                                  (artwork).snd_current_identifier :     \
380                                  (artwork).mus_current_identifier)
381
382 #define ARTWORKINFO_FILENAME(type)                                      \
383                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
384                                  GRAPHICSINFO_FILENAME :                \
385                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
386                                  SOUNDSINFO_FILENAME :                  \
387                                  (type) == ARTWORK_TYPE_MUSIC ?         \
388                                  MUSICINFO_FILENAME : "")
389
390 #define ARTWORK_DIRECTORY(type)                                         \
391                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
392                                  GRAPHICS_DIRECTORY :                   \
393                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
394                                  SOUNDS_DIRECTORY :                     \
395                                  (type) == ARTWORK_TYPE_MUSIC ?         \
396                                  MUSIC_DIRECTORY : "")
397
398 #define OPTIONS_ARTWORK_DIRECTORY(type)                                 \
399                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
400                                  options.graphics_directory :           \
401                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
402                                  options.sounds_directory :             \
403                                  (type) == ARTWORK_TYPE_MUSIC ?         \
404                                  options.music_directory : "")
405
406
407 /* type definitions */
408 typedef int (*EventFilter)(const Event *);
409
410
411 /* structure definitions */
412
413 struct ProgramInfo
414 {
415   char *command_basepath;       /* directory that contains the program */
416   char *command_basename;       /* base filename of the program binary */
417   char *userdata_directory;     /* personal user data directory */
418
419   char *program_title;
420   char *window_title;
421   char *icon_title;
422
423   char *x11_icon_filename;
424   char *x11_iconmask_filename;
425   char *msdos_cursor_filename;
426
427   char *cookie_prefix;
428   char *filename_prefix;        /* prefix to cut off from DOS filenames */
429
430   int version_major;
431   int version_minor;
432   int version_patch;
433
434   void (*exit_function)(int);
435 };
436
437 struct OptionInfo
438 {
439   char *display_name;
440   char *server_host;
441   int server_port;
442
443   char *ro_base_directory;
444   char *rw_base_directory;
445   char *level_directory;
446   char *graphics_directory;
447   char *sounds_directory;
448   char *music_directory;
449   char *docs_directory;
450   char *execute_command;
451
452   boolean serveronly;
453   boolean network;
454   boolean verbose;
455   boolean debug;
456 };
457
458 struct VideoSystemInfo
459 {
460   int default_depth;
461   int width, height, depth;
462   boolean fullscreen_available;
463   boolean fullscreen_enabled;
464 };
465
466 struct AudioSystemInfo
467 {
468   boolean sound_available;
469   boolean loops_available;
470   boolean music_available;
471
472   boolean sound_enabled;
473   boolean sound_deactivated;    /* for temporarily disabling sound */
474
475   int mixer_pipe[2];
476   int mixer_pid;
477   char *device_name;
478   int device_fd;
479
480   int num_channels;
481   int music_channel;
482   int first_sound_channel;
483 };
484
485 struct FontBitmapInfo
486 {
487   Bitmap *bitmap;
488   int src_x, src_y;             /* start position of animation frames */
489   int width, height;            /* width/height of each animation frame */
490   int draw_x, draw_y;           /* offset for drawing font characters */
491   int num_chars;
492   int num_chars_per_line;
493
494 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
495   Pixmap *clip_mask;            /* single-char-only clip mask array for X11 */
496 #endif
497 };
498
499 struct GfxInfo
500 {
501   int sx, sy;
502   int sxsize, sysize;
503   int real_sx, real_sy;
504   int full_sxsize, full_sysize;
505   int scrollbuffer_width, scrollbuffer_height;
506
507   int dx, dy;
508   int dxsize, dysize;
509
510   int vx, vy;
511   int vxsize, vysize;
512
513   int draw_deactivation_mask;
514   int draw_background_mask;
515
516   Bitmap *field_save_buffer;
517
518   Bitmap *background_bitmap;
519   int background_bitmap_mask;
520
521   int num_fonts;
522   struct FontBitmapInfo *font_bitmap_info;
523   int (*select_font_function)(int);
524
525   int anim_random_frame;
526 };
527
528 struct JoystickInfo
529 {
530   int status;
531   int fd[MAX_PLAYERS];          /* file descriptor of player's joystick */
532 };
533
534 struct SetupJoystickInfo
535 {
536   char *device_name;            /* device name of player's joystick */
537
538   int xleft, xmiddle, xright;
539   int yupper, ymiddle, ylower;
540   int snap, drop;
541 };
542
543 struct SetupKeyboardInfo
544 {
545   Key left, right, up, down;
546   Key snap, drop;
547 };
548
549 struct SetupInputInfo
550 {
551   boolean use_joystick;
552   struct SetupJoystickInfo joy;
553   struct SetupKeyboardInfo key;
554 };
555
556 struct SetupEditorInfo
557 {
558   boolean el_boulderdash;
559   boolean el_emerald_mine;
560   boolean el_emerald_mine_club;
561   boolean el_more;
562   boolean el_sokoban;
563   boolean el_supaplex;
564   boolean el_diamond_caves;
565   boolean el_dx_boulderdash;
566   boolean el_chars;
567   boolean el_custom;
568   boolean el_custom_more;
569   boolean el_user_defined;
570
571   boolean el_headlines;
572 };
573
574 struct SetupShortcutInfo
575 {
576   Key save_game;
577   Key load_game;
578   Key toggle_pause;
579 };
580
581 struct SetupSystemInfo
582 {
583   char *sdl_audiodriver;
584   int audio_fragment_size;
585 };
586
587 struct SetupInfo
588 {
589   char *player_name;
590
591   boolean sound;
592   boolean sound_loops;
593   boolean sound_music;
594   boolean sound_simple;
595   boolean toons;
596   boolean double_buffering;
597   boolean direct_draw;          /* !double_buffering (redundant!) */
598   boolean scroll_delay;
599   boolean soft_scrolling;
600   boolean fading;
601   boolean autorecord;
602   boolean quick_doors;
603   boolean team_mode;
604   boolean handicap;
605   boolean skip_levels;
606   boolean time_limit;
607   boolean fullscreen;
608   boolean ask_on_escape;
609
610   char *graphics_set;
611   char *sounds_set;
612   char *music_set;
613   boolean override_level_graphics;
614   boolean override_level_sounds;
615   boolean override_level_music;
616
617   struct SetupEditorInfo editor;
618   struct SetupShortcutInfo shortcut;
619   struct SetupInputInfo input[MAX_PLAYERS];
620   struct SetupSystemInfo system;
621   struct OptionInfo options;
622 };
623
624 struct TreeInfo
625 {
626   struct TreeInfo **node_top;           /* topmost node in tree */
627   struct TreeInfo *node_parent;         /* parent level directory info */
628   struct TreeInfo *node_group;          /* level group sub-directory info */
629   struct TreeInfo *next;                /* next level series structure node */
630
631   int cl_first;         /* internal control field for setup screen */
632   int cl_cursor;        /* internal control field for setup screen */
633
634   int type;             /* type of tree content */
635
636   /* fields for "type == TREE_TYPE_LEVEL_DIR" */
637
638   char *subdir;         /* tree info sub-directory basename (may be ".") */
639   char *fullpath;       /* complete path relative to tree base directory */
640   char *basepath;       /* absolute base path of tree base directory */
641   char *identifier;     /* identifier string for configuration files */
642   char *name;           /* tree info name, as displayed in selection menues */
643   char *name_sorting;   /* optional sorting name for correct name sorting */
644   char *author;         /* level or artwork author name */
645   char *imported_from;  /* optional comment for imported levels or artwork */
646   char *imported_by;    /* optional comment for imported levels or artwork */
647
648   char *graphics_set;   /* optional custom graphics set (level tree only) */
649   char *sounds_set;     /* optional custom sounds set (level tree only) */
650   char *music_set;      /* optional custom music set (level tree only) */
651   char *graphics_path;  /* path to optional custom graphics set (level only) */
652   char *sounds_path;    /* path to optional custom sounds set (level only) */
653   char *music_path;     /* path to optional custom music set (level only) */
654
655   char *level_filename; /* filename of level file (for packed level file) */
656   char *level_filetype; /* type of levels in level directory or level file */
657
658   int levels;           /* number of levels in level series */
659   int first_level;      /* first level number (to allow start with 0 or 1) */
660   int last_level;       /* last level number (automatically calculated) */
661   int sort_priority;    /* sort levels by 'sort_priority' and then by name */
662
663   boolean latest_engine;/* force level set to use the latest game engine */
664
665   boolean level_group;  /* directory contains more level series directories */
666   boolean parent_link;  /* entry links back to parent directory */
667   boolean in_user_dir;  /* user defined levels are stored in home directory */
668   boolean user_defined; /* levels in user directory and marked as "private" */
669   boolean readonly;     /* readonly levels can not be changed with editor */
670   boolean handicap;     /* level set has no handicap when set to "false" */
671   boolean skip_levels;  /* levels can be skipped when set to "true" */
672
673   int color;            /* color to use on selection screen for this level */
674   char *class_desc;     /* description of level series class */
675   int handicap_level;   /* number of the lowest unsolved level */
676 };
677
678 typedef struct TreeInfo TreeInfo;
679 typedef struct TreeInfo LevelDirTree;
680 typedef struct TreeInfo ArtworkDirTree;
681 typedef struct TreeInfo GraphicsDirTree;
682 typedef struct TreeInfo SoundsDirTree;
683 typedef struct TreeInfo MusicDirTree;
684
685 struct ArtworkInfo
686 {
687   GraphicsDirTree *gfx_first;
688   GraphicsDirTree *gfx_current;
689   SoundsDirTree *snd_first;
690   SoundsDirTree *snd_current;
691   MusicDirTree *mus_first;
692   MusicDirTree *mus_current;
693
694   char *gfx_current_identifier;
695   char *snd_current_identifier;
696   char *mus_current_identifier;
697 };
698
699 struct ValueTextInfo
700 {
701   int value;
702   char *text;
703 };
704
705 struct ConfigInfo
706 {
707   char *token;
708   char *value;
709 };
710
711 struct ConfigTypeInfo
712 {
713   char *token;
714   char *value;
715   int type;
716 };
717
718 struct TokenIntPtrInfo
719 {
720   char *token;
721   int *value;
722 };
723
724 struct FileInfo
725 {
726   char *token;
727
728   char *default_filename;
729   char *filename;
730
731   char **default_parameter;                     /* array of file parameters */
732   char **parameter;                             /* array of file parameters */
733
734   boolean redefined;
735   boolean fallback_to_default;
736 };
737
738 struct SetupFileList
739 {
740   char *token;
741   char *value;
742
743   struct SetupFileList *next;
744 };
745
746 struct ListNodeInfo
747 {
748   char *source_filename;                        /* primary key for node list */
749   int num_references;
750 };
751
752 struct PropertyMapping
753 {
754   int base_index;
755   int ext1_index;
756   int ext2_index;
757   int ext3_index;
758
759   int artwork_index;
760 };
761
762 struct ArtworkListInfo
763 {
764   int type;                                     /* type of artwork */
765
766   int num_file_list_entries;
767   int num_dynamic_file_list_entries;
768   struct FileInfo *file_list;                   /* static artwork file array */
769   struct FileInfo *dynamic_file_list;           /* dynamic artwrk file array */
770
771   int num_suffix_list_entries;
772   struct ConfigTypeInfo *suffix_list;           /* parameter suffixes array */
773
774   int num_base_prefixes;
775   int num_ext1_suffixes;
776   int num_ext2_suffixes;
777   int num_ext3_suffixes;
778   char **base_prefixes;                         /* base token prefixes array */
779   char **ext1_suffixes;                         /* property suffixes array 1 */
780   char **ext2_suffixes;                         /* property suffixes array 2 */
781   char **ext3_suffixes;                         /* property suffixes array 3 */
782
783   int num_ignore_tokens;
784   char **ignore_tokens;                         /* file tokens to be ignored */
785
786   int num_property_mapping_entries;
787   struct PropertyMapping *property_mapping;     /* mapping token -> artwork */
788
789   int sizeof_artwork_list_entry;
790
791   struct ListNodeInfo **artwork_list;           /* static artwork node array */
792   struct ListNodeInfo **dynamic_artwork_list;   /* dynamic artwrk node array */
793   struct ListNode *content_list;                /* dynamic artwork node list */
794
795   void *(*load_artwork)(char *);                /* constructor function */
796   void (*free_artwork)(void *);                 /* destructor function */
797 };
798
799
800 /* ========================================================================= */
801 /* exported variables                                                        */
802 /* ========================================================================= */
803
804 extern struct ProgramInfo       program;
805 extern struct OptionInfo        options;
806 extern struct VideoSystemInfo   video;
807 extern struct AudioSystemInfo   audio;
808 extern struct GfxInfo           gfx;
809 extern struct AnimInfo          anim;
810 extern struct ArtworkInfo       artwork;
811 extern struct JoystickInfo      joystick;
812 extern struct SetupInfo         setup;
813
814 extern LevelDirTree            *leveldir_first;
815 extern LevelDirTree            *leveldir_current;
816 extern int                      level_nr;
817
818 extern Display                 *display;
819 extern Visual                  *visual;
820 extern int                      screen;
821 extern Colormap                 cmap;
822
823 extern DrawWindow              *window;
824 extern DrawBuffer              *backbuffer;
825 extern DrawBuffer              *drawto;
826
827 extern int                      button_status;
828 extern boolean                  motion_status;
829
830 extern int                      redraw_mask;
831 extern int                      redraw_tiles;
832
833 extern int                      FrameCounter;
834
835
836 /* function definitions */
837
838 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
839                      char *, char *, char *, int);
840
841 void InitExitFunction(void (*exit_function)(int));
842 void InitPlatformDependentStuff(void);
843 void ClosePlatformDependentStuff(void);
844
845 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
846 void InitGfxDoor1Info(int, int, int, int);
847 void InitGfxDoor2Info(int, int, int, int);
848 void InitGfxScrollbufferInfo(int, int);
849 void SetDrawDeactivationMask(int);
850 void SetDrawBackgroundMask(int);
851 void SetMainBackgroundBitmap(Bitmap *);
852 void SetDoorBackgroundBitmap(Bitmap *);
853
854 inline void InitVideoDisplay(void);
855 inline void CloseVideoDisplay(void);
856 inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean);
857 inline Bitmap *CreateBitmapStruct(void);
858 inline Bitmap *CreateBitmap(int, int, int);
859 inline void FreeBitmap(Bitmap *);
860 inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
861 inline void FillRectangle(Bitmap *, int, int, int, int, Pixel);
862 inline void ClearRectangle(Bitmap *, int, int, int, int);
863 inline void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
864 inline void SetClipMask(Bitmap *, GC, Pixmap);
865 inline void SetClipOrigin(Bitmap *, GC, int, int);
866 inline void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
867 inline boolean DrawingOnBackground(int, int);
868 inline void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int,
869                                    int);
870 inline void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
871 inline void DrawLines(Bitmap *, struct XY *, int, Pixel);
872 inline Pixel GetPixel(Bitmap *, int, int);
873 inline Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
874 inline Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
875
876 inline void FlushDisplay(void);
877 inline void SyncDisplay(void);
878 inline void KeyboardAutoRepeatOn(void);
879 inline void KeyboardAutoRepeatOff(void);
880 inline boolean PointerInWindow(DrawWindow *);
881 inline boolean SetVideoMode(boolean);
882 inline boolean ChangeVideoModeIfNeeded(boolean);
883
884 Bitmap *LoadImage(char *);
885 Bitmap *LoadCustomImage(char *);
886 void ReloadCustomImage(Bitmap *, char *);
887
888 Bitmap *ZoomBitmap(Bitmap *, int, int);
889 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
890
891 void SetMouseCursor(int);
892
893 inline void OpenAudio(void);
894 inline void CloseAudio(void);
895 inline void SetAudioMode(boolean);
896
897 inline void InitEventFilter(EventFilter);
898 inline boolean PendingEvent(void);
899 inline void NextEvent(Event *event);
900 inline void PeekEvent(Event *event);
901 inline Key GetEventKey(KeyEvent *, boolean);
902 inline KeyMod HandleKeyModState(Key, int);
903 inline KeyMod GetKeyModState();
904 inline boolean CheckCloseWindowEvent(ClientMessageEvent *);
905
906 inline void InitJoysticks();
907 inline boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
908
909 #endif /* SYSTEM_H */