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_STOP 1
26 #define TAPE_CTRL_ID_PAUSE 2
27 #define TAPE_CTRL_ID_RECORD 3
28 #define TAPE_CTRL_ID_PLAY 4
30 #define NUM_TAPE_BUTTONS 5
32 /* forward declaration for internal use */
33 static void HandleTapeButtons(struct GadgetInfo *);
35 static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
38 /* ========================================================================= */
39 /* video tape definitions */
40 /* ========================================================================= */
42 /* some positions in the video tape control window */
43 #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS)
44 #define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS)
45 #define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
46 #define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
47 #define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS + 1)
48 #define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS + 14)
49 #define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE)
50 #define VIDEO_DATE_YSIZE 16
51 #define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
52 #define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
53 #define VIDEO_REC_LABEL_XSIZE 20
54 #define VIDEO_REC_LABEL_YSIZE 12
55 #define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 20)
56 #define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
57 #define VIDEO_REC_SYMBOL_XSIZE 16
58 #define VIDEO_REC_SYMBOL_YSIZE 16
59 #define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS + 65)
60 #define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
61 #define VIDEO_PLAY_LABEL_XSIZE 22
62 #define VIDEO_PLAY_LABEL_YSIZE 12
63 #define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 52)
64 #define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
65 #define VIDEO_PLAY_SYMBOL_XSIZE 11
66 #define VIDEO_PLAY_SYMBOL_YSIZE 13
67 #define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
68 #define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS + 20)
69 #define VIDEO_PAUSE_LABEL_XSIZE 35
70 #define VIDEO_PAUSE_LABEL_YSIZE 8
71 #define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 35)
72 #define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
73 #define VIDEO_PAUSE_SYMBOL_XSIZE 17
74 #define VIDEO_PAUSE_SYMBOL_YSIZE 13
75 #define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS + 38)
76 #define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS + 14)
77 #define VIDEO_TIME_XSIZE 50
78 #define VIDEO_TIME_YSIZE 16
81 #define VIDEO_PBEND_LABEL_XPOS 5
82 #define VIDEO_PBEND_LABEL_YPOS 220
83 #define VIDEO_PBEND_LABEL_XSIZE 35
84 #define VIDEO_PBEND_LABEL_YSIZE 30
86 #define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \
87 VIDEO_STATE_REC_OFF | \
88 VIDEO_STATE_PAUSE_OFF | \
89 VIDEO_STATE_FFWD_OFF | \
90 VIDEO_STATE_PBEND_OFF | \
91 VIDEO_STATE_DATE_OFF | \
93 #define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \
94 VIDEO_PRESS_REC_OFF | \
95 VIDEO_PRESS_PAUSE_OFF | \
96 VIDEO_PRESS_STOP_OFF | \
97 VIDEO_PRESS_EJECT_OFF)
98 #define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
100 #define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \
101 VIDEO_STATE_REC_ON | \
102 VIDEO_STATE_PAUSE_ON | \
103 VIDEO_STATE_FFWD_ON | \
104 VIDEO_STATE_PBEND_ON | \
105 VIDEO_STATE_DATE_ON | \
107 #define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \
108 VIDEO_PRESS_REC_ON | \
109 VIDEO_PRESS_PAUSE_ON | \
110 VIDEO_PRESS_STOP_ON | \
111 VIDEO_PRESS_EJECT_ON)
112 #define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON)
114 #define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF)
115 #define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
116 #define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF)
119 /* ========================================================================= */
120 /* video display functions */
121 /* ========================================================================= */
123 void DrawVideoDisplay(unsigned long state, unsigned long value)
126 int part_label = 0, part_symbol = 1;
127 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
128 static char *monatsname[12] =
130 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
131 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
133 static int video_pos[5][2][4] =
135 {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
136 VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
137 { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
138 VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
140 {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
141 VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
142 { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
143 VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
145 {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
146 VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
147 { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
148 VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
150 {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
151 VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
152 { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
153 VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
157 { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
158 VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }}
161 if (state & VIDEO_STATE_PBEND_OFF)
163 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
165 BlitBitmap(pix[PIX_DOOR], drawto,
166 cx + VIDEO_REC_LABEL_XPOS,
167 cy + VIDEO_REC_LABEL_YPOS,
168 VIDEO_PBEND_LABEL_XSIZE,
169 VIDEO_PBEND_LABEL_YSIZE,
170 VX + VIDEO_REC_LABEL_XPOS,
171 VY + VIDEO_REC_LABEL_YPOS);
178 int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
180 if (i%2) /* i ungerade => STATE_ON / PRESS_OFF */
181 cx = DOOR_GFX_PAGEX4;
183 cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */
185 if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
186 BlitBitmap(pix[PIX_DOOR], drawto,
187 cx + video_pos[pos][part_label][xpos],
188 cy + video_pos[pos][part_label][ypos],
189 video_pos[pos][part_label][xsize],
190 video_pos[pos][part_label][ysize],
191 VX + video_pos[pos][part_label][xpos],
192 VY + video_pos[pos][part_label][ypos]);
193 if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
194 BlitBitmap(pix[PIX_DOOR], drawto,
195 cx + video_pos[pos][part_symbol][xpos],
196 cy + video_pos[pos][part_symbol][ypos],
197 video_pos[pos][part_symbol][xsize],
198 video_pos[pos][part_symbol][ysize],
199 VX + video_pos[pos][part_symbol][xpos],
200 VY + video_pos[pos][part_symbol][ypos]);
204 if (state & VIDEO_STATE_FFWD_ON)
206 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
208 BlitBitmap(pix[PIX_DOOR], drawto,
209 cx + VIDEO_PLAY_SYMBOL_XPOS,
210 cy + VIDEO_PLAY_SYMBOL_YPOS,
211 VIDEO_PLAY_SYMBOL_XSIZE - 2,
212 VIDEO_PLAY_SYMBOL_YSIZE,
213 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
214 VY + VIDEO_PLAY_SYMBOL_YPOS);
217 if (state & VIDEO_STATE_PBEND_ON)
219 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
221 BlitBitmap(pix[PIX_DOOR], drawto,
222 cx + VIDEO_PBEND_LABEL_XPOS,
223 cy + VIDEO_PBEND_LABEL_YPOS,
224 VIDEO_PBEND_LABEL_XSIZE,
225 VIDEO_PBEND_LABEL_YSIZE,
226 VX + VIDEO_REC_LABEL_XPOS,
227 VY + VIDEO_REC_LABEL_YPOS);
230 if (state & VIDEO_STATE_DATE_ON)
232 int tag = value % 100;
233 int monat = (value/100) % 100;
234 int jahr = (value/10000);
236 DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
237 int2str(tag,2),FS_SMALL,FC_SPECIAL1);
238 DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
239 monatsname[monat],FS_SMALL,FC_SPECIAL1);
240 DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
241 int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
244 if (state & VIDEO_STATE_TIME_ON)
246 int min = value / 60;
247 int sec = value % 60;
249 DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
250 int2str(min,2),FS_SMALL,FC_SPECIAL1);
251 DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
252 int2str(sec,2),FS_SMALL,FC_SPECIAL1);
255 if (state & VIDEO_STATE_DATE)
256 redraw_mask |= REDRAW_VIDEO_1;
257 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
258 redraw_mask |= REDRAW_VIDEO_2;
259 if (state & VIDEO_PRESS)
260 redraw_mask |= REDRAW_VIDEO_3;
263 void DrawCompleteVideoDisplay()
265 BlitBitmap(pix[PIX_DOOR], drawto, DOOR_GFX_PAGEX3, DOOR_GFX_PAGEY2,
266 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
267 BlitBitmap(pix[PIX_DOOR], drawto,
268 DOOR_GFX_PAGEX4 + VIDEO_CONTROL_XPOS,
269 DOOR_GFX_PAGEY2 + VIDEO_CONTROL_YPOS,
270 VIDEO_CONTROL_XSIZE, VIDEO_CONTROL_YSIZE,
271 gfx.vx + VIDEO_CONTROL_XPOS, gfx.vy + VIDEO_CONTROL_YPOS);
273 DrawVideoDisplay(VIDEO_ALL_OFF, 0);
274 if (tape.date && tape.length)
276 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
277 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
280 BlitBitmap(drawto, pix[PIX_DB_DOOR], gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
281 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
285 /* ========================================================================= */
286 /* tape control functions */
287 /* ========================================================================= */
289 void TapeStartRecording()
291 time_t zeit1 = time(NULL);
292 struct tm *zeit2 = localtime(&zeit1);
295 if (!TAPE_IS_STOPPED(tape))
298 tape.level_nr = level_nr;
301 tape.pos[tape.counter].delay = 0;
302 tape.recording = TRUE;
303 tape.playing = FALSE;
304 tape.pausing = FALSE;
306 tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
307 tape.random_seed = InitRND(NEW_RANDOMIZE);
309 for(i=0; i<MAX_PLAYERS; i++)
310 tape.player_participates[i] = FALSE;
312 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
313 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
314 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
317 void TapeStopRecording()
327 for(i=0; i<MAX_PLAYERS; i++)
328 tape.pos[tape.counter].action[i] = 0;
332 tape.length = tape.counter;
333 tape.length_seconds = GetTapeLength();
334 tape.recording = FALSE;
335 tape.pausing = FALSE;
336 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
340 void TapeRecordAction(byte joy[MAX_PLAYERS])
344 if (!tape.recording || tape.pausing)
347 if (tape.counter >= MAX_TAPELEN-1)
353 for(i=0; i<MAX_PLAYERS; i++)
354 tape.pos[tape.counter].action[i] = joy[i];
357 tape.pos[tape.counter].delay = 0;
362 void TapeRecordAction(byte action[MAX_PLAYERS])
366 if (!tape.recording || tape.pausing)
369 if (tape.counter >= MAX_TAPELEN-1)
375 if (tape.pos[tape.counter].delay > 0) /* already stored action */
377 boolean changed_events = FALSE;
379 for(i=0; i<MAX_PLAYERS; i++)
380 if (tape.pos[tape.counter].action[i] != action[i])
381 changed_events = TRUE;
383 if (changed_events || tape.pos[tape.counter].delay >= 255)
386 tape.pos[tape.counter].delay = 0;
389 tape.pos[tape.counter].delay++;
392 if (tape.pos[tape.counter].delay == 0) /* store new action */
394 for(i=0; i<MAX_PLAYERS; i++)
395 tape.pos[tape.counter].action[i] = action[i];
397 tape.pos[tape.counter].delay++;
403 void TapeRecordDelay()
407 if (!tape.recording || tape.pausing)
410 if (tape.counter >= MAX_TAPELEN)
416 tape.pos[tape.counter].delay++;
418 if (tape.pos[tape.counter].delay >= 255)
420 for(i=0; i<MAX_PLAYERS; i++)
421 tape.pos[tape.counter].action[i] = 0;
424 tape.pos[tape.counter].delay = 0;
430 void TapeRecordDelay()
435 void TapeTogglePause()
439 if (!tape.recording && !tape.playing)
442 tape.pausing = !tape.pausing;
443 tape.fast_forward = FALSE;
444 tape.pause_before_death = FALSE;
446 state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
448 state |= VIDEO_STATE_PBEND_OFF;
450 DrawVideoDisplay(state, 0);
453 void TapeStartPlaying()
455 if (TAPE_IS_EMPTY(tape))
458 if (!TAPE_IS_STOPPED(tape))
462 tape.delay_played = 0;
463 tape.pause_before_death = FALSE;
464 tape.recording = FALSE;
466 tape.pausing = FALSE;
467 tape.fast_forward = FALSE;
468 InitRND(tape.random_seed);
470 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
471 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
472 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
475 void TapeStopPlaying()
480 tape.playing = FALSE;
481 tape.pausing = FALSE;
482 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
486 byte *TapePlayAction()
488 static byte joy[MAX_PLAYERS];
491 if (!tape.playing || tape.pausing)
494 if (tape.counter >= tape.length)
500 if (tape.delay_played == tape.pos[tape.counter].delay)
502 tape.delay_played = 0;
505 for(i=0; i<MAX_PLAYERS; i++)
506 joy[i] = tape.pos[tape.counter-1].action[i];
510 for(i=0; i<MAX_PLAYERS; i++)
519 byte *TapePlayAction()
521 static byte action[MAX_PLAYERS];
524 if (!tape.playing || tape.pausing)
527 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
529 if (!(FrameCounter % 20))
531 if ((FrameCounter / 20) % 2)
532 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
534 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
537 if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
544 if (tape.counter >= tape.length)
550 for(i=0; i<MAX_PLAYERS; i++)
551 action[i] = tape.pos[tape.counter].action[i];
554 if (tape.delay_played >= tape.pos[tape.counter].delay)
557 tape.delay_played = 0;
565 boolean TapePlayDelay()
567 if (!tape.playing || tape.pausing)
570 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
572 if (!(FrameCounter % 20))
574 if ((FrameCounter / 20) % 2)
575 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
577 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
580 if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
587 if (tape.counter >= tape.length)
593 if (tape.delay_played < tape.pos[tape.counter].delay)
604 boolean TapePlayDelay()
606 return TRUE|FALSE; /* ...it doesn't matter at all */
615 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
616 if (tape.date && tape.length)
618 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
619 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
628 unsigned int GetTapeLength()
630 unsigned int tape_length = 0;
633 if (TAPE_IS_EMPTY(tape))
636 for(i=0;i<tape.length;i++)
637 tape_length += tape.pos[i].delay;
639 return(tape_length * GAME_FRAME_DELAY / 1000);
642 /* ---------- new tape button stuff ---------------------------------------- */
644 /* graphic position values for tape buttons */
645 #define TAPE_BUTTON_XSIZE 18
646 #define TAPE_BUTTON_YSIZE 18
647 #define TAPE_BUTTON_XPOS 5
648 #define TAPE_BUTTON_YPOS 77
650 #define TAPE_BUTTON_EJECT_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_STOP_XPOS, TAPE_BUTTON_YPOS,
674 TAPE_BUTTON_PAUSE_XPOS, TAPE_BUTTON_YPOS,
679 TAPE_BUTTON_RECORD_XPOS, TAPE_BUTTON_YPOS,
684 TAPE_BUTTON_PLAY_XPOS, TAPE_BUTTON_YPOS,
690 void CreateTapeButtons()
694 for (i=0; i<NUM_TAPE_BUTTONS; i++)
696 Bitmap *gd_bitmap = pix[PIX_DOOR];
697 struct GadgetInfo *gi;
698 int gd_xoffset, gd_yoffset;
699 int gd_x1, gd_x2, gd_y;
702 gd_xoffset = tapebutton_info[i].x;
703 gd_yoffset = tapebutton_info[i].y;
704 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
705 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
706 gd_y = DOOR_GFX_PAGEY2 + gd_yoffset;
708 gi = CreateGadget(GDI_CUSTOM_ID, id,
709 GDI_INFO_TEXT, tapebutton_info[i].infotext,
710 GDI_X, VX + gd_xoffset,
711 GDI_Y, VY + gd_yoffset,
712 GDI_WIDTH, TAPE_BUTTON_XSIZE,
713 GDI_HEIGHT, TAPE_BUTTON_YSIZE,
714 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
715 GDI_STATE, GD_BUTTON_UNPRESSED,
716 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
717 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
718 GDI_EVENT_MASK, GD_EVENT_RELEASED,
719 GDI_CALLBACK_ACTION, HandleTapeButtons,
723 Error(ERR_EXIT, "cannot create gadget");
725 tape_gadget[id] = gi;
729 void MapTapeButtons()
733 for (i=0; i<NUM_TAPE_BUTTONS; i++)
734 MapGadget(tape_gadget[i]);
737 void UnmapTapeButtons()
741 for (i=0; i<NUM_TAPE_BUTTONS; i++)
742 UnmapGadget(tape_gadget[i]);
745 static void HandleTapeButtons(struct GadgetInfo *gi)
747 int id = gi->custom_id;
749 if (game_status != MAINMENU && game_status != PLAYING)
754 case TAPE_CTRL_ID_EJECT:
756 if (TAPE_IS_EMPTY(tape))
759 if (TAPE_IS_EMPTY(tape))
760 Request("No tape for this level !", REQ_CONFIRM);
765 SaveTape(tape.level_nr);
768 DrawCompleteVideoDisplay();
771 case TAPE_CTRL_ID_STOP:
775 case TAPE_CTRL_ID_PAUSE:
779 case TAPE_CTRL_ID_RECORD:
780 if (TAPE_IS_STOPPED(tape))
782 TapeStartRecording();
784 #if defined(PLATFORM_UNIX)
786 SendToServer_StartPlaying();
790 game_status = PLAYING;
795 else if (tape.pausing)
797 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
799 tape.pos[tape.counter].delay = tape.delay_played;
800 tape.playing = FALSE;
801 tape.recording = TRUE;
804 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
811 case TAPE_CTRL_ID_PLAY:
812 if (TAPE_IS_EMPTY(tape))
815 if (TAPE_IS_STOPPED(tape))
819 game_status = PLAYING;
823 else if (tape.playing)
825 if (tape.pausing) /* PAUSE -> PLAY */
827 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
829 tape.fast_forward = TRUE;
830 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
832 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
834 tape.pause_before_death = TRUE;
835 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
837 else /* -> NORMAL PLAY */
839 tape.fast_forward = FALSE;
840 tape.pause_before_death = FALSE;
841 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);