rnd-20060407-1-src
[rocksndiamonds.git] / src / screens.c
index ae2843a1fbc515b64e4dceda60589d6ae85e9f31..7a7fe1afcc03e553080458d7787057bf822890cc 100644 (file)
 #define SETUP_MODE_GAME                        1
 #define SETUP_MODE_EDITOR              2
 #define SETUP_MODE_INPUT               3
-#define SETUP_MODE_SHORTCUT            4
-#define SETUP_MODE_GRAPHICS            5
-#define SETUP_MODE_SOUND               6
-#define SETUP_MODE_ARTWORK             7
-#define SETUP_MODE_CHOOSE_GRAPHICS     8
-#define SETUP_MODE_CHOOSE_SOUNDS       9
-#define SETUP_MODE_CHOOSE_MUSIC                10
+#define SETUP_MODE_SHORTCUT_1          4
+#define SETUP_MODE_SHORTCUT_2          5
+#define SETUP_MODE_GRAPHICS            6
+#define SETUP_MODE_SOUND               7
+#define SETUP_MODE_ARTWORK             8
+#define SETUP_MODE_CHOOSE_GRAPHICS     9
+#define SETUP_MODE_CHOOSE_SOUNDS       10
+#define SETUP_MODE_CHOOSE_MUSIC                11
 
-#define MAX_SETUP_MODES                        11
+#define MAX_SETUP_MODES                        12
 
 /* for input setup functions */
 #define SETUPINPUT_SCREEN_POS_START    0
@@ -60,6 +61,7 @@
 #define MAX_MENU_ENTRIES_ON_SCREEN     (SCR_FIELDY - 2)
 #define MENU_SCREEN_START_YPOS         2
 #define MENU_SCREEN_VALUE_XPOS         14
+#define MENU_SCREEN_MAX_XPOS           (SCR_FIELDX - 1)
 #define MENU_TITLE1_YPOS               8
 #define MENU_TITLE2_YPOS               46
 
@@ -134,6 +136,8 @@ static void drawCursorExt(int xpos, int ypos, int color, int g)
         g == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE :
         g == IMG_MENU_BUTTON_LEAVE_MENU ? IMG_MENU_BUTTON_LEAVE_MENU_ACTIVE :
         g == IMG_MENU_BUTTON_ENTER_MENU ? IMG_MENU_BUTTON_ENTER_MENU_ACTIVE :
+        g == IMG_MENU_BUTTON_LAST_LEVEL ? IMG_MENU_BUTTON_LAST_LEVEL_ACTIVE :
+        g == IMG_MENU_BUTTON_NEXT_LEVEL ? IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE :
         IMG_MENU_BUTTON_ACTIVE);
 
   ypos += MENU_SCREEN_START_YPOS;
@@ -233,6 +237,26 @@ static void ToggleFullscreenIfNeeded()
   }
 }
 
+static int getLastLevelButtonPos()
+{
+  return 10;
+}
+
+static int getCurrentLevelTextPos()
+{
+  return (getLastLevelButtonPos() + 1);
+}
+
+static int getNextLevelButtonPos()
+{
+  return getLastLevelButtonPos() + 3 + 1;
+}
+
+static int getLevelRangeTextPos()
+{
+  return getNextLevelButtonPos() + 1;
+}
+
 void DrawMainMenu()
 {
   static LevelDirTree *leveldir_last_valid = NULL;
@@ -313,20 +337,30 @@ void DrawMainMenu()
 
   /* calculated after (possible) reload of custom artwork */
   name_width  = getTextWidth(name_text,  FONT_MENU_1);
+#if 1
+  level_width = 9 * 32;
+#else
 #if 1
   level_width = 9 * getFontWidth(FONT_MENU_1);
 #else
   level_width = getTextWidth(level_text, FONT_MENU_1);
+#endif
 #endif
 
   DrawText(mSX + 32 + name_width, mSY + 2 * 32, setup.player_name,
           FONT_INPUT_1);
+
+#if 1
+  DrawText(mSX + getCurrentLevelTextPos() * 32, mSY + 3 * 32,
+          int2str(level_nr, 3), FONT_VALUE_1);
+#else
 #if 1
   DrawText(mSX + level_width + 2 * 32, mSY + 3 * 32, int2str(level_nr, 3),
           FONT_VALUE_1);
 #else
   DrawText(mSX + level_width + 5 * 32, mSY + 3 * 32, int2str(level_nr, 3),
           FONT_VALUE_1);
+#endif
 #endif
 
   DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, TRUE);
