fixed bug with restarting same menu music on different screens
[rocksndiamonds.git] / src / screens.c
index c45e9badb79740cadbf519c085d788bd2ad14f4d..6e26fdf55e4f75e1c8b57b4349269ce1b691191c 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"
@@ -61,9 +61,9 @@
 #define SETUP_MODE_CHOOSE_GAME_SPEED   16
 #define SETUP_MODE_CHOOSE_SCROLL_DELAY 17
 #define SETUP_MODE_CHOOSE_SNAPSHOT_MODE        18
-#define SETUP_MODE_CHOOSE_SCREEN_MODE  19
-#define SETUP_MODE_CHOOSE_WINDOW_SIZE  20
-#define SETUP_MODE_CHOOSE_SCALING_TYPE 21
+#define SETUP_MODE_CHOOSE_WINDOW_SIZE  19
+#define SETUP_MODE_CHOOSE_SCALING_TYPE 20
+#define SETUP_MODE_CHOOSE_RENDERING    21
 #define SETUP_MODE_CHOOSE_GRAPHICS     22
 #define SETUP_MODE_CHOOSE_SOUNDS       23
 #define SETUP_MODE_CHOOSE_MUSIC                24
@@ -196,15 +196,15 @@ static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
 static int info_mode = INFO_MODE_MAIN;
 static int setup_mode = SETUP_MODE_MAIN;
 
-static TreeInfo *screen_modes = NULL;
-static TreeInfo *screen_mode_current = NULL;
-
 static TreeInfo *window_sizes = NULL;
 static TreeInfo *window_size_current = NULL;
 
 static TreeInfo *scaling_types = NULL;
 static TreeInfo *scaling_type_current = NULL;
 
+static TreeInfo *rendering_modes = NULL;
+static TreeInfo *rendering_mode_current = NULL;
+
 static TreeInfo *scroll_delays = NULL;
 static TreeInfo *scroll_delay_current = NULL;
 
@@ -270,6 +270,23 @@ static struct
   {    NULL,                    NULL           },
 };
 
+static struct
+{
+  char *value;
+  char *text;
+} rendering_modes_list[] =
+{
+  {    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                            },
+};
+
 static struct
 {
   int value;
@@ -366,6 +383,7 @@ static struct
 {
   {    TOUCH_CONTROL_VIRTUAL_BUTTONS,  "Virtual Buttons"       },
   {    TOUCH_CONTROL_WIPE_GESTURES,    "Wipe Gestures"         },
+  {    TOUCH_CONTROL_FOLLOW_FINGER,    "Follow Finger"         },
 
   {    NULL,                           NULL                    },
 };
@@ -708,6 +726,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)
 {
@@ -1160,6 +1185,17 @@ static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
          y >= rect_y && y < rect_y + rect->height);
 }
 
+static boolean insidePreviewRect(struct PreviewInfo *preview, int x, int y)
+{
+  int rect_width  = preview->xsize * preview->tile_size;
+  int rect_height = preview->ysize * preview->tile_size;
+  int rect_x = ALIGNED_XPOS(preview->x, rect_width,  preview->align);
+  int rect_y = ALIGNED_YPOS(preview->y, rect_height, preview->valign);
+
+  return (x >= rect_x && x < rect_x + rect_width &&
+         y >= rect_y && y < rect_y + rect_height);
+}
+
 static void AdjustScrollbar(int id, int items_max, int items_visible,
                            int item_position)
 {
@@ -1230,11 +1266,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);
-
-  game_status = last_game_status;      /* restore current game status */
 }
 
 void DrawHeadline()
@@ -1292,13 +1324,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 */
-  game_status = getTitleMessageGameMode(initial);
+  SetFontStatus(getTitleMessageGameMode(initial));
 
   /* if chars *and* width set to "-1", automatically determine width */
   if (tmi->chars == -1 && tmi->width == -1)
@@ -1337,7 +1368,7 @@ void DrawTitleScreenMessage(int nr, boolean initial)
               filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
               tmi->autowrap, tmi->centered, tmi->parse_comments);
 
-  game_status = last_game_status;      /* restore current game status */
+  ResetFontStatus();
 }
 
 void DrawTitleScreen()
@@ -1345,8 +1376,6 @@ void DrawTitleScreen()
   KeyboardAutoRepeatOff();
 
   HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
-
-  StopAnimation();
 }
 
 boolean CheckTitleScreen(boolean levelset_has_changed)
@@ -1379,7 +1408,9 @@ void DrawMainMenu()
   /* do not fade out here -- function may continue and fade on editor screen */
 
   UnmapAllGadgets();
-  FadeSoundsAndMusic();
+  FadeMenuSoundsAndMusic();
+
+  ExpireSoundLoops(FALSE);
 
   KeyboardAutoRepeatOn();
   ActivateJoystick();
