X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmsdos.c;h=c4c6ff4f4cceca78a66b418d0a00ed3ba78eff67;hb=61c3da024802ecc0268bab42d7499fc0346e4fd3;hp=c6c51db6b65912ce03a3aba80d29a877ea9bd4b7;hpb=dd192af0efbe08a2ec5dedc204cdfb9244c00468;p=rocksndiamonds.git diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index c6c51db6..c4c6ff4f 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -1,7 +1,7 @@ /*********************************************************** * Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1994-2001 Artsoft Entertainment * +* (c) 1994-2006 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -17,7 +17,9 @@ #if defined(PLATFORM_MSDOS) #include "sound.h" +#include "joystick.h" #include "misc.h" +#include "setup.h" #include "pcx.h" #define AllegroDefaultScreen() (display->screens[display->default_screen]) @@ -52,22 +54,16 @@ static int global_colormap_entries_used = 0; boolean wait_for_vsync; -/* -extern int playing_sounds; -extern struct SoundControl playlist[MAX_SOUNDS_PLAYING]; -extern struct SoundControl emptySoundControl; -*/ - static BITMAP *Read_PCX_to_AllegroBitmap(char *); static void allegro_init_drivers() { int i; - for (i=0; i>= 10; /* try to use existing colors from the global colormap */ - for (i=0; irgb.color_used[i]) continue; @@ -531,8 +526,8 @@ static BITMAP *Image_to_AllegroBitmap(Image *image) } /* copy bitmap data */ - for (y=0; yheight; y++) - for (x=0; xwidth; x++) + for (y = 0; y < image->height; y++) + for (x = 0; x < image->width; x++) putpixel(bitmap, x, y, pixel_mapping[*src_ptr++]); return bitmap; @@ -602,11 +597,9 @@ void XFreePixmap(Display *display, Pixmap pixmap) void XFreeGC(Display *display, GC gc) { - XGCValues *gcv; + XGCValues *gcv = (XGCValues *)gc; - gcv = (XGCValues *)gc; - if (gcv) - free(gcv); + checked_free(gcv); } void XUnmapWindow(Display *display, Window window) @@ -620,11 +613,8 @@ void XCloseDisplay(Display *display) if (is_screen_bitmap(bitmap)) destroy_bitmap(bitmap); - if (display->screens) - free(display->screens); - - if (display) - free(display); + checked_free(display->screens); + checked_free(display); /* return to text mode (or DOS box on Windows screen) */ set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); @@ -675,7 +665,7 @@ static void HandleKeyboardRaw(int mode) { int i; - for (i=0; i= num_joysticks) + joystick_nr = -1; + + /* misuse joystick file descriptor variable to store joystick number */ + joystick.fd[i] = joystick_nr; + } +} + +boolean MSDOSReadJoystick(int nr, int *x, int *y, boolean *b1, boolean *b2) +{ + /* the allegro global variable 'num_joysticks' contains the number + of joysticks found at initialization under MS-DOS / Windows */ + + if (nr < 0 || nr >= num_joysticks) + return FALSE; + + poll_joystick(); + + if (x != NULL) + *x = joy[nr].stick[0].axis[0].pos; + if (y != NULL) + *y = joy[nr].stick[0].axis[1].pos; + + if (b1 != NULL) + *b1 = joy[nr].button[0].b; + if (b2 != NULL) + *b2 = joy[nr].button[1].b; + + return TRUE; +} + #endif /* PLATFORM_MSDOS */