1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
19 #if defined(PLATFORM_MACOSX)
21 #elif defined(PLATFORM_WIN32)
23 #elif defined(PLATFORM_ANDROID)
25 #elif defined(PLATFORM_EMSCRIPTEN)
26 #include "emscripten.h"
32 // the additional 'b' is needed for Win32 to open files in binary mode
33 #define MODE_READ "rb"
34 #define MODE_WRITE "wb"
35 #define MODE_APPEND "ab"
37 #define DEFAULT_DEPTH 0
41 #define BLIT_INVERSE 2
42 #define BLIT_ON_BACKGROUND 3
44 // values for fullscreen status
45 #define FULLSCREEN_NOT_AVAILABLE FALSE
46 #define FULLSCREEN_AVAILABLE TRUE
48 // values for window scaling
49 #define WINDOW_SCALING_NOT_AVAILABLE FALSE
50 #define WINDOW_SCALING_AVAILABLE TRUE
52 #define MIN_WINDOW_SCALING_PERCENT 30
53 #define STD_WINDOW_SCALING_PERCENT 100
54 #define MAX_WINDOW_SCALING_PERCENT 400
55 #define STEP_WINDOW_SCALING_PERCENT 10
57 // values for window scaling quality
58 #define SCALING_QUALITY_NEAREST "nearest"
59 #define SCALING_QUALITY_LINEAR "linear"
60 #define SCALING_QUALITY_BEST "best"
62 #define SCALING_QUALITY_DEFAULT SCALING_QUALITY_LINEAR
64 // values for screen rendering mode
65 #define STR_SPECIAL_RENDERING_OFF "stream_texture_only"
66 #define STR_SPECIAL_RENDERING_BITMAP "bitmap_and_stream_texture"
67 #define STR_SPECIAL_RENDERING_TARGET "target_texture_only"
68 #define STR_SPECIAL_RENDERING_DOUBLE "stream_and_target_texture"
70 #if defined(PLATFORM_EMSCRIPTEN)
71 #define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_BITMAP
73 #define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_DOUBLE
76 #define SPECIAL_RENDERING_OFF 0
77 #define SPECIAL_RENDERING_BITMAP 1
78 #define SPECIAL_RENDERING_TARGET 2
79 #define SPECIAL_RENDERING_DOUBLE 3
81 // values for vertical screen retrace synchronization (vsync)
82 #define STR_VSYNC_MODE_OFF "off"
83 #define STR_VSYNC_MODE_NORMAL "normal"
84 #define STR_VSYNC_MODE_ADAPTIVE "adaptive"
86 #define STR_VSYNC_MODE_DEFAULT STR_VSYNC_MODE_OFF
88 #define VSYNC_MODE_OFF 0
89 #define VSYNC_MODE_NORMAL 1
90 #define VSYNC_MODE_ADAPTIVE -1
92 #define VSYNC_MODE_DEFAULT VSYNC_MODE_OFF
94 #define VSYNC_MODE_STR_TO_INT(s) \
95 (strEqual((s), STR_VSYNC_MODE_NORMAL) ? VSYNC_MODE_NORMAL : \
96 strEqual((s), STR_VSYNC_MODE_ADAPTIVE) ? VSYNC_MODE_ADAPTIVE : \
99 #define VSYNC_MODE_INT_TO_STR(i) \
100 ((i) == VSYNC_MODE_NORMAL ? STR_VSYNC_MODE_NORMAL : \
101 (i) == VSYNC_MODE_ADAPTIVE ? STR_VSYNC_MODE_ADAPTIVE : \
104 // values for network server settings
105 #define STR_NETWORK_AUTO_DETECT "auto_detect_network_server"
106 #define STR_NETWORK_AUTO_DETECT_SETUP "(auto detect network server)"
108 // values for API server settings
109 #define API_SERVER_HOSTNAME "api.artsoft.org"
110 #define API_SERVER_PORT 80
111 #define API_SERVER_METHOD "POST"
112 #define API_SERVER_URI_ADD "/api/scores/add"
113 #define API_SERVER_URI_GET "/api/scores/get"
114 #define API_SERVER_URI_RENAME "/api/players/rename"
115 #define API_SERVER_URI_RESETUUID "/api/players/resetuuid"
118 #undef API_SERVER_HOSTNAME
119 #define API_SERVER_HOSTNAME "api-test.artsoft.org"
120 #define TEST_PREFIX "test."
122 #define TEST_PREFIX ""
125 // values for touch control
126 #define TOUCH_CONTROL_OFF "off"
127 #define TOUCH_CONTROL_VIRTUAL_BUTTONS "virtual_buttons"
128 #define TOUCH_CONTROL_WIPE_GESTURES "wipe_gestures"
129 #define TOUCH_CONTROL_FOLLOW_FINGER "follow_finger"
131 #if defined(PLATFORM_ANDROID)
132 #define TOUCH_CONTROL_DEFAULT TOUCH_CONTROL_VIRTUAL_BUTTONS
134 #define TOUCH_CONTROL_DEFAULT TOUCH_CONTROL_OFF
137 #define TOUCH_MOVE_DISTANCE_DEFAULT 2
138 #define TOUCH_DROP_DISTANCE_DEFAULT 5
139 #define TOUCH_TRANSPARENCY_DEFAULT 50
141 #define ALPHA_FROM_TRANSPARENCY(x) ((100 - x) * SDL_ALPHA_OPAQUE / 100)
142 #define ALPHA_FADING_STEPSIZE(x) ((x) / 25)
144 // values for special settings for mobile devices
145 #if defined(PLATFORM_ANDROID)
146 #define HAS_TOUCH_DEVICE
147 #define USE_TOUCH_INPUT_OVERLAY
148 #define USE_COMPLETE_DISPLAY
149 #define HAS_SCREEN_KEYBOARD
150 #define SCREEN_KEYBOARD_POS(h) ((h) / 2)
153 // values for drag-and-drop support (some parts not added before SDL 2.0.5)
154 #if !SDL_VERSION_ATLEAST(2,0,5)
155 #define SDL_DROPTEXT (SDL_DROPFILE + 1)
156 #define SDL_DROPBEGIN (SDL_DROPFILE + 2)
157 #define SDL_DROPCOMPLETE (SDL_DROPFILE + 3)
160 // default input keys
161 #define DEFAULT_KEY_LEFT KSYM_Left
162 #define DEFAULT_KEY_RIGHT KSYM_Right
163 #define DEFAULT_KEY_UP KSYM_Up
164 #define DEFAULT_KEY_DOWN KSYM_Down
165 #if defined(PLATFORM_MACOSX)
166 #define DEFAULT_KEY_SNAP KSYM_Control_L
167 #define DEFAULT_KEY_DROP KSYM_KP_Enter
169 #define DEFAULT_KEY_SNAP KSYM_Control_L
170 #define DEFAULT_KEY_DROP KSYM_Control_R
172 #define DEFAULT_KEY_OKAY KSYM_Return
173 #define DEFAULT_KEY_CANCEL KSYM_Escape
175 // default shortcut keys
176 #define DEFAULT_KEY_SAVE_GAME KSYM_F1
177 #define DEFAULT_KEY_LOAD_GAME KSYM_F2
178 #define DEFAULT_KEY_TOGGLE_PAUSE KSYM_space
179 #define DEFAULT_KEY_FOCUS_PLAYER_1 KSYM_F5
180 #define DEFAULT_KEY_FOCUS_PLAYER_2 KSYM_F6
181 #define DEFAULT_KEY_FOCUS_PLAYER_3 KSYM_F7
182 #define DEFAULT_KEY_FOCUS_PLAYER_4 KSYM_F8
183 #define DEFAULT_KEY_FOCUS_PLAYER_ALL KSYM_F9
184 #define DEFAULT_KEY_TAPE_EJECT KSYM_UNDEFINED
185 #define DEFAULT_KEY_TAPE_EXTRA KSYM_UNDEFINED
186 #define DEFAULT_KEY_TAPE_STOP KSYM_UNDEFINED
187 #define DEFAULT_KEY_TAPE_PAUSE KSYM_UNDEFINED
188 #define DEFAULT_KEY_TAPE_RECORD KSYM_UNDEFINED
189 #define DEFAULT_KEY_TAPE_PLAY KSYM_UNDEFINED
190 #define DEFAULT_KEY_SOUND_SIMPLE KSYM_UNDEFINED
191 #define DEFAULT_KEY_SOUND_LOOPS KSYM_UNDEFINED
192 #define DEFAULT_KEY_SOUND_MUSIC KSYM_UNDEFINED
193 #define DEFAULT_KEY_SNAP_LEFT KSYM_UNDEFINED
194 #define DEFAULT_KEY_SNAP_RIGHT KSYM_UNDEFINED
195 #define DEFAULT_KEY_SNAP_UP KSYM_UNDEFINED
196 #define DEFAULT_KEY_SNAP_DOWN KSYM_UNDEFINED
198 // default debug setup keys and values
199 #define DEFAULT_FRAME_DELAY_0 20 // 100 % speed
200 #define DEFAULT_FRAME_DELAY_1 500 // 4 % speed
201 #define DEFAULT_FRAME_DELAY_2 250 // 8 % speed
202 #define DEFAULT_FRAME_DELAY_3 125 // 16 % speed
203 #define DEFAULT_FRAME_DELAY_4 60 // 33 % speed
204 #define DEFAULT_FRAME_DELAY_5 40 // 50 % speed
205 #define DEFAULT_FRAME_DELAY_6 30 // 66 % speed
206 #define DEFAULT_FRAME_DELAY_7 10 // 200 % speed
207 #define DEFAULT_FRAME_DELAY_8 5 // 400 % speed
208 #define DEFAULT_FRAME_DELAY_9 0 // maximum speed
210 #define DEFAULT_KEY_FRAME_DELAY_0 KSYM_0
211 #define DEFAULT_KEY_FRAME_DELAY_1 KSYM_1
212 #define DEFAULT_KEY_FRAME_DELAY_2 KSYM_2
213 #define DEFAULT_KEY_FRAME_DELAY_3 KSYM_3
214 #define DEFAULT_KEY_FRAME_DELAY_4 KSYM_4
215 #define DEFAULT_KEY_FRAME_DELAY_5 KSYM_5
216 #define DEFAULT_KEY_FRAME_DELAY_6 KSYM_6
217 #define DEFAULT_KEY_FRAME_DELAY_7 KSYM_7
218 #define DEFAULT_KEY_FRAME_DELAY_8 KSYM_8
219 #define DEFAULT_KEY_FRAME_DELAY_9 KSYM_9
221 #define NUM_DEBUG_FRAME_DELAY_KEYS 10
223 #define DEFAULT_FRAME_DELAY_USE_MOD_KEY FALSE
224 #define DEFAULT_FRAME_DELAY_GAME_ONLY TRUE
226 // values for key_status
227 #define KEY_NOT_PRESSED FALSE
228 #define KEY_RELEASED FALSE
229 #define KEY_PRESSED TRUE
231 // values for button status
232 #define MB_NOT_PRESSED FALSE
233 #define MB_NOT_RELEASED TRUE
234 #define MB_RELEASED FALSE
235 #define MB_PRESSED TRUE
236 #define MB_MENU_CHOICE FALSE
237 #define MB_MENU_MARK TRUE
238 #define MB_MENU_INITIALIZE (-1)
239 #define MB_MENU_LEAVE (-2)
240 #define MB_LEFTBUTTON 1
241 #define MB_MIDDLEBUTTON 2
242 #define MB_RIGHTBUTTON 3
243 #define MB_WHEEL_UP 4
244 #define MB_WHEEL_DOWN 5
245 #define MB_WHEEL_LEFT 6
246 #define MB_WHEEL_RIGHT 7
247 #define IS_WHEEL_BUTTON_VERTICAL(b) ((b) == MB_WHEEL_UP || \
248 (b) == MB_WHEEL_DOWN)
249 #define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) == MB_WHEEL_LEFT || \
250 (b) == MB_WHEEL_RIGHT)
251 #define IS_WHEEL_BUTTON(b) (IS_WHEEL_BUTTON_VERTICAL(b) || \
252 IS_WHEEL_BUTTON_HORIZONTAL(b))
253 #define DEFAULT_WHEEL_STEPS 3
255 #define BUTTON_STEPSIZE(b) ((b) == MB_LEFTBUTTON ? 1 : \
256 (b) == MB_MIDDLEBUTTON ? 5 : \
257 (b) == MB_RIGHTBUTTON ? 10 : 1)
259 // values for move directions
260 #define MV_BIT_LEFT 0
261 #define MV_BIT_RIGHT 1
263 #define MV_BIT_DOWN 3
265 #define NUM_DIRECTIONS 4
267 // diagonal movement directions are used in a different contect than buttons
268 #define MV_BIT_UPLEFT 4
269 #define MV_BIT_UPRIGHT 5
270 #define MV_BIT_DOWNLEFT 6
271 #define MV_BIT_DOWNRIGHT 7
273 #define NUM_DIRECTIONS_FULL 8
275 // values for special "button" bitmasks
279 #define NUM_PLAYER_ACTIONS 6
281 // values for special "focus player" bitmasks
282 #define BIT_SET_FOCUS 6
284 // values for drawing stages for global animations
285 #define DRAW_GLOBAL_ANIM_STAGE_1 1
286 #define DRAW_GLOBAL_ANIM_STAGE_2 2
288 // values for drawing target (various functions)
289 #define DRAW_TO_BACKBUFFER 0
290 #define DRAW_TO_FIELDBUFFER 1
291 #define DRAW_TO_SCREEN 2
292 #define DRAW_TO_FADE_SOURCE 3
293 #define DRAW_TO_FADE_TARGET 4
295 // values for move directions and special "button" key bitmasks
297 #define MV_LEFT (1 << MV_BIT_LEFT)
298 #define MV_RIGHT (1 << MV_BIT_RIGHT)
299 #define MV_UP (1 << MV_BIT_UP)
300 #define MV_DOWN (1 << MV_BIT_DOWN)
302 #define MV_UPLEFT (MV_UP | MV_LEFT)
303 #define MV_UPRIGHT (MV_UP | MV_RIGHT)
304 #define MV_DOWNLEFT (MV_DOWN | MV_LEFT)
305 #define MV_DOWNRIGHT (MV_DOWN | MV_RIGHT)
307 #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT)
308 #define MV_VERTICAL (MV_UP | MV_DOWN)
309 #define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
310 #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS)
311 #define MV_NO_DIRECTION (MV_NONE)
313 #define KEY_BUTTON_1 (1 << BUTTON_1)
314 #define KEY_BUTTON_2 (1 << BUTTON_2)
315 #define KEY_BUTTON_SNAP KEY_BUTTON_1
316 #define KEY_BUTTON_DROP KEY_BUTTON_2
317 #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
318 #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2)
319 #define KEY_ACTION (KEY_MOTION | KEY_BUTTON)
321 #define KEY_SET_FOCUS (1 << BIT_SET_FOCUS)
323 #define MV_DIR_FROM_BIT(x) ((x) < NUM_DIRECTIONS ? 1 << (x) : \
324 (x) == MV_BIT_UPLEFT ? MV_UPLEFT : \
325 (x) == MV_BIT_UPRIGHT ? MV_UPRIGHT : \
326 (x) == MV_BIT_DOWNLEFT ? MV_DOWNLEFT : \
327 (x) == MV_BIT_DOWNRIGHT ? MV_DOWNRIGHT : \
330 #define MV_DIR_TO_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \
331 (x) == MV_RIGHT ? MV_BIT_RIGHT : \
332 (x) == MV_UP ? MV_BIT_UP : \
333 (x) == MV_DOWN ? MV_BIT_DOWN : \
334 (x) == MV_UPLEFT ? MV_BIT_UPLEFT : \
335 (x) == MV_UPRIGHT ? MV_BIT_UPRIGHT : \
336 (x) == MV_DOWNLEFT ? MV_BIT_DOWNLEFT : \
337 (x) == MV_DOWNRIGHT ? MV_BIT_DOWNRIGHT : \
340 #define MV_DIR_OPPOSITE(x) ((x) == MV_LEFT ? MV_RIGHT : \
341 (x) == MV_RIGHT ? MV_LEFT : \
342 (x) == MV_UP ? MV_DOWN : \
343 (x) == MV_DOWN ? MV_UP : \
344 (x) == MV_UPLEFT ? MV_DOWNRIGHT : \
345 (x) == MV_UPRIGHT ? MV_DOWNLEFT : \
346 (x) == MV_DOWNLEFT ? MV_UPRIGHT : \
347 (x) == MV_DOWNRIGHT ? MV_UPLEFT : \
350 // values for animation mode (frame order and direction)
351 // (stored in level files -- never change existing values)
353 #define ANIM_LOOP (1 << 0)
354 #define ANIM_LINEAR (1 << 1)
355 #define ANIM_PINGPONG (1 << 2)
356 #define ANIM_PINGPONG2 (1 << 3)
357 #define ANIM_RANDOM (1 << 4)
358 #define ANIM_CE_VALUE (1 << 5)
359 #define ANIM_CE_SCORE (1 << 6)
360 #define ANIM_CE_DELAY (1 << 7)
361 #define ANIM_REVERSE (1 << 8)
362 #define ANIM_OPAQUE_PLAYER (1 << 9)
364 // values for special (non game element) animation modes
365 // (not stored in level files -- can be changed, if needed)
366 #define ANIM_HORIZONTAL (1 << 10)
367 #define ANIM_VERTICAL (1 << 11)
368 #define ANIM_CENTERED (1 << 12)
369 #define ANIM_STATIC_PANEL (1 << 13)
370 #define ANIM_ALL (1 << 14)
371 #define ANIM_ONCE (1 << 15)
373 #define ANIM_DEFAULT ANIM_LOOP
375 // values for special drawing styles and event handling
378 // values used for crumbled graphics
379 #define STYLE_ACCURATE_BORDERS (1 << 0)
380 #define STYLE_INNER_CORNERS (1 << 1)
382 // values used for game panel graphics
383 #define STYLE_REVERSE (1 << 2)
384 #define STYLE_LEFTMOST_POSITION (1 << 3)
386 // values used for global animations
387 #define STYLE_BLOCK (1 << 4)
388 #define STYLE_PASSTHROUGH (1 << 5)
389 #define STYLE_MULTIPLE_ACTIONS (1 << 6)
391 #define STYLE_DEFAULT STYLE_NONE
393 // values for special global animation delay types
394 #define ANIM_DELAY_UNDEFINED -1
395 #define ANIM_DELAY_NONE 0
396 #define ANIM_DELAY_INIT 1
397 #define ANIM_DELAY_ANIM 2
398 #define ANIM_DELAY_POST 3
400 // values for special global animation delay actions
401 #define ANIM_DELAY_ACTION_NONE -1
403 // values for special global animation events
404 #define ANIM_EVENT_UNDEFINED -1
405 #define ANIM_EVENT_NONE 0
406 #define ANIM_EVENT_SELF (1 << 16)
407 #define ANIM_EVENT_ANY (1 << 17)
408 #define ANIM_EVENT_CLICK (1 << 18)
409 #define ANIM_EVENT_INIT (1 << 19)
410 #define ANIM_EVENT_START (1 << 20)
411 #define ANIM_EVENT_END (1 << 21)
412 #define ANIM_EVENT_POST (1 << 22)
413 #define ANIM_EVENT_UNCLICK_ANY (1 << 23)
415 // anim number: bits 0-7
416 // part number: bits 8-15
417 #define ANIM_EVENT_ANIM_BIT 0
418 #define ANIM_EVENT_PART_BIT 8
420 #define ANIM_EVENT_ANIM_MASK (0xff << ANIM_EVENT_ANIM_BIT)
421 #define ANIM_EVENT_PART_MASK (0xff << ANIM_EVENT_PART_BIT)
423 #define ANIM_EVENT_DEFAULT ANIM_EVENT_NONE
425 // values for special global animation event actions
426 #define ANIM_EVENT_ACTION_NONE -1
428 // values for fade mode
429 #define FADE_TYPE_NONE 0
430 #define FADE_TYPE_FADE_IN (1 << 0)
431 #define FADE_TYPE_FADE_OUT (1 << 1)
432 #define FADE_TYPE_TRANSFORM (1 << 2)
433 #define FADE_TYPE_CROSSFADE (1 << 3)
434 #define FADE_TYPE_MELT (1 << 4)
435 #define FADE_TYPE_CURTAIN (1 << 5)
436 #define FADE_TYPE_SKIP (1 << 6)
438 #define FADE_MODE_NONE (FADE_TYPE_NONE)
439 #define FADE_MODE_FADE_IN (FADE_TYPE_FADE_IN)
440 #define FADE_MODE_FADE_OUT (FADE_TYPE_FADE_OUT)
441 #define FADE_MODE_FADE (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT)
442 #define FADE_MODE_TRANSFORM (FADE_TYPE_TRANSFORM | FADE_TYPE_FADE_IN)
443 #define FADE_MODE_CROSSFADE (FADE_MODE_TRANSFORM | FADE_TYPE_CROSSFADE)
444 #define FADE_MODE_MELT (FADE_MODE_TRANSFORM | FADE_TYPE_MELT)
445 #define FADE_MODE_CURTAIN (FADE_MODE_TRANSFORM | FADE_TYPE_CURTAIN)
446 #define FADE_MODE_SKIP_FADE_IN (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN)
447 #define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT)
449 #define FADE_MODE_DEFAULT FADE_MODE_FADE
451 #define AUTO_DELAY_UNIT_MS 0
452 #define AUTO_DELAY_UNIT_FRAMES 1
454 #define AUTO_DELAY_UNIT_DEFAULT AUTO_DELAY_UNIT_MS
456 // values for toon positions
457 #define POS_UNDEFINED -1
468 // values for text alignment
469 #define ALIGN_LEFT (1 << 0)
470 #define ALIGN_RIGHT (1 << 1)
471 #define ALIGN_CENTER (1 << 2)
472 #define ALIGN_DEFAULT ALIGN_LEFT
474 #define VALIGN_TOP (1 << 0)
475 #define VALIGN_BOTTOM (1 << 1)
476 #define VALIGN_MIDDLE (1 << 2)
477 #define VALIGN_DEFAULT VALIGN_TOP
479 #define ALIGNED_XPOS(x,w,a) ((a) == ALIGN_CENTER ? (x) - (w) / 2 : \
480 (a) == ALIGN_RIGHT ? (x) - (w) : (x))
481 #define ALIGNED_YPOS(y,h,v) ((v) == VALIGN_MIDDLE ? (y) - (h) / 2 : \
482 (v) == VALIGN_BOTTOM ? (y) - (h) : (y))
483 #define ALIGNED_TEXT_XPOS(p) ALIGNED_XPOS((p)->x, (p)->width, (p)->align)
484 #define ALIGNED_TEXT_YPOS(p) ALIGNED_YPOS((p)->y, (p)->height, (p)->valign)
485 #define ALIGNED_VP_XPOS(p) ALIGNED_TEXT_XPOS(p)
486 #define ALIGNED_VP_YPOS(p) ALIGNED_TEXT_YPOS(p)
488 // values for redraw_mask
489 #define REDRAW_NONE (0)
490 #define REDRAW_ALL (1 << 0)
491 #define REDRAW_FIELD (1 << 1)
492 #define REDRAW_DOOR_1 (1 << 2)
493 #define REDRAW_DOOR_2 (1 << 3)
494 #define REDRAW_DOOR_3 (1 << 4)
495 #define REDRAW_FPS (1 << 5)
497 #define REDRAW_DOORS (REDRAW_DOOR_1 | \
501 #define IN_GFX_FIELD_PLAY(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \
502 y >= gfx.sy && y < gfx.sy + gfx.sysize)
503 #define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \
504 x < gfx.real_sx + gfx.full_sxsize && \
505 y >= gfx.real_sy && \
506 y < gfx.real_sy + gfx.full_sysize)
507 #define IN_GFX_DOOR_1(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \
508 y >= gfx.dy && y < gfx.dy + gfx.dysize)
509 #define IN_GFX_DOOR_2(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \
510 y >= gfx.vy && y < gfx.vy + gfx.vysize)
511 #define IN_GFX_DOOR_3(x, y) (x >= gfx.ex && x < gfx.ex + gfx.exsize && \
512 y >= gfx.ey && y < gfx.ey + gfx.eysize)
514 // values for mouse cursor
515 #define CURSOR_UNDEFINED -1
516 #define CURSOR_DEFAULT 0
517 #define CURSOR_NONE 1
518 #define CURSOR_PLAYFIELD 2
520 // fundamental game speed values
521 #define ONE_SECOND_DELAY 1000 // delay value for one second
522 #define MENU_FRAME_DELAY 20 // frame delay in milliseconds
523 #define GAME_FRAME_DELAY 20 // frame delay in milliseconds
524 #define FFWD_FRAME_DELAY 10 // 200% speed for fast forward
525 #define MIN_VSYNC_FRAME_DELAY 15 // minimum value for vsync to keep
526 #define MAX_VSYNC_FRAME_DELAY 16 // maximum value for vsync to work
527 #define FRAMES_PER_SECOND (ONE_SECOND_DELAY / GAME_FRAME_DELAY)
528 #define FRAMES_PER_SECOND_SP 35
530 // maximum playfield size supported by libgame functions
531 #define MAX_PLAYFIELD_WIDTH 128
532 #define MAX_PLAYFIELD_HEIGHT 128
534 // maximum number of parallel players supported by libgame functions
535 #define MAX_PLAYERS 4
537 // maximum number of player names
538 #define MAX_PLAYER_NAMES 12
540 // maximum allowed length of player name
541 #define MAX_PLAYER_NAME_LEN 10
543 // maximum number of levels in a level set
544 #define MAX_LEVELS 1000
546 // maximum number of global animation and parts
547 #define MAX_GLOBAL_ANIMS 32
548 #define MAX_GLOBAL_ANIM_PARTS 32
550 // minimum/maximum/default x/y grid size for virtual buttons
551 #define MIN_GRID_XSIZE 3
552 #define MIN_GRID_YSIZE 3
553 #define MAX_GRID_XSIZE 32
554 #define MAX_GRID_YSIZE 32
555 #define GRID_REAL_WIDTH MAX(1, MAX(video.screen_width, \
556 video.screen_height))
557 #define GRID_REAL_HEIGHT MAX(1, MIN(video.screen_width, \
558 video.screen_height))
559 #define DEFAULT_GRID_XSIZE_0 18
560 #define DEFAULT_GRID_YSIZE_0 MIN(MAX(MIN_GRID_YSIZE, \
561 DEFAULT_GRID_XSIZE_0 * \
565 #define DEFAULT_GRID_XSIZE_1 13
566 #define DEFAULT_GRID_YSIZE_1 MIN(MAX(MIN_GRID_YSIZE, \
567 DEFAULT_GRID_XSIZE_1 * \
572 #define DEFAULT_GRID_XSIZE(n) ((n) == 0 ? DEFAULT_GRID_XSIZE_0 : \
573 DEFAULT_GRID_XSIZE_1)
574 #define DEFAULT_GRID_YSIZE(n) ((n) == 0 ? DEFAULT_GRID_YSIZE_0 : \
575 DEFAULT_GRID_YSIZE_1)
577 #define GRID_ACTIVE_NR() (video.screen_width > \
578 video.screen_height ? 0 : 1)
580 // values for grid button characters for virtual buttons
581 #define CHAR_GRID_BUTTON_NONE ' '
582 #define CHAR_GRID_BUTTON_LEFT '<'
583 #define CHAR_GRID_BUTTON_RIGHT '>'
584 #define CHAR_GRID_BUTTON_UP '^'
585 #define CHAR_GRID_BUTTON_DOWN 'v'
586 #define CHAR_GRID_BUTTON_SNAP '1'
587 #define CHAR_GRID_BUTTON_DROP '2'
589 #define GET_ACTION_FROM_GRID_BUTTON(c) ((c) == CHAR_GRID_BUTTON_LEFT ? \
591 (c) == CHAR_GRID_BUTTON_RIGHT ? \
593 (c) == CHAR_GRID_BUTTON_UP ? \
595 (c) == CHAR_GRID_BUTTON_DOWN ? \
597 (c) == CHAR_GRID_BUTTON_SNAP ? \
599 (c) == CHAR_GRID_BUTTON_DROP ? \
603 // maximum number of level sets in the level set history
604 #define MAX_LEVELDIR_HISTORY 12
606 // default name for empty highscore entry
607 #define EMPTY_PLAYER_NAME "no name"
609 // default name for unknown player names
610 #define ANONYMOUS_NAME "anonymous"
612 // default for other unknown names
613 #define UNKNOWN_NAME "unknown"
615 // default name for new levels
616 #define NAMELESS_LEVEL_NAME "nameless level"
618 // default text for non-existant artwork
619 #define NOT_AVAILABLE "(not available)"
621 // default value for undefined filename
622 #define UNDEFINED_FILENAME "[NONE]"
624 // default value for undefined levelset
625 #define UNDEFINED_LEVELSET "[NONE]"
627 // default value for undefined password
628 #define UNDEFINED_PASSWORD "[undefined]"
630 // default value for undefined parameter
631 #define ARG_DEFAULT "[DEFAULT]"
633 // default values for undefined configuration file parameters
634 #define ARG_UNDEFINED "-1000000"
635 #define ARG_UNDEFINED_VALUE (-1000000)
637 // default value for off-screen positions
638 #define POS_OFFSCREEN (-1000000)
640 // definitions for game base path and sub-directories
642 #define BASE_PATH "."
646 #define GRAPHICS_DIRECTORY "graphics"
647 #define SOUNDS_DIRECTORY "sounds"
648 #define MUSIC_DIRECTORY "music"
649 #define LEVELS_DIRECTORY "levels"
650 #define TAPES_DIRECTORY "tapes"
651 #define SCORES_DIRECTORY "scores"
652 #define DOCS_DIRECTORY "docs"
653 #define CACHE_DIRECTORY "cache"
654 #define CONF_DIRECTORY "conf"
655 #define NETWORK_DIRECTORY "network"
656 #define USERS_DIRECTORY "users"
658 #define GFX_CLASSIC_SUBDIR "gfx_classic"
659 #define SND_CLASSIC_SUBDIR "snd_classic"
660 #define MUS_CLASSIC_SUBDIR "mus_classic"
662 #define GFX_DEFAULT_SUBDIR (setup.internal.default_graphics_set)
663 #define SND_DEFAULT_SUBDIR (setup.internal.default_sounds_set)
664 #define MUS_DEFAULT_SUBDIR (setup.internal.default_music_set)
666 #define GFX_FALLBACK_FILENAME (setup.internal.fallback_graphics_file)
667 #define SND_FALLBACK_FILENAME (setup.internal.fallback_sounds_file)
668 #define MUS_FALLBACK_FILENAME (setup.internal.fallback_music_file)
670 #define DEFAULT_LEVELSET (setup.internal.default_level_series)
672 // file names and filename extensions
673 #define LEVELSETUP_DIRECTORY "levelsetup"
674 #define SETUP_FILENAME "setup.conf"
675 #define USERSETUP_FILENAME "usersetup.conf"
676 #define AUTOSETUP_FILENAME "autosetup.conf"
677 #define LEVELSETUP_FILENAME "levelsetup.conf"
678 #define SERVERSETUP_FILENAME "serversetup.conf"
679 #define EDITORSETUP_FILENAME "editorsetup.conf"
680 #define EDITORCASCADE_FILENAME "editorcascade.conf"
681 #define HELPANIM_FILENAME "helpanim.conf"
682 #define HELPTEXT_FILENAME "helptext.conf"
683 #define LEVELINFO_FILENAME "levelinfo.conf"
684 #define GRAPHICSINFO_FILENAME "graphicsinfo.conf"
685 #define SOUNDSINFO_FILENAME "soundsinfo.conf"
686 #define MUSICINFO_FILENAME "musicinfo.conf"
687 #define ARTWORKINFO_CACHE_FILE "artworkinfo.cache"
688 #define LEVELTEMPLATE_FILENAME "template.level"
689 #define UPLOADED_FILENAME ".uploaded"
690 #define LEVELFILE_EXTENSION "level"
691 #define TAPEFILE_EXTENSION "tape"
692 #define SCOREFILE_EXTENSION "score"
694 #define GAMECONTROLLER_BASENAME "gamecontrollerdb.txt"
696 #define LOG_OUT_BASENAME "stdout.txt"
697 #define LOG_ERR_BASENAME "stderr.txt"
703 #define STRING_PARENT_DIRECTORY ".."
704 #define STRING_TOP_DIRECTORY "/"
706 #define CHAR_PATH_SEPARATOR_UNIX '/'
707 #define CHAR_PATH_SEPARATOR_DOS '\\'
709 #define STRING_PATH_SEPARATOR_UNIX "/"
710 #define STRING_PATH_SEPARATOR_DOS "\\"
712 #define STRING_NEWLINE_UNIX "\n"
713 #define STRING_NEWLINE_DOS "\r\n"
715 #if defined(PLATFORM_WIN32)
716 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_DOS
717 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_DOS
718 #define STRING_NEWLINE STRING_NEWLINE_DOS
720 #define CHAR_PATH_SEPARATOR CHAR_PATH_SEPARATOR_UNIX
721 #define STRING_PATH_SEPARATOR STRING_PATH_SEPARATOR_UNIX
722 #define STRING_NEWLINE STRING_NEWLINE_UNIX
726 // areas in bitmap PIX_DOOR
727 // meaning in PIX_DB_DOOR: (3 PAGEs)
728 // PAGEX1: 1. buffer for DOOR_1
729 // PAGEX2: 2. buffer for DOOR_1
730 // PAGEX3: buffer for animations
732 // these values are hard-coded to be able to use them in initialization
733 #define DOOR_GFX_PAGE_WIDTH 100 // should be set to "gfx.dxsize"
734 #define DOOR_GFX_PAGE_HEIGHT 280 // should be set to "gfx.dysize"
736 #define DOOR_GFX_PAGESIZE (DOOR_GFX_PAGE_WIDTH)
737 #define DOOR_GFX_PAGEX1 (0 * DOOR_GFX_PAGESIZE)
738 #define DOOR_GFX_PAGEX2 (1 * DOOR_GFX_PAGESIZE)
739 #define DOOR_GFX_PAGEX3 (2 * DOOR_GFX_PAGESIZE)
740 #define DOOR_GFX_PAGEX4 (3 * DOOR_GFX_PAGESIZE)
741 #define DOOR_GFX_PAGEX5 (4 * DOOR_GFX_PAGESIZE)
742 #define DOOR_GFX_PAGEX6 (5 * DOOR_GFX_PAGESIZE)
743 #define DOOR_GFX_PAGEX7 (6 * DOOR_GFX_PAGESIZE)
744 #define DOOR_GFX_PAGEX8 (7 * DOOR_GFX_PAGESIZE)
745 #define DOOR_GFX_PAGEY1 (0)
746 #define DOOR_GFX_PAGEY2 (DOOR_GFX_PAGE_HEIGHT)
749 // macros for version handling
750 #define VERSION_PART_1(x) ((x) / 1000000)
751 #define VERSION_PART_2(x) (((x) % 1000000) / 10000)
752 #define VERSION_PART_3(x) (((x) % 10000) / 100)
753 #define VERSION_PART_4(x) ((x) % 100)
755 #define VERSION_SUPER(x) VERSION_PART_1(x)
756 #define VERSION_MAJOR(x) VERSION_PART_2(x)
757 #define VERSION_MINOR(x) VERSION_PART_3(x)
758 #define VERSION_PATCH(x) VERSION_PART_4(x)
759 #define VERSION_IDENT(a,b,c,d) ((a) * 1000000 + (b) * 10000 + (c) * 100 + (d))
762 // macros for parent/child process identification
763 #if defined(PLATFORM_UNIX)
764 #define IS_PARENT_PROCESS() (audio.mixer_pid != getpid())
765 #define IS_CHILD_PROCESS() (audio.mixer_pid == getpid())
766 #define HAS_CHILD_PROCESS() (audio.mixer_pid > 0)
768 #define IS_PARENT_PROCESS() TRUE
769 #define IS_CHILD_PROCESS() FALSE
770 #define HAS_CHILD_PROCESS() FALSE
774 // values for artwork type
775 #define ARTWORK_TYPE_GRAPHICS 0
776 #define ARTWORK_TYPE_SOUNDS 1
777 #define ARTWORK_TYPE_MUSIC 2
779 #define NUM_ARTWORK_TYPES 3
782 // values for tree type (chosen to match artwork type)
783 #define TREE_TYPE_UNDEFINED -1
784 #define TREE_TYPE_GRAPHICS_DIR ARTWORK_TYPE_GRAPHICS
785 #define TREE_TYPE_SOUNDS_DIR ARTWORK_TYPE_SOUNDS
786 #define TREE_TYPE_MUSIC_DIR ARTWORK_TYPE_MUSIC
787 #define TREE_TYPE_LEVEL_DIR 3
788 #define TREE_TYPE_LEVEL_NR 4
789 #define TREE_TYPE_PLAYER_NAME 5
791 #define NUM_BASE_TREE_TYPES 4
792 #define NUM_TREE_TYPES 6
794 #define TREE_TYPE_IS_DIR(type) ((type) == TREE_TYPE_GRAPHICS_DIR || \
795 (type) == TREE_TYPE_SOUNDS_DIR || \
796 (type) == TREE_TYPE_MUSIC_DIR || \
797 (type) == TREE_TYPE_LEVEL_DIR)
799 #define INFOTEXT_UNDEFINED ""
800 #define INFOTEXT_GRAPHICS_DIR "Custom Graphics"
801 #define INFOTEXT_SOUNDS_DIR "Custom Sounds"
802 #define INFOTEXT_MUSIC_DIR "Custom Music"
803 #define INFOTEXT_LEVEL_DIR "Level Sets"
804 #define INFOTEXT_LEVEL_NR "Levels"
805 #define INFOTEXT_PLAYER_NAME "Players & Teams"
807 #define BACKLINK_TEXT_MAIN ".. (main menu)"
808 #define BACKLINK_TEXT_SETUP ".. (setup menu)"
809 #define BACKLINK_TEXT_PARENT ".. (parent directory)"
811 #define TREE_INFOTEXT(t) ((t) == TREE_TYPE_PLAYER_NAME ? \
812 INFOTEXT_PLAYER_NAME : \
813 (t) == TREE_TYPE_LEVEL_NR ? \
814 INFOTEXT_LEVEL_NR : \
815 (t) == TREE_TYPE_LEVEL_DIR ? \
816 INFOTEXT_LEVEL_DIR : \
817 (t) == TREE_TYPE_GRAPHICS_DIR ? \
818 INFOTEXT_GRAPHICS_DIR : \
819 (t) == TREE_TYPE_SOUNDS_DIR ? \
820 INFOTEXT_SOUNDS_DIR : \
821 (t) == TREE_TYPE_MUSIC_DIR ? \
822 INFOTEXT_MUSIC_DIR : \
825 #define TREE_BACKLINK_TEXT(t) ((t) == TREE_TYPE_LEVEL_DIR ? \
826 BACKLINK_TEXT_MAIN : \
829 #define TREE_USERDIR(t) ((t) == TREE_TYPE_LEVEL_DIR ? \
830 getUserLevelDir(NULL) : \
831 (t) == TREE_TYPE_GRAPHICS_DIR ? \
832 getUserGraphicsDir() : \
833 (t) == TREE_TYPE_SOUNDS_DIR ? \
834 getUserSoundsDir() : \
835 (t) == TREE_TYPE_MUSIC_DIR ? \
836 getUserMusicDir() : \
839 #define TREE_FIRST_NODE_PTR(t) ((t) == TREE_TYPE_LEVEL_DIR ? \
841 (t) == TREE_TYPE_GRAPHICS_DIR ? \
842 &artwork.gfx_first : \
843 (t) == TREE_TYPE_SOUNDS_DIR ? \
844 &artwork.snd_first : \
845 (t) == TREE_TYPE_MUSIC_DIR ? \
846 &artwork.mus_first : \
849 #define TREE_FIRST_NODE(t) ((t) == TREE_TYPE_LEVEL_DIR ? \
851 (t) == TREE_TYPE_GRAPHICS_DIR ? \
852 artwork.gfx_first : \
853 (t) == TREE_TYPE_SOUNDS_DIR ? \
854 artwork.snd_first : \
855 (t) == TREE_TYPE_MUSIC_DIR ? \
856 artwork.mus_first : \
859 // values for artwork handling
860 #define LEVELDIR_ARTWORK_SET_PTR(leveldir, type) \
861 ((type) == ARTWORK_TYPE_GRAPHICS ? \
862 &(leveldir)->graphics_set : \
863 (type) == ARTWORK_TYPE_SOUNDS ? \
864 &(leveldir)->sounds_set : \
865 &(leveldir)->music_set)
867 #define LEVELDIR_ARTWORK_SET(leveldir, type) \
868 ((type) == ARTWORK_TYPE_GRAPHICS ? \
869 (leveldir)->graphics_set : \
870 (type) == ARTWORK_TYPE_SOUNDS ? \
871 (leveldir)->sounds_set : \
872 (leveldir)->music_set)
874 #define LEVELDIR_ARTWORK_PATH_PTR(leveldir, type) \
875 ((type) == ARTWORK_TYPE_GRAPHICS ? \
876 &(leveldir)->graphics_path : \
877 (type) == ARTWORK_TYPE_SOUNDS ? \
878 &(leveldir)->sounds_path : \
879 &(leveldir)->music_path)
881 #define LEVELDIR_ARTWORK_PATH(leveldir, type) \
882 ((type) == ARTWORK_TYPE_GRAPHICS ? \
883 (leveldir)->graphics_path : \
884 (type) == ARTWORK_TYPE_SOUNDS ? \
885 (leveldir)->sounds_path : \
886 (leveldir)->music_path)
888 #define SETUP_ARTWORK_SET(setup, type) \
889 ((type) == ARTWORK_TYPE_GRAPHICS ? \
890 (setup).graphics_set : \
891 (type) == ARTWORK_TYPE_SOUNDS ? \
892 (setup).sounds_set : \
895 #define SETUP_OVERRIDE_ARTWORK(setup, type) \
896 ((type) == ARTWORK_TYPE_GRAPHICS ? \
897 (setup).override_level_graphics : \
898 (type) == ARTWORK_TYPE_SOUNDS ? \
899 (setup).override_level_sounds : \
900 (setup).override_level_music)
902 #define GFX_OVERRIDE_ARTWORK(type) \
903 ((type) == ARTWORK_TYPE_GRAPHICS ? \
904 gfx.override_level_graphics : \
905 (type) == ARTWORK_TYPE_SOUNDS ? \
906 gfx.override_level_sounds : \
907 gfx.override_level_music)
909 #define ARTWORK_FIRST_NODE(artwork, type) \
910 ((type) == ARTWORK_TYPE_GRAPHICS ? \
911 (artwork).gfx_first : \
912 (type) == ARTWORK_TYPE_SOUNDS ? \
913 (artwork).snd_first : \
916 #define ARTWORK_CURRENT_PTR(artwork, type) \
917 ((type) == ARTWORK_TYPE_GRAPHICS ? \
918 &(artwork).gfx_current : \
919 (type) == ARTWORK_TYPE_SOUNDS ? \
920 &(artwork).snd_current : \
921 &(artwork).mus_current)
923 #define ARTWORK_CURRENT(artwork, type) \
924 ((type) == ARTWORK_TYPE_GRAPHICS ? \
925 (artwork).gfx_current : \
926 (type) == ARTWORK_TYPE_SOUNDS ? \
927 (artwork).snd_current : \
928 (artwork).mus_current)
930 #define ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type) \
931 ((type) == ARTWORK_TYPE_GRAPHICS ? \
932 &(artwork).gfx_current_identifier : \
933 (type) == ARTWORK_TYPE_SOUNDS ? \
934 &(artwork).snd_current_identifier : \
935 &(artwork).mus_current_identifier)
937 #define ARTWORK_CURRENT_IDENTIFIER(artwork, type) \
938 ((type) == ARTWORK_TYPE_GRAPHICS ? \
939 (artwork).gfx_current_identifier : \
940 (type) == ARTWORK_TYPE_SOUNDS ? \
941 (artwork).snd_current_identifier : \
942 (artwork).mus_current_identifier)
944 #define ARTWORKINFO_FILENAME(type) \
945 ((type) == ARTWORK_TYPE_GRAPHICS ? \
946 GRAPHICSINFO_FILENAME : \
947 (type) == ARTWORK_TYPE_SOUNDS ? \
948 SOUNDSINFO_FILENAME : \
949 (type) == ARTWORK_TYPE_MUSIC ? \
950 MUSICINFO_FILENAME : "")
952 #define ARTWORK_DIRECTORY(type) \
953 ((type) == ARTWORK_TYPE_GRAPHICS ? \
954 GRAPHICS_DIRECTORY : \
955 (type) == ARTWORK_TYPE_SOUNDS ? \
957 (type) == ARTWORK_TYPE_MUSIC ? \
958 MUSIC_DIRECTORY : "")
960 #define OPTIONS_ARTWORK_DIRECTORY(type) \
961 ((type) == ARTWORK_TYPE_GRAPHICS ? \
962 options.graphics_directory : \
963 (type) == ARTWORK_TYPE_SOUNDS ? \
964 options.sounds_directory : \
965 (type) == ARTWORK_TYPE_MUSIC ? \
966 options.music_directory : "")
968 #define USER_ARTWORK_DIRECTORY(type) \
969 ((type) == ARTWORK_TYPE_GRAPHICS ? \
970 getUserGraphicsDir() : \
971 (type) == ARTWORK_TYPE_SOUNDS ? \
972 getUserSoundsDir() : \
973 (type) == ARTWORK_TYPE_MUSIC ? \
974 getUserMusicDir() : "")
976 #define ARTWORK_DEFAULT_SUBDIR(type) \
977 ((type) == ARTWORK_TYPE_GRAPHICS ? \
978 GFX_DEFAULT_SUBDIR : \
979 (type) == ARTWORK_TYPE_SOUNDS ? \
980 SND_DEFAULT_SUBDIR : \
983 #define UPDATE_BUSY_STATE() \
985 if (gfx.draw_busy_anim_function != NULL) \
986 gfx.draw_busy_anim_function(); \
990 // structure definitions
994 char *command_basepath; // path to the program binary
995 char *command_basename; // base filename of the program binary
997 char *config_filename; // optional global program config filename
999 char *maindata_path; // main game data (installation) directory
1001 char *userdata_subdir; // personal user game data directory
1002 char *userdata_path; // resulting full path to game data directory
1004 char *program_title;
1008 char *icon_filename;
1010 char *cookie_prefix;
1012 char *log_filename[NUM_LOGS]; // log filenames for out/err messages
1013 FILE *log_file[NUM_LOGS]; // log file handles for out/err files
1014 FILE *log_file_default[NUM_LOGS]; // default log file handles (out/err)
1022 char *version_string;
1024 char *(*window_title_function)(void);
1025 void (*exit_message_function)(char *, va_list);
1026 void (*exit_function)(int);
1028 int api_thread_count;
1042 SDL_Thread *server_thread;
1043 boolean is_server_thread;
1048 boolean uses_touch_device;
1050 boolean use_api_server;
1058 char *base_directory;
1059 char *level_directory;
1060 char *graphics_directory;
1061 char *sounds_directory;
1062 char *music_directory;
1063 char *docs_directory;
1064 char *conf_directory;
1066 char *execute_command;
1067 char *tape_log_filename;
1069 char *special_flags;
1083 struct VideoSystemInfo
1086 int width, height, depth;
1087 int window_width, window_height;
1088 int display_width, display_height;
1089 int screen_width, screen_height;
1090 int screen_xoffset, screen_yoffset;
1092 boolean fullscreen_available;
1093 boolean fullscreen_enabled;
1094 boolean fullscreen_initial;
1096 boolean window_scaling_available;
1097 int window_scaling_percent;
1098 char *window_scaling_quality;
1099 int screen_rendering_mode;
1102 unsigned int frame_counter;
1103 unsigned int frame_delay;
1104 unsigned int frame_delay_value;
1108 int shifted_up_pos_last;
1109 unsigned int shifted_up_delay;
1110 unsigned int shifted_up_delay_value;
1112 boolean initialized;
1115 struct AudioSystemInfo
1117 boolean sound_available;
1118 boolean loops_available;
1119 boolean music_available;
1121 boolean sound_enabled;
1122 boolean sound_deactivated; // for temporarily disabling sound
1131 int first_sound_channel;
1134 struct FontBitmapInfo
1138 int src_x, src_y; // start position of font characters
1139 int width, height; // width / height of font characters
1141 int offset_x; // offset to next font character
1142 int offset_y; // offset to next font character
1144 int draw_xoffset; // offset for drawing font characters
1145 int draw_yoffset; // offset for drawing font characters
1148 int num_chars_per_line;
1155 int real_sx, real_sy;
1156 int full_sxsize, full_sysize;
1157 int scrollbuffer_width, scrollbuffer_height;
1159 int game_tile_size, standard_tile_size;
1170 int win_xsize, win_ysize;
1172 int draw_deactivation_mask;
1173 int draw_background_mask;
1175 Bitmap *field_save_buffer;
1177 Bitmap *background_bitmap;
1178 int background_bitmap_mask;
1180 Bitmap *fade_bitmap_backup;
1181 Bitmap *fade_bitmap_source;
1182 Bitmap *fade_bitmap_target;
1183 Bitmap *fade_bitmap_black;
1185 int fade_border_source_status;
1186 int fade_border_target_status;
1187 Bitmap *masked_border_bitmap_ptr;
1189 Bitmap *final_screen_bitmap;
1191 boolean clipping_enabled;
1193 int clip_width, clip_height;
1195 boolean override_level_graphics;
1196 boolean override_level_sounds;
1197 boolean override_level_music;
1199 boolean draw_init_text;
1202 struct FontBitmapInfo *font_bitmap_info;
1203 int (*select_font_function)(int);
1204 int (*get_font_from_token_function)(char *);
1206 int anim_random_frame;
1208 void (*draw_busy_anim_function)(void);
1209 void (*draw_global_anim_function)(int, int);
1210 void (*draw_global_border_function)(int);
1211 void (*draw_tile_cursor_function)(int);
1214 int cursor_mode_override;
1215 int cursor_mode_final;
1216 int mouse_x, mouse_y;
1219 struct TileCursorInfo
1221 boolean enabled; // tile cursor generally enabled or disabled
1222 boolean active; // tile cursor activated (depending on game)
1223 boolean moving; // tile cursor moving to target position
1225 int xpos, ypos; // tile cursor level playfield position
1226 int x, y; // tile cursor current screen position
1227 int target_x, target_y; // tile cursor target screen position
1229 int sx, sy; // tile cursor screen start position
1231 boolean xsn_debug; // enable or disable XSN debugging
1236 boolean enabled; // overlay generally enabled or disabled
1237 boolean active; // overlay activated (depending on game mode)
1244 char grid_button[MAX_GRID_XSIZE][MAX_GRID_YSIZE];
1245 char grid_button_highlight;
1247 int grid_button_action;
1253 int nr[MAX_PLAYERS]; // joystick number for each player
1256 struct SetupJoystickInfo
1258 char *device_name; // device name of player's joystick
1260 int xleft, xmiddle, xright;
1261 int yupper, ymiddle, ylower;
1265 struct SetupKeyboardInfo
1267 Key left, right, up, down;
1271 struct SetupTouchInfo
1280 char grid_button[2][MAX_GRID_XSIZE][MAX_GRID_YSIZE];
1282 int transparency; // in percent (0 == opaque, 100 == invisible)
1283 boolean draw_outlined;
1284 boolean draw_pressed;
1286 boolean grid_initialized;
1289 struct SetupInputInfo
1291 boolean use_joystick;
1292 struct SetupJoystickInfo joy;
1293 struct SetupKeyboardInfo key;
1296 struct SetupEditorInfo
1298 boolean el_boulderdash;
1299 boolean el_emerald_mine;
1300 boolean el_emerald_mine_club;
1303 boolean el_supaplex;
1304 boolean el_diamond_caves;
1305 boolean el_dx_boulderdash;
1307 boolean el_mirror_magic;
1308 boolean el_deflektor;
1311 boolean el_steel_chars;
1315 boolean el_user_defined;
1318 boolean el_headlines;
1323 boolean show_element_token;
1325 boolean show_read_only_warning;
1327 boolean use_template_for_new_levels;
1330 struct SetupAutoSetupInfo
1332 int editor_zoom_tilesize;
1335 struct SetupLevelSetupInfo
1337 char *last_level_series[MAX_LEVELDIR_HISTORY + 1];
1340 struct SetupEditorCascadeInfo
1353 boolean el_steel_chars;
1361 struct SetupShortcutInfo
1367 Key focus_player[MAX_PLAYERS];
1368 Key focus_player_all;
1387 struct SetupSystemInfo
1389 char *sdl_renderdriver;
1390 char *sdl_videodriver;
1391 char *sdl_audiodriver;
1392 int audio_fragment_size;
1395 struct SetupInternalInfo
1397 char *program_title;
1398 char *program_version;
1399 char *program_author;
1400 char *program_email;
1401 char *program_website;
1402 char *program_copyright;
1403 char *program_company;
1405 char *program_icon_file;
1407 char *default_graphics_set;
1408 char *default_sounds_set;
1409 char *default_music_set;
1411 char *fallback_graphics_file;
1412 char *fallback_sounds_file;
1413 char *fallback_music_file;
1415 char *default_level_series;
1417 int default_window_width;
1418 int default_window_height;
1420 boolean choose_from_top_leveldir;
1421 boolean show_scaling_in_title;
1422 boolean create_user_levelset;
1425 boolean menu_engines;
1426 boolean menu_editor;
1427 boolean menu_graphics;
1429 boolean menu_artwork;
1432 boolean menu_shortcuts;
1434 boolean menu_save_and_exit;
1437 struct SetupDebugInfo
1439 int frame_delay[10];
1440 Key frame_delay_key[10];
1441 boolean frame_delay_use_mod_key;
1442 boolean frame_delay_game_only;
1443 boolean show_frames_per_second;
1454 boolean multiple_users;
1457 boolean sound_loops;
1458 boolean sound_music;
1459 boolean sound_simple;
1461 boolean scroll_delay;
1462 boolean forced_scroll_delay;
1463 int scroll_delay_value;
1464 char *engine_snapshot_mode;
1465 int engine_snapshot_memory;
1466 boolean fade_screens;
1468 boolean show_titlescreen;
1469 boolean quick_doors;
1472 boolean skip_levels;
1473 boolean increment_levels;
1474 boolean auto_play_next_level;
1475 boolean count_score_after_game;
1476 boolean show_scores_after_game;
1479 int window_scaling_percent;
1480 char *window_scaling_quality;
1481 char *screen_rendering_mode;
1483 boolean ask_on_escape;
1484 boolean ask_on_escape_editor;
1485 boolean ask_on_game_over;
1486 boolean ask_on_quit_game;
1487 boolean ask_on_quit_program;
1488 boolean quick_switch;
1489 boolean input_on_focus;
1490 boolean prefer_aga_graphics;
1491 boolean prefer_lowpass_sounds;
1492 boolean prefer_extra_panel_items;
1493 boolean game_speed_extended;
1494 int game_frame_delay;
1495 boolean sp_show_border_elements;
1496 boolean small_game_graphics;
1497 boolean show_load_save_buttons;
1498 boolean show_undo_redo_buttons;
1499 char *scores_in_highscore_list;
1504 int override_level_graphics; // not boolean -- can also be "AUTO"
1505 int override_level_sounds; // not boolean -- can also be "AUTO"
1506 int override_level_music; // not boolean -- can also be "AUTO"
1512 boolean network_mode;
1513 int network_player_nr;
1514 char *network_server_hostname;
1516 boolean use_api_server;
1517 char *api_server_hostname;
1518 char *api_server_password;
1519 boolean ask_for_uploading_tapes;
1520 boolean ask_for_remaining_tapes;
1521 boolean provide_uploading_tapes;
1522 boolean ask_for_using_api_server;
1523 boolean has_remaining_tapes;
1525 struct SetupAutoSetupInfo auto_setup;
1526 struct SetupLevelSetupInfo level_setup;
1528 struct SetupEditorInfo editor;
1529 struct SetupEditorCascadeInfo editor_cascade;
1530 struct SetupShortcutInfo shortcut;
1531 struct SetupInputInfo input[MAX_PLAYERS];
1532 struct SetupTouchInfo touch;
1533 struct SetupSystemInfo system;
1534 struct SetupInternalInfo internal;
1535 struct SetupDebugInfo debug;
1537 struct OptionInfo options;
1547 struct TreeInfo **node_top; // topmost node in tree
1548 struct TreeInfo *node_parent; // parent level directory info
1549 struct TreeInfo *node_group; // level group sub-directory info
1550 struct TreeInfo *next; // next level series structure node
1552 int cl_first; // internal control field for setup screen
1553 int cl_cursor; // internal control field for setup screen
1555 int type; // type of tree content
1557 // fields for "type == TREE_TYPE_LEVEL_DIR"
1559 char *subdir; // tree info sub-directory basename (may be ".")
1560 char *fullpath; // complete path relative to tree base directory
1561 char *basepath; // absolute base path of tree base directory
1562 char *identifier; // identifier string for configuration files
1563 char *name; // tree info name, as displayed in selection menues
1564 char *name_sorting; // optional sorting name for correct name sorting
1565 char *author; // level or artwork author name
1566 char *year; // optional year of creation for levels or artwork
1568 char *program_title; // optional alternative text for program title
1569 char *program_copyright; // optional alternative text for program copyright
1570 char *program_company; // optional alternative text for program company
1572 char *imported_from; // optional comment for imported levels or artwork
1573 char *imported_by; // optional comment for imported levels or artwork
1574 char *tested_by; // optional comment to name people who tested a set
1576 char *graphics_set_ecs; // special EMC custom graphics set (ECS graphics)
1577 char *graphics_set_aga; // special EMC custom graphics set (AGA graphics)
1578 char *graphics_set; // optional custom graphics set (level tree only)
1579 char *sounds_set_default; // default EMC custom sounds set
1580 char *sounds_set_lowpass; // special EMC custom sounds set (lowpass filter)
1581 char *sounds_set; // optional custom sounds set (level tree only)
1582 char *music_set; // optional custom music set (level tree only)
1583 char *graphics_path; // path to optional custom graphics set (level only)
1584 char *sounds_path; // path to optional custom sounds set (level only)
1585 char *music_path; // path to optional custom music set (level only)
1587 char *level_filename; // filename of level file (for packed level file)
1588 char *level_filetype; // type of levels in level directory or level file
1590 char *special_flags; // flags for special actions performed on level file
1592 int levels; // number of levels in level series
1593 int first_level; // first level number (to allow start with 0 or 1)
1594 int last_level; // last level number (automatically calculated)
1595 int sort_priority; // sort levels by 'sort_priority' and then by name
1597 boolean latest_engine;// force level set to use the latest game engine
1599 boolean level_group; // directory contains more level series directories
1600 boolean parent_link; // entry links back to parent directory
1601 boolean is_copy; // this entry is a copy of another entry in the tree
1602 boolean in_user_dir; // user defined levels are stored in home directory
1603 boolean user_defined; // levels in user directory and marked as "private"
1604 boolean readonly; // readonly levels can not be changed with editor
1605 boolean handicap; // level set has no handicap when set to "false"
1606 boolean skip_levels; // levels can be skipped when set to "true"
1608 boolean use_emc_tiles;// use (swapped) V5/V6 EMC tiles when set to "true"
1610 int color; // color to use on selection screen for this level
1611 char *class_desc; // description of level series class
1612 int handicap_level; // number of the lowest unsolved level
1614 char *infotext; // optional text to describe the tree type (headline)
1617 typedef struct TreeInfo TreeInfo;
1618 typedef struct TreeInfo LevelDirTree;
1619 typedef struct TreeInfo ArtworkDirTree;
1620 typedef struct TreeInfo GraphicsDirTree;
1621 typedef struct TreeInfo SoundsDirTree;
1622 typedef struct TreeInfo MusicDirTree;
1626 GraphicsDirTree *gfx_first;
1627 GraphicsDirTree *gfx_current;
1628 SoundsDirTree *snd_first;
1629 SoundsDirTree *snd_current;
1630 MusicDirTree *mus_first;
1631 MusicDirTree *mus_current;
1633 char *gfx_current_identifier;
1634 char *snd_current_identifier;
1635 char *mus_current_identifier;
1638 struct ValueTextInfo
1644 struct StringValueTextInfo
1656 struct ConfigTypeInfo
1663 struct TokenIntPtrInfo
1673 char *default_filename;
1676 char **default_parameter; // array of file parameters
1677 char **parameter; // array of file parameters
1680 boolean fallback_to_default;
1681 boolean default_is_cloned;
1684 struct SetupFileList
1689 struct SetupFileList *next;
1694 char *source_filename; // primary key for node list
1698 struct PropertyMapping
1708 struct ArtworkListInfo
1710 int type; // type of artwork
1712 int num_file_list_entries;
1713 int num_dynamic_file_list_entries;
1714 struct FileInfo *file_list; // static artwork file array
1715 struct FileInfo *dynamic_file_list; // dynamic artwrk file array
1717 int num_suffix_list_entries;
1718 struct ConfigTypeInfo *suffix_list; // parameter suffixes array
1720 int num_base_prefixes;
1721 int num_ext1_suffixes;
1722 int num_ext2_suffixes;
1723 int num_ext3_suffixes;
1724 char **base_prefixes; // base token prefixes array
1725 char **ext1_suffixes; // property suffixes array 1
1726 char **ext2_suffixes; // property suffixes array 2
1727 char **ext3_suffixes; // property suffixes array 3
1729 int num_ignore_tokens;
1730 char **ignore_tokens; // file tokens to be ignored
1732 int num_property_mapping_entries;
1733 struct PropertyMapping *property_mapping; // mapping token -> artwork
1735 int sizeof_artwork_list_entry;
1737 struct ListNodeInfo **artwork_list; // static artwork node array
1738 struct ListNodeInfo **dynamic_artwork_list; // dynamic artwrk node array
1739 struct ListNode *content_list; // dynamic artwork node list
1741 void *(*load_artwork)(char *); // constructor function
1742 void (*free_artwork)(void *); // destructor function
1762 struct RectWithBorder
1766 int min_width, min_height;
1767 int max_width, max_height;
1788 struct DoorPartPosInfo
1795 int start_step_opening;
1796 int start_step_closing;
1797 boolean draw_masked;
1804 int xoffset; // special case for tape date and time
1805 int xoffset2; // special case for tape date
1806 int yoffset; // special case for list of preview players
1809 int size; // also used for suffix ".digits"
1811 boolean draw_masked;
1812 boolean draw_player; // special case for network player buttons
1813 int sort_priority; // also used for suffix ".draw_order"
1816 int direction; // needed for panel time/health graphics
1817 int class; // needed for panel time/health graphics
1818 int style; // needed for panel time/health graphics
1820 int tile_size; // special case for list of network players
1821 int border_size; // special case for list of preview players
1822 int vertical; // special case for list of preview players
1824 boolean redefined; // redefined by custom artwork
1827 struct MouseActionInfo
1836 int music[MAX_LEVELS];
1849 // ============================================================================
1850 // exported variables
1851 // ============================================================================
1853 extern struct ProgramInfo program;
1854 extern struct NetworkInfo network;
1855 extern struct RuntimeInfo runtime;
1856 extern struct OptionInfo options;
1857 extern struct VideoSystemInfo video;
1858 extern struct AudioSystemInfo audio;
1859 extern struct GfxInfo gfx;
1860 extern struct TileCursorInfo tile_cursor;
1861 extern struct OverlayInfo overlay;
1862 extern struct AnimInfo anim;
1863 extern struct ArtworkInfo artwork;
1864 extern struct JoystickInfo joystick;
1865 extern struct SetupInfo setup;
1866 extern struct UserInfo user;
1868 extern LevelDirTree *leveldir_first_all;
1869 extern LevelDirTree *leveldir_first;
1870 extern LevelDirTree *leveldir_current;
1871 extern int level_nr;
1873 extern struct LevelSetInfo levelset;
1874 extern struct LevelStats level_stats[];
1876 extern DrawWindow *window;
1877 extern DrawBuffer *backbuffer;
1878 extern DrawBuffer *drawto;
1880 extern int button_status;
1881 extern boolean motion_status;
1882 extern int wheel_steps;
1883 extern boolean keyrepeat_status;
1884 extern boolean textinput_status;
1886 extern int redraw_mask;
1888 extern int FrameCounter;
1891 // function definitions
1893 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
1895 void InitNetworkInfo(boolean, boolean, boolean, char *, int);
1896 void InitRuntimeInfo(void);
1898 void SetWindowTitle(void);
1900 void InitWindowTitleFunction(char *(*window_title_function)(void));
1901 void InitExitMessageFunction(void (*exit_message_function)(char *, va_list));
1902 void InitExitFunction(void (*exit_function)(int));
1903 void InitPlatformDependentStuff(void);
1904 void ClosePlatformDependentStuff(void);
1906 void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *);
1907 void InitGfxTileSizeInfo(int, int);
1908 void InitGfxDoor1Info(int, int, int, int);
1909 void InitGfxDoor2Info(int, int, int, int);
1910 void InitGfxDoor3Info(int, int, int, int);
1911 void InitGfxWindowInfo(int, int);
1912 void InitGfxScrollbufferInfo(int, int);
1913 void InitGfxClipRegion(boolean, int, int, int, int);
1914 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
1915 void InitGfxDrawGlobalAnimFunction(void (*draw_global_anim_function)(int, int));
1916 void InitGfxDrawGlobalBorderFunction(void (*draw_global_border_function)(int));
1917 void InitGfxDrawTileCursorFunction(void (*draw_tile_cursor_function)(int));
1918 void InitGfxCustomArtworkInfo(void);
1919 void InitGfxOtherSettings(void);
1920 void InitTileCursorInfo(void);
1921 void InitOverlayInfo(void);
1922 void SetOverlayGridSizeAndButtons(void);
1923 void SetTileCursorEnabled(boolean);
1924 void SetTileCursorActive(boolean);
1925 void SetTileCursorTargetXY(int, int);
1926 void SetTileCursorXY(int, int);
1927 void SetTileCursorSXSY(int, int);
1928 void SetOverlayEnabled(boolean);
1929 void SetOverlayActive(boolean);
1930 void SetOverlayShowGrid(boolean);
1931 boolean GetOverlayEnabled(void);
1932 boolean GetOverlayActive(void);
1933 void SetDrawDeactivationMask(int);
1934 int GetDrawDeactivationMask(void);
1935 void SetDrawBackgroundMask(int);
1936 void SetWindowBackgroundBitmap(Bitmap *);
1937 void SetMainBackgroundBitmap(Bitmap *);
1938 void SetDoorBackgroundBitmap(Bitmap *);
1939 void SetRedrawMaskFromArea(int, int, int, int);
1941 void LimitScreenUpdates(boolean);
1943 void InitVideoDefaults(void);
1944 void InitVideoDisplay(void);
1945 void CloseVideoDisplay(void);
1946 void InitVideoBuffer(int, int, int, boolean);
1947 Bitmap *CreateBitmapStruct(void);
1948 Bitmap *CreateBitmap(int, int, int);
1949 void ReCreateBitmap(Bitmap **, int, int);
1950 void FreeBitmap(Bitmap *);
1951 void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int);
1952 void BlitBitmapTiled(Bitmap *, Bitmap *, int, int, int, int, int, int, int,int);
1953 void FadeRectangle(int, int, int, int, int, int, int,
1954 void (*draw_border_function)(void));
1955 void FillRectangle(Bitmap *, int, int, int, int, Pixel);
1956 void ClearRectangle(Bitmap *, int, int, int, int);
1957 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
1958 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
1959 boolean DrawingDeactivatedField(void);
1960 boolean DrawingDeactivated(int, int, int, int);
1961 boolean DrawingOnBackground(int, int);
1962 boolean DrawingAreaChanged(void);
1963 void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int);
1964 void BlitTexture(Bitmap *, int, int, int, int, int, int);
1965 void BlitTextureMasked(Bitmap *, int, int, int, int, int, int);
1966 void BlitToScreen(Bitmap *, int, int, int, int, int, int);
1967 void BlitToScreenMasked(Bitmap *, int, int, int, int, int, int);
1968 void DrawSimpleBlackLine(Bitmap *, int, int, int, int);
1969 void DrawSimpleWhiteLine(Bitmap *, int, int, int, int);
1970 void DrawLines(Bitmap *, struct XY *, int, Pixel);
1971 Pixel GetPixel(Bitmap *, int, int);
1972 Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int);
1973 Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int);
1975 void KeyboardAutoRepeatOn(void);
1976 void KeyboardAutoRepeatOff(void);
1977 boolean SetVideoMode(boolean);
1978 void SetVideoFrameDelay(unsigned int);
1979 unsigned int GetVideoFrameDelay(void);
1980 boolean ChangeVideoModeIfNeeded(boolean);
1982 Bitmap *LoadImage(char *);
1983 Bitmap *LoadCustomImage(char *);
1984 void ReloadCustomImage(Bitmap *, char *);
1986 Bitmap *ZoomBitmap(Bitmap *, int, int);
1987 void ReCreateGameTileSizeBitmap(Bitmap **);
1988 void CreateBitmapWithSmallBitmaps(Bitmap **, int, int);
1989 void CreateBitmapTextures(Bitmap **);
1990 void FreeBitmapTextures(Bitmap **);
1991 void ScaleBitmap(Bitmap **, int);
1993 void SetMouseCursor(int);
1994 void UpdateRawMousePosition(int, int);
1995 void UpdateMousePosition(void);
1997 void OpenAudio(void);
1998 void CloseAudio(void);
1999 void SetAudioMode(boolean);
2001 void InitEventFilter(EventFilter);
2002 boolean PendingEvent(void);
2003 void WaitEvent(Event *event);
2004 void PeekEvent(Event *event);
2005 void PumpEvents(void);
2006 void CheckQuitEvent(void);
2007 Key GetEventKey(KeyEvent *, boolean);
2008 KeyMod HandleKeyModState(Key, int);
2009 KeyMod GetKeyModState(void);
2010 KeyMod GetKeyModStateFromEvents(void);
2011 void StartTextInput(int, int, int, int);
2012 void StopTextInput(void);
2013 void PushUserEvent(int, int, int);
2015 void InitJoysticks(void);
2016 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
2017 boolean CheckJoystickOpened(int);
2018 void ClearJoystickState(void);
2020 void InitEmscriptenFilesystem(void);
2021 void SyncEmscriptenFilesystem(void);