1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
24 /* tape button identifiers */
25 #define TAPE_CTRL_ID_EJECT 0
26 #define TAPE_CTRL_ID_EXTRA 1
27 #define TAPE_CTRL_ID_STOP 2
28 #define TAPE_CTRL_ID_PAUSE 3
29 #define TAPE_CTRL_ID_RECORD 4
30 #define TAPE_CTRL_ID_PLAY 5
32 #define NUM_TAPE_BUTTONS 6
34 /* values for tape handling */
35 #define TAPE_PAUSE_SECONDS_BEFORE_DEATH 5
37 /* forward declaration for internal use */
38 static void HandleTapeButtons(struct GadgetInfo *);
39 static void TapeStopWarpForward();
41 static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
44 /* ========================================================================= */
45 /* video tape definitions */
46 /* ========================================================================= */
48 /* some positions in the video tape control window */
49 #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS)
50 #define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS)
51 #define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
52 #define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
53 #define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS + 2)
54 #define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS + 14)
55 #define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE)
56 #define VIDEO_DATE_YSIZE 16
57 #define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
58 #define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
59 #define VIDEO_REC_LABEL_XSIZE 20
60 #define VIDEO_REC_LABEL_YSIZE 12
61 #define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 20)
62 #define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
63 #define VIDEO_REC_SYMBOL_XSIZE 16
64 #define VIDEO_REC_SYMBOL_YSIZE 16
65 #define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS + 65)
66 #define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
67 #define VIDEO_PLAY_LABEL_XSIZE 22
68 #define VIDEO_PLAY_LABEL_YSIZE 12
69 #define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 52)
70 #define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
71 #define VIDEO_PLAY_SYMBOL_XSIZE 11
72 #define VIDEO_PLAY_SYMBOL_YSIZE 13
73 #define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
74 #define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS + 20)
75 #define VIDEO_PAUSE_LABEL_XSIZE 35
76 #define VIDEO_PAUSE_LABEL_YSIZE 8
77 #define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS + 35)
78 #define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
79 #define VIDEO_PAUSE_SYMBOL_XSIZE 17
80 #define VIDEO_PAUSE_SYMBOL_YSIZE 13
81 #define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS + 39)
82 #define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS + 14)
83 #define VIDEO_TIME_XSIZE 50
84 #define VIDEO_TIME_YSIZE 16
86 /* some default values for tape labels and symbols */
87 #define VIDEO_LABEL_XPOS 5
88 #define VIDEO_LABEL_YPOS 42
89 #define VIDEO_LABEL_XSIZE 40
90 #define VIDEO_LABEL_YSIZE 28
91 #define VIDEO_SYMBOL_XPOS 39
92 #define VIDEO_SYMBOL_YPOS 42
93 #define VIDEO_SYMBOL_XSIZE 56
94 #define VIDEO_SYMBOL_YSIZE 13
96 /* values for certain tape labels and symbols */
97 #define VIDEO_FFWD_LABEL_XPOS VIDEO_LABEL_XPOS
98 #define VIDEO_FFWD_LABEL_YPOS 193
99 #define VIDEO_FFWD_LABEL_XSIZE VIDEO_LABEL_XSIZE
100 #define VIDEO_FFWD_LABEL_YSIZE VIDEO_LABEL_YSIZE
101 #define VIDEO_FFWD_SYMBOL_XPOS VIDEO_SYMBOL_XPOS
102 #define VIDEO_FFWD_SYMBOL_YPOS 193
103 #define VIDEO_FFWD_SYMBOL_XSIZE 27
104 #define VIDEO_FFWD_SYMBOL_YSIZE VIDEO_SYMBOL_YSIZE
106 #define VIDEO_PBEND_LABEL_XPOS VIDEO_LABEL_XPOS
107 #define VIDEO_PBEND_LABEL_YPOS 221
108 #define VIDEO_PBEND_LABEL_XSIZE VIDEO_LABEL_XSIZE
109 #define VIDEO_PBEND_LABEL_YSIZE VIDEO_LABEL_YSIZE
110 #define VIDEO_PBEND_SYMBOL_XPOS VIDEO_SYMBOL_XPOS
111 #define VIDEO_PBEND_SYMBOL_YPOS 221
112 #define VIDEO_PBEND_SYMBOL_XSIZE 27
113 #define VIDEO_PBEND_SYMBOL_YSIZE VIDEO_SYMBOL_YSIZE
115 #define VIDEO_WARP_LABEL_XPOS VIDEO_LABEL_XPOS
116 #define VIDEO_WARP_LABEL_YPOS 165
117 #define VIDEO_WARP_LABEL_XSIZE VIDEO_LABEL_XSIZE
118 #define VIDEO_WARP_LABEL_YSIZE VIDEO_LABEL_YSIZE
119 #define VIDEO_WARP_SYMBOL_XPOS VIDEO_SYMBOL_XPOS
120 #define VIDEO_WARP_SYMBOL_YPOS 165
121 #define VIDEO_WARP_SYMBOL_XSIZE 27
122 #define VIDEO_WARP_SYMBOL_YSIZE VIDEO_SYMBOL_YSIZE
123 #define VIDEO_WARP2_SYMBOL_XPOS VIDEO_SYMBOL_XPOS
124 #define VIDEO_WARP2_SYMBOL_YPOS 152
125 #define VIDEO_WARP2_SYMBOL_XSIZE 27
126 #define VIDEO_WARP2_SYMBOL_YSIZE VIDEO_SYMBOL_YSIZE
128 #define VIDEO_1STEP_SYMBOL_XPOS (VIDEO_SYMBOL_XPOS + 18)
129 #define VIDEO_1STEP_SYMBOL_YPOS 139
130 #define VIDEO_1STEP_SYMBOL_XSIZE (VIDEO_SYMBOL_XSIZE - 18)
131 #define VIDEO_1STEP_SYMBOL_YSIZE VIDEO_SYMBOL_YSIZE
133 #define PG_X3(x) (DOOR_GFX_PAGEX3 + (x))
134 #define PG_X4(x) (DOOR_GFX_PAGEX4 + (x))
135 #define PG_X5(x) (DOOR_GFX_PAGEX5 + (x))
136 #define PG_X6(x) (DOOR_GFX_PAGEX6 + (x))
138 #define PG_Y1(y) (DOOR_GFX_PAGEY1 + (y))
139 #define PG_Y2(y) (DOOR_GFX_PAGEY2 + (y))
141 #define VIDEO_INFO_OFF (VIDEO_STATE_DATE_OFF | \
142 VIDEO_STATE_TIME_OFF)
143 #define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \
144 VIDEO_STATE_REC_OFF | \
145 VIDEO_STATE_PAUSE_OFF | \
146 VIDEO_STATE_FFWD_OFF | \
147 VIDEO_STATE_PBEND_OFF | \
148 VIDEO_STATE_1STEP_OFF)
149 #define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \
150 VIDEO_PRESS_REC_OFF | \
151 VIDEO_PRESS_PAUSE_OFF | \
152 VIDEO_PRESS_STOP_OFF | \
153 VIDEO_PRESS_EJECT_OFF)
154 #define VIDEO_ALL_OFF (VIDEO_INFO_OFF | \
158 #define VIDEO_INFO_ON (VIDEO_STATE_DATE_ON | \
160 #define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \
161 VIDEO_STATE_REC_ON | \
162 VIDEO_STATE_PAUSE_ON | \
163 VIDEO_STATE_FFWD_ON | \
164 VIDEO_STATE_PBEND_ON | \
165 VIDEO_STATE_1STEP_ON)
166 #define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \
167 VIDEO_PRESS_REC_ON | \
168 VIDEO_PRESS_PAUSE_ON | \
169 VIDEO_PRESS_STOP_ON | \
170 VIDEO_PRESS_EJECT_ON)
171 #define VIDEO_ALL_ON (VIDEO_INFO_ON | \
175 #define VIDEO_INFO (VIDEO_INFO_ON | VIDEO_INFO_OFF)
176 #define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF)
177 #define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
178 #define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF)
180 #define NUM_TAPE_FUNCTIONS 10
181 #define NUM_TAPE_FUNCTION_PARTS 2
182 #define NUM_TAPE_FUNCTION_STATES 2
185 /* ========================================================================= */
186 /* video display functions */
187 /* ========================================================================= */
189 void DrawVideoDisplay(unsigned int state, unsigned int value)
192 static char *monatsname[12] =
194 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
195 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
206 video_pos[NUM_TAPE_FUNCTIONS][NUM_TAPE_FUNCTION_PARTS] =
210 PG_X4(VIDEO_PLAY_LABEL_XPOS), PG_Y2(VIDEO_PLAY_LABEL_YPOS),
211 PG_X3(VIDEO_PLAY_LABEL_XPOS), PG_Y2(VIDEO_PLAY_LABEL_YPOS),
212 VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
213 VIDEO_PLAY_LABEL_XSIZE, VIDEO_PLAY_LABEL_YSIZE
216 PG_X4(VIDEO_PLAY_SYMBOL_XPOS), PG_Y2(VIDEO_PLAY_SYMBOL_YPOS),
217 PG_X3(VIDEO_PLAY_SYMBOL_XPOS), PG_Y2(VIDEO_PLAY_SYMBOL_YPOS),
218 VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
219 VIDEO_PLAY_SYMBOL_XSIZE, VIDEO_PLAY_SYMBOL_YSIZE
224 PG_X4(VIDEO_REC_LABEL_XPOS), PG_Y2(VIDEO_REC_LABEL_YPOS),
225 PG_X3(VIDEO_REC_LABEL_XPOS), PG_Y2(VIDEO_REC_LABEL_YPOS),
226 VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
227 VIDEO_REC_LABEL_XSIZE, VIDEO_REC_LABEL_YSIZE
230 PG_X4(VIDEO_REC_SYMBOL_XPOS), PG_Y2(VIDEO_REC_SYMBOL_YPOS),
231 PG_X3(VIDEO_REC_SYMBOL_XPOS), PG_Y2(VIDEO_REC_SYMBOL_YPOS),
232 VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
233 VIDEO_REC_SYMBOL_XSIZE, VIDEO_REC_SYMBOL_YSIZE
238 PG_X4(VIDEO_PAUSE_LABEL_XPOS), PG_Y2(VIDEO_PAUSE_LABEL_YPOS),
239 PG_X3(VIDEO_PAUSE_LABEL_XPOS), PG_Y2(VIDEO_PAUSE_LABEL_YPOS),
240 VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
241 VIDEO_PAUSE_LABEL_XSIZE, VIDEO_PAUSE_LABEL_YSIZE
244 PG_X4(VIDEO_PAUSE_SYMBOL_XPOS), PG_Y2(VIDEO_PAUSE_SYMBOL_YPOS),
245 PG_X3(VIDEO_PAUSE_SYMBOL_XPOS), PG_Y2(VIDEO_PAUSE_SYMBOL_YPOS),
246 VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
247 VIDEO_PAUSE_SYMBOL_XSIZE, VIDEO_PAUSE_SYMBOL_YSIZE
252 PG_X4(VIDEO_DATE_LABEL_XPOS), PG_Y2(VIDEO_DATE_LABEL_YPOS),
253 PG_X3(VIDEO_DATE_LABEL_XPOS), PG_Y2(VIDEO_DATE_LABEL_YPOS),
254 VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
255 VIDEO_DATE_LABEL_XSIZE, VIDEO_DATE_LABEL_YSIZE
258 PG_X4(VIDEO_DATE_XPOS), PG_Y2(VIDEO_DATE_YPOS),
259 PG_X3(VIDEO_DATE_XPOS), PG_Y2(VIDEO_DATE_YPOS),
260 VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
261 VIDEO_DATE_XSIZE, VIDEO_DATE_YSIZE
272 PG_X4(VIDEO_TIME_XPOS), PG_Y2(VIDEO_TIME_YPOS),
273 PG_X3(VIDEO_TIME_XPOS), PG_Y2(VIDEO_TIME_YPOS),
274 VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
275 VIDEO_TIME_XSIZE, VIDEO_TIME_YSIZE
280 PG_X6(VIDEO_FFWD_LABEL_XPOS), PG_Y1(VIDEO_FFWD_LABEL_YPOS),
281 PG_X3(VIDEO_LABEL_XPOS), PG_Y2(VIDEO_LABEL_YPOS),
282 VIDEO_LABEL_XPOS, VIDEO_LABEL_YPOS,
283 VIDEO_LABEL_XSIZE, VIDEO_LABEL_YSIZE
286 PG_X6(VIDEO_FFWD_SYMBOL_XPOS), PG_Y1(VIDEO_FFWD_SYMBOL_YPOS),
287 PG_X3(VIDEO_FFWD_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
288 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
289 VIDEO_FFWD_SYMBOL_XSIZE, VIDEO_FFWD_SYMBOL_YSIZE
294 PG_X6(VIDEO_PBEND_LABEL_XPOS), PG_Y1(VIDEO_PBEND_LABEL_YPOS),
295 PG_X3(VIDEO_LABEL_XPOS), PG_Y2(VIDEO_LABEL_YPOS),
296 VIDEO_LABEL_XPOS, VIDEO_LABEL_YPOS,
297 VIDEO_LABEL_XSIZE, VIDEO_LABEL_YSIZE
300 PG_X6(VIDEO_PBEND_SYMBOL_XPOS), PG_Y1(VIDEO_PBEND_SYMBOL_YPOS),
301 PG_X3(VIDEO_PBEND_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
302 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
303 VIDEO_PBEND_SYMBOL_XSIZE, VIDEO_PBEND_SYMBOL_YSIZE
308 PG_X6(VIDEO_WARP_LABEL_XPOS), PG_Y1(VIDEO_WARP_LABEL_YPOS),
309 PG_X3(VIDEO_LABEL_XPOS), PG_Y2(VIDEO_LABEL_YPOS),
310 VIDEO_LABEL_XPOS, VIDEO_LABEL_YPOS,
311 VIDEO_LABEL_XSIZE, VIDEO_LABEL_YSIZE
314 PG_X6(VIDEO_WARP_SYMBOL_XPOS), PG_Y1(VIDEO_WARP_SYMBOL_YPOS),
315 PG_X3(VIDEO_WARP_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
316 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
317 VIDEO_WARP_SYMBOL_XSIZE, VIDEO_WARP_SYMBOL_YSIZE
328 PG_X6(VIDEO_WARP2_SYMBOL_XPOS), PG_Y1(VIDEO_WARP2_SYMBOL_YPOS),
329 PG_X3(VIDEO_WARP2_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
330 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
331 VIDEO_WARP2_SYMBOL_XSIZE, VIDEO_WARP2_SYMBOL_YSIZE
342 PG_X6(VIDEO_1STEP_SYMBOL_XPOS), PG_Y1(VIDEO_1STEP_SYMBOL_YPOS),
343 PG_X3(VIDEO_1STEP_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
344 VIDEO_1STEP_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
345 VIDEO_1STEP_SYMBOL_XSIZE, VIDEO_1STEP_SYMBOL_YSIZE
357 video_pos[NUM_TAPE_FUNCTIONS][NUM_TAPE_FUNCTION_PARTS] =
360 { IMG_TAPE_LABEL_GFX_PLAY, &tape.label.play },
361 { IMG_TAPE_SYMBOL_GFX_PLAY, &tape.symbol.play },
364 { IMG_TAPE_LABEL_GFX_RECORD, &tape.label.record },
365 { IMG_TAPE_SYMBOL_GFX_RECORD, &tape.symbol.record },
368 { IMG_TAPE_LABEL_GFX_PAUSE, &tape.label.pause },
369 { IMG_TAPE_SYMBOL_GFX_PAUSE, &tape.symbol.pause },
372 { IMG_TAPE_LABEL_GFX_DATE, &tape.label.date },
376 { IMG_TAPE_LABEL_GFX_TIME, &tape.label.time },
380 { IMG_TAPE_LABEL_GFX_FAST_FORWARD, &tape.label.fast_forward },
381 { IMG_TAPE_SYMBOL_GFX_FAST_FORWARD, &tape.symbol.fast_forward },
384 { IMG_TAPE_LABEL_GFX_PAUSE_BEFORE_END, &tape.label.pause_before_end },
385 { IMG_TAPE_SYMBOL_GFX_PAUSE_BEFORE_END, &tape.symbol.pause_before_end },
388 { IMG_TAPE_LABEL_GFX_WARP_FORWARD_BLIND, &tape.label.warp_forward_blind},
389 { IMG_TAPE_SYMBOL_GFX_WARP_FORWARD_BLIND, &tape.symbol.warp_forward_blind},
392 { IMG_TAPE_LABEL_GFX_WARP_FORWARD, &tape.label.warp_forward },
393 { IMG_TAPE_SYMBOL_GFX_WARP_FORWARD, &tape.symbol.warp_forward },
396 { IMG_TAPE_LABEL_GFX_SINGLE_STEP, &tape.label.single_step },
397 { IMG_TAPE_SYMBOL_GFX_SINGLE_STEP, &tape.symbol.single_step },
401 for (k = 0; k < NUM_TAPE_FUNCTION_STATES; k++) /* on or off states */
403 for (i = 0; i < NUM_TAPE_FUNCTIONS; i++) /* record, play, ... */
405 for (j = 0; j < NUM_TAPE_FUNCTION_PARTS; j++) /* label or symbol */
407 if (video_pos[i][j].graphic == -1 ||
408 video_pos[i][j].pos->x < 0 ||
409 video_pos[i][j].pos->y < 0)
412 if (state & (1 << (i * 2 + k)))
414 struct GraphicInfo *gfx_bg = &graphic_info[IMG_BACKGROUND_TAPE];
415 struct GraphicInfo *gfx = &graphic_info[video_pos[i][j].graphic];
416 struct Rect *pos = video_pos[i][j].pos;
420 (j == 0 ? VIDEO_DISPLAY_SYMBOL_ONLY : VIDEO_DISPLAY_LABEL_ONLY);
422 if (value == skip_value)
427 gd_bitmap = gfx->bitmap;
433 gd_bitmap = gfx_bg->bitmap;
434 gd_x = gfx_bg->src_x + pos->x;
435 gd_y = gfx_bg->src_y + pos->y;
438 /* some tape graphics may be undefined -- only draw if defined */
439 if (gd_bitmap != NULL)
440 BlitBitmap(gd_bitmap, drawto, gd_x, gd_y, gfx->width, gfx->height,
441 VX + pos->x, VY + pos->y);
449 for (k = 0; k < NUM_TAPE_FUNCTION_STATES; k++) /* on or off states */
451 for (i = 0; i < NUM_TAPE_FUNCTIONS; i++) /* record, play, ... */
453 for (j = 0; j < NUM_TAPE_FUNCTION_PARTS; j++) /* label or symbol */
455 if (state & (1 << (i * 2 + k)))
459 (j == 0 ? VIDEO_DISPLAY_SYMBOL_ONLY : VIDEO_DISPLAY_LABEL_ONLY);
463 gd_x = video_pos[i][j].gd_x1;
464 gd_y = video_pos[i][j].gd_y1;
468 gd_x = video_pos[i][j].gd_x2;
469 gd_y = video_pos[i][j].gd_y2;
472 if (video_pos[i][j].x != -1 && value != skip_value)
473 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
475 video_pos[i][j].width,
476 video_pos[i][j].height,
477 VX + video_pos[i][j].x,
478 VY + video_pos[i][j].y);
486 if (state & VIDEO_STATE_DATE_ON)
488 struct TextPosInfo *pos = &tape.text.date;
489 int tag = value % 100;
490 int monat = (value/100) % 100;
491 int jahr = (value/10000);
493 DrawText(VX + pos->x, VY + pos->y, int2str(tag, 2), pos->font);
494 DrawText(VX + pos->x + 27, VY + pos->y, monatsname[monat], pos->font);
495 DrawText(VX + pos->x + 64, VY + pos->y, int2str(jahr, 2), pos->font);
498 if (state & VIDEO_STATE_TIME_ON)
500 struct TextPosInfo *pos = &tape.text.time;
501 int min = value / 60;
502 int sec = value % 60;
504 DrawText(VX + pos->x, VY + pos->y, int2str(min, 2), pos->font);
505 DrawText(VX + pos->x + 27, VY + pos->y, int2str(sec, 2), pos->font);
510 if (state & VIDEO_STATE_DATE_ON)
512 int tag = value % 100;
513 int monat = (value/100) % 100;
514 int jahr = (value/10000);
516 DrawText(VX + VIDEO_DATE_XPOS, VY + VIDEO_DATE_YPOS,
517 int2str(tag, 2), FONT_TAPE_RECORDER);
518 DrawText(VX + VIDEO_DATE_XPOS + 27, VY + VIDEO_DATE_YPOS,
519 monatsname[monat], FONT_TAPE_RECORDER);
520 DrawText(VX + VIDEO_DATE_XPOS + 64, VY + VIDEO_DATE_YPOS,
521 int2str(jahr, 2), FONT_TAPE_RECORDER);
524 if (state & VIDEO_STATE_TIME_ON)
526 int min = value / 60;
527 int sec = value % 60;
529 DrawText(VX + VIDEO_TIME_XPOS, VY + VIDEO_TIME_YPOS,
530 int2str(min, 2), FONT_TAPE_RECORDER);
531 DrawText(VX + VIDEO_TIME_XPOS + 27, VY + VIDEO_TIME_YPOS,
532 int2str(sec, 2), FONT_TAPE_RECORDER);
536 redraw_mask |= REDRAW_DOOR_2;
539 void DrawCompleteVideoDisplay()
542 printf("::: %d, %d / %d, %d [%d] [%d, %d] [%d/%d]\n",
543 VX, VY, EX, EY, game_status, gfx.vx, gfx.vy,
544 tape.date, tape.length);
549 struct GraphicInfo *g_tape = &graphic_info[IMG_BACKGROUND_TAPE];
551 /* draw tape background */
552 BlitBitmap(g_tape->bitmap, drawto, g_tape->src_x, g_tape->src_y,
553 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
555 /* draw tape buttons (forced) */
562 struct GraphicInfo *g_tape = &graphic_info[IMG_BACKGROUND_TAPE];
563 int tape_button_graphics[] =
565 IMG_TAPE_BUTTON_GFX_EJECT,
566 IMG_TAPE_BUTTON_GFX_STOP,
567 IMG_TAPE_BUTTON_GFX_PAUSE,
568 IMG_TAPE_BUTTON_GFX_RECORD,
569 IMG_TAPE_BUTTON_GFX_PLAY
571 struct Rect *tape_button_positions[] =
581 BlitBitmap(g_tape->bitmap, drawto, g_tape->src_x, g_tape->src_y,
582 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
584 for (i = 0; i < SIZEOF_ARRAY_INT(tape_button_graphics); i++)
586 struct GraphicInfo *g = &graphic_info[tape_button_graphics[i]];
587 struct Rect *pos = tape_button_positions[i];
589 BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y,
590 g->width, g->height, gfx.vx + pos->x, gfx.vy + pos->y);
593 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
594 DOOR_GFX_PAGEX3, DOOR_GFX_PAGEY2,
595 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
596 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
597 DOOR_GFX_PAGEX4 + VIDEO_CONTROL_XPOS,
598 DOOR_GFX_PAGEY2 + VIDEO_CONTROL_YPOS,
599 VIDEO_CONTROL_XSIZE, VIDEO_CONTROL_YSIZE,
600 gfx.vx + VIDEO_CONTROL_XPOS, gfx.vy + VIDEO_CONTROL_YPOS);
605 DrawVideoDisplay(VIDEO_ALL_OFF, 0);
610 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
611 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
612 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
615 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, 0);
617 else if (tape.playing)
619 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
620 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
621 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
624 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, 0);
626 else if (tape.date && tape.length)
628 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
629 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
632 if (tape.date && tape.length)
634 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
635 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
640 BlitBitmap(drawto, bitmap_db_door_2, gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
643 BlitBitmap(drawto, bitmap_db_door, gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
644 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
648 void TapeDeactivateDisplayOn()
650 SetDrawDeactivationMask(REDRAW_FIELD);
651 audio.sound_deactivated = TRUE;
654 void TapeDeactivateDisplayOff(boolean redraw_display)
656 SetDrawDeactivationMask(REDRAW_NONE);
657 audio.sound_deactivated = FALSE;
661 RedrawPlayfield(TRUE, 0,0,0,0);
662 DrawGameDoorValues();
667 /* ========================================================================= */
668 /* tape control functions */
669 /* ========================================================================= */
671 void TapeSetDateFromEpochSeconds(time_t epoch_seconds)
673 struct tm *lt = localtime(&epoch_seconds);
675 tape.date = 10000 * (lt->tm_year % 100) + 100 * lt->tm_mon + lt->tm_mday;
678 void TapeSetDateFromNow()
680 TapeSetDateFromEpochSeconds(time(NULL));
689 tape.length_seconds = 0;
691 if (leveldir_current)
692 setString(&tape.level_identifier, leveldir_current->identifier);
694 tape.level_nr = level_nr;
695 tape.pos[tape.counter].delay = 0;
698 tape.random_seed = InitRND(level.random_seed);
700 tape.file_version = FILE_VERSION_ACTUAL;
701 tape.game_version = GAME_VERSION_ACTUAL;
702 tape.engine_version = level.game_version;
704 TapeSetDateFromNow();
706 for (i = 0; i < MAX_PLAYERS; i++)
707 tape.player_participates[i] = FALSE;
709 tape.centered_player_nr_next = -1;
710 tape.set_centered_player = FALSE;
713 static void TapeRewind()
716 tape.delay_played = 0;
717 tape.pause_before_death = FALSE;
718 tape.recording = FALSE;
719 tape.playing = FALSE;
720 tape.fast_forward = FALSE;
721 tape.warp_forward = FALSE;
722 tape.deactivate_display = FALSE;
723 tape.auto_play = (global.autoplay_leveldir != NULL);
724 tape.auto_play_level_solved = FALSE;
725 tape.quick_resume = FALSE;
726 tape.single_step = FALSE;
728 tape.centered_player_nr_next = -1;
729 tape.set_centered_player = FALSE;
731 InitRND(tape.random_seed);
734 static void TapeSetRandomSeed(int random_seed)
736 tape.random_seed = InitRND(random_seed);
739 void TapeStartRecording(int random_seed)
741 if (!TAPE_IS_STOPPED(tape))
746 TapeSetRandomSeed(random_seed);
748 tape.recording = TRUE;
750 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
751 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
752 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
756 SetDrawDeactivationMask(REDRAW_NONE);
757 audio.sound_deactivated = FALSE;
760 static void TapeStartGameRecording()
762 TapeStartRecording(level.random_seed);
764 #if defined(NETWORK_AVALIABLE)
767 SendToServer_StartPlaying();
776 static void TapeAppendRecording()
778 if (!tape.playing || !tape.pausing)
781 tape.pos[tape.counter].delay = tape.delay_played;
782 tape.playing = FALSE;
783 tape.recording = TRUE;
786 TapeSetDateFromNow();
788 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
789 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON, 0);
792 UpdateAndDisplayGameControlValues();
796 void TapeHaltRecording()
802 tape.pos[tape.counter].delay = 0;
804 tape.length = tape.counter;
805 tape.length_seconds = GetTapeLength();
808 void TapeStopRecording()
812 tape.recording = FALSE;
813 tape.pausing = FALSE;
815 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
816 MapTapeEjectButton();
819 void TapeRecordAction(byte action_raw[MAX_PLAYERS])
821 byte action[MAX_PLAYERS];
824 if (!tape.recording) /* (record action even when tape is paused) */
827 if (tape.counter >= MAX_TAPE_LEN - 1)
833 for (i = 0; i < MAX_PLAYERS; i++)
834 action[i] = action_raw[i];
836 if (tape.set_centered_player)
838 for (i = 0; i < MAX_PLAYERS; i++)
839 if (tape.centered_player_nr_next == i ||
840 tape.centered_player_nr_next == -1)
841 action[i] |= KEY_SET_FOCUS;
843 tape.set_centered_player = FALSE;
846 if (tape.pos[tape.counter].delay > 0) /* already stored action */
848 boolean changed_events = FALSE;
850 for (i = 0; i < MAX_PLAYERS; i++)
851 if (tape.pos[tape.counter].action[i] != action[i])
852 changed_events = TRUE;
854 if (changed_events || tape.pos[tape.counter].delay >= 255)
857 tape.pos[tape.counter].delay = 0;
860 tape.pos[tape.counter].delay++;
863 if (tape.pos[tape.counter].delay == 0) /* store new action */
865 for (i = 0; i < MAX_PLAYERS; i++)
866 tape.pos[tape.counter].action[i] = action[i];
868 tape.pos[tape.counter].delay++;
872 void TapeTogglePause(boolean toggle_manual)
876 if (tape.pause_before_death)
877 state |= VIDEO_STATE_PBEND_OFF;
878 else if (tape.fast_forward)
879 state |= VIDEO_STATE_FFWD_OFF;
881 tape.pausing = !tape.pausing;
882 tape.fast_forward = FALSE;
883 tape.pause_before_death = FALSE;
885 if (tape.single_step && toggle_manual)
886 tape.single_step = FALSE;
888 state |= (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
890 state |= VIDEO_STATE_PLAY_ON;
892 state |= (tape.single_step ? VIDEO_STATE_1STEP_ON : VIDEO_STATE_1STEP_OFF);
894 DrawVideoDisplay(state, 0);
896 if (tape.warp_forward)
898 TapeStopWarpForward();
900 if (tape.quick_resume)
902 tape.quick_resume = FALSE;
904 TapeAppendRecording();
906 if (!CheckEngineSnapshot())
907 SaveEngineSnapshot();
912 void TapeStartPlaying()
914 if (TAPE_IS_EMPTY(tape))
917 if (!TAPE_IS_STOPPED(tape))
924 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
925 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
926 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
930 SetDrawDeactivationMask(REDRAW_NONE);
931 audio.sound_deactivated = FALSE;
934 static void TapeStartGamePlaying()
941 void TapeStopPlaying()
943 tape.playing = FALSE;
944 tape.pausing = FALSE;
946 if (tape.warp_forward)
947 TapeStopWarpForward();
949 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
950 MapTapeEjectButton();
953 byte *TapePlayAction()
955 static byte action[MAX_PLAYERS];
958 if (!tape.playing || tape.pausing)
961 if (tape.pause_before_death) /* stop 10 seconds before player gets killed */
963 if (!(FrameCounter % 20))
965 if ((FrameCounter / 20) % 2)
966 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
968 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
971 if (tape.warp_forward)
973 if (tape.deactivate_display)
974 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
976 DrawVideoDisplay(VIDEO_STATE_WARP2_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
979 if (TapeTime > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
981 TapeTogglePause(TAPE_TOGGLE_MANUAL);
986 else if (tape.fast_forward)
988 if ((FrameCounter / 20) % 2)
989 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, VIDEO_DISPLAY_LABEL_ONLY);
991 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF, VIDEO_DISPLAY_LABEL_ONLY);
993 if (tape.warp_forward)
995 if (tape.deactivate_display)
996 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
998 DrawVideoDisplay(VIDEO_STATE_WARP2_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
1003 /* !!! this makes things much slower !!! */
1004 else if (tape.warp_forward)
1006 if ((FrameCounter / 20) % 2)
1007 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_LABEL_ONLY);
1009 DrawVideoDisplay(VIDEO_STATE_WARP_OFF, VIDEO_DISPLAY_LABEL_ONLY);
1011 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
1015 if (tape.counter >= tape.length) /* end of tape reached */
1017 if (tape.warp_forward && !tape.auto_play)
1018 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1025 for (i = 0; i < MAX_PLAYERS; i++)
1026 action[i] = tape.pos[tape.counter].action[i];
1028 tape.set_centered_player = FALSE;
1029 tape.centered_player_nr_next = -999;
1031 for (i = 0; i < MAX_PLAYERS; i++)
1033 if (action[i] & KEY_SET_FOCUS)
1035 tape.set_centered_player = TRUE;
1036 tape.centered_player_nr_next =
1037 (tape.centered_player_nr_next == -999 ? i : -1);
1040 action[i] &= ~KEY_SET_FOCUS;
1043 tape.delay_played++;
1044 if (tape.delay_played >= tape.pos[tape.counter].delay)
1047 tape.delay_played = 0;
1055 TapeStopRecording();
1058 DrawVideoDisplay(VIDEO_STATE_OFF, 0);
1060 if (tape.date && tape.length)
1062 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
1063 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
1067 unsigned int GetTapeLength()
1069 unsigned int tape_length = 0;
1072 if (TAPE_IS_EMPTY(tape))
1075 for (i = 0; i < tape.length; i++)
1076 tape_length += tape.pos[i].delay;
1078 return(tape_length * GAME_FRAME_DELAY / 1000);
1081 static void TapeStartWarpForward()
1083 tape.warp_forward = TRUE;
1085 if (!tape.fast_forward && !tape.pause_before_death)
1087 tape.pausing = FALSE;
1088 tape.deactivate_display = TRUE;
1090 TapeDeactivateDisplayOn();
1093 if (tape.fast_forward || tape.pause_before_death)
1094 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
1096 DrawVideoDisplay(VIDEO_STATE_WARP_ON, 0);
1099 static void TapeStopWarpForward()
1101 int state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
1103 tape.warp_forward = FALSE;
1104 tape.deactivate_display = FALSE;
1106 TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
1108 if (tape.pause_before_death)
1109 state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_PBEND_ON;
1110 else if (tape.fast_forward)
1111 state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_FFWD_ON;
1113 state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_PLAY_ON;
1115 DrawVideoDisplay(state, 0);
1118 static void TapeSingleStep()
1120 if (options.network)
1124 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1126 tape.single_step = !tape.single_step;
1128 DrawVideoDisplay((tape.single_step ? VIDEO_STATE_1STEP_ON :
1129 VIDEO_STATE_1STEP_OFF), 0);
1132 void TapeQuickSave()
1134 if (game_status == GAME_MODE_MAIN)
1136 Request("No game that can be saved!", REQ_CONFIRM);
1141 if (game_status != GAME_MODE_PLAYING)
1145 TapeHaltRecording(); /* prepare tape for saving on-the-fly */
1147 if (TAPE_IS_EMPTY(tape))
1149 Request("No tape that can be saved!", REQ_CONFIRM);
1154 if (SaveTapeChecked(tape.level_nr))
1155 SaveEngineSnapshot();
1158 void TapeQuickLoad()
1160 char *filename = getTapeFilename(level_nr);
1162 if (!fileExists(filename))
1164 Request("No tape for this level!", REQ_CONFIRM);
1169 if (tape.recording && !Request("Stop recording and load tape?",
1170 REQ_ASK | REQ_STAY_CLOSED))
1172 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
1177 if (game_status != GAME_MODE_PLAYING && game_status != GAME_MODE_MAIN)
1180 if (CheckEngineSnapshot())
1183 printf("::: MARK 1\n");
1186 TapeStartGamePlaying();
1188 LoadEngineSnapshot();
1190 DrawCompleteVideoDisplay();
1192 tape.playing = TRUE;
1193 tape.pausing = TRUE;
1195 TapeStopWarpForward();
1196 TapeAppendRecording();
1198 if (FrameCounter > 0)
1203 printf("::: MARK 2\n");
1211 if (!TAPE_IS_EMPTY(tape))
1213 TapeStartGamePlaying();
1214 TapeStartWarpForward();
1216 tape.quick_resume = TRUE;
1218 else /* this should not happen (basically checked above) */
1220 int reopen_door = (game_status == GAME_MODE_PLAYING ? REQ_REOPEN : 0);
1222 Request("No tape for this level!", REQ_CONFIRM | reopen_door);
1226 void InsertSolutionTape()
1228 if (!TAPE_IS_EMPTY(tape))
1231 LoadSolutionTape(level_nr);
1233 if (TAPE_IS_EMPTY(tape))
1234 Request("No solution tape for this level!", REQ_CONFIRM);
1236 DrawCompleteVideoDisplay();
1240 /* ------------------------------------------------------------------------- *
1241 * tape autoplay functions
1242 * ------------------------------------------------------------------------- */
1246 static LevelDirTree *autoplay_leveldir = NULL;
1247 static boolean autoplay_initialized = FALSE;
1248 static int autoplay_level_nr = -1;
1249 static int num_levels_played = 0;
1250 static int num_levels_solved = 0;
1251 static int num_tape_missing = 0;
1252 static boolean level_failed[MAX_TAPES_PER_SET];
1254 static boolean tape_missing[MAX_TAPES_PER_SET];
1258 if (autoplay_initialized)
1260 /* just finished auto-playing tape */
1261 printf("%s.\n", tape.auto_play_level_solved ? "solved" : "NOT SOLVED");
1263 num_levels_played++;
1265 if (tape.auto_play_level_solved)
1266 num_levels_solved++;
1267 else if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
1268 level_failed[level_nr] = TRUE;
1272 DrawCompleteVideoDisplay();
1273 audio.sound_enabled = FALSE;
1275 autoplay_leveldir = getTreeInfoFromIdentifier(leveldir_first,
1276 global.autoplay_leveldir);
1278 if (autoplay_leveldir == NULL)
1279 Error(ERR_EXIT, "no such level identifier: '%s'",
1280 global.autoplay_leveldir);
1282 leveldir_current = autoplay_leveldir;
1284 if (autoplay_leveldir->first_level < 0)
1285 autoplay_leveldir->first_level = 0;
1286 if (autoplay_leveldir->last_level >= MAX_TAPES_PER_SET)
1287 autoplay_leveldir->last_level = MAX_TAPES_PER_SET - 1;
1289 autoplay_level_nr = autoplay_leveldir->first_level;
1291 printf_line("=", 79);
1292 printf("Automatically playing level tapes\n");
1293 printf_line("-", 79);
1294 printf("Level series identifier: '%s'\n", autoplay_leveldir->identifier);
1295 printf("Level series name: '%s'\n", autoplay_leveldir->name);
1296 printf("Level series author: '%s'\n", autoplay_leveldir->author);
1297 printf("Number of levels: %d\n", autoplay_leveldir->levels);
1298 printf_line("=", 79);
1301 for (i = 0; i < MAX_TAPES_PER_SET; i++)
1303 level_failed[i] = FALSE;
1305 tape_missing[i] = FALSE;
1309 autoplay_initialized = TRUE;
1312 while (autoplay_level_nr <= autoplay_leveldir->last_level)
1314 level_nr = autoplay_level_nr++;
1316 if (!global.autoplay_all && !global.autoplay_level[level_nr])
1321 printf("Level %03d: ", level_nr);
1323 LoadLevel(level_nr);
1324 if (level.no_valid_file)
1326 printf("(no level)\n");
1331 /* ACTIVATE THIS FOR LOADING/TESTING OF LEVELS ONLY */
1332 printf("(only testing level)\n");
1336 LoadSolutionTape(level_nr);
1338 if (tape.no_valid_file)
1342 if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
1343 tape_missing[level_nr] = TRUE;
1346 printf("(no tape)\n");
1350 printf("playing tape ... ");
1352 TapeStartGamePlaying();
1353 TapeStartWarpForward();
1359 printf_line("=", 79);
1360 printf("Number of levels played: %d\n", num_levels_played);
1361 printf("Number of levels solved: %d (%d%%)\n", num_levels_solved,
1362 (num_levels_played ? num_levels_solved * 100 / num_levels_played :0));
1363 printf_line("-", 79);
1364 printf("Summary (for automatic parsing by scripts):\n");
1365 printf("LEVELDIR '%s', SOLVED %d/%d (%d%%)",
1366 autoplay_leveldir->identifier, num_levels_solved, num_levels_played,
1367 (num_levels_played ? num_levels_solved * 100 / num_levels_played :0));
1369 if (num_levels_played != num_levels_solved)
1371 printf(", FAILED:");
1372 for (i = 0; i < MAX_TAPES_PER_SET; i++)
1373 if (level_failed[i])
1378 if (num_tape_missing > 0)
1380 printf(", NO TAPE:");
1381 for (i = 0; i < MAX_TAPES_PER_SET; i++)
1382 if (tape_missing[i])
1388 printf_line("=", 79);
1394 /* ---------- new tape button stuff ---------------------------------------- */
1402 } tapebutton_info[NUM_TAPE_BUTTONS] =
1405 IMG_TAPE_BUTTON_GFX_EJECT, &tape.button.eject,
1406 TAPE_CTRL_ID_EJECT, "eject tape"
1409 /* (same position as "eject" button) */
1410 IMG_TAPE_BUTTON_GFX_EXTRA, &tape.button.eject,
1411 TAPE_CTRL_ID_EXTRA, "extra functions"
1414 IMG_TAPE_BUTTON_GFX_STOP, &tape.button.stop,
1415 TAPE_CTRL_ID_STOP, "stop tape"
1418 IMG_TAPE_BUTTON_GFX_PAUSE, &tape.button.pause,
1419 TAPE_CTRL_ID_PAUSE, "pause tape"
1422 IMG_TAPE_BUTTON_GFX_RECORD, &tape.button.record,
1423 TAPE_CTRL_ID_RECORD, "record tape"
1426 IMG_TAPE_BUTTON_GFX_PLAY, &tape.button.play,
1427 TAPE_CTRL_ID_PLAY, "play tape"
1431 void CreateTapeButtons()
1435 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1437 struct GraphicInfo *gfx = &graphic_info[tapebutton_info[i].graphic];
1438 struct Rect *pos = tapebutton_info[i].pos;
1439 struct GadgetInfo *gi;
1440 int gd_x = gfx->src_x;
1441 int gd_y = gfx->src_y;
1442 int gd_xp = gfx->src_x + gfx->pressed_xoffset;
1443 int gd_yp = gfx->src_y + gfx->pressed_yoffset;
1446 gi = CreateGadget(GDI_CUSTOM_ID, id,
1447 GDI_INFO_TEXT, tapebutton_info[i].infotext,
1450 GDI_WIDTH, gfx->width,
1451 GDI_HEIGHT, gfx->height,
1452 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
1453 GDI_STATE, GD_BUTTON_UNPRESSED,
1454 GDI_DESIGN_UNPRESSED, gfx->bitmap, gd_x, gd_y,
1455 GDI_DESIGN_PRESSED, gfx->bitmap, gd_xp, gd_yp,
1456 GDI_DIRECT_DRAW, FALSE,
1457 GDI_EVENT_MASK, GD_EVENT_RELEASED,
1458 GDI_CALLBACK_ACTION, HandleTapeButtons,
1462 Error(ERR_EXIT, "cannot create gadget");
1464 tape_gadget[id] = gi;
1468 void FreeTapeButtons()
1472 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1473 FreeGadget(tape_gadget[i]);
1476 void MapTapeEjectButton()
1478 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EXTRA]);
1479 MapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
1482 void MapTapeWarpButton()
1484 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
1485 MapGadget(tape_gadget[TAPE_CTRL_ID_EXTRA]);
1488 void MapTapeButtons()
1492 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1493 if (i != TAPE_CTRL_ID_EXTRA)
1494 MapGadget(tape_gadget[i]);
1496 if (tape.recording || tape.playing)
1497 MapTapeWarpButton();
1499 if (tape.show_game_buttons)
1503 void UnmapTapeButtons()
1507 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1508 UnmapGadget(tape_gadget[i]);
1511 static void HandleTapeButtonsExt(int id)
1513 if (game_status != GAME_MODE_MAIN && game_status != GAME_MODE_PLAYING)
1518 case TAPE_CTRL_ID_EJECT:
1521 if (TAPE_IS_EMPTY(tape))
1525 if (TAPE_IS_EMPTY(tape))
1526 Request("No tape for this level!", REQ_CONFIRM);
1531 SaveTapeChecked(tape.level_nr);
1536 DrawCompleteVideoDisplay();
1539 case TAPE_CTRL_ID_EXTRA:
1542 if (!tape.warp_forward) /* PLAY -> WARP FORWARD PLAY */
1544 TapeStartWarpForward();
1546 else /* WARP FORWARD PLAY -> PLAY */
1548 TapeStopWarpForward();
1551 else if (tape.recording)
1556 case TAPE_CTRL_ID_STOP:
1560 case TAPE_CTRL_ID_PAUSE:
1561 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1564 case TAPE_CTRL_ID_RECORD:
1565 if (TAPE_IS_STOPPED(tape))
1566 TapeStartGameRecording();
1567 else if (tape.pausing)
1569 if (tape.playing) /* PLAY -> PAUSE -> RECORD */
1570 TapeAppendRecording();
1572 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1576 case TAPE_CTRL_ID_PLAY:
1577 if (TAPE_IS_EMPTY(tape))
1580 if (TAPE_IS_STOPPED(tape))
1582 TapeStartGamePlaying();
1584 else if (tape.playing)
1586 if (tape.pausing) /* PAUSE -> PLAY */
1588 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1590 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
1592 tape.fast_forward = TRUE;
1593 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
1595 else if (!tape.pause_before_death) /* FFWD PLAY -> AUTO PAUSE */
1597 tape.pause_before_death = TRUE;
1598 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_ON, 0);
1600 else /* AUTO PAUSE -> NORMAL PLAY */
1602 if (tape.warp_forward)
1603 TapeStopWarpForward();
1605 tape.fast_forward = FALSE;
1606 tape.pause_before_death = FALSE;
1608 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF | VIDEO_STATE_PLAY_ON, 0);
1618 static void HandleTapeButtons(struct GadgetInfo *gi)
1620 HandleTapeButtonsExt(gi->custom_id);
1623 void HandleTapeButtonKeys(Key key)
1625 boolean eject_button_is_active = TAPE_IS_STOPPED(tape);
1626 boolean extra_button_is_active = !eject_button_is_active;
1628 if (key == setup.shortcut.tape_eject && eject_button_is_active)
1629 HandleTapeButtonsExt(TAPE_CTRL_ID_EJECT);
1630 else if (key == setup.shortcut.tape_extra && extra_button_is_active)
1631 HandleTapeButtonsExt(TAPE_CTRL_ID_EXTRA);
1632 else if (key == setup.shortcut.tape_stop)
1633 HandleTapeButtonsExt(TAPE_CTRL_ID_STOP);
1634 else if (key == setup.shortcut.tape_pause)
1635 HandleTapeButtonsExt(TAPE_CTRL_ID_PAUSE);
1636 else if (key == setup.shortcut.tape_record)
1637 HandleTapeButtonsExt(TAPE_CTRL_ID_RECORD);
1638 else if (key == setup.shortcut.tape_play)
1639 HandleTapeButtonsExt(TAPE_CTRL_ID_PLAY);