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 /* values for tape handling */
34 #define TAPE_PAUSE_SECONDS_BEFORE_DEATH 5
36 /* forward declaration for internal use */
37 static void HandleTapeButtons(struct GadgetInfo *);
39 static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
42 /* ========================================================================= */
43 /* video tape definitions */
44 /* ========================================================================= */
46 /* some positions in the video tape control window */
47 #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS)
48 #define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS)
49 #define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
50 #define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
51 #define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS + 1)
52 #define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS + 14)
53 #define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE)
54 #define VIDEO_DATE_YSIZE 16
55 #define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
56 #define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
57 #define VIDEO_REC_LABEL_XSIZE 20
58 #define VIDEO_REC_LABEL_YSIZE 12
59 #define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 20)
60 #define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
61 #define VIDEO_REC_SYMBOL_XSIZE 16
62 #define VIDEO_REC_SYMBOL_YSIZE 16
63 #define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS + 65)
64 #define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
65 #define VIDEO_PLAY_LABEL_XSIZE 22
66 #define VIDEO_PLAY_LABEL_YSIZE 12
67 #define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 52)
68 #define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
69 #define VIDEO_PLAY_SYMBOL_XSIZE 11
70 #define VIDEO_PLAY_SYMBOL_YSIZE 13
71 #define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
72 #define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS + 20)
73 #define VIDEO_PAUSE_LABEL_XSIZE 35
74 #define VIDEO_PAUSE_LABEL_YSIZE 8
75 #define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 35)
76 #define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
77 #define VIDEO_PAUSE_SYMBOL_XSIZE 17
78 #define VIDEO_PAUSE_SYMBOL_YSIZE 13
79 #define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS + 38)
80 #define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS + 14)
81 #define VIDEO_TIME_XSIZE 50
82 #define VIDEO_TIME_YSIZE 16
85 #define VIDEO_PBEND_LABEL_XPOS 5
86 #define VIDEO_PBEND_LABEL_YPOS 220
87 #define VIDEO_PBEND_LABEL_XSIZE 35
88 #define VIDEO_PBEND_LABEL_YSIZE 30
90 #define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \
91 VIDEO_STATE_REC_OFF | \
92 VIDEO_STATE_PAUSE_OFF | \
93 VIDEO_STATE_FFWD_OFF | \
94 VIDEO_STATE_PBEND_OFF | \
95 VIDEO_STATE_DATE_OFF | \
97 #define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \
98 VIDEO_PRESS_REC_OFF | \
99 VIDEO_PRESS_PAUSE_OFF | \
100 VIDEO_PRESS_STOP_OFF | \
101 VIDEO_PRESS_EJECT_OFF)
102 #define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
104 #define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \
105 VIDEO_STATE_REC_ON | \
106 VIDEO_STATE_PAUSE_ON | \
107 VIDEO_STATE_FFWD_ON | \
108 VIDEO_STATE_PBEND_ON | \
109 VIDEO_STATE_DATE_ON | \
111 #define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \
112 VIDEO_PRESS_REC_ON | \
113 VIDEO_PRESS_PAUSE_ON | \
114 VIDEO_PRESS_STOP_ON | \
115 VIDEO_PRESS_EJECT_ON)
116 #define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON)
118 #define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF)
119 #define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
120 #define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF)
123 /* ========================================================================= */
124 /* video display functions */
125 /* ========================================================================= */
127 void DrawVideoDisplay(unsigned long state, unsigned long value)
130 int part_label = 0, part_symbol = 1;
131 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
132 static char *monatsname[12] =
134 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
135 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
137 static int video_pos[5][2][4] =
139 {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
140 VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
141 { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
142 VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
144 {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
145 VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
146 { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
147 VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
149 {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
150 VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
151 { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
152 VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
154 {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
155 VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
156 { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
157 VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
161 { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
162 VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }}
165 if (state & VIDEO_STATE_PBEND_OFF)
167 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
169 BlitBitmap(pix[PIX_DOOR], drawto,
170 cx + VIDEO_REC_LABEL_XPOS,
171 cy + VIDEO_REC_LABEL_YPOS,
172 VIDEO_PBEND_LABEL_XSIZE,
173 VIDEO_PBEND_LABEL_YSIZE,
174 VX + VIDEO_REC_LABEL_XPOS,
175 VY + VIDEO_REC_LABEL_YPOS);
182 int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
184 if (i%2) /* i ungerade => STATE_ON / PRESS_OFF */
185 cx = DOOR_GFX_PAGEX4;
187 cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */
189 if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
190 BlitBitmap(pix[PIX_DOOR], drawto,
191 cx + video_pos[pos][part_label][xpos],
192 cy + video_pos[pos][part_label][ypos],
193 video_pos[pos][part_label][xsize],
194 video_pos[pos][part_label][ysize],
195 VX + video_pos[pos][part_label][xpos],
196 VY + video_pos[pos][part_label][ypos]);
197 if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
198 BlitBitmap(pix[PIX_DOOR], drawto,
199 cx + video_pos[pos][part_symbol][xpos],
200 cy + video_pos[pos][part_symbol][ypos],
201 video_pos[pos][part_symbol][xsize],
202 video_pos[pos][part_symbol][ysize],
203 VX + video_pos[pos][part_symbol][xpos],
204 VY + video_pos[pos][part_symbol][ypos]);
208 if (state & VIDEO_STATE_FFWD_ON)
210 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
212 BlitBitmap(pix[PIX_DOOR], drawto,
213 cx + VIDEO_PLAY_SYMBOL_XPOS,
214 cy + VIDEO_PLAY_SYMBOL_YPOS,
215 VIDEO_PLAY_SYMBOL_XSIZE - 2,
216 VIDEO_PLAY_SYMBOL_YSIZE,
217 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
218 VY + VIDEO_PLAY_SYMBOL_YPOS);
221 if (state & VIDEO_STATE_PBEND_ON)
223 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
225 BlitBitmap(pix[PIX_DOOR], drawto,
226 cx + VIDEO_PBEND_LABEL_XPOS,
227 cy + VIDEO_PBEND_LABEL_YPOS,
228 VIDEO_PBEND_LABEL_XSIZE,
229 VIDEO_PBEND_LABEL_YSIZE,
230 VX + VIDEO_REC_LABEL_XPOS,
231 VY + VIDEO_REC_LABEL_YPOS);
234 if (state & VIDEO_STATE_DATE_ON)
236 int tag = value % 100;
237 int monat = (value/100) % 100;
238 int jahr = (value/10000);
240 DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
241 int2str(tag,2),FS_SMALL,FC_SPECIAL1);
242 DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
243 monatsname[monat],FS_SMALL,FC_SPECIAL1);
244 DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
245 int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
248 if (state & VIDEO_STATE_TIME_ON)
250 int min = value / 60;
251 int sec = value % 60;
253 DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
254 int2str(min,2),FS_SMALL,FC_SPECIAL1);
255 DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
256 int2str(sec,2),FS_SMALL,FC_SPECIAL1);
259 if (state & VIDEO_STATE_DATE)
260 redraw_mask |= REDRAW_VIDEO_1;
261 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
262 redraw_mask |= REDRAW_VIDEO_2;
263 if (state & VIDEO_PRESS)
264 redraw_mask |= REDRAW_VIDEO_3;
267 void DrawCompleteVideoDisplay()
269 BlitBitmap(pix[PIX_DOOR], drawto, DOOR_GFX_PAGEX3, DOOR_GFX_PAGEY2,
270 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
271 BlitBitmap(pix[PIX_DOOR], drawto,
272 DOOR_GFX_PAGEX4 + VIDEO_CONTROL_XPOS,
273 DOOR_GFX_PAGEY2 + VIDEO_CONTROL_YPOS,
274 VIDEO_CONTROL_XSIZE, VIDEO_CONTROL_YSIZE,
275 gfx.vx + VIDEO_CONTROL_XPOS, gfx.vy + VIDEO_CONTROL_YPOS);
277 DrawVideoDisplay(VIDEO_ALL_OFF, 0);
278 if (tape.date && tape.length)
280 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
281 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
284 BlitBitmap(drawto, pix[PIX_DB_DOOR], gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
285 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
289 /* ========================================================================= */
290 /* tape control functions */
291 /* ========================================================================= */
293 void TapeStartRecording()
295 time_t zeit1 = time(NULL);
296 struct tm *zeit2 = localtime(&zeit1);
299 if (!TAPE_IS_STOPPED(tape))
302 tape.level_nr = level_nr;
305 tape.pos[tape.counter].delay = 0;
306 tape.recording = TRUE;
307 tape.playing = FALSE;
308 tape.pausing = FALSE;
310 tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
311 tape.random_seed = InitRND(NEW_RANDOMIZE);
312 tape.game_version = GAME_VERSION_ACTUAL;
314 for(i=0; i<MAX_PLAYERS; i++)
315 tape.player_participates[i] = FALSE;
317 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
318 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
319 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
320 MapTapeIndexButton();
322 SetDrawDeactivationMask(REDRAW_NONE);
323 audio.sound_deactivated = FALSE;
326 static void TapeStartGameRecording()
328 TapeStartRecording();
330 #if defined(PLATFORM_UNIX)
332 SendToServer_StartPlaying();
336 game_status = PLAYING;
342 static void TapeAppendRecording()
344 if (!tape.playing || !tape.pausing)
347 if (tape.game_version != GAME_VERSION_ACTUAL &&
348 !Request("This may break old version tape ! Append anyway ?",
352 tape.pos[tape.counter].delay = tape.delay_played;
353 tape.playing = FALSE;
354 tape.recording = TRUE;
356 tape.game_version = GAME_VERSION_ACTUAL;
358 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
361 void TapeHaltRecording()
367 tape.pos[tape.counter].delay = 0;
369 tape.length = tape.counter;
370 tape.length_seconds = GetTapeLength();
373 void TapeStopRecording()
380 tape.recording = FALSE;
381 tape.pausing = FALSE;
383 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
384 MapTapeEjectButton();
387 void TapeRecordAction(byte action[MAX_PLAYERS])
391 if (!tape.recording || tape.pausing)
394 if (tape.counter >= MAX_TAPELEN - 1)
400 if (tape.pos[tape.counter].delay > 0) /* already stored action */
402 boolean changed_events = FALSE;
404 for(i=0; i<MAX_PLAYERS; i++)
405 if (tape.pos[tape.counter].action[i] != action[i])
406 changed_events = TRUE;
408 if (changed_events || tape.pos[tape.counter].delay >= 255)
411 tape.pos[tape.counter].delay = 0;
414 tape.pos[tape.counter].delay++;
417 if (tape.pos[tape.counter].delay == 0) /* store new action */
419 for(i=0; i<MAX_PLAYERS; i++)
420 tape.pos[tape.counter].action[i] = action[i];
422 tape.pos[tape.counter].delay++;
426 void TapeTogglePause()
430 if (!tape.recording && !tape.playing)
433 tape.pausing = !tape.pausing;
434 tape.fast_forward = FALSE;
435 tape.pause_before_death = FALSE;
437 state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
439 state |= VIDEO_STATE_PBEND_OFF;
441 DrawVideoDisplay(state, 0);
443 if (tape.index_search)
445 tape.index_search = FALSE;
447 SetDrawDeactivationMask(REDRAW_NONE);
448 audio.sound_deactivated = FALSE;
450 RedrawPlayfield(TRUE, 0,0,0,0);
451 DrawGameDoorValues();
453 if (tape.quick_resume)
455 tape.quick_resume = FALSE;
457 TapeAppendRecording();
463 void TapeStartPlaying()
465 if (TAPE_IS_EMPTY(tape))
468 if (!TAPE_IS_STOPPED(tape))
472 tape.delay_played = 0;
473 tape.pause_before_death = FALSE;
474 tape.recording = FALSE;
476 tape.pausing = FALSE;
477 tape.fast_forward = FALSE;
478 tape.index_search = FALSE;
479 tape.quick_resume = FALSE;
481 InitRND(tape.random_seed);
483 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
484 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
485 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
486 MapTapeIndexButton();
488 SetDrawDeactivationMask(REDRAW_NONE);
489 audio.sound_deactivated = FALSE;
492 static void TapeStartGamePlaying()
496 game_status = PLAYING;
501 void TapeStopPlaying()
506 tape.playing = FALSE;
507 tape.pausing = FALSE;
509 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
510 MapTapeEjectButton();
513 byte *TapePlayAction()
515 static byte action[MAX_PLAYERS];
518 if (!tape.playing || tape.pausing)
521 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
523 if (!(FrameCounter % 20))
525 if ((FrameCounter / 20) % 2)
526 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
528 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
531 if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
538 if (tape.counter >= tape.length) /* end of tape reached */
540 if (tape.index_search)
548 for(i=0; i<MAX_PLAYERS; i++)
549 action[i] = tape.pos[tape.counter].action[i];
552 if (tape.delay_played >= tape.pos[tape.counter].delay)
555 tape.delay_played = 0;
566 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
567 if (tape.date && tape.length)
569 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
570 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
579 unsigned int GetTapeLength()
581 unsigned int tape_length = 0;
584 if (TAPE_IS_EMPTY(tape))
587 for(i=0;i<tape.length;i++)
588 tape_length += tape.pos[i].delay;
590 return(tape_length * GAME_FRAME_DELAY / 1000);
593 void TapeIndexSearch()
595 tape.index_search = TRUE;
597 if (!tape.fast_forward || tape.pause_before_death)
599 SetDrawDeactivationMask(REDRAW_FIELD | REDRAW_DOOR_1);
600 audio.sound_deactivated = TRUE;
606 if (game_status == PLAYING)
609 TapeHaltRecording(); /* prepare tape for saving on-the-fly */
611 if (TAPE_IS_EMPTY(tape))
612 Request("No tape that can be saved !", REQ_CONFIRM);
614 SaveTape(tape.level_nr);
616 else if (game_status == MAINMENU)
617 Request("No game that can be saved !", REQ_CONFIRM);
622 if (game_status == PLAYING || game_status == MAINMENU)
628 if (!TAPE_IS_EMPTY(tape))
630 TapeStartGamePlaying();
633 tape.quick_resume = TRUE;
636 Request("No tape for this level !", REQ_CONFIRM);
641 /* ---------- new tape button stuff ---------------------------------------- */
643 /* graphic position values for tape buttons */
644 #define TAPE_BUTTON_XSIZE 18
645 #define TAPE_BUTTON_YSIZE 18
646 #define TAPE_BUTTON_XPOS 5
647 #define TAPE_BUTTON_YPOS 77
649 #define TAPE_BUTTON_EJECT_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
650 #define TAPE_BUTTON_INDEX_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
651 #define TAPE_BUTTON_STOP_XPOS (TAPE_BUTTON_XPOS + 1 * TAPE_BUTTON_XSIZE)
652 #define TAPE_BUTTON_PAUSE_XPOS (TAPE_BUTTON_XPOS + 2 * TAPE_BUTTON_XSIZE)
653 #define TAPE_BUTTON_RECORD_XPOS (TAPE_BUTTON_XPOS + 3 * TAPE_BUTTON_XSIZE)
654 #define TAPE_BUTTON_PLAY_XPOS (TAPE_BUTTON_XPOS + 4 * TAPE_BUTTON_XSIZE)
661 } tapebutton_info[NUM_TAPE_BUTTONS] =
664 TAPE_BUTTON_EJECT_XPOS, TAPE_BUTTON_YPOS,
669 TAPE_BUTTON_INDEX_XPOS, TAPE_BUTTON_YPOS,
674 TAPE_BUTTON_STOP_XPOS, TAPE_BUTTON_YPOS,
679 TAPE_BUTTON_PAUSE_XPOS, TAPE_BUTTON_YPOS,
684 TAPE_BUTTON_RECORD_XPOS, TAPE_BUTTON_YPOS,
689 TAPE_BUTTON_PLAY_XPOS, TAPE_BUTTON_YPOS,
695 void CreateTapeButtons()
699 for (i=0; i<NUM_TAPE_BUTTONS; i++)
701 Bitmap *gd_bitmap = pix[PIX_DOOR];
702 struct GadgetInfo *gi;
703 int gd_xoffset, gd_yoffset;
704 int gd_x1, gd_x2, gd_y;
707 gd_xoffset = tapebutton_info[i].x;
708 gd_yoffset = tapebutton_info[i].y;
709 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
710 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
711 gd_y = DOOR_GFX_PAGEY2 + gd_yoffset;
713 if (i == TAPE_CTRL_ID_INDEX)
715 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
716 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
719 gi = CreateGadget(GDI_CUSTOM_ID, id,
720 GDI_INFO_TEXT, tapebutton_info[i].infotext,
721 GDI_X, VX + gd_xoffset,
722 GDI_Y, VY + gd_yoffset,
723 GDI_WIDTH, TAPE_BUTTON_XSIZE,
724 GDI_HEIGHT, TAPE_BUTTON_YSIZE,
725 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
726 GDI_STATE, GD_BUTTON_UNPRESSED,
727 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
728 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
729 GDI_EVENT_MASK, GD_EVENT_RELEASED,
730 GDI_CALLBACK_ACTION, HandleTapeButtons,
734 Error(ERR_EXIT, "cannot create gadget");
736 tape_gadget[id] = gi;
740 void MapTapeEjectButton()
742 UnmapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
743 MapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
746 void MapTapeIndexButton()
748 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
749 MapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
752 void MapTapeButtons()
756 for (i=0; i<NUM_TAPE_BUTTONS; i++)
757 if (i != TAPE_CTRL_ID_INDEX)
758 MapGadget(tape_gadget[i]);
760 if (tape.recording || tape.playing)
761 MapTapeIndexButton();
764 void UnmapTapeButtons()
768 for (i=0; i<NUM_TAPE_BUTTONS; i++)
769 UnmapGadget(tape_gadget[i]);
772 static void HandleTapeButtons(struct GadgetInfo *gi)
774 int id = gi->custom_id;
776 if (game_status != MAINMENU && game_status != PLAYING)
781 case TAPE_CTRL_ID_EJECT:
783 if (TAPE_IS_EMPTY(tape))
786 if (TAPE_IS_EMPTY(tape))
787 Request("No tape for this level !", REQ_CONFIRM);
792 SaveTape(tape.level_nr);
795 DrawCompleteVideoDisplay();
798 case TAPE_CTRL_ID_INDEX:
801 else if (tape.recording)
802 ; /* setting index mark -- not yet implemented */
805 case TAPE_CTRL_ID_STOP:
809 case TAPE_CTRL_ID_PAUSE:
813 case TAPE_CTRL_ID_RECORD:
814 if (TAPE_IS_STOPPED(tape))
815 TapeStartGameRecording();
816 else if (tape.pausing)
818 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
819 TapeAppendRecording();
825 case TAPE_CTRL_ID_PLAY:
826 if (TAPE_IS_EMPTY(tape))
829 if (TAPE_IS_STOPPED(tape))
831 TapeStartGamePlaying();
833 else if (tape.playing)
835 if (tape.pausing) /* PAUSE -> PLAY */
839 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
841 tape.fast_forward = TRUE;
842 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
844 else if (!tape.pause_before_death) /* FFWD PLAY -> AUTO PAUSE */
846 tape.pause_before_death = TRUE;
847 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
849 else /* AUTO PAUSE -> NORMAL PLAY */
851 tape.fast_forward = FALSE;
852 tape.pause_before_death = FALSE;
853 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);