From 4337ea074a6962a576fc0e44d61d48ebc76fa6ae Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 15 Dec 2000 16:07:35 +0100 Subject: [PATCH] rnd-20001215-1-src --- CHANGES | 4 ++- src/init.c | 17 +++++++---- src/libgame/misc.c | 14 +++++---- src/libgame/msdos.c | 67 ++++++++++++++++++++++++++++---------------- src/libgame/msdos.h | 3 ++ src/libgame/system.c | 2 ++ src/main.c | 26 ++++++++--------- src/screens.c | 2 ++ 8 files changed, 87 insertions(+), 48 deletions(-) diff --git a/CHANGES b/CHANGES index 9cde8a3a..7a595f93 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,10 @@ Version 1.5.0 ------------- - - SDL!!! + - can be compiled with SDL library to build native Windows version - trying to open already busy audio device does not block the game - fixed network playing bug (patch from web site) + - SDL version can load and play music modules + - fixed element description in level editor for EM doors and keys Release Version 1.4.0 [27 OCT 1999] ----------------------------------- diff --git a/src/init.c b/src/init.c index dbe878cd..17a1cbdb 100644 --- a/src/init.c +++ b/src/init.c @@ -341,7 +341,7 @@ void InitGfx() }; #endif -#ifdef TARGET_X11 +#if defined(TARGET_X11_NATIVE) static struct { int start; @@ -433,7 +433,16 @@ void InitGfx() InitFontInfo(pix[PIX_BIGFONT], pix[PIX_MEDIUMFONT], pix[PIX_SMALLFONT]); + /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */ + for(i=0; i=0; i++) { @@ -485,6 +491,7 @@ void InitGfx() src_x, src_y, TILEX, TILEY, 0, 0); } } +#endif /* TARGET_X11_ANTIVE */ #endif /* TARGET_X11 */ } diff --git a/src/libgame/misc.c b/src/libgame/misc.c index b72fa146..5673dced 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -551,15 +551,18 @@ void Error(int mode, char *format, ...) { char *process_name = ""; FILE *error = stderr; + char *newline = "\n"; /* display warnings only when running in verbose mode */ if (mode & ERR_WARN && !options.verbose) return; #if !defined(PLATFORM_UNIX) + newline = "\r\n"; + if ((error = openErrorFile()) == NULL) { - printf("Cannot write to error output file!\n"); + printf("Cannot write to error output file!%s", newline); program.exit_function(1); } #endif @@ -584,15 +587,16 @@ void Error(int mode, char *format, ...) vfprintf(error, format, ap); va_end(ap); - fprintf(error, "\n"); + fprintf(error, "%s", newline); } if (mode & ERR_HELP) - fprintf(error, "%s: Try option '--help' for more information.\n", - program.command_basename); + fprintf(error, "%s: Try option '--help' for more information.%s", + program.command_basename, newline); if (mode & ERR_EXIT) - fprintf(error, "%s%s: aborting\n", program.command_basename, process_name); + fprintf(error, "%s%s: aborting%s", + program.command_basename, process_name, newline); if (error != stderr) fclose(error); diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index 75f92a05..77257e07 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -238,25 +238,7 @@ static KeySym ScancodeToKeySym(byte scancode) } } -void XMapWindow(Display *display, Window window) -{ - int x, y; - unsigned int width, height; - boolean mouse_off; - - x = AllegroDefaultScreen().x; - y = AllegroDefaultScreen().y; - width = AllegroDefaultScreen().width; - height = AllegroDefaultScreen().height; - - mouse_off = hide_mouse(display, x, y, width, height); - blit((BITMAP *)window, video_bitmap, 0, 0, x, y, width, height); - - if (mouse_off) - unhide_mouse(display); -} - -static unsigned long AllocColorCell(int r, int g, int b) +Pixel AllegroAllocColorCell(int r, int g, int b) { byte pixel_mapping = 0; int i; @@ -282,16 +264,38 @@ static unsigned long AllocColorCell(int r, int g, int b) if (global_colormap_entries_used < MAX_COLORS) global_colormap_entries_used++; + i = global_colormap_entries_used - 1; + global_colormap[i].r = r; global_colormap[i].g = g; global_colormap[i].b = b; + set_palette(global_colormap); + pixel_mapping = i; } return pixel_mapping; } +void XMapWindow(Display *display, Window window) +{ + int x, y; + unsigned int width, height; + boolean mouse_off; + + x = AllegroDefaultScreen().x; + y = AllegroDefaultScreen().y; + width = AllegroDefaultScreen().width; + height = AllegroDefaultScreen().height; + + mouse_off = hide_mouse(display, x, y, width, height); + blit((BITMAP *)window, video_bitmap, 0, 0, x, y, width, height); + + if (mouse_off) + unhide_mouse(display); +} + Display *XOpenDisplay(char *display_name) { Screen *screen; @@ -311,8 +315,8 @@ Display *XOpenDisplay(char *display_name) screen[0].white_pixel = 0xFF; screen[0].black_pixel = 0x00; #else - screen[0].white_pixel = AllocColorCell(0xFFFF, 0xFFFF, 0xFFFF); - screen[0].black_pixel = AllocColorCell(0x0000, 0x0000, 0x0000); + screen[0].white_pixel = AllegroAllocColorCell(0xFFFF, 0xFFFF, 0xFFFF); + screen[0].black_pixel = AllegroAllocColorCell(0x0000, 0x0000, 0x0000); #endif screen[0].video_bitmap = NULL; @@ -562,9 +566,9 @@ static BITMAP *Image_to_AllegroBitmap(Image *image) pixel_mapping[i] = j; } #else - pixel_mapping[i] = AllocColorCell(image->rgb.red[i], - image->rgb.green[i], - image->rgb.blue[i]); + pixel_mapping[i] = AllegroAllocColorCell(image->rgb.red[i], + image->rgb.green[i], + image->rgb.blue[i]); #endif } @@ -604,7 +608,17 @@ int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename, return errno_pcx; *pixmap = (Pixmap)bitmap; +#if 0 *pixmap_mask = (Pixmap)bitmap; + /* !!! two pointers on same bitmap => second free() fails !!! */ +#else + /* pixmap_mask will never be used in Allegro (which uses masked_blit()), + so use non-NULL dummy pointer to empty Pixmap */ + /* + *pixmap_mask = (Pixmap)checked_calloc(sizeof(Pixmap)); + */ + *pixmap_mask = (Pixmap)DUMMY_MASK; +#endif return PCX_Success; } @@ -952,6 +966,11 @@ void AllegroDrawLine(Drawable d, int from_x, int from_y, int to_x, int to_y, freeze_mouse_flag = FALSE; } +Pixel AllegroGetPixel(Drawable d, int x, int y) +{ + return getpixel((BITMAP *)d, x, y); +} + void MSDOSOpenAudio(void) { if (allegro_init_audio()) diff --git a/src/libgame/msdos.h b/src/libgame/msdos.h index af865235..40a42da2 100644 --- a/src/libgame/msdos.h +++ b/src/libgame/msdos.h @@ -694,6 +694,8 @@ typedef union _XEvent XKeyEvent xkey; } XEvent; +Pixel AllegroAllocColorCell(int, int, int); + void XMapWindow(Display *, Window); Display *XOpenDisplay(char *); Window XCreateSimpleWindow(Display *, Window, int, int, @@ -732,6 +734,7 @@ void XAutoRepeatOn(Display *); void XAutoRepeatOff(Display *); void AllegroDrawLine(Drawable, int, int, int, int, Pixel); +Pixel AllegroGetPixel(Drawable, int, int); void MSDOSOpenAudio(void); void MSDOSCloseAudio(void); diff --git a/src/libgame/system.c b/src/libgame/system.c index 5217460d..22e9f2f1 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -441,6 +441,8 @@ inline Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r, #if defined(TARGET_SDL) pixel = SDL_MapRGB(bitmap->surface->format, color_r, color_g, color_b); +#elif defined(TARGET_ALLEGRO) + pixel = AllegroAllocColorCell(color_r << 8, color_g << 8, color_b << 8); #elif defined(TARGET_X11_NATIVE) XColor xcolor; diff --git a/src/main.c b/src/main.c index 0ef3af3b..521e4b35 100644 --- a/src/main.c +++ b/src/main.c @@ -273,7 +273,7 @@ char *element_info[] = "normal wall (BD style)", "rock (BD style)", "open exit", - "unknown", + "black orb bomb", "amoeba", "mole", /* 110 */ "penguin", @@ -284,7 +284,7 @@ char *element_info[] = "arrow down", "pig", "fire breathing dragon", - "unknown", + "red key (EM style)", "letter ' '", /* 120 */ "letter '!'", "letter '\"'", @@ -368,13 +368,13 @@ char *element_info[] = "growing wall (horizontal)", /* 200 */ "growing wall (vertical)", "growing wall (all directions)", - "unused", - "unused", - "unused", - "unused", - "unused", - "unused", - "unused", + "red door (EM style)", + "yellow door (EM style)", + "green door (EM style)", + "blue door (EM style)", + "yellow key (EM style)", + "green key (EM style)", + "blue key (EM style)", "empty space", /* 210 */ "zonk", "base", @@ -415,10 +415,10 @@ char *element_info[] = "hardware", "chip (upper half)", "chip (lower half)", - "unknown", /* 250 */ - "unknown", - "unknown", - "unknown", + "gray door (EM style, red key)", /* 250 */ + "gray door (EM style, yellow key)", + "gray door (EM style, green key)", + "gray door (EM style, blue key)", "unknown", "unknown", diff --git a/src/screens.c b/src/screens.c index 486ad6d9..556cc29e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -700,7 +700,9 @@ void DrawHelpScreenMusicText(int num) DrawTextFCentered(ybottom, FC_BLUE, "Press any key or button for next page"); +#if 0 PlaySoundLoop(background_loop[num]); +#endif } void DrawHelpScreenCreditsText() -- 2.34.1