changed tape recorder logic to separate speed and 'pause before end'
[rocksndiamonds.git] / src / tape.c
index 4bc245234c81d607ab1eb566a24dbc8902b8c7d0..ff6d10f250c8e48d6e440b0bbbb3eb9690944f9e 100644 (file)
@@ -675,36 +675,26 @@ void TapeTogglePause(boolean toggle_manual)
 
   DrawVideoDisplayPlayState();
 
-  if (tape.warp_forward)
+  if (tape.deactivate_display)
   {
     if (tape.pausing)
-    {
       TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
-    }
-    else if (tape.deactivate_display)
-    {
-      TapeDeactivateDisplayOn();
-
-      DrawVideoDisplaySymbol(VIDEO_STATE_WARP_ON);
-    }
     else
-    {
-      DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON);
-    }
+      TapeDeactivateDisplayOn();
+  }
 
-    if (tape.quick_resume)
-    {
-      tape.quick_resume = FALSE;
+  if (tape.quick_resume)
+  {
+    tape.quick_resume = FALSE;
 
-      TapeStopWarpForward();
-      TapeAppendRecording();
+    TapeStopWarpForward();
+    TapeAppendRecording();
 
-      if (!CheckEngineSnapshotSingle())
-       SaveEngineSnapshotSingle();
+    if (!CheckEngineSnapshotSingle())
+      SaveEngineSnapshotSingle();
 
-      // restart step/move snapshots after quick loading tape
-      SaveEngineSnapshotToListInitial();
-    }
+    // restart step/move snapshots after quick loading tape
+    SaveEngineSnapshotToListInitial();
   }
 
   if (setup.show_snapshot_buttons &&
@@ -775,9 +765,6 @@ byte *TapePlayAction()
   {
     if (TapeTime > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
     {
-      tape.fast_forward = FALSE;
-      tape.pause_before_end = FALSE;
-
       TapeStopWarpForward();
       TapeTogglePause(TAPE_TOGGLE_MANUAL);
 
@@ -788,22 +775,33 @@ byte *TapePlayAction()
   if (tape.counter >= tape.length)     /* end of tape reached */
   {
     if (tape.warp_forward && !tape.auto_play)
+    {
+      TapeStopWarpForward();
       TapeTogglePause(TAPE_TOGGLE_MANUAL);
+    }
     else
+    {
       TapeStop();
+    }
 
     return NULL;
   }
 
   if (update_video_display && !tape.deactivate_display)
   {
-    if (tape.pause_before_end)
-      DrawVideoDisplayLabel(VIDEO_STATE_PBEND(update_draw_label_on));
-    else if (tape.fast_forward)
-      DrawVideoDisplayLabel(VIDEO_STATE_FFWD(update_draw_label_on));
+    int state = 0;
 
     if (tape.warp_forward)
-      DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON);
+      state |= VIDEO_STATE_WARP(update_draw_label_on);
+    else if (tape.fast_forward)
+      state |= VIDEO_STATE_FFWD(update_draw_label_on);
+
+    if (tape.pause_before_end)
+      state |= VIDEO_STATE_PBEND(update_draw_label_on);
+
+    // draw labels and symbols separately to prevent labels overlapping symbols
+    DrawVideoDisplayLabel(state);
+    DrawVideoDisplaySymbol(state);
   }
 
   for (i = 0; i < MAX_PLAYERS; i++)
@@ -877,43 +875,28 @@ unsigned int GetTapeLengthSeconds()
 
 static void TapeStartWarpForward()
 {
+  tape.fast_forward = TRUE;
   tape.warp_forward = TRUE;
+  tape.deactivate_display = TRUE;
 
-  if (!tape.fast_forward && !tape.pause_before_end)
-  {
-    tape.pausing = FALSE;
-    tape.pause_before_end = TRUE;
-    tape.deactivate_display = TRUE;
+  tape.pausing = FALSE;
 
-    TapeDeactivateDisplayOn();
+  TapeDeactivateDisplayOn();
 
-    DrawVideoDisplay(VIDEO_STATE_PBEND_ON, 0);
-    DrawVideoDisplaySymbol(VIDEO_STATE_WARP_ON);
-  }
-  else
-  {
-    DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON);
-  }
+  DrawVideoDisplayPlayState();
 }
 
 static void TapeStopWarpForward()
 {
-  int state = VIDEO_STATE_PAUSE(tape.pausing);
-
-  if (tape.deactivate_display)
-    tape.pause_before_end = FALSE;
-
+  tape.fast_forward = FALSE;
   tape.warp_forward = FALSE;
   tape.deactivate_display = FALSE;
 
-  TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
+  tape.pause_before_end = FALSE;
 
-  state |= VIDEO_STATE_WARP_OFF;
-  state |= (tape.pause_before_end ? VIDEO_STATE_PBEND_ON :
-           tape.fast_forward     ? VIDEO_STATE_FFWD_ON :
-           VIDEO_STATE_PLAY_ON);
+  TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
 
-  DrawVideoDisplay(state, 0);
+  DrawVideoDisplayPlayState();
 }
 
 static void TapeSingleStep()
@@ -1323,18 +1306,9 @@ static void HandleTapeButtonsExt(int id)
     case TAPE_CTRL_ID_EXTRA:
       if (tape.playing)
       {
-       if (!tape.warp_forward)                 /* PLAY -> WARP FORWARD PLAY */
-       {
-         TapeStartWarpForward();
-       }
-       else if (tape.pausing)                  /* PAUSE -> WARP FORWARD PLAY */
-       {
-         TapeTogglePause(TAPE_TOGGLE_MANUAL);
-       }
-       else                                    /* WARP FORWARD PLAY -> PLAY */
-       {
-         TapeStopWarpForward();
-       }
+       tape.pause_before_end = !tape.pause_before_end;
+
+       DrawVideoDisplayPlayState();
       }
       else if (tape.recording)
        TapeSingleStep();
@@ -1388,36 +1362,30 @@ static void HandleTapeButtonsExt(int id)
 
          TapeTogglePause(TAPE_TOGGLE_MANUAL);
        }
-       else if (tape.warp_forward &&
-                !tape.fast_forward)            /* WARP FORWARD PLAY -> PLAY */
+       else if (!tape.fast_forward)            /* PLAY -> FFWD */
        {
-         TapeStopWarpForward();
+         tape.fast_forward = TRUE;
        }
-       else if (!tape.fast_forward)            /* PLAY -> FAST FORWARD PLAY */
+       else if (!tape.warp_forward)            /* FFWD -> WARP */
        {
-         tape.fast_forward = TRUE;
-
-         DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
+         tape.warp_forward = TRUE;
        }
-       else if (!tape.pause_before_end)        /* FFWD PLAY -> AUTO PAUSE */
+       else if (!tape.deactivate_display)      /* WARP -> WARP BLIND */
        {
-         tape.pause_before_end = TRUE;
+         tape.deactivate_display = TRUE;
 
-         DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_ON, 0);
-
-         if (tape.warp_forward)
-           DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON);
+         TapeDeactivateDisplayOn();
        }
-       else                                    /* AUTO PAUSE -> NORMAL PLAY */
+       else                                    /* WARP BLIND -> PLAY */
        {
-         if (tape.warp_forward)
-           TapeStopWarpForward();
-
          tape.fast_forward = FALSE;
-         tape.pause_before_end = FALSE;
+         tape.warp_forward = FALSE;
+         tape.deactivate_display = FALSE;
 
-         DrawVideoDisplay(VIDEO_STATE_PBEND_OFF | VIDEO_STATE_PLAY_ON, 0);
+         TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
        }
+
+       DrawVideoDisplayPlayState();
       }
       break;