From: Holger Schemel Date: Sat, 24 Mar 2007 02:26:37 +0000 (+0100) Subject: rnd-20070324-1-src X-Git-Tag: 3.2.4^2~56 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2c54d1765fec2db1ab23e2d5b5fba927efa463ce;p=rocksndiamonds.git rnd-20070324-1-src * added new menu fading effect "melt", shamelessly stolen from "DOOM" --- diff --git a/ChangeLog b/ChangeLog index ce543daf..f2da7971 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ teleportations to level areas that look exactly the same, giving the illusion that the player did not relocate at all (this was the default since 3.2.3, but caused visual problems with room creation in "Zelda") + * added new menu fading effect "melt", shamelessly stolen from "DOOM" 2007-03-21 * improved menu fading, adding separate fading definitions for entering diff --git a/src/conftime.h b/src/conftime.h index 657a6810..f3e97ef6 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2007-03-23 20:29" +#define COMPILE_DATE_STRING "2007-03-24 03:22" diff --git a/src/init.c b/src/init.c index 0a9e7967..a6f67bcd 100644 --- a/src/init.c +++ b/src/init.c @@ -4851,10 +4851,14 @@ void InitGfxBackground() fieldbuffer = bitmap_db_field; SetDrawtoField(DRAW_BACKBUFFER); +#if 1 + ClearRectangle(backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE); +#else RedrawBackground(); ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE); +#endif for (x = 0; x < MAX_BUF_XSIZE; x++) for (y = 0; y < MAX_BUF_YSIZE; y++) @@ -5212,7 +5216,8 @@ void OpenAll() #if 1 FadeSetStartItem(); - FadeSkipNextFadeOut(); + if (!(fading.fade_mode & FADE_TYPE_TRANSFORM)) + FadeSkipNextFadeOut(); // FadeSetDisabled(); #else fading = fading_none; diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 25df21ca..c06eac4f 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1835,6 +1835,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) result = (string_has_parameter(value, "none") ? FADE_MODE_NONE : string_has_parameter(value, "fade") ? FADE_MODE_FADE : string_has_parameter(value, "crossfade") ? FADE_MODE_CROSSFADE : + string_has_parameter(value, "melt") ? FADE_MODE_MELT : FADE_MODE_DEFAULT); } else if (strEqualN(suffix, ".font", 5)) /* (may also be ".font_xyz") */ diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 605f2342..a71ee30c 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -415,8 +415,8 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height, dst_rect.x = dst_x; dst_rect.y = dst_y; - dst_rect.w = width; - dst_rect.h = height; + dst_rect.w = width; /* (ignored) */ + dst_rect.h = height; /* (ignored) */ if (initialization_needed) { @@ -472,17 +472,17 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height, } /* copy source and target surfaces to temporary surfaces for fading */ - if (fade_mode == FADE_MODE_CROSSFADE) + if (fade_mode & FADE_TYPE_TRANSFORM) { SDL_BlitSurface(surface_cross, &src_rect, surface_source, &src_rect); SDL_BlitSurface(surface_screen, &dst_rect, surface_target, &src_rect); } - else if (fade_mode == FADE_MODE_FADE_IN) + else if (fade_mode & FADE_TYPE_FADE_IN) { SDL_BlitSurface(surface_black, &src_rect, surface_source, &src_rect); SDL_BlitSurface(surface_screen, &dst_rect, surface_target, &src_rect); } - else /* FADE_MODE_FADE_OUT */ + else /* FADE_TYPE_FADE_OUT */ { SDL_BlitSurface(surface_screen, &dst_rect, surface_source, &src_rect); SDL_BlitSurface(surface_black, &src_rect, surface_target, &src_rect); @@ -490,29 +490,145 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height, time_current = SDL_GetTicks(); - for (alpha = 0.0; alpha < 255.0;) + if (fade_mode == FADE_MODE_MELT) { - time_last = time_current; - time_current = SDL_GetTicks(); - alpha += 255 * ((float)(time_current - time_last) / fade_delay); - alpha_final = MIN(MAX(0, alpha), 255); + boolean done = FALSE; + int melt_pixels = 2; + int melt_columns = width / melt_pixels; + int ypos[melt_columns]; + int max_steps = height / 8 + 32; + int steps_done = 0; + int i; - /* draw existing (source) image to screen buffer */ SDL_BlitSurface(surface_source, &src_rect, surface_screen, &dst_rect); + SDL_SetAlpha(surface_target, 0, 0); /* disable alpha blending */ + + ypos[0] = -GetSimpleRandom(16); + + for (i = 1 ; i < melt_columns; i++) + { + int r = GetSimpleRandom(3) - 1; /* randomly choose from { -1, 0, -1 } */ + + ypos[i] = ypos[i - 1] + r; + + if (ypos[i] > 0) + ypos[i] = 0; + else + if (ypos[i] == -16) + ypos[i] = -15; + } + + while (!done) + { + float steps; + int steps_final; + + time_last = time_current; + time_current = SDL_GetTicks(); + steps += max_steps * ((float)(time_current - time_last) / fade_delay); + steps_final = MIN(MAX(0, steps), max_steps); + + steps_done++; - /* draw new (target) image to screen buffer using alpha blending */ - SDL_SetAlpha(surface_target, SDL_SRCALPHA, alpha_final); - SDL_BlitSurface(surface_target, &src_rect, surface_screen, &dst_rect); + done = (steps_done >= steps_final); - if (draw_border_function != NULL) - draw_border_function(); + for (i = 0 ; i < melt_columns; i++) + { + if (ypos[i] < 0) + { + ypos[i]++; + + done = FALSE; + } + else if (ypos[i] < height) + { + int y1 = 16; + int y2 = 8; + int y3 = 8; + int dy = (ypos[i] < y1) ? ypos[i] + 1 : y2 + GetSimpleRandom(y3); + + if (ypos[i] + dy >= height) + dy = height - ypos[i]; + + /* copy part of (appearing) target surface to upper area */ + src_rect.x = src_x + i * melt_pixels; + // src_rect.y = src_y + ypos[i]; + src_rect.y = src_y; + src_rect.w = melt_pixels; + // src_rect.h = dy; + src_rect.h = ypos[i] + dy; + + dst_rect.x = dst_x + i * melt_pixels; + // dst_rect.y = dst_y + ypos[i]; + dst_rect.y = dst_y; + + if (steps_done >= steps_final) + SDL_BlitSurface(surface_target, &src_rect, + surface_screen, &dst_rect); + + ypos[i] += dy; + + /* copy part of (disappearing) source surface to lower area */ + src_rect.x = src_x + i * melt_pixels; + src_rect.y = src_y; + src_rect.w = melt_pixels; + src_rect.h = height - ypos[i]; + + dst_rect.x = dst_x + i * melt_pixels; + dst_rect.y = dst_y + ypos[i]; + + if (steps_done >= steps_final) + SDL_BlitSurface(surface_source, &src_rect, + surface_screen, &dst_rect); + + done = FALSE; + } + else + { + src_rect.x = src_x + i * melt_pixels; + src_rect.y = src_y; + src_rect.w = melt_pixels; + src_rect.h = height; + + dst_rect.x = dst_x + i * melt_pixels; + dst_rect.y = dst_y; + + if (steps_done >= steps_final) + SDL_BlitSurface(surface_target, &src_rect, + surface_screen, &dst_rect); + } + } + + if (steps_done >= steps_final) + SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height); + } + } + else + { + 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 = MIN(MAX(0, alpha), 255); + + /* draw existing (source) image to screen buffer */ + SDL_BlitSurface(surface_source, &src_rect, surface_screen, &dst_rect); + + /* draw new (target) image to screen buffer using alpha blending */ + SDL_SetAlpha(surface_target, SDL_SRCALPHA, alpha_final); + SDL_BlitSurface(surface_target, &src_rect, surface_screen, &dst_rect); + + if (draw_border_function != NULL) + draw_border_function(); #if 1 - /* only update the region of the screen that is affected from fading */ - SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height); + /* only update the region of the screen that is affected from fading */ + SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height); #else - SDL_Flip(surface_screen); + SDL_Flip(surface_screen); #endif + } } Delay(post_delay); diff --git a/src/libgame/system.h b/src/libgame/system.h index 5ba6da71..12fea19b 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -203,14 +203,18 @@ #define FADE_TYPE_NONE 0 #define FADE_TYPE_FADE_IN (1 << 0) #define FADE_TYPE_FADE_OUT (1 << 1) -#define FADE_TYPE_CROSS (1 << 2) -#define FADE_TYPE_SKIP (1 << 3) +#define FADE_TYPE_TRANSFORM (1 << 2) +#define FADE_TYPE_CROSSFADE (1 << 3) +#define FADE_TYPE_MELT (1 << 4) +#define FADE_TYPE_SKIP (1 << 5) #define FADE_MODE_NONE (FADE_TYPE_NONE) #define FADE_MODE_FADE_IN (FADE_TYPE_FADE_IN) #define FADE_MODE_FADE_OUT (FADE_TYPE_FADE_OUT) #define FADE_MODE_FADE (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT) -#define FADE_MODE_CROSSFADE (FADE_TYPE_FADE_IN | FADE_TYPE_CROSS) +#define FADE_MODE_TRANSFORM (FADE_TYPE_TRANSFORM | FADE_TYPE_FADE_IN) +#define FADE_MODE_CROSSFADE (FADE_MODE_TRANSFORM | FADE_TYPE_CROSSFADE) +#define FADE_MODE_MELT (FADE_MODE_TRANSFORM | FADE_TYPE_MELT) #define FADE_MODE_SKIP_FADE_IN (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN) #define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT) diff --git a/src/screens.c b/src/screens.c index b7e4572a..8f4b35b2 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1560,6 +1560,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) #endif #endif struct TitleControlInfo *tci; + struct TitleFadingInfo fading_default; struct TitleFadingInfo fading_last = fading; struct TitleFadingInfo fading_next; int sound, music; @@ -1614,11 +1615,24 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) else DrawTitleScreenMessage(tci->local_nr, tci->initial); + fading_default = (tci->initial ? title_initial_default : title_default); + fading = fading_next = getTitleFading(tci); +#if 1 +#if 1 + if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) && + fading_next.fade_mode & FADE_TYPE_TRANSFORM) + { + fading.fade_mode = FADE_MODE_FADE; + fading.fade_delay = fading_default.fade_delay; + } +#else if (fading_last.fade_mode != FADE_MODE_CROSSFADE && fading_next.fade_mode == FADE_MODE_CROSSFADE) fading.fade_mode = FADE_MODE_FADE; +#endif +#endif #if 1 sound = getTitleSound(tci); @@ -1635,6 +1649,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) SetMouseCursor(CURSOR_NONE); + // printf("::: mode: %d, delay: %d\n", fading.fade_mode, fading.fade_delay); + #if 1 FadeIn(REDRAW_ALL); #endif @@ -1739,10 +1755,17 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) printf("::: %d -> %d\n", fading.fade_mode, fading_next.fade_mode); #endif +#if 1 + /* last screen already faded out, next screen has no animation */ + if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) && + fading_next.fade_mode == FADE_MODE_NONE) + fading = fading_next; +#else /* last screen already faded out, next screen has no animation */ if (fading.fade_mode != FADE_MODE_CROSSFADE && fading_next.fade_mode == FADE_MODE_NONE) fading = fading_next; +#endif #if 1 FadeIn(REDRAW_ALL); @@ -2250,6 +2273,9 @@ static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading) UnmapAllGadgets(); CloseDoor(DOOR_CLOSE_2); + /* (needed after displaying title screens which disable auto repeat) */ + KeyboardAutoRepeatOn(); + #if 1 FadeOut(redraw_mask); #endif diff --git a/src/tools.c b/src/tools.c index d3909d5e..d556beb8 100644 --- a/src/tools.c +++ b/src/tools.c @@ -523,7 +523,11 @@ void FadeExt(int fade_mask, int fade_mode) { static int fade_mode_skip = FADE_MODE_NONE; void (*draw_border_function)(void) = NULL; - Bitmap *bitmap = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_db_cross : NULL); +#if 0 + Bitmap *bitmap = (fade_mode != FADE_MODE_FADE_IN ? bitmap_db_cross : NULL); +#else + Bitmap *bitmap = (fade_mode & FADE_TYPE_TRANSFORM ? bitmap_db_cross : NULL); +#endif int x, y, width, height; int fade_delay, post_delay; @@ -531,6 +535,10 @@ void FadeExt(int fade_mask, int fade_mode) if (fade_mode & FADE_TYPE_SKIP) { +#if 0 + printf("::: will skip %d ... [%d]\n", fade_mode, fade_mode_skip); +#endif + fade_mode_skip = fade_mode; return; @@ -599,6 +607,14 @@ void FadeExt(int fade_mask, int fade_mode) void FadeIn(int fade_mask) { +#if 1 + // printf("::: now fading in...\n"); + + if (fading.fade_mode & FADE_TYPE_TRANSFORM) + FadeExt(fade_mask, fading.fade_mode); + else + FadeExt(fade_mask, FADE_MODE_FADE_IN); +#else #if 1 if (fading.fade_mode == FADE_MODE_CROSSFADE) FadeExt(fade_mask, FADE_MODE_CROSSFADE); @@ -607,10 +623,19 @@ void FadeIn(int fade_mask) #else FadeExt(fade_mask, FADE_MODE_FADE_IN); #endif +#endif } void FadeOut(int fade_mask) { +#if 1 + // printf("::: fading.fade_mode == %d\n", fading.fade_mode); + + if (fading.fade_mode & FADE_TYPE_TRANSFORM) + FadeCrossSaveBackbuffer(); + else + FadeExt(fade_mask, FADE_MODE_FADE_OUT); +#else #if 1 if (fading.fade_mode == FADE_MODE_CROSSFADE) FadeCrossSaveBackbuffer(); @@ -619,6 +644,7 @@ void FadeOut(int fade_mask) #else FadeExt(fade_mask, FADE_MODE_FADE_OUT); #endif +#endif } void FadeCross(int fade_mask)