@@ -336,12 +370,17 @@ void DrawMainMenu()
 #if 1
   {
     int text_height = getFontHeight(FONT_TEXT_3);
+#if 1
+    int xpos = getLevelRangeTextPos() * 32;
+#else
+    int xpos = level_width + 6 * 32;
+#endif
     int ypos2 = -SY + 3 * 32 + 16;
     int ypos1 = ypos2 - text_height;
 
-    DrawTextF(mSX + level_width + 6 * 32, mSY + ypos1, FONT_TEXT_3,
+    DrawTextF(mSX + xpos, mSY + ypos1, FONT_TEXT_3,
              "%03d", leveldir_current->first_level);
-    DrawTextF(mSX + level_width + 6 * 32, mSY + ypos2, FONT_TEXT_3,
+    DrawTextF(mSX + xpos, mSY + ypos2, FONT_TEXT_3,
              "%03d", leveldir_current->last_level);
   }
 #else
@@ -368,12 +407,17 @@ void DrawMainMenu()
     initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_ENTER_MENU :
                   IMG_MENU_BUTTON));
 
+#if 1
+  drawCursorXY(getLastLevelButtonPos(), 1, IMG_MENU_BUTTON_LAST_LEVEL);
+  drawCursorXY(getNextLevelButtonPos(), 1, IMG_MENU_BUTTON_NEXT_LEVEL);
+#else
 #if 1
   drawCursorXY(level_width / 32 + 1, 1, IMG_MENU_BUTTON_LEFT);
   drawCursorXY(level_width / 32 + 5, 1, IMG_MENU_BUTTON_RIGHT);
 #else
   drawCursorXY(level_width / 32 + 4, 1, IMG_MENU_BUTTON_LEFT);
   drawCursorXY(level_width / 32 + 8, 1, IMG_MENU_BUTTON_RIGHT);
+#endif
 #endif
 
   DrawTextSCentered(326, FONT_TITLE_2, "A Game by Artsoft Entertainment");
@@ -452,6 +496,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
   {
     if (dx && choice == 1)
       x = (dx < 0 ? 10 : 14);
+    else if (dx > 0)
+    {
+      if (choice == 4 || choice == 6)
+       button = MB_MENU_CHOICE;
+    }
     else if (dy)
       y = choice + dy;
   }
@@ -821,12 +870,15 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
     action = helpanim_info[j].action;
     direction = helpanim_info[j].direction;
 
+    if (element < 0)
+      element = EL_UNKNOWN;
+
     if (action != -1 && direction != -1)
       graphic = el_act_dir2img(element, action, direction);
     else if (action != -1)
       graphic = el_act2img(element, action);
     else if (direction != -1)
-      graphic = el_act2img(element, direction);
+      graphic = el_dir2img(element, direction);
     else
       graphic = el2img(element);
 
@@ -995,7 +1047,7 @@ void HandleInfoScreen_Elements(int button)
   }
   else
   {
-    if (DelayReached(&info_delay, GAME_FRAME_DELAY))
+    if (DelayReached(&info_delay, GameFrameDelay))
       if (page < num_pages)
        DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
 
@@ -1998,9 +2050,15 @@ static void execSetupInput()
   DrawSetupScreen();
 }
 
-static void execSetupShortcut()
+static void execSetupShortcut1()
 {
-  setup_mode = SETUP_MODE_SHORTCUT;
+  setup_mode = SETUP_MODE_SHORTCUT_1;
+  DrawSetupScreen();
+}
+
+static void execSetupShortcut2()
+{
+  setup_mode = SETUP_MODE_SHORTCUT_2;
   DrawSetupScreen();
 }
 
