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)
{
}
/* 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);
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);
#endif
#endif
struct TitleControlInfo *tci;
+ struct TitleFadingInfo fading_default;
struct TitleFadingInfo fading_last = fading;
struct TitleFadingInfo fading_next;
int sound, music;
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);
SetMouseCursor(CURSOR_NONE);
+ // printf("::: mode: %d, delay: %d\n", fading.fade_mode, fading.fade_delay);
+
#if 1
FadeIn(REDRAW_ALL);
#endif
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);
UnmapAllGadgets();
CloseDoor(DOOR_CLOSE_2);
+ /* (needed after displaying title screens which disable auto repeat) */
+ KeyboardAutoRepeatOn();
+
#if 1
FadeOut(redraw_mask);
#endif
{
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;
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;
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);
#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();
#else
FadeExt(fade_mask, FADE_MODE_FADE_OUT);
#endif
+#endif
}
void FadeCross(int fade_mask)