From b124c56f1cf069a6c77802919b1a9cbbedb77029 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 30 Apr 2006 17:00:30 +0200 Subject: [PATCH] rnd-20060430-3-src --- ChangeLog | 3 +- src/conftime.h | 2 +- src/files.c | 90 ++++++++------------------- src/libgame/misc.h | 4 +- src/libgame/msdos.h | 4 +- src/libgame/sdl.c | 144 ++++++++++++++++++++++++++++++++++--------- src/libgame/sdl.h | 36 +++++------ src/libgame/system.c | 130 +++++++++++++++++++------------------- src/libgame/system.h | 95 ++++++++++++++-------------- src/libgame/x11.c | 46 +++++++++----- src/libgame/x11.h | 21 ++++--- src/main.c | 1 + src/screens.c | 57 +++++++++++++---- src/tools.c | 131 ++++++--------------------------------- src/tools.h | 7 ++- 15 files changed, 392 insertions(+), 379 deletions(-) diff --git a/ChangeLog b/ChangeLog index 280d27d8..93062e35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2006-04-30 - * fixed bug that forced re-defining menu settings in each config file + * fixed bug that forced re-defining of menu settings in local graphics + config file which are already defined in existing base config file 2006-04-29 * added the possibility to define up to five title screens for each diff --git a/src/conftime.h b/src/conftime.h index 0224c2c5..52b9cad4 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-04-30 15:04]" +#define COMPILE_DATE_STRING "[2006-04-30 16:56]" diff --git a/src/files.c b/src/files.c index a762cdb9..57a03447 100644 --- a/src/files.c +++ b/src/files.c @@ -4944,25 +4944,26 @@ void SaveScore(int nr) #define SETUP_TOKEN_SOFT_SCROLLING 7 #define SETUP_TOKEN_FADING 8 #define SETUP_TOKEN_AUTORECORD 9 -#define SETUP_TOKEN_QUICK_DOORS 10 -#define SETUP_TOKEN_TEAM_MODE 11 -#define SETUP_TOKEN_HANDICAP 12 -#define SETUP_TOKEN_SKIP_LEVELS 13 -#define SETUP_TOKEN_TIME_LIMIT 14 -#define SETUP_TOKEN_FULLSCREEN 15 -#define SETUP_TOKEN_ASK_ON_ESCAPE 16 -#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 17 -#define SETUP_TOKEN_QUICK_SWITCH 18 -#define SETUP_TOKEN_INPUT_ON_FOCUS 19 -#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 20 -#define SETUP_TOKEN_GRAPHICS_SET 21 -#define SETUP_TOKEN_SOUNDS_SET 22 -#define SETUP_TOKEN_MUSIC_SET 23 -#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 24 -#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 25 -#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 26 - -#define NUM_GLOBAL_SETUP_TOKENS 27 +#define SETUP_TOKEN_SHOW_TITLESCREEN 10 +#define SETUP_TOKEN_QUICK_DOORS 11 +#define SETUP_TOKEN_TEAM_MODE 12 +#define SETUP_TOKEN_HANDICAP 13 +#define SETUP_TOKEN_SKIP_LEVELS 14 +#define SETUP_TOKEN_TIME_LIMIT 15 +#define SETUP_TOKEN_FULLSCREEN 16 +#define SETUP_TOKEN_ASK_ON_ESCAPE 17 +#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 18 +#define SETUP_TOKEN_QUICK_SWITCH 19 +#define SETUP_TOKEN_INPUT_ON_FOCUS 20 +#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 21 +#define SETUP_TOKEN_GRAPHICS_SET 22 +#define SETUP_TOKEN_SOUNDS_SET 23 +#define SETUP_TOKEN_MUSIC_SET 24 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 25 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 26 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 27 + +#define NUM_GLOBAL_SETUP_TOKENS 28 /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 @@ -5064,6 +5065,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.soft_scrolling, "soft_scrolling" }, { TYPE_SWITCH, &si.fading, "screen_fading" }, { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording" }, + { TYPE_SWITCH, &si.show_titlescreen, "show_titlescreen" }, { TYPE_SWITCH, &si.quick_doors, "quick_doors" }, { TYPE_SWITCH, &si.team_mode, "team_mode" }, { TYPE_SWITCH, &si.handicap, "handicap" }, @@ -5193,6 +5195,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->soft_scrolling = TRUE; si->fading = FALSE; si->autorecord = TRUE; + si->show_titlescreen = TRUE; si->quick_doors = FALSE; si->team_mode = FALSE; si->handicap = TRUE; @@ -5587,7 +5590,7 @@ static void LoadSpecialMenuDesignSettingsFromFilename(char *filename) freeSetupFileHash(setup_file_hash); } -void LoadSpecialMenuDesignSettings_NEW() +void LoadSpecialMenuDesignSettings() { char *filename_base = UNDEFINED_FILENAME, *filename_local; int i, j; @@ -5600,7 +5603,7 @@ void LoadSpecialMenuDesignSettings_NEW() get_auto_parameter_value(image_config_vars[i].token, image_config[j].value); -#if 0 +#if 1 if (!SETUP_OVERRIDE_ARTWORK(setup, ARTWORK_TYPE_GRAPHICS)) { /* first look for special settings configured in level series config */ @@ -5623,51 +5626,6 @@ void LoadSpecialMenuDesignSettings_NEW() #endif } -void LoadSpecialMenuDesignSettings() -{ - char *filename = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS); - SetupFileHash *setup_file_hash; - int i, j; - - /* always start with reliable default values from default config */ - for (i = 0; image_config_vars[i].token != NULL; i++) - for (j = 0; image_config[j].token != NULL; j++) - if (strEqual(image_config_vars[i].token, image_config[j].token)) - *image_config_vars[i].value = - get_auto_parameter_value(image_config_vars[i].token, - image_config[j].value); - - if ((setup_file_hash = loadSetupFileHash(filename)) == NULL) - return; - - /* special case: initialize with default values that may be overwritten */ - for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) - { - char *value_x = getHashEntry(setup_file_hash, "menu.draw_xoffset"); - char *value_y = getHashEntry(setup_file_hash, "menu.draw_yoffset"); - char *list_size = getHashEntry(setup_file_hash, "menu.list_size"); - - if (value_x != NULL) - menu.draw_xoffset[i] = get_integer_from_string(value_x); - if (value_y != NULL) - menu.draw_yoffset[i] = get_integer_from_string(value_y); - if (list_size != NULL) - menu.list_size[i] = get_integer_from_string(list_size); - } - - /* read (and overwrite with) values that may be specified in config file */ - for (i = 0; image_config_vars[i].token != NULL; i++) - { - char *value = getHashEntry(setup_file_hash, image_config_vars[i].token); - - if (value != NULL) - *image_config_vars[i].value = - get_auto_parameter_value(image_config_vars[i].token, value); - } - - freeSetupFileHash(setup_file_hash); -} - void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 7b36d47a..1e6692e2 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -117,8 +117,8 @@ void *checked_calloc(unsigned long); void *checked_realloc(void *, unsigned long); void checked_free(void *); -inline void swap_numbers(int *, int *); -inline void swap_number_pairs(int *, int *, int *, int *); +void swap_numbers(int *, int *); +void swap_number_pairs(int *, int *, int *, int *); int getFile8BitInteger(FILE *); int putFile8BitInteger(FILE *, int); diff --git a/src/libgame/msdos.h b/src/libgame/msdos.h index e976420e..8307a054 100644 --- a/src/libgame/msdos.h +++ b/src/libgame/msdos.h @@ -722,8 +722,8 @@ void XFillRectangle(Display *, Drawable, GC, int, int, Pixmap XCreatePixmap(Display *, Drawable, unsigned int, unsigned int, unsigned int); void XSync(Display *, Bool); -inline void XCopyArea(Display *, Drawable, Drawable, GC, int, int, - unsigned int, unsigned int, int, int); +void XCopyArea(Display *, Drawable, Drawable, GC, int, int, + unsigned int, unsigned int, int, int); int Read_PCX_to_Pixmap(Display *, Window, GC, char *, Pixmap *, Pixmap *); int XReadBitmapFile(Display *, Drawable, char *, unsigned int *, unsigned int *, Pixmap *, int *, int *); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index a6afa282..14dac929 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -24,7 +24,7 @@ /* ========================================================================= */ /* functions from SGE library */ -inline void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32); +void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32); /* #ifdef PLATFORM_WIN32 */ #define FULLSCREEN_BUG @@ -38,7 +38,7 @@ static int fullscreen_yoffset; static int video_xoffset; static int video_yoffset; -inline void SDLInitVideoDisplay(void) +void SDLInitVideoDisplay(void) { putenv("SDL_VIDEO_CENTERED=1"); @@ -50,8 +50,8 @@ inline void SDLInitVideoDisplay(void) video.default_depth = SDL_GetVideoInfo()->vfmt->BitsPerPixel; } -inline void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, - boolean fullscreen) +void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, + boolean fullscreen) { #ifdef FULLSCREEN_BUG int i; @@ -109,7 +109,7 @@ inline void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, *window = CreateBitmap(video.width, video.height, video.depth); } -inline boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) +boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) { boolean success = TRUE; int surface_flags_fullscreen = SURFACE_FLAGS | SDL_FULLSCREEN; @@ -172,8 +172,8 @@ inline boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) return success; } -inline void SDLCreateBitmapContent(Bitmap *new_bitmap, - int width, int height, int depth) +void SDLCreateBitmapContent(Bitmap *new_bitmap, int width, int height, + int depth) { SDL_Surface *surface_tmp, *surface_native; @@ -190,7 +190,7 @@ inline void SDLCreateBitmapContent(Bitmap *new_bitmap, new_bitmap->surface = surface_native; } -inline void SDLFreeBitmapPointers(Bitmap *bitmap) +void SDLFreeBitmapPointers(Bitmap *bitmap) { if (bitmap->surface) SDL_FreeSurface(bitmap->surface); @@ -200,10 +200,9 @@ inline void SDLFreeBitmapPointers(Bitmap *bitmap) bitmap->surface_masked = NULL; } -inline void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, - int src_x, int src_y, - int width, int height, - int dst_x, int dst_y, int mask_mode) +void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y, int mask_mode) { Bitmap *real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap); SDL_Rect src_rect, dst_rect; @@ -243,8 +242,8 @@ inline void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, SDL_UpdateRect(backbuffer->surface, dst_x, dst_y, width, height); } -inline void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, - int width, int height, Uint32 color) +void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, + int width, int height, Uint32 color) { Bitmap *real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap); SDL_Rect rect; @@ -268,8 +267,93 @@ inline void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, SDL_UpdateRect(backbuffer->surface, x, y, width, height); } -inline void SDLDrawSimpleLine(Bitmap *dst_bitmap, int from_x, int from_y, - int to_x, int to_y, Uint32 color) +void SDLFadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, + int post_delay) +{ + static boolean initialization_needed = TRUE; + static SDL_Surface *surface_screen_copy = NULL; + static SDL_Surface *surface_black = NULL; + SDL_Surface *surface_screen = backbuffer->surface; + SDL_Surface *surface_cross; /* initialized later */ + boolean fade_reverse; /* initialized later */ + unsigned int time_last, time_current; + float alpha; + int alpha_final; + + if (initialization_needed) + { + unsigned int flags = SDL_SRCALPHA; + + /* use same surface type as screen surface */ + if ((surface_screen->flags & SDL_HWSURFACE)) + flags |= SDL_HWSURFACE; + else + flags |= SDL_SWSURFACE; + + /* create surface for temporary copy of screen buffer */ + if ((surface_screen_copy = + SDL_CreateRGBSurface(flags, + surface_screen->w, + surface_screen->h, + surface_screen->format->BitsPerPixel, + surface_screen->format->Rmask, + surface_screen->format->Gmask, + surface_screen->format->Bmask, + surface_screen->format->Amask)) == NULL) + Error(ERR_EXIT, "SDL_CreateRGBSurface( ) failed: %s", SDL_GetError()); + + /* create black surface for fading from/to black */ + if ((surface_black = + SDL_CreateRGBSurface(flags, + surface_screen->w, + surface_screen->h, + surface_screen->format->BitsPerPixel, + surface_screen->format->Rmask, + surface_screen->format->Gmask, + surface_screen->format->Bmask, + surface_screen->format->Amask)) == NULL) + Error(ERR_EXIT, "SDL_CreateRGBSurface( ) failed: %s", SDL_GetError()); + + /* completely fill the surface with black color pixels */ + SDL_FillRect(surface_black, NULL, + SDL_MapRGB(surface_screen->format, 0, 0, 0)); + + initialization_needed = FALSE; + } + + /* copy the current screen backbuffer to the temporary screen copy buffer */ + SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL); + + fade_reverse = (fade_mode == FADE_MODE_FADE_IN ? TRUE : FALSE); + surface_cross = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_cross->surface : + surface_black); + + time_current = SDL_GetTicks(); + + for (alpha = 0.0; alpha < 255.0;) + { + time_last = time_current; + time_current = SDL_GetTicks(); + alpha += 255 * ((float)(time_current - time_last) / fade_delay); + alpha_final = (int)(fade_reverse ? 255.0 - alpha : alpha); + alpha_final = MIN(MAX(0, alpha_final), 255); + + /* draw existing image to screen buffer */ + SDL_BlitSurface(surface_screen_copy, NULL, surface_screen, NULL); + + /* draw new image to screen buffer using alpha blending */ + SDL_SetAlpha(surface_cross, SDL_SRCALPHA, alpha_final); + SDL_BlitSurface(surface_cross, NULL, surface_screen, NULL); + + /* draw screen buffer to visible display */ + SDL_Flip(surface_screen); + } + + Delay(post_delay); +} + +void SDLDrawSimpleLine(Bitmap *dst_bitmap, int from_x, int from_y, + int to_x, int to_y, Uint32 color) { SDL_Surface *surface = dst_bitmap->surface; SDL_Rect rect; @@ -296,8 +380,8 @@ inline void SDLDrawSimpleLine(Bitmap *dst_bitmap, int from_x, int from_y, SDL_FillRect(surface, &rect, color); } -inline void SDLDrawLine(Bitmap *dst_bitmap, int from_x, int from_y, - int to_x, int to_y, Uint32 color) +void SDLDrawLine(Bitmap *dst_bitmap, int from_x, int from_y, + int to_x, int to_y, Uint32 color) { #ifdef FULLSCREEN_BUG if (dst_bitmap == backbuffer || dst_bitmap == window) @@ -313,8 +397,8 @@ inline void SDLDrawLine(Bitmap *dst_bitmap, int from_x, int from_y, } #if 0 -inline void SDLDrawLines(SDL_Surface *surface, struct XY *points, - int num_points, Uint32 color) +void SDLDrawLines(SDL_Surface *surface, struct XY *points, + int num_points, Uint32 color) { int i, x, y; int line_width = 4; @@ -342,7 +426,7 @@ inline void SDLDrawLines(SDL_Surface *surface, struct XY *points, } #endif -inline Pixel SDLGetPixel(Bitmap *src_bitmap, int x, int y) +Pixel SDLGetPixel(Bitmap *src_bitmap, int x, int y) { SDL_Surface *surface = src_bitmap->surface; @@ -843,7 +927,7 @@ void sge_LineRGB(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2, sge_Line(Surface, x1, y1, x2, y2, SDL_MapRGB(Surface->format, R, G, B)); } -inline void SDLPutPixel(Bitmap *dst_bitmap, int x, int y, Pixel pixel) +void SDLPutPixel(Bitmap *dst_bitmap, int x, int y, Pixel pixel) { #ifdef FULLSCREEN_BUG if (dst_bitmap == backbuffer || dst_bitmap == window) @@ -863,8 +947,8 @@ inline void SDLPutPixel(Bitmap *dst_bitmap, int x, int y, Pixel pixel) ----------------------------------------------------------------------------- */ -inline void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y, - int width, int height, Uint32 color) +void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y, + int width, int height, Uint32 color) { int x, y; @@ -879,9 +963,9 @@ inline void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y, } } -inline void SDLCopyInverseMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap, - int src_x, int src_y, int width, int height, - int dst_x, int dst_y) +void SDLCopyInverseMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) { int x, y; @@ -1282,7 +1366,7 @@ void SDLSetMouseCursor(struct MouseCursorInfo *cursor_info) /* audio functions */ /* ========================================================================= */ -inline void SDLOpenAudio(void) +void SDLOpenAudio(void) { if (!strEqual(setup.system.sdl_audiodriver, ARG_DEFAULT)) putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver)); @@ -1314,7 +1398,7 @@ inline void SDLOpenAudio(void) Mixer_InitChannels(); } -inline void SDLCloseAudio(void) +void SDLCloseAudio(void) { Mix_HaltMusic(); Mix_HaltChannel(-1); @@ -1328,7 +1412,7 @@ inline void SDLCloseAudio(void) /* event functions */ /* ========================================================================= */ -inline void SDLNextEvent(Event *event) +void SDLNextEvent(Event *event) { SDL_WaitEvent(event); diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 9c8e9b58..f817e329 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -352,21 +352,21 @@ struct XY /* SDL function definitions */ -inline void SDLInitVideoDisplay(void); -inline void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean); -inline boolean SDLSetVideoMode(DrawBuffer **, boolean); -inline void SDLCreateBitmapContent(Bitmap *, int, int, int); -inline void SDLFreeBitmapPointers(Bitmap *); -inline void SDLCopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int); -inline void SDLFillRectangle(Bitmap *, int, int, int, int, Uint32); -inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, Uint32); -inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32); -inline Pixel SDLGetPixel(Bitmap *, int, int); -inline void SDLPutPixel(Bitmap *, int, int, Pixel); - -inline void SDLInvertArea(Bitmap *, int, int, int, int, Uint32); -inline void SDLCopyInverseMasked(Bitmap *, Bitmap *, int, int, int, int, - int, int); +void SDLInitVideoDisplay(void); +void SDLInitVideoBuffer(DrawBuffer **, DrawWindow **, boolean); +boolean SDLSetVideoMode(DrawBuffer **, boolean); +void SDLCreateBitmapContent(Bitmap *, int, int, int); +void SDLFreeBitmapPointers(Bitmap *); +void SDLCopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int); +void SDLFillRectangle(Bitmap *, int, int, int, int, Uint32); +void SDLFadeScreen(Bitmap *, int, int, int); +void SDLDrawSimpleLine(Bitmap *, int, int, int, int, Uint32); +void SDLDrawLine(Bitmap *, int, int, int, int, Uint32); +Pixel SDLGetPixel(Bitmap *, int, int); +void SDLPutPixel(Bitmap *, int, int, Pixel); + +void SDLInvertArea(Bitmap *, int, int, int, int, Uint32); +void SDLCopyInverseMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); void SDLZoomBitmap(Bitmap *, Bitmap *); @@ -374,10 +374,10 @@ Bitmap *SDLLoadImage(char *); void SDLSetMouseCursor(struct MouseCursorInfo *); -inline void SDLOpenAudio(void); -inline void SDLCloseAudio(void); +void SDLOpenAudio(void); +void SDLCloseAudio(void); -inline void SDLNextEvent(Event *); +void SDLNextEvent(Event *); void HandleJoystickEvent(Event *); void SDLInitJoysticks(void); diff --git a/src/libgame/system.c b/src/libgame/system.c index adcc58ff..7d0351a6 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -281,7 +281,7 @@ inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, #endif } -inline void InitVideoDisplay(void) +void InitVideoDisplay(void) { #if defined(TARGET_SDL) SDLInitVideoDisplay(); @@ -290,7 +290,7 @@ inline void InitVideoDisplay(void) #endif } -inline void CloseVideoDisplay(void) +void CloseVideoDisplay(void) { KeyboardAutoRepeatOn(); @@ -302,9 +302,8 @@ inline void CloseVideoDisplay(void) #endif } -inline void InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, - int width, int height, int depth, - boolean fullscreen) +void InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, + int width, int height, int depth, boolean fullscreen) { video.width = width; video.height = height; @@ -319,7 +318,7 @@ inline void InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, #endif } -inline Bitmap *CreateBitmapStruct(void) +Bitmap *CreateBitmapStruct(void) { #if defined(TARGET_SDL) return checked_calloc(sizeof(struct SDLSurfaceInfo)); @@ -328,7 +327,7 @@ inline Bitmap *CreateBitmapStruct(void) #endif } -inline Bitmap *CreateBitmap(int width, int height, int depth) +Bitmap *CreateBitmap(int width, int height, int depth) { Bitmap *new_bitmap = CreateBitmapStruct(); int real_depth = GetRealDepth(depth); @@ -371,7 +370,7 @@ inline static void TransferBitmapPointers(Bitmap *src_bitmap, *dst_bitmap = *src_bitmap; } -inline void FreeBitmap(Bitmap *bitmap) +void FreeBitmap(Bitmap *bitmap) { if (bitmap == NULL) return; @@ -381,7 +380,7 @@ inline void FreeBitmap(Bitmap *bitmap) free(bitmap); } -inline void CloseWindow(DrawWindow *window) +void CloseWindow(DrawWindow *window) { #if defined(TARGET_X11) if (window->drawable) @@ -394,7 +393,7 @@ inline void CloseWindow(DrawWindow *window) #endif } -static inline boolean CheckDrawingArea(int x, int y, int width, int height, +inline static boolean CheckDrawingArea(int x, int y, int width, int height, int draw_mask) { if (draw_mask == REDRAW_NONE) @@ -415,20 +414,20 @@ static inline boolean CheckDrawingArea(int x, int y, int width, int height, return FALSE; } -inline boolean DrawingDeactivated(int x, int y, int width, int height) +boolean DrawingDeactivated(int x, int y, int width, int height) { return CheckDrawingArea(x, y, width, height, gfx.draw_deactivation_mask); } -inline boolean DrawingOnBackground(int x, int y) +boolean DrawingOnBackground(int x, int y) { return (CheckDrawingArea(x, y, 1, 1, gfx.background_bitmap_mask) && CheckDrawingArea(x, y, 1, 1, gfx.draw_background_mask)); } -inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, - int src_x, int src_y, int width, int height, - int dst_x, int dst_y) +void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) { if (DrawingDeactivated(dst_x, dst_y, width, height)) return; @@ -437,8 +436,18 @@ inline void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, dst_x, dst_y, BLIT_OPAQUE); } -inline void FillRectangle(Bitmap *bitmap, int x, int y, int width, int height, - Pixel color) +void FadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, + int post_delay) +{ +#if defined(TARGET_SDL) + SDLFadeScreen(bitmap_cross, fade_mode, fade_delay, post_delay); +#else + X11FadeScreen(bitmap_cross, fade_mode, fade_delay, post_delay); +#endif +} + +void FillRectangle(Bitmap *bitmap, int x, int y, int width, int height, + Pixel color) { if (DrawingDeactivated(x, y, width, height)) return; @@ -446,13 +455,13 @@ inline void FillRectangle(Bitmap *bitmap, int x, int y, int width, int height, sysFillRectangle(bitmap, x, y, width, height, color); } -inline void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height) +void ClearRectangle(Bitmap *bitmap, int x, int y, int width, int height) { FillRectangle(bitmap, x, y, width, height, BLACK_PIXEL); } -inline void ClearRectangleOnBackground(Bitmap *bitmap, int x, int y, - int width, int height) +void ClearRectangleOnBackground(Bitmap *bitmap, int x, int y, + int width, int height) { if (DrawingOnBackground(x, y)) BlitBitmap(gfx.background_bitmap, bitmap, x, y, width, height, x, y); @@ -460,7 +469,7 @@ inline void ClearRectangleOnBackground(Bitmap *bitmap, int x, int y, ClearRectangle(bitmap, x, y, width, height); } -inline void SetClipMask(Bitmap *bitmap, GC clip_gc, Pixmap clip_pixmap) +void SetClipMask(Bitmap *bitmap, GC clip_gc, Pixmap clip_pixmap) { #if defined(TARGET_X11) if (clip_gc) @@ -471,7 +480,7 @@ inline void SetClipMask(Bitmap *bitmap, GC clip_gc, Pixmap clip_pixmap) #endif } -inline void SetClipOrigin(Bitmap *bitmap, GC clip_gc, int clip_x, int clip_y) +void SetClipOrigin(Bitmap *bitmap, GC clip_gc, int clip_x, int clip_y) { #if defined(TARGET_X11) if (clip_gc) @@ -482,10 +491,9 @@ inline void SetClipOrigin(Bitmap *bitmap, GC clip_gc, int clip_x, int clip_y) #endif } -inline void BlitBitmapMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap, - int src_x, int src_y, - int width, int height, - int dst_x, int dst_y) +void BlitBitmapMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) { if (DrawingDeactivated(dst_x, dst_y, width, height)) return; @@ -494,10 +502,9 @@ inline void BlitBitmapMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap, dst_x, dst_y, BLIT_MASKED); } -inline void BlitBitmapOnBackground(Bitmap *src_bitmap, Bitmap *dst_bitmap, - int src_x, int src_y, - int width, int height, - int dst_x, int dst_y) +void BlitBitmapOnBackground(Bitmap *src_bitmap, Bitmap *dst_bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) { if (DrawingOnBackground(dst_x, dst_y)) { @@ -516,8 +523,8 @@ inline void BlitBitmapOnBackground(Bitmap *src_bitmap, Bitmap *dst_bitmap, dst_x, dst_y); } -inline void DrawSimpleBlackLine(Bitmap *bitmap, int from_x, int from_y, - int to_x, int to_y) +void DrawSimpleBlackLine(Bitmap *bitmap, int from_x, int from_y, + int to_x, int to_y) { #if defined(TARGET_SDL) SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, BLACK_PIXEL); @@ -526,8 +533,8 @@ inline void DrawSimpleBlackLine(Bitmap *bitmap, int from_x, int from_y, #endif } -inline void DrawSimpleWhiteLine(Bitmap *bitmap, int from_x, int from_y, - int to_x, int to_y) +void DrawSimpleWhiteLine(Bitmap *bitmap, int from_x, int from_y, + int to_x, int to_y) { #if defined(TARGET_SDL) SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, WHITE_PIXEL); @@ -537,8 +544,8 @@ inline void DrawSimpleWhiteLine(Bitmap *bitmap, int from_x, int from_y, } #if !defined(TARGET_X11_NATIVE) -inline void DrawLine(Bitmap *bitmap, int from_x, int from_y, - int to_x, int to_y, Pixel pixel, int line_width) +void DrawLine(Bitmap *bitmap, int from_x, int from_y, + int to_x, int to_y, Pixel pixel, int line_width) { int x, y; @@ -567,8 +574,7 @@ inline void DrawLine(Bitmap *bitmap, int from_x, int from_y, } #endif -inline void DrawLines(Bitmap *bitmap, struct XY *points, int num_points, - Pixel pixel) +void DrawLines(Bitmap *bitmap, struct XY *points, int num_points, Pixel pixel) { #if !defined(TARGET_X11_NATIVE) int line_width = 4; @@ -588,7 +594,7 @@ inline void DrawLines(Bitmap *bitmap, struct XY *points, int num_points, #endif } -inline Pixel GetPixel(Bitmap *bitmap, int x, int y) +Pixel GetPixel(Bitmap *bitmap, int x, int y) { if (x < 0 || x >= bitmap->width || y < 0 || y >= bitmap->height) @@ -603,8 +609,8 @@ inline Pixel GetPixel(Bitmap *bitmap, int x, int y) #endif } -inline Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r, - unsigned int color_g, unsigned int color_b) +Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r, + unsigned int color_g, unsigned int color_b) { #if defined(TARGET_SDL) return SDL_MapRGB(bitmap->surface->format, color_r, color_g, color_b); @@ -615,7 +621,7 @@ inline Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r, #endif } -inline Pixel GetPixelFromRGBcompact(Bitmap *bitmap, unsigned int color) +Pixel GetPixelFromRGBcompact(Bitmap *bitmap, unsigned int color) { unsigned int color_r = (color >> 16) & 0xff; unsigned int color_g = (color >> 8) & 0xff; @@ -625,7 +631,7 @@ inline Pixel GetPixelFromRGBcompact(Bitmap *bitmap, unsigned int color) } /* execute all pending screen drawing operations */ -inline void FlushDisplay(void) +void FlushDisplay(void) { #ifndef TARGET_SDL XFlush(display); @@ -633,14 +639,14 @@ inline void FlushDisplay(void) } /* execute and wait for all pending screen drawing operations */ -inline void SyncDisplay(void) +void SyncDisplay(void) { #ifndef TARGET_SDL XSync(display, FALSE); #endif } -inline void KeyboardAutoRepeatOn(void) +void KeyboardAutoRepeatOn(void) { #if defined(TARGET_SDL) SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2, @@ -652,7 +658,7 @@ inline void KeyboardAutoRepeatOn(void) #endif } -inline void KeyboardAutoRepeatOff(void) +void KeyboardAutoRepeatOff(void) { #if defined(TARGET_SDL) SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL); @@ -663,7 +669,7 @@ inline void KeyboardAutoRepeatOff(void) #endif } -inline boolean PointerInWindow(DrawWindow *window) +boolean PointerInWindow(DrawWindow *window) { #if defined(TARGET_SDL) return TRUE; @@ -680,7 +686,7 @@ inline boolean PointerInWindow(DrawWindow *window) #endif } -inline boolean SetVideoMode(boolean fullscreen) +boolean SetVideoMode(boolean fullscreen) { #if defined(TARGET_SDL) return SDLSetVideoMode(&backbuffer, fullscreen); @@ -701,7 +707,7 @@ inline boolean SetVideoMode(boolean fullscreen) #endif } -inline boolean ChangeVideoModeIfNeeded(boolean fullscreen) +boolean ChangeVideoModeIfNeeded(boolean fullscreen) { #if defined(TARGET_SDL) if ((fullscreen && !video.fullscreen_enabled && video.fullscreen_available)|| @@ -1061,7 +1067,7 @@ void SetMouseCursor(int mode) /* audio functions */ /* ========================================================================= */ -inline void OpenAudio(void) +void OpenAudio(void) { /* always start with reliable default values */ audio.sound_available = FALSE; @@ -1089,7 +1095,7 @@ inline void OpenAudio(void) #endif } -inline void CloseAudio(void) +void CloseAudio(void) { #if defined(TARGET_SDL) SDLCloseAudio(); @@ -1102,7 +1108,7 @@ inline void CloseAudio(void) audio.sound_enabled = FALSE; } -inline void SetAudioMode(boolean enabled) +void SetAudioMode(boolean enabled) { if (!audio.sound_available) return; @@ -1115,7 +1121,7 @@ inline void SetAudioMode(boolean enabled) /* event functions */ /* ========================================================================= */ -inline void InitEventFilter(EventFilter filter_function) +void InitEventFilter(EventFilter filter_function) { #if defined(TARGET_SDL) /* set event filter to filter out certain events */ @@ -1123,7 +1129,7 @@ inline void InitEventFilter(EventFilter filter_function) #endif } -inline boolean PendingEvent(void) +boolean PendingEvent(void) { #if defined(TARGET_SDL) return (SDL_PollEvent(NULL) ? TRUE : FALSE); @@ -1132,7 +1138,7 @@ inline boolean PendingEvent(void) #endif } -inline void NextEvent(Event *event) +void NextEvent(Event *event) { #if defined(TARGET_SDL) SDLNextEvent(event); @@ -1141,7 +1147,7 @@ inline void NextEvent(Event *event) #endif } -inline void PeekEvent(Event *event) +void PeekEvent(Event *event) { #if defined(TARGET_SDL) SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_ALLEVENTS); @@ -1150,7 +1156,7 @@ inline void PeekEvent(Event *event) #endif } -inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) +Key GetEventKey(KeyEvent *event, boolean with_modifiers) { #if defined(TARGET_SDL) @@ -1183,7 +1189,7 @@ inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) #endif } -inline KeyMod HandleKeyModState(Key key, int key_status) +KeyMod HandleKeyModState(Key key, int key_status) { static KeyMod current_modifiers = KMOD_None; @@ -1232,7 +1238,7 @@ inline KeyMod HandleKeyModState(Key key, int key_status) return current_modifiers; } -inline KeyMod GetKeyModState() +KeyMod GetKeyModState() { #if defined(TARGET_SDL) return (KeyMod)SDL_GetModState(); @@ -1241,7 +1247,7 @@ inline KeyMod GetKeyModState() #endif } -inline boolean CheckCloseWindowEvent(ClientMessageEvent *event) +boolean CheckCloseWindowEvent(ClientMessageEvent *event) { if (event->type != EVENT_CLIENTMESSAGE) return FALSE; @@ -1262,7 +1268,7 @@ inline boolean CheckCloseWindowEvent(ClientMessageEvent *event) /* joystick functions */ /* ========================================================================= */ -inline void InitJoysticks() +void InitJoysticks() { int i; @@ -1289,7 +1295,7 @@ inline void InitJoysticks() #endif } -inline boolean ReadJoystick(int nr, int *x, int *y, boolean *b1, boolean *b2) +boolean ReadJoystick(int nr, int *x, int *y, boolean *b1, boolean *b2) { #if defined(TARGET_SDL) return SDLReadJoystick(nr, x, y, b1, b2); diff --git a/src/libgame/system.h b/src/libgame/system.h index 174a95ed..21068dbc 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -212,6 +212,10 @@ #define REDRAW_FPS (1 << 11) #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2) +#define FADE_MODE_FADE_IN 0 +#define FADE_MODE_FADE_OUT 1 +#define FADE_MODE_CROSSFADE 2 + #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ y >= gfx.sy && y < gfx.sy + gfx.sysize) #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \ @@ -701,6 +705,7 @@ struct SetupInfo boolean soft_scrolling; boolean fading; boolean autorecord; + boolean show_titlescreen; boolean quick_doors; boolean team_mode; boolean handicap; @@ -961,36 +966,36 @@ void SetDrawBackgroundMask(int); void SetMainBackgroundBitmap(Bitmap *); void SetDoorBackgroundBitmap(Bitmap *); -inline void InitVideoDisplay(void); -inline void CloseVideoDisplay(void); -inline void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean); -inline Bitmap *CreateBitmapStruct(void); -inline Bitmap *CreateBitmap(int, int, int); -inline void FreeBitmap(Bitmap *); -inline void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int); -inline void FillRectangle(Bitmap *, int, int, int, int, Pixel); -inline void ClearRectangle(Bitmap *, int, int, int, int); -inline void ClearRectangleOnBackground(Bitmap *, int, int, int, int); -inline void SetClipMask(Bitmap *, GC, Pixmap); -inline void SetClipOrigin(Bitmap *, GC, int, int); -inline void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); -inline boolean DrawingOnBackground(int, int); -inline void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, - int); -inline void DrawSimpleBlackLine(Bitmap *, int, int, int, int); -inline void DrawSimpleWhiteLine(Bitmap *, int, int, int, int); -inline void DrawLines(Bitmap *, struct XY *, int, Pixel); -inline Pixel GetPixel(Bitmap *, int, int); -inline Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int); -inline Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int); - -inline void FlushDisplay(void); -inline void SyncDisplay(void); -inline void KeyboardAutoRepeatOn(void); -inline void KeyboardAutoRepeatOff(void); -inline boolean PointerInWindow(DrawWindow *); -inline boolean SetVideoMode(boolean); -inline boolean ChangeVideoModeIfNeeded(boolean); +void InitVideoDisplay(void); +void CloseVideoDisplay(void); +void InitVideoBuffer(DrawBuffer **,DrawWindow **, int,int,int, boolean); +Bitmap *CreateBitmapStruct(void); +Bitmap *CreateBitmap(int, int, int); +void FreeBitmap(Bitmap *); +void BlitBitmap(Bitmap *, Bitmap *, int, int, int, int, int, int); +void FadeScreen(Bitmap *bitmap, int, int, int); +void FillRectangle(Bitmap *, int, int, int, int, Pixel); +void ClearRectangle(Bitmap *, int, int, int, int); +void ClearRectangleOnBackground(Bitmap *, int, int, int, int); +void SetClipMask(Bitmap *, GC, Pixmap); +void SetClipOrigin(Bitmap *, GC, int, int); +void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); +boolean DrawingOnBackground(int, int); +void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int); +void DrawSimpleBlackLine(Bitmap *, int, int, int, int); +void DrawSimpleWhiteLine(Bitmap *, int, int, int, int); +void DrawLines(Bitmap *, struct XY *, int, Pixel); +Pixel GetPixel(Bitmap *, int, int); +Pixel GetPixelFromRGB(Bitmap *, unsigned int,unsigned int,unsigned int); +Pixel GetPixelFromRGBcompact(Bitmap *, unsigned int); + +void FlushDisplay(void); +void SyncDisplay(void); +void KeyboardAutoRepeatOn(void); +void KeyboardAutoRepeatOff(void); +boolean PointerInWindow(DrawWindow *); +boolean SetVideoMode(boolean); +boolean ChangeVideoModeIfNeeded(boolean); Bitmap *LoadImage(char *); Bitmap *LoadCustomImage(char *); @@ -1002,20 +1007,20 @@ void ScaleBitmap(Bitmap *, int); void SetMouseCursor(int); -inline void OpenAudio(void); -inline void CloseAudio(void); -inline void SetAudioMode(boolean); - -inline void InitEventFilter(EventFilter); -inline boolean PendingEvent(void); -inline void NextEvent(Event *event); -inline void PeekEvent(Event *event); -inline Key GetEventKey(KeyEvent *, boolean); -inline KeyMod HandleKeyModState(Key, int); -inline KeyMod GetKeyModState(); -inline boolean CheckCloseWindowEvent(ClientMessageEvent *); - -inline void InitJoysticks(); -inline boolean ReadJoystick(int, int *, int *, boolean *, boolean *); +void OpenAudio(void); +void CloseAudio(void); +void SetAudioMode(boolean); + +void InitEventFilter(EventFilter); +boolean PendingEvent(void); +void NextEvent(Event *event); +void PeekEvent(Event *event); +Key GetEventKey(KeyEvent *, boolean); +KeyMod HandleKeyModState(Key, int); +KeyMod GetKeyModState(); +boolean CheckCloseWindowEvent(ClientMessageEvent *); + +void InitJoysticks(); +boolean ReadJoystick(int, int *, int *, boolean *, boolean *); #endif /* SYSTEM_H */ diff --git a/src/libgame/x11.c b/src/libgame/x11.c index 30aaa1bc..b0d70d55 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -22,7 +22,7 @@ static void X11InitDisplay(); static DrawWindow *X11InitWindow(); -inline void X11InitVideoDisplay(void) +void X11InitVideoDisplay(void) { /* initialize X11 video */ X11InitDisplay(); @@ -31,7 +31,7 @@ inline void X11InitVideoDisplay(void) video.default_depth = XDefaultDepth(display, screen); } -inline void X11InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window) +void X11InitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window) { *window = X11InitWindow(); @@ -307,8 +307,8 @@ Bitmap *X11LoadImage(char *filename) return new_bitmap; } -inline void X11CreateBitmapContent(Bitmap *new_bitmap, - int width, int height, int depth) +void X11CreateBitmapContent(Bitmap *new_bitmap, + int width, int height, int depth) { Pixmap pixmap; @@ -327,7 +327,7 @@ inline void X11CreateBitmapContent(Bitmap *new_bitmap, new_bitmap->line_gc[1] = window->line_gc[1]; } -inline void X11FreeBitmapPointers(Bitmap *bitmap) +void X11FreeBitmapPointers(Bitmap *bitmap) { /* The X11 version seems to have a memory leak here -- although "XFreePixmap()" is called, the corresponding memory seems not @@ -346,30 +346,44 @@ inline void X11FreeBitmapPointers(Bitmap *bitmap) bitmap->stored_clip_gc = None; } -inline void X11CopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, - int src_x, int src_y, int width, int height, - int dst_x, int dst_y, int mask_mode) +void X11CopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y, int mask_mode) { XCopyArea(display, src_bitmap->drawable, dst_bitmap->drawable, (mask_mode == BLIT_MASKED ? src_bitmap->clip_gc : dst_bitmap->gc), src_x, src_y, width, height, dst_x, dst_y); } -inline void X11FillRectangle(Bitmap *bitmap, int x, int y, - int width, int height, Pixel color) +void X11FillRectangle(Bitmap *bitmap, int x, int y, + int width, int height, Pixel color) { XSetForeground(display, bitmap->gc, color); XFillRectangle(display, bitmap->drawable, bitmap->gc, x, y, width, height); } -inline void X11DrawSimpleLine(Bitmap *bitmap, int from_x, int from_y, - int to_x, int to_y, Pixel color) +void X11FadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, + int post_delay) +{ + /* fading currently not supported -- simply copy target image to screen */ + + if (fade_mode == FADE_MODE_FADE_OUT) + X11FillRectangle(window, 0, 0, video.width, video.height, BLACK_PIXEL); + else + X11CopyArea(bitmap_cross != NULL ? bitmap_cross : backbuffer, window, + 0, 0, video.width, video.height, 0, 0, BLIT_OPAQUE); + + /* as we currently cannot use the fade delay, also do not use post delay */ +} + +void X11DrawSimpleLine(Bitmap *bitmap, int from_x, int from_y, + int to_x, int to_y, Pixel color) { XSetForeground(display, bitmap->gc, color); XDrawLine(display, bitmap->drawable, bitmap->gc, from_x, from_y, to_x, to_y); } -inline Pixel X11GetPixel(Bitmap *bitmap, int x, int y) +Pixel X11GetPixel(Bitmap *bitmap, int x, int y) { XImage *pixel_image; Pixel pixel_value; @@ -384,8 +398,8 @@ inline Pixel X11GetPixel(Bitmap *bitmap, int x, int y) } #if defined(TARGET_X11_NATIVE) -inline Pixel X11GetPixelFromRGB(unsigned int color_r, unsigned int color_g, - unsigned int color_b) +Pixel X11GetPixelFromRGB(unsigned int color_r, unsigned int color_g, + unsigned int color_b) { XColor xcolor; Pixel pixel; @@ -402,7 +416,7 @@ inline Pixel X11GetPixelFromRGB(unsigned int color_r, unsigned int color_g, } #endif /* TARGET_X11_NATIVE */ -inline void X11DestroyImage(XImage *ximage) +void X11DestroyImage(XImage *ximage) { #if defined(TARGET_X11_NATIVE) /* this seems to be needed for OS/2, but does not hurt on other platforms */ diff --git a/src/libgame/x11.h b/src/libgame/x11.h index 7c69a323..2519955f 100644 --- a/src/libgame/x11.h +++ b/src/libgame/x11.h @@ -334,20 +334,21 @@ struct XY /* X11 function definitions */ -inline void X11InitVideoDisplay(void); -inline void X11InitVideoBuffer(DrawBuffer **, DrawWindow **); +void X11InitVideoDisplay(void); +void X11InitVideoBuffer(DrawBuffer **, DrawWindow **); void X11ZoomBitmap(Bitmap *, Bitmap *); Bitmap *X11LoadImage(char *); -inline void X11CreateBitmapContent(Bitmap *, int, int, int); -inline void X11FreeBitmapPointers(Bitmap *); -inline void X11CopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int); -inline void X11FillRectangle(Bitmap *, int, int, int, int, Pixel); -inline void X11DrawSimpleLine(Bitmap *, int, int, int, int, Pixel); -inline Pixel X11GetPixel(Bitmap *, int, int); -inline Pixel X11GetPixelFromRGB(unsigned int, unsigned int, unsigned int); -inline void X11DestroyImage(XImage *); +void X11CreateBitmapContent(Bitmap *, int, int, int); +void X11FreeBitmapPointers(Bitmap *); +void X11CopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int); +void X11FillRectangle(Bitmap *, int, int, int, int, Pixel); +void X11FadeScreen(Bitmap *, int, int, int); +void X11DrawSimpleLine(Bitmap *, int, int, int, int, Pixel); +Pixel X11GetPixel(Bitmap *, int, int); +Pixel X11GetPixelFromRGB(unsigned int, unsigned int, unsigned int); +void X11DestroyImage(XImage *); #if defined(TARGET_X11_NATIVE) void X11SetMouseCursor(struct MouseCursorInfo *); diff --git a/src/main.c b/src/main.c index f317b46d..d999aa64 100644 --- a/src/main.c +++ b/src/main.c @@ -4523,6 +4523,7 @@ struct ElementDirectionInfo element_direction_info[NUM_DIRECTIONS_FULL + 1] = struct SpecialSuffixInfo special_suffix_info[NUM_SPECIAL_GFX_ARGS + 1 + 1] = { { ".[DEFAULT]", GAME_MODE_DEFAULT, }, + { ".TITLE", GAME_MODE_TITLE, }, { ".MAIN", GAME_MODE_MAIN, }, { ".LEVELS", GAME_MODE_LEVELS }, { ".SCORES", GAME_MODE_SCORES, }, diff --git a/src/screens.c b/src/screens.c index 0743c514..6f0208de 100644 --- a/src/screens.c +++ b/src/screens.c @@ -336,20 +336,23 @@ void DrawTitleScreen() CloseDoor(DOOR_CLOSE_1); #endif - HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE); - PlayMenuSound(); PlayMenuMusic(); + HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE); + +#if 0 #if 1 FadeIn(1000); #else FadeToFront(); #endif +#endif + StopAnimation(); } -void DrawMainMenu() +static void DrawMainMenuExt(int fade_delay) { static LevelDirTree *leveldir_last_valid = NULL; boolean levelset_has_changed = FALSE; @@ -405,7 +408,9 @@ void DrawMainMenu() SetDrawtoField(DRAW_BACKBUFFER); #endif - if (levelset_has_changed && graphic_info[IMG_TITLESCREEN_1].bitmap != NULL) + if (setup.show_titlescreen && + levelset_has_changed && + graphic_info[IMG_TITLESCREEN_1].bitmap != NULL) { game_status = GAME_MODE_TITLE; DrawTitleScreen(); @@ -526,8 +531,10 @@ void DrawMainMenu() DrawTextSCentered(326, FONT_TITLE_2, "A Game by Artsoft Entertainment"); +#if 0 FadeToFront(); InitAnimation(); +#endif HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE); @@ -539,12 +546,33 @@ void DrawMainMenu() PlayMenuSound(); PlayMenuMusic(); +#if 1 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); +#else + if (fade_delay > 0) + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + else + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); +#endif #if 1 /* map gadgets for main menu screen */ MapTapeButtons(); #endif + +#if 1 + if (fade_delay > 0) + FadeIn(fade_delay); + else + BackToFront(); + + InitAnimation(); +#endif +} + +void DrawMainMenu() +{ + DrawMainMenuExt(FALSE); } #if 0 @@ -582,6 +610,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) { static int title_nr = 0; boolean return_to_main_menu = FALSE; + boolean use_fading_main_menu = TRUE; boolean use_cross_fading = TRUE; int fade_delay = 1000; int post_delay = 500; @@ -592,21 +621,21 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) DrawTitleScreenImage(title_nr); + FadeIn(fade_delay); + return; } else if (button == MB_MENU_LEAVE) { return_to_main_menu = TRUE; + use_fading_main_menu = FALSE; } else if (button == MB_MENU_CHOICE) { title_nr++; if (!use_cross_fading) - { - FadeOut(fade_delay); - Delay(post_delay); - } + FadeOut(fade_delay, post_delay); if (title_nr < MAX_NUM_TITLE_SCREENS && graphic_info[IMG_TITLESCREEN_1 + title_nr].bitmap != NULL) @@ -627,8 +656,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) } else { - FadeOut(fade_delay); - Delay(post_delay); + FadeOut(fade_delay, post_delay); return_to_main_menu = TRUE; } @@ -638,8 +666,12 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) { RedrawBackground(); +#if 1 + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); +#endif + game_status = GAME_MODE_MAIN; - DrawMainMenu(); + DrawMainMenuExt(use_fading_main_menu ? fade_delay : 0); } } @@ -2321,7 +2353,8 @@ static struct TokenInfo setup_info_graphics[] = #endif { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" }, { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" }, - { TYPE_SWITCH, &setup.toons, "Toons:" }, + { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" }, + { TYPE_SWITCH, &setup.toons, "Show Toons:" }, { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, diff --git a/src/tools.c b/src/tools.c index 15338973..3a2315a6 100644 --- a/src/tools.c +++ b/src/tools.c @@ -414,119 +414,25 @@ void FadeToFront() BackToFront(); } -#define FADE_MODE_FADE_IN 0 -#define FADE_MODE_FADE_OUT 1 -#define FADE_MODE_CROSSFADE 2 - -static void FadeExt(Bitmap *bitmap_cross, int fade_ms, int fade_mode) +void FadeIn(int fade_delay) { - static boolean initialization_needed = TRUE; - static SDL_Surface *surface_screen_copy = NULL; - static SDL_Surface *surface_black = NULL; - SDL_Surface *surface_screen = backbuffer->surface; - SDL_Surface *surface_cross; /* initialized later */ - boolean fade_reverse; /* initialized later */ - unsigned int time_last, time_current; - float alpha; - int alpha_final; - - if (initialization_needed) - { - unsigned int flags = SDL_SRCALPHA; - - /* use same surface type as screen surface */ - if ((surface_screen->flags & SDL_HWSURFACE)) - flags |= SDL_HWSURFACE; - else - flags |= SDL_SWSURFACE; - - /* create surface for temporary copy of screen buffer */ - if ((surface_screen_copy = - SDL_CreateRGBSurface(flags, - surface_screen->w, - surface_screen->h, - surface_screen->format->BitsPerPixel, - surface_screen->format->Rmask, - surface_screen->format->Gmask, - surface_screen->format->Bmask, - surface_screen->format->Amask)) == NULL) - Error(ERR_EXIT, "SDL_CreateRGBSurface( ) failed: %s", SDL_GetError()); - - /* create black surface for fading from/to black */ - if ((surface_black = - SDL_CreateRGBSurface(flags, - surface_screen->w, - surface_screen->h, - surface_screen->format->BitsPerPixel, - surface_screen->format->Rmask, - surface_screen->format->Gmask, - surface_screen->format->Bmask, - surface_screen->format->Amask)) == NULL) - Error(ERR_EXIT, "SDL_CreateRGBSurface( ) failed: %s", SDL_GetError()); - - /* completely fill the surface with black color pixels */ - SDL_FillRect(surface_black, NULL, - SDL_MapRGB(surface_screen->format, 0, 0, 0)); - - initialization_needed = FALSE; - } - - /* copy the current screen backbuffer to the temporary screen copy buffer */ - SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL); - - fade_reverse = (fade_mode == FADE_MODE_FADE_IN ? TRUE : FALSE); - surface_cross = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_cross->surface : - surface_black); - - time_current = SDL_GetTicks(); - - for (alpha = 0.0; alpha < 255.0;) - { - time_last = time_current; - time_current = SDL_GetTicks(); - alpha += 255 * ((float)(time_current - time_last) / fade_ms); - alpha_final = (int)(fade_reverse ? 255.0 - alpha : alpha); - alpha_final = MIN(MAX(0, alpha_final), 255); - - /* draw existing image to screen buffer */ - SDL_BlitSurface(surface_screen_copy, NULL, surface_screen, NULL); - - /* draw new image to screen buffer using alpha blending */ - SDL_SetAlpha(surface_cross, SDL_SRCALPHA, alpha_final); - SDL_BlitSurface(surface_cross, NULL, surface_screen, NULL); - - /* draw screen buffer to visible display */ - SDL_Flip(surface_screen); - } + FadeScreen(NULL, FADE_MODE_FADE_IN, fade_delay, 0); redraw_mask = REDRAW_NONE; } -void FadeIn(int fade_ms) +void FadeOut(int fade_delay, int post_delay) { -#ifdef TARGET_SDL - FadeExt(NULL, fade_ms, FADE_MODE_FADE_IN); -#else - BackToFront(); -#endif -} + FadeScreen(NULL, FADE_MODE_FADE_OUT, fade_delay, post_delay); -void FadeOut(int fade_ms) -{ -#ifdef TARGET_SDL - FadeExt(NULL, fade_ms, FADE_MODE_FADE_OUT); -#else - BackToFront(); -#endif + redraw_mask = REDRAW_NONE; } -void FadeCross(Bitmap *bitmap, int fade_ms) +void FadeCross(Bitmap *bitmap, int fade_delay) { -#ifdef TARGET_SDL - FadeExt(bitmap, fade_ms, FADE_MODE_CROSSFADE); -#else - BackToFront(); -#endif + FadeScreen(bitmap, FADE_MODE_CROSSFADE, fade_delay, 0); + + redraw_mask = REDRAW_NONE; } void SetMainBackgroundImageIfDefined(int graphic) @@ -2641,14 +2547,17 @@ unsigned int MoveDoor(unsigned int door_state) return (door1 | door2); } - if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1) - door_state &= ~DOOR_OPEN_1; - else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1) - door_state &= ~DOOR_CLOSE_1; - if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2) - door_state &= ~DOOR_OPEN_2; - else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2) - door_state &= ~DOOR_CLOSE_2; + if (!(door_state & DOOR_FORCE_REDRAW)) + { + if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1) + door_state &= ~DOOR_OPEN_1; + else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1) + door_state &= ~DOOR_CLOSE_1; + if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2) + door_state &= ~DOOR_OPEN_2; + else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2) + door_state &= ~DOOR_CLOSE_2; + } door_delay_value = (door_state & DOOR_ACTION_1 ? door_1.step_delay : door_2.step_delay); diff --git a/src/tools.h b/src/tools.h index 10b4890b..5044c746 100644 --- a/src/tools.h +++ b/src/tools.h @@ -46,8 +46,9 @@ #define DOOR_COPY_BACK (1 << 4) #define DOOR_NO_COPY_BACK (1 << 5) #define DOOR_NO_DELAY (1 << 6) -#define DOOR_GET_STATE (1 << 7) -#define DOOR_SET_STATE (1 << 8) +#define DOOR_FORCE_REDRAW (1 << 7) +#define DOOR_GET_STATE (1 << 8) +#define DOOR_SET_STATE (1 << 9) /* for Request */ #define REQ_ASK (1 << 0) @@ -67,7 +68,7 @@ void BackToFront(); void FadeToFront(); void FadeIn(int); -void FadeOut(int); +void FadeOut(int, int); void FadeCross(Bitmap *, int); void ClearWindow(); -- 2.34.1