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