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