+ Request("No tape for this level!", REQ_CONFIRM);
+
+ return;
+ }
+
+ if (tape.recording && !Request("Stop recording and load tape?",
+ REQ_ASK | REQ_STAY_CLOSED))
+ {
+ OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
+
+ return;
+ }
+
+ if (game_status != GAME_MODE_PLAYING && game_status != GAME_MODE_MAIN)
+ return;
+
+ if (CheckEngineSnapshotSingle())
+ {
+ TapeStartGamePlaying();
+
+ LoadEngineSnapshotSingle();
+
+ DrawCompleteVideoDisplay();
+
+ tape.playing = TRUE;
+ tape.pausing = TRUE;
+
+ TapeStopWarpForward();
+ TapeAppendRecording();
+
+ // restart step/move snapshots after quick loading tape
+ SaveEngineSnapshotToListInitial();
+
+ if (FrameCounter > 0)
+ return;
+ }
+
+ TapeStop();
+ TapeErase();
+
+ LoadTape(level_nr);
+
+ if (!TAPE_IS_EMPTY(tape))
+ {
+ TapeStartGamePlaying();
+ TapeStartWarpForward(AUTOPLAY_MODE_WARP_NO_DISPLAY);
+
+ tape.quick_resume = TRUE;
+ }
+ else /* this should not happen (basically checked above) */
+ {
+ int reopen_door = (game_status == GAME_MODE_PLAYING ? REQ_REOPEN : 0);
+
+ Request("No tape for this level!", REQ_CONFIRM | reopen_door);
+ }
+}
+
+void InsertSolutionTape()
+{
+ boolean level_has_tape = (level.game_engine_type == GAME_ENGINE_TYPE_SP &&
+ level.native_sp_level->demo.is_available);
+
+ if (!fileExists(getSolutionTapeFilename(level_nr)) && !level_has_tape)
+ {
+ Request("No solution tape for this level!", REQ_CONFIRM);
+
+ return;
+ }
+
+ // if tape recorder already contains a tape, remove it without asking
+ TapeErase();
+
+ LoadSolutionTape(level_nr);
+
+ if (TAPE_IS_EMPTY(tape))
+ Request("Loading solution tape for this level failed!", REQ_CONFIRM);
+
+ DrawCompleteVideoDisplay();
+}
+
+
+/* ------------------------------------------------------------------------- *
+ * tape autoplay functions
+ * ------------------------------------------------------------------------- */
+
+void AutoPlayTape()
+{
+ static LevelDirTree *autoplay_leveldir = NULL;
+ static boolean autoplay_initialized = FALSE;
+ static int autoplay_level_nr = -1;
+ static int num_levels_played = 0;
+ static int num_levels_solved = 0;
+ static int num_tape_missing = 0;
+ static boolean level_failed[MAX_TAPES_PER_SET];
+ int i;
+
+ if (autoplay_initialized)
+ {
+ /* just finished auto-playing tape */
+ PrintTapeReplayProgress(TRUE);
+
+ num_levels_played++;
+
+ if (tape.auto_play_level_solved)
+ num_levels_solved++;
+ else if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
+ level_failed[level_nr] = TRUE;
+ }
+ else
+ {
+ DrawCompleteVideoDisplay();
+
+ audio.sound_enabled = FALSE;
+ setup.engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_OFF);
+
+ autoplay_leveldir = getTreeInfoFromIdentifier(leveldir_first,
+ global.autoplay_leveldir);
+
+ if (autoplay_leveldir == NULL)
+ Error(ERR_EXIT, "no such level identifier: '%s'",
+ global.autoplay_leveldir);
+
+ leveldir_current = autoplay_leveldir;
+
+ if (autoplay_leveldir->first_level < 0)
+ autoplay_leveldir->first_level = 0;
+ if (autoplay_leveldir->last_level >= MAX_TAPES_PER_SET)
+ autoplay_leveldir->last_level = MAX_TAPES_PER_SET - 1;
+
+ autoplay_level_nr = autoplay_leveldir->first_level;
+
+ PrintLine("=", 79);
+ Print("Automatically playing level tapes\n");
+ PrintLine("-", 79);
+ Print("Level series identifier: '%s'\n", autoplay_leveldir->identifier);
+ Print("Level series name: '%s'\n", autoplay_leveldir->name);
+ Print("Level series author: '%s'\n", autoplay_leveldir->author);
+ Print("Number of levels: %d\n", autoplay_leveldir->levels);
+ PrintLine("=", 79);
+ Print("\n");
+
+ for (i = 0; i < MAX_TAPES_PER_SET; i++)
+ level_failed[i] = FALSE;
+
+ autoplay_initialized = TRUE;
+ }
+
+ while (autoplay_level_nr <= autoplay_leveldir->last_level)
+ {
+ level_nr = autoplay_level_nr++;
+
+ if (!global.autoplay_all && !global.autoplay_level[level_nr])
+ continue;
+