1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
19 void TapeStartRecording()
21 time_t zeit1 = time(NULL);
22 struct tm *zeit2 = localtime(&zeit1);
25 if (!TAPE_IS_STOPPED(tape))
28 tape.level_nr = level_nr;
31 tape.pos[tape.counter].delay = 0;
32 tape.recording = TRUE;
36 tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
37 tape.random_seed = InitRND(NEW_RANDOMIZE);
39 for(i=0; i<MAX_PLAYERS; i++)
40 tape.player_participates[i] = FALSE;
42 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
43 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
44 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
47 void TapeStopRecording()
54 for(i=0; i<MAX_PLAYERS; i++)
55 tape.pos[tape.counter].action[i] = 0;
58 tape.length = tape.counter;
59 tape.length_seconds = GetTapeLength();
60 tape.recording = FALSE;
62 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
65 void TapeRecordAction(byte joy[MAX_PLAYERS])
69 if (!tape.recording || tape.pausing)
72 if (tape.counter >= MAX_TAPELEN-1)
78 for(i=0; i<MAX_PLAYERS; i++)
79 tape.pos[tape.counter].action[i] = joy[i];
82 tape.pos[tape.counter].delay = 0;
85 void TapeRecordDelay()
89 if (!tape.recording || tape.pausing)
92 if (tape.counter >= MAX_TAPELEN)
98 tape.pos[tape.counter].delay++;
100 if (tape.pos[tape.counter].delay >= 255)
102 for(i=0; i<MAX_PLAYERS; i++)
103 tape.pos[tape.counter].action[i] = 0;
106 tape.pos[tape.counter].delay = 0;
110 void TapeTogglePause()
112 if (!tape.recording && !tape.playing)
115 tape.pausing = !tape.pausing;
116 tape.fast_forward = FALSE;
117 tape.pause_before_death = FALSE;
118 DrawVideoDisplay((tape.pausing ?
119 VIDEO_STATE_PAUSE_ON :
120 VIDEO_STATE_PAUSE_OFF) | VIDEO_STATE_PBEND_OFF,
124 void TapeStartPlaying()
126 if (TAPE_IS_EMPTY(tape))
129 if (!TAPE_IS_STOPPED(tape))
133 tape.delay_played = 0;
134 tape.pause_before_death = FALSE;
135 tape.recording = FALSE;
137 tape.pausing = FALSE;
138 tape.fast_forward = FALSE;
139 InitRND(tape.random_seed);
141 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
142 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
143 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
146 void TapeStopPlaying()
151 tape.playing = FALSE;
152 tape.pausing = FALSE;
153 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
156 byte *TapePlayAction()
158 static byte joy[MAX_PLAYERS];
161 if (!tape.playing || tape.pausing)
164 if (tape.counter >= tape.length)
170 if (tape.delay_played == tape.pos[tape.counter].delay)
172 tape.delay_played = 0;
175 for(i=0; i<MAX_PLAYERS; i++)
176 joy[i] = tape.pos[tape.counter-1].action[i];
180 for(i=0; i<MAX_PLAYERS; i++)
187 boolean TapePlayDelay()
189 if (!tape.playing || tape.pausing)
192 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
194 if (!(FrameCounter % 20))
196 if ((FrameCounter / 20) % 2)
197 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
199 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
202 if (level.time-TimeLeft > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH)
209 if (tape.counter >= tape.length)
215 if (tape.delay_played < tape.pos[tape.counter].delay)
229 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
230 if (tape.date && tape.length)
232 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
233 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
242 unsigned int GetTapeLength()
244 unsigned int tape_length = 0;
247 if (TAPE_IS_EMPTY(tape))
250 for(i=0;i<tape.length;i++)
251 tape_length += tape.pos[i].delay;
253 return(tape_length * GAME_FRAME_DELAY / 1000);