@@ -2018,13 +2076,14 @@ static void execSaveAndExitSetup()
 
 static struct TokenInfo setup_info_main[] =
 {
-  { TYPE_ENTER_MENU,   execSetupGame,          "Game Settings"         },
-  { TYPE_ENTER_MENU,   execSetupEditor,        "Editor Settings"       },
+  { TYPE_ENTER_MENU,   execSetupGame,          "Game & Menu"           },
+  { TYPE_ENTER_MENU,   execSetupEditor,        "Editor"                },
   { TYPE_ENTER_MENU,   execSetupGraphics,      "Graphics"              },
   { TYPE_ENTER_MENU,   execSetupSound,         "Sound & Music"         },
   { TYPE_ENTER_MENU,   execSetupArtwork,       "Custom Artwork"        },
   { TYPE_ENTER_MENU,   execSetupInput,         "Input Devices"         },
-  { TYPE_ENTER_MENU,   execSetupShortcut,      "Key Shortcuts"         },
+  { TYPE_ENTER_MENU,   execSetupShortcut1,     "Key Shortcuts 1"       },
+  { TYPE_ENTER_MENU,   execSetupShortcut2,     "Key Shortcuts 2"       },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execExitSetup,          "Exit"                  },
   { TYPE_LEAVE_MENU,   execSaveAndExitSetup,   "Save and Exit"         },
