rocksndiamonds-1.2.0
[rocksndiamonds.git] / src / tape.c
index 35929e882351bde6cc66bbc662ffde6b51d4d641..2cc0b39962eba632c9606af412956264e3a64f64 100644 (file)
@@ -1,12 +1,12 @@
 /***********************************************************
 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
 *----------------------------------------------------------*
-*  ©1997 Artsoft Development                               *
-*        Holger Schemel                                    *
-*        33604 Bielefeld                                   *
-*        Telefon: (0521) 290471                            *
-*        eMail: aeglos@valinor.owl.de                      *
-*               aeglos@uni-paderborn.de                    *
+*  (c) 1995-98 Artsoft Entertainment                       *
+*              Holger Schemel                              *
+*              Oststrasse 11a                              *
+*              33604 Bielefeld                             *
+*              phone: ++49 +521 290471                     *
+*              email: aeglos@valinor.owl.de                *
 *----------------------------------------------------------*
 *  tape.c                                                  *
 ***********************************************************/
@@ -20,6 +20,7 @@ void TapeStartRecording()
 {
   time_t zeit1 = time(NULL);
   struct tm *zeit2 = localtime(&zeit1);
+  int i;
 
   if (!TAPE_IS_STOPPED(tape))
     TapeStop();
@@ -28,57 +29,67 @@ void TapeStartRecording()
   tape.length = 0;
   tape.counter = 0;
   tape.pos[tape.counter].delay = 0;
-  tape.changed = TRUE;
   tape.recording = TRUE;
   tape.playing = FALSE;
   tape.pausing = FALSE;
+  tape.changed = TRUE;
   tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
   tape.random_seed = InitRND(NEW_RANDOMIZE);
 
-  DrawVideoDisplay(VIDEO_STATE_REC_ON,0);
-  DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
-  DrawVideoDisplay(VIDEO_STATE_TIME_ON,0);
+  for(i=0; i<MAX_PLAYERS; i++)
+    tape.player_participates[i] = FALSE;
+
+  DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
+  DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
+  DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
 }
 
 void TapeStopRecording()
 {
+  int i;
+
   if (!tape.recording)
     return;
 
-  tape.pos[tape.counter].joystickdata = 0;
+  for(i=0; i<MAX_PLAYERS; i++)
+    tape.pos[tape.counter].action[i] = 0;
+
   tape.counter++;
   tape.length = tape.counter;
   tape.length_seconds = GetTapeLength();
   tape.recording = FALSE;
   tape.pausing = FALSE;
-  DrawVideoDisplay(VIDEO_STATE_REC_OFF,0);
+  DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
 }
 
-void TapeRecordAction(int joy)
+void TapeRecordAction(byte joy[MAX_PLAYERS])
 {
+  int i;
+
   if (!tape.recording || tape.pausing)
     return;
 
-  if (tape.counter>=MAX_TAPELEN-1)
+  if (tape.counter >= MAX_TAPELEN-1)
   {
     TapeStopRecording();
     return;
   }
 
-  if (joy)
-  {
-    tape.pos[tape.counter].joystickdata = joy;
-    tape.counter++;
-    tape.pos[tape.counter].delay = 0;
-  }
+  for(i=0; i<MAX_PLAYERS; i++)
+    tape.pos[tape.counter].action[i] = joy[i];
+
+  tape.counter++;
+  tape.pos[tape.counter].delay = 0;
 }
 
 void TapeRecordDelay()
 {
+  int i;
+
   if (!tape.recording || tape.pausing)
     return;
 
-  if (tape.counter>=MAX_TAPELEN)
+  if (tape.counter >= MAX_TAPELEN)
   {
     TapeStopRecording();
     return;
@@ -86,9 +97,11 @@ void TapeRecordDelay()
 
   tape.pos[tape.counter].delay++;
 
-  if (tape.pos[tape.counter].delay>=255)
+  if (tape.pos[tape.counter].delay >= 255)
   {
-    tape.pos[tape.counter].joystickdata = 0;
+    for(i=0; i<MAX_PLAYERS; i++)
+      tape.pos[tape.counter].action[i] = 0;
+
     tape.counter++;
     tape.pos[tape.counter].delay = 0;
   }
@@ -102,9 +115,10 @@ void TapeTogglePause()
   tape.pausing = !tape.pausing;
   tape.fast_forward = FALSE;
   tape.pause_before_death = FALSE;
-  DrawVideoDisplay(tape.pausing ?
-                  VIDEO_STATE_PAUSE_ON :
-                  VIDEO_STATE_PAUSE_OFF,0);
+  DrawVideoDisplay((tape.pausing ?
+                   VIDEO_STATE_PAUSE_ON :
+                   VIDEO_STATE_PAUSE_OFF) | VIDEO_STATE_PBEND_OFF,
+                  0);
 }
 
 void TapeStartPlaying()
@@ -124,9 +138,9 @@ void TapeStartPlaying()
   tape.fast_forward = FALSE;
   InitRND(tape.random_seed);
 
-  DrawVideoDisplay(VIDEO_STATE_PLAY_ON,0);
-  DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
-  DrawVideoDisplay(VIDEO_STATE_TIME_ON,0);
+  DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
+  DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
+  DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
 }
 
 void TapeStopPlaying()
