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 ***********************************************************/
21 /* symbol 'window' is defined in DJGPP cross-compiler in libc.a(conio.o) */
22 #define window window_internal
24 /* symbol 'font' is defined in "allegro.h" */
25 #define font font_internal
27 /* system dependent definitions */
29 #define TARGET_STRING "DOS"
31 /* allegro defines TRUE as -1 */
43 /* allegro defines some macros that bother the rest of the program */
55 /* additional Allegro keyboard mapping */
57 /* The following are all undefined in Allegro */
58 #define NEW_KEY_BACKSLASH 86
59 #define NEW_KEY_1_PAD 101
60 #define NEW_KEY_2_PAD 102
61 #define NEW_KEY_3_PAD 103
62 #define NEW_KEY_4_PAD 104
63 #define NEW_KEY_5_PAD 105
64 #define NEW_KEY_6_PAD 106
65 #define NEW_KEY_7_PAD 107
66 #define NEW_KEY_8_PAD 108
67 #define NEW_KEY_9_PAD 109
68 #define NEW_KEY_0_PAD 110
69 #define NEW_KEY_STOP_PAD 111
70 #define NEW_KEY_EQUALS_PAD 112
71 #define NEW_KEY_SLASH_PAD 113
72 #define NEW_KEY_ASTERISK_PAD 114
73 #define NEW_KEY_ENTER_PAD 115
75 /* X11 keyboard mapping (from 'keysymdef.h') */
77 #define XK_VoidSymbol 0xFFFFFF /* void symbol */
80 * TTY Functions, cleverly chosen to map to ascii, for convenience of
81 * programming, but could have been arbitrary (at the cost of lookup
82 * tables in client code.
85 #define XK_BackSpace 0xFF08 /* back space, back char */
87 #define XK_Linefeed 0xFF0A /* Linefeed, LF */
88 #define XK_Clear 0xFF0B
89 #define XK_Return 0xFF0D /* Return, enter */
90 #define XK_Pause 0xFF13 /* Pause, hold */
91 #define XK_Scroll_Lock 0xFF14
92 #define XK_Sys_Req 0xFF15
93 #define XK_Escape 0xFF1B
94 #define XK_Delete 0xFFFF /* Delete, rubout */
96 /* International & multi-key character composition */
98 #define XK_Multi_key 0xFF20 /* Multi-key character compose */
99 #define XK_SingleCandidate 0xFF3C
100 #define XK_MultipleCandidate 0xFF3D
101 #define XK_PreviousCandidate 0xFF3E
103 /* Cursor control & motion */
105 #define XK_Home 0xFF50
106 #define XK_Left 0xFF51 /* Move left, left arrow */
107 #define XK_Up 0xFF52 /* Move up, up arrow */
108 #define XK_Right 0xFF53 /* Move right, right arrow */
109 #define XK_Down 0xFF54 /* Move down, down arrow */
110 #define XK_Prior 0xFF55 /* Prior, previous */
111 #define XK_Page_Up 0xFF55
112 #define XK_Next 0xFF56 /* Next */
113 #define XK_Page_Down 0xFF56
114 #define XK_End 0xFF57 /* EOL */
115 #define XK_Begin 0xFF58 /* BOL */
119 #define XK_Select 0xFF60 /* Select, mark */
120 #define XK_Print 0xFF61
121 #define XK_Execute 0xFF62 /* Execute, run, do */
122 #define XK_Insert 0xFF63 /* Insert, insert here */
123 #define XK_Undo 0xFF65 /* Undo, oops */
124 #define XK_Redo 0xFF66 /* redo, again */
125 #define XK_Menu 0xFF67
126 #define XK_Find 0xFF68 /* Find, search */
127 #define XK_Cancel 0xFF69 /* Cancel, stop, abort, exit */
128 #define XK_Help 0xFF6A /* Help */
129 #define XK_Break 0xFF6B
130 #define XK_Mode_switch 0xFF7E /* Character set switch */
131 #define XK_script_switch 0xFF7E /* Alias for mode_switch */
132 #define XK_Num_Lock 0xFF7F
134 /* Keypad Functions, keypad numbers cleverly chosen to map to ascii */
136 #define XK_KP_Space 0xFF80 /* space */
137 #define XK_KP_Tab 0xFF89
138 #define XK_KP_Enter 0xFF8D /* enter */
139 #define XK_KP_F1 0xFF91 /* PF1, KP_A, ... */
140 #define XK_KP_F2 0xFF92
141 #define XK_KP_F3 0xFF93
142 #define XK_KP_F4 0xFF94
143 #define XK_KP_Home 0xFF95
144 #define XK_KP_Left 0xFF96
145 #define XK_KP_Up 0xFF97
146 #define XK_KP_Right 0xFF98
147 #define XK_KP_Down 0xFF99
148 #define XK_KP_Prior 0xFF9A
149 #define XK_KP_Page_Up 0xFF9A
150 #define XK_KP_Next 0xFF9B
151 #define XK_KP_Page_Down 0xFF9B
152 #define XK_KP_End 0xFF9C
153 #define XK_KP_Begin 0xFF9D
154 #define XK_KP_Insert 0xFF9E
155 #define XK_KP_Delete 0xFF9F
156 #define XK_KP_Equal 0xFFBD /* equals */
157 #define XK_KP_Multiply 0xFFAA
158 #define XK_KP_Add 0xFFAB
159 #define XK_KP_Separator 0xFFAC /* separator, often comma */
160 #define XK_KP_Subtract 0xFFAD
161 #define XK_KP_Decimal 0xFFAE
162 #define XK_KP_Divide 0xFFAF
164 #define XK_KP_0 0xFFB0
165 #define XK_KP_1 0xFFB1
166 #define XK_KP_2 0xFFB2
167 #define XK_KP_3 0xFFB3
168 #define XK_KP_4 0xFFB4
169 #define XK_KP_5 0xFFB5
170 #define XK_KP_6 0xFFB6
171 #define XK_KP_7 0xFFB7
172 #define XK_KP_8 0xFFB8
173 #define XK_KP_9 0xFFB9
176 * Auxilliary Functions; note the duplicate definitions for left and right
177 * function keys; Sun keyboards and a few other manufactures have such
178 * function key groups on the left and/or right sides of the keyboard.
179 * We've not found a keyboard with more than 35 function keys total.
191 #define XK_F10 0xFFC7
192 #define XK_F11 0xFFC8
194 #define XK_F12 0xFFC9
196 #define XK_F13 0xFFCA
198 #define XK_F14 0xFFCB
200 #define XK_F15 0xFFCC
202 #define XK_F16 0xFFCD
204 #define XK_F17 0xFFCE
206 #define XK_F18 0xFFCF
208 #define XK_F19 0xFFD0
210 #define XK_F20 0xFFD1
211 #define XK_L10 0xFFD1
212 #define XK_F21 0xFFD2
214 #define XK_F22 0xFFD3
216 #define XK_F23 0xFFD4
218 #define XK_F24 0xFFD5
220 #define XK_F25 0xFFD6
222 #define XK_F26 0xFFD7
224 #define XK_F27 0xFFD8
226 #define XK_F28 0xFFD9
228 #define XK_F29 0xFFDA
230 #define XK_F30 0xFFDB
231 #define XK_R10 0xFFDB
232 #define XK_F31 0xFFDC
233 #define XK_R11 0xFFDC
234 #define XK_F32 0xFFDD
235 #define XK_R12 0xFFDD
236 #define XK_F33 0xFFDE
237 #define XK_R13 0xFFDE
238 #define XK_F34 0xFFDF
239 #define XK_R14 0xFFDF
240 #define XK_F35 0xFFE0
241 #define XK_R15 0xFFE0
245 #define XK_Shift_L 0xFFE1 /* Left shift */
246 #define XK_Shift_R 0xFFE2 /* Right shift */
247 #define XK_Control_L 0xFFE3 /* Left control */
248 #define XK_Control_R 0xFFE4 /* Right control */
249 #define XK_Caps_Lock 0xFFE5 /* Caps lock */
250 #define XK_Shift_Lock 0xFFE6 /* Shift lock */
252 #define XK_Meta_L 0xFFE7 /* Left meta */
253 #define XK_Meta_R 0xFFE8 /* Right meta */
254 #define XK_Alt_L 0xFFE9 /* Left alt */
255 #define XK_Alt_R 0xFFEA /* Right alt */
256 #define XK_Super_L 0xFFEB /* Left super */
257 #define XK_Super_R 0xFFEC /* Right super */
258 #define XK_Hyper_L 0xFFED /* Left hyper */
259 #define XK_Hyper_R 0xFFEE /* Right hyper */
266 #define XK_space 0x020
267 #define XK_exclam 0x021
268 #define XK_quotedbl 0x022
269 #define XK_numbersign 0x023
270 #define XK_dollar 0x024
271 #define XK_percent 0x025
272 #define XK_ampersand 0x026
273 #define XK_apostrophe 0x027
274 #define XK_quoteright 0x027 /* deprecated */
275 #define XK_parenleft 0x028
276 #define XK_parenright 0x029
277 #define XK_asterisk 0x02a
278 #define XK_plus 0x02b
279 #define XK_comma 0x02c
280 #define XK_minus 0x02d
281 #define XK_period 0x02e
282 #define XK_slash 0x02f
293 #define XK_colon 0x03a
294 #define XK_semicolon 0x03b
295 #define XK_less 0x03c
296 #define XK_equal 0x03d
297 #define XK_greater 0x03e
298 #define XK_question 0x03f
326 #define XK_bracketleft 0x05b
327 #define XK_backslash 0x05c
328 #define XK_bracketright 0x05d
329 #define XK_asciicircum 0x05e
330 #define XK_underscore 0x05f
331 #define XK_grave 0x060
332 #define XK_quoteleft 0x060 /* deprecated */
359 #define XK_braceleft 0x07b
361 #define XK_braceright 0x07d
362 #define XK_asciitilde 0x07e
364 #define XK_nobreakspace 0x0a0
365 #define XK_exclamdown 0x0a1
366 #define XK_cent 0x0a2
367 #define XK_sterling 0x0a3
368 #define XK_currency 0x0a4
370 #define XK_brokenbar 0x0a6
371 #define XK_section 0x0a7
372 #define XK_diaeresis 0x0a8
373 #define XK_copyright 0x0a9
374 #define XK_ordfeminine 0x0aa
375 #define XK_guillemotleft 0x0ab /* left angle quotation mark */
376 #define XK_notsign 0x0ac
377 #define XK_hyphen 0x0ad
378 #define XK_registered 0x0ae
379 #define XK_macron 0x0af
380 #define XK_degree 0x0b0
381 #define XK_plusminus 0x0b1
382 #define XK_twosuperior 0x0b2
383 #define XK_threesuperior 0x0b3
384 #define XK_acute 0x0b4
386 #define XK_paragraph 0x0b6
387 #define XK_periodcentered 0x0b7
388 #define XK_cedilla 0x0b8
389 #define XK_onesuperior 0x0b9
390 #define XK_masculine 0x0ba
391 #define XK_guillemotright 0x0bb /* right angle quotation mark */
392 #define XK_onequarter 0x0bc
393 #define XK_onehalf 0x0bd
394 #define XK_threequarters 0x0be
395 #define XK_questiondown 0x0bf
396 #define XK_Agrave 0x0c0
397 #define XK_Aacute 0x0c1
398 #define XK_Acircumflex 0x0c2
399 #define XK_Atilde 0x0c3
400 #define XK_Adiaeresis 0x0c4
401 #define XK_Aring 0x0c5
403 #define XK_Ccedilla 0x0c7
404 #define XK_Egrave 0x0c8
405 #define XK_Eacute 0x0c9
406 #define XK_Ecircumflex 0x0ca
407 #define XK_Ediaeresis 0x0cb
408 #define XK_Igrave 0x0cc
409 #define XK_Iacute 0x0cd
410 #define XK_Icircumflex 0x0ce
411 #define XK_Idiaeresis 0x0cf
413 #define XK_Eth 0x0d0 /* deprecated */
414 #define XK_Ntilde 0x0d1
415 #define XK_Ograve 0x0d2
416 #define XK_Oacute 0x0d3
417 #define XK_Ocircumflex 0x0d4
418 #define XK_Otilde 0x0d5
419 #define XK_Odiaeresis 0x0d6
420 #define XK_multiply 0x0d7
421 #define XK_Ooblique 0x0d8
422 #define XK_Ugrave 0x0d9
423 #define XK_Uacute 0x0da
424 #define XK_Ucircumflex 0x0db
425 #define XK_Udiaeresis 0x0dc
426 #define XK_Yacute 0x0dd
427 #define XK_THORN 0x0de
428 #define XK_Thorn 0x0de /* deprecated */
429 #define XK_ssharp 0x0df
430 #define XK_agrave 0x0e0
431 #define XK_aacute 0x0e1
432 #define XK_acircumflex 0x0e2
433 #define XK_atilde 0x0e3
434 #define XK_adiaeresis 0x0e4
435 #define XK_aring 0x0e5
437 #define XK_ccedilla 0x0e7
438 #define XK_egrave 0x0e8
439 #define XK_eacute 0x0e9
440 #define XK_ecircumflex 0x0ea
441 #define XK_ediaeresis 0x0eb
442 #define XK_igrave 0x0ec
443 #define XK_iacute 0x0ed
444 #define XK_icircumflex 0x0ee
445 #define XK_idiaeresis 0x0ef
447 #define XK_ntilde 0x0f1
448 #define XK_ograve 0x0f2
449 #define XK_oacute 0x0f3
450 #define XK_ocircumflex 0x0f4
451 #define XK_otilde 0x0f5
452 #define XK_odiaeresis 0x0f6
453 #define XK_division 0x0f7
454 #define XK_oslash 0x0f8
455 #define XK_ugrave 0x0f9
456 #define XK_uacute 0x0fa
457 #define XK_ucircumflex 0x0fb
458 #define XK_udiaeresis 0x0fc
459 #define XK_yacute 0x0fd
460 #define XK_thorn 0x0fe
461 #define XK_ydiaeresis 0x0ff
463 /* end of X11 keyboard mapping */
466 #define screen myscreen
469 #define XGetImage(a,b,c,d,e,f,g,h) ((XImage *) NULL)
470 #define XDisplayName(a) ((char *) NULL)
471 #define XFreeColors(a,b,c,d,e)
472 #define XSelectInput(a,b,c)
473 #define XDefaultDepth(a,b) (8)
474 #define XSetWMProperties(a,b,c,d,e,f,g,h,i)
476 #define MAX_EVENT_BUFFER 256
477 #define MAX_SCANCODES 128
483 #define DUMMY_FILE ((void *) -1)
484 #define DUMMY_MASK (-1)
486 #define KeyPressMask (1L << 0)
487 #define KeyReleaseMask (1L << 1)
488 #define ButtonPressMask (1L << 2)
489 #define ButtonReleaseMask (1L << 3)
490 #define ButtonMotionMask (1L << 13)
491 #define ExposureMask (1L << 15)
492 #define StructureNotifyMask (1L << 17)
493 #define FocusChangeMask (1L << 21)
497 #define ButtonPress 4
498 #define ButtonRelease 5
499 #define MotionNotify 6
503 #define UnmapNotify 18
505 #define ClientMessage 33
508 #define LineOnOffDash 1
509 #define LineDoubleDash 2
514 #define CapProjecting 3
520 #define GCForeground (1L << 2)
521 #define GCBackground (1L << 3)
522 #define GCLineWidth (1L << 4)
523 #define GCLineStyle (1L << 5)
524 #define GCCapStyle (1L << 6)
525 #define GCJoinStyle (1L << 7)
526 #define GCGraphicsExposures (1L << 16)
527 #define GCClipMask (1L << 19)
529 #define NormalState 1 /* most applications want to start this way */
530 #define InputHint (1L << 0)
531 #define StateHint (1L << 1)
532 #define IconPixmapHint (1L << 2)
533 #define IconMaskHint (1L << 5)
534 #define PSize (1L << 3) /* program specified size */
535 #define PMinSize (1L << 4) /* program specified minimum size */
536 #define PMaxSize (1L << 5) /* program specified maximum size */
538 #define PCX_Success 0
539 #define PCX_OpenFailed -1
540 #define PCX_ReadFailed -2
541 #define PCX_FileInvalid -3
542 #define PCX_NoMemory -4
543 #define PCX_ColorFailed -5
545 #define BitmapSuccess 0
546 #define BitmapOpenFailed 1
547 #define BitmapFileInvalid 2
548 #define BitmapNoMemory 3
550 #define ZPixmap 2 /* depth == drawable depth */
552 #define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
553 #define DefaultColormap(dpy, scr) (ScreenOfDisplay(dpy,scr)->cmap)
554 #define ScreenOfDisplay(dpy, scr) (&((_XPrivDisplay)dpy)->screens[scr])
555 #define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
556 #define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
557 #define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
558 #define AllPlanes ((unsigned long)~0L)
560 #define DefaultVisual(dpy, scr) (NULL)
561 #define DefaultDepth(dpy, scr) (NULL)
562 #define XDisplayWidth(dpy, scr) (XRES)
563 #define XDisplayHeight(dpy, scr) (YRES)
565 #define XGetPixel(ximage, x, y) \
566 ((*((ximage)->f.get_pixel))((ximage), (x), (y)))
568 typedef unsigned long Pixel; /* Index into colormap */
569 typedef unsigned long XID;
571 typedef XID Drawable;
573 typedef XID Colormap;
575 typedef XID GContext;
576 typedef struct _XDisplay Display;
578 typedef long XVisualInfo;
582 typedef int XComposeStatus; /* we don't need the real type */
586 GContext gid; /* protocol ID for graphics context */
591 Colormap cmap; /* default color map */
592 Window root; /* root window id */
593 unsigned long white_pixel; /* white pixel value */
594 unsigned long black_pixel; /* black pixel value */
599 BITMAP *video_bitmap;
602 typedef struct _XDisplay
604 int default_screen; /* default screen for operations */
605 Screen *screens; /* pointer to list of screens */
609 typedef struct _XImage
613 unsigned long (*get_pixel) (struct _XImage *, int, int);
619 long flags; /* marks which fields in this structure are defined */
620 int width, height; /* should set so old wm's don't mess up */
621 int min_width, min_height;
622 int max_width, max_height;
627 long flags; /* marks which fields in this structure are defined */
628 Bool input; /* does this application rely on the window manager to
629 get keyboard input? */
630 int initial_state; /* see below */
631 Pixmap icon_pixmap; /* pixmap to be used as icon */
632 Pixmap icon_mask; /* icon mask bitmap */
643 unsigned char *value; /* same as Property routines */
648 unsigned long foreground; /* foreground pixel */
649 unsigned long background; /* background pixel */
650 Bool graphics_exposures; /* boolean, should exposures be generated */
651 Pixmap clip_mask; /* bitmap clipping; other calls for rects */
652 int clip_x_origin; /* x origin for clipping */
653 int clip_y_origin; /* y origin for clipping */
654 unsigned long value_mask;
655 int line_width; /* line width */
656 int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
657 int cap_style; /* CapNotLast, CapButt,
658 CapRound, CapProjecting */
659 int join_style; /* JoinMiter, JoinRound, JoinBevel */
672 int type; /* of event */
673 int x, y; /* pointer x, y coordinates in event window */
674 unsigned int button; /* detail */
680 int x, y; /* pointer x, y coordinates in event window */
685 int type; /* of event */
686 unsigned int state; /* key or button mask */
691 int type; /* FocusIn or FocusOut */
696 int type; /* ClientMessage */
697 } XClientMessageEvent;
699 typedef union _XEvent
701 int type; /* must not be changed; first element */
702 XExposeEvent xexpose;
703 XButtonEvent xbutton;
704 XMotionEvent xmotion;
708 Pixel AllegroAllocColorCell(int, int, int);
710 void XMapWindow(Display *, Window);
711 Display *XOpenDisplay(char *);
712 Window XCreateSimpleWindow(Display *, Window, int, int,
713 unsigned int, unsigned int, unsigned int,
714 unsigned long, unsigned long);
715 Status XStringListToTextProperty(char **, int, XTextProperty *);
717 GC XCreateGC(Display *, Drawable, unsigned long, XGCValues *);
718 void XSetClipMask(Display *, GC, Pixmap);
719 void XSetClipOrigin(Display *, GC, int, int);
720 void XFillRectangle(Display *, Drawable, GC, int, int,
721 unsigned int, unsigned int);
722 Pixmap XCreatePixmap(Display *, Drawable, unsigned int, unsigned int,
724 void XSync(Display *, Bool);
725 inline void XCopyArea(Display *, Drawable, Drawable, GC, int, int,
726 unsigned int, unsigned int, int, int);
727 int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *);
728 int XReadBitmapFile(Display *, Drawable, char *,
729 unsigned int *, unsigned int *, Pixmap *, int *, int *);
730 void XFreePixmap(Display *, Pixmap);
731 void XFreeGC(Display *, GC);
732 void XUnmapWindow(Display *, Window);
733 void XCloseDisplay(Display *);
734 void XNextEvent(Display *, XEvent *);
735 int XPending(Display *);
736 KeySym XLookupKeysym(XKeyEvent *, int);
737 int XLookupString(XKeyEvent *, char *, int, KeySym *, XComposeStatus *);
738 void XSetForeground(Display *, GC, unsigned long);
739 void XDrawLine(Display *, Drawable, GC, int, int, int, int);
740 void XDestroyImage(XImage *);
741 void XDestroyWindow(Display *, Window);
742 Bool XQueryPointer(Display *, Window, Window *, Window *, int *, int *,
743 int *, int *, unsigned int *);
744 void XAutoRepeatOn(Display *);
745 void XAutoRepeatOff(Display *);
747 void AllegroDrawLine(Drawable, int, int, int, int, Pixel);
748 Pixel AllegroGetPixel(Drawable, int, int);
750 void AllegroZoomBitmap(Drawable, Drawable, int, int, int, int);
752 void MSDOSOpenAudio(void);
753 void MSDOSCloseAudio(void);
755 void NetworkServer(int, int);
757 void MSDOSInitJoysticks();
758 boolean MSDOSReadJoystick(int, int *, int *, boolean *, boolean *);