1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2000 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
17 #if defined(PLATFORM_MSDOS)
23 #define AllegroDefaultScreen() (display->screens[display->default_screen])
25 /* allegro driver declarations */
26 DECLARE_GFX_DRIVER_LIST(GFX_DRIVER_VBEAF GFX_DRIVER_VESA2L GFX_DRIVER_VESA1)
27 DECLARE_COLOR_DEPTH_LIST(COLOR_DEPTH_8)
28 DECLARE_DIGI_DRIVER_LIST(DIGI_DRIVER_SB)
29 DECLARE_MIDI_DRIVER_LIST()
30 DECLARE_JOYSTICK_DRIVER_LIST(JOYSTICK_DRIVER_STANDARD)
32 /* allegro global variables */
33 extern volatile int key_shifts;
34 extern int num_joysticks;
35 extern JOYSTICK_INFO joy[];
36 extern int i_love_bill;
38 /* internal variables of msdos.c */
39 static boolean keyboard_auto_repeat = TRUE;
40 static int key_press_state[MAX_SCANCODES];
41 static XEvent event_buffer[MAX_EVENT_BUFFER];
42 static int pending_events;
43 static boolean joystick_event;
44 static boolean mouse_installed = FALSE;
45 static int last_mouse_pos;
46 static int last_mouse_b;
47 static int last_joystick_state;
48 static BITMAP* video_bitmap;
50 static RGB global_colormap[MAX_COLORS];
51 static int global_colormap_entries_used = 0;
53 boolean wait_for_vsync;
56 extern int playing_sounds;
57 extern struct SoundControl playlist[MAX_SOUNDS_PLAYING];
58 extern struct SoundControl emptySoundControl;
61 static BITMAP *Read_PCX_to_AllegroBitmap(char *);
63 static void allegro_init_drivers()
67 for (i=0; i<MAX_EVENT_BUFFER; i++)
68 event_buffer[i].type = 0;
70 for (i=0; i<MAX_SCANCODES; i++)
71 key_press_state[i] = KeyReleaseMask;
73 last_mouse_pos = mouse_pos;
79 /* enable Windows friendly timer mode (already default under Windows) */
84 if (install_mouse() > 0)
85 mouse_installed = TRUE;
87 last_joystick_state = 0;
88 joystick_event = FALSE;
91 static boolean allegro_init_audio()
93 reserve_voices(MAX_SOUNDS_PLAYING, 0);
95 if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1)
96 if (install_sound(DIGI_SB, MIDI_NONE, NULL) == -1)
102 static boolean hide_mouse(Display *display, int x, int y,
103 unsigned int width, unsigned int height)
105 if (mouse_x + display->mouse_ptr->w < x || mouse_x > x + width)
107 if (mouse_y + display->mouse_ptr->h < y || mouse_y > y + height)
115 static void unhide_mouse(Display *display)
118 show_mouse(video_bitmap);
121 static KeySym ScancodeToKeySym(byte scancode)
125 case KEY_ESC: return XK_Escape;
126 case KEY_1: return XK_1;
127 case KEY_2: return XK_2;
128 case KEY_3: return XK_3;
129 case KEY_4: return XK_4;
130 case KEY_5: return XK_5;
131 case KEY_6: return XK_6;
132 case KEY_7: return XK_7;
133 case KEY_8: return XK_8;
134 case KEY_9: return XK_9;
135 case KEY_0: return XK_0;
136 case KEY_MINUS: return XK_minus;
137 case KEY_EQUALS: return XK_equal;
138 case KEY_BACKSPACE: return XK_BackSpace;
139 case KEY_TAB: return XK_Tab;
140 case KEY_Q: return XK_q;
141 case KEY_W: return XK_w;
142 case KEY_E: return XK_e;
143 case KEY_R: return XK_r;
144 case KEY_T: return XK_t;
145 case KEY_Y: return XK_y;
146 case KEY_U: return XK_u;
147 case KEY_I: return XK_i;
148 case KEY_O: return XK_o;
149 case KEY_P: return XK_p;
150 case KEY_OPENBRACE: return XK_braceleft;
151 case KEY_CLOSEBRACE: return XK_braceright;
152 case KEY_ENTER: return XK_Return;
153 case KEY_LCONTROL: return XK_Control_L;
154 case KEY_A: return XK_a;
155 case KEY_S: return XK_s;
156 case KEY_D: return XK_d;
157 case KEY_F: return XK_f;
158 case KEY_G: return XK_g;
159 case KEY_H: return XK_h;
160 case KEY_J: return XK_j;
161 case KEY_K: return XK_k;
162 case KEY_L: return XK_l;
163 case KEY_COLON: return XK_colon;
164 case KEY_QUOTE: return XK_apostrophe;
165 case KEY_TILDE: return XK_asciitilde;
166 case KEY_LSHIFT: return XK_Shift_L;
167 case KEY_BACKSLASH: return XK_backslash;
168 case KEY_Z: return XK_z;
169 case KEY_X: return XK_x;
170 case KEY_C: return XK_c;
171 case KEY_V: return XK_v;
172 case KEY_B: return XK_b;
173 case KEY_N: return XK_n;
174 case KEY_M: return XK_m;
175 case KEY_COMMA: return XK_comma;
176 case KEY_STOP: return XK_period;
177 case KEY_SLASH: return XK_slash;
178 case KEY_RSHIFT: return XK_Shift_R;
179 case KEY_ASTERISK: return XK_KP_Multiply;
180 case KEY_ALT: return XK_Alt_L;
181 case KEY_SPACE: return XK_space;
182 case KEY_CAPSLOCK: return XK_Caps_Lock;
183 case KEY_F1: return XK_F1;
184 case KEY_F2: return XK_F2;
185 case KEY_F3: return XK_F3;
186 case KEY_F4: return XK_F4;
187 case KEY_F5: return XK_F5;
188 case KEY_F6: return XK_F6;
189 case KEY_F7: return XK_F7;
190 case KEY_F8: return XK_F8;
191 case KEY_F9: return XK_F9;
192 case KEY_F10: return XK_F10;
193 case KEY_NUMLOCK: return XK_Num_Lock;
194 case KEY_SCRLOCK: return XK_Scroll_Lock;
195 case KEY_HOME: return XK_Home;
196 case KEY_UP: return XK_Up;
197 case KEY_PGUP: return XK_Page_Up;
198 case KEY_MINUS_PAD: return XK_KP_Subtract;
199 case KEY_LEFT: return XK_Left;
200 case KEY_5_PAD: return XK_KP_5;
201 case KEY_RIGHT: return XK_Right;
202 case KEY_PLUS_PAD: return XK_KP_Add;
203 case KEY_END: return XK_End;
204 case KEY_DOWN: return XK_Down;
205 case KEY_PGDN: return XK_Page_Down;
206 case KEY_INSERT: return XK_Insert;
207 case KEY_DEL: return XK_Delete;
208 case KEY_PRTSCR: return XK_Print;
209 case KEY_F11: return XK_F11;
210 case KEY_F12: return XK_F12;
211 case KEY_LWIN: return XK_Meta_L;
212 case KEY_RWIN: return XK_Meta_R;
213 case KEY_MENU: return XK_Menu;
214 case KEY_PAD: return XK_VoidSymbol;
215 case KEY_RCONTROL: return XK_Control_R;
216 case KEY_ALTGR: return XK_Alt_R;
217 case KEY_SLASH2: return XK_KP_Divide;
218 case KEY_PAUSE: return XK_Pause;
220 case NEW_KEY_BACKSLASH: return XK_backslash;
221 case NEW_KEY_1_PAD: return XK_KP_1;
222 case NEW_KEY_2_PAD: return XK_KP_2;
223 case NEW_KEY_3_PAD: return XK_KP_3;
224 case NEW_KEY_4_PAD: return XK_KP_4;
225 case NEW_KEY_5_PAD: return XK_KP_5;
226 case NEW_KEY_6_PAD: return XK_KP_6;
227 case NEW_KEY_7_PAD: return XK_KP_7;
228 case NEW_KEY_8_PAD: return XK_KP_8;
229 case NEW_KEY_9_PAD: return XK_KP_9;
230 case NEW_KEY_0_PAD: return XK_KP_0;
231 case NEW_KEY_STOP_PAD: return XK_KP_Separator;
232 case NEW_KEY_EQUALS_PAD: return XK_KP_Equal;
233 case NEW_KEY_SLASH_PAD: return XK_KP_Divide;
234 case NEW_KEY_ASTERISK_PAD: return XK_KP_Multiply;
235 case NEW_KEY_ENTER_PAD: return XK_KP_Enter;
237 default: return XK_VoidSymbol;
241 Pixel AllegroAllocColorCell(int r, int g, int b)
243 byte pixel_mapping = 0;
250 /* try to use existing colors from the global colormap */
251 for (i=0; i<global_colormap_entries_used; i++)
253 if (r == global_colormap[i].r &&
254 g == global_colormap[i].g &&
255 b == global_colormap[i].b) /* color found */
262 if (i == global_colormap_entries_used) /* color not found */
264 if (global_colormap_entries_used < MAX_COLORS)
265 global_colormap_entries_used++;
267 i = global_colormap_entries_used - 1;
269 global_colormap[i].r = r;
270 global_colormap[i].g = g;
271 global_colormap[i].b = b;
273 set_palette(global_colormap);
278 return pixel_mapping;
281 void XMapWindow(Display *display, Window window)
284 unsigned int width, height;
287 x = AllegroDefaultScreen().x;
288 y = AllegroDefaultScreen().y;
289 width = AllegroDefaultScreen().width;
290 height = AllegroDefaultScreen().height;
292 mouse_off = hide_mouse(display, x, y, width, height);
293 blit((BITMAP *)window, video_bitmap, 0, 0, x, y, width, height);
296 unhide_mouse(display);
299 Display *XOpenDisplay(char *display_name)
303 BITMAP *mouse_bitmap = NULL;
305 mouse_bitmap = Read_PCX_to_AllegroBitmap(program.msdos_pointer_filename);
306 if (mouse_bitmap == NULL)
309 screen = malloc(sizeof(Screen));
310 display = malloc(sizeof(Display));
315 screen[0].white_pixel = 0xFF;
316 screen[0].black_pixel = 0x00;
318 screen[0].white_pixel = AllegroAllocColorCell(0xFFFF, 0xFFFF, 0xFFFF);
319 screen[0].black_pixel = AllegroAllocColorCell(0x0000, 0x0000, 0x0000);
321 screen[0].video_bitmap = NULL;
323 display->default_screen = 0;
324 display->screens = screen;
325 display->mouse_ptr = mouse_bitmap;
328 allegro_init_drivers();
331 /* force Windows 95 to switch to fullscreen mode */
332 set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
334 set_gfx_mode(GFX_AUTODETECT, XRES, YRES, 0, 0);
339 Window XCreateSimpleWindow(Display *display, Window parent, int x, int y,
340 unsigned int width, unsigned int height,
341 unsigned int border_width, unsigned long border,
342 unsigned long background)
344 video_bitmap = create_video_bitmap(XRES, YRES);
345 clear_to_color(video_bitmap, background);
347 AllegroDefaultScreen().video_bitmap = video_bitmap;
348 AllegroDefaultScreen().x = x;
349 AllegroDefaultScreen().y = y;
350 AllegroDefaultScreen().width = XRES;
351 AllegroDefaultScreen().height = YRES;
353 set_mouse_sprite(display->mouse_ptr);
356 set_mouse_sprite_focus(1, 1);
359 set_mouse_speed(1, 1);
360 set_mouse_range(AllegroDefaultScreen().x + 1,
361 AllegroDefaultScreen().y + 1,
362 AllegroDefaultScreen().x + video.width + 1,
363 AllegroDefaultScreen().y + video.height + 1);
365 show_video_bitmap(video_bitmap);
367 return (Window)video_bitmap;
370 Status XStringListToTextProperty(char **list, int count,
371 XTextProperty *text_prop_return)
377 string = malloc(strlen(list[0] + 1));
378 strcpy(string, list[0]);
379 text_prop_return->value = (unsigned char *)string;
383 text_prop_return = NULL;
388 void XFree(void *data)
394 GC XCreateGC(Display *display, Drawable d, unsigned long value_mask,
398 gcv = malloc(sizeof(XGCValues));
399 gcv->foreground = values->foreground;
400 gcv->background = values->background;
401 gcv->graphics_exposures = values->graphics_exposures;
402 gcv->clip_mask = values->clip_mask;
403 gcv->clip_x_origin = values->clip_x_origin;
404 gcv->clip_y_origin = values->clip_y_origin;
405 gcv->value_mask = value_mask;
409 void XSetClipMask(Display *display, GC gc, Pixmap pixmap)
411 XGCValues *gcv = (XGCValues *)gc;
413 gcv->clip_mask = pixmap;
414 gcv->value_mask |= GCClipMask;
417 void XSetClipOrigin(Display *display, GC gc, int x, int y)
419 XGCValues *gcv = (XGCValues *)gc;
421 gcv->clip_x_origin = x;
422 gcv->clip_x_origin = y;
425 void XFillRectangle(Display *display, Drawable d, GC gc, int x, int y,
426 unsigned int width, unsigned int height)
428 boolean mouse_off = FALSE;
430 if ((BITMAP *)d == video_bitmap)
432 x += AllegroDefaultScreen().x;
433 y += AllegroDefaultScreen().y;
434 freeze_mouse_flag = TRUE;
435 mouse_off = hide_mouse(display, x, y, width, height);
438 rectfill((BITMAP *)d, x, y, x + width - 1, y + height - 1,
439 ((XGCValues *)gc)->foreground);
442 unhide_mouse(display);
444 freeze_mouse_flag = FALSE;
447 Pixmap XCreatePixmap(Display *display, Drawable d, unsigned int width,
448 unsigned int height, unsigned int depth)
450 BITMAP *bitmap = NULL;
452 if (gfx_capabilities & GFX_HW_VRAM_BLIT &&
453 width == gfx.scrollbuffer_width && height == gfx.scrollbuffer_height)
454 bitmap = create_video_bitmap(width, height);
457 bitmap = create_bitmap(width, height);
459 return (Pixmap)bitmap;
462 void XSync(Display *display, Bool discard_events)
464 wait_for_vsync = TRUE;
467 inline void XCopyArea(Display *display, Drawable src, Drawable dest, GC gc,
468 int src_x, int src_y,
469 unsigned int width, unsigned int height,
470 int dest_x, int dest_y)
472 boolean mouse_off = FALSE;
474 if ((BITMAP *)src == video_bitmap)
476 src_x += AllegroDefaultScreen().x;
477 src_y += AllegroDefaultScreen().y;
480 if ((BITMAP *)dest == video_bitmap)
482 dest_x += AllegroDefaultScreen().x;
483 dest_y += AllegroDefaultScreen().y;
484 freeze_mouse_flag = TRUE;
485 mouse_off = hide_mouse(display, dest_x, dest_y, width, height);
490 wait_for_vsync = FALSE;
494 if (((XGCValues *)gc)->value_mask & GCClipMask)
495 masked_blit((BITMAP *)src, (BITMAP *)dest, src_x, src_y, dest_x, dest_y,
498 blit((BITMAP *)src, (BITMAP *)dest, src_x, src_y, dest_x, dest_y,
502 unhide_mouse(display);
504 freeze_mouse_flag = FALSE;
507 static BITMAP *Image_to_AllegroBitmap(Image *image)
510 byte *src_ptr = image->data;
511 byte pixel_mapping[MAX_COLORS];
512 unsigned int depth = 8;
520 /* allocate new allegro bitmap structure */
521 if ((bitmap = create_bitmap_ex(depth, image->width, image->height)) == NULL)
523 errno_pcx = PCX_NoMemory;
529 /* try to use existing colors from the global colormap */
530 for (i=0; i<MAX_COLORS; i++)
537 if (!image->rgb.color_used[i])
542 r = image->rgb.red[i] >> 10;
543 g = image->rgb.green[i] >> 10;
544 b = image->rgb.blue[i] >> 10;
546 for (j=0; j<global_colormap_entries_used; j++)
548 if (r == global_colormap[j].r &&
549 g == global_colormap[j].g &&
550 b == global_colormap[j].b) /* color found */
552 pixel_mapping[i] = j;
557 if (j == global_colormap_entries_used) /* color not found */
559 if (global_colormap_entries_used < MAX_COLORS)
560 global_colormap_entries_used++;
562 global_colormap[j].r = r;
563 global_colormap[j].g = g;
564 global_colormap[j].b = b;
566 pixel_mapping[i] = j;
569 pixel_mapping[i] = AllegroAllocColorCell(image->rgb.red[i],
576 /* copy bitmap data */
577 for (y=0; y<image->height; y++)
578 for (x=0; x<image->width; x++)
579 putpixel(bitmap, x, y, pixel_mapping[*src_ptr++]);
584 static BITMAP *Read_PCX_to_AllegroBitmap(char *filename)
589 /* read the graphic file in PCX format to internal image structure */
590 if ((image = Read_PCX_to_Image(filename)) == NULL)
593 /* convert internal image structure to allegro bitmap structure */
594 if ((bitmap = Image_to_AllegroBitmap(image)) == NULL)
597 set_palette(global_colormap);
602 int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename,
603 Pixmap *pixmap, Pixmap *pixmap_mask)
607 if ((bitmap = Read_PCX_to_AllegroBitmap(filename)) == NULL)
610 *pixmap = (Pixmap)bitmap;
612 *pixmap_mask = (Pixmap)bitmap;
613 /* !!! two pointers on same bitmap => second free() fails !!! */
615 /* pixmap_mask will never be used in Allegro (which uses masked_blit()),
616 so use non-NULL dummy pointer to empty Pixmap */
618 *pixmap_mask = (Pixmap)checked_calloc(sizeof(Pixmap));
620 *pixmap_mask = (Pixmap)DUMMY_MASK;
626 int XReadBitmapFile(Display *display, Drawable d, char *filename,
627 unsigned int *width_return, unsigned int *height_return,
628 Pixmap *bitmap_return,
629 int *x_hot_return, int *y_hot_return)
633 if ((bitmap = Read_PCX_to_AllegroBitmap(filename)) == NULL)
634 return BitmapOpenFailed;
636 *width_return = bitmap->w;
637 *height_return = bitmap->h;
640 *bitmap_return = (Pixmap)bitmap;
642 return BitmapSuccess;
645 void XFreePixmap(Display *display, Pixmap pixmap)
647 if (pixmap != DUMMY_MASK &&
648 (is_memory_bitmap((BITMAP *)pixmap) ||
649 is_screen_bitmap((BITMAP *)pixmap)))
650 destroy_bitmap((BITMAP *)pixmap);
653 void XFreeGC(Display *display, GC gc)
657 gcv = (XGCValues *)gc;
662 void XUnmapWindow(Display *display, Window window)
666 void XCloseDisplay(Display *display)
668 BITMAP *bitmap = video_bitmap;
670 if (is_screen_bitmap(bitmap))
671 destroy_bitmap(bitmap);
673 if (display->screens)
674 free(display->screens);
679 /* return to text mode (or DOS box on Windows screen) */
680 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
683 void XNextEvent(Display *display, XEvent *event_return)
685 while (!pending_events)
688 memcpy(event_return, &event_buffer[pending_events], sizeof(XEvent));
692 static void NewKeyEvent(int key_press_state, KeySym keysym)
696 if (pending_events >= MAX_EVENT_BUFFER)
700 xkey = (XKeyEvent *)&event_buffer[pending_events];
701 xkey->type = key_press_state;
702 xkey->state = (unsigned int)keysym;
705 #define HANDLE_RAW_KB_ALL_KEYS 0
706 #define HANDLE_RAW_KB_MODIFIER_KEYS_ONLY 1
708 static int modifier_scancode[] =
724 static void HandleKeyboardRaw(int mode)
728 for (i=0; i<MAX_SCANCODES; i++)
730 int scancode, new_state, event_type;
733 if (mode == HANDLE_RAW_KB_MODIFIER_KEYS_ONLY)
735 if ((scancode = modifier_scancode[i]) == -1)
741 key_pressed = key[scancode];
742 new_state = (key_pressed ? KeyPressMask : KeyReleaseMask);
743 event_type = (key_pressed ? KeyPress : KeyRelease);
745 if (key_press_state[i] == new_state) /* state not changed */
748 key_press_state[i] = new_state;
750 NewKeyEvent(event_type, ScancodeToKeySym(scancode));
754 static void HandleKeyboardEvent()
758 int key_info = readkey();
759 int scancode = (key_info >> 8);
760 int ascii = (key_info & 0xff);
761 KeySym keysym = ScancodeToKeySym(scancode);
763 if (scancode == KEY_PAD)
765 /* keys on the numeric keypad return just scancode 'KEY_PAD'
766 for some reason, so we must handle them separately */
768 if (ascii >= '0' && ascii <= '9')
769 keysym = XK_KP_0 + (KeySym)(ascii - '0');
770 else if (ascii == '.')
771 keysym = XK_KP_Separator;
773 else if (ascii >= ' ' && ascii <= 'Z')
774 keysym = XK_space + (KeySym)(ascii - ' ');
775 else if (ascii == '^')
776 keysym = XK_asciicircum;
777 else if (ascii == '_')
778 keysym = XK_underscore;
779 else if (ascii == 'Ä')
780 keysym = XK_Adiaeresis;
781 else if (ascii == 'Ö')
782 keysym = XK_Odiaeresis;
783 else if (ascii == 'Ü')
784 keysym = XK_Udiaeresis;
785 else if (ascii == 'ä')
786 keysym = XK_adiaeresis;
787 else if (ascii == 'ö')
788 keysym = XK_odiaeresis;
789 else if (ascii == 'ü')
790 keysym = XK_udiaeresis;
791 else if (ascii == 'ß')
794 NewKeyEvent(KeyPress, keysym);
796 else if (key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))
798 /* the allegro function keypressed() does not give us single pressed
799 modifier keys, so we must detect them with the internal global
800 allegro variable 'key_shifts' and then handle them separately */
802 HandleKeyboardRaw(HANDLE_RAW_KB_MODIFIER_KEYS_ONLY);
806 int XPending(Display *display)
808 XButtonEvent *xbutton;
809 XMotionEvent *xmotion;
812 /* When using 'HandleKeyboardRaw()', keyboard input is also stored in
813 the allegro keyboard input buffer and would be available a second
814 time by calling 'HandleKeyboardEvent()'. To avoid double keyboard
815 events, the allegro function 'clear_keybuf()' must be called each
816 time when switching from calling 'HandleKeyboardRaw()' to calling
817 'HandleKeyboardEvent()' to get keyboard input, which is actually
818 done by 'XAutoRepeatOn()' which sets keyboard_auto_repeat to TRUE. */
821 if (keyboard_auto_repeat)
822 HandleKeyboardEvent();
824 HandleKeyboardRaw(HANDLE_RAW_KB_ALL_KEYS);
826 /* mouse motion event */
827 if (mouse_pos != last_mouse_pos)
829 last_mouse_pos = mouse_pos;
831 xmotion = (XMotionEvent *)&event_buffer[pending_events];
832 xmotion->type = MotionNotify;
833 xmotion->x = mouse_x - AllegroDefaultScreen().x;
834 xmotion->y = mouse_y - AllegroDefaultScreen().y;
837 /* mouse button event */
838 if (mouse_b != last_mouse_b)
840 for (i=0; i<3; i++) /* check all three mouse buttons */
842 int bitmask = (1 << i);
844 if ((last_mouse_b & bitmask) != (mouse_b & bitmask))
846 int mapping[3] = { 1, 3, 2 };
849 xbutton = (XButtonEvent *)&event_buffer[pending_events];
850 xbutton->type = (mouse_b & bitmask ? ButtonPress : ButtonRelease);
851 xbutton->button = mapping[i];
852 xbutton->x = mouse_x - AllegroDefaultScreen().x;
853 xbutton->y = mouse_y - AllegroDefaultScreen().y;
856 last_mouse_b = mouse_b;
859 return pending_events;
862 KeySym XLookupKeysym(XKeyEvent *key_event, int index)
864 return key_event->state;
867 int XLookupString(XKeyEvent *key_event, char *buffer, int buffer_size,
868 KeySym *key, XComposeStatus *compose)
870 *key = key_event->state;
874 void XSetForeground(Display *display, GC gc, unsigned long pixel)
876 XGCValues *gcv = (XGCValues *)gc;
878 gcv->foreground = pixel;
881 void XDrawLine(Display *display, Drawable d, GC gc,
882 int x1, int y1, int x2, int y2)
884 XGCValues *gcv = (XGCValues *)gc;
885 boolean mouse_off = FALSE;
887 if ((BITMAP *)d == video_bitmap)
889 x1 += AllegroDefaultScreen().x;
890 y1 += AllegroDefaultScreen().y;
891 x2 += AllegroDefaultScreen().x;
892 y2 += AllegroDefaultScreen().y;
893 freeze_mouse_flag = TRUE;
894 mouse_off = hide_mouse(display, MIN(x1, x2), MIN(y1, y2),
895 MAX(x1, x2) - MIN(x1, x2),
896 MAX(y1, y2) - MIN(y1, y2));
899 line((BITMAP *)d, x1, y1, x2, y2, gcv->foreground);
902 unhide_mouse(display);
904 freeze_mouse_flag = FALSE;
907 void XDestroyImage(XImage *ximage)
911 void XDestroyWindow(Display *display, Window window)
915 Bool XQueryPointer(Display *display, Window window,
916 Window *root, Window *child, int *root_x, int *root_y,
917 int *win_x, int *win_y, unsigned int *mask)
919 *win_x = mouse_x - AllegroDefaultScreen().x;
920 *win_y = mouse_y - AllegroDefaultScreen().y;
925 void XAutoRepeatOn(Display *display)
927 keyboard_auto_repeat = TRUE;
931 void XAutoRepeatOff(Display *display)
933 keyboard_auto_repeat = FALSE;
936 void AllegroDrawLine(Drawable d, int from_x, int from_y, int to_x, int to_y,
939 boolean mouse_off = FALSE;
941 if ((BITMAP *)d == video_bitmap)
943 int dx = AllegroDefaultScreen().x;
944 int dy = AllegroDefaultScreen().y;
952 x1 = (from_x < to_x ? from_x : to_x);
953 y1 = (from_y < to_y ? from_y : to_y);
954 x2 = (from_x < to_x ? to_x : from_x);
955 y2 = (from_y < to_y ? to_y : from_y);
957 freeze_mouse_flag = TRUE;
958 mouse_off = hide_mouse(display, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
961 line((BITMAP *)d, from_x, from_y, to_x, to_y, color);
964 unhide_mouse(display);
966 freeze_mouse_flag = FALSE;
969 Pixel AllegroGetPixel(Drawable d, int x, int y)
971 return getpixel((BITMAP *)d, x, y);
974 void MSDOSOpenAudio(void)
976 if (allegro_init_audio())
978 audio.sound_available = TRUE;
979 audio.music_available = TRUE;
980 audio.loops_available = TRUE;
981 audio.sound_enabled = TRUE;
987 void MSDOSCloseAudio(void)
989 /* nothing to be done here */
992 void NetworkServer(int port, int serveronly)
994 Error(ERR_WARN, "networking not supported in DOS version");
997 #endif /* PLATFORM_MSDOS */