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"
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 long state, unsigned long value)
192 static char *monatsname[12] =
194 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
195 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
204 video_pos[NUM_TAPE_FUNCTIONS][NUM_TAPE_FUNCTION_PARTS] =
208 PG_X4(VIDEO_PLAY_LABEL_XPOS), PG_Y2(VIDEO_PLAY_LABEL_YPOS),
209 PG_X3(VIDEO_PLAY_LABEL_XPOS), PG_Y2(VIDEO_PLAY_LABEL_YPOS),
210 VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
211 VIDEO_PLAY_LABEL_XSIZE, VIDEO_PLAY_LABEL_YSIZE
214 PG_X4(VIDEO_PLAY_SYMBOL_XPOS), PG_Y2(VIDEO_PLAY_SYMBOL_YPOS),
215 PG_X3(VIDEO_PLAY_SYMBOL_XPOS), PG_Y2(VIDEO_PLAY_SYMBOL_YPOS),
216 VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
217 VIDEO_PLAY_SYMBOL_XSIZE, VIDEO_PLAY_SYMBOL_YSIZE
222 PG_X4(VIDEO_REC_LABEL_XPOS), PG_Y2(VIDEO_REC_LABEL_YPOS),
223 PG_X3(VIDEO_REC_LABEL_XPOS), PG_Y2(VIDEO_REC_LABEL_YPOS),
224 VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
225 VIDEO_REC_LABEL_XSIZE, VIDEO_REC_LABEL_YSIZE
228 PG_X4(VIDEO_REC_SYMBOL_XPOS), PG_Y2(VIDEO_REC_SYMBOL_YPOS),
229 PG_X3(VIDEO_REC_SYMBOL_XPOS), PG_Y2(VIDEO_REC_SYMBOL_YPOS),
230 VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
231 VIDEO_REC_SYMBOL_XSIZE, VIDEO_REC_SYMBOL_YSIZE
236 PG_X4(VIDEO_PAUSE_LABEL_XPOS), PG_Y2(VIDEO_PAUSE_LABEL_YPOS),
237 PG_X3(VIDEO_PAUSE_LABEL_XPOS), PG_Y2(VIDEO_PAUSE_LABEL_YPOS),
238 VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
239 VIDEO_PAUSE_LABEL_XSIZE, VIDEO_PAUSE_LABEL_YSIZE
242 PG_X4(VIDEO_PAUSE_SYMBOL_XPOS), PG_Y2(VIDEO_PAUSE_SYMBOL_YPOS),
243 PG_X3(VIDEO_PAUSE_SYMBOL_XPOS), PG_Y2(VIDEO_PAUSE_SYMBOL_YPOS),
244 VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
245 VIDEO_PAUSE_SYMBOL_XSIZE, VIDEO_PAUSE_SYMBOL_YSIZE
250 PG_X4(VIDEO_DATE_LABEL_XPOS), PG_Y2(VIDEO_DATE_LABEL_YPOS),
251 PG_X3(VIDEO_DATE_LABEL_XPOS), PG_Y2(VIDEO_DATE_LABEL_YPOS),
252 VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
253 VIDEO_DATE_LABEL_XSIZE, VIDEO_DATE_LABEL_YSIZE
256 PG_X4(VIDEO_DATE_XPOS), PG_Y2(VIDEO_DATE_YPOS),
257 PG_X3(VIDEO_DATE_XPOS), PG_Y2(VIDEO_DATE_YPOS),
258 VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
259 VIDEO_DATE_XSIZE, VIDEO_DATE_YSIZE
270 PG_X4(VIDEO_TIME_XPOS), PG_Y2(VIDEO_TIME_YPOS),
271 PG_X3(VIDEO_TIME_XPOS), PG_Y2(VIDEO_TIME_YPOS),
272 VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
273 VIDEO_TIME_XSIZE, VIDEO_TIME_YSIZE
278 PG_X6(VIDEO_FFWD_LABEL_XPOS), PG_Y1(VIDEO_FFWD_LABEL_YPOS),
279 PG_X3(VIDEO_LABEL_XPOS), PG_Y2(VIDEO_LABEL_YPOS),
280 VIDEO_LABEL_XPOS, VIDEO_LABEL_YPOS,
281 VIDEO_LABEL_XSIZE, VIDEO_LABEL_YSIZE
284 PG_X6(VIDEO_FFWD_SYMBOL_XPOS), PG_Y1(VIDEO_FFWD_SYMBOL_YPOS),
285 PG_X3(VIDEO_FFWD_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
286 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
287 VIDEO_FFWD_SYMBOL_XSIZE, VIDEO_FFWD_SYMBOL_YSIZE
292 PG_X6(VIDEO_PBEND_LABEL_XPOS), PG_Y1(VIDEO_PBEND_LABEL_YPOS),
293 PG_X3(VIDEO_LABEL_XPOS), PG_Y2(VIDEO_LABEL_YPOS),
294 VIDEO_LABEL_XPOS, VIDEO_LABEL_YPOS,
295 VIDEO_LABEL_XSIZE, VIDEO_LABEL_YSIZE
298 PG_X6(VIDEO_PBEND_SYMBOL_XPOS), PG_Y1(VIDEO_PBEND_SYMBOL_YPOS),
299 PG_X3(VIDEO_PBEND_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
300 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
301 VIDEO_PBEND_SYMBOL_XSIZE, VIDEO_PBEND_SYMBOL_YSIZE
306 PG_X6(VIDEO_WARP_LABEL_XPOS), PG_Y1(VIDEO_WARP_LABEL_YPOS),
307 PG_X3(VIDEO_LABEL_XPOS), PG_Y2(VIDEO_LABEL_YPOS),
308 VIDEO_LABEL_XPOS, VIDEO_LABEL_YPOS,
309 VIDEO_LABEL_XSIZE, VIDEO_LABEL_YSIZE
312 PG_X6(VIDEO_WARP_SYMBOL_XPOS), PG_Y1(VIDEO_WARP_SYMBOL_YPOS),
313 PG_X3(VIDEO_WARP_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
314 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
315 VIDEO_WARP_SYMBOL_XSIZE, VIDEO_WARP_SYMBOL_YSIZE
326 PG_X6(VIDEO_WARP2_SYMBOL_XPOS), PG_Y1(VIDEO_WARP2_SYMBOL_YPOS),
327 PG_X3(VIDEO_WARP2_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
328 VIDEO_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
329 VIDEO_WARP2_SYMBOL_XSIZE, VIDEO_WARP2_SYMBOL_YSIZE
340 PG_X6(VIDEO_1STEP_SYMBOL_XPOS), PG_Y1(VIDEO_1STEP_SYMBOL_YPOS),
341 PG_X3(VIDEO_1STEP_SYMBOL_XPOS), PG_Y2(VIDEO_SYMBOL_YPOS),
342 VIDEO_1STEP_SYMBOL_XPOS, VIDEO_SYMBOL_YPOS,
343 VIDEO_1STEP_SYMBOL_XSIZE, VIDEO_1STEP_SYMBOL_YSIZE
349 if (state & VIDEO_STATE_FFWD_OFF)
352 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
354 if (value != VIDEO_DISPLAY_SYMBOL_ONLY)
355 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
356 cx + VIDEO_LABEL_XPOS,
357 cy + VIDEO_LABEL_YPOS,
360 VX + VIDEO_LABEL_XPOS,
361 VY + VIDEO_LABEL_YPOS);
363 cx = DOOR_GFX_PAGEX3;
364 cy = DOOR_GFX_PAGEY2;
366 if (value != VIDEO_DISPLAY_LABEL_ONLY)
367 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
368 cx + VIDEO_FFWD_SYMBOL_XPOS,
369 cy + VIDEO_SYMBOL_YPOS,
370 VIDEO_FFWD_SYMBOL_XSIZE,
371 VIDEO_FFWD_SYMBOL_YSIZE,
372 VX + VIDEO_SYMBOL_XPOS,
373 VY + VIDEO_SYMBOL_YPOS);
375 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
377 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
378 cx + VIDEO_PLAY_SYMBOL_XPOS - 9,
379 cy + VIDEO_PLAY_SYMBOL_YPOS,
380 VIDEO_PLAY_SYMBOL_XSIZE - 2,
381 VIDEO_PLAY_SYMBOL_YSIZE,
382 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
383 VY + VIDEO_PLAY_SYMBOL_YPOS);
389 if (state & VIDEO_STATE_PBEND_OFF)
392 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
394 if (value != VIDEO_DISPLAY_SYMBOL_ONLY)
395 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
396 cx + VIDEO_LABEL_XPOS,
397 cy + VIDEO_LABEL_YPOS,
400 VX + VIDEO_LABEL_XPOS,
401 VY + VIDEO_LABEL_YPOS);
403 cx = DOOR_GFX_PAGEX3;
404 cy = DOOR_GFX_PAGEY2;
406 if (value != VIDEO_DISPLAY_LABEL_ONLY)
407 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
408 cx + VIDEO_PBEND_SYMBOL_XPOS,
409 cy + VIDEO_SYMBOL_YPOS,
410 VIDEO_PBEND_SYMBOL_XSIZE,
411 VIDEO_PBEND_SYMBOL_YSIZE,
412 VX + VIDEO_PBEND_SYMBOL_XPOS,
413 VY + VIDEO_SYMBOL_YPOS);
415 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
417 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
418 cx + VIDEO_REC_LABEL_XPOS,
419 cy + VIDEO_REC_LABEL_YPOS,
420 VIDEO_PBEND_LABEL_XSIZE,
421 VIDEO_PBEND_LABEL_YSIZE,
422 VX + VIDEO_REC_LABEL_XPOS,
423 VY + VIDEO_REC_LABEL_YPOS);
429 if (state & VIDEO_STATE_1STEP_OFF)
431 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
433 if (value != VIDEO_DISPLAY_LABEL_ONLY)
434 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
435 cx + VIDEO_1STEP_SYMBOL_XPOS,
436 cy + VIDEO_SYMBOL_YPOS,
437 VIDEO_1STEP_SYMBOL_XSIZE,
438 VIDEO_1STEP_SYMBOL_YSIZE,
439 VX + VIDEO_1STEP_SYMBOL_XPOS,
440 VY + VIDEO_SYMBOL_YPOS);
444 for (k = 0; k < NUM_TAPE_FUNCTION_STATES; k++) /* on or off states */
446 for (i = 0; i < NUM_TAPE_FUNCTIONS; i++) /* record, play, ... */
448 for (j = 0; j < NUM_TAPE_FUNCTION_PARTS; j++) /* label or symbol */
450 if (state & (1 << (i * 2 + k)))
454 (j == 0 ? VIDEO_DISPLAY_SYMBOL_ONLY : VIDEO_DISPLAY_LABEL_ONLY);
458 gd_x = video_pos[i][j].gd_x1;
459 gd_y = video_pos[i][j].gd_y1;
463 gd_x = video_pos[i][j].gd_x2;
464 gd_y = video_pos[i][j].gd_y2;
467 if (video_pos[i][j].x != -1 && value != skip_value)
468 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
470 video_pos[i][j].width,
471 video_pos[i][j].height,
472 VX + video_pos[i][j].x,
473 VY + video_pos[i][j].y);
480 if (state & VIDEO_STATE_FFWD_ON)
483 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
485 if (value != VIDEO_DISPLAY_SYMBOL_ONLY)
486 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
487 cx + VIDEO_FFWD_LABEL_XPOS,
488 cy + VIDEO_FFWD_LABEL_YPOS,
491 VX + VIDEO_LABEL_XPOS,
492 VY + VIDEO_LABEL_YPOS);
494 cx = DOOR_GFX_PAGEX6;
495 cy = DOOR_GFX_PAGEY1;
497 if (value != VIDEO_DISPLAY_LABEL_ONLY)
498 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
499 cx + VIDEO_FFWD_SYMBOL_XPOS,
500 cy + VIDEO_FFWD_SYMBOL_YPOS,
501 VIDEO_FFWD_SYMBOL_XSIZE,
502 VIDEO_FFWD_SYMBOL_YSIZE,
503 VX + VIDEO_SYMBOL_XPOS,
504 VY + VIDEO_SYMBOL_YPOS);
506 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
508 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
509 cx + VIDEO_PLAY_SYMBOL_XPOS,
510 cy + VIDEO_PLAY_SYMBOL_YPOS,
511 VIDEO_PLAY_SYMBOL_XSIZE - 2,
512 VIDEO_PLAY_SYMBOL_YSIZE,
513 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
514 VY + VIDEO_PLAY_SYMBOL_YPOS);
520 if (state & VIDEO_STATE_PBEND_ON)
523 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
525 if (value != VIDEO_DISPLAY_SYMBOL_ONLY)
526 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
527 cx + VIDEO_PBEND_LABEL_XPOS,
528 cy + VIDEO_PBEND_LABEL_YPOS,
531 VX + VIDEO_LABEL_XPOS,
532 VY + VIDEO_LABEL_YPOS);
534 cx = DOOR_GFX_PAGEX6;
535 cy = DOOR_GFX_PAGEY1;
537 if (value != VIDEO_DISPLAY_LABEL_ONLY)
538 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
539 cx + VIDEO_PBEND_SYMBOL_XPOS,
540 cy + VIDEO_PBEND_SYMBOL_YPOS,
541 VIDEO_PBEND_SYMBOL_XSIZE,
542 VIDEO_PBEND_SYMBOL_YSIZE,
543 VX + VIDEO_SYMBOL_XPOS,
544 VY + VIDEO_SYMBOL_YPOS);
546 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
548 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
549 cx + VIDEO_PBEND_LABEL_XPOS,
550 cy + VIDEO_PBEND_LABEL_YPOS,
551 VIDEO_PBEND_LABEL_XSIZE,
552 VIDEO_PBEND_LABEL_YSIZE,
553 VX + VIDEO_REC_LABEL_XPOS,
554 VY + VIDEO_REC_LABEL_YPOS);
560 if (state & VIDEO_STATE_1STEP_ON)
562 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
564 if (value != VIDEO_DISPLAY_LABEL_ONLY)
565 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
566 cx + VIDEO_1STEP_SYMBOL_XPOS,
567 cy + VIDEO_1STEP_SYMBOL_YPOS,
568 VIDEO_1STEP_SYMBOL_XSIZE,
569 VIDEO_1STEP_SYMBOL_YSIZE,
570 VX + VIDEO_1STEP_SYMBOL_XPOS,
571 VY + VIDEO_SYMBOL_YPOS);
575 if (state & VIDEO_STATE_DATE_ON)
577 int tag = value % 100;
578 int monat = (value/100) % 100;
579 int jahr = (value/10000);
581 DrawText(VX + VIDEO_DATE_XPOS, VY + VIDEO_DATE_YPOS,
582 int2str(tag, 2), FONT_TAPE_RECORDER);
583 DrawText(VX + VIDEO_DATE_XPOS + 27, VY + VIDEO_DATE_YPOS,
584 monatsname[monat], FONT_TAPE_RECORDER);
585 DrawText(VX + VIDEO_DATE_XPOS + 64, VY + VIDEO_DATE_YPOS,
586 int2str(jahr, 2), FONT_TAPE_RECORDER);
589 if (state & VIDEO_STATE_TIME_ON)
591 int min = value / 60;
592 int sec = value % 60;
594 DrawText(VX + VIDEO_TIME_XPOS, VY + VIDEO_TIME_YPOS,
595 int2str(min, 2), FONT_TAPE_RECORDER);
596 DrawText(VX + VIDEO_TIME_XPOS + 27, VY + VIDEO_TIME_YPOS,
597 int2str(sec, 2), FONT_TAPE_RECORDER);
601 redraw_mask |= REDRAW_DOOR_2;
603 if (state & VIDEO_STATE_DATE)
604 redraw_mask |= REDRAW_VIDEO_1;
605 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
606 redraw_mask |= REDRAW_VIDEO_2;
607 if (state & VIDEO_PRESS)
608 redraw_mask |= REDRAW_VIDEO_3;
612 void DrawCompleteVideoDisplay()
614 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
615 DOOR_GFX_PAGEX3, DOOR_GFX_PAGEY2,
616 gfx.vxsize, gfx.vysize, gfx.vx, gfx.vy);
617 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
618 DOOR_GFX_PAGEX4 + VIDEO_CONTROL_XPOS,
619 DOOR_GFX_PAGEY2 + VIDEO_CONTROL_YPOS,
620 VIDEO_CONTROL_XSIZE, VIDEO_CONTROL_YSIZE,
621 gfx.vx + VIDEO_CONTROL_XPOS, gfx.vy + VIDEO_CONTROL_YPOS);
623 DrawVideoDisplay(VIDEO_ALL_OFF, 0);
624 if (tape.date && tape.length)
626 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
627 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
630 BlitBitmap(drawto, bitmap_db_door, gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
631 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
634 void TapeDeactivateDisplayOn()
636 SetDrawDeactivationMask(REDRAW_FIELD);
637 audio.sound_deactivated = TRUE;
640 void TapeDeactivateDisplayOff(boolean redraw_display)
642 SetDrawDeactivationMask(REDRAW_NONE);
643 audio.sound_deactivated = FALSE;
647 RedrawPlayfield(TRUE, 0,0,0,0);
648 DrawGameDoorValues();
653 /* ========================================================================= */
654 /* tape control functions */
655 /* ========================================================================= */
657 static void TapeSetDate()
659 time_t epoch_seconds = time(NULL);
660 struct tm *now = localtime(&epoch_seconds);
662 tape.date = 10000 * (now->tm_year % 100) + 100 * now->tm_mon + now->tm_mday;
672 if (leveldir_current)
673 setString(&tape.level_identifier, leveldir_current->identifier);
675 tape.level_nr = level_nr;
676 tape.pos[tape.counter].delay = 0;
679 tape.random_seed = InitRND(NEW_RANDOMIZE);
681 tape.file_version = FILE_VERSION_ACTUAL;
682 tape.game_version = GAME_VERSION_ACTUAL;
683 tape.engine_version = level.game_version;
688 printf("::: tape.engine_version = level.game_version = %d \n",
692 for (i = 0; i < MAX_PLAYERS; i++)
693 tape.player_participates[i] = FALSE;
696 static void TapeRewind()
699 tape.delay_played = 0;
700 tape.pause_before_death = FALSE;
701 tape.recording = FALSE;
702 tape.playing = FALSE;
703 tape.fast_forward = FALSE;
704 tape.warp_forward = FALSE;
705 tape.deactivate_display = FALSE;
706 tape.auto_play = (global.autoplay_leveldir != NULL);
707 tape.auto_play_level_solved = FALSE;
708 tape.quick_resume = FALSE;
709 tape.single_step = FALSE;
711 InitRND(tape.random_seed);
714 static void TapeSetRandomSeed(long random_seed)
716 tape.random_seed = InitRND(random_seed);
719 void TapeStartRecording(long random_seed)
721 if (!TAPE_IS_STOPPED(tape))
726 TapeSetRandomSeed(random_seed);
728 tape.recording = TRUE;
730 DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
731 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
732 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
735 SetDrawDeactivationMask(REDRAW_NONE);
736 audio.sound_deactivated = FALSE;
739 static void TapeStartGameRecording()
741 TapeStartRecording(NEW_RANDOMIZE);
743 #if defined(NETWORK_AVALIABLE)
745 SendToServer_StartPlaying();
749 game_status = GAME_MODE_PLAYING;
755 static void TapeAppendRecording()
757 if (!tape.playing || !tape.pausing)
760 tape.pos[tape.counter].delay = tape.delay_played;
761 tape.playing = FALSE;
762 tape.recording = TRUE;
767 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
768 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON, 0);
771 void TapeHaltRecording()
777 tape.pos[tape.counter].delay = 0;
779 tape.length = tape.counter;
780 tape.length_seconds = GetTapeLength();
783 void TapeStopRecording()
792 tape.recording = FALSE;
793 tape.pausing = FALSE;
795 DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
796 MapTapeEjectButton();
799 void TapeRecordAction(byte action[MAX_PLAYERS])
804 if (!tape.recording) /* record action even when tape is paused! */
807 if (!tape.recording || tape.pausing)
811 if (tape.counter >= MAX_TAPE_LEN - 1)
818 printf("::: %05d: recording action: %d\n", FrameCounter, action[0]);
821 if (tape.pos[tape.counter].delay > 0) /* already stored action */
823 boolean changed_events = FALSE;
825 for (i = 0; i < MAX_PLAYERS; i++)
826 if (tape.pos[tape.counter].action[i] != action[i])
827 changed_events = TRUE;
829 if (changed_events || tape.pos[tape.counter].delay >= 255)
832 tape.pos[tape.counter].delay = 0;
835 tape.pos[tape.counter].delay++;
838 if (tape.pos[tape.counter].delay == 0) /* store new action */
842 printf("::: %05d: new sequence\n", FrameCounter);
845 for (i = 0; i < MAX_PLAYERS; i++)
846 tape.pos[tape.counter].action[i] = action[i];
848 tape.pos[tape.counter].delay++;
852 void TapeTogglePause(boolean toggle_manual)
857 if (!tape.recording && !tape.playing)
861 if (tape.pause_before_death)
862 state |= VIDEO_STATE_PBEND_OFF;
863 else if (tape.fast_forward)
864 state |= VIDEO_STATE_FFWD_OFF;
866 tape.pausing = !tape.pausing;
867 tape.fast_forward = FALSE;
868 tape.pause_before_death = FALSE;
870 if (tape.single_step && toggle_manual)
871 tape.single_step = FALSE;
873 state |= (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
875 state |= VIDEO_STATE_PLAY_ON;
877 state |= (tape.single_step ? VIDEO_STATE_1STEP_ON : VIDEO_STATE_1STEP_OFF);
879 DrawVideoDisplay(state, 0);
883 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, 0);
886 if (tape.warp_forward)
888 TapeStopWarpForward();
890 if (tape.quick_resume)
892 tape.quick_resume = FALSE;
894 TapeAppendRecording();
896 TapeTogglePause(toggle_manual);
902 void TapeStartPlaying()
904 if (TAPE_IS_EMPTY(tape))
907 if (!TAPE_IS_STOPPED(tape))
914 DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
915 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
916 DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
919 SetDrawDeactivationMask(REDRAW_NONE);
920 audio.sound_deactivated = FALSE;
923 static void TapeStartGamePlaying()
927 game_status = GAME_MODE_PLAYING;
932 void TapeStopPlaying()
939 tape.playing = FALSE;
940 tape.pausing = FALSE;
942 if (tape.warp_forward)
943 TapeStopWarpForward();
945 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
946 MapTapeEjectButton();
949 byte *TapePlayAction()
951 static byte action[MAX_PLAYERS];
954 if (!tape.playing || tape.pausing)
957 if (tape.pause_before_death) /* stop 10 seconds before player gets killed */
959 if (!(FrameCounter % 20))
961 if ((FrameCounter / 20) % 2)
962 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
964 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
967 if (tape.warp_forward)
969 if (tape.deactivate_display)
970 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
972 DrawVideoDisplay(VIDEO_STATE_WARP2_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
975 if (TapeTime > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
977 TapeTogglePause(TAPE_TOGGLE_MANUAL);
982 else if (tape.fast_forward)
984 if ((FrameCounter / 20) % 2)
985 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, VIDEO_DISPLAY_LABEL_ONLY);
987 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF, VIDEO_DISPLAY_LABEL_ONLY);
989 if (tape.warp_forward)
991 if (tape.deactivate_display)
992 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
994 DrawVideoDisplay(VIDEO_STATE_WARP2_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
999 /* !!! this makes things much slower !!! */
1000 else if (tape.warp_forward)
1002 if ((FrameCounter / 20) % 2)
1003 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_LABEL_ONLY);
1005 DrawVideoDisplay(VIDEO_STATE_WARP_OFF, VIDEO_DISPLAY_LABEL_ONLY);
1007 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
1011 if (tape.counter >= tape.length) /* end of tape reached */
1013 if (tape.warp_forward && !tape.auto_play)
1014 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1021 for (i = 0; i < MAX_PLAYERS; i++)
1022 action[i] = tape.pos[tape.counter].action[i];
1024 tape.delay_played++;
1025 if (tape.delay_played >= tape.pos[tape.counter].delay)
1028 tape.delay_played = 0;
1032 printf("::: %05d: replaying action: %d\n", FrameCounter, action[0]);
1042 printf("::: stopped recording: %d\n", FrameCounter);
1043 else if (tape.playing)
1044 printf("::: stopped playing: %d\n\n", FrameCounter);
1047 TapeStopRecording();
1050 DrawVideoDisplay(VIDEO_STATE_OFF, 0);
1052 if (tape.date && tape.length)
1054 DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
1055 DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
1060 AutoPlayTape(); /* continue automatically playing next tape */
1064 unsigned int GetTapeLength()
1066 unsigned int tape_length = 0;
1069 if (TAPE_IS_EMPTY(tape))
1072 for (i = 0; i < tape.length; i++)
1073 tape_length += tape.pos[i].delay;
1075 return(tape_length * GAME_FRAME_DELAY / 1000);
1078 static void TapeStartWarpForward()
1080 tape.warp_forward = TRUE;
1083 if (!tape.fast_forward && !tape.pause_before_death)
1085 tape.pausing = FALSE;
1086 tape.deactivate_display = TRUE;
1088 TapeDeactivateDisplayOn();
1091 if (!tape.fast_forward || tape.pause_before_death)
1093 tape.pausing = FALSE;
1094 tape.deactivate_display = TRUE;
1096 TapeDeactivateDisplayOn();
1100 if (tape.fast_forward || tape.pause_before_death)
1101 DrawVideoDisplay(VIDEO_STATE_WARP_ON, VIDEO_DISPLAY_SYMBOL_ONLY);
1103 DrawVideoDisplay(VIDEO_STATE_WARP_ON, 0);
1106 static void TapeStopWarpForward()
1108 int state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
1110 tape.warp_forward = FALSE;
1111 tape.deactivate_display = FALSE;
1113 TapeDeactivateDisplayOff(game_status == GAME_MODE_PLAYING);
1117 if (game_status == GAME_MODE_PLAYING)
1120 RedrawPlayfield(TRUE, 0,0,0,0);
1121 DrawGameDoorValues();
1125 if (tape.pause_before_death)
1126 state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_PBEND_ON;
1127 else if (tape.fast_forward)
1128 state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_FFWD_ON;
1130 state |= VIDEO_STATE_WARP_OFF | VIDEO_STATE_PLAY_ON;
1132 DrawVideoDisplay(state, 0);
1135 static void TapeSingleStep()
1137 if (options.network)
1141 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1143 tape.single_step = !tape.single_step;
1145 DrawVideoDisplay((tape.single_step ? VIDEO_STATE_1STEP_ON :
1146 VIDEO_STATE_1STEP_OFF), 0);
1149 void TapeQuickSave()
1151 if (game_status == GAME_MODE_PLAYING)
1154 TapeHaltRecording(); /* prepare tape for saving on-the-fly */
1156 if (TAPE_IS_EMPTY(tape))
1157 Request("No tape that can be saved !", REQ_CONFIRM);
1159 SaveTape(tape.level_nr);
1161 else if (game_status == GAME_MODE_MAIN)
1162 Request("No game that can be saved !", REQ_CONFIRM);
1165 void TapeQuickLoad()
1167 char *filename = getTapeFilename(level_nr);
1169 if (!fileExists(filename))
1171 Request("No tape for this level !", REQ_CONFIRM);
1176 if (tape.recording && !Request("Stop recording and load tape ?",
1177 REQ_ASK | REQ_STAY_CLOSED))
1179 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
1184 if (game_status == GAME_MODE_PLAYING || game_status == GAME_MODE_MAIN)
1190 if (!TAPE_IS_EMPTY(tape))
1192 TapeStartGamePlaying();
1193 TapeStartWarpForward();
1195 tape.quick_resume = TRUE;
1197 else /* this should not happen (basically checked above) */
1199 int reopen_door = (game_status == GAME_MODE_PLAYING ? REQ_REOPEN : 0);
1201 Request("No tape for this level !", REQ_CONFIRM | reopen_door);
1206 void InsertSolutionTape()
1208 if (!TAPE_IS_EMPTY(tape))
1211 LoadSolutionTape(level_nr);
1213 if (TAPE_IS_EMPTY(tape))
1214 Request("No solution tape for this level !", REQ_CONFIRM);
1216 DrawCompleteVideoDisplay();
1220 /* ------------------------------------------------------------------------- *
1221 * tape autoplay functions
1222 * ------------------------------------------------------------------------- */
1226 static LevelDirTree *autoplay_leveldir = NULL;
1227 static boolean autoplay_initialized = FALSE;
1228 static int autoplay_level_nr = -1;
1229 static int num_levels_played = 0;
1230 static int num_levels_solved = 0;
1231 static int num_tape_missing = 0;
1232 static boolean level_failed[MAX_TAPES_PER_SET];
1233 static boolean tape_missing[MAX_TAPES_PER_SET];
1236 if (autoplay_initialized)
1238 /* just finished auto-playing tape */
1239 printf("%s.\n", tape.auto_play_level_solved ? "solved" : "NOT SOLVED");
1241 num_levels_played++;
1243 if (tape.auto_play_level_solved)
1244 num_levels_solved++;
1245 else if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
1246 level_failed[level_nr] = TRUE;
1250 DrawCompleteVideoDisplay();
1251 audio.sound_enabled = FALSE;
1253 autoplay_leveldir = getTreeInfoFromIdentifier(leveldir_first,
1254 global.autoplay_leveldir);
1256 if (autoplay_leveldir == NULL)
1257 Error(ERR_EXIT, "no such level identifier: '%s'",
1258 global.autoplay_leveldir);
1260 leveldir_current = autoplay_leveldir;
1262 if (autoplay_leveldir->first_level < 0)
1263 autoplay_leveldir->first_level = 0;
1264 if (autoplay_leveldir->last_level >= MAX_TAPES_PER_SET)
1265 autoplay_leveldir->last_level = MAX_TAPES_PER_SET - 1;
1267 autoplay_level_nr = autoplay_leveldir->first_level;
1269 printf_line("=", 79);
1270 printf("Automatically playing level tapes\n");
1271 printf_line("-", 79);
1272 printf("Level series identifier: '%s'\n", autoplay_leveldir->identifier);
1273 printf("Level series name: '%s'\n", autoplay_leveldir->name);
1274 printf("Level series author: '%s'\n", autoplay_leveldir->author);
1275 printf("Number of levels: %d\n", autoplay_leveldir->levels);
1276 printf_line("=", 79);
1279 for (i = 0; i < MAX_TAPES_PER_SET; i++)
1281 level_failed[i] = FALSE;
1282 tape_missing[i] = FALSE;
1285 autoplay_initialized = TRUE;
1288 while (autoplay_level_nr <= autoplay_leveldir->last_level)
1290 level_nr = autoplay_level_nr++;
1292 if (!global.autoplay_all && !global.autoplay_level[level_nr])
1297 printf("Level %03d: ", level_nr);
1299 LoadLevel(level_nr);
1300 if (level.no_valid_file)
1302 printf("(no level)\n");
1307 /* ACTIVATE THIS FOR LOADING/TESTING OF LEVELS ONLY */
1308 printf("(only testing level)\n");
1312 LoadSolutionTape(level_nr);
1314 if (tape.no_valid_file)
1316 if (TAPE_IS_EMPTY(tape))
1320 if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
1321 tape_missing[level_nr] = TRUE;
1323 printf("(no tape)\n");
1327 printf("playing tape ... ");
1329 TapeStartGamePlaying();
1330 TapeStartWarpForward();
1336 printf_line("=", 79);
1337 printf("Number of levels played: %d\n", num_levels_played);
1338 printf("Number of levels solved: %d (%d%%)\n", num_levels_solved,
1339 (num_levels_played ? num_levels_solved * 100 / num_levels_played :0));
1340 printf_line("-", 79);
1341 printf("Summary (for automatic parsing by scripts):\n");
1342 printf("LEVELDIR '%s', SOLVED %d/%d (%d%%)",
1343 autoplay_leveldir->identifier, num_levels_solved, num_levels_played,
1344 (num_levels_played ? num_levels_solved * 100 / num_levels_played :0));
1346 if (num_levels_played != num_levels_solved)
1348 printf(", FAILED:");
1349 for (i = 0; i < MAX_TAPES_PER_SET; i++)
1350 if (level_failed[i])
1355 if (num_tape_missing > 0)
1357 printf(", NO TAPE:");
1358 for (i = 0; i < MAX_TAPES_PER_SET; i++)
1359 if (tape_missing[i])
1365 printf_line("=", 79);
1371 /* ---------- new tape button stuff ---------------------------------------- */
1373 /* graphic position values for tape buttons */
1374 #define TAPE_BUTTON_XSIZE 18
1375 #define TAPE_BUTTON_YSIZE 18
1376 #define TAPE_BUTTON_XPOS 5
1377 #define TAPE_BUTTON_YPOS 77
1379 #define TAPE_BUTTON_EJECT_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
1380 #define TAPE_BUTTON_EXTRA_XPOS (TAPE_BUTTON_XPOS + 0 * TAPE_BUTTON_XSIZE)
1381 #define TAPE_BUTTON_STOP_XPOS (TAPE_BUTTON_XPOS + 1 * TAPE_BUTTON_XSIZE)
1382 #define TAPE_BUTTON_PAUSE_XPOS (TAPE_BUTTON_XPOS + 2 * TAPE_BUTTON_XSIZE)
1383 #define TAPE_BUTTON_RECORD_XPOS (TAPE_BUTTON_XPOS + 3 * TAPE_BUTTON_XSIZE)
1384 #define TAPE_BUTTON_PLAY_XPOS (TAPE_BUTTON_XPOS + 4 * TAPE_BUTTON_XSIZE)
1391 } tapebutton_info[NUM_TAPE_BUTTONS] =
1394 TAPE_BUTTON_EJECT_XPOS, TAPE_BUTTON_YPOS,
1399 TAPE_BUTTON_EXTRA_XPOS, TAPE_BUTTON_YPOS,
1404 TAPE_BUTTON_STOP_XPOS, TAPE_BUTTON_YPOS,
1409 TAPE_BUTTON_PAUSE_XPOS, TAPE_BUTTON_YPOS,
1414 TAPE_BUTTON_RECORD_XPOS, TAPE_BUTTON_YPOS,
1415 TAPE_CTRL_ID_RECORD,
1419 TAPE_BUTTON_PLAY_XPOS, TAPE_BUTTON_YPOS,
1425 void CreateTapeButtons()
1429 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1431 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
1432 struct GadgetInfo *gi;
1433 int gd_xoffset, gd_yoffset;
1434 int gd_x1, gd_x2, gd_y;
1437 gd_xoffset = tapebutton_info[i].x;
1438 gd_yoffset = tapebutton_info[i].y;
1439 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
1440 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
1441 gd_y = DOOR_GFX_PAGEY2 + gd_yoffset;
1443 if (i == TAPE_CTRL_ID_EXTRA)
1445 gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset;
1446 gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset;
1449 gi = CreateGadget(GDI_CUSTOM_ID, id,
1450 GDI_INFO_TEXT, tapebutton_info[i].infotext,
1451 GDI_X, VX + gd_xoffset,
1452 GDI_Y, VY + gd_yoffset,
1453 GDI_WIDTH, TAPE_BUTTON_XSIZE,
1454 GDI_HEIGHT, TAPE_BUTTON_YSIZE,
1455 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
1456 GDI_STATE, GD_BUTTON_UNPRESSED,
1457 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
1458 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
1459 GDI_EVENT_MASK, GD_EVENT_RELEASED,
1460 GDI_CALLBACK_ACTION, HandleTapeButtons,
1464 Error(ERR_EXIT, "cannot create gadget");
1466 tape_gadget[id] = gi;
1470 void FreeTapeButtons()
1474 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1475 FreeGadget(tape_gadget[i]);
1478 void MapTapeEjectButton()
1480 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EXTRA]);
1481 MapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
1484 void MapTapeWarpButton()
1486 UnmapGadget(tape_gadget[TAPE_CTRL_ID_EJECT]);
1487 MapGadget(tape_gadget[TAPE_CTRL_ID_EXTRA]);
1490 void MapTapeButtons()
1494 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1495 if (i != TAPE_CTRL_ID_EXTRA)
1496 MapGadget(tape_gadget[i]);
1498 if (tape.recording || tape.playing)
1499 MapTapeWarpButton();
1502 void UnmapTapeButtons()
1506 for (i = 0; i < NUM_TAPE_BUTTONS; i++)
1507 UnmapGadget(tape_gadget[i]);
1510 static void HandleTapeButtons(struct GadgetInfo *gi)
1512 int id = gi->custom_id;
1514 if (game_status != GAME_MODE_MAIN && game_status != GAME_MODE_PLAYING)
1519 case TAPE_CTRL_ID_EJECT:
1521 if (TAPE_IS_EMPTY(tape))
1524 if (TAPE_IS_EMPTY(tape))
1525 Request("No tape for this level !", REQ_CONFIRM);
1530 SaveTape(tape.level_nr);
1533 DrawCompleteVideoDisplay();
1536 case TAPE_CTRL_ID_EXTRA:
1539 if (!tape.warp_forward) /* PLAY -> WARP FORWARD PLAY */
1541 TapeStartWarpForward();
1543 else /* WARP FORWARD PLAY -> PLAY */
1545 TapeStopWarpForward();
1548 if (tape.pause_before_death)
1549 DrawVideoDisplay(VIDEO_STATE_WARP_OFF | VIDEO_STATE_PLAY_ON, 0);
1550 else if (tape.fast_forward)
1551 DrawVideoDisplay(VIDEO_STATE_WARP_OFF | VIDEO_STATE_FFWD_ON, 0);
1553 DrawVideoDisplay(VIDEO_STATE_WARP_OFF | VIDEO_STATE_PBEND_ON, 0);
1557 else if (tape.recording)
1561 case TAPE_CTRL_ID_STOP:
1565 case TAPE_CTRL_ID_PAUSE:
1566 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1569 case TAPE_CTRL_ID_RECORD:
1570 if (TAPE_IS_STOPPED(tape))
1571 TapeStartGameRecording();
1572 else if (tape.pausing)
1574 if (tape.playing) /* PLAY -> PAUSE -> RECORD */
1575 TapeAppendRecording();
1577 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1581 case TAPE_CTRL_ID_PLAY:
1582 if (TAPE_IS_EMPTY(tape))
1585 if (TAPE_IS_STOPPED(tape))
1587 TapeStartGamePlaying();
1589 else if (tape.playing)
1591 if (tape.pausing) /* PAUSE -> PLAY */
1593 TapeTogglePause(TAPE_TOGGLE_MANUAL);
1595 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
1597 tape.fast_forward = TRUE;
1598 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
1600 else if (!tape.pause_before_death) /* FFWD PLAY -> AUTO PAUSE */
1602 tape.pause_before_death = TRUE;
1604 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_ON, 0);
1606 DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
1609 else /* AUTO PAUSE -> NORMAL PLAY */
1612 if (tape.warp_forward)
1613 TapeStopWarpForward();
1615 tape.warp_forward = FALSE;
1617 tape.fast_forward = FALSE;
1618 tape.pause_before_death = FALSE;
1621 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF | VIDEO_STATE_PLAY_ON, 0);
1623 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PBEND_OFF, 0);