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