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 ***********************************************************/
17 #if defined(PLATFORM_MSDOS)
25 #define AllegroDefaultScreen() (display->screens[display->default_screen])
27 /* allegro driver declarations */
28 DECLARE_GFX_DRIVER_LIST(GFX_DRIVER_VBEAF GFX_DRIVER_VESA2L GFX_DRIVER_VESA1)
29 DECLARE_COLOR_DEPTH_LIST(COLOR_DEPTH_8)
30 DECLARE_DIGI_DRIVER_LIST(DIGI_DRIVER_SB)
31 DECLARE_MIDI_DRIVER_LIST()
32 DECLARE_JOYSTICK_DRIVER_LIST(JOYSTICK_DRIVER_STANDARD)
34 /* allegro global variables */
35 extern volatile int key_shifts;
36 extern int num_joysticks;
37 extern JOYSTICK_INFO joy[];
38 extern int i_love_bill;
40 /* internal variables of msdos.c */
41 static boolean keyboard_auto_repeat = TRUE;
42 static int key_press_state[MAX_SCANCODES];
43 static XEvent event_buffer[MAX_EVENT_BUFFER];
44 static int pending_events;
45 static boolean joystick_event;
46 static boolean mouse_installed = FALSE;
47 static int last_mouse_pos;
48 static int last_mouse_b;
49 static int last_joystick_state;
50 static BITMAP* video_bitmap;
52 static RGB global_colormap[MAX_COLORS];
53 static int global_colormap_entries_used = 0;
55 boolean wait_for_vsync;
57 static BITMAP *Read_PCX_to_AllegroBitmap(char *);
59 static void allegro_init_drivers()
63 for (i=0; i<MAX_EVENT_BUFFER; i++)
64 event_buffer[i].type = 0;
66 for (i=0; i<MAX_SCANCODES; i++)
67 key_press_state[i] = KeyReleaseMask;
69 last_mouse_pos = mouse_pos;
75 /* enable Windows friendly timer mode (already default under Windows) */
80 if (install_mouse() > 0)
81 mouse_installed = TRUE;
83 last_joystick_state = 0;
84 joystick_event = FALSE;
87 static boolean allegro_init_audio()
89 reserve_voices(NUM_MIXER_CHANNELS, 0);
91 if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1)
92 if (install_sound(DIGI_SB, MIDI_NONE, NULL) == -1)
98 static boolean hide_mouse(Display *display, int x, int y,
99 unsigned int width, unsigned int height)
101 if (mouse_x + display->mouse_ptr->w < x || mouse_x > x + width)
103 if (mouse_y + display->mouse_ptr->h < y || mouse_y > y + height)
111 static void unhide_mouse(Display *display)
114 show_mouse(video_bitmap);
117 static KeySym ScancodeToKeySym(byte scancode)
121 case KEY_ESC: return XK_Escape;
122 case KEY_1: return XK_1;
123 case KEY_2: return XK_2;
124 case KEY_3: return XK_3;
125 case KEY_4: return XK_4;
126 case KEY_5: return XK_5;
127 case KEY_6: return XK_6;
128 case KEY_7: return XK_7;
129 case KEY_8: return XK_8;
130 case KEY_9: return XK_9;
131 case KEY_0: return XK_0;
132 case KEY_MINUS: return XK_minus;
133 case KEY_EQUALS: return XK_equal;
134 case KEY_BACKSPACE: return XK_BackSpace;
135 case KEY_TAB: return XK_Tab;
136 case KEY_Q: return XK_q;
137 case KEY_W: return XK_w;
138 case KEY_E: return XK_e;
139 case KEY_R: return XK_r;
140 case KEY_T: return XK_t;
141 case KEY_Y: return XK_y;
142 case KEY_U: return XK_u;
143 case KEY_I: return XK_i;
144 case KEY_O: return XK_o;
145 case KEY_P: return XK_p;
146 case KEY_OPENBRACE: return XK_braceleft;
147 case KEY_CLOSEBRACE: return XK_braceright;
148 case KEY_ENTER: return XK_Return;
149 case KEY_LCONTROL: return XK_Control_L;
150 case KEY_A: return XK_a;
151 case KEY_S: return XK_s;
152 case KEY_D: return XK_d;
153 case KEY_F: return XK_f;
154 case KEY_G: return XK_g;
155 case KEY_H: return XK_h;
156 case KEY_J: return XK_j;
157 case KEY_K: return XK_k;
158 case KEY_L: return XK_l;
159 case KEY_COLON: return XK_colon;
160 case KEY_QUOTE: return XK_apostrophe;
161 case KEY_TILDE: return XK_asciitilde;
162 case KEY_LSHIFT: return XK_Shift_L;
163 case KEY_BACKSLASH: return XK_backslash;
164 case KEY_Z: return XK_z;
165 case KEY_X: return XK_x;
166 case KEY_C: return XK_c;
167 case KEY_V: return XK_v;
168 case KEY_B: return XK_b;
169 case KEY_N: return XK_n;
170 case KEY_M: return XK_m;
171 case KEY_COMMA: return XK_comma;
172 case KEY_STOP: return XK_period;
173 case KEY_SLASH: return XK_slash;
174 case KEY_RSHIFT: return XK_Shift_R;
175 case KEY_ASTERISK: return XK_KP_Multiply;
176 case KEY_ALT: return XK_Alt_L;
177 case KEY_SPACE: return XK_space;
178 case KEY_CAPSLOCK: return XK_Caps_Lock;
179 case KEY_F1: return XK_F1;
180 case KEY_F2: return XK_F2;
181 case KEY_F3: return XK_F3;
182 case KEY_F4: return XK_F4;
183 case KEY_F5: return XK_F5;
184 case KEY_F6: return XK_F6;
185 case KEY_F7: return XK_F7;
186 case KEY_F8: return XK_F8;
187 case KEY_F9: return XK_F9;
188 case KEY_F10: return XK_F10;
189 case KEY_NUMLOCK: return XK_Num_Lock;
190 case KEY_SCRLOCK: return XK_Scroll_Lock;
191 case KEY_HOME: return XK_Home;
192 case KEY_UP: return XK_Up;
193 case KEY_PGUP: return XK_Page_Up;
194 case KEY_MINUS_PAD: return XK_KP_Subtract;
195 case KEY_LEFT: return XK_Left;
196 case KEY_5_PAD: return XK_KP_5;
197 case KEY_RIGHT: return XK_Right;
198 case KEY_PLUS_PAD: return XK_KP_Add;
199 case KEY_END: return XK_End;
200 case KEY_DOWN: return XK_Down;
201 case KEY_PGDN: return XK_Page_Down;
202 case KEY_INSERT: return XK_Insert;
203 case KEY_DEL: return XK_Delete;
204 case KEY_PRTSCR: return XK_Print;
205 case KEY_F11: return XK_F11;
206 case KEY_F12: return XK_F12;
207 case KEY_LWIN: return XK_Meta_L;
208 case KEY_RWIN: return XK_Meta_R;
209 case KEY_MENU: return XK_Menu;
210 case KEY_PAD: return XK_VoidSymbol;
211 case KEY_RCONTROL: return XK_Control_R;
212 case KEY_ALTGR: return XK_Alt_R;
213 case KEY_SLASH2: return XK_KP_Divide;
214 case KEY_PAUSE: return XK_Pause;
216 case NEW_KEY_BACKSLASH: return XK_backslash;
217 case NEW_KEY_1_PAD: return XK_KP_1;
218 case NEW_KEY_2_PAD: return XK_KP_2;
219 case NEW_KEY_3_PAD: return XK_KP_3;
220 case NEW_KEY_4_PAD: return XK_KP_4;
221 case NEW_KEY_5_PAD: return XK_KP_5;
222 case NEW_KEY_6_PAD: return XK_KP_6;
223 case NEW_KEY_7_PAD: return XK_KP_7;
224 case NEW_KEY_8_PAD: return XK_KP_8;
225 case NEW_KEY_9_PAD: return XK_KP_9;
226 case NEW_KEY_0_PAD: return XK_KP_0;
227 case NEW_KEY_STOP_PAD: return XK_KP_Separator;
228 case NEW_KEY_EQUALS_PAD: return XK_KP_Equal;
229 case NEW_KEY_SLASH_PAD: return XK_KP_Divide;
230 case NEW_KEY_ASTERISK_PAD: return XK_KP_Multiply;
231 case NEW_KEY_ENTER_PAD: return XK_KP_Enter;
233 default: return XK_VoidSymbol;
237 Pixel AllegroAllocColorCell(int r, int g, int b)
239 byte pixel_mapping = 0;
246 /* try to use existing colors from the global colormap */
247 for (i=0; i<global_colormap_entries_used; i++)
249 if (r == global_colormap[i].r &&
250 g == global_colormap[i].g &&
251 b == global_colormap[i].b) /* color found */
258 if (i == global_colormap_entries_used) /* color not found */
260 if (global_colormap_entries_used < MAX_COLORS)
261 global_colormap_entries_used++;
263 i = global_colormap_entries_used - 1;
265 global_colormap[i].r = r;
266 global_colormap[i].g = g;
267 global_colormap[i].b = b;
269 set_palette(global_colormap);
274 return pixel_mapping;
277 void XMapWindow(Display *display, Window window)
280 unsigned int width, height;
283 x = AllegroDefaultScreen().x;
284 y = AllegroDefaultScreen().y;
285 width = AllegroDefaultScreen().width;
286 height = AllegroDefaultScreen().height;
288 mouse_off = hide_mouse(display, x, y, width, height);
289 blit((BITMAP *)window, video_bitmap, 0, 0, x, y, width, height);
292 unhide_mouse(display);
295 Display *XOpenDisplay(char *display_name)
299 BITMAP *mouse_bitmap = NULL;
300 char *mouse_filename =getCustomImageFilename(program.msdos_pointer_filename);
302 if ((mouse_bitmap = Read_PCX_to_AllegroBitmap(mouse_filename)) == NULL)
305 screen = malloc(sizeof(Screen));
306 display = malloc(sizeof(Display));
310 screen[0].white_pixel = AllegroAllocColorCell(0xFFFF, 0xFFFF, 0xFFFF);
311 screen[0].black_pixel = AllegroAllocColorCell(0x0000, 0x0000, 0x0000);
312 screen[0].video_bitmap = NULL;
314 display->default_screen = 0;
315 display->screens = screen;
316 display->mouse_ptr = mouse_bitmap;
319 allegro_init_drivers();
322 /* force Windows 95 to switch to fullscreen mode */
323 set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
325 set_gfx_mode(GFX_AUTODETECT, XRES, YRES, 0, 0);
330 Window XCreateSimpleWindow(Display *display, Window parent, int x, int y,
331 unsigned int width, unsigned int height,
332 unsigned int border_width, unsigned long border,
333 unsigned long background)
335 video_bitmap = create_video_bitmap(XRES, YRES);
336 clear_to_color(video_bitmap, background);
338 AllegroDefaultScreen().video_bitmap = video_bitmap;
339 AllegroDefaultScreen().x = x;
340 AllegroDefaultScreen().y = y;
341 AllegroDefaultScreen().width = XRES;
342 AllegroDefaultScreen().height = YRES;
344 set_mouse_sprite(display->mouse_ptr);
347 set_mouse_sprite_focus(1, 1);
350 set_mouse_speed(1, 1);
351 set_mouse_range(AllegroDefaultScreen().x + 1,
352 AllegroDefaultScreen().y + 1,
353 AllegroDefaultScreen().x + video.width + 1,
354 AllegroDefaultScreen().y + video.height + 1);
356 show_video_bitmap(video_bitmap);
358 return (Window)video_bitmap;
361 Status XStringListToTextProperty(char **list, int count,
362 XTextProperty *text_prop_return)
368 string = malloc(strlen(list[0] + 1));
369 strcpy(string, list[0]);
370 text_prop_return->value = (unsigned char *)string;
374 text_prop_return = NULL;
379 void XFree(void *data)
385 GC XCreateGC(Display *display, Drawable d, unsigned long value_mask,
389 gcv = malloc(sizeof(XGCValues));
390 gcv->foreground = values->foreground;
391 gcv->background = values->background;
392 gcv->graphics_exposures = values->graphics_exposures;
393 gcv->clip_mask = values->clip_mask;
394 gcv->clip_x_origin = values->clip_x_origin;
395 gcv->clip_y_origin = values->clip_y_origin;
396 gcv->value_mask = value_mask;
400 void XSetClipMask(Display *display, GC gc, Pixmap pixmap)
402 XGCValues *gcv = (XGCValues *)gc;
404 gcv->clip_mask = pixmap;
405 gcv->value_mask |= GCClipMask;
408 void XSetClipOrigin(Display *display, GC gc, int x, int y)
410 XGCValues *gcv = (XGCValues *)gc;
412 gcv->clip_x_origin = x;
413 gcv->clip_x_origin = y;
416 void XFillRectangle(Display *display, Drawable d, GC gc, int x, int y,
417 unsigned int width, unsigned int height)
419 boolean mouse_off = FALSE;
421 if ((BITMAP *)d == video_bitmap)
423 x += AllegroDefaultScreen().x;
424 y += AllegroDefaultScreen().y;
425 freeze_mouse_flag = TRUE;
426 mouse_off = hide_mouse(display, x, y, width, height);
429 rectfill((BITMAP *)d, x, y, x + width - 1, y + height - 1,
430 ((XGCValues *)gc)->foreground);
433 unhide_mouse(display);
435 freeze_mouse_flag = FALSE;
438 Pixmap XCreatePixmap(Display *display, Drawable d, unsigned int width,
439 unsigned int height, unsigned int depth)
441 BITMAP *bitmap = NULL;
443 if (gfx_capabilities & GFX_HW_VRAM_BLIT &&
444 width == gfx.scrollbuffer_width && height == gfx.scrollbuffer_height)
445 bitmap = create_video_bitmap(width, height);
448 bitmap = create_bitmap(width, height);
450 return (Pixmap)bitmap;
453 void XSync(Display *display, Bool discard_events)
455 wait_for_vsync = TRUE;
458 inline void XCopyArea(Display *display, Drawable src, Drawable dest, GC gc,
459 int src_x, int src_y,
460 unsigned int width, unsigned int height,
461 int dest_x, int dest_y)
463 boolean mouse_off = FALSE;
465 if ((BITMAP *)src == video_bitmap)
467 src_x += AllegroDefaultScreen().x;
468 src_y += AllegroDefaultScreen().y;
471 if ((BITMAP *)dest == video_bitmap)
473 dest_x += AllegroDefaultScreen().x;
474 dest_y += AllegroDefaultScreen().y;
475 freeze_mouse_flag = TRUE;
476 mouse_off = hide_mouse(display, dest_x, dest_y, width, height);
481 wait_for_vsync = FALSE;
485 if (((XGCValues *)gc)->value_mask & GCClipMask)
486 masked_blit((BITMAP *)src, (BITMAP *)dest, src_x, src_y, dest_x, dest_y,
489 blit((BITMAP *)src, (BITMAP *)dest, src_x, src_y, dest_x, dest_y,
493 unhide_mouse(display);
495 freeze_mouse_flag = FALSE;
498 static BITMAP *Image_to_AllegroBitmap(Image *image)
501 byte *src_ptr = image->data;
502 byte pixel_mapping[MAX_COLORS];
503 unsigned int depth = 8;
506 if (image->type == IMAGETYPE_TRUECOLOR && depth == 8)
507 Error(ERR_EXIT, "cannot handle true-color images on 8-bit display");
509 /* allocate new allegro bitmap structure */
510 if ((bitmap = create_bitmap_ex(depth, image->width, image->height)) == NULL)
512 errno_pcx = PCX_NoMemory;
518 /* try to use existing colors from the global colormap */
519 for (i=0; i<MAX_COLORS; i++)
521 if (!image->rgb.color_used[i])
524 pixel_mapping[i] = AllegroAllocColorCell(image->rgb.red[i],
529 /* copy bitmap data */
530 for (y=0; y<image->height; y++)
531 for (x=0; x<image->width; x++)
532 putpixel(bitmap, x, y, pixel_mapping[*src_ptr++]);
537 static BITMAP *Read_PCX_to_AllegroBitmap(char *filename)
542 /* read the graphic file in PCX format to internal image structure */
543 if ((image = Read_PCX_to_Image(filename)) == NULL)
546 /* convert internal image structure to allegro bitmap structure */
547 if ((bitmap = Image_to_AllegroBitmap(image)) == NULL)
550 set_palette(global_colormap);
555 int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename,
556 Pixmap *pixmap, Pixmap *pixmap_mask)
560 if ((bitmap = Read_PCX_to_AllegroBitmap(filename)) == NULL)
563 *pixmap = (Pixmap)bitmap;
565 /* pixmap_mask will never be used in Allegro (which uses masked_blit()),
566 so use non-NULL dummy pointer to empty Pixmap */
567 *pixmap_mask = (Pixmap)DUMMY_MASK;
572 int XReadBitmapFile(Display *display, Drawable d, char *filename,
573 unsigned int *width_return, unsigned int *height_return,
574 Pixmap *bitmap_return,
575 int *x_hot_return, int *y_hot_return)
579 if ((bitmap = Read_PCX_to_AllegroBitmap(filename)) == NULL)
580 return BitmapOpenFailed;
582 *width_return = bitmap->w;
583 *height_return = bitmap->h;
586 *bitmap_return = (Pixmap)bitmap;
588 return BitmapSuccess;
591 void XFreePixmap(Display *display, Pixmap pixmap)
593 if (pixmap != DUMMY_MASK &&
594 (is_memory_bitmap((BITMAP *)pixmap) ||
595 is_screen_bitmap((BITMAP *)pixmap)))
596 destroy_bitmap((BITMAP *)pixmap);
599 void XFreeGC(Display *display, GC gc)
603 gcv = (XGCValues *)gc;
608 void XUnmapWindow(Display *display, Window window)
612 void XCloseDisplay(Display *display)
614 BITMAP *bitmap = video_bitmap;
616 if (is_screen_bitmap(bitmap))
617 destroy_bitmap(bitmap);
619 if (display->screens)
620 free(display->screens);
625 /* return to text mode (or DOS box on Windows screen) */
626 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
629 void XNextEvent(Display *display, XEvent *event_return)
631 while (!pending_events)
634 memcpy(event_return, &event_buffer[pending_events], sizeof(XEvent));
638 static void NewKeyEvent(int key_press_state, KeySym keysym)
642 if (pending_events >= MAX_EVENT_BUFFER)
646 xkey = (XKeyEvent *)&event_buffer[pending_events];
647 xkey->type = key_press_state;
648 xkey->state = (unsigned int)keysym;
651 #define HANDLE_RAW_KB_ALL_KEYS 0
652 #define HANDLE_RAW_KB_MODIFIER_KEYS_ONLY 1
654 static int modifier_scancode[] =
670 static void HandleKeyboardRaw(int mode)
674 for (i=0; i<MAX_SCANCODES; i++)
676 int scancode, new_state, event_type;
679 if (mode == HANDLE_RAW_KB_MODIFIER_KEYS_ONLY)
681 if ((scancode = modifier_scancode[i]) == -1)
687 key_pressed = key[scancode];
688 new_state = (key_pressed ? KeyPressMask : KeyReleaseMask);
689 event_type = (key_pressed ? KeyPress : KeyRelease);
691 if (key_press_state[i] == new_state) /* state not changed */
694 key_press_state[i] = new_state;
696 NewKeyEvent(event_type, ScancodeToKeySym(scancode));
700 static void HandleKeyboardEvent()
704 int key_info = readkey();
705 int scancode = (key_info >> 8);
706 int ascii = (key_info & 0xff);
707 KeySym keysym = ScancodeToKeySym(scancode);
709 if (scancode == KEY_PAD)
711 /* keys on the numeric keypad return just scancode 'KEY_PAD'
712 for some reason, so we must handle them separately */
714 if (ascii >= '0' && ascii <= '9')
715 keysym = XK_KP_0 + (KeySym)(ascii - '0');
716 else if (ascii == '.')
717 keysym = XK_KP_Separator;
719 else if (ascii >= ' ' && ascii <= 'Z')
720 keysym = XK_space + (KeySym)(ascii - ' ');
721 else if (ascii == '^')
722 keysym = XK_asciicircum;
723 else if (ascii == '_')
724 keysym = XK_underscore;
725 else if (ascii == 'Ä')
726 keysym = XK_Adiaeresis;
727 else if (ascii == 'Ö')
728 keysym = XK_Odiaeresis;
729 else if (ascii == 'Ü')
730 keysym = XK_Udiaeresis;
731 else if (ascii == 'ä')
732 keysym = XK_adiaeresis;
733 else if (ascii == 'ö')
734 keysym = XK_odiaeresis;
735 else if (ascii == 'ü')
736 keysym = XK_udiaeresis;
737 else if (ascii == 'ß')
740 NewKeyEvent(KeyPress, keysym);
742 else if (key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))
744 /* the allegro function keypressed() does not give us single pressed
745 modifier keys, so we must detect them with the internal global
746 allegro variable 'key_shifts' and then handle them separately */
748 HandleKeyboardRaw(HANDLE_RAW_KB_MODIFIER_KEYS_ONLY);
752 int XPending(Display *display)
754 XButtonEvent *xbutton;
755 XMotionEvent *xmotion;
758 /* When using 'HandleKeyboardRaw()', keyboard input is also stored in
759 the allegro keyboard input buffer and would be available a second
760 time by calling 'HandleKeyboardEvent()'. To avoid double keyboard
761 events, the allegro function 'clear_keybuf()' must be called each
762 time when switching from calling 'HandleKeyboardRaw()' to calling
763 'HandleKeyboardEvent()' to get keyboard input, which is actually
764 done by 'XAutoRepeatOn()' which sets keyboard_auto_repeat to TRUE. */
767 if (keyboard_auto_repeat)
768 HandleKeyboardEvent();
770 HandleKeyboardRaw(HANDLE_RAW_KB_ALL_KEYS);
772 /* mouse motion event */
773 if (mouse_pos != last_mouse_pos)
775 last_mouse_pos = mouse_pos;
777 xmotion = (XMotionEvent *)&event_buffer[pending_events];
778 xmotion->type = MotionNotify;
779 xmotion->x = mouse_x - AllegroDefaultScreen().x;
780 xmotion->y = mouse_y - AllegroDefaultScreen().y;
783 /* mouse button event */
784 if (mouse_b != last_mouse_b)
786 for (i=0; i<3; i++) /* check all three mouse buttons */
788 int bitmask = (1 << i);
790 if ((last_mouse_b & bitmask) != (mouse_b & bitmask))
792 int mapping[3] = { 1, 3, 2 };
795 xbutton = (XButtonEvent *)&event_buffer[pending_events];
796 xbutton->type = (mouse_b & bitmask ? ButtonPress : ButtonRelease);
797 xbutton->button = mapping[i];
798 xbutton->x = mouse_x - AllegroDefaultScreen().x;
799 xbutton->y = mouse_y - AllegroDefaultScreen().y;
802 last_mouse_b = mouse_b;
805 return pending_events;
808 KeySym XLookupKeysym(XKeyEvent *key_event, int index)
810 return key_event->state;
813 int XLookupString(XKeyEvent *key_event, char *buffer, int buffer_size,
814 KeySym *key, XComposeStatus *compose)
816 *key = key_event->state;
820 void XSetForeground(Display *display, GC gc, unsigned long pixel)
822 XGCValues *gcv = (XGCValues *)gc;
824 gcv->foreground = pixel;
827 void XDrawLine(Display *display, Drawable d, GC gc,
828 int x1, int y1, int x2, int y2)
830 XGCValues *gcv = (XGCValues *)gc;
831 boolean mouse_off = FALSE;
833 if ((BITMAP *)d == video_bitmap)
835 x1 += AllegroDefaultScreen().x;
836 y1 += AllegroDefaultScreen().y;
837 x2 += AllegroDefaultScreen().x;
838 y2 += AllegroDefaultScreen().y;
839 freeze_mouse_flag = TRUE;
840 mouse_off = hide_mouse(display, MIN(x1, x2), MIN(y1, y2),
841 MAX(x1, x2) - MIN(x1, x2),
842 MAX(y1, y2) - MIN(y1, y2));
845 line((BITMAP *)d, x1, y1, x2, y2, gcv->foreground);
848 unhide_mouse(display);
850 freeze_mouse_flag = FALSE;
853 void XDestroyImage(XImage *ximage)
857 void XDestroyWindow(Display *display, Window window)
861 Bool XQueryPointer(Display *display, Window window,
862 Window *root, Window *child, int *root_x, int *root_y,
863 int *win_x, int *win_y, unsigned int *mask)
865 *win_x = mouse_x - AllegroDefaultScreen().x;
866 *win_y = mouse_y - AllegroDefaultScreen().y;
871 void XAutoRepeatOn(Display *display)
873 keyboard_auto_repeat = TRUE;
877 void XAutoRepeatOff(Display *display)
879 keyboard_auto_repeat = FALSE;
882 void AllegroDrawLine(Drawable d, int from_x, int from_y, int to_x, int to_y,
885 boolean mouse_off = FALSE;
887 if ((BITMAP *)d == video_bitmap)
889 int dx = AllegroDefaultScreen().x;
890 int dy = AllegroDefaultScreen().y;
898 x1 = (from_x < to_x ? from_x : to_x);
899 y1 = (from_y < to_y ? from_y : to_y);
900 x2 = (from_x < to_x ? to_x : from_x);
901 y2 = (from_y < to_y ? to_y : from_y);
903 freeze_mouse_flag = TRUE;
904 mouse_off = hide_mouse(display, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
907 line((BITMAP *)d, from_x, from_y, to_x, to_y, color);
910 unhide_mouse(display);
912 freeze_mouse_flag = FALSE;
915 Pixel AllegroGetPixel(Drawable d, int x, int y)
917 return getpixel((BITMAP *)d, x, y);
920 void MSDOSOpenAudio(void)
922 if (allegro_init_audio())
924 audio.sound_available = TRUE;
925 audio.music_available = TRUE;
926 audio.loops_available = TRUE;
927 audio.sound_enabled = TRUE;
929 audio.num_channels = NUM_MIXER_CHANNELS;
930 audio.music_channel = MUSIC_CHANNEL;
931 audio.first_sound_channel = FIRST_SOUND_CHANNEL;
933 Mixer_InitChannels();
937 void MSDOSCloseAudio(void)
939 /* nothing to be done here */
942 void NetworkServer(int port, int serveronly)
944 Error(ERR_WARN, "networking not supported in DOS version");
948 /* ========================================================================= */
949 /* joystick functions */
950 /* ========================================================================= */
952 void MSDOSInitJoysticks()
956 /* start from scratch */
959 /* try to access two joysticks; if that fails, try to access just one */
960 if (install_joystick(JOY_TYPE_2PADS) == 0 ||
961 install_joystick(JOY_TYPE_AUTODETECT) == 0)
962 joystick.status = JOYSTICK_ACTIVATED;
964 for (i=0; i<MAX_PLAYERS; i++)
966 char *device_name = setup.input[i].joy.device_name;
967 int joystick_nr = getJoystickNrFromDeviceName(device_name);
969 if (joystick_nr >= num_joysticks)
972 /* misuse joystick file descriptor variable to store joystick number */
973 joystick.fd[i] = joystick_nr;
977 boolean MSDOSReadJoystick(int nr, int *x, int *y, boolean *b1, boolean *b2)
979 /* the allegro global variable 'num_joysticks' contains the number
980 of joysticks found at initialization under MS-DOS / Windows */
982 if (nr < 0 || nr >= num_joysticks)
988 *x = joy[nr].stick[0].axis[0].pos;
990 *y = joy[nr].stick[0].axis[1].pos;
993 *b1 = joy[nr].button[0].b;
995 *b2 = joy[nr].button[1].b;
1000 #endif /* PLATFORM_MSDOS */