e2dfca6e53f35c3e6bef54cf8969bef8723929f0
[rocksndiamonds.git] / src / system.h
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  ©1995 Artsoft Development                               *
5 *        Holger Schemel                                    *
6 *        33659 Bielefeld-Senne                             *
7 *        Telefon: (0521) 493245                            *
8 *        eMail: aeglos@valinor.owl.de                      *
9 *               aeglos@uni-paderborn.de                    *
10 *               q99492@pbhrzx.uni-paderborn.de             *
11 *----------------------------------------------------------*
12 *  system.h                                                *
13 ***********************************************************/
14
15 #ifndef SYSTEM_H
16 #define SYSTEM_H
17
18 #ifndef MSDOS
19 #include <X11/Xlib.h>
20 #include <X11/Xutil.h>
21 #include <X11/Xatom.h>
22 #include <X11/Xos.h>
23 #include <X11/Intrinsic.h>
24 #include <X11/keysymdef.h>
25 #endif
26
27 #ifdef USE_SDL_LIBRARY
28 #include "sdl.h"
29 #endif
30
31 #ifdef USE_SDL_LIBRARY
32
33 typedef SDL_Surface            *Bitmap;
34 typedef SDL_Surface            *DrawWindow;
35 typedef SDL_Surface            *DrawBuffer;
36
37 typedef SDLKey                  Key;
38
39 typedef SDL_Event               Event;
40 typedef SDL_MouseButtonEvent    ButtonEvent;
41 typedef SDL_MouseMotionEvent    MotionEvent;
42 typedef SDL_KeyboardEvent       KeyEvent;
43 typedef XExposeEvent            ExposeEvent;
44 typedef XFocusChangeEvent       FocusChangeEvent;
45 typedef XClientMessageEvent     ClientMessageEvent;
46
47 #define EVENT_BUTTONPRESS       SDL_MOUSEBUTTONDOWN
48 #define EVENT_BUTTONRELEASE     SDL_MOUSEBUTTONUP
49 #define EVENT_MOTIONNOTIFY      SDL_MOUSEMOTION
50 #define EVENT_KEYPRESS          SDL_KEYDOWN
51 #define EVENT_KEYRELEASE        SDL_KEYUP
52 #define EVENT_EXPOSE            SDL_USEREVENT + 0
53 #define EVENT_FOCUSIN           SDL_USEREVENT + 1
54 #define EVENT_FOCUSOUT          SDL_USEREVENT + 2
55 #define EVENT_CLIENTMESSAGE     SDL_QUIT
56 #define EVENT_MAPNOTIFY         SDL_USEREVENT + 4
57 #define EVENT_UNMAPNOTIFY       SDL_USEREVENT + 5
58
59 #define KEY_UNDEFINED           SDLK_UNKNOWN
60
61 #define KEY_Return              SDLK_RETURN
62 #define KEY_Escape              SDLK_ESCAPE
63
64 #define KEY_Left                SDLK_LEFT
65 #define KEY_Right               SDLK_RIGHT
66 #define KEY_Up                  SDLK_UP
67 #define KEY_Down                SDLK_DOWN
68
69 #ifdef SDLK_KP_LEFT
70 #define KEY_KP_Left             SDLK_KP_LEFT
71 #define KEY_KP_Right            SDLK_KP_RIGHT
72 #define KEY_KP_Up               SDLK_KP_UP
73 #define KEY_KP_Down             SDLK_KP_DOWN
74 #endif
75
76 #define KEY_KP_Enter            SDLK_KP_ENTER
77 #define KEY_KP_Add              SDLK_KP_PLUS
78 #define KEY_KP_Subtract         SDLK_KP_MINUS
79 #define KEY_KP_Multiply         SDLK_KP_MULTIPLY
80 #define KEY_KP_Divide           SDLK_KP_DIVIDE
81 #define KEY_KP_Separator        SDLK_KP_PERIOD
82
83 #define KEY_Shift_L             SDLK_LSHIFT
84 #define KEY_Shift_R             SDLK_RSHIFT
85 #define KEY_Control_L           SDLK_LCTRL
86 #define KEY_Control_R           SDLK_RCTRL
87 #define KEY_Meta_L              SDLK_LMETA
88 #define KEY_Meta_R              SDLK_RMETA
89 #define KEY_Alt_L               SDLK_LALT
90 #define KEY_Alt_R               SDLK_RALT
91 #define KEY_Mode_switch         SDLK_MODE
92 #define KEY_Multi_key           KEY_UNDEFINED           /* undefined */
93
94 #define KEY_BackSpace           SDLK_BACKSPACE
95 #define KEY_Delete              SDLK_DELETE
96 #define KEY_Insert              SDLK_INSERT
97 #define KEY_Tab                 SDLK_TAB
98 #define KEY_Home                SDLK_HOME
99 #define KEY_End                 SDLK_END
100 #define KEY_Page_Up             SDLK_PAGEUP
101 #define KEY_Page_Down           SDLK_PAGEDOWN
102
103 #define KEY_space               SDLK_SPACE
104 #define KEY_exclam              SDLK_EXCLAIM
105 #define KEY_quotedbl            SDLK_QUOTEDBL
106 #define KEY_numbersign          SDLK_HASH
107 #define KEY_dollar              SDLK_DOLLAR
108 #define KEY_percent             KEY_UNDEFINED           /* undefined */
109 #define KEY_ampersand           SDLK_AMPERSAND
110 #define KEY_apostrophe          SDLK_QUOTE
111 #define KEY_parenleft           SDLK_LEFTPAREN
112 #define KEY_parenright          SDLK_RIGHTPAREN
113 #define KEY_asterisk            SDLK_ASTERISK
114 #define KEY_plus                SDLK_PLUS
115 #define KEY_comma               SDLK_COMMA
116 #define KEY_minus               SDLK_MINUS
117 #define KEY_period              SDLK_PERIOD
118 #define KEY_slash               SDLK_SLASH
119
120 #define KEY_colon               SDLK_COLON
121 #define KEY_semicolon           SDLK_SEMICOLON
122 #define KEY_less                SDLK_LESS
123 #define KEY_equal               SDLK_EQUALS
124 #define KEY_greater             SDLK_GREATER
125 #define KEY_question            SDLK_QUESTION
126 #define KEY_at                  SDLK_AT
127
128 #define KEY_bracketleft         SDLK_LEFTBRACKET
129 #define KEY_backslash           SDLK_BACKSLASH
130 #define KEY_bracketright        SDLK_RIGHTBRACKET
131 #define KEY_asciicircum         SDLK_CARET
132 #define KEY_underscore          SDLK_UNDERSCORE
133 #define KEY_grave               SDLK_BACKQUOTE
134
135 #define KEY_quoteleft           KEY_UNDEFINED           /* undefined */
136 #define KEY_braceleft           KEY_UNDEFINED           /* undefined */
137 #define KEY_bar                 KEY_UNDEFINED           /* undefined */
138 #define KEY_braceright          KEY_UNDEFINED           /* undefined */
139 #define KEY_asciitilde          KEY_UNDEFINED           /* undefined */
140
141 #define KEY_Adiaeresis          SDLK_WORLD_36
142 #define KEY_Odiaeresis          SDLK_WORLD_54
143 #define KEY_Udiaeresis          SDLK_WORLD_60
144 #define KEY_adiaeresis          SDLK_WORLD_68
145 #define KEY_odiaeresis          SDLK_WORLD_86
146 #define KEY_udiaeresis          SDLK_WORLD_92
147 #define KEY_ssharp              SDLK_WORLD_63
148
149 #ifndef SDLK_A
150 #define SDLK_A                  65
151 #define SDLK_B                  66
152 #define SDLK_C                  67
153 #define SDLK_D                  68
154 #define SDLK_E                  69
155 #define SDLK_F                  70
156 #define SDLK_G                  71
157 #define SDLK_H                  72
158 #define SDLK_I                  73
159 #define SDLK_J                  74
160 #define SDLK_K                  75
161 #define SDLK_L                  76
162 #define SDLK_M                  77
163 #define SDLK_N                  78
164 #define SDLK_O                  79
165 #define SDLK_P                  80
166 #define SDLK_Q                  81
167 #define SDLK_R                  82
168 #define SDLK_S                  83
169 #define SDLK_T                  84
170 #define SDLK_U                  85
171 #define SDLK_V                  86
172 #define SDLK_W                  87
173 #define SDLK_X                  88
174 #define SDLK_Y                  89
175 #define SDLK_Z                  90
176 #endif
177
178 #define KEY_A                   SDLK_A
179 #define KEY_B                   SDLK_B
180 #define KEY_C                   SDLK_C
181 #define KEY_D                   SDLK_D
182 #define KEY_E                   SDLK_E
183 #define KEY_F                   SDLK_F
184 #define KEY_G                   SDLK_G
185 #define KEY_H                   SDLK_H
186 #define KEY_I                   SDLK_I
187 #define KEY_J                   SDLK_J
188 #define KEY_K                   SDLK_K
189 #define KEY_L                   SDLK_L
190 #define KEY_M                   SDLK_M
191 #define KEY_N                   SDLK_N
192 #define KEY_O                   SDLK_O
193 #define KEY_P                   SDLK_P
194 #define KEY_Q                   SDLK_Q
195 #define KEY_R                   SDLK_R
196 #define KEY_S                   SDLK_S
197 #define KEY_T                   SDLK_T
198 #define KEY_U                   SDLK_U
199 #define KEY_V                   SDLK_V
200 #define KEY_W                   SDLK_W
201 #define KEY_X                   SDLK_X
202 #define KEY_Y                   SDLK_Y
203 #define KEY_Z                   SDLK_Z
204
205 #define KEY_a                   SDLK_a
206 #define KEY_b                   SDLK_b
207 #define KEY_c                   SDLK_c
208 #define KEY_d                   SDLK_d
209 #define KEY_e                   SDLK_e
210 #define KEY_f                   SDLK_f
211 #define KEY_g                   SDLK_g
212 #define KEY_h                   SDLK_h
213 #define KEY_i                   SDLK_i
214 #define KEY_j                   SDLK_j
215 #define KEY_k                   SDLK_k
216 #define KEY_l                   SDLK_l
217 #define KEY_m                   SDLK_m
218 #define KEY_n                   SDLK_n
219 #define KEY_o                   SDLK_o
220 #define KEY_p                   SDLK_p
221 #define KEY_q                   SDLK_q
222 #define KEY_r                   SDLK_r
223 #define KEY_s                   SDLK_s
224 #define KEY_t                   SDLK_t
225 #define KEY_u                   SDLK_u
226 #define KEY_v                   SDLK_v
227 #define KEY_w                   SDLK_w
228 #define KEY_x                   SDLK_x
229 #define KEY_y                   SDLK_y
230 #define KEY_z                   SDLK_z
231
232 #define KEY_0                   SDLK_0
233 #define KEY_1                   SDLK_1
234 #define KEY_2                   SDLK_2
235 #define KEY_3                   SDLK_3
236 #define KEY_4                   SDLK_4
237 #define KEY_5                   SDLK_5
238 #define KEY_6                   SDLK_6
239 #define KEY_7                   SDLK_7
240 #define KEY_8                   SDLK_8
241 #define KEY_9                   SDLK_9
242
243 #define KEY_KP_0                SDLK_KP0
244 #define KEY_KP_1                SDLK_KP1
245 #define KEY_KP_2                SDLK_KP2
246 #define KEY_KP_3                SDLK_KP3
247 #define KEY_KP_4                SDLK_KP4
248 #define KEY_KP_5                SDLK_KP5
249 #define KEY_KP_6                SDLK_KP6
250 #define KEY_KP_7                SDLK_KP7
251 #define KEY_KP_8                SDLK_KP8
252 #define KEY_KP_9                SDLK_KP9
253
254 #define KEY_F1                  SDLK_F1
255 #define KEY_F2                  SDLK_F2
256 #define KEY_F3                  SDLK_F3
257 #define KEY_F4                  SDLK_F4
258 #define KEY_F5                  SDLK_F5
259 #define KEY_F6                  SDLK_F6
260 #define KEY_F7                  SDLK_F7
261 #define KEY_F8                  SDLK_F8
262 #define KEY_F9                  SDLK_F9
263 #define KEY_F10                 SDLK_F10
264 #define KEY_F11                 SDLK_F11
265 #define KEY_F12                 SDLK_F12
266 #define KEY_F13                 SDLK_F13
267 #define KEY_F14                 SDLK_F14
268 #define KEY_F15                 SDLK_F15
269 #define KEY_F16                 KEY_UNDEFINED
270 #define KEY_F17                 KEY_UNDEFINED
271 #define KEY_F18                 KEY_UNDEFINED
272 #define KEY_F19                 KEY_UNDEFINED
273 #define KEY_F20                 KEY_UNDEFINED
274 #define KEY_F21                 KEY_UNDEFINED
275 #define KEY_F22                 KEY_UNDEFINED
276 #define KEY_F23                 KEY_UNDEFINED
277 #define KEY_F24                 KEY_UNDEFINED
278
279 #else   /* X11 type definitions */
280
281 typedef Pixmap                  Bitmap;
282 typedef Window                  DrawWindow;
283 typedef Drawable                DrawBuffer;
284
285 typedef KeySym                  Key;
286
287 typedef XEvent                  Event;
288 typedef XButtonEvent            ButtonEvent;
289 typedef XMotionEvent            MotionEvent;
290 typedef XKeyEvent               KeyEvent;
291 typedef XExposeEvent            ExposeEvent;
292 typedef XFocusChangeEvent       FocusChangeEvent;
293 typedef XClientMessageEvent     ClientMessageEvent;
294
295 #define EVENT_BUTTONPRESS       ButtonPress
296 #define EVENT_BUTTONRELEASE     ButtonRelease
297 #define EVENT_MOTIONNOTIFY      MotionNotify
298 #define EVENT_KEYPRESS          KeyPress
299 #define EVENT_KEYRELEASE        KeyRelease
300 #define EVENT_EXPOSE            Expose
301 #define EVENT_FOCUSIN           FocusIn
302 #define EVENT_FOCUSOUT          FocusOut
303 #define EVENT_CLIENTMESSAGE     ClientMessage
304 #define EVENT_MAPNOTIFY         MapNotify
305 #define EVENT_UNMAPNOTIFY       UnmapNotify
306
307 #define KEY_UNDEFINED           XK_VoidSymbol
308
309 #define KEY_Return              XK_Return
310 #define KEY_Escape              XK_Escape
311
312 #define KEY_Left                XK_Left
313 #define KEY_Right               XK_Right
314 #define KEY_Up                  XK_Up
315 #define KEY_Down                XK_Down
316
317 #ifdef XK_KP_Left
318 #define KEY_KP_Left             XK_KP_Left
319 #define KEY_KP_Right            XK_KP_Right
320 #define KEY_KP_Up               XK_KP_Up
321 #define KEY_KP_Down             XK_KP_Down
322 #endif
323
324 #ifdef XK_KP_Enter
325 #define KEY_KP_Enter            XK_KP_Enter
326 #define KEY_KP_Add              XK_KP_Add
327 #define KEY_KP_Subtract         XK_KP_Subtract
328 #define KEY_KP_Multiply         XK_KP_Multiply
329 #define KEY_KP_Divide           XK_KP_Divide
330 #define KEY_KP_Separator        XK_KP_Separator
331 #endif
332
333 #define KEY_Shift_L             XK_Shift_L
334 #define KEY_Shift_R             XK_Shift_R
335 #define KEY_Control_L           XK_Control_L
336 #define KEY_Control_R           XK_Control_R
337 #define KEY_Meta_L              XK_Meta_L
338 #define KEY_Meta_R              XK_Meta_R
339 #define KEY_Alt_L               XK_Alt_L
340 #define KEY_Alt_R               XK_Alt_R
341 #define KEY_Mode_switch         XK_Mode_switch
342 #define KEY_Multi_key           XK_Multi_key
343
344 #define KEY_BackSpace           XK_BackSpace
345 #define KEY_Delete              XK_Delete
346 #define KEY_Insert              XK_Insert
347 #define KEY_Tab                 XK_Tab
348 #define KEY_Home                XK_Home
349 #define KEY_End                 XK_End
350 #define KEY_Page_Up             XK_Page_Up
351 #define KEY_Page_Down           XK_Page_Down
352
353 #define KEY_space               XK_space
354 #define KEY_exclam              XK_exclam
355 #define KEY_quotedbl            XK_quotedbl
356 #define KEY_numbersign          XK_numbersign
357 #define KEY_dollar              XK_dollar
358 #define KEY_percent             XK_percent
359 #define KEY_ampersand           XK_ampersand
360 #define KEY_apostrophe          XK_apostrophe
361 #define KEY_parenleft           XK_parenleft
362 #define KEY_parenright          XK_parenright
363 #define KEY_asterisk            XK_asterisk
364 #define KEY_plus                XK_plus
365 #define KEY_comma               XK_comma
366 #define KEY_minus               XK_minus
367 #define KEY_period              XK_period
368 #define KEY_slash               XK_slash
369
370 #define KEY_colon               XK_colon
371 #define KEY_semicolon           XK_semicolon
372 #define KEY_less                XK_less
373 #define KEY_equal               XK_equal
374 #define KEY_greater             XK_greater
375 #define KEY_question            XK_question
376 #define KEY_at                  XK_at
377
378 #define KEY_bracketleft         XK_bracketleft
379 #define KEY_backslash           XK_backslash
380 #define KEY_bracketright        XK_bracketright
381 #define KEY_asciicircum         XK_asciicircum
382 #define KEY_underscore          XK_underscore
383 #define KEY_grave               XK_grave
384
385 #define KEY_quoteleft           XK_quoteleft
386 #define KEY_braceleft           XK_braceleft
387 #define KEY_bar                 XK_bar
388 #define KEY_braceright          XK_braceright
389 #define KEY_asciitilde          XK_asciitilde
390
391 #define KEY_Adiaeresis          XK_Adiaeresis
392 #define KEY_Odiaeresis          XK_Odiaeresis
393 #define KEY_Udiaeresis          XK_Udiaeresis
394 #define KEY_adiaeresis          XK_adiaeresis
395 #define KEY_odiaeresis          XK_odiaeresis
396 #define KEY_udiaeresis          XK_udiaeresis
397 #define KEY_ssharp              XK_ssharp
398
399 #define KEY_A                   XK_A
400 #define KEY_B                   XK_B
401 #define KEY_C                   XK_C
402 #define KEY_D                   XK_D
403 #define KEY_E                   XK_E
404 #define KEY_F                   XK_F
405 #define KEY_G                   XK_G
406 #define KEY_H                   XK_H
407 #define KEY_I                   XK_I
408 #define KEY_J                   XK_J
409 #define KEY_K                   XK_K
410 #define KEY_L                   XK_L
411 #define KEY_M                   XK_M
412 #define KEY_N                   XK_N
413 #define KEY_O                   XK_O
414 #define KEY_P                   XK_P
415 #define KEY_Q                   XK_Q
416 #define KEY_R                   XK_R
417 #define KEY_S                   XK_S
418 #define KEY_T                   XK_T
419 #define KEY_U                   XK_U
420 #define KEY_V                   XK_V
421 #define KEY_W                   XK_W
422 #define KEY_X                   XK_X
423 #define KEY_Y                   XK_Y
424 #define KEY_Z                   XK_Z
425
426 #define KEY_a                   XK_a
427 #define KEY_b                   XK_b
428 #define KEY_c                   XK_c
429 #define KEY_d                   XK_d
430 #define KEY_e                   XK_e
431 #define KEY_f                   XK_f
432 #define KEY_g                   XK_g
433 #define KEY_h                   XK_h
434 #define KEY_i                   XK_i
435 #define KEY_j                   XK_j
436 #define KEY_k                   XK_k
437 #define KEY_l                   XK_l
438 #define KEY_m                   XK_m
439 #define KEY_n                   XK_n
440 #define KEY_o                   XK_o
441 #define KEY_p                   XK_p
442 #define KEY_q                   XK_q
443 #define KEY_r                   XK_r
444 #define KEY_s                   XK_s
445 #define KEY_t                   XK_t
446 #define KEY_u                   XK_u
447 #define KEY_v                   XK_v
448 #define KEY_w                   XK_w
449 #define KEY_x                   XK_x
450 #define KEY_y                   XK_y
451 #define KEY_z                   XK_z
452
453 #define KEY_0                   XK_0
454 #define KEY_1                   XK_1
455 #define KEY_2                   XK_2
456 #define KEY_3                   XK_3
457 #define KEY_4                   XK_4
458 #define KEY_5                   XK_5
459 #define KEY_6                   XK_6
460 #define KEY_7                   XK_7
461 #define KEY_8                   XK_8
462 #define KEY_9                   XK_9
463
464 #define KEY_KP_0                XK_KP_0
465 #define KEY_KP_1                XK_KP_1
466 #define KEY_KP_2                XK_KP_2
467 #define KEY_KP_3                XK_KP_3
468 #define KEY_KP_4                XK_KP_4
469 #define KEY_KP_5                XK_KP_5
470 #define KEY_KP_6                XK_KP_6
471 #define KEY_KP_7                XK_KP_7
472 #define KEY_KP_8                XK_KP_8
473 #define KEY_KP_9                XK_KP_9
474
475 #define KEY_F1                  XK_F1
476 #define KEY_F2                  XK_F2
477 #define KEY_F3                  XK_F3
478 #define KEY_F4                  XK_F4
479 #define KEY_F5                  XK_F5
480 #define KEY_F6                  XK_F6
481 #define KEY_F7                  XK_F7
482 #define KEY_F8                  XK_F8
483 #define KEY_F9                  XK_F9
484 #define KEY_F10                 XK_F10
485 #define KEY_F11                 XK_F11
486 #define KEY_F12                 XK_F12
487 #define KEY_F13                 XK_F13
488 #define KEY_F14                 XK_F14
489 #define KEY_F15                 XK_F15
490 #define KEY_F16                 XK_F16
491 #define KEY_F17                 XK_F17
492 #define KEY_F18                 XK_F18
493 #define KEY_F19                 XK_F19
494 #define KEY_F20                 XK_F20
495 #define KEY_F21                 XK_F21
496 #define KEY_F22                 XK_F22
497 #define KEY_F23                 XK_F23
498 #define KEY_F24                 XK_F24
499
500 #endif
501
502 inline void ClearRectangle(Bitmap, int, int, int, int);
503 inline void BlitBitmap(Bitmap, Bitmap, int, int, int, int, int, int);
504 inline void SetClipMask(GC, Pixmap);
505 inline void SetClipOrigin(GC, int, int);
506 inline void BlitBitmapMasked(Bitmap, Bitmap, int, int, int, int, int, int);
507 inline void DrawSimpleWhiteLine(Bitmap, int, int, int, int);
508
509 inline void FlushDisplay();
510 inline void SyncDisplay();
511 inline void KeyboardAutoRepeatOn();
512 inline void KeyboardAutoRepeatOff();
513 inline boolean QueryPointer(DrawWindow, int *, int *);
514
515 inline boolean PendingEvent();
516 inline void NextEvent(Event *event);
517
518 inline Key GetEventKey(KeyEvent *, boolean);
519
520 #endif /* SYSTEM_H */