small move of code block
[rocksndiamonds.git] / src / tape.c
index 28bc0566655222b87b40e5bc241ba5c6b308397c..d6c538d9dfd9b6191c180742b993bb2fbed3a8e6 100644 (file)
@@ -52,6 +52,8 @@ static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
                                         VIDEO_STATE_REC_OFF    |       \
                                         VIDEO_STATE_PAUSE_OFF  |       \
                                         VIDEO_STATE_FFWD_OFF   |       \
+                                        VIDEO_STATE_WARP_OFF   |       \
+                                        VIDEO_STATE_WARP2_OFF  |       \
                                         VIDEO_STATE_PBEND_OFF  |       \
                                         VIDEO_STATE_1STEP_OFF)
 #define VIDEO_PRESS_OFF                        (VIDEO_PRESS_PLAY_OFF   |       \
@@ -70,6 +72,8 @@ static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
                                         VIDEO_STATE_REC_ON     |       \
                                         VIDEO_STATE_PAUSE_ON   |       \
                                         VIDEO_STATE_FFWD_ON    |       \
+                                        VIDEO_STATE_WARP_ON    |       \
+                                        VIDEO_STATE_WARP2_ON   |       \
                                         VIDEO_STATE_PBEND_ON   |       \
                                         VIDEO_STATE_1STEP_ON)
 #define VIDEO_PRESS_ON                 (VIDEO_PRESS_PLAY_ON    |       \
@@ -352,6 +356,36 @@ void DrawVideoDisplaySymbol(unsigned int state)
   DrawVideoDisplay(state, VIDEO_DISPLAY_SYMBOL_ONLY);
 }
 
+void DrawVideoDisplayPlayState()
+{
+  int state = 0;
+
+  DrawVideoDisplay(VIDEO_STATE_OFF, 0);
+
+  state |= VIDEO_STATE_PLAY_ON;
+
+  if (tape.pausing)
+  {
+    state |= VIDEO_STATE_PAUSE_ON;
+  }
+  else
+  {
+    if (tape.deactivate_display)
+      state |= VIDEO_STATE_WARP2_ON;
+    else if (tape.warp_forward)
+      state |= VIDEO_STATE_WARP_ON;
+    else if (tape.fast_forward)
+      state |= VIDEO_STATE_FFWD_ON;
+
+    if (tape.pause_before_end)
+      state |= VIDEO_STATE_PBEND_ON;
+  }
+
+  // draw labels and symbols separately to prevent labels overlapping symbols
+  DrawVideoDisplayLabel(state);
+  DrawVideoDisplaySymbol(state);
+}
+
 void DrawCompleteVideoDisplay()
 {
   struct GraphicInfo *g_tape = &graphic_info[IMG_BACKGROUND_TAPE];
@@ -634,26 +668,12 @@ void TapeRecordAction(byte action_raw[MAX_PLAYERS])
 
 void TapeTogglePause(boolean toggle_manual)
 {
-  int state = 0;
-
   tape.pausing = !tape.pausing;
 
   if (tape.single_step && toggle_manual)
     tape.single_step = FALSE;
 
-  state |= VIDEO_STATE_PAUSE(tape.pausing);
-
-  if (tape.pause_before_end)
-    state |= VIDEO_STATE_PBEND(!tape.pausing);
-  else if (tape.fast_forward)
-    state |= VIDEO_STATE_FFWD(!tape.pausing);
-
-  if (tape.playing)
-    state |= VIDEO_STATE_PLAY_ON;
-  else
-    state |= VIDEO_STATE_1STEP(tape.single_step);
-
-  DrawVideoDisplay(state, 0);
+  DrawVideoDisplayPlayState();
 
   if (tape.warp_forward)
   {
@@ -671,20 +691,20 @@ void TapeTogglePause(boolean toggle_manual)
     {
       DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON);
     }
+  }
 
-    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 &&
@@ -765,6 +785,16 @@ byte *TapePlayAction()
     }
   }
 
+  if (tape.counter >= tape.length)     /* end of tape reached */
+  {
+    if (tape.warp_forward && !tape.auto_play)
+      TapeTogglePause(TAPE_TOGGLE_MANUAL);
+    else
+      TapeStop();
+
+    return NULL;
+  }
+
   if (update_video_display && !tape.deactivate_display)
   {
     if (tape.pause_before_end)
@@ -776,16 +806,6 @@ byte *TapePlayAction()
       DrawVideoDisplaySymbol(VIDEO_STATE_WARP2_ON);
   }
 
-  if (tape.counter >= tape.length)     /* end of tape reached */
-  {
-    if (tape.warp_forward && !tape.auto_play)
-      TapeTogglePause(TAPE_TOGGLE_MANUAL);
-    else
-      TapeStop();
-
-    return NULL;
-  }
-
   for (i = 0; i < MAX_PLAYERS; i++)
     action[i] = tape.pos[tape.counter].action[i];