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