fixed and extended auto-replay modes from command line
[rocksndiamonds.git] / src / tape.c
index 963ca1e89a6253b7a8f6d25fc9c264612395554c..6d90ca96e093b9a3b9c5cfd3a8edcd9a2f2ddc76 100644 (file)
@@ -356,20 +356,26 @@ void DrawVideoDisplaySymbol(unsigned int state)
   DrawVideoDisplay(state, VIDEO_DISPLAY_SYMBOL_ONLY);
 }
 
-void DrawVideoDisplayPlayState()
+void DrawVideoDisplayCurrentState()
 {
   int state = 0;
 
   DrawVideoDisplay(VIDEO_STATE_OFF, 0);
 
-  state |= VIDEO_STATE_PLAY_ON;
-
   if (tape.pausing)
-  {
     state |= VIDEO_STATE_PAUSE_ON;
+
+  if (tape.recording)
+  {
+    state |= VIDEO_STATE_REC_ON;
+
+    if (tape.single_step)
+      state |= VIDEO_STATE_1STEP_ON;
   }
-  else
+  else if (tape.playing)
   {
+    state |= VIDEO_STATE_PLAY_ON;
+
     if (tape.deactivate_display)
       state |= VIDEO_STATE_WARP2_ON;
     else if (tape.warp_forward)
@@ -666,14 +672,24 @@ 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;
 
-  DrawVideoDisplayPlayState();
+  DrawVideoDisplayCurrentState();
 
   if (tape.deactivate_display)
   {
@@ -873,17 +889,18 @@ 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();
 
-  DrawVideoDisplayPlayState();
+  DrawVideoDisplayCurrentState();
 }
 
 static void TapeStopWarpForward()
@@ -896,7 +913,7 @@ static void TapeStopWarpForward()
 
   TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
 
-  DrawVideoDisplayPlayState();
+  DrawVideoDisplayCurrentState();
 }
 
 static void TapeSingleStep()
@@ -989,7 +1006,7 @@ void TapeQuickLoad()
   if (!TAPE_IS_EMPTY(tape))
   {
     TapeStartGamePlaying();
-    TapeStartWarpForward();
+    TapeStartWarpForward(AUTOPLAY_MODE_WARP_NO_DISPLAY);
 
     tape.quick_resume = TRUE;
   }
@@ -1119,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;
   }
@@ -1308,7 +1320,7 @@ static void HandleTapeButtonsExt(int id)
       {
        tape.pause_before_end = !tape.pause_before_end;
 
-       DrawVideoDisplayPlayState();
+       DrawVideoDisplayCurrentState();
       }
       else if (tape.recording)
       {
@@ -1361,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 */
        {
@@ -1393,7 +1398,7 @@ static void HandleTapeButtonsExt(int id)
          TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
        }
 
-       DrawVideoDisplayPlayState();
+       DrawVideoDisplayCurrentState();
       }
 
       break;