@@ -1391,7 +1422,10 @@ void DrawMainMenu()
   /* needed if last screen was the playing screen, invoked from level editor */
   if (level_editor_test_game)
   {
-    game_status = GAME_MODE_EDITOR;
+    CloseDoor(DOOR_CLOSE_ALL);
+
+    SetGameStatus(GAME_MODE_EDITOR);
+
     DrawLevelEd();
 
     return;
@@ -1416,8 +1450,14 @@ void DrawMainMenu()
   /* needed if last screen (level choice) changed graphics, sounds or music */
   ReloadCustomArtwork(0);
 
-  /* needed if different viewport properties defined for menues */
-  ChangeViewportPropertiesIfNeeded();
+  if (CheckTitleScreen(levelset_has_changed))
+  {
+    SetGameStatus(GAME_MODE_TITLE);
+
+    DrawTitleScreen();
+
+    return;
+  }
 
   if (redraw_mask & REDRAW_ALL)
     fade_mask = REDRAW_ALL;
@@ -1427,20 +1467,10 @@ void DrawMainMenu()
 
   FadeOut(fade_mask);
 
-  /* needed if last screen was the editor screen */
-  UndrawSpecialEditorDoor();
-
-  SetDrawtoField(DRAW_BACKBUFFER);
-
-  if (CheckTitleScreen(levelset_has_changed))
-  {
-    game_status_last_screen = GAME_MODE_MAIN;
-    game_status = GAME_MODE_TITLE;
+  /* needed if different viewport properties defined for menues */
+  ChangeViewportPropertiesIfNeeded();
 
-    DrawTitleScreen();
-
-    return;
-  }
+  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)
@@ -1474,8 +1504,7 @@ void DrawMainMenu()
     LoadTape(level_nr);
   DrawCompleteVideoDisplay();
 
-  PlayMenuSound();
-  PlayMenuMusic();
+  PlayMenuSoundsAndMusic();
 
   /* create gadgets for main menu screen */
   FreeScreenGadgets();
@@ -1502,8 +1531,6 @@ void DrawMainMenu()
 
   SetMouseCursor(CURSOR_DEFAULT);
 
-  InitAnimation();
-
   OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
 }
 
@@ -1552,6 +1579,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;
 
@@ -1568,25 +1597,27 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
       if (num_title_screens == 0)
       {
        /* switch game mode from title screen mode back to info screen mode */
-       game_status = GAME_MODE_INFO;
+       SetGameStatus(GAME_MODE_INFO);
+
+       /* store that last screen was info screen, not main menu screen */
+       game_status_last_screen = GAME_MODE_INFO;
 
        DrawInfoScreen_NotAvailable("Title screen information:",
                                    "No title screen for this level set.");
-
        return;
       }
 
-      FadeSoundsAndMusic();
-
-      FadeOut(REDRAW_ALL);
+      FadeMenuSoundsAndMusic();
     }
 
-    /* only required to update logic for redrawing global border */
-    ClearField();
+    FadeOut(REDRAW_ALL);
 
     /* 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
@@ -1623,7 +1654,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
   {
     if (game_status_last_screen == GAME_MODE_INFO && num_title_screens == 0)
     {
-      game_status = GAME_MODE_INFO;
+      SetGameStatus(GAME_MODE_INFO);
+
       info_mode = INFO_MODE_MAIN;
 
       DrawInfoScreen();
@@ -1632,16 +1664,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);
@@ -1670,7 +1705,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     }
     else
     {
-      FadeSoundsAndMusic();
+      FadeMenuSoundsAndMusic();
 
       return_to_main_menu = TRUE;
     }
@@ -1685,14 +1720,15 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     if (game_status_last_screen == GAME_MODE_INFO)
     {
-      game_status = GAME_MODE_INFO;
+      SetGameStatus(GAME_MODE_INFO);
+
       info_mode = INFO_MODE_MAIN;
 
       DrawInfoScreen();
     }
     else       /* default: return to main menu */
     {
-      game_status = GAME_MODE_MAIN;
+      SetGameStatus(GAME_MODE_MAIN);
 
       DrawMainMenu();
     }
@@ -1783,6 +1819,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
     }
 
+    /* check if level preview was clicked */
+    if (insidePreviewRect(&preview, mx - SX, my - SY))
+      pos = MAIN_CONTROL_GAME;
+
     // handle pressed/unpressed state for active/inactive menu buttons
     // (if pos != -1, "i" contains index position corresponding to "pos")
     if (button &&
@@ -1823,13 +1863,9 @@ 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);
 
-    game_status = GAME_MODE_LEVELNR;
-
-    ChangeViewportPropertiesIfNeeded();
+    SetGameStatus(GAME_MODE_LEVELNR);
 
     DrawChooseLevelNr();
   }
@@ -1853,7 +1889,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 
       if (pos == MAIN_CONTROL_NAME)
       {
-       game_status = GAME_MODE_PSEUDO_TYPENAME;
+       SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
 
        HandleTypeName(strlen(setup.player_name), 0);
       }
