rnd-20100310-1-src
[rocksndiamonds.git] / src / libgame / system.h
1 /***********************************************************
2 * Artsoft Retro-Game Library                               *
3 *----------------------------------------------------------*
4 * (c) 1994-2006 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_DROP                KSYM_KP_Enter
59 #else
60 #define DEFAULT_KEY_SNAP                KSYM_Control_L
61 #define DEFAULT_KEY_DROP                KSYM_Control_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 #define DEFAULT_KEY_FOCUS_PLAYER_1      KSYM_F5
71 #define DEFAULT_KEY_FOCUS_PLAYER_2      KSYM_F6
72 #define DEFAULT_KEY_FOCUS_PLAYER_3      KSYM_F7
73 #define DEFAULT_KEY_FOCUS_PLAYER_4      KSYM_F8
74 #define DEFAULT_KEY_FOCUS_PLAYER_ALL    KSYM_F9
75 #define DEFAULT_KEY_TAPE_EJECT          KSYM_UNDEFINED
76 #define DEFAULT_KEY_TAPE_STOP           KSYM_UNDEFINED
77 #define DEFAULT_KEY_TAPE_PAUSE          KSYM_UNDEFINED
78 #define DEFAULT_KEY_TAPE_RECORD         KSYM_UNDEFINED
79 #define DEFAULT_KEY_TAPE_PLAY           KSYM_UNDEFINED
80
81 /* values for key_status */
82 #define KEY_NOT_PRESSED                 FALSE
83 #define KEY_RELEASED                    FALSE
84 #define KEY_PRESSED                     TRUE
85
86 /* values for button status */
87 #define MB_NOT_PRESSED                  FALSE
88 #define MB_NOT_RELEASED                 TRUE
89 #define MB_RELEASED                     FALSE
90 #define MB_PRESSED                      TRUE
91 #define MB_MENU_CHOICE                  FALSE
92 #define MB_MENU_MARK                    TRUE
93 #define MB_MENU_INITIALIZE              (-1)
94 #define MB_MENU_LEAVE                   (-2)
95 #define MB_LEFTBUTTON                   1
96 #define MB_MIDDLEBUTTON                 2
97 #define MB_RIGHTBUTTON                  3
98 #define MB_WHEEL_UP                     4
99 #define MB_WHEEL_DOWN                   5
100 #define MB_WHEEL_LEFT                   6
101 #define MB_WHEEL_RIGHT                  7
102 #define IS_WHEEL_BUTTON_VERTICAL(b)     ((b) >= MB_WHEEL_UP &&          \
103                                          (b) <= MB_WHEEL_DOWN)
104 #define IS_WHEEL_BUTTON_HORIZONTAL(b)   ((b) >= MB_WHEEL_LEFT &&        \
105                                          (b) <= MB_WHEEL_RIGHT)
106 #define IS_WHEEL_BUTTON(b)              ((b) >= MB_WHEEL_UP &&          \
107                                          (b) <= MB_WHEEL_DOWN)
108 #define DEFAULT_WHEEL_STEPS             3
109
110 /* values for move directions */
111 #define MV_BIT_LEFT                     0
112 #define MV_BIT_RIGHT                    1
113 #define MV_BIT_UP                       2
114 #define MV_BIT_DOWN                     3
115
116 #define NUM_DIRECTIONS                  4
117
118 /* diagonal movement directions are used in a different contect than buttons */
119 #define MV_BIT_UPLEFT                   4
120 #define MV_BIT_UPRIGHT                  5
121 #define MV_BIT_DOWNLEFT                 6
122 #define MV_BIT_DOWNRIGHT                7
123
124 #define NUM_DIRECTIONS_FULL             8
125
126 /* values for special "button" bitmasks */
127 #define BUTTON_1                        4
128 #define BUTTON_2                        5
129
130 /* values for special "focus player" bitmasks */
131 #define BIT_SET_FOCUS                   6
132
133 /* values for move directions and special "button" key bitmasks */
134 #define MV_NONE                 0
135 #define MV_LEFT                 (1 << MV_BIT_LEFT)
136 #define MV_RIGHT                (1 << MV_BIT_RIGHT)
137 #define MV_UP                   (1 << MV_BIT_UP)
138 #define MV_DOWN                 (1 << MV_BIT_DOWN)
139
140 #define MV_UPLEFT               (MV_UP   | MV_LEFT)
141 #define MV_UPRIGHT              (MV_UP   | MV_RIGHT)
142 #define MV_DOWNLEFT             (MV_DOWN | MV_LEFT)
143 #define MV_DOWNRIGHT            (MV_DOWN | MV_RIGHT)
144
145 #define MV_HORIZONTAL           (MV_LEFT | MV_RIGHT)
146 #define MV_VERTICAL             (MV_UP   | MV_DOWN)
147 #define MV_ALL_DIRECTIONS       (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
148 #define MV_ANY_DIRECTION        (MV_ALL_DIRECTIONS)
149 #define MV_NO_DIRECTION         (MV_NONE)
150
151 #define KEY_BUTTON_1            (1 << BUTTON_1)
152 #define KEY_BUTTON_2            (1 << BUTTON_2)
153 #define KEY_MOTION              (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
154 #define KEY_BUTTON              (KEY_BUTTON_1 | KEY_BUTTON_2)
155 #define KEY_ACTION              (KEY_MOTION | KEY_BUTTON)
156
157 #define KEY_SET_FOCUS           (1 << BIT_SET_FOCUS)
158
159 #define MV_DIR_FROM_BIT(x)      ((x) < NUM_DIRECTIONS ? 1 << (x) :        \
160                                  (x) == MV_BIT_UPLEFT    ? MV_UPLEFT    : \
161                                  (x) == MV_BIT_UPRIGHT   ? MV_UPRIGHT   : \
162                                  (x) == MV_BIT_DOWNLEFT  ? MV_DOWNLEFT  : \
163                                  (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
164                                  MV_NONE)
165
166 #define MV_DIR_TO_BIT(x)        ((x) == MV_LEFT      ? MV_BIT_LEFT      : \
167                                  (x) == MV_RIGHT     ? MV_BIT_RIGHT     : \
168                                  (x) == MV_UP        ? MV_BIT_UP        : \
169                                  (x) == MV_DOWN      ? MV_BIT_DOWN      : \
170                                  (x) == MV_UPLEFT    ? MV_BIT_UPLEFT    : \
171                                  (x) == MV_UPRIGHT   ? MV_BIT_UPRIGHT   : \
172                                  (x) == MV_DOWNLEFT  ? MV_BIT_DOWNLEFT  : \
173                                  (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
174                                  MV_BIT_DOWN)
175
176 #define MV_DIR_OPPOSITE(x)      ((x) == MV_LEFT      ? MV_RIGHT     : \
177                                  (x) == MV_RIGHT     ? MV_LEFT      : \
178                                  (x) == MV_UP        ? MV_DOWN      : \
179                                  (x) == MV_DOWN      ? MV_UP        : \
180                                  (x) == MV_UPLEFT    ? MV_DOWNRIGHT : \
181                                  (x) == MV_UPRIGHT   ? MV_DOWNLEFT  : \
182                                  (x) == MV_DOWNLEFT  ? MV_UPRIGHT   : \
183                                  (x) == MV_DOWNRIGHT ? MV_UPLEFT    : \
184                                  MV_NONE)
185
186 /* values for animation mode (frame order and direction) */
187 #define ANIM_NONE               0
188 #define ANIM_LOOP               (1 << 0)
189 #define ANIM_LINEAR             (1 << 1)
190 #define ANIM_PINGPONG           (1 << 2)
191 #define ANIM_PINGPONG2          (1 << 3)
192 #define ANIM_RANDOM             (1 << 4)
193 #define ANIM_CE_VALUE           (1 << 5)
194 #define ANIM_CE_SCORE           (1 << 6)
195 #define ANIM_CE_DELAY           (1 << 7)
196 #define ANIM_REVERSE            (1 << 8)
197 #define ANIM_OPAQUE_PLAYER      (1 << 9)
198
199 /* values for special (non game element) animation modes */
200 #define ANIM_HORIZONTAL         (1 << 10)
201 #define ANIM_VERTICAL           (1 << 11)
202 #define ANIM_CENTERED           (1 << 12)
203 #define ANIM_STATIC_PANEL       (1 << 13)
204
205 #define ANIM_DEFAULT            ANIM_LOOP
206
207 /* values for fade mode */
208 #define FADE_TYPE_NONE          0
209 #define FADE_TYPE_FADE_IN       (1 << 0)
210 #define FADE_TYPE_FADE_OUT      (1 << 1)
211 #define FADE_TYPE_TRANSFORM     (1 << 2)
212 #define FADE_TYPE_CROSSFADE     (1 << 3)
213 #define FADE_TYPE_MELT          (1 << 4)
214 #define FADE_TYPE_SKIP          (1 << 5)
215
216 #define FADE_MODE_NONE          (FADE_TYPE_NONE)
217 #define FADE_MODE_FADE_IN       (FADE_TYPE_FADE_IN)
218 #define FADE_MODE_FADE_OUT      (FADE_TYPE_FADE_OUT)
219 #define FADE_MODE_FADE          (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT)
220 #define FADE_MODE_TRANSFORM     (FADE_TYPE_TRANSFORM | FADE_TYPE_FADE_IN)
221 #define FADE_MODE_CROSSFADE     (FADE_MODE_TRANSFORM | FADE_TYPE_CROSSFADE)
222 #define FADE_MODE_MELT          (FADE_MODE_TRANSFORM | FADE_TYPE_MELT)
223 #define FADE_MODE_SKIP_FADE_IN  (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN)
224 #define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT)
225
226 #define FADE_MODE_DEFAULT       FADE_MODE_FADE
227
228 /* values for text alignment */
229 #define ALIGN_LEFT              (1 << 0)
230 #define ALIGN_RIGHT             (1 << 1)
231 #define ALIGN_CENTER            (1 << 2)
232 #define ALIGN_DEFAULT           ALIGN_LEFT
233
234 #define VALIGN_TOP              (1 << 0)
235 #define VALIGN_BOTTOM           (1 << 1)
236 #define VALIGN_MIDDLE           (1 << 2)
237 #define VALIGN_DEFAULT          VALIGN_TOP
238
239 #define ALIGNED_XPOS(x,w,a)     ((a) == ALIGN_CENTER  ? (x) - (w) / 2 : \
240                                  (a) == ALIGN_RIGHT   ? (x) - (w) : (x))
241 #define ALIGNED_YPOS(y,h,v)     ((v) == VALIGN_MIDDLE ? (y) - (h) / 2 : \
242                                  (v) == VALIGN_BOTTOM ? (y) - (h) : (y))
243 #define ALIGNED_TEXT_XPOS(p)    ALIGNED_XPOS((p)->x, (p)->width,  (p)->align)
244 #define ALIGNED_TEXT_YPOS(p)    ALIGNED_YPOS((p)->y, (p)->height, (p)->valign)
245
246 /* values for redraw_mask */
247 #define REDRAW_NONE             (0)
248 #define REDRAW_ALL              (1 << 0)
249 #define REDRAW_FIELD            (1 << 1)
250 #define REDRAW_TILES            (1 << 2)
251 #define REDRAW_DOOR_1           (1 << 3)
252 #define REDRAW_VIDEO_1          (1 << 4)
253 #define REDRAW_VIDEO_2          (1 << 5)
254 #define REDRAW_VIDEO_3          (1 << 6)
255 #define REDRAW_MICROLEVEL       (1 << 7)
256 #define REDRAW_MICROLABEL       (1 << 8)
257 #define REDRAW_FROM_BACKBUFFER  (1 << 9)
258 #define REDRAW_DOOR_2           (REDRAW_VIDEO_1 | \
259                                  REDRAW_VIDEO_2 | \
260                                  REDRAW_VIDEO_3)
261 #define REDRAW_DOOR_3           (1 << 10)
262 #define REDRAW_DOORS            (REDRAW_DOOR_1 | \
263                                  REDRAW_DOOR_2 | \
264                                  REDRAW_DOOR_3)
265 #define REDRAW_MAIN             (REDRAW_FIELD | \
266                                  REDRAW_TILES | \
267                                  REDRAW_MICROLEVEL)
268 #define REDRAW_FPS              (1 << 11)
269 #define REDRAWTILES_THRESHOLD   (SCR_FIELDX * SCR_FIELDY / 2)
270
271 #define IN_GFX_SCREEN(x, y)     (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
272                                  y >= gfx.sy && y < gfx.sy + gfx.sysize)
273 #define IN_GFX_DOOR(x, y)       (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
274                                  y >= gfx.dy && y < gfx.dy + gfx.dysize)
275 #define IN_GFX_VIDEO(x, y)      (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
276                                  y >= gfx.vy && y < gfx.vy + gfx.vysize)
277
278 /* values for mouse cursor */
279 #define CURSOR_DEFAULT          0
280 #define CURSOR_NONE             1
281 #define CURSOR_PLAYFIELD        2
282
283 /* fundamental game speed values */
284 #define ONE_SECOND_DELAY        1000    /* delay value for one second */
285 #define GAME_FRAME_DELAY        20      /* frame delay in milliseconds */
286 #define FFWD_FRAME_DELAY        10      /* 200% speed for fast forward */
287 #define FRAMES_PER_SECOND       (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
288
289 /* maximum playfield size supported by libgame functions */
290 #define MAX_PLAYFIELD_WIDTH     128
291 #define MAX_PLAYFIELD_HEIGHT    128
292
293 /* maximum number of parallel players supported by libgame functions */
294 #define MAX_PLAYERS             4
295
296 /* maximum allowed length of player name */
297 #define MAX_PLAYER_NAME_LEN     10
298
299 /* default name for empty highscore entry */
300 #define EMPTY_PLAYER_NAME       "no name"
301
302 /* default name for unknown player names */
303 #define ANONYMOUS_NAME          "anonymous"
304
305 /* default for other unknown names */
306 #define UNKNOWN_NAME            "unknown"
307
308 /* default name for new levels */
309 #define NAMELESS_LEVEL_NAME     "nameless level"
310
311 /* default text for non-existant artwork */
312 #define NOT_AVAILABLE           "(not available)"
313
314 /* default value for undefined filename */
315 #define UNDEFINED_FILENAME      "[NONE]"
316
317 /* default value for undefined parameter */
318 #define ARG_DEFAULT             "[DEFAULT]"
319
320 /* default values for undefined configuration file parameters */
321 #define ARG_UNDEFINED           "-1000000"
322 #define ARG_UNDEFINED_VALUE     (atoi(ARG_UNDEFINED))
323
324 /* definitions for game sub-directories */
325 #ifndef RO_GAME_DIR
326 #define RO_GAME_DIR             "."
327 #endif
328
329 #ifndef RW_GAME_DIR
330 #define RW_GAME_DIR             "."
331 #endif
332
333 #define RO_BASE_PATH            RO_GAME_DIR
334 #define RW_BASE_PATH            RW_GAME_DIR
335
336 /* directory names */
337 #define GRAPHICS_DIRECTORY      "graphics"
338 #define SOUNDS_DIRECTORY        "sounds"
339 #define MUSIC_DIRECTORY         "music"
340 #define LEVELS_DIRECTORY        "levels"
341 #define TAPES_DIRECTORY         "tapes"
342 #define SCORES_DIRECTORY        "scores"
343 #define DOCS_DIRECTORY          "docs"
344 #define CACHE_DIRECTORY         "cache"
345
346 #if !defined(PLATFORM_MSDOS)
347 #define GFX_CLASSIC_SUBDIR      "gfx_classic"
348 #define SND_CLASSIC_SUBDIR      "snd_classic"
349 #define MUS_CLASSIC_SUBDIR      "mus_classic"
350 #else
351 #define GFX_CLASSIC_SUBDIR      "gfx_orig"
352 #define SND_CLASSIC_SUBDIR      "snd_orig"
353 #define MUS_CLASSIC_SUBDIR      "mus_orig"
354 #endif
355
356 #if defined(CREATE_SPECIAL_EDITION_RND_JUE)
357 #define GFX_DEFAULT_SUBDIR      "jue0"
358 #define SND_DEFAULT_SUBDIR      "jue0"
359 #define MUS_DEFAULT_SUBDIR      "jue0"
360 #else
361 #define GFX_DEFAULT_SUBDIR      GFX_CLASSIC_SUBDIR
362 #define SND_DEFAULT_SUBDIR      SND_CLASSIC_SUBDIR
363 #define MUS_DEFAULT_SUBDIR      MUS_CLASSIC_SUBDIR
364 #endif
365
366 #if defined(CREATE_SPECIAL_EDITION)
367 #define GFX_FALLBACK_FILENAME   "fallback.pcx"
368 #define SND_FALLBACK_FILENAME   "fallback.wav"
369 #define MUS_FALLBACK_FILENAME   "fallback.wav"
370 #endif
371
372 /* file names and filename extensions */
373 #if !defined(PLATFORM_MSDOS)
374 #define LEVELSETUP_DIRECTORY    "levelsetup"
375 #define SETUP_FILENAME          "setup.conf"
376 #define LEVELSETUP_FILENAME     "levelsetup.conf"
377 #define EDITORSETUP_FILENAME    "editorsetup.conf"
378 #define EDITORCASCADE_FILENAME  "editorcascade.conf"
379 #define HELPANIM_FILENAME       "helpanim.conf"
380 #define HELPTEXT_FILENAME       "helptext.conf"
381 #define LEVELINFO_FILENAME      "levelinfo.conf"
382 #define GRAPHICSINFO_FILENAME   "graphicsinfo.conf"
383 #define SOUNDSINFO_FILENAME     "soundsinfo.conf"
384 #define MUSICINFO_FILENAME      "musicinfo.conf"
385 #define ARTWORKINFO_CACHE_FILE  "artworkinfo.cache"
386 #define LEVELFILE_EXTENSION     "level"
387 #define TAPEFILE_EXTENSION      "tape"
388 #define SCOREFILE_EXTENSION     "score"
389 #else
390 #define LEVELSETUP_DIRECTORY    "lvlsetup"
391 #define SETUP_FILENAME          "setup.cnf"
392 #define LEVELSETUP_FILENAME     "lvlsetup.cnf"
393 #define EDITORSETUP_FILENAME    "edsetup.cnf"
394 #define EDITORCASCADE_FILENAME  "edcascad.conf"
395 #define HELPANIM_FILENAME       "helpanim.cnf"
396 #define HELPTEXT_FILENAME       "helptext.cnf"
397 #define LEVELINFO_FILENAME      "lvlinfo.cnf"
398 #define GRAPHICSINFO_FILENAME   "gfxinfo.cnf"
399 #define SOUNDSINFO_FILENAME     "sndinfo.cnf"
400 #define MUSICINFO_FILENAME      "musinfo.cnf"
401 #define ARTWORKINFO_CACHE_FILE  "artinfo.cac"
402 #define LEVELFILE_EXTENSION     "lvl"
403 #define TAPEFILE_EXTENSION      "tap"
404 #define SCOREFILE_EXTENSION     "sco"
405 #endif
406
407 #define ERROR_BASENAME          "stderr.txt"
408
409 #define CHAR_PATH_SEPARATOR_UNIX        '/'
410 #define CHAR_PATH_SEPARATOR_DOS         '\\'
411
412 #define STRING_PATH_SEPARATOR_UNIX      "/"
413 #define STRING_PATH_SEPARATOR_DOS       "\\"
414
415 #define STRING_NEWLINE_UNIX             "\n"
416 #define STRING_NEWLINE_DOS              "\r\n"
417
418 #if defined(PLATFORM_WIN32) || defined(PLATFORM_MSDOS)
419 #define CHAR_PATH_SEPARATOR     CHAR_PATH_SEPARATOR_DOS
420 #define STRING_PATH_SEPARATOR   STRING_PATH_SEPARATOR_DOS
421 #define STRING_NEWLINE          STRING_NEWLINE_DOS
422 #else
423 #define CHAR_PATH_SEPARATOR     CHAR_PATH_SEPARATOR_UNIX
424 #define STRING_PATH_SEPARATOR   STRING_PATH_SEPARATOR_UNIX
425 #define STRING_NEWLINE          STRING_NEWLINE_UNIX
426 #endif
427
428
429 /* areas in bitmap PIX_DOOR */
430 /* meaning in PIX_DB_DOOR: (3 PAGEs)
431    PAGEX1: 1. buffer for DOOR_1
432    PAGEX2: 2. buffer for DOOR_1
433    PAGEX3: buffer for animations
434 */
435
436 /* these values are hard-coded to be able to use them in initialization */
437 #define DOOR_GFX_PAGE_WIDTH     100     /* should be set to "gfx.dxsize" */
438 #define DOOR_GFX_PAGE_HEIGHT    280     /* should be set to "gfx.dysize" */
439
440 #define DOOR_GFX_PAGESIZE       (DOOR_GFX_PAGE_WIDTH)
441 #define DOOR_GFX_PAGEX1         (0 * DOOR_GFX_PAGESIZE)
442 #define DOOR_GFX_PAGEX2         (1 * DOOR_GFX_PAGESIZE)
443 #define DOOR_GFX_PAGEX3         (2 * DOOR_GFX_PAGESIZE)
444 #define DOOR_GFX_PAGEX4         (3 * DOOR_GFX_PAGESIZE)
445 #define DOOR_GFX_PAGEX5         (4 * DOOR_GFX_PAGESIZE)
446 #define DOOR_GFX_PAGEX6         (5 * DOOR_GFX_PAGESIZE)
447 #define DOOR_GFX_PAGEX7         (6 * DOOR_GFX_PAGESIZE)
448 #define DOOR_GFX_PAGEX8         (7 * DOOR_GFX_PAGESIZE)
449 #define DOOR_GFX_PAGEY1         (0)
450 #define DOOR_GFX_PAGEY2         (DOOR_GFX_PAGE_HEIGHT)
451
452
453 /* macros for version handling */
454 #define VERSION_MAJOR(x)        ((x) / 1000000)
455 #define VERSION_MINOR(x)        (((x) % 1000000) / 10000)
456 #define VERSION_PATCH(x)        (((x) % 10000) / 100)
457 #define VERSION_BUILD(x)        ((x) % 100)
458 #define VERSION_IDENT(a,b,c,d)  ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
459
460
461 /* macros for parent/child process identification */
462 #if defined(PLATFORM_UNIX)
463 #define IS_PARENT_PROCESS()     (audio.mixer_pid != getpid())
464 #define IS_CHILD_PROCESS()      (audio.mixer_pid == getpid())
465 #define HAS_CHILD_PROCESS()     (audio.mixer_pid > 0)
466 #else
467 #define IS_PARENT_PROCESS()     TRUE
468 #define IS_CHILD_PROCESS()      FALSE
469 #define HAS_CHILD_PROCESS()     FALSE
470 #endif
471
472
473 /* values for artwork type */
474 #define ARTWORK_TYPE_GRAPHICS   0
475 #define ARTWORK_TYPE_SOUNDS     1
476 #define ARTWORK_TYPE_MUSIC      2
477
478 #define NUM_ARTWORK_TYPES       3
479
480
481 /* values for tree type (chosen to match artwork type) */
482 #define TREE_TYPE_UNDEFINED     -1
483 #define TREE_TYPE_GRAPHICS_DIR  ARTWORK_TYPE_GRAPHICS
484 #define TREE_TYPE_SOUNDS_DIR    ARTWORK_TYPE_SOUNDS
485 #define TREE_TYPE_MUSIC_DIR     ARTWORK_TYPE_MUSIC
486 #define TREE_TYPE_LEVEL_DIR     3
487
488 #define NUM_TREE_TYPES          4
489
490 #define INFOTEXT_UNDEFINED      ""
491 #define INFOTEXT_GRAPHICS_DIR   "Custom Graphics"
492 #define INFOTEXT_SOUNDS_DIR     "Custom Sounds"
493 #define INFOTEXT_MUSIC_DIR      "Custom Music"
494 #define INFOTEXT_LEVEL_DIR      "Level Sets"
495
496 #define TREE_INFOTEXT(t)        ((t) == TREE_TYPE_LEVEL_DIR ?           \
497                                  INFOTEXT_LEVEL_DIR :                   \
498                                  (t) == TREE_TYPE_GRAPHICS_DIR ?        \
499                                  INFOTEXT_GRAPHICS_DIR :                \
500                                  (t) == TREE_TYPE_SOUNDS_DIR ?          \
501                                  INFOTEXT_SOUNDS_DIR :                  \
502                                  (t) == TREE_TYPE_MUSIC_DIR ?           \
503                                  INFOTEXT_MUSIC_DIR :                   \
504                                  INFOTEXT_UNDEFINED)
505
506 /* values for artwork handling */
507 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type)                        \
508                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
509                                  &(leveldir)->graphics_set :            \
510                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
511                                  &(leveldir)->sounds_set :              \
512                                  &(leveldir)->music_set)
513
514 #define LEVELDIR_ARTWORK_SET(leveldir, type)                            \
515                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
516                                  (leveldir)->graphics_set :             \
517                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
518                                  (leveldir)->sounds_set :               \
519                                  (leveldir)->music_set)
520
521 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type)                       \
522                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
523                                  &(leveldir)->graphics_path :           \
524                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
525                                  &(leveldir)->sounds_path :             \
526                                  &(leveldir)->music_path)
527
528 #define LEVELDIR_ARTWORK_PATH(leveldir, type)                           \
529                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
530                                  (leveldir)->graphics_path :            \
531                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
532                                  (leveldir)->sounds_path :              \
533                                  (leveldir)->music_path)
534
535 #define SETUP_ARTWORK_SET(setup, type)                                  \
536                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
537                                  (setup).graphics_set :                 \
538                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
539                                  (setup).sounds_set :                   \
540                                  (setup).music_set)
541
542 #define SETUP_OVERRIDE_ARTWORK(setup, type)                             \
543                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
544                                  (setup).override_level_graphics :      \
545                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
546                                  (setup).override_level_sounds :        \
547                                  (setup).override_level_music)
548
549 #define GFX_OVERRIDE_ARTWORK(type)                                      \
550                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
551                                  gfx.override_level_graphics :          \
552                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
553                                  gfx.override_level_sounds :            \
554                                  gfx.override_level_music)
555
556 #define ARTWORK_FIRST_NODE(artwork, type)                               \
557                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
558                                  (artwork).gfx_first :                  \
559                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
560                                  (artwork).snd_first :                  \
561                                  (artwork).mus_first)
562
563 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type)                   \
564                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
565                                  &(artwork).gfx_current_identifier :    \
566                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
567                                  &(artwork).snd_current_identifier :    \
568                                  &(artwork).mus_current_identifier)
569
570 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type)                       \
571                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
572                                  (artwork).gfx_current_identifier :     \
573                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
574                                  (artwork).snd_current_identifier :     \
575                                  (artwork).mus_current_identifier)
576
577 #define ARTWORKINFO_FILENAME(type)                                      \
578                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
579                                  GRAPHICSINFO_FILENAME :                \
580                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
581                                  SOUNDSINFO_FILENAME :                  \
582                                  (type) == ARTWORK_TYPE_MUSIC ?         \
583                                  MUSICINFO_FILENAME : "")
584
585 #define ARTWORK_DIRECTORY(type)                                         \
586                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
587                                  GRAPHICS_DIRECTORY :                   \
588                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
589                                  SOUNDS_DIRECTORY :                     \
590                                  (type) == ARTWORK_TYPE_MUSIC ?         \
591                                  MUSIC_DIRECTORY : "")
592
593 #define OPTIONS_ARTWORK_DIRECTORY(type)                                 \
594                                 ((type) == ARTWORK_TYPE_GRAPHICS ?      \
595                                  options.graphics_directory :           \
596                                  (type) == ARTWORK_TYPE_SOUNDS ?        \
597                                  options.sounds_directory :             \
598                                  (type) == ARTWORK_TYPE_MUSIC ?         \
599                                  options.music_directory : "")
600
601 #define UPDATE_BUSY_STATE()                     \
602 {                                               \
603   if (gfx.draw_busy_anim_function != NULL)      \
604     gfx.draw_busy_anim_function();              \
605 }
606
607
608 /* type definitions */
609 typedef int (*EventFilter)(const Event *);
610
611
612 /* structure definitions */
613
614 struct ProgramInfo
615 {
616   char *command_basepath;       /* directory that contains the program */
617   char *command_basename;       /* base filename of the program binary */
618
619   char *userdata_subdir;        /* personal user game data directory */
620   char *userdata_subdir_unix;   /* personal user game data directory (Unix) */
621   char *userdata_path;          /* resulting full path to game data directory */
622
623   char *program_title;
624   char *window_title;
625   char *icon_title;
626
627   char *x11_icon_filename;
628   char *x11_iconmask_filename;
629   char *sdl_icon_filename;
630   char *msdos_cursor_filename;
631
632   char *cookie_prefix;
633   char *filename_prefix;        /* prefix to cut off from DOS filenames */
634
635   char *error_filename;         /* filename where to write error messages to */
636   FILE *error_file;             /* (used instead of 'stderr' on some systems) */
637
638   int version_major;
639   int version_minor;
640   int version_patch;
641
642   void (*exit_function)(int);
643 };
644
645 struct OptionInfo
646 {
647   char *display_name;
648   char *server_host;
649   int server_port;
650
651   char *ro_base_directory;
652   char *rw_base_directory;
653   char *level_directory;
654   char *graphics_directory;
655   char *sounds_directory;
656   char *music_directory;
657   char *docs_directory;
658
659   char *execute_command;
660
661   char *special_flags;
662
663   boolean serveronly;
664   boolean network;
665   boolean verbose;
666   boolean debug;
667   boolean debug_x11_sync;
668 };
669
670 struct ScreenModeInfo
671 {
672   int width, height;
673 };
674
675 struct VideoSystemInfo
676 {
677   int default_depth;
678   int width, height, depth;
679
680   boolean fullscreen_available;
681   boolean fullscreen_enabled;
682   struct ScreenModeInfo *fullscreen_modes;
683   char *fullscreen_mode_current;
684 };
685
686 struct AudioSystemInfo
687 {
688   boolean sound_available;
689   boolean loops_available;
690   boolean music_available;
691
692   boolean sound_enabled;
693   boolean sound_deactivated;    /* for temporarily disabling sound */
694
695   int mixer_pipe[2];
696   int mixer_pid;
697   char *device_name;
698   int device_fd;
699
700   int num_channels;
701   int music_channel;
702   int first_sound_channel;
703 };
704
705 struct FontBitmapInfo
706 {
707   Bitmap *bitmap;
708
709   int src_x, src_y;             /* start position of animation frames */
710   int width, height;            /* width/height of each animation frame */
711
712   int draw_xoffset;             /* offset for drawing font characters */
713   int draw_yoffset;             /* offset for drawing font characters */
714
715   int num_chars;
716   int num_chars_per_line;
717
718 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
719   Pixmap *clip_mask;            /* single-char-only clip mask array for X11 */
720 #endif
721 };
722
723 struct GfxInfo
724 {
725   int sx, sy;
726   int sxsize, sysize;
727   int real_sx, real_sy;
728   int full_sxsize, full_sysize;
729   int scrollbuffer_width, scrollbuffer_height;
730
731   int dx, dy;
732   int dxsize, dysize;
733
734   int vx, vy;
735   int vxsize, vysize;
736
737   int win_xsize, win_ysize;
738
739   int draw_deactivation_mask;
740   int draw_background_mask;
741
742   Bitmap *field_save_buffer;
743
744   Bitmap *background_bitmap;
745   int background_bitmap_mask;
746
747   boolean override_level_graphics;
748   boolean override_level_sounds;
749   boolean override_level_music;
750
751   boolean draw_init_text;
752
753   int num_fonts;
754   struct FontBitmapInfo *font_bitmap_info;
755   int (*select_font_function)(int);
756   int (*get_font_from_token_function)(char *);
757
758   int anim_random_frame;
759
760   void (*draw_busy_anim_function)(void);
761 };
762
763 struct JoystickInfo
764 {
765   int status;
766   int fd[MAX_PLAYERS];          /* file descriptor of player's joystick */
767 };
768
769 struct SetupJoystickInfo
770 {
771   char *device_name;            /* device name of player's joystick */
772
773   int xleft, xmiddle, xright;
774   int yupper, ymiddle, ylower;
775   int snap, drop;
776 };
777
778 struct SetupKeyboardInfo
779 {
780   Key left, right, up, down;
781   Key snap, drop;
782 };
783
784 struct SetupInputInfo
785 {
786   boolean use_joystick;
787   struct SetupJoystickInfo joy;
788   struct SetupKeyboardInfo key;
789 };
790
791 struct SetupEditorInfo
792 {
793   boolean el_boulderdash;
794   boolean el_emerald_mine;
795   boolean el_emerald_mine_club;
796   boolean el_more;
797   boolean el_sokoban;
798   boolean el_supaplex;
799   boolean el_diamond_caves;
800   boolean el_dx_boulderdash;
801   boolean el_chars;
802   boolean el_steel_chars;
803   boolean el_custom;
804   boolean el_user_defined;
805   boolean el_dynamic;
806
807   boolean el_headlines;
808
809   boolean el_by_game;
810   boolean el_by_type;
811
812   boolean show_element_token;
813 };
814
815 struct SetupEditorCascadeInfo
816 {
817   boolean el_bd;
818   boolean el_em;
819   boolean el_emc;
820   boolean el_rnd;
821   boolean el_sb;
822   boolean el_sp;
823   boolean el_dc;
824   boolean el_dx;
825   boolean el_chars;
826   boolean el_steel_chars;
827   boolean el_ce;
828   boolean el_ge;
829   boolean el_ref;
830   boolean el_user;
831   boolean el_dynamic;
832 };
833
834 struct SetupShortcutInfo
835 {
836   Key save_game;
837   Key load_game;
838   Key toggle_pause;
839
840   Key focus_player[MAX_PLAYERS];
841   Key focus_player_all;
842
843   Key tape_eject;
844   Key tape_stop;
845   Key tape_pause;
846   Key tape_record;
847   Key tape_play;
848 };
849
850 struct SetupSystemInfo
851 {
852   char *sdl_videodriver;
853   char *sdl_audiodriver;
854   int audio_fragment_size;
855 };
856
857 struct SetupInfo
858 {
859   char *player_name;
860
861   boolean sound;
862   boolean sound_loops;
863   boolean sound_music;
864   boolean sound_simple;
865   boolean toons;
866   boolean scroll_delay;
867   boolean scroll_delay_value;
868   boolean soft_scrolling;
869   boolean fade_screens;
870   boolean autorecord;
871   boolean show_titlescreen;
872   boolean quick_doors;
873   boolean team_mode;
874   boolean handicap;
875   boolean skip_levels;
876   boolean time_limit;
877   boolean fullscreen;
878   char *fullscreen_mode;
879   boolean ask_on_escape;
880   boolean ask_on_escape_editor;
881   boolean quick_switch;
882   boolean input_on_focus;
883   boolean prefer_aga_graphics;
884   int game_frame_delay;
885   boolean sp_show_border_elements;
886
887   char *graphics_set;
888   char *sounds_set;
889   char *music_set;
890   int override_level_graphics;          /* not boolean -- can also be "AUTO" */
891   int override_level_sounds;            /* not boolean -- can also be "AUTO" */
892   int override_level_music;             /* not boolean -- can also be "AUTO" */
893
894   struct SetupEditorInfo editor;
895   struct SetupEditorCascadeInfo editor_cascade;
896   struct SetupShortcutInfo shortcut;
897   struct SetupInputInfo input[MAX_PLAYERS];
898   struct SetupSystemInfo system;
899   struct OptionInfo options;
900 };
901
902 struct TreeInfo
903 {
904   struct TreeInfo **node_top;           /* topmost node in tree */
905   struct TreeInfo *node_parent;         /* parent level directory info */
906   struct TreeInfo *node_group;          /* level group sub-directory info */
907   struct TreeInfo *next;                /* next level series structure node */
908
909   int cl_first;         /* internal control field for setup screen */
910   int cl_cursor;        /* internal control field for setup screen */
911
912   int type;             /* type of tree content */
913
914   /* fields for "type == TREE_TYPE_LEVEL_DIR" */
915
916   char *subdir;         /* tree info sub-directory basename (may be ".") */
917   char *fullpath;       /* complete path relative to tree base directory */
918   char *basepath;       /* absolute base path of tree base directory */
919   char *identifier;     /* identifier string for configuration files */
920   char *name;           /* tree info name, as displayed in selection menues */
921   char *name_sorting;   /* optional sorting name for correct name sorting */
922   char *author;         /* level or artwork author name */
923   char *year;           /* optional year of creation for levels or artwork */
924   char *imported_from;  /* optional comment for imported levels or artwork */
925   char *imported_by;    /* optional comment for imported levels or artwork */
926   char *tested_by;      /* optional comment to name people who tested a set */
927
928   char *graphics_set_ecs; /* special EMC custom graphics set (ECS graphics) */
929   char *graphics_set_aga; /* special EMC custom graphics set (AGA graphics) */
930   char *graphics_set;   /* optional custom graphics set (level tree only) */
931   char *sounds_set;     /* optional custom sounds set (level tree only) */
932   char *music_set;      /* optional custom music set (level tree only) */
933   char *graphics_path;  /* path to optional custom graphics set (level only) */
934   char *sounds_path;    /* path to optional custom sounds set (level only) */
935   char *music_path;     /* path to optional custom music set (level only) */
936
937   char *level_filename; /* filename of level file (for packed level file) */
938   char *level_filetype; /* type of levels in level directory or level file */
939
940   char *special_flags;  /* flags for special actions performed on level file */
941
942   int levels;           /* number of levels in level series */
943   int first_level;      /* first level number (to allow start with 0 or 1) */
944   int last_level;       /* last level number (automatically calculated) */
945   int sort_priority;    /* sort levels by 'sort_priority' and then by name */
946
947   boolean latest_engine;/* force level set to use the latest game engine */
948
949   boolean level_group;  /* directory contains more level series directories */
950   boolean parent_link;  /* entry links back to parent directory */
951   boolean in_user_dir;  /* user defined levels are stored in home directory */
952   boolean user_defined; /* levels in user directory and marked as "private" */
953   boolean readonly;     /* readonly levels can not be changed with editor */
954   boolean handicap;     /* level set has no handicap when set to "false" */
955   boolean skip_levels;  /* levels can be skipped when set to "true" */
956
957   int color;            /* color to use on selection screen for this level */
958   char *class_desc;     /* description of level series class */
959   int handicap_level;   /* number of the lowest unsolved level */
960
961   char *infotext;       /* optional text to describe the tree type (headline) */
962 };
963
964 typedef struct TreeInfo TreeInfo;
965 typedef struct TreeInfo LevelDirTree;
966 typedef struct TreeInfo ArtworkDirTree;
967 typedef struct TreeInfo GraphicsDirTree;
968 typedef struct TreeInfo SoundsDirTree;
969 typedef struct TreeInfo MusicDirTree;
970
971 struct ArtworkInfo
972 {
973   GraphicsDirTree *gfx_first;
974   GraphicsDirTree *gfx_current;
975   SoundsDirTree *snd_first;
976   SoundsDirTree *snd_current;
977   MusicDirTree *mus_first;
978   MusicDirTree *mus_current;
979
980   char *gfx_current_identifier;
981   char *snd_current_identifier;
982   char *mus_current_identifier;
983 };
984
985 struct ValueTextInfo
986 {
987   int value;
988   char *text;
989 };
990
991 struct ConfigInfo
992 {
993   char *token;
994   char *value;
995 };
996
997 struct ConfigTypeInfo
998 {
999   char *token;
1000   char *value;
1001   int type;
1002 };
1003
1004 struct TokenIntPtrInfo
1005 {
1006   char *token;
1007   int *value;
1008 };
1009
1010 struct FileInfo
1011 {
1012   char *token;
1013
1014   char *default_filename;
1015   char *filename;
1016
1017   char **default_parameter;                     /* array of file parameters */
1018   char **parameter;                             /* array of file parameters */
1019
1020   boolean redefined;
1021   boolean fallback_to_default;
1022   boolean default_is_cloned;
1023 };
1024
1025 struct SetupFileList
1026 {
1027   char *token;
1028   char *value;
1029
1030   struct SetupFileList *next;
1031 };
1032
1033 struct ListNodeInfo
1034 {
1035   char *source_filename;                        /* primary key for node list */
1036   int num_references;
1037 };
1038
1039 struct PropertyMapping
1040 {
1041   int base_index;
1042   int ext1_index;
1043   int ext2_index;
1044   int ext3_index;
1045
1046   int artwork_index;
1047 };
1048
1049 struct ArtworkListInfo
1050 {
1051   int type;                                     /* type of artwork */
1052
1053   int num_file_list_entries;
1054   int num_dynamic_file_list_entries;
1055   struct FileInfo *file_list;                   /* static artwork file array */
1056   struct FileInfo *dynamic_file_list;           /* dynamic artwrk file array */
1057
1058   int num_suffix_list_entries;
1059   struct ConfigTypeInfo *suffix_list;           /* parameter suffixes array */
1060
1061   int num_base_prefixes;
1062   int num_ext1_suffixes;
1063   int num_ext2_suffixes;
1064   int num_ext3_suffixes;
1065   char **base_prefixes;                         /* base token prefixes array */
1066   char **ext1_suffixes;                         /* property suffixes array 1 */
1067   char **ext2_suffixes;                         /* property suffixes array 2 */
1068   char **ext3_suffixes;                         /* property suffixes array 3 */
1069
1070   int num_ignore_tokens;
1071   char **ignore_tokens;                         /* file tokens to be ignored */
1072
1073   int num_property_mapping_entries;
1074   struct PropertyMapping *property_mapping;     /* mapping token -> artwork */
1075
1076   int sizeof_artwork_list_entry;
1077
1078   struct ListNodeInfo **artwork_list;           /* static artwork node array */
1079   struct ListNodeInfo **dynamic_artwork_list;   /* dynamic artwrk node array */
1080   struct ListNode *content_list;                /* dynamic artwork node list */
1081
1082   void *(*load_artwork)(char *);                /* constructor function */
1083   void (*free_artwork)(void *);                 /* destructor function */
1084 };
1085
1086 struct XY
1087 {
1088   int x, y;
1089 };
1090
1091 struct Rect
1092 {
1093   int x, y;
1094   int width, height;
1095 };
1096
1097 struct MenuPosInfo
1098 {
1099   int x, y;
1100   int width, height;
1101   int align, valign;
1102 };
1103
1104 struct TextPosInfo
1105 {
1106   int x, y;
1107   int width, height;
1108   int align, valign;
1109   int size;
1110   int font, font_alt;
1111   boolean draw_masked;
1112   int sort_priority;
1113   int id;
1114 };
1115
1116
1117 /* ========================================================================= */
1118 /* exported variables                                                        */
1119 /* ========================================================================= */
1120
1121 extern struct ProgramInfo       program;
1122 extern struct OptionInfo        options;
1123 extern struct VideoSystemInfo   video;
1124 extern struct AudioSystemInfo   audio;
1125 extern struct GfxInfo           gfx;
1126 extern struct AnimInfo          anim;
1127 extern struct ArtworkInfo       artwork;
1128 extern struct JoystickInfo      joystick;
1129 extern struct SetupInfo         setup;
1130
1131 extern LevelDirTree            *leveldir_first_all;
1132 extern LevelDirTree            *leveldir_first;
1133 extern LevelDirTree            *leveldir_current;
1134 extern int                      level_nr;
1135
1136 extern Display                 *display;
1137 extern Visual                  *visual;
1138 extern int                      screen;
1139 extern Colormap                 cmap;
1140
1141 extern DrawWindow              *window;
1142 extern DrawBuffer              *backbuffer;
1143 extern DrawBuffer              *drawto;
1144
1145 extern int                      button_status;
1146 extern boolean                  motion_status;
1147
1148 extern int                      redraw_mask;
1149 extern int                      redraw_tiles;
1150
1151 extern int                      FrameCounter;
1152
1153
1154 /* function definitions */
1155
1156 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1157                      char *, char *, char *, char *, char *, int);
1158
1159 void InitExitFunction(void (*exit_function)(int));
1160 void InitPlatformDependentStuff(void);
1161 void ClosePlatformDependentStuff(void);
1162
1163 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1164 void InitGfxDoor1Info(int, int, int, int);
1165 void InitGfxDoor2Info(int, int, int, int);
1166 void InitGfxWindowInfo(int, int);
1167 void InitGfxScrollbufferInfo(int, int);
1168 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
1169 void InitGfxCustomArtworkInfo();
1170 void SetDrawDeactivationMask(int);
1171 void SetDrawBackgroundMask(int);
1172 void SetWindowBackgroundBitmap(Bitmap *);
1173 void SetMainBackgroundBitmap(Bitmap *);
1174 void SetDoorBackgroundBitmap(Bitmap *);
1175
1176 void InitVideoDisplay(void);
1177 void CloseVideoDisplay(void);
1178 void InitVideoBuffer(int, int, int, boolean);
1179 Bitmap *CreateBitmapStruct(void);
1180 Bitmap *CreateBitmap(int, int, int);
1181 void FreeBitmap(Bitmap *);
1182 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1183 void FadeRectangle(Bitmap *bitmap, int, int, int, int, int, int, int,
1184                    void (*draw_border_function)(void));
1185 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1186 void ClearRectangle(Bitmap *, int, int, int, int);
1187 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1188 void SetClipMask(Bitmap *, GC, Pixmap);
1189 void SetClipOrigin(Bitmap *, GC, int, int);
1190 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1191 boolean DrawingOnBackground(int, int);
1192 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1193 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1194 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1195 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1196 Pixel GetPixel(Bitmap *, int, int);
1197 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1198 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1199
1200 void FlushDisplay(void);
1201 void SyncDisplay(void);
1202 void KeyboardAutoRepeatOn(void);
1203 void KeyboardAutoRepeatOff(void);
1204 boolean PointerInWindow(DrawWindow *);
1205 boolean SetVideoMode(boolean);
1206 boolean ChangeVideoModeIfNeeded(boolean);
1207
1208 Bitmap *LoadImage(char *);
1209 Bitmap *LoadCustomImage(char *);
1210 void ReloadCustomImage(Bitmap *, char *);
1211
1212 Bitmap *ZoomBitmap(Bitmap *, int, int);
1213 void CreateBitmapWithSmallBitmaps(Bitmap *, int);
1214 void ScaleBitmap(Bitmap *, int);
1215
1216 void SetMouseCursor(int);
1217
1218 void OpenAudio(void);
1219 void CloseAudio(void);
1220 void SetAudioMode(boolean);
1221
1222 void InitEventFilter(EventFilter);
1223 boolean PendingEvent(void);
1224 void NextEvent(Event *event);
1225 void PeekEvent(Event *event);
1226 Key GetEventKey(KeyEvent *, boolean);
1227 KeyMod HandleKeyModState(Key, int);
1228 KeyMod GetKeyModState();
1229 KeyMod GetKeyModStateFromEvents();
1230 boolean CheckCloseWindowEvent(ClientMessageEvent *);
1231
1232 void InitJoysticks();
1233 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
1234
1235 #endif /* SYSTEM_H */