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