undo of buggy 'small change for setting background image' (commit 00ca5a80)
[rocksndiamonds.git] / src / screens.c
index de42525a6ab33fc43a651a0c94a4ae00bd7546f3..4802015c8fe1519456267c76133a700c2cac65fb 100644 (file)
@@ -18,7 +18,7 @@
 #include "editor.h"
 #include "files.h"
 #include "tape.h"
-#include "cartoons.h"
+#include "anim.h"
 #include "network.h"
 #include "init.h"
 #include "config.h"
@@ -235,9 +235,6 @@ static TreeInfo *drop_distance_current = NULL;
 static TreeInfo *level_number = NULL;
 static TreeInfo *level_number_current = NULL;
 
-static unsigned int sync_frame_delay = 0;
-static unsigned int sync_frame_delay_value = GAME_FRAME_DELAY;
-
 static struct
 {
   int value;
@@ -281,7 +278,10 @@ static struct
 {
   {    STR_SPECIAL_RENDERING_OFF,      "Off (May show artifacts, fast)" },
   {    STR_SPECIAL_RENDERING_BITMAP,   "Bitmap/Texture mode (slower)"   },
+#if DEBUG
+  // this mode may work under certain conditions, but does not work on Windows
   {    STR_SPECIAL_RENDERING_TARGET,   "Target Texture mode (slower)"   },
+#endif
   {    STR_SPECIAL_RENDERING_DOUBLE,   "Double Texture mode (slower)"   },
 
   {    NULL,                            NULL                            },
@@ -725,6 +725,13 @@ static int getTitleMessageGameMode(boolean initial)
   return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
 }
 
+static int getTitleAnimMode(struct TitleControlInfo *tci)
+{
+  int base = (tci->initial ? GAME_MODE_TITLE_INITIAL_1 : GAME_MODE_TITLE_1);
+
+  return base + tci->local_nr;
+}
+
 #if 0
 static int getTitleScreenBackground(boolean initial)
 {
@@ -1247,11 +1254,7 @@ static void drawCursorXY(int xpos, int ypos, int graphic)
 
 static void drawChooseTreeCursor(int ypos, boolean active)
 {
-  int last_game_status = game_status;  /* save current game status */
-
   drawCursorExt(0, ypos, active, -1);
-
-  SetGameStatus(last_game_status);     /* restore current game status */
 }
 
 void DrawHeadline()
@@ -1309,13 +1312,12 @@ void DrawTitleScreenMessage(int nr, boolean initial)
 {
   char *filename = getLevelSetTitleMessageFilename(nr, initial);
   struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
-  int last_game_status = game_status;  /* save current game status */
 
   if (filename == NULL)
     return;
 
   /* force TITLE font on title message screen */
-  SetGameStatus(getTitleMessageGameMode(initial));
+  SetFontStatus(getTitleMessageGameMode(initial));
 
   /* if chars *and* width set to "-1", automatically determine width */
   if (tmi->chars == -1 && tmi->width == -1)
@@ -1354,7 +1356,7 @@ void DrawTitleScreenMessage(int nr, boolean initial)
               filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
               tmi->autowrap, tmi->centered, tmi->parse_comments);
 
-  SetGameStatus(last_game_status);     /* restore current game status */
+  ResetFontStatus();
 }
 
 void DrawTitleScreen()
@@ -1362,8 +1364,6 @@ void DrawTitleScreen()
   KeyboardAutoRepeatOff();
 
   HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
-
-  StopAnimation();
 }
 
 boolean CheckTitleScreen(boolean levelset_has_changed)
@@ -1398,6 +1398,8 @@ void DrawMainMenu()
   UnmapAllGadgets();
   FadeSoundsAndMusic();
 
+  ExpireSoundLoops(FALSE);
+
   KeyboardAutoRepeatOn();
   ActivateJoystick();
 
@@ -1447,9 +1449,6 @@ void DrawMainMenu()
     return;
   }
 
-  /* needed if different viewport properties defined for menues */
-  ChangeViewportPropertiesIfNeeded();
-
   if (redraw_mask & REDRAW_ALL)
     fade_mask = REDRAW_ALL;
 
@@ -1458,7 +1457,10 @@ void DrawMainMenu()
 
   FadeOut(fade_mask);
 
