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