@@ -2034,11 +2093,12 @@ static struct TokenInfo setup_info_main[] =
 
 static struct TokenInfo setup_info_game[] =
 {
-  { TYPE_SWITCH,       &setup.team_mode,       "Team-Mode:"            },
+  { TYPE_SWITCH,       &setup.team_mode,       "Team-Mode (Multi-Player):" },
+  { TYPE_YES_NO,       &setup.input_on_focus,  "Only Move Focussed Player:" },
   { TYPE_SWITCH,       &setup.handicap,        "Handicap:"             },
-  { TYPE_SWITCH,       &setup.skip_levels,     "Skip Levels:"          },
-  { TYPE_SWITCH,       &setup.time_limit,      "Timelimit:"            },
-  { TYPE_SWITCH,       &setup.autorecord,      "Auto-Record:"          },
+  { TYPE_SWITCH,       &setup.skip_levels,     "Skip Unsolved Levels:" },
+  { TYPE_SWITCH,       &setup.time_limit,      "Time Limit:"           },
+  { TYPE_SWITCH,       &setup.autorecord,      "Auto-Record Tapes:"    },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -2047,26 +2107,19 @@ static struct TokenInfo setup_info_game[] =
 
 static struct TokenInfo setup_info_editor[] =
 {
-#if 0
-  { TYPE_STRING,       NULL,                   "Offer Special Elements:"},
-#endif
-
-#if 0
-#else
-  { TYPE_SWITCH,       &setup.editor.el_boulderdash,   "BoulderDash:"  },
+  { TYPE_SWITCH,       &setup.editor.el_boulderdash,   "Boulder Dash:" },
   { TYPE_SWITCH,       &setup.editor.el_emerald_mine,  "Emerald Mine:" },
-  { TYPE_SWITCH,       &setup.editor.el_emerald_mine_club,"E.M.C.:"    },
-  { TYPE_SWITCH,       &setup.editor.el_more,          "R'n'D:"        },
+  { TYPE_SWITCH, &setup.editor.el_emerald_mine_club,   "Emerald Mine Club:" },
+  { TYPE_SWITCH,       &setup.editor.el_more,          "Rocks'n'Diamonds:" },
   { TYPE_SWITCH,       &setup.editor.el_sokoban,       "Sokoban:"      },
   { TYPE_SWITCH,       &setup.editor.el_supaplex,      "Supaplex:"     },
-  { TYPE_SWITCH,       &setup.editor.el_diamond_caves, "DC II:"        },
-  { TYPE_SWITCH,       &setup.editor.el_dx_boulderdash,"DX BD:"        },
-#endif
-  { TYPE_SWITCH,       &setup.editor.el_chars,         "Characters:"   },
-  { TYPE_SWITCH,       &setup.editor.el_custom,        "Custom:"       },
+  { TYPE_SWITCH,       &setup.editor.el_diamond_caves, "Diamond Caves II:" },
+  { TYPE_SWITCH,       &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
+  { TYPE_SWITCH,       &setup.editor.el_chars,         "Text Characters:" },
+  { TYPE_SWITCH,       &setup.editor.el_custom,  "Custom & Group Elements:" },
   { TYPE_SWITCH,       &setup.editor.el_headlines,     "Headlines:"    },
-  { TYPE_SWITCH,       &setup.editor.el_user_defined,  "User defined:" },
-  { TYPE_SWITCH,       &setup.editor.el_dynamic,       "Dynamic:"      },
+  { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
+  { TYPE_SWITCH,       &setup.editor.el_dynamic,  "Dynamic level elements:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -2075,15 +2128,17 @@ static struct TokenInfo setup_info_editor[] =
 
 static struct TokenInfo setup_info_graphics[] =
 {
-  { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen:"           },
-  { TYPE_SWITCH,       &setup.scroll_delay,    "Scroll Delay:"         },
-  { TYPE_SWITCH,       &setup.soft_scrolling,  "Soft Scroll.:"         },
+  { TYPE_SWITCH,       &setup.fullscreen,      "Fullscreen Mode:"      },
+  { TYPE_SWITCH,       &setup.scroll_delay,    "Delayed Scrolling:"    },
 #if 0
-  { TYPE_SWITCH,       &setup.double_buffering,"Buffered gfx:"         },
+  { TYPE_SWITCH,       &setup.soft_scrolling,  "Soft Scrolling:"       },
+  { TYPE_SWITCH,       &setup.double_buffering,"Double-Buffering:"     },
   { TYPE_SWITCH,       &setup.fading,          "Fading:"               },
 #endif
-  { TYPE_SWITCH,       &setup.quick_doors,     "Quick Doors:"          },
+  { TYPE_SWITCH,       &setup.quick_switch,    "Quick Player Focus Switch:" },
+  { TYPE_SWITCH,       &setup.quick_doors,     "Quick Menu Doors:"     },
   { TYPE_SWITCH,       &setup.toons,           "Toons:"                },
+  { TYPE_ECS_AGA,      &setup.prefer_aga_graphics,"EMC graphics preference:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -2092,9 +2147,9 @@ static struct TokenInfo setup_info_graphics[] =
 
 static struct TokenInfo setup_info_sound[] =
 {
-  { TYPE_SWITCH,       &setup.sound_simple,    "Simple Sound:"         },
-  { TYPE_SWITCH,       &setup.sound_loops,     "Sound Loops:"          },
-  { TYPE_SWITCH,       &setup.sound_music,     "Game Music:"           },
+  { TYPE_SWITCH,       &setup.sound_simple,    "Sound Effects (Normal):"  },
+  { TYPE_SWITCH,       &setup.sound_loops,     "Sound Effects (Looping):" },
+  { TYPE_SWITCH,       &setup.sound_music,     "Music:"                },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -2110,26 +2165,51 @@ static struct TokenInfo setup_info_artwork[] =
   { TYPE_ENTER_MENU,   execSetupChooseMusic,   "Custom Music"          },
   { TYPE_STRING,       &music_set_name,        ""                      },
   { TYPE_EMPTY,                NULL,                   ""                      },
+#if 1
+  { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
+  { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:"   },
+  { TYPE_YES_NO, &setup.override_level_music,  "Override Level Music:"    },
+#else
   { TYPE_STRING,       NULL,                   "Override Level Artwork:"},
   { TYPE_YES_NO,       &setup.override_level_graphics, "Graphics:"     },
   { TYPE_YES_NO,       &setup.override_level_sounds,   "Sounds:"       },
   { TYPE_YES_NO,       &setup.override_level_music,    "Music:"        },
+#endif
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
   { 0,                 NULL,                   NULL                    }
 };
 
-static struct TokenInfo setup_info_shortcut[] =
+static struct TokenInfo setup_info_shortcut_1[] =
 {
-  { TYPE_KEYTEXT,      NULL,                   "Quick Save Game:",     },
-  { TYPE_KEY,          &setup.shortcut.save_game,      ""              },
-  { TYPE_KEYTEXT,      NULL,                   "Quick Load Game:",     },
-  { TYPE_KEY,          &setup.shortcut.load_game,      ""              },
-  { TYPE_KEYTEXT,      NULL,                   "Toggle Pause:",        },
-  { TYPE_KEY,          &setup.shortcut.toggle_pause,   ""              },
+  { TYPE_KEYTEXT,      NULL,           "Quick Save Game to Tape:",     },
+  { TYPE_KEY,          &setup.shortcut.save_game, ""                   },
+  { TYPE_KEYTEXT,      NULL,           "Quick Load Game from Tape:",   },
+  { TYPE_KEY,          &setup.shortcut.load_game, ""                   },
+  { TYPE_KEYTEXT,      NULL,           "Start Game & Toggle Pause:",   },
+  { TYPE_KEY,          &setup.shortcut.toggle_pause, ""                },
   { TYPE_EMPTY,                NULL,                   ""                      },
-  { TYPE_YES_NO,       &setup.ask_on_escape,   "Ask on Esc:"           },
+  { TYPE_YES_NO,       &setup.ask_on_escape,   "Ask on 'Esc' Key:"     },
+  { TYPE_YES_NO, &setup.ask_on_escape_editor,  "Ask on 'Esc' Key (Editor):" },
+  { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
+
+  { 0,                 NULL,                   NULL                    }
+};
+
+static struct TokenInfo setup_info_shortcut_2[] =
+{
+  { TYPE_KEYTEXT,      NULL,           "Set Focus to Player 1:",       },
+  { TYPE_KEY,          &setup.shortcut.focus_player[0], ""             },
+  { TYPE_KEYTEXT,      NULL,           "Set Focus to Player 2:",       },
+  { TYPE_KEY,          &setup.shortcut.focus_player[1], ""             },
+  { TYPE_KEYTEXT,      NULL,           "Set Focus to Player 3:",       },
+  { TYPE_KEY,          &setup.shortcut.focus_player[2], ""             },
+  { TYPE_KEYTEXT,      NULL,           "Set Focus to Player 4:",       },
+  { TYPE_KEY,          &setup.shortcut.focus_player[3], ""             },
+  { TYPE_KEYTEXT,      NULL,           "Set Focus to All Players:",    },
+  { TYPE_KEY,          &setup.shortcut.focus_player_all, ""            },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -2188,17 +2268,22 @@ static void drawSetupValue(int pos)
   int xpos = MENU_SCREEN_VALUE_XPOS;
   int ypos = MENU_SCREEN_START_YPOS + pos;
   int font_nr = FONT_VALUE_1;
+  int font_width = getFontWidth(font_nr);
   int type = setup_info[pos].type;
   void *value = setup_info[pos].value;
-  char *value_string = (!(type & TYPE_GHOSTED) ? getSetupValue(type, value) :
-                       "n/a");
+  char *value_string = getSetupValue(type, value);
+  int i;
 
   if (value_string == NULL)
     return;
 
   if (type & TYPE_KEY)
   {
+#if 1
+    xpos = 1;
+#else
     xpos = 3;
+#endif
 
     if (type & TYPE_QUERY)
     {
@@ -2216,13 +2301,28 @@ static void drawSetupValue(int pos)
     if (strlen(value_string) > max_value_len)
       value_string[max_value_len] = '\0';
   }
+  else if (type & TYPE_ECS_AGA)
+  {
+    font_nr = FONT_VALUE_1;
+  }
   else if (type & TYPE_BOOLEAN_STYLE)
   {
     font_nr = (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
   }
 
+#if 1
+  for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++)
+    DrawText(mSX + xpos * 32 + i * font_width, mSY + ypos * 32, " ", font_nr);
+#else
+#if 1
+  for (i = xpos; i <= MENU_SCREEN_MAX_XPOS; i++)
+    DrawText(mSX + i * 32, mSY + ypos * 32, " ", font_nr);
+#else
   DrawText(mSX + xpos * 32, mSY + ypos * 32,
           (xpos == 3 ? "              " : "   "), font_nr);
+#endif
+#endif
+
   DrawText(mSX + xpos * 32, mSY + ypos * 32, value_string, font_nr);
 }
 
@@ -2288,9 +2388,14 @@ static void DrawSetupScreen_Generic()
     setup_info = setup_info_artwork;
     title_string = "Custom Artwork";
   }
-  else if (setup_mode == SETUP_MODE_SHORTCUT)
+  else if (setup_mode == SETUP_MODE_SHORTCUT_1)
   {
-    setup_info = setup_info_shortcut;
+    setup_info = setup_info_shortcut_1;
+    title_string = "Setup Shortcuts";
+  }
+  else if (setup_mode == SETUP_MODE_SHORTCUT_2)
+  {
+    setup_info = setup_info_shortcut_2;
     title_string = "Setup Shortcuts";
   }
 
@@ -2314,8 +2419,17 @@ static void DrawSetupScreen_Generic()
        (value_ptr == &setup.fullscreen   && !video.fullscreen_available))
       setup_info[i].type |= TYPE_GHOSTED;
 
+#if 1
+    if (setup_info[i].type & (TYPE_SWITCH |
+                             TYPE_YES_NO |
+                             TYPE_STRING |
+                             TYPE_ECS_AGA |
+                             TYPE_KEYTEXT))
+      font_nr = FONT_MENU_2;
+#else
     if (setup_info[i].type & TYPE_STRING)
       font_nr = FONT_MENU_2;
+#endif
 
     DrawText(mSX + 32, mSY + ypos * 32, setup_info[i].text, font_nr);
 
@@ -2514,6 +2628,8 @@ static void drawPlayerSetupInputInfo(int player_nr)
     "Joystick4"
   };
 
+  InitJoysticks();
+
   custom_key = setup.input[player_nr].key;
 
   DrawText(mSX + 11 * 32, mSY + 2 * 32, int2str(player_nr + 1, 1),
@@ -2527,10 +2643,10 @@ static void drawPlayerSetupInputInfo(int player_nr)
   if (setup.input[player_nr].use_joystick)
   {
     char *device_name = setup.input[player_nr].joy.device_name;
+    char *text = joystick_name[getJoystickNrFromDeviceName(device_name)];
+    int font_nr = (joystick.fd[player_nr] < 0 ? FONT_VALUE_OLD : FONT_VALUE_1);
 
-    DrawText(mSX + 8 * 32, mSY + 3 * 32,
-            joystick_name[getJoystickNrFromDeviceName(device_name)],
-            FONT_VALUE_1);
+    DrawText(mSX + 8 * 32, mSY + 3 * 32, text, font_nr);
     DrawText(mSX + 32, mSY + 4 * 32, "Calibrate", FONT_MENU_1);
   }
   else
@@ -2982,7 +3098,9 @@ static boolean CalibrateJoystickMain(int player_nr)
 
   StopAnimation();
 
+#if 0
   DrawSetupScreen_Input();
+#endif
 
   /* wait until the last pressed button was released */
   while (Joystick(player_nr) & JOY_BUTTON)
@@ -3005,13 +3123,25 @@ void CalibrateJoystick(int player_nr)
 {
   if (!CalibrateJoystickMain(player_nr))
   {
+    char *device_name = setup.input[player_nr].joy.device_name;
+    int nr = getJoystickNrFromDeviceName(device_name) + 1;
+    int xpos = mSX - SX;
+    int ypos = mSY - SY;
+
     ClearWindow();
 
-    DrawText(mSX + 16, mSY + 6 * 32, "  JOYSTICK NOT  ",  FONT_TITLE_1);
-    DrawText(mSX,      mSY + 7 * 32, "    AVAILABLE    ", FONT_TITLE_1);
+    DrawTextF(xpos + 16, ypos + 6 * 32, FONT_TITLE_1, "   JOYSTICK %d   ", nr);
+    DrawTextF(xpos + 16, ypos + 7 * 32, FONT_TITLE_1, " NOT AVAILABLE! ");
     BackToFront();
-    Delay(2000);       /* show error message for two seconds */
+
+    Delay(2000);               /* show error message for a short time */
+
+    ClearEventQueue();
   }
+
+#if 1
+  DrawSetupScreen_Input();
+#endif
 }
 
 void DrawSetupScreen()
@@ -3056,160 +3186,10 @@ void HandleGameActions()
   if (game_status != GAME_MODE_PLAYING)
     return;
 
-  /* !!! FIX THIS (START) !!! */
-  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
-  {
-    byte *recorded_player_action;
-    byte summarized_player_action = 0;
-    byte tape_action[MAX_PLAYERS];
-    int i;
-
-    if (level.native_em_level->lev->home == 0) /* all players at home */
-    {
-      GameWon();
-
-      if (!TAPE_IS_STOPPED(tape))
-       TapeStop();
-
-      if (game_status != GAME_MODE_PLAYING)
-       return;
-    }
-
-    if (level.native_em_level->ply1->alive == 0 &&
-       level.native_em_level->ply2->alive == 0)        /* all dead */
-      AllPlayersGone = TRUE;
-
-    if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
-      TapeStop();
-
-    /* --- game actions --- */
-
-    if (tape.pausing)
-    {
-      /* don't use 100% CPU while in pause mode -- this should better be solved
-        like in the R'n'D game engine! */
-
-      Delay(10);
-
-      return;
-    }
-
-    recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
-
-#if 1
-    /* !!! CHECK THIS (tape.pausing is always FALSE here!) !!! */
-    if (recorded_player_action == NULL && tape.pausing)
-      return;
-#endif
-
-    for (i = 0; i < MAX_PLAYERS; i++)
-    {
-      summarized_player_action |= stored_player[i].action;
-
-      if (!network_playing)
-       stored_player[i].effective_action = stored_player[i].action;
-    }
-
-    if (!options.network && !setup.team_mode)
-      local_player->effective_action = summarized_player_action;
-
-    if (recorded_player_action != NULL)
-      for (i = 0; i < MAX_PLAYERS; i++)
-       stored_player[i].effective_action = recorded_player_action[i];
-
-    for (i = 0; i < MAX_PLAYERS; i++)
-    {
-      tape_action[i] = stored_player[i].effective_action;
-
-      /* !!! (this does not happen in the EM engine) !!! */
-      if (tape.recording && tape_action[i] && !tape.player_participates[i])
-       tape.player_participates[i] = TRUE;  /* player just appeared from CE */
-    }
-
-    /* only save actions from input devices, but not programmed actions */
-    if (tape.recording)
-      TapeRecordAction(tape_action);
-
-    GameActions_EM(local_player->effective_action);
-
-    if (TimeFrames >= FRAMES_PER_SECOND)
-    {
-      TimeFrames = 0;
-      TapeTime++;
-
-      if (!level.use_step_counter)
-      {
-       TimePlayed++;
-
-       if (TimeLeft > 0)
-       {
-         TimeLeft--;
-
-         if (TimeLeft <= 10 && setup.time_limit)
-           PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE);
-
-         DrawGameValue_Time(TimeLeft);
-
-         if (!TimeLeft && setup.time_limit)
-           level.native_em_level->lev->killed_out_of_time = TRUE;
-       }
-       else if (level.time == 0 && level.native_em_level->lev->home > 0)
-         DrawGameValue_Time(TimePlayed);
-
-       level.native_em_level->lev->time =
-         (level.time == 0 ? TimePlayed : TimeLeft);
-      }
-
-      if (tape.recording || tape.playing)
-       DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
-    }
-
-    FrameCounter++;
-    TimeFrames++;
-
-    BackToFront();
-  }
-  else
-  {
-    if (game.restart_level)
-      StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
-
-    if (local_player->LevelSolved)
-      GameWon();
-
-    if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
-      TapeStop();
-
-    GameActions();
-    BackToFront();
-
-    if (tape.auto_play && !tape.playing)
-      AutoPlayTape();  /* continue automatically playing next tape */
-  }
-}
-
-void StartGameActions(boolean init_network_game, boolean record_tape,
-                     long random_seed)
-{
-  if (record_tape)
-    TapeStartRecording(random_seed);
-
-#if defined(NETWORK_AVALIABLE)
-  if (init_network_game)
-  {
-    SendToServer_StartPlaying();
-
-    return;
-  }
-#endif
-
-  StopAnimation();
-
-  game_status = GAME_MODE_PLAYING;
-
-  InitRND(random_seed);
+  GameActions();       /* main game loop */
 
-  InitGame();
+  if (tape.auto_play && !tape.playing)
+    AutoPlayTape();    /* continue automatically playing next tape */
 }
 
 /* ---------- new screen button stuff -------------------------------------- */