@@ -1861,11 +1897,9 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       {
        if (leveldir_first)
        {
-         StopAnimation();
-
          CloseDoor(DOOR_CLOSE_2);
 
-         game_status = GAME_MODE_LEVELS;
+         SetGameStatus(GAME_MODE_LEVELS);
 
          SaveLevelSetup_LastSeries();
          SaveLevelSetup_SeriesInfo();
@@ -1873,18 +1907,14 @@ 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);
 
-       game_status = GAME_MODE_SCORES;
+       SetGameStatus(GAME_MODE_SCORES);
 
        DrawHallOfFame(-1);
       }
@@ -1894,11 +1924,9 @@ 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);
 
-       game_status = GAME_MODE_EDITOR;
+       SetGameStatus(GAME_MODE_EDITOR);
 
        FadeSetEnterScreen();
 
@@ -1906,33 +1934,25 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
       else if (pos == MAIN_CONTROL_INFO)
       {
-       StopAnimation();
-
        CloseDoor(DOOR_CLOSE_2);
 
-       game_status = GAME_MODE_INFO;
-       info_mode = INFO_MODE_MAIN;
+       SetGameStatus(GAME_MODE_INFO);
 
-       ChangeViewportPropertiesIfNeeded();
+       info_mode = INFO_MODE_MAIN;
 
        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);
 
-       game_status = GAME_MODE_SETUP;
-       setup_mode = SETUP_MODE_MAIN;
+       SetGameStatus(GAME_MODE_SETUP);
 
-       ChangeViewportPropertiesIfNeeded();
+       setup_mode = SETUP_MODE_MAIN;
 
        DrawSetupScreen();
       }
@@ -1942,7 +1962,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        SaveLevelSetup_SeriesInfo();
 
         if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED))
-         game_status = GAME_MODE_QUIT;
+         SetGameStatus(GAME_MODE_QUIT);
       }
     }
   }
@@ -2010,7 +2030,7 @@ static void execInfoLevelSet()
 
 static void execExitInfo()
 {
-  game_status = GAME_MODE_MAIN;
+  SetGameStatus(GAME_MODE_MAIN);
 
   DrawMainMenu();
 }
@@ -2083,7 +2103,6 @@ static void DrawCursorAndText_Setup(int screen_pos, int menu_info_pos_raw,
   DrawCursorAndText_Menu_Ext(setup_info, screen_pos, menu_info_pos_raw, active);
 }
 
-static char *screen_mode_text;
 static char *window_size_text;
 static char *scaling_type_text;
 
@@ -2110,7 +2129,6 @@ static void drawMenuInfoList(int first_entry, int num_page_entries,
        (value_ptr == &setup.sound_loops  && !audio.loops_available) ||
        (value_ptr == &setup.sound_music  && !audio.music_available) ||
        (value_ptr == &setup.fullscreen   && !video.fullscreen_available) ||
-       (value_ptr == &screen_mode_text   && !video.fullscreen_available) ||
        (value_ptr == &window_size_text   && !video.window_scaling_available) ||
        (value_ptr == &scaling_type_text  && !video.window_scaling_available))
       si->type |= TYPE_GHOSTED;
@@ -2142,12 +2160,11 @@ static void DrawInfoScreen_Main()
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
+  FadeMenuSoundsAndMusic();
 
   FreeScreenGadgets();
   CreateScreenGadgets();
 
-  CloseDoor(DOOR_CLOSE_2);
-
   /* (needed after displaying title screens which disable auto repeat) */
   KeyboardAutoRepeatOn();
 
@@ -2155,12 +2172,15 @@ static void DrawInfoScreen_Main()
 
   FadeOut(fade_mask);
 
+  /* needed if different viewport properties defined for info screen */
   ChangeViewportPropertiesIfNeeded();
 
-  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+  SetMainBackgroundImage(IMG_BACKGROUND_INFO);
 
   ClearField();
 
+  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+
   DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
 
   info_info = info_info_main;
@@ -2179,19 +2199,11 @@ static void DrawInfoScreen_Main()
 
   MapScreenGadgets(max_info_info);
 
-  PlayMenuSound();
-  PlayMenuMusic();
-
-#if 1
-  // needed after returning from title screens with different window size
-  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
-#endif
+  PlayMenuSoundsAndMusic();
 
   DrawMaskedBorder(fade_mask);
 
   FadeIn(fade_mask);
-
-  InitAnimation();
 }
 
 static void changeSetupValue(int, int, int);
@@ -2665,8 +2677,7 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
 
 void DrawInfoScreen_TitleScreen()
 {
-  game_status_last_screen = GAME_MODE_INFO;
-  game_status = GAME_MODE_TITLE;
+  SetGameStatus(GAME_MODE_TITLE);
 
   DrawTitleScreen();
 }
@@ -2688,8 +2699,6 @@ void DrawInfoScreen_Elements()
   HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
 
   FadeIn(REDRAW_FIELD);
-
-  InitAnimation();
 }
 
 void HandleInfoScreen_Elements(int button)