-  SetDrawtoField(DRAW_BACKBUFFER);
+  /* needed if different viewport properties defined for menues */
+  ChangeViewportPropertiesIfNeeded();
+
+  SetDrawtoField(DRAW_TO_BACKBUFFER);
 
   /* level_nr may have been set to value over handicap with level editor */
   if (setup.handicap && level_nr > leveldir_current->handicap_level)
@@ -1520,8 +1522,6 @@ void DrawMainMenu()
 
   SetMouseCursor(CURSOR_DEFAULT);
 
-  InitAnimation();
-
   OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
 }
 
@@ -1570,6 +1570,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     title_screen_nr = 0;
     tci = &title_controls[title_screen_nr];
 
+    SetAnimStatus(getTitleAnimMode(tci));
+
     last_sound = SND_UNDEFINED;
     last_music = MUS_UNDEFINED;
 
@@ -1590,7 +1592,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
        DrawInfoScreen_NotAvailable("Title screen information:",
                                    "No title screen for this level set.");
-
        return;
       }
 
@@ -1599,12 +1600,12 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     FadeOut(REDRAW_ALL);
 
-    /* only required to update logic for redrawing global border */
-    ClearField();
-
     /* title screens may have different window size */
     ChangeViewportPropertiesIfNeeded();
 
+    /* only required to update logic for redrawing global border */
+    ClearField();
+
     if (tci->is_image)
       DrawTitleScreenImage(tci->local_nr, tci->initial);
     else
@@ -1651,16 +1652,19 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     }
 
     title_screen_nr++;
-    tci = &title_controls[title_screen_nr];
 
     if (title_screen_nr < num_title_screens)
     {
+      tci = &title_controls[title_screen_nr];
+
+      SetAnimStatus(getTitleAnimMode(tci));
+
       sound = getTitleSound(tci);
       music = getTitleMusic(tci);
 
-      if (sound == SND_UNDEFINED || sound != last_sound)
-       FadeSounds();
-      if (music == MUS_UNDEFINED || music != last_music)
+      if (last_sound != SND_UNDEFINED && sound != last_sound)
+       FadeSound(last_sound);
+      if (last_music != MUS_UNDEFINED && music != last_music)
        FadeMusic();
 
       fading = getTitleFading(tci);
@@ -1843,14 +1847,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
   }
   else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
   {
-    StopAnimation();
-
     CloseDoor(DOOR_CLOSE_2);
 
     SetGameStatus(GAME_MODE_LEVELNR);
 
-    ChangeViewportPropertiesIfNeeded();
-
     DrawChooseLevelNr();
   }
   else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
@@ -1881,8 +1881,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       {
        if (leveldir_first)
        {
-         StopAnimation();
-
          CloseDoor(DOOR_CLOSE_2);
 
          SetGameStatus(GAME_MODE_LEVELS);
@@ -1893,15 +1891,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
          if (setup.internal.choose_from_top_leveldir)
            gotoTopLevelDir();
 
-         ChangeViewportPropertiesIfNeeded();
-
          DrawChooseLevelSet();
        }
       }
       else if (pos == MAIN_CONTROL_SCORES)
       {
-       StopAnimation();
-
        CloseDoor(DOOR_CLOSE_2);
 
        SetGameStatus(GAME_MODE_SCORES);
@@ -1914,8 +1908,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
            !strEqual(setup.player_name, "Artsoft"))
          Request("This level is read only!", REQ_CONFIRM);
 
-       StopAnimation();
-
        CloseDoor(DOOR_CLOSE_2);
 
        SetGameStatus(GAME_MODE_EDITOR);
@@ -1926,36 +1918,26 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
       else if (pos == MAIN_CONTROL_INFO)
       {
-       StopAnimation();
-
        CloseDoor(DOOR_CLOSE_2);
 
        SetGameStatus(GAME_MODE_INFO);
 
        info_mode = INFO_MODE_MAIN;
 
-       ChangeViewportPropertiesIfNeeded();
-
        DrawInfoScreen();
       }
       else if (pos == MAIN_CONTROL_GAME)
       {
-       StopAnimation();
-
        StartGameActions(options.network, setup.autorecord, level.random_seed);
       }
       else if (pos == MAIN_CONTROL_SETUP)
       {
-       StopAnimation();
-
        CloseDoor(DOOR_CLOSE_2);
 
        SetGameStatus(GAME_MODE_SETUP);
 
        setup_mode = SETUP_MODE_MAIN;
 
-       ChangeViewportPropertiesIfNeeded();
-
        DrawSetupScreen();
       }
       else if (pos == MAIN_CONTROL_QUIT)
