1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1997 Artsoft Development *
7 * Telefon: (0521) 290471 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.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()
48 tape.pos[tape.counter].joystickdata = 0;
50 tape.length = tape.counter;
51 tape.length_seconds = GetTapeLength();
52 tape.recording = FALSE;
54 DrawVideoDisplay(VIDEO_STATE_REC_OFF,0);
57 void TapeRecordAction(int joy)
59 if (!tape.recording || tape.pausing)
62 if (tape.counter>=MAX_TAPELEN-1)
70 tape.pos[tape.counter].joystickdata = joy;
72 tape.pos[tape.counter].delay = 0;
76 void TapeRecordDelay()
78 if (!tape.recording || tape.pausing)
81 if (tape.counter>=MAX_TAPELEN)
87 tape.pos[tape.counter].delay++;
89 if (tape.pos[tape.counter].delay>=255)
91 tape.pos[tape.counter].joystickdata = 0;
93 tape.pos[tape.counter].delay = 0;
97 void TapeTogglePause()
99 if (!tape.recording && !tape.playing)
102 tape.pausing = !tape.pausing;
103 tape.fast_forward = FALSE;
104 tape.pause_before_death = FALSE;
105 DrawVideoDisplay(tape.pausing ?
106 VIDEO_STATE_PAUSE_ON :
107 VIDEO_STATE_PAUSE_OFF,0);
110 void TapeStartPlaying()
112 if (TAPE_IS_EMPTY(tape))
115 if (!TAPE_IS_STOPPED(tape))
119 tape.delay_played = 0;
120 tape.pause_before_death = FALSE;
121 tape.recording = FALSE;
123 tape.pausing = FALSE;
124 tape.fast_forward = FALSE;
125 InitRND(tape.random_seed);
127 DrawVideoDisplay(VIDEO_STATE_PLAY_ON,0);
128 DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
129 DrawVideoDisplay(VIDEO_STATE_TIME_ON,0);
132 void TapeStopPlaying()
137 tape.playing = FALSE;
138 tape.pausing = FALSE;
139 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF,0);
144 if (!tape.playing || tape.pausing)
147 if (tape.counter>=tape.length)
153 if (tape.delay_played == tape.pos[tape.counter].delay)
155 tape.delay_played = 0;
157 return(tape.pos[tape.counter-1].joystickdata);
165 if (!tape.playing || tape.pausing)
168 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
170 if (!(FrameCounter % 5))
172 if (2*(FrameCounter/10) == FrameCounter/5)
173 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, VIDEO_DISPLAY_LABEL_ONLY);
175 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF, VIDEO_DISPLAY_LABEL_ONLY);
178 if (level.time-TimeLeft > tape.length_seconds - PAUSE_SECONDS_BEFORE_DEATH)
185 if (tape.counter>=tape.length)
191 if (tape.delay_played < tape.pos[tape.counter].delay)
205 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
206 if (tape.date && tape.length)
208 DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
209 DrawVideoDisplay(VIDEO_STATE_TIME_ON,tape.length_seconds);
218 unsigned int GetTapeLength()
220 unsigned int tape_length = 0;
223 if (TAPE_IS_EMPTY(tape))
226 for(i=0;i<tape.length;i++)
227 tape_length += tape.pos[i].delay;
229 return(tape_length * GAME_FRAME_DELAY / 100);