@@ -2742,7 +2751,7 @@ void HandleInfoScreen_Elements(int button)
 
     if (page >= num_pages)
     {
-      FadeSoundsAndMusic();
+      FadeMenuSoundsAndMusic();
 
       info_mode = INFO_MODE_MAIN;
       DrawInfoScreen();
@@ -2801,7 +2810,7 @@ void HandleInfoScreen_Music(int button)
 
     if (list == NULL)
     {
-      FadeSoundsAndMusic();
+      FadeMenuSoundsAndMusic();
 
       ClearField();
       DrawHeadline();
@@ -2820,7 +2829,7 @@ void HandleInfoScreen_Music(int button)
   {
     PlaySound(SND_MENU_ITEM_SELECTING);
 
-    FadeSoundsAndMusic();
+    FadeMenuSoundsAndMusic();
 
     info_mode = INFO_MODE_MAIN;
     DrawInfoScreen();
@@ -2841,7 +2850,7 @@ void HandleInfoScreen_Music(int button)
 
     if (list == NULL)
     {
-      FadeSoundsAndMusic();
+      FadeMenuSoundsAndMusic();
 
       info_mode = INFO_MODE_MAIN;
       DrawInfoScreen();
@@ -2849,7 +2858,7 @@ void HandleInfoScreen_Music(int button)
       return;
     }
 
-    FadeSoundsAndMusic();
+    FadeMenuSoundsAndMusic();
 
     if (list != music_file_info)
       FadeSetNextScreen();
@@ -3104,7 +3113,7 @@ void DrawInfoScreen_Credits()
 {
   SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
 
-  FadeSoundsAndMusic();
+  FadeMenuSoundsAndMusic();
 
   FadeOut(REDRAW_FIELD);
 
@@ -3145,7 +3154,7 @@ void HandleInfoScreen_Credits(int button)
 
     if (screen_nr >= num_screens)
     {
-      FadeSoundsAndMusic();
+      FadeMenuSoundsAndMusic();
 
       info_mode = INFO_MODE_MAIN;
       DrawInfoScreen();
@@ -3224,7 +3233,7 @@ void HandleInfoScreen_Program(int button)
   {
     PlaySound(SND_MENU_ITEM_SELECTING);
 
-    FadeSoundsAndMusic();
+    FadeMenuSoundsAndMusic();
 
     info_mode = INFO_MODE_MAIN;
     DrawInfoScreen();
@@ -3399,7 +3408,7 @@ void HandleInfoScreen_Version(int button)
   {
     PlaySound(SND_MENU_ITEM_SELECTING);
 
-    FadeSoundsAndMusic();
+    FadeMenuSoundsAndMusic();
 
     info_mode = INFO_MODE_MAIN;
     DrawInfoScreen();
@@ -3487,7 +3496,7 @@ void HandleInfoScreen_LevelSet(int button)
   {
     PlaySound(SND_MENU_ITEM_SELECTING);
 
-    FadeSoundsAndMusic();
+    FadeMenuSoundsAndMusic();
 
     info_mode = INFO_MODE_MAIN;
     DrawInfoScreen();
@@ -3500,8 +3509,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)
@@ -3522,10 +3529,7 @@ static void DrawInfoScreen()
   if (info_mode != INFO_MODE_MAIN &&
       info_mode != INFO_MODE_TITLE &&
       info_mode != INFO_MODE_MUSIC)
-  {
-    PlayMenuSound();
-    PlayMenuMusic();
-  }
+    PlayMenuSoundsAndMusic();
 }
 
 void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
@@ -3576,9 +3580,7 @@ void HandleTypeName(int newxpos, Key key)
 
     xpos = newxpos;
 
-#if defined(TARGET_SDL2)
-    SDL_StartTextInput();
-#endif
+    StartTextInput(startx, starty, pos->width, pos->height);
   }
   else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
   {
@@ -3599,7 +3601,7 @@ void HandleTypeName(int newxpos, Key key)
 
     is_active = FALSE;
 
-    game_status = GAME_MODE_MAIN;
+    SetGameStatus(GAME_MODE_MAIN);
   }
   else if (key == KSYM_Escape)
   {
@@ -3607,7 +3609,7 @@ void HandleTypeName(int newxpos, Key key)
 
     is_active = FALSE;
 
-    game_status = GAME_MODE_MAIN;
+    SetGameStatus(GAME_MODE_MAIN);
   }
 
   if (is_active)
@@ -3625,9 +3627,7 @@ void HandleTypeName(int newxpos, Key key)
 
     DrawText(startx, starty, setup.player_name, font_nr);
 
-#if defined(TARGET_SDL2)
-    SDL_StopTextInput();
-#endif
+    StopTextInput();
   }
 }
 
@@ -3645,7 +3645,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
 
   if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY))
   {
-    game_status = GAME_MODE_MAIN;
+    SetGameStatus(GAME_MODE_MAIN);
 
     DrawMainMenu();
 
@@ -3657,22 +3657,26 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
   FreeScreenGadgets();
   CreateScreenGadgets();
 
-  CloseDoor(DOOR_CLOSE_2);
-
   FadeOut(fade_mask);
 
-  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+  /* 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);
+
   HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
   MapScreenTreeGadgets(*ti_ptr);
 
   DrawMaskedBorder(fade_mask);
 
   FadeIn(fade_mask);
-
-  InitAnimation();
 }
 
 static void drawChooseTreeList(int first_entry, int num_page_entries,
@@ -3684,7 +3688,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;
 
@@ -3724,8 +3727,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
       initCursor(i, IMG_MENU_BUTTON);
   }
 
-  game_status = last_game_status;      /* restore current game status */
-
   redraw_mask |= REDRAW_FIELD;
 }
 
@@ -3773,7 +3774,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)
@@ -3781,8 +3781,6 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
   else
     num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
 