@@ -2162,6 +2144,7 @@ static void DrawInfoScreen_Main()
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
+  FadeSoundsAndMusic();
 
   FreeScreenGadgets();
   CreateScreenGadgets();
@@ -2173,8 +2156,11 @@ static void DrawInfoScreen_Main()
 
   FadeOut(fade_mask);
 
+  /* needed if different viewport properties defined for info screen */
   ChangeViewportPropertiesIfNeeded();
 
+  SetMainBackgroundImage(IMG_BACKGROUND_INFO);
+
   ClearField();
 
   OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
@@ -2203,8 +2189,6 @@ static void DrawInfoScreen_Main()
   DrawMaskedBorder(fade_mask);
 
   FadeIn(fade_mask);
-
-  InitAnimation();
 }
 
 static void changeSetupValue(int, int, int);
@@ -2702,8 +2686,6 @@ void DrawInfoScreen_Elements()
   HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
 
   FadeIn(REDRAW_FIELD);
-
-  InitAnimation();
 }
 
 void HandleInfoScreen_Elements(int button)
@@ -3514,8 +3496,6 @@ void HandleInfoScreen_LevelSet(int button)
 
 static void DrawInfoScreen()
 {
-  SetMainBackgroundImage(IMG_BACKGROUND_INFO);
-
   if (info_mode == INFO_MODE_TITLE)
     DrawInfoScreen_TitleScreen();
   else if (info_mode == INFO_MODE_ELEMENTS)
@@ -3673,6 +3653,14 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
 
   FadeOut(fade_mask);
 
+  /* needed if different viewport properties defined for choosing level (set) */
+  ChangeViewportPropertiesIfNeeded();
+
+  if (game_status == GAME_MODE_LEVELNR)
+    SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
+  else if (game_status == GAME_MODE_LEVELS)
+    SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
+
   ClearField();
 
   OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
@@ -3683,8 +3671,6 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
   DrawMaskedBorder(fade_mask);
 
   FadeIn(fade_mask);
-
-  InitAnimation();
 }
 
 static void drawChooseTreeList(int first_entry, int num_page_entries,
@@ -3696,7 +3682,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
   int yoffset_setup = 16;
   int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
                 ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
-  int last_game_status = game_status;  /* save current game status */
 
   title_string = ti->infotext;
 
@@ -3736,8 +3721,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
       initCursor(i, IMG_MENU_BUTTON);
   }
 
-  SetGameStatus(last_game_status);     /* restore current game status */
-
   redraw_mask |= REDRAW_FIELD;
 }
 
@@ -3785,7 +3768,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
   int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
   int num_entries = numTreeInfoInGroup(ti);
   int num_page_entries;
-  int last_game_status = game_status;  /* save current game status */
   boolean position_set_by_scrollbar = (dx == 999);
 
   if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
@@ -3793,8 +3775,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
   else
     num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
 
