1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
18 #include "SDL_image.h"
19 #include "SDL_mixer.h"
21 #include "SDL_thread.h"
24 /* definitions needed for "system.c" */
26 #define SURFACE_FLAGS (SDL_SWSURFACE)
28 /* system dependent definitions */
30 #define TARGET_STRING "SDL"
31 #define FULLSCREEN_STATUS FULLSCREEN_AVAILABLE
33 #define CURSOR_MAX_WIDTH 32
34 #define CURSOR_MAX_HEIGHT 32
37 /* SDL type definitions */
39 typedef struct SDLSurfaceInfo Bitmap;
40 typedef struct SDLSurfaceInfo DrawBuffer;
41 typedef struct SDLSurfaceInfo DrawWindow;
43 typedef SDL_Cursor *Cursor;
46 typedef unsigned int KeyMod;
48 typedef SDL_Event Event;
49 typedef SDL_MouseButtonEvent ButtonEvent;
50 typedef SDL_MouseMotionEvent MotionEvent;
51 typedef SDL_KeyboardEvent KeyEvent;
52 typedef SDL_Event ExposeEvent;
53 typedef SDL_Event FocusChangeEvent;
54 typedef SDL_Event ClientMessageEvent;
63 /* structure definitions */
67 char *source_filename;
71 SDL_Surface *surface_masked;
76 struct MouseCursorInfo
81 char data[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
82 char mask[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
91 /* SDL symbol definitions */
95 #define BLACK_PIXEL 0x000000
96 #define WHITE_PIXEL 0xffffff
98 #define EVENT_BUTTONPRESS SDL_MOUSEBUTTONDOWN
99 #define EVENT_BUTTONRELEASE SDL_MOUSEBUTTONUP
100 #define EVENT_MOTIONNOTIFY SDL_MOUSEMOTION
101 #define EVENT_KEYPRESS SDL_KEYDOWN
102 #define EVENT_KEYRELEASE SDL_KEYUP
103 #define EVENT_EXPOSE SDL_USEREVENT + 0
104 #define EVENT_FOCUSIN SDL_USEREVENT + 1
105 #define EVENT_FOCUSOUT SDL_USEREVENT + 2
106 #define EVENT_CLIENTMESSAGE SDL_QUIT
107 #define EVENT_MAPNOTIFY SDL_USEREVENT + 4
108 #define EVENT_UNMAPNOTIFY SDL_USEREVENT + 5
110 #define KSYM_UNDEFINED SDLK_UNKNOWN
112 #define KSYM_Return SDLK_RETURN
113 #define KSYM_Escape SDLK_ESCAPE
115 #define KSYM_Left SDLK_LEFT
116 #define KSYM_Right SDLK_RIGHT
117 #define KSYM_Up SDLK_UP
118 #define KSYM_Down SDLK_DOWN
121 #define KSYM_KP_Left SDLK_KP_LEFT
122 #define KSYM_KP_Right SDLK_KP_RIGHT
123 #define KSYM_KP_Up SDLK_KP_UP
124 #define KSYM_KP_Down SDLK_KP_DOWN
127 #define KSYM_KP_Enter SDLK_KP_ENTER
128 #define KSYM_KP_Add SDLK_KP_PLUS
129 #define KSYM_KP_Subtract SDLK_KP_MINUS
130 #define KSYM_KP_Multiply SDLK_KP_MULTIPLY
131 #define KSYM_KP_Divide SDLK_KP_DIVIDE
132 #define KSYM_KP_Separator SDLK_KP_PERIOD
134 #define KSYM_Shift_L SDLK_LSHIFT
135 #define KSYM_Shift_R SDLK_RSHIFT
136 #define KSYM_Control_L SDLK_LCTRL
137 #define KSYM_Control_R SDLK_RCTRL
138 #define KSYM_Meta_L SDLK_LMETA
139 #define KSYM_Meta_R SDLK_RMETA
140 #define KSYM_Alt_L SDLK_LALT
141 #define KSYM_Alt_R SDLK_RALT
142 #define KSYM_Super_L SDLK_LSUPER
143 #define KSYM_Super_R SDLK_RSUPER
144 #define KSYM_Mode_switch SDLK_MODE
145 #define KSYM_Multi_key SDLK_RCTRL
147 #define KSYM_BackSpace SDLK_BACKSPACE
148 #define KSYM_Delete SDLK_DELETE
149 #define KSYM_Insert SDLK_INSERT
150 #define KSYM_Tab SDLK_TAB
151 #define KSYM_Home SDLK_HOME
152 #define KSYM_End SDLK_END
153 #define KSYM_Page_Up SDLK_PAGEUP
154 #define KSYM_Page_Down SDLK_PAGEDOWN
155 #define KSYM_Menu SDLK_MENU
157 #define KSYM_space SDLK_SPACE
158 #define KSYM_exclam SDLK_EXCLAIM
159 #define KSYM_quotedbl SDLK_QUOTEDBL
160 #define KSYM_numbersign SDLK_HASH
161 #define KSYM_dollar SDLK_DOLLAR
162 #define KSYM_percent KSYM_UNDEFINED /* undefined */
163 #define KSYM_ampersand SDLK_AMPERSAND
164 #define KSYM_apostrophe SDLK_QUOTE
165 #define KSYM_parenleft SDLK_LEFTPAREN
166 #define KSYM_parenright SDLK_RIGHTPAREN
167 #define KSYM_asterisk SDLK_ASTERISK
168 #define KSYM_plus SDLK_PLUS
169 #define KSYM_comma SDLK_COMMA
170 #define KSYM_minus SDLK_MINUS
171 #define KSYM_period SDLK_PERIOD
172 #define KSYM_slash SDLK_SLASH
174 #define KSYM_colon SDLK_COLON
175 #define KSYM_semicolon SDLK_SEMICOLON
176 #define KSYM_less SDLK_LESS
177 #define KSYM_equal SDLK_EQUALS
178 #define KSYM_greater SDLK_GREATER
179 #define KSYM_question SDLK_QUESTION
180 #define KSYM_at SDLK_AT
182 #define KSYM_bracketleft SDLK_LEFTBRACKET
183 #define KSYM_backslash SDLK_BACKSLASH
184 #define KSYM_bracketright SDLK_RIGHTBRACKET
185 #define KSYM_asciicircum SDLK_CARET
186 #define KSYM_underscore SDLK_UNDERSCORE
187 #define KSYM_grave SDLK_BACKQUOTE
189 #define KSYM_quoteleft KSYM_UNDEFINED /* undefined */
190 #define KSYM_braceleft KSYM_UNDEFINED /* undefined */
191 #define KSYM_bar KSYM_UNDEFINED /* undefined */
192 #define KSYM_braceright KSYM_UNDEFINED /* undefined */
193 #define KSYM_asciitilde KSYM_UNDEFINED /* undefined */
195 #define KSYM_Adiaeresis SDLK_WORLD_36
196 #define KSYM_Odiaeresis SDLK_WORLD_54
197 #define KSYM_Udiaeresis SDLK_WORLD_60
198 #define KSYM_adiaeresis SDLK_WORLD_68
199 #define KSYM_odiaeresis SDLK_WORLD_86
200 #define KSYM_udiaeresis SDLK_WORLD_92
201 #define KSYM_ssharp SDLK_WORLD_63
232 #define KSYM_A SDLK_A
233 #define KSYM_B SDLK_B
234 #define KSYM_C SDLK_C
235 #define KSYM_D SDLK_D
236 #define KSYM_E SDLK_E
237 #define KSYM_F SDLK_F
238 #define KSYM_G SDLK_G
239 #define KSYM_H SDLK_H
240 #define KSYM_I SDLK_I
241 #define KSYM_J SDLK_J
242 #define KSYM_K SDLK_K
243 #define KSYM_L SDLK_L
244 #define KSYM_M SDLK_M
245 #define KSYM_N SDLK_N
246 #define KSYM_O SDLK_O
247 #define KSYM_P SDLK_P
248 #define KSYM_Q SDLK_Q
249 #define KSYM_R SDLK_R
250 #define KSYM_S SDLK_S
251 #define KSYM_T SDLK_T
252 #define KSYM_U SDLK_U
253 #define KSYM_V SDLK_V
254 #define KSYM_W SDLK_W
255 #define KSYM_X SDLK_X
256 #define KSYM_Y SDLK_Y
257 #define KSYM_Z SDLK_Z
259 #define KSYM_a SDLK_a
260 #define KSYM_b SDLK_b
261 #define KSYM_c SDLK_c
262 #define KSYM_d SDLK_d
263 #define KSYM_e SDLK_e
264 #define KSYM_f SDLK_f
265 #define KSYM_g SDLK_g
266 #define KSYM_h SDLK_h
267 #define KSYM_i SDLK_i
268 #define KSYM_j SDLK_j
269 #define KSYM_k SDLK_k
270 #define KSYM_l SDLK_l
271 #define KSYM_m SDLK_m
272 #define KSYM_n SDLK_n
273 #define KSYM_o SDLK_o
274 #define KSYM_p SDLK_p
275 #define KSYM_q SDLK_q
276 #define KSYM_r SDLK_r
277 #define KSYM_s SDLK_s
278 #define KSYM_t SDLK_t
279 #define KSYM_u SDLK_u
280 #define KSYM_v SDLK_v
281 #define KSYM_w SDLK_w
282 #define KSYM_x SDLK_x
283 #define KSYM_y SDLK_y
284 #define KSYM_z SDLK_z
286 #define KSYM_0 SDLK_0
287 #define KSYM_1 SDLK_1
288 #define KSYM_2 SDLK_2
289 #define KSYM_3 SDLK_3
290 #define KSYM_4 SDLK_4
291 #define KSYM_5 SDLK_5
292 #define KSYM_6 SDLK_6
293 #define KSYM_7 SDLK_7
294 #define KSYM_8 SDLK_8
295 #define KSYM_9 SDLK_9
297 #define KSYM_KP_0 SDLK_KP0
298 #define KSYM_KP_1 SDLK_KP1
299 #define KSYM_KP_2 SDLK_KP2
300 #define KSYM_KP_3 SDLK_KP3
301 #define KSYM_KP_4 SDLK_KP4
302 #define KSYM_KP_5 SDLK_KP5
303 #define KSYM_KP_6 SDLK_KP6
304 #define KSYM_KP_7 SDLK_KP7
305 #define KSYM_KP_8 SDLK_KP8
306 #define KSYM_KP_9 SDLK_KP9
308 #define KSYM_F1 SDLK_F1
309 #define KSYM_F2 SDLK_F2
310 #define KSYM_F3 SDLK_F3
311 #define KSYM_F4 SDLK_F4
312 #define KSYM_F5 SDLK_F5
313 #define KSYM_F6 SDLK_F6
314 #define KSYM_F7 SDLK_F7
315 #define KSYM_F8 SDLK_F8
316 #define KSYM_F9 SDLK_F9
317 #define KSYM_F10 SDLK_F10
318 #define KSYM_F11 SDLK_F11
319 #define KSYM_F12 SDLK_F12
320 #define KSYM_F13 SDLK_F13
321 #define KSYM_F14 SDLK_F14
322 #define KSYM_F15 SDLK_F15
323 #define KSYM_F16 KSYM_UNDEFINED
324 #define KSYM_F17 KSYM_UNDEFINED
325 #define KSYM_F18 KSYM_UNDEFINED
326 #define KSYM_F19 KSYM_UNDEFINED
327 #define KSYM_F20 KSYM_UNDEFINED
328 #define KSYM_F21 KSYM_UNDEFINED
329 #define KSYM_F22 KSYM_UNDEFINED
330 #define KSYM_F23 KSYM_UNDEFINED
331 #define KSYM_F24 KSYM_UNDEFINED
333 #define KSYM_FKEY_FIRST KSYM_F1
334 #define KSYM_FKEY_LAST KSYM_F15
335 #define KSYM_NUM_FKEYS (KSYM_FKEY_LAST - KSYM_FKEY_FIRST + 1)
337 #define KMOD_None None
338 #define KMOD_Shift_L KMOD_LSHIFT
339 #define KMOD_Shift_R KMOD_RSHIFT
340 #define KMOD_Control_L KMOD_LCTRL
341 #define KMOD_Control_R KMOD_RCTRL
342 #define KMOD_Meta_L KMOD_LMETA
343 #define KMOD_Meta_R KMOD_RMETA
344 #define KMOD_Alt_L KMOD_LALT
345 #define KMOD_Alt_R KMOD_RALT
347 #define KMOD_Shift (KMOD_Shift_L | KMOD_Shift_R)
348 #define KMOD_Control (KMOD_Control_L | KMOD_Control_R)
349 #define KMOD_Meta (KMOD_Meta_L | KMOD_Meta_R)
350 #define KMOD_Alt (KMOD_Alt_L | KMOD_Alt_R)
353 /* SDL function definitions */
355 inline void SDLInitVideoDisplay(void);
356 inline void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean);
357 inline boolean SDLSetVideoMode(DrawBuffer **, boolean);
358 inline void SDLCreateBitmapContent(Bitmap *, int, int, int);
359 inline void SDLFreeBitmapPointers(Bitmap *);
360 inline void SDLCopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int);
361 inline void SDLFillRectangle(Bitmap *, int, int, int, int, Uint32);
362 inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, Uint32);
363 inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32);
364 inline Pixel SDLGetPixel(Bitmap *, int, int);
365 inline void SDLPutPixel(Bitmap *, int, int, Pixel);
367 inline void SDLInvertArea(Bitmap *, int, int, int, int, Uint32);
368 inline void SDLCopyInverseMasked(Bitmap *, Bitmap *, int, int, int, int,
371 void SDLZoomBitmap(Bitmap *, Bitmap *);
373 Bitmap *SDLLoadImage(char *);
375 void SDLSetMouseCursor(struct MouseCursorInfo *);
377 inline void SDLOpenAudio(void);
378 inline void SDLCloseAudio(void);
380 inline void SDLNextEvent(Event *);
382 void HandleJoystickEvent(Event *);
383 void SDLInitJoysticks(void);
384 boolean SDLReadJoystick(int, int *, int *, boolean *, boolean *);