-  game_status = last_game_status;      /* restore current game status */
-
   if (button == MB_MENU_INITIALIZE)
   {
     int num_entries = numTreeInfoInGroup(ti);
@@ -3832,9 +3830,9 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
          setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
          setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
        execSetupGame();
-      else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
-              setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
-              setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
+      else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
+              setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
+              setup_mode == SETUP_MODE_CHOOSE_RENDERING)
        execSetupGraphics();
       else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
               setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
@@ -3856,7 +3854,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
        HandleMainMenu_SelectLevel(0, 0, new_level_nr);
       }
 
-      game_status = GAME_MODE_MAIN;
+      SetGameStatus(GAME_MODE_MAIN);
 
       DrawMainMenu();
     }
@@ -3866,12 +3864,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;
-
-    game_status = last_game_status;    /* restore current game status */
   }
   else if (dx || dy)   /* keyboard or scrollbar/scrollbutton input */
   {
@@ -4030,9 +4024,9 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
              setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
              setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
            execSetupGame();
-         else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE ||
-                  setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
-                  setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
+         else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
+                  setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
+                  setup_mode == SETUP_MODE_CHOOSE_RENDERING)
            execSetupGraphics();
          else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
                   setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
@@ -4054,7 +4048,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
            HandleMainMenu_SelectLevel(0, 0, new_level_nr);
          }
 
-         game_status = GAME_MODE_MAIN;
+         SetGameStatus(GAME_MODE_MAIN);
 
          DrawMainMenu();
        }
@@ -4065,12 +4059,11 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
 void DrawChooseLevelSet()
 {
-  SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
+  FadeMenuSoundsAndMusic();
 
   DrawChooseTree(&leveldir_current);
 
-  PlayMenuSound();
-  PlayMenuMusic();
+  PlayMenuSoundsAndMusic();
 }
 
 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
@@ -4082,6 +4075,8 @@ void DrawChooseLevelNr()
 {
   int i;
 
+  FadeMenuSoundsAndMusic();
+
   if (level_number != NULL)
   {
     freeTreeInfo(level_number);
@@ -4126,12 +4121,9 @@ void DrawChooseLevelNr()
   if (level_number_current == NULL)
     level_number_current = level_number;
 
-  SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
-
   DrawChooseTree(&level_number_current);
 
-  PlayMenuSound();
-  PlayMenuMusic();
+  PlayMenuSoundsAndMusic();
 }
 
 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
@@ -4143,17 +4135,11 @@ void DrawHallOfFame(int highlight_position)
 {
   int fade_mask = REDRAW_FIELD;
 
-  /* required before door position may be changed in next step */
-  CloseDoor(DOOR_CLOSE_ALL);
-
-  /* needed if different viewport properties defined for scores */
-  ChangeViewportPropertiesIfNeeded();
-
   if (CheckIfGlobalBorderHasChanged())
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
-  FadeSoundsAndMusic();
+  FadeMenuSoundsAndMusic();
 
   /* (this is needed when called from GameEnd() after winning a game) */
   KeyboardAutoRepeatOn();
@@ -4170,10 +4156,10 @@ void DrawHallOfFame(int highlight_position)
 
   FadeOut(fade_mask);
 
-  InitAnimation();
+  /* needed if different viewport properties defined for scores */
+  ChangeViewportPropertiesIfNeeded();
 
-  PlayMenuSound();
-  PlayMenuMusic();
+  PlayMenuSoundsAndMusic();
 
   OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
 
@@ -4203,9 +4189,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;
 
@@ -4270,7 +4257,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
 
     FadeSound(SND_BACKGROUND_SCORES);
 
-    game_status = GAME_MODE_MAIN;
+    SetGameStatus(GAME_MODE_MAIN);
 
     DrawMainMenu();
   }
@@ -4280,7 +4267,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
 
     FadeSound(SND_BACKGROUND_SCORES);
 
-    game_status = GAME_MODE_MAIN;
+    SetGameStatus(GAME_MODE_MAIN);
 
     DrawMainMenu();
   }
@@ -4298,9 +4285,9 @@ static struct TokenInfo *setup_info;
 static int num_setup_info;     /* number of setup entries shown on screen */
 static int max_setup_info;     /* total number of setup entries in list */
 
