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