+ redraw_mask &= ~fade_mask;
+}
+
+void FadeIn(int fade_mask)
+{
+#if 0
+ global.border_status = game_status;
+#endif
+
+#if 0
+ global.fading_status = game_status;
+
+ if (global.fading_type == TYPE_ENTER_MENU)
+ fading = menu.enter_menu;
+ else if (global.fading_type == TYPE_LEAVE_MENU)
+ fading = menu.leave_menu;
+ else if (global.fading_type == TYPE_ENTER_SCREEN)
+ fading = menu.enter_screen[global.fading_status];
+ else if (global.fading_type == TYPE_LEAVE_SCREEN)
+ fading = menu.leave_screen[global.fading_status];
+
+ printf("::: FadeIn: %s [0x%08x] [%d]\n",
+ global.fading_type == TYPE_ENTER_MENU ? "enter_menu" :
+ global.fading_type == TYPE_LEAVE_MENU ? "leave_menu" :
+ global.fading_type == TYPE_ENTER_SCREEN ? "enter_screen" :
+ global.fading_type == TYPE_LEAVE_SCREEN ? "leave_screen" : "(?)",
+ global.fading_type,
+ global.fading_status);
+#endif
+
+#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);
+#else
+ FadeExt(fade_mask, FADE_MODE_FADE_IN);
+#endif
+#endif
+}
+
+void FadeOut(int fade_mask)
+{
+#if 0
+ if (global.fading_type == TYPE_ENTER_MENU)
+ fading = menu.enter_menu;
+ else if (global.fading_type == TYPE_LEAVE_MENU)
+ fading = menu.leave_menu;
+ else if (global.fading_type == TYPE_ENTER_SCREEN)
+ fading = menu.enter_screen[global.fading_status];
+ else if (global.fading_type == TYPE_LEAVE_SCREEN)
+ fading = menu.leave_screen[global.fading_status];
+
+ printf("::: FadeOut: %s [0x%08x] [%d]\n",
+ global.fading_type == TYPE_ENTER_MENU ? "enter_menu" :
+ global.fading_type == TYPE_LEAVE_MENU ? "leave_menu" :
+ global.fading_type == TYPE_ENTER_SCREEN ? "enter_screen" :
+ global.fading_type == TYPE_LEAVE_SCREEN ? "leave_screen" : "(?)",
+ global.fading_type,
+ global.fading_status);
+#endif
+
+#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);
+#else
+ FadeExt(fade_mask, FADE_MODE_FADE_OUT);
+#endif
+#endif
+
+#if 1
+ global.border_status = game_status;
+#endif
+}
+
+void FadeCross(int fade_mask)
+{
+ FadeExt(fade_mask, FADE_MODE_CROSSFADE);
+}
+
+void FadeCrossSaveBackbuffer()
+{
+ BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+}
+
+#if 0
+void FadeSetEnterMenu()
+{
+ global.fading_type = TYPE_ENTER_MENU;
+}
+
+void FadeSetLeaveMenu()
+{
+ global.fading_type = TYPE_LEAVE_MENU;
+}
+
+void FadeSetEnterScreen()
+{
+ global.fading_type = TYPE_ENTER_SCREEN;
+}
+
+void FadeSetLeaveScreen()
+{
+ // global.fading_type = TYPE_LEAVE_SCREEN;
+
+ global.fading_type = (global.fading_type == TYPE_ENTER_SCREEN ?
+ TYPE_LEAVE_SCREEN : TYPE_LEAVE_MENU);
+}
+
+#else
+
+static void FadeSetLeaveNext(struct TitleFadingInfo fading_leave, boolean set)
+{
+ static struct TitleFadingInfo fading_leave_stored;
+
+ if (set)
+ fading_leave_stored = fading_leave;
+ else
+ fading = fading_leave_stored;
+}
+
+void FadeSetEnterMenu()
+{
+ fading = menu.enter_menu;
+
+#if 0
+ printf("::: storing enter_menu\n");
+#endif
+
+ FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
+}
+
+void FadeSetLeaveMenu()
+{
+ fading = menu.leave_menu;
+
+#if 0
+ printf("::: storing leave_menu\n");
+#endif
+
+ FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
+}
+
+void FadeSetEnterScreen()
+{
+ fading = menu.enter_screen[game_status];
+
+#if 0
+ printf("::: storing leave_screen[%d]\n", game_status);
+#endif
+
+#if 0
+ printf("::: - %d, %d / %d, %d\n",
+ menu.enter_screen[game_status].fade_mode,
+ menu.enter_screen[game_status].fade_delay,
+ menu.leave_screen[game_status].fade_mode,
+ menu.leave_screen[game_status].fade_delay);
+#endif
+
+ FadeSetLeaveNext(menu.leave_screen[game_status], TRUE); /* store */
+}
+
+void FadeSetLeaveScreen()
+{
+#if 0
+ printf("::: recalling last stored value\n");
+#endif
+
+ FadeSetLeaveNext(menu.leave_screen[game_status], FALSE); /* recall */
+}
+
+#endif
+
+void FadeSetFromType(int type)
+{
+ if (type & TYPE_ENTER_SCREEN)
+ FadeSetEnterScreen();
+ else if (type & TYPE_ENTER)
+ FadeSetEnterMenu();
+ else if (type & TYPE_LEAVE)
+ FadeSetLeaveMenu();
+}
+
+void FadeSetDisabled()
+{
+ static struct TitleFadingInfo fading_none = { FADE_MODE_NONE, -1, -1, -1 };
+
+ fading = fading_none;
+}
+
+void FadeSkipNextFadeIn()
+{
+ FadeExt(0, FADE_MODE_SKIP_FADE_IN);
+}
+
+void FadeSkipNextFadeOut()
+{
+ FadeExt(0, FADE_MODE_SKIP_FADE_OUT);
+}
+
+void SetWindowBackgroundImageIfDefined(int graphic)
+{
+ if (graphic_info[graphic].bitmap)
+ SetWindowBackgroundBitmap(graphic_info[graphic].bitmap);