-static char *screen_mode_text;
 static char *window_size_text;
 static char *scaling_type_text;
+static char *rendering_mode_text;
 static char *scroll_delay_text;
 static char *snapshot_mode_text;
 static char *game_speed_text;
@@ -4393,31 +4380,31 @@ static void execSetupGame_setScrollDelays()
       setString(&ti->identifier, identifier);
       setString(&ti->name, name);
       setString(&ti->name_sorting, name);
-      setString(&ti->infotext, "Scaling Type");
+      setString(&ti->infotext, "Scroll Delay");
 
       pushTreeInfo(&scroll_delays, ti);
     }
 
-    /* sort scaling type values to start with lowest scaling type value */
+    /* sort scroll delay values to start with lowest scroll delay value */
     sortTreeInfo(&scroll_delays);
 
-    /* set current scaling type value to configured scaling type value */
+    /* set current scroll delay value to configured scroll delay value */
     scroll_delay_current =
       getTreeInfoFromIdentifier(scroll_delays,i_to_a(setup.scroll_delay_value));
 
-    /* if that fails, set current scaling type to reliable default value */
+    /* if that fails, set current scroll delay to reliable default value */
     if (scroll_delay_current == NULL)
       scroll_delay_current =
        getTreeInfoFromIdentifier(scroll_delays, i_to_a(STD_SCROLL_DELAY));
 
-    /* if that also fails, set current scaling type to first available value */
+    /* if that also fails, set current scroll delay to first available value */
     if (scroll_delay_current == NULL)
       scroll_delay_current = scroll_delays;
   }
 
   setup.scroll_delay_value = atoi(scroll_delay_current->identifier);
 
-  /* needed for displaying scaling type text instead of identifier */
+  /* needed for displaying scroll delay text instead of identifier */
   scroll_delay_text = scroll_delay_current->name;
 }
 
@@ -4645,82 +4632,70 @@ static void execSetupGraphics_setScalingTypes()
   scaling_type_text = scaling_type_current->name;
 }
 
-static void execSetupGraphics_setScreenModes()
+static void execSetupGraphics_setRenderingModes()
 {
-  // if (screen_modes == NULL && video.fullscreen_available)
-  if (screen_modes == NULL && video.fullscreen_modes != NULL)
+  if (rendering_modes == NULL)
   {
     int i;
 
-    for (i = 0; video.fullscreen_modes[i].width != -1; i++)
+    for (i = 0; rendering_modes_list[i].value != NULL; i++)
     {
       TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
       char identifier[32], name[32];
-      int x = video.fullscreen_modes[i].width;
-      int y = video.fullscreen_modes[i].height;
-      int xx, yy;
+      char *value = rendering_modes_list[i].value;
+      char *text = rendering_modes_list[i].text;
 
-      get_aspect_ratio_from_screen_mode(&video.fullscreen_modes[i], &xx, &yy);
-
-      ti->node_top = &screen_modes;
-      ti->sort_priority = x * 10000 + y;
+      ti->node_top = &rendering_modes;
+      ti->sort_priority = i;
 
-      sprintf(identifier, "%dx%d", x, y);
-      sprintf(name, "%d x %d [%d:%d]", x, y, xx, yy);
+      sprintf(identifier, "%s", value);
+      sprintf(name, "%s", text);
 
       setString(&ti->identifier, identifier);
       setString(&ti->name, name);
       setString(&ti->name_sorting, name);
-      setString(&ti->infotext, "Fullscreen Mode");
+      setString(&ti->infotext, "Special Rendering");
 
-      pushTreeInfo(&screen_modes, ti);
+      pushTreeInfo(&rendering_modes, ti);
     }
 
-    /* sort fullscreen modes to start with lowest available screen resolution */
-    sortTreeInfo(&screen_modes);
-
-    /* set current screen mode for fullscreen mode to configured setup value */
-    screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
-                                                   setup.fullscreen_mode);
+    /* sort rendering mode values to start with lowest rendering mode value */
+    sortTreeInfo(&rendering_modes);
 
-    /* if that fails, set current screen mode to reliable default value */
-    if (screen_mode_current == NULL)
-      screen_mode_current = getTreeInfoFromIdentifier(screen_modes,
-                                                     DEFAULT_FULLSCREEN_MODE);
+    /* set current rendering mode value to configured rendering mode value */
+    rendering_mode_current =
+      getTreeInfoFromIdentifier(rendering_modes, setup.screen_rendering_mode);
 
-    /* if that also fails, set current screen mode to first available mode */
-    if (screen_mode_current == NULL)
-      screen_mode_current = screen_modes;
+    /* if that fails, set current rendering mode to reliable default value */
+    if (rendering_mode_current == NULL)
+      rendering_mode_current =
+       getTreeInfoFromIdentifier(rendering_modes,
+                                 STR_SPECIAL_RENDERING_DEFAULT);
 
-    if (screen_mode_current == NULL)
-      video.fullscreen_available = FALSE;
+    /* if that also fails, set current rendering mode to first available one */
+    if (rendering_mode_current == NULL)
+      rendering_mode_current = rendering_modes;
   }
 
