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);
24 if (!TAPE_IS_STOPPED(tape))
27 tape.level_nr = level_nr;
30 tape.pos[tape.counter].delay = 0;
31 tape.recording = TRUE;
35 tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
36 tape.random_seed = InitRND(NEW_RANDOMIZE);
38 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
39 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
40 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
43 void TapeStopRecording()
50 for(i=0; i<MAX_PLAYERS; i++)
51 tape.pos[tape.counter].action[i] = 0;
54 tape.length = tape.counter;
55 tape.length_seconds = GetTapeLength();
56 tape.recording = FALSE;
58 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
61 void TapeRecordAction(byte joy[MAX_PLAYERS])
65 if (!tape.recording || tape.pausing)
68 if (tape.counter >= MAX_TAPELEN-1)
74 for(i=0; i<MAX_PLAYERS; i++)
75 tape.pos[tape.counter].action[i] = joy[i];
78 tape.pos[tape.counter].delay = 0;
81 void TapeRecordDelay()
85 if (!tape.recording || tape.pausing)
88 if (tape.counter >= MAX_TAPELEN)
94 tape.pos[tape.counter].delay++;
96 if (tape.pos[tape.counter].delay >= 255)
98 for(i=0; i<MAX_PLAYERS; i++)
99 tape.pos[tape.counter].action[i] = 0;
102 tape.pos[tape.counter].delay = 0;
106 void TapeTogglePause()
108 if (!tape.recording && !tape.playing)
111 tape.pausing = !tape.pausing;
112 tape.fast_forward = FALSE;
113 tape.pause_before_death = FALSE;
114 DrawVideoDisplay((tape.pausing ?
115 VIDEO_STATE_PAUSE_ON :
116 VIDEO_STATE_PAUSE_OFF),
120 void TapeStartPlaying()
122 if (TAPE_IS_EMPTY(tape))
125 if (!TAPE_IS_STOPPED(tape))
129 tape.delay_played = 0;
130 tape.pause_before_death = FALSE;
131 tape.recording = FALSE;
133 tape.pausing = FALSE;
134 tape.fast_forward = FALSE;
135 InitRND(tape.random_seed);
137 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
138 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
139 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
142 void TapeStopPlaying()
147 tape.playing = FALSE;
148 tape.pausing = FALSE;
149 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
152 byte *TapePlayAction()
154 static byte joy[MAX_PLAYERS];
157 if (!tape.playing || tape.pausing)
160 if (tape.counter >= tape.length)
166 if (tape.delay_played == tape.pos[tape.counter].delay)
168 tape.delay_played = 0;
171 for(i=0; i<MAX_PLAYERS; i++)
172 joy[i] = tape.pos[tape.counter-1].action[i];
180 boolean TapePlayDelay()
182 if (!tape.playing || tape.pausing)
185 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
187 if (!(FrameCounter % 5))
189 if (2*(FrameCounter/10) == FrameCounter/5)
190 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, VIDEO_DISPLAY_LABEL_ONLY);
192 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF, VIDEO_DISPLAY_LABEL_ONLY);
195 if (level.time-TimeLeft > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH)
202 if (tape.counter >= tape.length)
208 if (tape.delay_played < tape.pos[tape.counter].delay)
222 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
223 if (tape.date && tape.length)
225 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
226 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
235 unsigned int GetTapeLength()
237 unsigned int tape_length = 0;
240 if (TAPE_IS_EMPTY(tape))
243 for(i=0;i<tape.length;i++)
244 tape_length += tape.pos[i].delay;
246 return(tape_length * GAME_FRAME_DELAY / 1000);