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)
{
- SDL_Surface *surface_screen = backbuffer->surface;
- SDL_Surface *surface_screen_copy = NULL;
- SDL_Surface *surface_black = NULL;
- SDL_Surface *surface_cross; /* initialized later */
- boolean fade_reverse; /* initialized later */
- unsigned int flags = SDL_SRCALPHA;
- unsigned int time_last, time_current;
- float alpha;
- int alpha_final;
-
- /* use same surface type as screen surface */
- if ((surface_screen->flags & SDL_HWSURFACE))
- flags |= SDL_HWSURFACE;
- else
- flags |= SDL_SWSURFACE;
-
- /* create surface for 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());
-
- SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL);
-
- /* 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());
-
- SDL_FillRect(surface_black, NULL, SDL_MapRGB(surface_screen->format, 0,0,0));
-
- 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);
+ if (fade_delay == 0)
+ {
+ BackToFront();
+
+ return;
}
- SDL_FreeSurface(surface_screen_copy);
- SDL_FreeSurface(surface_black);
+ 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
-}
+ if (fade_delay == 0)
+ {
+ ClearRectangle(backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE);
+ BackToFront();
-void FadeOut(int fade_ms)
-{
-#ifdef TARGET_SDL
- FadeExt(NULL, fade_ms, FADE_MODE_FADE_OUT);
-#else
- BackToFront();
-#endif
+ return;
+ }
+
+ FadeScreen(NULL, FADE_MODE_FADE_OUT, fade_delay, post_delay);
+
+ redraw_mask = REDRAW_NONE;
}
-void FadeCross(Bitmap *bitmap, int fade_ms)
+void FadeCross(int fade_delay)
{
-#ifdef TARGET_SDL
- FadeExt(bitmap, fade_ms, FADE_MODE_CROSSFADE);
-#else
- BackToFront();
-#endif
+ if (fade_delay == 0)
+ {
+ BlitBitmap(bitmap_db_title, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+ BackToFront();
+
+ return;
+ }
+
+ FadeScreen(bitmap_db_title, FADE_MODE_CROSSFADE, fade_delay, 0);
+
+ redraw_mask = REDRAW_NONE;
}
void SetMainBackgroundImageIfDefined(int graphic)
game.envelope_active = TRUE; /* needed for RedrawPlayfield() events */
- PlaySoundStereo(sound_opening, SOUND_MIDDLE);
+ PlayMenuSoundStereo(sound_opening, SOUND_MIDDLE);
if (anim_mode == ANIM_DEFAULT)
AnimateEnvelope(envelope_nr, ANIM_DEFAULT, ACTION_OPENING);
else
WaitForEventToContinue();
- PlaySoundStereo(sound_closing, SOUND_MIDDLE);
+ PlayMenuSoundStereo(sound_closing, SOUND_MIDDLE);
if (anim_mode != ANIM_NONE)
AnimateEnvelope(envelope_nr, main_anim_mode, ACTION_CLOSING);
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);
#if 1
int end = door_size;
#else
- int end = (door_state & DOOR_ACTION_1 &&
- door_1.anim_mode & ANIM_VERTICAL ? DYSIZE : DXSIZE);
+ int end = (door_state & DOOR_ACTION_1 && door_1.anim_mode & ANIM_VERTICAL ?
+ DYSIZE : DXSIZE);
#endif
#if 1
int start = ((door_state & DOOR_NO_DELAY) ? end : 0);
{
/* opening door sound has priority over simultaneously closing door */
if (door_state & (DOOR_OPEN_1 | DOOR_OPEN_2))
- PlaySoundStereo(SND_DOOR_OPENING, SOUND_MIDDLE);
+ PlayMenuSoundStereo(SND_DOOR_OPENING, SOUND_MIDDLE);
else if (door_state & (DOOR_CLOSE_1 | DOOR_CLOSE_2))
- PlaySoundStereo(SND_DOOR_CLOSING, SOUND_MIDDLE);
+ PlayMenuSoundStereo(SND_DOOR_CLOSING, SOUND_MIDDLE);
}
for (k = start; k <= end && !(door_1_done && door_2_done); k += stepsize)
if (door_state & DOOR_ACTION_2)
{
+#if 1
+ int a = MIN(x * door_2.step_offset, door_size);
+ int p = (door_state & DOOR_OPEN_2 ? door_size - a : a);
+ int i = p + door_skip;
+#else
int a = MIN(x * door_2.step_offset, door_size_2);
int p = (door_state & DOOR_OPEN_2 ? door_size_2 - a : a);
int i = p + door_skip;
+#endif
if (door_2.anim_mode & ANIM_STATIC_PANEL)
{
exit(0);
#endif
}
+
+void PlayMenuSound()
+{
+ int sound = menu.sound[game_status];
+
+ if (sound == SND_UNDEFINED)
+ return;
+
+ if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
+ (!setup.sound_loops && IS_LOOP_SOUND(sound)))
+ return;
+
+ if (IS_LOOP_SOUND(sound))
+ PlaySoundLoop(sound);
+ else
+ PlaySound(sound);
+}
+
+void PlayMenuSoundStereo(int sound, int stereo_position)
+{
+ if (sound == SND_UNDEFINED)
+ return;
+
+ if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
+ (!setup.sound_loops && IS_LOOP_SOUND(sound)))
+ return;
+
+ if (IS_LOOP_SOUND(sound))
+ PlaySoundExt(sound, SOUND_MAX_VOLUME, stereo_position, SND_CTRL_PLAY_LOOP);
+ else
+ PlaySoundStereo(sound, stereo_position);
+}
+
+void PlayMenuSoundIfLoop()
+{
+ int sound = menu.sound[game_status];
+
+ if (sound == SND_UNDEFINED)
+ return;
+
+ if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
+ (!setup.sound_loops && IS_LOOP_SOUND(sound)))
+ return;
+
+ if (IS_LOOP_SOUND(sound))
+ PlaySoundLoop(sound);
+}
+
+void PlayMenuMusic()
+{
+ int music = menu.music[game_status];
+
+ if (music == MUS_UNDEFINED)
+ return;
+
+ PlayMusic(music);
+}