-  // if (video.fullscreen_available)
-  if (screen_mode_current != NULL)
-  {
-    setup.fullscreen_mode = screen_mode_current->identifier;
+  setup.screen_rendering_mode = rendering_mode_current->identifier;
 
-    /* needed for displaying screen mode name instead of identifier */
-    screen_mode_text = screen_mode_current->name;
-  }
+  /* needed for displaying rendering mode text instead of identifier */
+  rendering_mode_text = rendering_mode_current->name;
 }
 
 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_setScreenModes();
+  execSetupGraphics_setRenderingModes();
 
   setup_mode = SETUP_MODE_GRAPHICS;
 
@@ -4733,11 +4708,13 @@ static void execSetupGraphics()
   // window scaling quality may have changed at this point
   if (!strEqual(setup.window_scaling_quality, video.window_scaling_quality))
     SDLSetWindowScalingQuality(setup.window_scaling_quality);
+
+  // screen rendering mode may have changed at this point
+  SDLSetScreenRenderingMode(setup.screen_rendering_mode);
 #endif
 }
 
-#if !defined(PLATFORM_ANDROID)
-#if defined(TARGET_SDL2)
+#if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
 static void execSetupChooseWindowSize()
 {
   setup_mode = SETUP_MODE_CHOOSE_WINDOW_SIZE;
@@ -4751,18 +4728,14 @@ static void execSetupChooseScalingType()
 
   DrawSetupScreen();
 }
-#else
-static void execSetupChooseScreenMode()
-{
-  if (!video.fullscreen_available)
-    return;
 
-  setup_mode = SETUP_MODE_CHOOSE_SCREEN_MODE;
+static void execSetupChooseRenderingMode()
+{
+  setup_mode = SETUP_MODE_CHOOSE_RENDERING;
 
   DrawSetupScreen();
 }
 #endif
-#endif
 
 static void execSetupChooseVolumeSimple()
 {
@@ -5270,7 +5243,7 @@ static void execSetupShortcuts5()
 
 static void execExitSetup()
 {
-  game_status = GAME_MODE_MAIN;
+  SetGameStatus(GAME_MODE_MAIN);
 
   DrawMainMenu();
 }
@@ -5360,17 +5333,14 @@ static struct TokenInfo setup_info_editor[] =
 
 static struct TokenInfo setup_info_graphics[] =
 {
-#if !defined(PLATFORM_ANDROID)
+#if defined(TARGET_SDL2) && !defined(PLATFORM_ANDROID)
   { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen:"           },
-#if defined(TARGET_SDL2)
   { TYPE_ENTER_LIST,   execSetupChooseWindowSize, "Window Scaling:"    },
   { TYPE_STRING,       &window_size_text,      ""                      },
   { TYPE_ENTER_LIST,   execSetupChooseScalingType, "Anti-Aliasing:"    },
   { TYPE_STRING,       &scaling_type_text,     ""                      },
-#else
-  { TYPE_ENTER_LIST,   execSetupChooseScreenMode, "Fullscreen Mode:"   },
-  { TYPE_STRING,       &screen_mode_text,      ""                      },
-#endif
+  { TYPE_ENTER_LIST,   execSetupChooseRenderingMode, "Special Rendering:" },
+  { TYPE_STRING,       &rendering_mode_text,   ""                      },
 #endif
 #if 0
   { TYPE_ENTER_LIST,   execSetupChooseScrollDelay, "Scroll Delay:"     },
@@ -5380,7 +5350,7 @@ static struct TokenInfo setup_info_graphics[] =
   { TYPE_SWITCH,       &setup.quick_switch,    "Quick Player Focus Switch:" },
   { TYPE_SWITCH,       &setup.quick_doors,     "Quick Menu Doors:"     },
   { TYPE_SWITCH,       &setup.show_titlescreen,"Show Title Screens:"   },
-  { TYPE_SWITCH,       &setup.toons,           "Show Toons:"           },
+  { TYPE_SWITCH,       &setup.toons,           "Show Menu Animations:" },
   { TYPE_ECS_AGA,      &setup.prefer_aga_graphics,"EMC graphics preference:" },
   { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" },
   { TYPE_SWITCH,       &setup.small_game_graphics, "Small Game Graphics:" },
@@ -5447,6 +5417,16 @@ static struct TokenInfo setup_info_input[] =
 };
 
 static struct TokenInfo setup_info_touch[] =
+{
+  { TYPE_ENTER_LIST,   execSetupChooseTouchControls, "Touch Control Type:" },
+  { TYPE_STRING,       &touch_controls_text,   ""                      },
+  { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
+
+  { 0,                 NULL,                   NULL                    }
+};
+
+static struct TokenInfo setup_info_touch_wipe_gestures[] =
 {
   { TYPE_ENTER_LIST,   execSetupChooseTouchControls, "Touch Control Type:" },
   { TYPE_STRING,       &touch_controls_text,   ""                      },
@@ -5596,11 +5576,7 @@ static Key getSetupKey()
       }
     }
 
-    DoAnimation();
     BackToFront();
-
-    /* don't eat all CPU time */
-    Delay(10);
   }
 
   return key;
@@ -5623,20 +5599,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);
@@ -5668,8 +5653,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)
@@ -5710,7 +5716,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);
 