-  SetGameStatus(last_game_status);     /* restore current game status */
-
   if (button == MB_MENU_INITIALIZE)
   {
     int num_entries = numTreeInfoInGroup(ti);
@@ -3878,12 +3858,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
   if (mx || my)                /* mouse input */
   {
-    int last_game_status = game_status;        /* save current game status */
-
     x = (mx - mSX) / 32;
     y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
-
-    SetGameStatus(last_game_status);   /* restore current game status */
   }
   else if (dx || dy)   /* keyboard or scrollbar/scrollbutton input */
   {
@@ -4077,7 +4053,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
 void DrawChooseLevelSet()
 {
-  SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
+  FadeSoundsAndMusic();
 
   DrawChooseTree(&leveldir_current);
 
@@ -4094,6 +4070,8 @@ void DrawChooseLevelNr()
 {
   int i;
 
+  FadeSoundsAndMusic();
+
   if (level_number != NULL)
   {
     freeTreeInfo(level_number);
@@ -4138,8 +4116,6 @@ void DrawChooseLevelNr()
   if (level_number_current == NULL)
     level_number_current = level_number;
 
-  SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
-
   DrawChooseTree(&level_number_current);
 
   PlayMenuSound();
@@ -4155,9 +4131,6 @@ void DrawHallOfFame(int highlight_position)
 {
   int fade_mask = REDRAW_FIELD;
 
-  /* needed if different viewport properties defined for scores */
-  ChangeViewportPropertiesIfNeeded();
-
   if (CheckIfGlobalBorderHasChanged())
     fade_mask = REDRAW_ALL;
 
@@ -4179,7 +4152,8 @@ void DrawHallOfFame(int highlight_position)
 
   FadeOut(fade_mask);
 
-  InitAnimation();
+  /* needed if different viewport properties defined for scores */
+  ChangeViewportPropertiesIfNeeded();
 
   PlayMenuSound();
   PlayMenuMusic();
@@ -4212,9 +4186,10 @@ static void drawHallOfFameList(int first_entry, int highlight_position)
     int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
     int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
     int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
+    int dxoff = getFontDrawOffsetX(font_nr1);
     int dx1 = 3 * getFontWidth(font_nr1);
     int dx2 = dx1 + getFontWidth(font_nr1);
-    int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
+    int dx3 = SXSIZE - 2 * (mSX - SX + dxoff) - 5 * getFontWidth(font_nr4);
     int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
     int sy = mSY + 64 + i * 32;
 
@@ -4707,16 +4682,14 @@ static void execSetupGraphics_setRenderingModes()
 
 static void execSetupGraphics()
 {
+  // update "setup.window_scaling_percent" from list selection
+  // (in this case, window scaling was changed on setup screen)
   if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
-  {
-    // update "setup.window_scaling_percent" from list selection
     execSetupGraphics_setWindowSizes(FALSE);
-  }
-  else
-  {
-    // update list selection from "setup.window_scaling_percent"
-    execSetupGraphics_setWindowSizes(TRUE);
-  }
+
+  // update list selection from "setup.window_scaling_percent"
+  // (window scaling may have changed by resizing the window)
+  execSetupGraphics_setWindowSizes(TRUE);
 
   execSetupGraphics_setScalingTypes();
   execSetupGraphics_setRenderingModes();
@@ -5590,10 +5563,7 @@ static Key getSetupKey()
       }
     }
 
-    DoAnimation();
     BackToFront();
-
-    WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
   }
 
   return key;
@@ -5616,20 +5586,29 @@ static int getSetupValueFont(int type, void *value)
     return FONT_VALUE_1;
 }
 
+static int getSetupValueFontNarrow(int type, int font_nr)
+{
+  return (font_nr == FONT_VALUE_1    ? FONT_VALUE_NARROW :
+         font_nr == FONT_OPTION_ON  ? FONT_OPTION_ON_NARROW :
+         font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW :
+         font_nr);
+}
+
 static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
 {
   int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
   struct TokenInfo *si = &setup_info[si_pos];
   boolean font_draw_xoffset_modified = FALSE;
+  boolean scrollbar_needed = (num_setup_info < max_setup_info);
   int font_draw_xoffset_old = -1;
-  int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
+  int xoffset = (scrollbar_needed ? -1 : 0);
   int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
   int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
   int xpos = menu_screen_value_xpos;
   int ypos = MENU_SCREEN_START_YPOS + screen_pos;
   int startx = mSX + xpos * 32;
   int starty = mSY + ypos * 32;
-  int font_nr, font_width;
+  int font_nr, font_nr_default, font_width_default;
   int type = si->type;
   void *value = si->value;
   char *value_string = getSetupValue(type, value);
@@ -5661,8 +5640,29 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
 
   startx = mSX + xpos * 32;
   starty = mSY + ypos * 32;
-  font_nr = getSetupValueFont(type, value);
-  font_width = getFontWidth(font_nr);
+  font_nr_default = getSetupValueFont(type, value);
+  font_width_default = getFontWidth(font_nr_default);
+
+  font_nr = font_nr_default;
+
+  // special check if right-side setup values moved left due to scrollbar
+  if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS)
+  {
+    int max_menu_text_length = 26;     // maximum text length for classic menu
+    int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
+    int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
+    int text_font_nr = getMenuTextFont(FONT_MENU_2);
+    int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
+    int text_width = max_menu_text_length * getFontWidth(text_font_nr);
+
+    if (startx + font_xoffset < text_startx + text_width + text_font_xoffset)
+    {
+      xpos += 1;
+      startx = mSX + xpos * 32;
+
+      font_nr = getSetupValueFontNarrow(type, font_nr);
+    }
+  }
 
   /* downward compatibility correction for Juergen Bonhagen's menu settings */
   if (setup_mode != SETUP_MODE_INPUT)
@@ -5703,7 +5703,7 @@ static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
   }
 
   for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
-    DrawText(startx + i * font_width, starty, " ", font_nr);
+    DrawText(startx + i * font_width_default, starty, " ", font_nr_default);
 
   DrawText(startx, starty, value_string, font_nr);
 
@@ -5760,6 +5760,7 @@ static void DrawSetupScreen_Generic()
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
+  FadeSoundsAndMusic();
 
   FreeScreenGadgets();
   CreateScreenGadgets();
@@ -5769,6 +5770,11 @@ static void DrawSetupScreen_Generic()
 
   FadeOut(fade_mask);
 
+  /* needed if different viewport properties defined for setup screen */
+  ChangeViewportPropertiesIfNeeded();
+
+  SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
+
   ClearField();
 
   OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
@@ -5861,8 +5867,6 @@ static void DrawSetupScreen_Generic()
   DrawMaskedBorder(fade_mask);
 
   FadeIn(fade_mask);
-
-  InitAnimation();
 }
 
 void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
@@ -5910,8 +5914,6 @@ void DrawSetupScreen_Input()
   HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
 
   FadeIn(REDRAW_FIELD);
-
-  InitAnimation();
 }
 
 static void setJoystickDeviceToNr(char *device_name, int device_nr)
