fixed and extended auto-replay modes from command line
[rocksndiamonds.git] / src / tape.c
index 919bd418455f9749b5490bf4445de947b3371a05..6d90ca96e093b9a3b9c5cfd3a8edcd9a2f2ddc76 100644 (file)
@@ -672,11 +672,21 @@ void TapeRecordAction(byte action_raw[MAX_PLAYERS])
   }
 }
 
-void TapeTogglePause(boolean toggle_manual)
+void TapeTogglePause(boolean toggle_mode)
 {
+  if (tape.playing && tape.pausing && (toggle_mode & TAPE_TOGGLE_PLAY_PAUSE))
+  {
+    // continue playing in normal mode
+    tape.fast_forward = FALSE;
+    tape.warp_forward = FALSE;
+    tape.deactivate_display = FALSE;
+
+    tape.pause_before_end = FALSE;
+  }
+
   tape.pausing = !tape.pausing;
 
-  if (tape.single_step && toggle_manual)
+  if (tape.single_step && (toggle_mode & TAPE_TOGGLE_MANUAL))
     tape.single_step = FALSE;
 
   DrawVideoDisplayCurrentState();
@@ -879,15 +889,16 @@ unsigned int GetTapeLengthSeconds()
   return (GetTapeLengthFrames() * GAME_FRAME_DELAY / 1000);
 }
 
-static void TapeStartWarpForward()
+static void TapeStartWarpForward(int mode)
 {
-  tape.fast_forward = TRUE;
-  tape.warp_forward = TRUE;
-  tape.deactivate_display = TRUE;
+  tape.fast_forward = (mode & AUTOPLAY_FFWD);
+  tape.warp_forward = (mode & AUTOPLAY_WARP);
+  tape.deactivate_display = (mode & AUTOPLAY_WARP_NO_DISPLAY);
 
   tape.pausing = FALSE;
 
-  TapeDeactivateDisplayOn();
+  if (tape.deactivate_display)
+    TapeDeactivateDisplayOn();
 
   DrawVideoDisplayCurrentState();
 }
@@ -995,7 +1006,7 @@ void TapeQuickLoad()
   if (!TAPE_IS_EMPTY(tape))
   {
     TapeStartGamePlaying();
-    TapeStartWarpForward();
+    TapeStartWarpForward(AUTOPLAY_MODE_WARP_NO_DISPLAY);
 
     tape.quick_resume = TRUE;
   }
@@ -1125,12 +1136,7 @@ void AutoPlayTape()
     printf("playing tape ... ");
 
     TapeStartGamePlaying();
-
-    if (global.autoplay_mode == AUTOPLAY_FFWD)
-      tape.fast_forward = TRUE;
-
-    if (global.autoplay_mode != AUTOPLAY_PLAY)
-      TapeStartWarpForward();
+    TapeStartWarpForward(global.autoplay_mode);
 
     return;
   }
@@ -1367,14 +1373,7 @@ static void HandleTapeButtonsExt(int id)
       {
        if (tape.pausing)                       /* PAUSE -> PLAY */
        {
-         // continue playing in normal mode
-         tape.fast_forward = FALSE;
-         tape.warp_forward = FALSE;
-         tape.deactivate_display = FALSE;
-
-         tape.pause_before_end = FALSE;
-
-         TapeTogglePause(TAPE_TOGGLE_MANUAL);
+         TapeTogglePause(TAPE_TOGGLE_MANUAL | TAPE_TOGGLE_PLAY_PAUSE);
        }
        else if (!tape.fast_forward)            /* PLAY -> FFWD */
        {