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()
114 if (!tape.recording && !tape.playing)
117 tape.pausing = !tape.pausing;
118 tape.fast_forward = FALSE;
119 tape.pause_before_death = FALSE;
121 state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
123 state |= VIDEO_STATE_PBEND_OFF;
125 DrawVideoDisplay(state, 0);
128 void TapeStartPlaying()
130 if (TAPE_IS_EMPTY(tape))
133 if (!TAPE_IS_STOPPED(tape))
137 tape.delay_played = 0;
138 tape.pause_before_death = FALSE;
139 tape.recording = FALSE;
141 tape.pausing = FALSE;
142 tape.fast_forward = FALSE;
143 InitRND(tape.random_seed);
145 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
146 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
147 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
150 void TapeStopPlaying()
155 tape.playing = FALSE;
156 tape.pausing = FALSE;
157 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
160 byte *TapePlayAction()
162 static byte joy[MAX_PLAYERS];
165 if (!tape.playing || tape.pausing)
168 if (tape.counter >= tape.length)
174 if (tape.delay_played == tape.pos[tape.counter].delay)
176 tape.delay_played = 0;
179 for(i=0; i<MAX_PLAYERS; i++)
180 joy[i] = tape.pos[tape.counter-1].action[i];
184 for(i=0; i<MAX_PLAYERS; i++)
191 boolean TapePlayDelay()
193 if (!tape.playing || tape.pausing)
196 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
198 if (!(FrameCounter % 20))
200 if ((FrameCounter / 20) % 2)
201 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
203 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
206 if (TimePlayed > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH)
213 if (tape.counter >= tape.length)
219 if (tape.delay_played < tape.pos[tape.counter].delay)
233 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
234 if (tape.date && tape.length)
236 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
237 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
246 unsigned int GetTapeLength()
248 unsigned int tape_length = 0;
251 if (TAPE_IS_EMPTY(tape))
254 for(i=0;i<tape.length;i++)
255 tape_length += tape.pos[i].delay;
257 return(tape_length * GAME_FRAME_DELAY / 1000);