@@ -6192,8 +6194,6 @@ void CustomizeKeyboard(int player_nr)
 
   FadeIn(REDRAW_FIELD);
 
-  InitAnimation();
-
   while (!finished)
   {
     if (PendingEvent())                /* got event */
@@ -6275,16 +6275,12 @@ void CustomizeKeyboard(int player_nr)
       }
     }
 
-    DoAnimation();
     BackToFront();
-
-    WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
   }
 
   /* write new key bindings back to player setup */
   setup.input[player_nr].key = custom_key;
 
-  StopAnimation();
   DrawSetupScreen_Input();
 }
 
@@ -6348,7 +6344,6 @@ static boolean CalibrateJoystickMain(int player_nr)
   FadeIn(REDRAW_FIELD);
 
   while (Joystick(player_nr) & JOY_BUTTON);    /* wait for released button */
-  InitAnimation();
 
   while (result < 0)
   {
@@ -6430,10 +6425,7 @@ static boolean CalibrateJoystickMain(int player_nr)
       }
     }
 
-    DoAnimation();
     BackToFront();
-
-    WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
   }
 
   /* calibrated center position (joystick should now be centered) */
@@ -6443,8 +6435,6 @@ static boolean CalibrateJoystickMain(int player_nr)
   new_joystick_xmiddle = joy_x;
   new_joystick_ymiddle = joy_y;
 
-  StopAnimation();
-
   /* wait until the last pressed button was released */
   while (Joystick(player_nr) & JOY_BUTTON)
   {
@@ -6455,7 +6445,7 @@ static boolean CalibrateJoystickMain(int player_nr)
       NextEvent(&event);
       HandleOtherEvents(&event);
 
-      WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
+      BackToFront();
     }
   }
 
@@ -6489,8 +6479,6 @@ void DrawSetupScreen()
 {
   DeactivateJoystick();
 
-  SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
-
   if (setup_mode == SETUP_MODE_INPUT)
     DrawSetupScreen_Input();
   else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
@@ -6906,14 +6894,10 @@ static void CreateScreenScrollbars()
 
 void CreateScreenGadgets()
 {
-  int last_game_status = game_status;  /* save current game status */
-
   CreateScreenMenubuttons();
 
   CreateScreenScrollbuttons();
   CreateScreenScrollbars();
-
-  SetGameStatus(last_game_status);     /* restore current game status */
 }
 
 void FreeScreenGadgets()