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