1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2006 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_cursor_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)
384 GC XCreateGC(Display *display, Drawable d, unsigned long value_mask,
388 gcv = malloc(sizeof(XGCValues));
389 gcv->foreground = values->foreground;
390 gcv->background = values->background;
391 gcv->graphics_exposures = values->graphics_exposures;
392 gcv->clip_mask = values->clip_mask;
393 gcv->clip_x_origin = values->clip_x_origin;
394 gcv->clip_y_origin = values->clip_y_origin;
395 gcv->value_mask = value_mask;
399 void XSetClipMask(Display *display, GC gc, Pixmap pixmap)
401 XGCValues *gcv = (XGCValues *)gc;
403 gcv->clip_mask = pixmap;
404 gcv->value_mask |= GCClipMask;
407 void XSetClipOrigin(Display *display, GC gc, int x, int y)
409 XGCValues *gcv = (XGCValues *)gc;
411 gcv->clip_x_origin = x;
412 gcv->clip_x_origin = y;
415 void XFillRectangle(Display *display, Drawable d, GC gc, int x, int y,
416 unsigned int width, unsigned int height)
418 boolean mouse_off = FALSE;
420 if ((BITMAP *)d == video_bitmap)
422 x += AllegroDefaultScreen().x;
423 y += AllegroDefaultScreen().y;
424 freeze_mouse_flag = TRUE;
425 mouse_off = hide_mouse(display, x, y, width, height);
428 rectfill((BITMAP *)d, x, y, x + width - 1, y + height - 1,
429 ((XGCValues *)gc)->foreground);
432 unhide_mouse(display);
434 freeze_mouse_flag = FALSE;
437 Pixmap XCreatePixmap(Display *display, Drawable d, unsigned int width,
438 unsigned int height, unsigned int depth)
440 BITMAP *bitmap = NULL;
442 if (gfx_capabilities & GFX_HW_VRAM_BLIT &&
443 width == gfx.scrollbuffer_width && height == gfx.scrollbuffer_height)
444 bitmap = create_video_bitmap(width, height);
447 bitmap = create_bitmap(width, height);
449 return (Pixmap)bitmap;
452 void XSync(Display *display, Bool discard_events)
454 wait_for_vsync = TRUE;
457 inline void XCopyArea(Display *display, Drawable src, Drawable dest, GC gc,
458 int src_x, int src_y,
459 unsigned int width, unsigned int height,
460 int dest_x, int dest_y)
462 boolean mouse_off = FALSE;
464 if ((BITMAP *)src == video_bitmap)
466 src_x += AllegroDefaultScreen().x;
467 src_y += AllegroDefaultScreen().y;
470 if ((BITMAP *)dest == video_bitmap)
472 dest_x += AllegroDefaultScreen().x;
473 dest_y += AllegroDefaultScreen().y;
474 freeze_mouse_flag = TRUE;
475 mouse_off = hide_mouse(display, dest_x, dest_y, width, height);
480 wait_for_vsync = FALSE;
484 if (((XGCValues *)gc)->value_mask & GCClipMask)
485 masked_blit((BITMAP *)src, (BITMAP *)dest, src_x, src_y, dest_x, dest_y,
488 blit((BITMAP *)src, (BITMAP *)dest, src_x, src_y, dest_x, dest_y,
492 unhide_mouse(display);
494 freeze_mouse_flag = FALSE;
497 static BITMAP *Image_to_AllegroBitmap(Image *image)
500 byte *src_ptr = image->data;
501 byte pixel_mapping[MAX_COLORS];
502 unsigned int depth = 8;
505 if (image->type == IMAGETYPE_TRUECOLOR && depth == 8)
506 Error(ERR_EXIT, "cannot handle true-color images on 8-bit display");
508 /* allocate new allegro bitmap structure */
509 if ((bitmap = create_bitmap_ex(depth, image->width, image->height)) == NULL)
511 errno_pcx = PCX_NoMemory;
517 /* try to use existing colors from the global colormap */
518 for (i = 0; i < MAX_COLORS; i++)
520 if (!image->rgb.color_used[i])
523 pixel_mapping[i] = AllegroAllocColorCell(image->rgb.red[i],
528 /* copy bitmap data */
529 for (y = 0; y < image->height; y++)
530 for (x = 0; x < image->width; x++)
531 putpixel(bitmap, x, y, pixel_mapping[*src_ptr++]);
536 static BITMAP *Read_PCX_to_AllegroBitmap(char *filename)
541 /* read the graphic file in PCX format to internal image structure */
542 if ((image = Read_PCX_to_Image(filename)) == NULL)
545 /* convert internal image structure to allegro bitmap structure */
546 if ((bitmap = Image_to_AllegroBitmap(image)) == NULL)
549 set_palette(global_colormap);
554 int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename,
555 Pixmap *pixmap, Pixmap *pixmap_mask)
559 if ((bitmap = Read_PCX_to_AllegroBitmap(filename)) == NULL)
562 *pixmap = (Pixmap)bitmap;
564 /* pixmap_mask will never be used in Allegro (which uses masked_blit()),
565 so use non-NULL dummy pointer to empty Pixmap */
566 *pixmap_mask = (Pixmap)DUMMY_MASK;
571 int XReadBitmapFile(Display *display, Drawable d, char *filename,
572 unsigned int *width_return, unsigned int *height_return,
573 Pixmap *bitmap_return,
574 int *x_hot_return, int *y_hot_return)
578 if ((bitmap = Read_PCX_to_AllegroBitmap(filename)) == NULL)
579 return BitmapOpenFailed;
581 *width_return = bitmap->w;
582 *height_return = bitmap->h;
585 *bitmap_return = (Pixmap)bitmap;
587 return BitmapSuccess;
590 void XFreePixmap(Display *display, Pixmap pixmap)
592 if (pixmap != DUMMY_MASK &&
593 (is_memory_bitmap((BITMAP *)pixmap) ||
594 is_screen_bitmap((BITMAP *)pixmap)))
595 destroy_bitmap((BITMAP *)pixmap);
598 void XFreeGC(Display *display, GC gc)
600 XGCValues *gcv = (XGCValues *)gc;
605 void XUnmapWindow(Display *display, Window window)
609 void XCloseDisplay(Display *display)
611 BITMAP *bitmap = video_bitmap;
613 if (is_screen_bitmap(bitmap))
614 destroy_bitmap(bitmap);
616 checked_free(display->screens);
617 checked_free(display);
619 /* return to text mode (or DOS box on Windows screen) */
620 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
623 void XNextEvent(Display *display, XEvent *event_return)
625 while (!pending_events)
628 memcpy(event_return, &event_buffer[pending_events], sizeof(XEvent));
632 static void NewKeyEvent(int key_press_state, KeySym keysym)
636 if (pending_events >= MAX_EVENT_BUFFER)
640 xkey = (XKeyEvent *)&event_buffer[pending_events];
641 xkey->type = key_press_state;
642 xkey->state = (unsigned int)keysym;
645 #define HANDLE_RAW_KB_ALL_KEYS 0
646 #define HANDLE_RAW_KB_MODIFIER_KEYS_ONLY 1
648 static int modifier_scancode[] =
664 static void HandleKeyboardRaw(int mode)
668 for (i = 0; i < MAX_SCANCODES; i++)
670 int scancode, new_state, event_type;
673 if (mode == HANDLE_RAW_KB_MODIFIER_KEYS_ONLY)
675 if ((scancode = modifier_scancode[i]) == -1)
681 key_pressed = key[scancode];
682 new_state = (key_pressed ? KeyPressMask : KeyReleaseMask);
683 event_type = (key_pressed ? KeyPress : KeyRelease);
685 if (key_press_state[i] == new_state) /* state not changed */
688 key_press_state[i] = new_state;
690 NewKeyEvent(event_type, ScancodeToKeySym(scancode));
694 static void HandleKeyboardEvent()
698 int key_info = readkey();
699 int scancode = (key_info >> 8);
700 int ascii = (key_info & 0xff);
701 KeySym keysym = ScancodeToKeySym(scancode);
703 if (scancode == KEY_PAD)
705 /* keys on the numeric keypad return just scancode 'KEY_PAD'
706 for some reason, so we must handle them separately */
708 if (ascii >= '0' && ascii <= '9')
709 keysym = XK_KP_0 + (KeySym)(ascii - '0');
710 else if (ascii == '.')
711 keysym = XK_KP_Separator;
713 else if (ascii >= ' ' && ascii <= 'Z')
714 keysym = XK_space + (KeySym)(ascii - ' ');
715 else if (ascii == '^')
716 keysym = XK_asciicircum;
717 else if (ascii == '_')
718 keysym = XK_underscore;
719 else if (ascii == 'Ä')
720 keysym = XK_Adiaeresis;
721 else if (ascii == 'Ö')
722 keysym = XK_Odiaeresis;
723 else if (ascii == 'Ü')
724 keysym = XK_Udiaeresis;
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 == 'ß')
734 NewKeyEvent(KeyPress, keysym);
736 else if (key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))
738 /* the allegro function keypressed() does not give us single pressed
739 modifier keys, so we must detect them with the internal global
740 allegro variable 'key_shifts' and then handle them separately */
742 HandleKeyboardRaw(HANDLE_RAW_KB_MODIFIER_KEYS_ONLY);
746 int XPending(Display *display)
748 XButtonEvent *xbutton;
749 XMotionEvent *xmotion;
752 /* When using 'HandleKeyboardRaw()', keyboard input is also stored in
753 the allegro keyboard input buffer and would be available a second
754 time by calling 'HandleKeyboardEvent()'. To avoid double keyboard
755 events, the allegro function 'clear_keybuf()' must be called each
756 time when switching from calling 'HandleKeyboardRaw()' to calling
757 'HandleKeyboardEvent()' to get keyboard input, which is actually
758 done by 'XAutoRepeatOn()' which sets keyboard_auto_repeat to TRUE. */
761 if (keyboard_auto_repeat)
762 HandleKeyboardEvent();
764 HandleKeyboardRaw(HANDLE_RAW_KB_ALL_KEYS);
766 /* mouse motion event */
767 if (mouse_pos != last_mouse_pos)
769 last_mouse_pos = mouse_pos;
771 xmotion = (XMotionEvent *)&event_buffer[pending_events];
772 xmotion->type = MotionNotify;
773 xmotion->x = mouse_x - AllegroDefaultScreen().x;
774 xmotion->y = mouse_y - AllegroDefaultScreen().y;
777 /* mouse button event */
778 if (mouse_b != last_mouse_b)
780 for (i = 0; i < 3; i++) /* check all three mouse buttons */
782 int bitmask = (1 << i);
784 if ((last_mouse_b & bitmask) != (mouse_b & bitmask))
786 int mapping[3] = { 1, 3, 2 };
789 xbutton = (XButtonEvent *)&event_buffer[pending_events];
790 xbutton->type = (mouse_b & bitmask ? ButtonPress : ButtonRelease);
791 xbutton->button = mapping[i];
792 xbutton->x = mouse_x - AllegroDefaultScreen().x;
793 xbutton->y = mouse_y - AllegroDefaultScreen().y;
796 last_mouse_b = mouse_b;
799 return pending_events;
802 KeySym XLookupKeysym(XKeyEvent *key_event, int index)
804 return key_event->state;
807 int XLookupString(XKeyEvent *key_event, char *buffer, int buffer_size,
808 KeySym *key, XComposeStatus *compose)
810 *key = key_event->state;
814 void XSetForeground(Display *display, GC gc, unsigned long pixel)
816 XGCValues *gcv = (XGCValues *)gc;
818 gcv->foreground = pixel;
821 void XDrawLine(Display *display, Drawable d, GC gc,
822 int x1, int y1, int x2, int y2)
824 XGCValues *gcv = (XGCValues *)gc;
825 boolean mouse_off = FALSE;
827 if ((BITMAP *)d == video_bitmap)
829 x1 += AllegroDefaultScreen().x;
830 y1 += AllegroDefaultScreen().y;
831 x2 += AllegroDefaultScreen().x;
832 y2 += AllegroDefaultScreen().y;
833 freeze_mouse_flag = TRUE;
834 mouse_off = hide_mouse(display, MIN(x1, x2), MIN(y1, y2),
835 MAX(x1, x2) - MIN(x1, x2),
836 MAX(y1, y2) - MIN(y1, y2));
839 line((BITMAP *)d, x1, y1, x2, y2, gcv->foreground);
842 unhide_mouse(display);
844 freeze_mouse_flag = FALSE;
847 void XDestroyImage(XImage *ximage)
851 void XDestroyWindow(Display *display, Window window)
855 Bool XQueryPointer(Display *display, Window window,
856 Window *root, Window *child, int *root_x, int *root_y,
857 int *win_x, int *win_y, unsigned int *mask)
859 *win_x = mouse_x - AllegroDefaultScreen().x;
860 *win_y = mouse_y - AllegroDefaultScreen().y;
865 void XAutoRepeatOn(Display *display)
867 keyboard_auto_repeat = TRUE;
871 void XAutoRepeatOff(Display *display)
873 keyboard_auto_repeat = FALSE;
876 void AllegroDrawLine(Drawable d, int from_x, int from_y, int to_x, int to_y,
879 boolean mouse_off = FALSE;
881 if ((BITMAP *)d == video_bitmap)
883 int dx = AllegroDefaultScreen().x;
884 int dy = AllegroDefaultScreen().y;
892 x1 = (from_x < to_x ? from_x : to_x);
893 y1 = (from_y < to_y ? from_y : to_y);
894 x2 = (from_x < to_x ? to_x : from_x);
895 y2 = (from_y < to_y ? to_y : from_y);
897 freeze_mouse_flag = TRUE;
898 mouse_off = hide_mouse(display, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
901 line((BITMAP *)d, from_x, from_y, to_x, to_y, color);
904 unhide_mouse(display);
906 freeze_mouse_flag = FALSE;
909 Pixel AllegroGetPixel(Drawable d, int x, int y)
911 return getpixel((BITMAP *)d, x, y);
914 void AllegroZoomBitmap(Drawable src, Drawable dst,
915 int src_width, int src_height,
916 int dst_width, int dst_height)
918 stretch_blit((BITMAP *)src, (BITMAP *)dst,
919 0, 0, src_width, src_height, 0, 0, dst_width, dst_height);
922 void MSDOSOpenAudio(void)
924 if (allegro_init_audio())
926 audio.sound_available = TRUE;
927 audio.music_available = TRUE;
928 audio.loops_available = TRUE;
929 audio.sound_enabled = TRUE;
931 audio.num_channels = NUM_MIXER_CHANNELS;
932 audio.music_channel = MUSIC_CHANNEL;
933 audio.first_sound_channel = FIRST_SOUND_CHANNEL;
935 Mixer_InitChannels();
939 void MSDOSCloseAudio(void)
941 /* nothing to be done here */
944 void NetworkServer(int port, int serveronly)
946 Error(ERR_WARN, "networking not supported in DOS version");
950 /* ========================================================================= */
951 /* joystick functions */
952 /* ========================================================================= */
954 void MSDOSInitJoysticks()
958 /* start from scratch */
961 /* try to access two joysticks; if that fails, try to access just one */
962 if (install_joystick(JOY_TYPE_2PADS) == 0 ||
963 install_joystick(JOY_TYPE_AUTODETECT) == 0)
964 joystick.status = JOYSTICK_ACTIVATED;
966 for (i = 0; i < MAX_PLAYERS; i++)
968 char *device_name = setup.input[i].joy.device_name;
969 int joystick_nr = getJoystickNrFromDeviceName(device_name);
971 if (joystick_nr >= num_joysticks)
974 /* misuse joystick file descriptor variable to store joystick number */
975 joystick.fd[i] = joystick_nr;
979 boolean MSDOSReadJoystick(int nr, int *x, int *y, boolean *b1, boolean *b2)
981 /* the allegro global variable 'num_joysticks' contains the number
982 of joysticks found at initialization under MS-DOS / Windows */
984 if (nr < 0 || nr >= num_joysticks)
990 *x = joy[nr].stick[0].axis[0].pos;
992 *y = joy[nr].stick[0].axis[1].pos;
995 *b1 = joy[nr].button[0].b;
997 *b2 = joy[nr].button[1].b;
1002 #endif /* PLATFORM_MSDOS */