X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmsdos.c;h=02c6a96e34ffd97ea7e88a2a3eb9d25b97fa9764;hb=74c0f7de91268e40d15948f473eac51a9760b9c0;hp=a49148817ce28d1a3b79d368e9d7123fe6184024;hpb=1465ca1ffdf2104d25b9a46ca9bf8a3f175403fd;p=rocksndiamonds.git diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index a4914881..02c6a96e 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -1,21 +1,27 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Artsoft Retro-Game Library * *----------------------------------------------------------* -* ©1995 Artsoft Development * -* Holger Schemel * -* 33659 Bielefeld-Senne * -* Telefon: (0521) 493245 * -* eMail: aeglos@valinor.owl.de * -* aeglos@uni-paderborn.de * -* q99492@pbhrzx.uni-paderborn.de * +* (c) 1994-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* msdos.c * +* msdos.c * ***********************************************************/ -#include "libgame.h" +#include "system.h" + #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]) /* allegro driver declarations */ @@ -48,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; idefault_screen = 0; @@ -442,8 +441,7 @@ Pixmap XCreatePixmap(Display *display, Drawable d, unsigned int width, BITMAP *bitmap = NULL; if (gfx_capabilities & GFX_HW_VRAM_BLIT && - width == playfield.scrollbuffer_width && - height == playfield.scrollbuffer_height) + width == gfx.scrollbuffer_width && height == gfx.scrollbuffer_height) bitmap = create_video_bitmap(width, height); if (bitmap == NULL) @@ -503,12 +501,10 @@ static BITMAP *Image_to_AllegroBitmap(Image *image) byte *src_ptr = image->data; byte pixel_mapping[MAX_COLORS]; unsigned int depth = 8; - -#if 0 - int i, j, x, y; -#else int i, x, y; -#endif + + if (image->type == IMAGETYPE_TRUECOLOR && depth == 8) + Error(ERR_EXIT, "cannot handle true-color images on 8-bit display"); /* allocate new allegro bitmap structure */ if ((bitmap = create_bitmap_ex(depth, image->width, image->height)) == NULL) @@ -520,55 +516,19 @@ static BITMAP *Image_to_AllegroBitmap(Image *image) clear(bitmap); /* try to use existing colors from the global colormap */ - for (i=0; irgb.color_used[i]) continue; - -#if 0 - r = image->rgb.red[i] >> 10; - g = image->rgb.green[i] >> 10; - b = image->rgb.blue[i] >> 10; - - for (j=0; jrgb.red[i], - image->rgb.green[i], - image->rgb.blue[i]); -#endif - + pixel_mapping[i] = AllegroAllocColorCell(image->rgb.red[i], + image->rgb.green[i], + image->rgb.blue[i]); } /* 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; @@ -601,7 +561,10 @@ int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename, return errno_pcx; *pixmap = (Pixmap)bitmap; - *pixmap_mask = (Pixmap)bitmap; + + /* pixmap_mask will never be used in Allegro (which uses masked_blit()), + so use non-NULL dummy pointer to empty Pixmap */ + *pixmap_mask = (Pixmap)DUMMY_MASK; return PCX_Success; } @@ -708,7 +671,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 */