@@ -136,43 +150,53 @@ void TapeStopPlaying()
 
   tape.playing = FALSE;
   tape.pausing = FALSE;
-  DrawVideoDisplay(VIDEO_STATE_PLAY_OFF,0);
+  DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
 }
 
-int TapePlayAction()
+byte *TapePlayAction()
 {
+  static byte joy[MAX_PLAYERS];
+  int i;
+
   if (!tape.playing || tape.pausing)
-    return(0);
+    return(NULL);
 
-  if (tape.counter>=tape.length)
+  if (tape.counter >= tape.length)
   {
-    TapeStopPlaying();
-    return(0);
+    TapeStop();
+    return(NULL);
   }
 
   if (tape.delay_played == tape.pos[tape.counter].delay)
   {
     tape.delay_played = 0;
     tape.counter++;
-    return(tape.pos[tape.counter-1].joystickdata);
+
+    for(i=0; i<MAX_PLAYERS; i++)
+      joy[i] = tape.pos[tape.counter-1].action[i];
   }
   else
-    return(0);
+  {
+    for(i=0; i<MAX_PLAYERS; i++)
+      joy[i] = 0;
+  }
+
+  return(joy);
 }
 
-BOOL TapePlayDelay()
+boolean TapePlayDelay()
 {
   if (!tape.playing || tape.pausing)
     return(FALSE);
 
   if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
   {
-    if (!(FrameCounter % 5))
+    if (!(FrameCounter % 20))
     {
-      if (2*(FrameCounter/10) == FrameCounter/5)
-       DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, VIDEO_DISPLAY_LABEL_ONLY);
+      if ((FrameCounter / 20) % 2)
+       DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
       else
-       DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF, VIDEO_DISPLAY_LABEL_ONLY);
+       DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
     }
 
     if (level.time-TimeLeft > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH)
@@ -182,9 +206,9 @@ BOOL TapePlayDelay()
     }
   }
 
-  if (tape.counter>=tape.length)
+  if (tape.counter >= tape.length)
   {
-    TapeStopPlaying();
+    TapeStop();
     return(TRUE);
   }
 
@@ -205,8 +229,8 @@ void TapeStop()
   DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
   if (tape.date && tape.length)
   {
-    DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
-    DrawVideoDisplay(VIDEO_STATE_TIME_ON,tape.length_seconds);
+    DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
+    DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
   }
 }
 
@@ -226,5 +250,5 @@ unsigned int GetTapeLength()
   for(i=0;i<tape.length;i++)
     tape_length += tape.pos[i].delay;
 
-  return(tape_length * GAME_FRAME_DELAY / 100);
+  return(tape_length * GAME_FRAME_DELAY / 1000);
 }