1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2001 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
23 /* tape button identifiers */
24 #define TAPE_CTRL_ID_EJECT 0
25 #define TAPE_CTRL_ID_INDEX 1
26 #define TAPE_CTRL_ID_STOP 2
27 #define TAPE_CTRL_ID_PAUSE 3
28 #define TAPE_CTRL_ID_RECORD 4
29 #define TAPE_CTRL_ID_PLAY 5
31 #define NUM_TAPE_BUTTONS 6
33 /* forward declaration for internal use */
34 static void HandleTapeButtons(struct GadgetInfo *);
36 static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
39 /* ========================================================================= */
40 /* video tape definitions */
41 /* ========================================================================= */
43 /* some positions in the video tape control window */
44 #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS)
45 #define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS)
46 #define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
47 #define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
48 #define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS + 1)
49 #define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS + 14)
50 #define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE)
51 #define VIDEO_DATE_YSIZE 16
52 #define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
53 #define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
54 #define VIDEO_REC_LABEL_XSIZE 20
55 #define VIDEO_REC_LABEL_YSIZE 12
56 #define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 20)
57 #define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
58 #define VIDEO_REC_SYMBOL_XSIZE 16
59 #define VIDEO_REC_SYMBOL_YSIZE 16
60 #define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS + 65)
61 #define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
62 #define VIDEO_PLAY_LABEL_XSIZE 22
63 #define VIDEO_PLAY_LABEL_YSIZE 12
64 #define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 52)
65 #define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
66 #define VIDEO_PLAY_SYMBOL_XSIZE 11
67 #define VIDEO_PLAY_SYMBOL_YSIZE 13
68 #define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
69 #define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS + 20)
70 #define VIDEO_PAUSE_LABEL_XSIZE 35
71 #define VIDEO_PAUSE_LABEL_YSIZE 8
72 #define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 35)
73 #define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
74 #define VIDEO_PAUSE_SYMBOL_XSIZE 17
75 #define VIDEO_PAUSE_SYMBOL_YSIZE 13
76 #define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS + 38)
77 #define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS + 14)
78 #define VIDEO_TIME_XSIZE 50
79 #define VIDEO_TIME_YSIZE 16
82 #define VIDEO_PBEND_LABEL_XPOS 5
83 #define VIDEO_PBEND_LABEL_YPOS 220
84 #define VIDEO_PBEND_LABEL_XSIZE 35
85 #define VIDEO_PBEND_LABEL_YSIZE 30
87 #define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \
88 VIDEO_STATE_REC_OFF | \
89 VIDEO_STATE_PAUSE_OFF | \
90 VIDEO_STATE_FFWD_OFF | \
91 VIDEO_STATE_PBEND_OFF | \
92 VIDEO_STATE_DATE_OFF | \
94 #define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \
95 VIDEO_PRESS_REC_OFF | \
96 VIDEO_PRESS_PAUSE_OFF | \
97 VIDEO_PRESS_STOP_OFF | \
98 VIDEO_PRESS_EJECT_OFF)
99 #define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
101 #define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \
102 VIDEO_STATE_REC_ON | \
103 VIDEO_STATE_PAUSE_ON | \
104 VIDEO_STATE_FFWD_ON | \
105 VIDEO_STATE_PBEND_ON | \
106 VIDEO_STATE_DATE_ON | \
108 #define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \
109 VIDEO_PRESS_REC_ON | \
110 VIDEO_PRESS_PAUSE_ON | \
111 VIDEO_PRESS_STOP_ON | \
112 VIDEO_PRESS_EJECT_ON)
113 #define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON)
115 #define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF)
116 #define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
117 #define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF)
120 /* ========================================================================= */
121 /* video display functions */
122 /* ========================================================================= */
124 void DrawVideoDisplay(unsigned long state, unsigned long value)
127 int part_label = 0, part_symbol = 1;
128 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
129 static char *monatsname[12] =
131 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
132 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
134 static int video_pos[5][2][4] =
136 {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
137 VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
138 { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
139 VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
141 {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
142 VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
143 { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
144 VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
146 {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
147 VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
148 { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
149 VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
151 {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
152 VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
153 { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
154 VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
158 { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
159 VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }}
162 if (state & VIDEO_STATE_PBEND_OFF)
164 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
166 BlitBitmap(pix[PIX_DOOR], drawto,
167 cx + VIDEO_REC_LABEL_XPOS,
168 cy + VIDEO_REC_LABEL_YPOS,
169 VIDEO_PBEND_LABEL_XSIZE,
170 VIDEO_PBEND_LABEL_YSIZE,
171 VX + VIDEO_REC_LABEL_XPOS,
172 VY + VIDEO_REC_LABEL_YPOS);
179 int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
181 if (i%2) /* i ungerade => STATE_ON / PRESS_OFF */
182 cx = DOOR_GFX_PAGEX4;
184 cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */
186 if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
187 BlitBitmap(pix[PIX_DOOR], drawto,
188 cx + video_pos[pos][part_label][xpos],
189 cy + video_pos[pos][part_label][ypos],
190 video_pos[pos][part_label][xsize],
191 video_pos[pos][part_label][ysize],
192 VX + video_pos[pos][part_label][xpos],
193 VY + video_pos[pos][part_label][ypos]);
194 if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
195 BlitBitmap(pix[PIX_DOOR], drawto,
196 cx + video_pos[pos][part_symbol][xpos],
197 cy + video_pos[pos][part_symbol][ypos],
198 video_pos[pos][part_symbol][xsize],
199 video_pos[pos][part_symbol][ysize],
200 VX + video_pos[pos][part_symbol][xpos],
201 VY + video_pos[pos][part_symbol][ypos]);
205 if (state & VIDEO_STATE_FFWD_ON)
207 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
209 BlitBitmap(pix[PIX_DOOR], drawto,
210 cx + VIDEO_PLAY_SYMBOL_XPOS,
211 cy + VIDEO_PLAY_SYMBOL_YPOS,
212 VIDEO_PLAY_SYMBOL_XSIZE - 2,
213 VIDEO_PLAY_SYMBOL_YSIZE,
214 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
215 VY + VIDEO_PLAY_SYMBOL_YPOS);
218 if (state & VIDEO_STATE_PBEND_ON)
220 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
222 BlitBitmap(pix[PIX_DOOR], drawto,
223 cx + VIDEO_PBEND_LABEL_XPOS,
224 cy + VIDEO_PBEND_LABEL_YPOS,
225 VIDEO_PBEND_LABEL_XSIZE,
226 VIDEO_PBEND_LABEL_YSIZE,
227 VX + VIDEO_REC_LABEL_XPOS,
228 VY + VIDEO_REC_LABEL_YPOS);
231 if (state & VIDEO_STATE_DATE_ON)
233 int tag = value % 100;
234 int monat = (value/100) % 100;
235 int jahr = (value/10000);
237 DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
238 int2str(tag,2),FS_SMALL,FC_SPECIAL1);
239 DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
240 monatsname[monat],FS_SMALL,FC_SPECIAL1);
241 DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
242 int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
245 if (state & VIDEO_STATE_TIME_ON)
247 int min = value / 60;
248 int sec = value % 60;
250 DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
251 int2str(min,2),FS_SMALL,FC_SPECIAL1);
252 DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
253 int2str(sec,2),FS_SMALL,FC_SPECIAL1);
256 if (state & VIDEO_STATE_DATE)
257 redraw_mask |= REDRAW_VIDEO_1;
258 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
259 redraw_mask |= REDRAW_VIDEO_2;
260 if (state & VIDEO_PRESS)
261 redraw_mask |= REDRAW_VIDEO_3;
264 void DrawCompleteVideoDisplay()
266 BlitBitmap(pix[PIX_DOOR], drawto, DOOR_GFX_PAGEX3, DOOR_GFX_PAGEY2,
267 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
268 BlitBitmap(pix[PIX_DOOR], drawto,
269 DOOR_GFX_PAGEX4 + VIDEO_CONTROL_XPOS,
270 DOOR_GFX_PAGEY2 + VIDEO_CONTROL_YPOS,
271 VIDEO_CONTROL_XSIZE, VIDEO_CONTROL_YSIZE,
272 gfx.vx + VIDEO_CONTROL_XPOS, gfx.vy + VIDEO_CONTROL_YPOS);
274 DrawVideoDisplay(VIDEO_ALL_OFF, 0);
275 if (tape.date && tape.length)
277 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
278 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
281 BlitBitmap(drawto, pix[PIX_DB_DOOR], gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
282 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
286 /* ========================================================================= */
287 /* tape control functions */
288 /* ========================================================================= */
290 void TapeStartRecording()
292 time_t zeit1 = time(NULL);
293 struct tm *zeit2 = localtime(&zeit1);
296 if (!TAPE_IS_STOPPED(tape))
299 tape.level_nr = level_nr;
302 tape.pos[tape.counter].delay = 0;
303 tape.recording = TRUE;
304 tape.playing = FALSE;
305 tape.pausing = FALSE;
307 tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
308 tape.random_seed = InitRND(NEW_RANDOMIZE);
309 tape.game_version = GAME_VERSION_ACTUAL;
311 for(i=0; i<MAX_PLAYERS; i++)
312 tape.player_participates[i] = FALSE;
314 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
315 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
316 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
317 MapTapeIndexButton();
320 void TapeStopRecording()
326 tape.length = tape.counter;
327 tape.length_seconds = GetTapeLength();
328 tape.recording = FALSE;
329 tape.pausing = FALSE;
331 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
332 MapTapeEjectButton();
335 void TapeRecordAction(byte action[MAX_PLAYERS])
339 if (!tape.recording || tape.pausing)
342 if (tape.counter >= MAX_TAPELEN-1)
348 if (tape.pos[tape.counter].delay > 0) /* already stored action */
350 boolean changed_events = FALSE;
352 for(i=0; i<MAX_PLAYERS; i++)
353 if (tape.pos[tape.counter].action[i] != action[i])
354 changed_events = TRUE;
356 if (changed_events || tape.pos[tape.counter].delay >= 255)
359 tape.pos[tape.counter].delay = 0;
362 tape.pos[tape.counter].delay++;
365 if (tape.pos[tape.counter].delay == 0) /* store new action */
367 for(i=0; i<MAX_PLAYERS; i++)
368 tape.pos[tape.counter].action[i] = action[i];
370 tape.pos[tape.counter].delay++;
374 void TapeTogglePause()
378 if (!tape.recording && !tape.playing)
381 tape.pausing = !tape.pausing;
382 tape.fast_forward = FALSE;
383 tape.pause_before_death = FALSE;
385 state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
387 state |= VIDEO_STATE_PBEND_OFF;
389 DrawVideoDisplay(state, 0);
391 if (tape.index_search)
393 SetDrawDeactivationMask(REDRAW_NONE);
394 RedrawPlayfield(TRUE, 0,0,0,0);
398 void TapeStartPlaying()
400 if (TAPE_IS_EMPTY(tape))
403 if (!TAPE_IS_STOPPED(tape))
407 tape.delay_played = 0;
408 tape.pause_before_death = FALSE;
409 tape.recording = FALSE;
411 tape.pausing = FALSE;
412 tape.fast_forward = FALSE;
413 tape.index_search = FALSE;
415 InitRND(tape.random_seed);
417 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
418 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
419 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
420 MapTapeIndexButton();
423 void TapeStopPlaying()
428 tape.playing = FALSE;
429 tape.pausing = FALSE;
431 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
432 MapTapeEjectButton();
435 byte *TapePlayAction()
437 static byte action[MAX_PLAYERS];
440 if (!tape.playing || tape.pausing)
443 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
445 if (!(FrameCounter % 20))
447 if ((FrameCounter / 20) % 2)
448 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
450 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
453 if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
460 if (tape.index_search)
462 if (tape.counter >= tape.length)
464 tape.index_search = FALSE;
466 SetDrawDeactivationMask(REDRAW_NONE);
467 RedrawPlayfield(TRUE, 0,0,0,0);
474 if (tape.counter >= tape.length)
480 for(i=0; i<MAX_PLAYERS; i++)
481 action[i] = tape.pos[tape.counter].action[i];
484 if (tape.delay_played >= tape.pos[tape.counter].delay)
487 tape.delay_played = 0;
498 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
499 if (tape.date && tape.length)
501 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
502 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
511 unsigned int GetTapeLength()
513 unsigned int tape_length = 0;
516 if (TAPE_IS_EMPTY(tape))
519 for(i=0;i<tape.length;i++)
520 tape_length += tape.pos[i].delay;
522 return(tape_length * GAME_FRAME_DELAY / 1000);
525 /* ---------- new tape button stuff ---------------------------------------- */
527 /* graphic position values for tape buttons */
528 #define TAPE_BUTTON_XSIZE 18
529 #define TAPE_BUTTON_YSIZE 18
530 #define TAPE_BUTTON_XPOS 5
531 #define TAPE_BUTTON_YPOS 77
533 #define TAPE_BUTTON_EJECT_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
534 #define TAPE_BUTTON_INDEX_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
535 #define TAPE_BUTTON_STOP_XPOS (TAPE_BUTTON_XPOS + 1 * TAPE_BUTTON_XSIZE)
536 #define TAPE_BUTTON_PAUSE_XPOS (TAPE_BUTTON_XPOS + 2 * TAPE_BUTTON_XSIZE)
537 #define TAPE_BUTTON_RECORD_XPOS (TAPE_BUTTON_XPOS + 3 * TAPE_BUTTON_XSIZE)
538 #define TAPE_BUTTON_PLAY_XPOS (TAPE_BUTTON_XPOS + 4 * TAPE_BUTTON_XSIZE)
545 } tapebutton_info[NUM_TAPE_BUTTONS] =
548 TAPE_BUTTON_EJECT_XPOS, TAPE_BUTTON_YPOS,
553 TAPE_BUTTON_INDEX_XPOS, TAPE_BUTTON_YPOS,
558 TAPE_BUTTON_STOP_XPOS, TAPE_BUTTON_YPOS,
563 TAPE_BUTTON_PAUSE_XPOS, TAPE_BUTTON_YPOS,
568 TAPE_BUTTON_RECORD_XPOS, TAPE_BUTTON_YPOS,
573 TAPE_BUTTON_PLAY_XPOS, TAPE_BUTTON_YPOS,
579 void CreateTapeButtons()
583 for (i=0; i<NUM_TAPE_BUTTONS; i++)
585 Bitmap *gd_bitmap = pix[PIX_DOOR];
586 struct GadgetInfo *gi;
587 int gd_xoffset, gd_yoffset;
588 int gd_x1, gd_x2, gd_y;
591 gd_xoffset = tapebutton_info[i].x;
592 gd_yoffset = tapebutton_info[i].y;
593 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
594 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
595 gd_y = DOOR_GFX_PAGEY2 + gd_yoffset;
597 if (i == TAPE_CTRL_ID_INDEX)
599 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
600 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
603 gi = CreateGadget(GDI_CUSTOM_ID, id,
604 GDI_INFO_TEXT, tapebutton_info[i].infotext,
605 GDI_X, VX + gd_xoffset,
606 GDI_Y, VY + gd_yoffset,
607 GDI_WIDTH, TAPE_BUTTON_XSIZE,
608 GDI_HEIGHT, TAPE_BUTTON_YSIZE,
609 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
610 GDI_STATE, GD_BUTTON_UNPRESSED,
611 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
612 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
613 GDI_EVENT_MASK, GD_EVENT_RELEASED,
614 GDI_CALLBACK_ACTION, HandleTapeButtons,
618 Error(ERR_EXIT, "cannot create gadget");
620 tape_gadget[id] = gi;
624 void MapTapeEjectButton()
626 UnmapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
627 MapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
630 void MapTapeIndexButton()
632 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
633 MapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
636 void MapTapeButtons()
640 for (i=0; i<NUM_TAPE_BUTTONS; i++)
641 if (i != TAPE_CTRL_ID_INDEX)
642 MapGadget(tape_gadget[i]);
644 if (tape.recording || tape.playing)
645 MapTapeIndexButton();
648 void UnmapTapeButtons()
652 for (i=0; i<NUM_TAPE_BUTTONS; i++)
653 UnmapGadget(tape_gadget[i]);
656 static void HandleTapeButtons(struct GadgetInfo *gi)
658 int id = gi->custom_id;
660 if (game_status != MAINMENU && game_status != PLAYING)
665 case TAPE_CTRL_ID_EJECT:
667 if (TAPE_IS_EMPTY(tape))
670 if (TAPE_IS_EMPTY(tape))
671 Request("No tape for this level !", REQ_CONFIRM);
676 SaveTape(tape.level_nr);
679 DrawCompleteVideoDisplay();
682 case TAPE_CTRL_ID_INDEX:
684 printf("Setting index mark ...\n");
685 else if (tape.playing)
687 printf("Going to index mark ...\n");
689 tape.index_search = TRUE;
690 SetDrawDeactivationMask(REDRAW_FIELD);
694 case TAPE_CTRL_ID_STOP:
698 case TAPE_CTRL_ID_PAUSE:
702 case TAPE_CTRL_ID_RECORD:
703 if (TAPE_IS_STOPPED(tape))
705 TapeStartRecording();
707 #if defined(PLATFORM_UNIX)
709 SendToServer_StartPlaying();
713 game_status = PLAYING;
718 else if (tape.pausing)
720 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
722 tape.pos[tape.counter].delay = tape.delay_played;
723 tape.playing = FALSE;
724 tape.recording = TRUE;
726 tape.game_version = GAME_VERSION_ACTUAL;
728 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
735 case TAPE_CTRL_ID_PLAY:
736 if (TAPE_IS_EMPTY(tape))
739 if (TAPE_IS_STOPPED(tape))
743 game_status = PLAYING;
747 else if (tape.playing)
749 if (tape.pausing) /* PAUSE -> PLAY */
751 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
753 tape.fast_forward = TRUE;
754 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
756 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
758 tape.pause_before_death = TRUE;
759 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
761 else /* -> NORMAL PLAY */
763 tape.fast_forward = FALSE;
764 tape.pause_before_death = FALSE;
765 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);