1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 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 *);
38 static void TapeStopIndexSearch();
40 static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
43 /* ========================================================================= */
44 /* video tape definitions */
45 /* ========================================================================= */
47 /* some positions in the video tape control window */
48 #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS)
49 #define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS)
50 #define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
51 #define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
52 #define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS + 1)
53 #define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS + 14)
54 #define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE)
55 #define VIDEO_DATE_YSIZE 16
56 #define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
57 #define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
58 #define VIDEO_REC_LABEL_XSIZE 20
59 #define VIDEO_REC_LABEL_YSIZE 12
60 #define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 20)
61 #define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
62 #define VIDEO_REC_SYMBOL_XSIZE 16
63 #define VIDEO_REC_SYMBOL_YSIZE 16
64 #define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS + 65)
65 #define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
66 #define VIDEO_PLAY_LABEL_XSIZE 22
67 #define VIDEO_PLAY_LABEL_YSIZE 12
68 #define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 52)
69 #define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
70 #define VIDEO_PLAY_SYMBOL_XSIZE 11
71 #define VIDEO_PLAY_SYMBOL_YSIZE 13
72 #define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
73 #define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS + 20)
74 #define VIDEO_PAUSE_LABEL_XSIZE 35
75 #define VIDEO_PAUSE_LABEL_YSIZE 8
76 #define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 35)
77 #define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
78 #define VIDEO_PAUSE_SYMBOL_XSIZE 17
79 #define VIDEO_PAUSE_SYMBOL_YSIZE 13
80 #define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS + 38)
81 #define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS + 14)
82 #define VIDEO_TIME_XSIZE 50
83 #define VIDEO_TIME_YSIZE 16
86 #define VIDEO_PBEND_LABEL_XPOS 5
87 #define VIDEO_PBEND_LABEL_YPOS 220
88 #define VIDEO_PBEND_LABEL_XSIZE 35
89 #define VIDEO_PBEND_LABEL_YSIZE 30
91 #define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \
92 VIDEO_STATE_REC_OFF | \
93 VIDEO_STATE_PAUSE_OFF | \
94 VIDEO_STATE_FFWD_OFF | \
95 VIDEO_STATE_PBEND_OFF | \
96 VIDEO_STATE_DATE_OFF | \
98 #define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \
99 VIDEO_PRESS_REC_OFF | \
100 VIDEO_PRESS_PAUSE_OFF | \
101 VIDEO_PRESS_STOP_OFF | \
102 VIDEO_PRESS_EJECT_OFF)
103 #define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
105 #define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \
106 VIDEO_STATE_REC_ON | \
107 VIDEO_STATE_PAUSE_ON | \
108 VIDEO_STATE_FFWD_ON | \
109 VIDEO_STATE_PBEND_ON | \
110 VIDEO_STATE_DATE_ON | \
112 #define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \
113 VIDEO_PRESS_REC_ON | \
114 VIDEO_PRESS_PAUSE_ON | \
115 VIDEO_PRESS_STOP_ON | \
116 VIDEO_PRESS_EJECT_ON)
117 #define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON)
119 #define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF)
120 #define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
121 #define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF)
124 /* ========================================================================= */
125 /* video display functions */
126 /* ========================================================================= */
128 void DrawVideoDisplay(unsigned long state, unsigned long value)
131 int part_label = 0, part_symbol = 1;
132 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
133 static char *monatsname[12] =
135 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
136 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
138 static int video_pos[5][2][4] =
140 {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
141 VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
142 { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
143 VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
145 {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
146 VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
147 { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
148 VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
150 {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
151 VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
152 { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
153 VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
155 {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
156 VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
157 { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
158 VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
162 { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
163 VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }}
166 if (state & VIDEO_STATE_PBEND_OFF)
168 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
170 BlitBitmap(pix[PIX_DOOR], drawto,
171 cx + VIDEO_REC_LABEL_XPOS,
172 cy + VIDEO_REC_LABEL_YPOS,
173 VIDEO_PBEND_LABEL_XSIZE,
174 VIDEO_PBEND_LABEL_YSIZE,
175 VX + VIDEO_REC_LABEL_XPOS,
176 VY + VIDEO_REC_LABEL_YPOS);
183 int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
185 if (i%2) /* i ungerade => STATE_ON / PRESS_OFF */
186 cx = DOOR_GFX_PAGEX4;
188 cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */
190 if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
191 BlitBitmap(pix[PIX_DOOR], drawto,
192 cx + video_pos[pos][part_label][xpos],
193 cy + video_pos[pos][part_label][ypos],
194 video_pos[pos][part_label][xsize],
195 video_pos[pos][part_label][ysize],
196 VX + video_pos[pos][part_label][xpos],
197 VY + video_pos[pos][part_label][ypos]);
198 if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
199 BlitBitmap(pix[PIX_DOOR], drawto,
200 cx + video_pos[pos][part_symbol][xpos],
201 cy + video_pos[pos][part_symbol][ypos],
202 video_pos[pos][part_symbol][xsize],
203 video_pos[pos][part_symbol][ysize],
204 VX + video_pos[pos][part_symbol][xpos],
205 VY + video_pos[pos][part_symbol][ypos]);
209 if (state & VIDEO_STATE_FFWD_ON)
211 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
213 BlitBitmap(pix[PIX_DOOR], drawto,
214 cx + VIDEO_PLAY_SYMBOL_XPOS,
215 cy + VIDEO_PLAY_SYMBOL_YPOS,
216 VIDEO_PLAY_SYMBOL_XSIZE - 2,
217 VIDEO_PLAY_SYMBOL_YSIZE,
218 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
219 VY + VIDEO_PLAY_SYMBOL_YPOS);
222 if (state & VIDEO_STATE_PBEND_ON)
224 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
226 BlitBitmap(pix[PIX_DOOR], drawto,
227 cx + VIDEO_PBEND_LABEL_XPOS,
228 cy + VIDEO_PBEND_LABEL_YPOS,
229 VIDEO_PBEND_LABEL_XSIZE,
230 VIDEO_PBEND_LABEL_YSIZE,
231 VX + VIDEO_REC_LABEL_XPOS,
232 VY + VIDEO_REC_LABEL_YPOS);
235 if (state & VIDEO_STATE_DATE_ON)
237 int tag = value % 100;
238 int monat = (value/100) % 100;
239 int jahr = (value/10000);
241 DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
242 int2str(tag,2),FS_SMALL,FC_SPECIAL1);
243 DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
244 monatsname[monat],FS_SMALL,FC_SPECIAL1);
245 DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
246 int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
249 if (state & VIDEO_STATE_TIME_ON)
251 int min = value / 60;
252 int sec = value % 60;
254 DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
255 int2str(min,2),FS_SMALL,FC_SPECIAL1);
256 DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
257 int2str(sec,2),FS_SMALL,FC_SPECIAL1);
260 if (state & VIDEO_STATE_DATE)
261 redraw_mask |= REDRAW_VIDEO_1;
262 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
263 redraw_mask |= REDRAW_VIDEO_2;
264 if (state & VIDEO_PRESS)
265 redraw_mask |= REDRAW_VIDEO_3;
268 void DrawCompleteVideoDisplay()
270 BlitBitmap(pix[PIX_DOOR], drawto, DOOR_GFX_PAGEX3, DOOR_GFX_PAGEY2,
271 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
272 BlitBitmap(pix[PIX_DOOR], drawto,
273 DOOR_GFX_PAGEX4 + VIDEO_CONTROL_XPOS,
274 DOOR_GFX_PAGEY2 + VIDEO_CONTROL_YPOS,
275 VIDEO_CONTROL_XSIZE, VIDEO_CONTROL_YSIZE,
276 gfx.vx + VIDEO_CONTROL_XPOS, gfx.vy + VIDEO_CONTROL_YPOS);
278 DrawVideoDisplay(VIDEO_ALL_OFF, 0);
279 if (tape.date && tape.length)
281 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
282 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
285 BlitBitmap(drawto, pix[PIX_DB_DOOR], gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
286 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
290 /* ========================================================================= */
291 /* tape control functions */
292 /* ========================================================================= */
296 time_t epoch_seconds = time(NULL);
297 struct tm *time = localtime(&epoch_seconds);
303 tape.level_nr = level_nr;
304 tape.pos[tape.counter].delay = 0;
307 tape.date = 10000*(time->tm_year % 100) + 100*time->tm_mon + time->tm_mday;
308 tape.random_seed = InitRND(NEW_RANDOMIZE);
310 tape.file_version = FILE_VERSION_ACTUAL;
311 tape.game_version = GAME_VERSION_ACTUAL;
312 tape.engine_version = level.game_version;
314 for(i=0; i<MAX_PLAYERS; i++)
315 tape.player_participates[i] = FALSE;
318 static void TapeRewind()
321 tape.delay_played = 0;
322 tape.pause_before_death = FALSE;
323 tape.recording = FALSE;
324 tape.playing = FALSE;
325 tape.fast_forward = FALSE;
326 tape.index_search = FALSE;
327 tape.quick_resume = FALSE;
328 tape.single_step = FALSE;
330 InitRND(tape.random_seed);
333 void TapeStartRecording()
335 if (!TAPE_IS_STOPPED(tape))
341 tape.recording = TRUE;
343 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
344 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
345 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
346 MapTapeIndexButton();
348 SetDrawDeactivationMask(REDRAW_NONE);
349 audio.sound_deactivated = FALSE;
352 static void TapeStartGameRecording()
354 TapeStartRecording();
356 #if defined(PLATFORM_UNIX)
358 SendToServer_StartPlaying();
362 game_status = PLAYING;
368 static void TapeAppendRecording()
370 if (!tape.playing || !tape.pausing)
373 tape.pos[tape.counter].delay = tape.delay_played;
374 tape.playing = FALSE;
375 tape.recording = TRUE;
378 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
381 void TapeHaltRecording()
387 tape.pos[tape.counter].delay = 0;
389 tape.length = tape.counter;
390 tape.length_seconds = GetTapeLength();
393 void TapeStopRecording()
400 tape.recording = FALSE;
401 tape.pausing = FALSE;
403 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
404 MapTapeEjectButton();
407 void TapeRecordAction(byte action[MAX_PLAYERS])
411 if (!tape.recording || tape.pausing)
414 if (tape.counter >= MAX_TAPELEN - 1)
420 if (tape.pos[tape.counter].delay > 0) /* already stored action */
422 boolean changed_events = FALSE;
424 for(i=0; i<MAX_PLAYERS; i++)
425 if (tape.pos[tape.counter].action[i] != action[i])
426 changed_events = TRUE;
428 if (changed_events || tape.pos[tape.counter].delay >= 255)
431 tape.pos[tape.counter].delay = 0;
434 tape.pos[tape.counter].delay++;
437 if (tape.pos[tape.counter].delay == 0) /* store new action */
439 for(i=0; i<MAX_PLAYERS; i++)
440 tape.pos[tape.counter].action[i] = action[i];
442 tape.pos[tape.counter].delay++;
446 void TapeTogglePause(boolean toggle_manual)
451 if (!tape.recording && !tape.playing)
455 tape.pausing = !tape.pausing;
456 tape.fast_forward = FALSE;
457 tape.pause_before_death = FALSE;
459 if (tape.single_step && toggle_manual)
460 tape.single_step = FALSE;
462 state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
464 state |= VIDEO_STATE_PBEND_OFF;
466 DrawVideoDisplay(state, 0);
468 if (tape.index_search)
470 TapeStopIndexSearch();
472 if (tape.quick_resume)
474 tape.quick_resume = FALSE;
476 TapeAppendRecording();
477 TapeTogglePause(toggle_manual);
482 void TapeStartPlaying()
484 if (TAPE_IS_EMPTY(tape))
487 if (!TAPE_IS_STOPPED(tape))
494 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
495 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
496 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
497 MapTapeIndexButton();
499 SetDrawDeactivationMask(REDRAW_NONE);
500 audio.sound_deactivated = FALSE;
503 static void TapeStartGamePlaying()
507 game_status = PLAYING;
512 void TapeStopPlaying()
517 tape.playing = FALSE;
518 tape.pausing = FALSE;
520 if (tape.index_search)
521 TapeStopIndexSearch();
523 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
524 MapTapeEjectButton();
527 byte *TapePlayAction()
529 static byte action[MAX_PLAYERS];
532 if (!tape.playing || tape.pausing)
535 if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
537 if (!(FrameCounter % 20))
539 if ((FrameCounter / 20) % 2)
540 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
542 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
545 if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
547 TapeTogglePause(TAPE_TOGGLE_MANUAL);
552 if (tape.counter >= tape.length) /* end of tape reached */
554 if (tape.index_search)
555 TapeTogglePause(TAPE_TOGGLE_MANUAL);
562 for(i=0; i<MAX_PLAYERS; i++)
563 action[i] = tape.pos[tape.counter].action[i];
566 if (tape.delay_played >= tape.pos[tape.counter].delay)
569 tape.delay_played = 0;
580 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
581 if (tape.date && tape.length)
583 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
584 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
588 unsigned int GetTapeLength()
590 unsigned int tape_length = 0;
593 if (TAPE_IS_EMPTY(tape))
596 for(i=0;i<tape.length;i++)
597 tape_length += tape.pos[i].delay;
599 return(tape_length * GAME_FRAME_DELAY / 1000);
602 static void TapeStartIndexSearch()
604 tape.index_search = TRUE;
606 if (!tape.fast_forward || tape.pause_before_death)
608 tape.pausing = FALSE;
610 SetDrawDeactivationMask(REDRAW_FIELD | REDRAW_DOOR_1);
611 audio.sound_deactivated = TRUE;
615 static void TapeStopIndexSearch()
617 tape.index_search = FALSE;
619 SetDrawDeactivationMask(REDRAW_NONE);
620 audio.sound_deactivated = FALSE;
622 RedrawPlayfield(TRUE, 0,0,0,0);
623 DrawGameDoorValues();
626 static void TapeSingleStep()
632 TapeTogglePause(TAPE_TOGGLE_MANUAL);
634 tape.single_step = !tape.single_step;
639 if (game_status == PLAYING)
642 TapeHaltRecording(); /* prepare tape for saving on-the-fly */
644 if (TAPE_IS_EMPTY(tape))
645 Request("No tape that can be saved !", REQ_CONFIRM);
647 SaveTape(tape.level_nr);
649 else if (game_status == MAINMENU)
650 Request("No game that can be saved !", REQ_CONFIRM);
655 if (game_status == PLAYING || game_status == MAINMENU)
661 if (!TAPE_IS_EMPTY(tape))
663 TapeStartGamePlaying();
664 TapeStartIndexSearch();
666 tape.quick_resume = TRUE;
669 Request("No tape for this level !", REQ_CONFIRM);
674 /* ---------- new tape button stuff ---------------------------------------- */
676 /* graphic position values for tape buttons */
677 #define TAPE_BUTTON_XSIZE 18
678 #define TAPE_BUTTON_YSIZE 18
679 #define TAPE_BUTTON_XPOS 5
680 #define TAPE_BUTTON_YPOS 77
682 #define TAPE_BUTTON_EJECT_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
683 #define TAPE_BUTTON_INDEX_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
684 #define TAPE_BUTTON_STOP_XPOS (TAPE_BUTTON_XPOS + 1 * TAPE_BUTTON_XSIZE)
685 #define TAPE_BUTTON_PAUSE_XPOS (TAPE_BUTTON_XPOS + 2 * TAPE_BUTTON_XSIZE)
686 #define TAPE_BUTTON_RECORD_XPOS (TAPE_BUTTON_XPOS + 3 * TAPE_BUTTON_XSIZE)
687 #define TAPE_BUTTON_PLAY_XPOS (TAPE_BUTTON_XPOS + 4 * TAPE_BUTTON_XSIZE)
694 } tapebutton_info[NUM_TAPE_BUTTONS] =
697 TAPE_BUTTON_EJECT_XPOS, TAPE_BUTTON_YPOS,
702 TAPE_BUTTON_INDEX_XPOS, TAPE_BUTTON_YPOS,
707 TAPE_BUTTON_STOP_XPOS, TAPE_BUTTON_YPOS,
712 TAPE_BUTTON_PAUSE_XPOS, TAPE_BUTTON_YPOS,
717 TAPE_BUTTON_RECORD_XPOS, TAPE_BUTTON_YPOS,
722 TAPE_BUTTON_PLAY_XPOS, TAPE_BUTTON_YPOS,
728 void CreateTapeButtons()
732 for (i=0; i<NUM_TAPE_BUTTONS; i++)
734 Bitmap *gd_bitmap = pix[PIX_DOOR];
735 struct GadgetInfo *gi;
736 int gd_xoffset, gd_yoffset;
737 int gd_x1, gd_x2, gd_y;
740 gd_xoffset = tapebutton_info[i].x;
741 gd_yoffset = tapebutton_info[i].y;
742 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
743 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
744 gd_y = DOOR_GFX_PAGEY2 + gd_yoffset;
746 if (i == TAPE_CTRL_ID_INDEX)
748 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
749 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
752 gi = CreateGadget(GDI_CUSTOM_ID, id,
753 GDI_INFO_TEXT, tapebutton_info[i].infotext,
754 GDI_X, VX + gd_xoffset,
755 GDI_Y, VY + gd_yoffset,
756 GDI_WIDTH, TAPE_BUTTON_XSIZE,
757 GDI_HEIGHT, TAPE_BUTTON_YSIZE,
758 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
759 GDI_STATE, GD_BUTTON_UNPRESSED,
760 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
761 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
762 GDI_EVENT_MASK, GD_EVENT_RELEASED,
763 GDI_CALLBACK_ACTION, HandleTapeButtons,
767 Error(ERR_EXIT, "cannot create gadget");
769 tape_gadget[id] = gi;
773 void MapTapeEjectButton()
775 UnmapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
776 MapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
779 void MapTapeIndexButton()
781 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
782 MapGadget(tape_gadget[TAPE_CTRL_ID_INDEX]);
785 void MapTapeButtons()
789 for (i=0; i<NUM_TAPE_BUTTONS; i++)
790 if (i != TAPE_CTRL_ID_INDEX)
791 MapGadget(tape_gadget[i]);
793 if (tape.recording || tape.playing)
794 MapTapeIndexButton();
797 void UnmapTapeButtons()
801 for (i=0; i<NUM_TAPE_BUTTONS; i++)
802 UnmapGadget(tape_gadget[i]);
805 static void HandleTapeButtons(struct GadgetInfo *gi)
807 int id = gi->custom_id;
809 if (game_status != MAINMENU && game_status != PLAYING)
814 case TAPE_CTRL_ID_EJECT:
816 if (TAPE_IS_EMPTY(tape))
819 if (TAPE_IS_EMPTY(tape))
820 Request("No tape for this level !", REQ_CONFIRM);
825 SaveTape(tape.level_nr);
828 DrawCompleteVideoDisplay();
831 case TAPE_CTRL_ID_INDEX:
833 TapeStartIndexSearch();
834 else if (tape.recording)
838 case TAPE_CTRL_ID_STOP:
842 case TAPE_CTRL_ID_PAUSE:
843 TapeTogglePause(TAPE_TOGGLE_MANUAL);
846 case TAPE_CTRL_ID_RECORD:
847 if (TAPE_IS_STOPPED(tape))
848 TapeStartGameRecording();
849 else if (tape.pausing)
851 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
852 TapeAppendRecording();
854 TapeTogglePause(TAPE_TOGGLE_MANUAL);
858 case TAPE_CTRL_ID_PLAY:
859 if (TAPE_IS_EMPTY(tape))
862 if (TAPE_IS_STOPPED(tape))
864 TapeStartGamePlaying();
866 else if (tape.playing)
868 if (tape.pausing) /* PAUSE -> PLAY */
870 TapeTogglePause(TAPE_TOGGLE_MANUAL);
872 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
874 tape.fast_forward = TRUE;
875 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
877 else if (!tape.pause_before_death) /* FFWD PLAY -> AUTO PAUSE */
879 tape.pause_before_death = TRUE;
880 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
882 else /* AUTO PAUSE -> NORMAL PLAY */
884 tape.fast_forward = FALSE;
885 tape.pause_before_death = FALSE;
886 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);