@@ -5767,21 +5773,25 @@ static void DrawSetupScreen_Generic()
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
+  FadeMenuSoundsAndMusic();
 
   FreeScreenGadgets();
   CreateScreenGadgets();
 
-  CloseDoor(DOOR_CLOSE_2);
-
   if (redraw_mask & REDRAW_ALL)
     redraw_all = TRUE;
 
   FadeOut(fade_mask);
 
-  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+  /* needed if different viewport properties defined for setup screen */
+  ChangeViewportPropertiesIfNeeded();
+
+  SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
 
   ClearField();
 
+  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+
   if (setup_mode == SETUP_MODE_MAIN)
   {
     setup_info = setup_info_main;
@@ -5816,6 +5826,9 @@ static void DrawSetupScreen_Generic()
   {
     setup_info = setup_info_touch;
     title_string = "Setup Touch Ctrls";
+
+    if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
+      setup_info = setup_info_touch_wipe_gestures;
   }
   else if (setup_mode == SETUP_MODE_SHORTCUTS)
   {
@@ -5870,8 +5883,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)
@@ -5919,8 +5930,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)
@@ -6201,8 +6210,6 @@ void CustomizeKeyboard(int player_nr)
 
   FadeIn(REDRAW_FIELD);
 
-  InitAnimation();
-
   while (!finished)
   {
     if (PendingEvent())                /* got event */
@@ -6284,17 +6291,12 @@ void CustomizeKeyboard(int player_nr)
       }
     }
 
-    DoAnimation();
     BackToFront();
-
-    /* don't eat all CPU time */
-    Delay(10);
   }
 
   /* write new key bindings back to player setup */
   setup.input[player_nr].key = custom_key;
 
-  StopAnimation();
   DrawSetupScreen_Input();
 }
 
@@ -6358,7 +6360,6 @@ static boolean CalibrateJoystickMain(int player_nr)
   FadeIn(REDRAW_FIELD);
 
   while (Joystick(player_nr) & JOY_BUTTON);    /* wait for released button */
-  InitAnimation();
 
   while (result < 0)
   {
@@ -6440,11 +6441,7 @@ static boolean CalibrateJoystickMain(int player_nr)
       }
     }
 
-    DoAnimation();
     BackToFront();
-
-    /* don't eat all CPU time */
-    Delay(10);
   }
 
   /* calibrated center position (joystick should now be centered) */
@@ -6454,8 +6451,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)
   {
@@ -6466,7 +6461,7 @@ static boolean CalibrateJoystickMain(int player_nr)
       NextEvent(&event);
       HandleOtherEvents(&event);
 
-      Delay(10);
+      BackToFront();
     }
   }
 
@@ -6500,8 +6495,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)
@@ -6510,12 +6503,12 @@ void DrawSetupScreen()
     DrawChooseTree(&scroll_delay_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
     DrawChooseTree(&snapshot_mode_current);
-  else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
-    DrawChooseTree(&screen_mode_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
     DrawChooseTree(&window_size_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
     DrawChooseTree(&scaling_type_current);
+  else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING)
+    DrawChooseTree(&rendering_mode_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
     DrawChooseTree(&artwork.gfx_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
@@ -6537,8 +6530,7 @@ void DrawSetupScreen()
   else
     DrawSetupScreen_Generic();
 
-  PlayMenuSound();
-  PlayMenuMusic();
+  PlayMenuSoundsAndMusic();
 }
 
 void RedrawSetupScreenAfterFullscreenToggle()
@@ -6563,12 +6555,12 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
     HandleChooseTree(mx, my, dx, dy, button, &scroll_delay_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
     HandleChooseTree(mx, my, dx, dy, button, &snapshot_mode_current);
-  else if (setup_mode == SETUP_MODE_CHOOSE_SCREEN_MODE)
-    HandleChooseTree(mx, my, dx, dy, button, &screen_mode_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
     HandleChooseTree(mx, my, dx, dy, button, &window_size_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE)
     HandleChooseTree(mx, my, dx, dy, button, &scaling_type_current);
+  else if (setup_mode == SETUP_MODE_CHOOSE_RENDERING)
+    HandleChooseTree(mx, my, dx, dy, button, &rendering_mode_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
     HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current);
   else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS)
@@ -6917,14 +6909,10 @@ static void CreateScreenScrollbars()
 
 void CreateScreenGadgets()
 {
-  int last_game_status = game_status;  /* save current game status */
-
   CreateScreenMenubuttons();
 
   CreateScreenScrollbuttons();
   CreateScreenScrollbars();
-
-  game_status = last_game_status;      /* restore current game status */
 }
 
 void FreeScreenGadgets()