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 ***********************************************************/
16 #include "libgame/libgame.h"
28 /* select level set with EMC X11 graphics before activating EM GFX debugging */
29 #define DEBUG_EM_GFX 0
31 /* tool button identifiers */
32 #define TOOL_CTRL_ID_YES 0
33 #define TOOL_CTRL_ID_NO 1
34 #define TOOL_CTRL_ID_CONFIRM 2
35 #define TOOL_CTRL_ID_PLAYER_1 3
36 #define TOOL_CTRL_ID_PLAYER_2 4
37 #define TOOL_CTRL_ID_PLAYER_3 5
38 #define TOOL_CTRL_ID_PLAYER_4 6
40 #define NUM_TOOL_BUTTONS 7
42 /* constants for number of doors and door parts */
44 #define NUM_PANELS NUM_DOORS
45 // #define NUM_PANELS 0
46 #define MAX_PARTS_PER_DOOR 8
47 #define MAX_DOOR_PARTS (NUM_DOORS * MAX_PARTS_PER_DOOR + NUM_PANELS)
48 #define DOOR_PART_IS_PANEL(i) ((i) >= NUM_DOORS * MAX_PARTS_PER_DOOR)
51 struct DoorPartOrderInfo
57 static struct DoorPartOrderInfo door_part_order[MAX_DOOR_PARTS];
59 struct DoorPartControlInfo
63 struct DoorPartPosInfo *pos;
66 static struct DoorPartControlInfo door_part_controls[] =
70 IMG_DOOR_1_GFX_PART_1,
75 IMG_DOOR_1_GFX_PART_2,
80 IMG_DOOR_1_GFX_PART_3,
85 IMG_DOOR_1_GFX_PART_4,
90 IMG_DOOR_1_GFX_PART_5,
95 IMG_DOOR_1_GFX_PART_6,
100 IMG_DOOR_1_GFX_PART_7,
105 IMG_DOOR_1_GFX_PART_8,
111 IMG_DOOR_2_GFX_PART_1,
116 IMG_DOOR_2_GFX_PART_2,
121 IMG_DOOR_2_GFX_PART_3,
126 IMG_DOOR_2_GFX_PART_4,
131 IMG_DOOR_2_GFX_PART_5,
136 IMG_DOOR_2_GFX_PART_6,
141 IMG_DOOR_2_GFX_PART_7,
146 IMG_DOOR_2_GFX_PART_8,
152 IMG_BACKGROUND_PANEL,
169 /* forward declaration for internal use */
170 static void UnmapToolButtons();
171 static void HandleToolButtons(struct GadgetInfo *);
172 static int el_act_dir2crm(int, int, int);
173 static int el_act2crm(int, int);
175 static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS];
176 static int request_gadget_id = -1;
178 static char *print_if_not_empty(int element)
180 static char *s = NULL;
181 char *token_name = element_info[element].token_name;
186 s = checked_malloc(strlen(token_name) + 10 + 1);
188 if (element != EL_EMPTY)
189 sprintf(s, "%d\t['%s']", element, token_name);
191 sprintf(s, "%d", element);
196 void DumpTile(int x, int y)
201 if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
207 printf_line("-", 79);
208 printf("Field Info: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y);
209 printf_line("-", 79);
211 if (!IN_LEV_FIELD(x, y))
213 printf("(not in level field)\n");
219 printf(" Feld: %d\t['%s']\n", Feld[x][y],
220 element_info[Feld[x][y]].token_name);
221 printf(" Back: %s\n", print_if_not_empty(Back[x][y]));
222 printf(" Store: %s\n", print_if_not_empty(Store[x][y]));
223 printf(" Store2: %s\n", print_if_not_empty(Store2[x][y]));
224 printf(" StorePlayer: %s\n", print_if_not_empty(StorePlayer[x][y]));
225 printf(" MovPos: %d\n", MovPos[x][y]);
226 printf(" MovDir: %d\n", MovDir[x][y]);
227 printf(" MovDelay: %d\n", MovDelay[x][y]);
228 printf(" ChangeDelay: %d\n", ChangeDelay[x][y]);
229 printf(" CustomValue: %d\n", CustomValue[x][y]);
230 printf(" GfxElement: %d\n", GfxElement[x][y]);
231 printf(" GfxAction: %d\n", GfxAction[x][y]);
232 printf(" GfxFrame: %d\n", GfxFrame[x][y]);
236 void SetDrawtoField(int mode)
238 if (mode == DRAW_BUFFERED && setup.soft_scrolling)
246 BX2 = SCR_FIELDX + 1;
247 BY2 = SCR_FIELDY + 1;
266 BX2 = SCR_FIELDX + 1;
267 BY2 = SCR_FIELDY + 1;
282 drawto_field = fieldbuffer;
284 else /* DRAW_BACKBUFFER */
290 BX2 = SCR_FIELDX - 1;
291 BY2 = SCR_FIELDY - 1;
295 drawto_field = backbuffer;
299 void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height)
301 if (game_status == GAME_MODE_PLAYING &&
302 level.game_engine_type == GAME_ENGINE_TYPE_EM)
304 /* currently there is no partial redraw -- always redraw whole playfield */
305 RedrawPlayfield_EM(TRUE);
307 /* blit playfield from scroll buffer to normal back buffer for fading in */
308 BlitScreenToBitmap_EM(backbuffer);
310 else if (game_status == GAME_MODE_PLAYING &&
311 level.game_engine_type == GAME_ENGINE_TYPE_SP)
313 /* currently there is no partial redraw -- always redraw whole playfield */
314 RedrawPlayfield_SP(TRUE);
316 /* blit playfield from scroll buffer to normal back buffer for fading in */
317 BlitScreenToBitmap_SP(backbuffer);
319 else if (game_status == GAME_MODE_PLAYING &&
320 !game.envelope_active)
326 width = gfx.sxsize + 2 * TILEX;
327 height = gfx.sysize + 2 * TILEY;
333 int x1 = (x - SX) / TILEX, y1 = (y - SY) / TILEY;
334 int x2 = (x - SX + width) / TILEX, y2 = (y - SY + height) / TILEY;
336 for (xx = BX1; xx <= BX2; xx++)
337 for (yy = BY1; yy <= BY2; yy++)
338 if (xx >= x1 && xx <= x2 && yy >= y1 && yy <= y2)
339 DrawScreenField(xx, yy);
343 if (setup.soft_scrolling)
345 int fx = FX, fy = FY;
347 fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
348 fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0);
350 BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY);
362 BlitBitmap(drawto, window, x, y, width, height, x, y);
365 void DrawMaskedBorder_Rect(int x, int y, int width, int height)
367 Bitmap *bitmap = graphic_info[IMG_GLOBAL_BORDER].bitmap;
369 SetClipOrigin(bitmap, bitmap->stored_clip_gc, 0, 0);
370 BlitBitmapMasked(bitmap, backbuffer, x, y, width, height, x, y);
373 void DrawMaskedBorder_FIELD()
375 if (global.border_status >= GAME_MODE_TITLE &&
376 global.border_status <= GAME_MODE_PLAYING &&
377 border.draw_masked[global.border_status])
378 DrawMaskedBorder_Rect(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
381 void DrawMaskedBorder_DOOR_1()
383 if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] &&
384 (global.border_status != GAME_MODE_EDITOR ||
385 border.draw_masked[GFX_SPECIAL_ARG_EDITOR]))
386 DrawMaskedBorder_Rect(DX, DY, DXSIZE, DYSIZE);
389 void DrawMaskedBorder_DOOR_2()
391 if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] &&
392 global.border_status != GAME_MODE_EDITOR)
393 DrawMaskedBorder_Rect(VX, VY, VXSIZE, VYSIZE);
396 void DrawMaskedBorder_DOOR_3()
398 /* currently not available */
401 void DrawMaskedBorder_ALL()
403 DrawMaskedBorder_FIELD();
404 DrawMaskedBorder_DOOR_1();
405 DrawMaskedBorder_DOOR_2();
406 DrawMaskedBorder_DOOR_3();
409 void DrawMaskedBorder(int redraw_mask)
411 /* never draw masked screen borders on borderless screens */
412 if (effectiveGameStatus() == GAME_MODE_LOADING ||
413 effectiveGameStatus() == GAME_MODE_TITLE)
416 /* never draw masked screen borders when displaying request outside door */
417 if (effectiveGameStatus() == GAME_MODE_PSEUDO_DOOR &&
418 global.use_envelope_request)
421 if (redraw_mask & REDRAW_ALL)
422 DrawMaskedBorder_ALL();
425 if (redraw_mask & REDRAW_FIELD)
426 DrawMaskedBorder_FIELD();
427 if (redraw_mask & REDRAW_DOOR_1)
428 DrawMaskedBorder_DOOR_1();
429 if (redraw_mask & REDRAW_DOOR_2)
430 DrawMaskedBorder_DOOR_2();
431 if (redraw_mask & REDRAW_DOOR_3)
432 DrawMaskedBorder_DOOR_3();
436 void BlitScreenToBitmap(Bitmap *target_bitmap)
438 DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field);
439 int fx = FX, fy = FY;
442 int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0);
443 int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0);
444 int dx_var = dx * TILESIZE_VAR / TILESIZE;
445 int dy_var = dy * TILESIZE_VAR / TILESIZE;
448 // fx += dx * TILESIZE_VAR / TILESIZE;
449 // fy += dy * TILESIZE_VAR / TILESIZE;
451 fx += (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0);
452 fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0);
455 ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var;
456 ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var;
458 if (EVEN(SCR_FIELDX))
460 if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR)
461 fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR;
463 fx += (dx_var > 0 ? TILEX_VAR : 0);
470 if (EVEN(SCR_FIELDY))
472 if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR)
473 fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR;
475 fy += (dy_var > 0 ? TILEY_VAR : 0);
483 printf("::: (%d, %d) [(%d / %d, %d / %d)] => %d, %d\n",
486 SBY_Upper, SBY_Lower,
490 if (border.draw_masked[GAME_MODE_PLAYING])
492 if (buffer != backbuffer)
494 /* copy playfield buffer to backbuffer to add masked border */
495 BlitBitmap(buffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
496 DrawMaskedBorder(REDRAW_FIELD);
499 BlitBitmap(backbuffer, target_bitmap,
500 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
505 BlitBitmap(buffer, target_bitmap, fx, fy, SXSIZE, SYSIZE, SX, SY);
512 DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field);
515 printf("::: TILES TO REFRESH: %d\n", redraw_tiles);
516 for (x = 0; x < SCR_FIELDX; x++)
517 for (y = 0 ; y < SCR_FIELDY; y++)
518 if (redraw[redraw_x1 + x][redraw_y1 + y])
519 printf("::: - %d, %d [%s]\n",
520 LEVELX(x), LEVELY(y),
521 EL_NAME(Feld[LEVELX(x)][LEVELY(y)]));
524 if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD)
525 redraw_mask |= REDRAW_FIELD;
528 // never redraw single tiles, always redraw the whole field
529 // (redrawing single tiles up to a certain threshold was faster on old,
530 // now legacy graphics, but slows things down on modern graphics now)
531 // UPDATE: this is now globally defined by value of REDRAWTILES_THRESHOLD
532 if (redraw_mask & REDRAW_TILES)
533 redraw_mask |= REDRAW_FIELD;
537 /* !!! TEST ONLY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
538 /* (force full redraw) */
539 if (game_status == GAME_MODE_PLAYING)
540 redraw_mask |= REDRAW_FIELD;
543 if (redraw_mask & REDRAW_FIELD)
544 redraw_mask &= ~REDRAW_TILES;
546 if (redraw_mask == REDRAW_NONE)
551 if (redraw_mask & REDRAW_ALL)
552 printf("[REDRAW_ALL]");
553 if (redraw_mask & REDRAW_FIELD)
554 printf("[REDRAW_FIELD]");
555 if (redraw_mask & REDRAW_TILES)
556 printf("[REDRAW_TILES]");
557 if (redraw_mask & REDRAW_DOOR_1)
558 printf("[REDRAW_DOOR_1]");
559 if (redraw_mask & REDRAW_DOOR_2)
560 printf("[REDRAW_DOOR_2]");
561 if (redraw_mask & REDRAW_FROM_BACKBUFFER)
562 printf("[REDRAW_FROM_BACKBUFFER]");
563 printf(" [%d]\n", FrameCounter);
566 if (redraw_mask & REDRAW_TILES &&
567 game_status == GAME_MODE_PLAYING &&
568 border.draw_masked[GAME_MODE_PLAYING])
569 redraw_mask |= REDRAW_FIELD;
571 if (global.fps_slowdown && game_status == GAME_MODE_PLAYING)
573 static boolean last_frame_skipped = FALSE;
574 boolean skip_even_when_not_scrolling = TRUE;
575 boolean just_scrolling = (ScreenMovDir != 0);
576 boolean verbose = FALSE;
578 if (global.fps_slowdown_factor > 1 &&
579 (FrameCounter % global.fps_slowdown_factor) &&
580 (just_scrolling || skip_even_when_not_scrolling))
582 redraw_mask &= ~REDRAW_MAIN;
584 last_frame_skipped = TRUE;
587 printf("FRAME SKIPPED\n");
591 if (last_frame_skipped)
592 redraw_mask |= REDRAW_FIELD;
594 last_frame_skipped = FALSE;
597 printf("frame not skipped\n");
601 /* synchronize X11 graphics at this point; if we would synchronize the
602 display immediately after the buffer switching (after the XFlush),
603 this could mean that we have to wait for the graphics to complete,
604 although we could go on doing calculations for the next frame */
608 /* never draw masked border to backbuffer when using playfield buffer */
609 if (game_status != GAME_MODE_PLAYING ||
610 redraw_mask & REDRAW_FROM_BACKBUFFER ||
611 buffer == backbuffer)
612 DrawMaskedBorder(redraw_mask);
614 DrawMaskedBorder(redraw_mask & REDRAW_DOORS);
616 if (redraw_mask & REDRAW_ALL)
618 BlitBitmap(backbuffer, window, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
620 redraw_mask = REDRAW_NONE;
623 if (redraw_mask & REDRAW_FIELD)
626 printf("::: REDRAW_FIELD\n");
629 if (game_status != GAME_MODE_PLAYING ||
630 redraw_mask & REDRAW_FROM_BACKBUFFER)
632 BlitBitmap(backbuffer, window,
633 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, REAL_SX, REAL_SY);
638 BlitScreenToBitmap(window);
640 int fx = FX, fy = FY;
643 int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0);
644 int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0);
645 int dx_var = dx * TILESIZE_VAR / TILESIZE;
646 int dy_var = dy * TILESIZE_VAR / TILESIZE;
649 // fx += dx * TILESIZE_VAR / TILESIZE;
650 // fy += dy * TILESIZE_VAR / TILESIZE;
652 fx += (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0);
653 fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0);
656 /* !!! THIS WORKS !!! */
658 printf("::: %d, %d\n", scroll_x, scroll_y);
660 ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var;
661 ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var;
663 if (EVEN(SCR_FIELDX))
665 if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR)
666 fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR;
668 fx += (dx > 0 ? TILEX_VAR : 0);
675 if (EVEN(SCR_FIELDY))
677 if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR)
678 fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR;
680 fy += (dy > 0 ? TILEY_VAR : 0);
687 if (border.draw_masked[GAME_MODE_PLAYING])
689 if (buffer != backbuffer)
691 /* copy playfield buffer to backbuffer to add masked border */
692 BlitBitmap(buffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY);
693 DrawMaskedBorder(REDRAW_FIELD);
696 BlitBitmap(backbuffer, window,
697 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
702 BlitBitmap(buffer, window, fx, fy, SXSIZE, SYSIZE, SX, SY);
708 printf("redrawing all (ScreenGfxPos == %d) because %s\n",
710 (setup.soft_scrolling ?
711 "setup.soft_scrolling" :
712 ABS(ScreenGfxPos) + ScrollStepSize == TILEX ?
713 "ABS(ScreenGfxPos) + ScrollStepSize == TILEX" :
714 ABS(ScreenGfxPos) == ScrollStepSize ?
715 "ABS(ScreenGfxPos) == ScrollStepSize" :
716 "redraw_tiles > REDRAWTILES_THRESHOLD"));
721 redraw_mask &= ~REDRAW_MAIN;
724 if (redraw_mask & REDRAW_DOORS)
726 if (redraw_mask & REDRAW_DOOR_1)
727 BlitBitmap(backbuffer, window, DX, DY, DXSIZE, DYSIZE, DX, DY);
729 if (redraw_mask & REDRAW_DOOR_2)
730 BlitBitmap(backbuffer, window, VX, VY, VXSIZE, VYSIZE, VX, VY);
732 if (redraw_mask & REDRAW_DOOR_3)
733 BlitBitmap(backbuffer, window, EX, EY, EXSIZE, EYSIZE, EX, EY);
735 redraw_mask &= ~REDRAW_DOORS;
738 if (redraw_mask & REDRAW_MICROLEVEL)
740 BlitBitmap(backbuffer, window, SX, SY + 10 * TILEY, SXSIZE, 7 * TILEY,
741 SX, SY + 10 * TILEY);
743 redraw_mask &= ~REDRAW_MICROLEVEL;
746 if (redraw_mask & REDRAW_TILES)
749 printf("::: REDRAW_TILES\n");
755 InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE);
758 int sx = SX; // - (EVEN(SCR_FIELDX) ? TILEX_VAR / 2 : 0);
759 int sy = SY; // + (EVEN(SCR_FIELDY) ? TILEY_VAR / 2 : 0);
762 int dx_var = dx * TILESIZE_VAR / TILESIZE;
763 int dy_var = dy * TILESIZE_VAR / TILESIZE;
765 int fx = FX, fy = FY;
767 int scr_fieldx = SCR_FIELDX + (EVEN(SCR_FIELDX) ? 2 : 0);
768 int scr_fieldy = SCR_FIELDY + (EVEN(SCR_FIELDY) ? 2 : 0);
770 ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var;
771 ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var;
773 if (EVEN(SCR_FIELDX))
775 if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR)
777 fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR;
786 fx += (dx_var > 0 ? TILEX_VAR : 0);
790 if (EVEN(SCR_FIELDY))
792 if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR)
794 fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR;
803 fy += (dy_var > 0 ? TILEY_VAR : 0);
808 printf("::: %d, %d, %d, %d\n", sx, sy, SCR_FIELDX, SCR_FIELDY);
811 for (x = 0; x < scr_fieldx; x++)
812 for (y = 0 ; y < scr_fieldy; y++)
813 if (redraw[redraw_x1 + x][redraw_y1 + y])
814 BlitBitmap(buffer, window,
815 FX + x * TILEX_VAR, FY + y * TILEY_VAR,
816 TILEX_VAR, TILEY_VAR,
817 sx + x * TILEX_VAR, sy + y * TILEY_VAR);
820 InitGfxClipRegion(FALSE, -1, -1, -1, -1);
822 for (x = 0; x < SCR_FIELDX; x++)
823 for (y = 0 ; y < SCR_FIELDY; y++)
824 if (redraw[redraw_x1 + x][redraw_y1 + y])
825 BlitBitmap(buffer, window,
826 FX + x * TILEX_VAR, FY + y * TILEY_VAR,
827 TILEX_VAR, TILEY_VAR,
828 SX + x * TILEX_VAR, SY + y * TILEY_VAR);
832 for (x = 0; x < SCR_FIELDX; x++)
833 for (y = 0 ; y < SCR_FIELDY; y++)
834 if (redraw[redraw_x1 + x][redraw_y1 + y])
835 BlitBitmap(buffer, window,
836 FX + x * TILEX, FY + y * TILEY, TILEX, TILEY,
837 SX + x * TILEX, SY + y * TILEY);
841 if (redraw_mask & REDRAW_FPS) /* display frames per second */
846 sprintf(info1, " (only every %d. frame)", global.fps_slowdown_factor);
847 if (!global.fps_slowdown)
850 sprintf(text, "%04.1f fps%s", global.frames_per_second, info1);
852 DrawTextExt(window, SX + SXSIZE + SX, 0, text, FONT_TEXT_2, BLIT_OPAQUE);
854 DrawTextExt(window, SX, SY, text, FONT_TEXT_2, BLIT_OPAQUE);
860 for (x = 0; x < MAX_BUF_XSIZE; x++)
861 for (y = 0; y < MAX_BUF_YSIZE; y++)
864 redraw_mask = REDRAW_NONE;
867 static void FadeCrossSaveBackbuffer()
869 BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
872 static void FadeExt(int fade_mask, int fade_mode, int fade_type)
874 static int fade_type_skip = FADE_TYPE_NONE;
875 void (*draw_border_function)(void) = NULL;
876 Bitmap *bitmap = (fade_mode & FADE_TYPE_TRANSFORM ? bitmap_db_cross : NULL);
877 int x, y, width, height;
878 int fade_delay, post_delay;
880 if (fade_type == FADE_TYPE_FADE_OUT)
882 if (fade_type_skip != FADE_TYPE_NONE)
885 printf("::: skipping %d ... [%d] (X)\n", fade_mode, fade_type_skip);
888 /* skip all fade operations until specified fade operation */
889 if (fade_type & fade_type_skip)
890 fade_type_skip = FADE_TYPE_NONE;
895 if (fading.fade_mode & FADE_TYPE_TRANSFORM)
897 FadeCrossSaveBackbuffer();
903 redraw_mask |= fade_mask;
905 if (fade_type == FADE_TYPE_SKIP)
908 printf("::: will skip %d ... [%d]\n", fade_mode, fade_type_skip);
911 fade_type_skip = fade_mode;
917 printf("::: !!! FADING %d ... [%d] [%d]\n", fade_mode, fade_type,
922 fade_delay = fading.fade_delay;
923 post_delay = (fade_mode == FADE_MODE_FADE_OUT ? fading.post_delay : 0);
926 if (fade_type_skip != FADE_TYPE_NONE)
929 printf("::: skipping %d ... [%d]\n", fade_mode, fade_type_skip);
932 /* skip all fade operations until specified fade operation */
933 if (fade_type & fade_type_skip)
934 fade_type_skip = FADE_TYPE_NONE;
944 if (global.autoplay_leveldir)
946 // fading.fade_mode = FADE_MODE_NONE;
953 if (fading.fade_mode == FADE_MODE_NONE)
961 /* !!! what about fade_mask == REDRAW_FIELD | REDRAW_ALL ??? !!! */
964 printf("::: NOW FADING %d ... [%d]\n", fade_mode, fade_type);
968 if (fade_mask == REDRAW_NONE)
969 fade_mask = REDRAW_FIELD;
972 // if (fade_mask & REDRAW_FIELD)
973 if (fade_mask == REDRAW_FIELD)
978 height = FULL_SYSIZE;
981 fade_delay = fading.fade_delay;
982 post_delay = (fade_mode == FADE_MODE_FADE_OUT ? fading.post_delay : 0);
985 if (border.draw_masked_when_fading)
986 draw_border_function = DrawMaskedBorder_FIELD; /* update when fading */
988 DrawMaskedBorder_FIELD(); /* draw once */
990 else /* REDRAW_ALL */
998 fade_delay = fading.fade_delay;
999 post_delay = (fade_mode == FADE_MODE_FADE_OUT ? fading.post_delay : 0);
1004 if (!setup.fade_screens ||
1006 fading.fade_mode == FADE_MODE_NONE)
1008 if (!setup.fade_screens || fade_delay == 0)
1011 if (fade_mode == FADE_MODE_FADE_OUT)
1015 if (fade_mode == FADE_MODE_FADE_OUT &&
1016 fading.fade_mode != FADE_MODE_NONE)
1017 ClearRectangle(backbuffer, x, y, width, height);
1021 BlitBitmap(backbuffer, window, x, y, width, height, x, y);
1022 redraw_mask = REDRAW_NONE;
1030 FadeRectangle(bitmap, x, y, width, height, fade_mode, fade_delay, post_delay,
1031 draw_border_function);
1033 redraw_mask &= ~fade_mask;
1036 void FadeIn(int fade_mask)
1038 if (fading.fade_mode & FADE_TYPE_TRANSFORM)
1039 FadeExt(fade_mask, fading.fade_mode, FADE_TYPE_FADE_IN);
1041 FadeExt(fade_mask, FADE_MODE_FADE_IN, FADE_TYPE_FADE_IN);
1044 void FadeOut(int fade_mask)
1046 if (fading.fade_mode & FADE_TYPE_TRANSFORM)
1047 FadeExt(fade_mask, fading.fade_mode, FADE_TYPE_FADE_OUT);
1049 FadeExt(fade_mask, FADE_MODE_FADE_OUT, FADE_TYPE_FADE_OUT);
1051 global.border_status = game_status;
1054 static void FadeSetLeaveNext(struct TitleFadingInfo fading_leave, boolean set)
1056 static struct TitleFadingInfo fading_leave_stored;
1059 fading_leave_stored = fading_leave;
1061 fading = fading_leave_stored;
1064 void FadeSetEnterMenu()
1066 fading = menu.enter_menu;
1069 printf("::: storing enter_menu\n");
1072 FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
1075 void FadeSetLeaveMenu()
1077 fading = menu.leave_menu;
1080 printf("::: storing leave_menu\n");
1083 FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
1086 void FadeSetEnterScreen()
1088 fading = menu.enter_screen[game_status];
1091 printf("::: storing leave_screen[%d]\n", game_status);
1094 FadeSetLeaveNext(menu.leave_screen[game_status], TRUE); /* store */
1097 void FadeSetNextScreen()
1099 fading = menu.next_screen;
1102 printf("::: storing next_screen\n");
1105 // (do not overwrite fade mode set by FadeSetEnterScreen)
1106 // FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */
1109 void FadeSetLeaveScreen()
1112 printf("::: recalling last stored value\n");
1115 FadeSetLeaveNext(menu.leave_screen[game_status], FALSE); /* recall */
1118 void FadeSetFromType(int type)
1120 if (type & TYPE_ENTER_SCREEN)
1121 FadeSetEnterScreen();
1122 else if (type & TYPE_ENTER)
1124 else if (type & TYPE_LEAVE)
1128 void FadeSetDisabled()
1130 static struct TitleFadingInfo fading_none = { FADE_MODE_NONE, -1, -1, -1 };
1132 fading = fading_none;
1135 void FadeSkipNextFadeIn()
1137 FadeExt(0, FADE_MODE_SKIP_FADE_IN, FADE_TYPE_SKIP);
1140 void FadeSkipNextFadeOut()
1142 FadeExt(0, FADE_MODE_SKIP_FADE_OUT, FADE_TYPE_SKIP);
1145 void SetWindowBackgroundImageIfDefined(int graphic)
1147 if (graphic_info[graphic].bitmap)
1148 SetWindowBackgroundBitmap(graphic_info[graphic].bitmap);
1151 void SetMainBackgroundImageIfDefined(int graphic)
1153 if (graphic_info[graphic].bitmap)
1154 SetMainBackgroundBitmap(graphic_info[graphic].bitmap);
1157 void SetDoorBackgroundImageIfDefined(int graphic)
1159 if (graphic_info[graphic].bitmap)
1160 SetDoorBackgroundBitmap(graphic_info[graphic].bitmap);
1163 void SetWindowBackgroundImage(int graphic)
1165 SetWindowBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL :
1166 graphic_info[graphic].bitmap ?
1167 graphic_info[graphic].bitmap :
1168 graphic_info[IMG_BACKGROUND].bitmap);
1171 void SetMainBackgroundImage(int graphic)
1173 SetMainBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL :
1174 graphic_info[graphic].bitmap ?
1175 graphic_info[graphic].bitmap :
1176 graphic_info[IMG_BACKGROUND].bitmap);
1179 void SetDoorBackgroundImage(int graphic)
1181 SetDoorBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL :
1182 graphic_info[graphic].bitmap ?
1183 graphic_info[graphic].bitmap :
1184 graphic_info[IMG_BACKGROUND].bitmap);
1187 void SetPanelBackground()
1190 struct GraphicInfo *gfx = &graphic_info[IMG_BACKGROUND_PANEL];
1193 BlitBitmapTiled(gfx->bitmap, bitmap_db_panel, gfx->src_x, gfx->src_y,
1194 gfx->width, gfx->height, 0, 0, DXSIZE, DYSIZE);
1196 /* (ClearRectangle() only needed if panel bitmap is smaller than panel) */
1197 ClearRectangle(bitmap_db_panel, DX, DY, DXSIZE, DYSIZE);
1198 BlitBitmap(gfx->bitmap, bitmap_db_panel, gfx->src_x, gfx->src_y,
1199 MIN(gfx->width, DXSIZE), MIN(gfx->height, DYSIZE), 0, 0);
1202 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, bitmap_db_panel,
1203 DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, 0, 0);
1206 SetDoorBackgroundBitmap(bitmap_db_panel);
1209 void DrawBackground(int x, int y, int width, int height)
1211 /* !!! "drawto" might still point to playfield buffer here (see below) !!! */
1212 /* (when entering hall of fame after playing) */
1214 ClearRectangleOnBackground(drawto, x, y, width, height);
1216 ClearRectangleOnBackground(backbuffer, x, y, width, height);
1222 if (IN_GFX_FIELD_FULL(x, y))
1223 redraw_mask |= REDRAW_FIELD;
1224 else if (IN_GFX_DOOR_1(x, y))
1225 redraw_mask |= REDRAW_DOOR_1;
1226 else if (IN_GFX_DOOR_2(x, y))
1227 redraw_mask |= REDRAW_DOOR_2;
1228 else if (IN_GFX_DOOR_3(x, y))
1229 redraw_mask |= REDRAW_DOOR_3;
1231 /* (this only works for the current arrangement of playfield and panels) */
1233 redraw_mask |= REDRAW_FIELD;
1234 else if (y < gfx.vy)
1235 redraw_mask |= REDRAW_DOOR_1;
1237 redraw_mask |= REDRAW_DOOR_2;
1241 /* (this is just wrong (when drawing to one of the two door panel areas)) */
1242 redraw_mask |= REDRAW_FIELD;
1246 void DrawBackgroundForFont(int x, int y, int width, int height, int font_nr)
1248 struct FontBitmapInfo *font = getFontBitmapInfo(font_nr);
1250 if (font->bitmap == NULL)
1253 DrawBackground(x, y, width, height);
1256 void DrawBackgroundForGraphic(int x, int y, int width, int height, int graphic)
1258 struct GraphicInfo *g = &graphic_info[graphic];
1260 if (g->bitmap == NULL)
1263 DrawBackground(x, y, width, height);
1268 /* !!! "drawto" might still point to playfield buffer here (see above) !!! */
1269 /* (when entering hall of fame after playing) */
1270 DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
1272 /* !!! maybe this should be done before clearing the background !!! */
1273 if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
1275 ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE);
1276 SetDrawtoField(DRAW_BUFFERED);
1279 SetDrawtoField(DRAW_BACKBUFFER);
1282 void MarkTileDirty(int x, int y)
1284 int xx = redraw_x1 + x;
1285 int yy = redraw_y1 + y;
1287 if (!redraw[xx][yy])
1290 redraw[xx][yy] = TRUE;
1291 redraw_mask |= REDRAW_TILES;
1294 void SetBorderElement()
1298 BorderElement = EL_EMPTY;
1300 for (y = 0; y < lev_fieldy && BorderElement == EL_EMPTY; y++)
1302 for (x = 0; x < lev_fieldx; x++)
1304 if (!IS_INDESTRUCTIBLE(Feld[x][y]))
1305 BorderElement = EL_STEELWALL;
1307 if (y != 0 && y != lev_fieldy - 1 && x != lev_fieldx - 1)
1313 void FloodFillLevel(int from_x, int from_y, int fill_element,
1314 short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
1315 int max_fieldx, int max_fieldy)
1319 static int check[4][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };
1320 static int safety = 0;
1322 /* check if starting field still has the desired content */
1323 if (field[from_x][from_y] == fill_element)
1328 if (safety > max_fieldx * max_fieldy)
1329 Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
1331 old_element = field[from_x][from_y];
1332 field[from_x][from_y] = fill_element;
1334 for (i = 0; i < 4; i++)
1336 x = from_x + check[i][0];
1337 y = from_y + check[i][1];
1339 if (IN_FIELD(x, y, max_fieldx, max_fieldy) && field[x][y] == old_element)
1340 FloodFillLevel(x, y, fill_element, field, max_fieldx, max_fieldy);
1346 void SetRandomAnimationValue(int x, int y)
1348 gfx.anim_random_frame = GfxRandom[x][y];
1351 inline int getGraphicAnimationFrame(int graphic, int sync_frame)
1353 /* animation synchronized with global frame counter, not move position */
1354 if (graphic_info[graphic].anim_global_sync || sync_frame < 0)
1355 sync_frame = FrameCounter;
1357 return getAnimationFrame(graphic_info[graphic].anim_frames,
1358 graphic_info[graphic].anim_delay,
1359 graphic_info[graphic].anim_mode,
1360 graphic_info[graphic].anim_start_frame,
1364 void getSizedGraphicSourceExt(int graphic, int frame, int tilesize_raw,
1365 Bitmap **bitmap, int *x, int *y,
1366 boolean get_backside)
1370 int width_mult, width_div;
1371 int height_mult, height_div;
1375 { 15, 16, 2, 3 }, /* 1 x 1 */
1376 { 7, 8, 2, 3 }, /* 2 x 2 */
1377 { 3, 4, 2, 3 }, /* 4 x 4 */
1378 { 1, 2, 2, 3 }, /* 8 x 8 */
1379 { 0, 1, 2, 3 }, /* 16 x 16 */
1380 { 0, 1, 0, 1 }, /* 32 x 32 */
1382 struct GraphicInfo *g = &graphic_info[graphic];
1383 Bitmap *src_bitmap = g->bitmap;
1384 int tilesize = MIN(MAX(1, tilesize_raw), TILESIZE);
1385 int offset_calc_pos = log_2(tilesize);
1386 int width_mult = offset_calc[offset_calc_pos].width_mult;
1387 int width_div = offset_calc[offset_calc_pos].width_div;
1388 int height_mult = offset_calc[offset_calc_pos].height_mult;
1389 int height_div = offset_calc[offset_calc_pos].height_div;
1390 int startx = src_bitmap->width * width_mult / width_div;
1391 int starty = src_bitmap->height * height_mult / height_div;
1393 int src_x = (g->src_x + (get_backside ? g->offset2_x : 0)) *
1394 tilesize / TILESIZE;
1395 int src_y = (g->src_y + (get_backside ? g->offset2_y : 0)) *
1396 tilesize / TILESIZE;
1398 int src_x = g->src_x * tilesize / TILESIZE;
1399 int src_y = g->src_y * tilesize / TILESIZE;
1401 int width = g->width * tilesize / TILESIZE;
1402 int height = g->height * tilesize / TILESIZE;
1403 int offset_x = g->offset_x * tilesize / TILESIZE;
1404 int offset_y = g->offset_y * tilesize / TILESIZE;
1406 if (g->offset_y == 0) /* frames are ordered horizontally */
1408 int max_width = g->anim_frames_per_line * width;
1409 int pos = (src_y / height) * max_width + src_x + frame * offset_x;
1411 src_x = pos % max_width;
1412 src_y = src_y % height + pos / max_width * height;
1414 else if (g->offset_x == 0) /* frames are ordered vertically */
1416 int max_height = g->anim_frames_per_line * height;
1417 int pos = (src_x / width) * max_height + src_y + frame * offset_y;
1419 src_x = src_x % width + pos / max_height * width;
1420 src_y = pos % max_height;
1422 else /* frames are ordered diagonally */
1424 src_x = src_x + frame * offset_x;
1425 src_y = src_y + frame * offset_y;
1428 *bitmap = src_bitmap;
1429 *x = startx + src_x;
1430 *y = starty + src_y;
1433 void getFixedGraphicSourceExt(int graphic, int frame, Bitmap **bitmap,
1434 int *x, int *y, boolean get_backside)
1436 getSizedGraphicSourceExt(graphic, frame, TILESIZE, bitmap, x, y,
1440 void getSizedGraphicSource(int graphic, int frame, int tilesize_raw,
1441 Bitmap **bitmap, int *x, int *y)
1443 getSizedGraphicSourceExt(graphic, frame, tilesize_raw, bitmap, x, y, FALSE);
1446 void getFixedGraphicSource(int graphic, int frame,
1447 Bitmap **bitmap, int *x, int *y)
1449 getSizedGraphicSourceExt(graphic, frame, TILESIZE, bitmap, x, y, FALSE);
1452 void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
1455 getSizedGraphicSource(graphic, 0, MINI_TILESIZE, bitmap, x, y);
1457 struct GraphicInfo *g = &graphic_info[graphic];
1458 int mini_startx = 0;
1459 int mini_starty = g->bitmap->height * 2 / 3;
1461 *bitmap = g->bitmap;
1462 *x = mini_startx + g->src_x / 2;
1463 *y = mini_starty + g->src_y / 2;
1467 inline void getGraphicSourceExt(int graphic, int frame, Bitmap **bitmap,
1468 int *x, int *y, boolean get_backside)
1470 struct GraphicInfo *g = &graphic_info[graphic];
1471 int src_x = g->src_x + (get_backside ? g->offset2_x : 0);
1472 int src_y = g->src_y + (get_backside ? g->offset2_y : 0);
1475 if (TILESIZE_VAR != TILESIZE)
1476 return getSizedGraphicSourceExt(graphic, frame, TILESIZE_VAR, bitmap, x, y,
1480 *bitmap = g->bitmap;
1482 if (g->offset_y == 0) /* frames are ordered horizontally */
1484 int max_width = g->anim_frames_per_line * g->width;
1485 int pos = (src_y / g->height) * max_width + src_x + frame * g->offset_x;
1487 *x = pos % max_width;
1488 *y = src_y % g->height + pos / max_width * g->height;
1490 else if (g->offset_x == 0) /* frames are ordered vertically */
1492 int max_height = g->anim_frames_per_line * g->height;
1493 int pos = (src_x / g->width) * max_height + src_y + frame * g->offset_y;
1495 *x = src_x % g->width + pos / max_height * g->width;
1496 *y = pos % max_height;
1498 else /* frames are ordered diagonally */
1500 *x = src_x + frame * g->offset_x;
1501 *y = src_y + frame * g->offset_y;
1505 void getGraphicSource(int graphic, int frame, Bitmap **bitmap, int *x, int *y)
1507 getGraphicSourceExt(graphic, frame, bitmap, x, y, FALSE);
1510 void DrawGraphic(int x, int y, int graphic, int frame)
1513 if (!IN_SCR_FIELD(x, y))
1515 printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic);
1516 printf("DrawGraphic(): This should never happen!\n");
1522 DrawGraphicExt(drawto_field, FX + x * TILEX_VAR, FY + y * TILEY_VAR, graphic,
1525 DrawGraphicExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic, frame);
1527 MarkTileDirty(x, y);
1530 void DrawFixedGraphic(int x, int y, int graphic, int frame)
1533 if (!IN_SCR_FIELD(x, y))
1535 printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic);
1536 printf("DrawGraphic(): This should never happen!\n");
1541 DrawFixedGraphicExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic,
1543 MarkTileDirty(x, y);
1546 void DrawGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic,
1552 getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
1554 BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX_VAR, TILEY_VAR, x, y);
1556 BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y);
1560 void DrawFixedGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic,
1566 getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
1567 BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y);
1570 void DrawGraphicThruMask(int x, int y, int graphic, int frame)
1573 if (!IN_SCR_FIELD(x, y))
1575 printf("DrawGraphicThruMask(): x = %d,y = %d, graphic = %d\n",x,y,graphic);
1576 printf("DrawGraphicThruMask(): This should never happen!\n");
1582 DrawGraphicThruMaskExt(drawto_field, FX + x * TILEX_VAR, FY + y * TILEY_VAR,
1585 DrawGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic,
1588 MarkTileDirty(x, y);
1591 void DrawFixedGraphicThruMask(int x, int y, int graphic, int frame)
1594 if (!IN_SCR_FIELD(x, y))
1596 printf("DrawGraphicThruMask(): x = %d,y = %d, graphic = %d\n",x,y,graphic);
1597 printf("DrawGraphicThruMask(): This should never happen!\n");
1602 DrawFixedGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y * TILEY,
1604 MarkTileDirty(x, y);
1607 void DrawGraphicThruMaskExt(DrawBuffer *d, int dst_x, int dst_y, int graphic,
1613 getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
1615 SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
1616 dst_x - src_x, dst_y - src_y);
1618 BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX_VAR, TILEY_VAR,
1621 BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y);
1625 void DrawFixedGraphicThruMaskExt(DrawBuffer *d, int dst_x, int dst_y,
1626 int graphic, int frame)
1631 getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
1633 SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
1634 dst_x - src_x, dst_y - src_y);
1635 BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y);
1638 void DrawSizedGraphic(int x, int y, int graphic, int frame, int tilesize)
1640 DrawSizedGraphicExt(drawto, SX + x * tilesize, SY + y * tilesize, graphic,
1642 MarkTileDirty(x / tilesize, y / tilesize);
1645 void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame,
1651 getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y);
1652 BlitBitmap(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y);
1655 void DrawMiniGraphic(int x, int y, int graphic)
1657 DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic);
1658 MarkTileDirty(x / 2, y / 2);
1661 void DrawMiniGraphicExt(DrawBuffer *d, int x, int y, int graphic)
1666 getMiniGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
1667 BlitBitmap(src_bitmap, d, src_x, src_y, MINI_TILEX, MINI_TILEY, x, y);
1670 inline static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy,
1671 int graphic, int frame,
1672 int cut_mode, int mask_mode)
1677 int width = TILEX, height = TILEY;
1680 if (dx || dy) /* shifted graphic */
1682 if (x < BX1) /* object enters playfield from the left */
1689 else if (x > BX2) /* object enters playfield from the right */
1695 else if (x==BX1 && dx < 0) /* object leaves playfield to the left */
1701 else if (x==BX2 && dx > 0) /* object leaves playfield to the right */
1703 else if (dx) /* general horizontal movement */
1704 MarkTileDirty(x + SIGN(dx), y);
1706 if (y < BY1) /* object enters playfield from the top */
1708 if (cut_mode==CUT_BELOW) /* object completely above top border */
1716 else if (y > BY2) /* object enters playfield from the bottom */
1722 else if (y==BY1 && dy < 0) /* object leaves playfield to the top */
1728 else if (dy > 0 && cut_mode == CUT_ABOVE)
1730 if (y == BY2) /* object completely above bottom border */
1736 MarkTileDirty(x, y + 1);
1737 } /* object leaves playfield to the bottom */
1738 else if (dy > 0 && (y == BY2 || cut_mode == CUT_BELOW))
1740 else if (dy) /* general vertical movement */
1741 MarkTileDirty(x, y + SIGN(dy));
1745 if (!IN_SCR_FIELD(x, y))
1747 printf("DrawGraphicShifted(): x = %d, y = %d, graphic = %d\n",x,y,graphic);
1748 printf("DrawGraphicShifted(): This should never happen!\n");
1754 width = width * TILESIZE_VAR / TILESIZE;
1755 height = height * TILESIZE_VAR / TILESIZE;
1756 cx = cx * TILESIZE_VAR / TILESIZE;
1757 cy = cy * TILESIZE_VAR / TILESIZE;
1758 dx = dx * TILESIZE_VAR / TILESIZE;
1759 dy = dy * TILESIZE_VAR / TILESIZE;
1762 if (width > 0 && height > 0)
1764 getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
1770 dst_x = FX + x * TILEX_VAR + dx;
1771 dst_y = FY + y * TILEY_VAR + dy;
1773 dst_x = FX + x * TILEX + dx;
1774 dst_y = FY + y * TILEY + dy;
1777 if (mask_mode == USE_MASKING)
1779 SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
1780 dst_x - src_x, dst_y - src_y);
1781 BlitBitmapMasked(src_bitmap, drawto_field, src_x, src_y, width, height,
1785 BlitBitmap(src_bitmap, drawto_field, src_x, src_y, width, height,
1788 MarkTileDirty(x, y);
1792 inline static void DrawGraphicShiftedDouble(int x, int y, int dx, int dy,
1793 int graphic, int frame,
1794 int cut_mode, int mask_mode)
1800 int width = TILEX_VAR, height = TILEY_VAR;
1802 int width = TILEX, height = TILEY;
1806 int x2 = x + SIGN(dx);
1807 int y2 = y + SIGN(dy);
1809 /* !!! DOES NOT WORK FOR SLOW MOVEMENT !!! */
1810 int sync_frame = GfxFrame[LEVELX(x)][LEVELY(y)];
1812 /* movement with two-tile animations must be sync'ed with movement position,
1813 not with current GfxFrame (which can be higher when using slow movement) */
1814 int anim_pos = (dx ? ABS(dx) : ABS(dy));
1815 int anim_frames = graphic_info[graphic].anim_frames;
1817 /* (we also need anim_delay here for movement animations with less frames) */
1818 int anim_delay = graphic_info[graphic].anim_delay;
1819 int sync_frame = anim_pos * anim_frames * anim_delay / TILESIZE;
1821 int sync_frame = anim_pos * anim_frames / TILESIZE;
1824 boolean draw_start_tile = (cut_mode != CUT_ABOVE); /* only for falling! */
1825 boolean draw_end_tile = (cut_mode != CUT_BELOW); /* only for falling! */
1827 /* re-calculate animation frame for two-tile movement animation */
1828 frame = getGraphicAnimationFrame(graphic, sync_frame);
1832 printf("::: %d, %d, %d => %d [%d]\n",
1833 anim_pos, anim_frames, anim_delay, sync_frame, graphic);
1835 printf("::: %d, %d => %d\n",
1836 anim_pos, anim_frames, sync_frame);
1841 printf("::: %d [%d, %d] [%d] [%d]\n", frame, sync_frame, dy,
1842 GfxFrame[LEVELX(x)][LEVELY(y)], mask_mode);
1845 /* check if movement start graphic inside screen area and should be drawn */
1846 if (draw_start_tile && IN_SCR_FIELD(x1, y1))
1848 getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y, TRUE);
1851 dst_x = FX + x1 * TILEX_VAR;
1852 dst_y = FY + y1 * TILEY_VAR;
1854 dst_x = FX + x1 * TILEX;
1855 dst_y = FY + y1 * TILEY;
1858 if (mask_mode == USE_MASKING)
1860 SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
1861 dst_x - src_x, dst_y - src_y);
1862 BlitBitmapMasked(src_bitmap, drawto_field, src_x, src_y, width, height,
1866 BlitBitmap(src_bitmap, drawto_field, src_x, src_y, width, height,
1869 MarkTileDirty(x1, y1);
1872 /* check if movement end graphic inside screen area and should be drawn */
1873 if (draw_end_tile && IN_SCR_FIELD(x2, y2))
1875 getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y, FALSE);
1878 dst_x = FX + x2 * TILEX_VAR;
1879 dst_y = FY + y2 * TILEY_VAR;
1881 dst_x = FX + x2 * TILEX;
1882 dst_y = FY + y2 * TILEY;
1885 if (mask_mode == USE_MASKING)
1887 SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
1888 dst_x - src_x, dst_y - src_y);
1889 BlitBitmapMasked(src_bitmap, drawto_field, src_x, src_y, width, height,
1893 BlitBitmap(src_bitmap, drawto_field, src_x, src_y, width, height,
1896 MarkTileDirty(x2, y2);
1900 static void DrawGraphicShifted(int x, int y, int dx, int dy,
1901 int graphic, int frame,
1902 int cut_mode, int mask_mode)
1906 DrawGraphic(x, y, graphic, frame);
1911 if (graphic_info[graphic].double_movement) /* EM style movement images */
1912 DrawGraphicShiftedDouble(x, y, dx, dy, graphic, frame, cut_mode,mask_mode);
1914 DrawGraphicShiftedNormal(x, y, dx, dy, graphic, frame, cut_mode,mask_mode);
1917 void DrawGraphicShiftedThruMask(int x, int y, int dx, int dy, int graphic,
1918 int frame, int cut_mode)
1920 DrawGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, USE_MASKING);
1923 void DrawScreenElementExt(int x, int y, int dx, int dy, int element,
1924 int cut_mode, int mask_mode)
1926 int lx = LEVELX(x), ly = LEVELY(y);
1930 if (IN_LEV_FIELD(lx, ly))
1932 SetRandomAnimationValue(lx, ly);
1934 graphic = el_act_dir2img(element, GfxAction[lx][ly], GfxDir[lx][ly]);
1935 frame = getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]);
1937 /* do not use double (EM style) movement graphic when not moving */
1938 if (graphic_info[graphic].double_movement && !dx && !dy)
1940 graphic = el_act_dir2img(element, ACTION_DEFAULT, GfxDir[lx][ly]);
1941 frame = getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]);
1944 else /* border element */
1946 graphic = el2img(element);
1947 frame = getGraphicAnimationFrame(graphic, -1);
1950 if (element == EL_EXPANDABLE_WALL)
1952 boolean left_stopped = FALSE, right_stopped = FALSE;
1954 if (!IN_LEV_FIELD(lx - 1, ly) || IS_WALL(Feld[lx - 1][ly]))
1955 left_stopped = TRUE;
1956 if (!IN_LEV_FIELD(lx + 1, ly) || IS_WALL(Feld[lx + 1][ly]))
1957 right_stopped = TRUE;
1959 if (left_stopped && right_stopped)
1961 else if (left_stopped)
1963 graphic = IMG_EXPANDABLE_WALL_GROWING_RIGHT;
1964 frame = graphic_info[graphic].anim_frames - 1;
1966 else if (right_stopped)
1968 graphic = IMG_EXPANDABLE_WALL_GROWING_LEFT;
1969 frame = graphic_info[graphic].anim_frames - 1;
1974 DrawGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, mask_mode);
1975 else if (mask_mode == USE_MASKING)
1976 DrawGraphicThruMask(x, y, graphic, frame);
1978 DrawGraphic(x, y, graphic, frame);
1981 void DrawLevelElementExt(int x, int y, int dx, int dy, int element,
1982 int cut_mode, int mask_mode)
1984 if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
1985 DrawScreenElementExt(SCREENX(x), SCREENY(y), dx, dy, element,
1986 cut_mode, mask_mode);
1989 void DrawScreenElementShifted(int x, int y, int dx, int dy, int element,
1992 DrawScreenElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING);
1995 void DrawLevelElementShifted(int x, int y, int dx, int dy, int element,
1998 DrawLevelElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING);
2001 void DrawLevelElementThruMask(int x, int y, int element)
2003 DrawLevelElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING);
2006 void DrawLevelFieldThruMask(int x, int y)
2008 DrawLevelElementExt(x, y, 0, 0, Feld[x][y], NO_CUTTING, USE_MASKING);
2011 /* !!! implementation of quicksand is totally broken !!! */
2012 #define IS_CRUMBLED_TILE(x, y, e) \
2013 (GFX_CRUMBLED(e) && (!IN_LEV_FIELD(x, y) || \
2014 !IS_MOVING(x, y) || \
2015 (e) == EL_QUICKSAND_EMPTYING || \
2016 (e) == EL_QUICKSAND_FAST_EMPTYING))
2018 static void DrawLevelFieldCrumbledInnerCorners(int x, int y, int dx, int dy,
2023 int width, height, cx, cy;
2024 int sx = SCREENX(x), sy = SCREENY(y);
2025 int crumbled_border_size = graphic_info[graphic].border_size;
2028 getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
2030 for (i = 1; i < 4; i++)
2032 int dxx = (i & 1 ? dx : 0);
2033 int dyy = (i & 2 ? dy : 0);
2036 int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) :
2039 /* check if neighbour field is of same crumble type */
2040 boolean same = (IS_CRUMBLED_TILE(xx, yy, element) &&
2041 graphic_info[graphic].class ==
2042 graphic_info[el_act2crm(element, ACTION_DEFAULT)].class);
2044 /* return if check prevents inner corner */
2045 if (same == (dxx == dx && dyy == dy))
2049 /* if we reach this point, we have an inner corner */
2051 getGraphicSource(graphic, 1, &src_bitmap, &src_x, &src_y);
2054 width = crumbled_border_size * TILESIZE_VAR / TILESIZE;
2055 height = crumbled_border_size * TILESIZE_VAR / TILESIZE;
2056 cx = (dx > 0 ? TILEX - crumbled_border_size : 0) * TILESIZE_VAR / TILESIZE;
2057 cy = (dy > 0 ? TILEY - crumbled_border_size : 0) * TILESIZE_VAR / TILESIZE;
2059 BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy,
2060 width, height, FX + sx * TILEX_VAR + cx, FY + sy * TILEY_VAR + cy);
2062 width = crumbled_border_size;
2063 height = crumbled_border_size;
2064 cx = (dx > 0 ? TILEX - crumbled_border_size : 0);
2065 cy = (dy > 0 ? TILEY - crumbled_border_size : 0);
2067 BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy,
2068 width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy);
2072 static void DrawLevelFieldCrumbledBorders(int x, int y, int graphic, int frame,
2077 int width, height, bx, by, cx, cy;
2078 int sx = SCREENX(x), sy = SCREENY(y);
2079 int crumbled_border_size = graphic_info[graphic].border_size;
2082 getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
2084 /* draw simple, sloppy, non-corner-accurate crumbled border */
2087 width = (dir == 1 || dir == 2 ? crumbled_border_size : TILEX);
2088 height = (dir == 0 || dir == 3 ? crumbled_border_size : TILEY);
2089 cx = (dir == 2 ? TILEX - crumbled_border_size : 0);
2090 cy = (dir == 3 ? TILEY - crumbled_border_size : 0);
2092 if (dir == 1 || dir == 2) /* left or right crumbled border */
2094 width = crumbled_border_size;
2096 cx = (dir == 2 ? TILEX - crumbled_border_size : 0);
2099 else /* top or bottom crumbled border */
2102 height = crumbled_border_size;
2104 cy = (dir == 3 ? TILEY - crumbled_border_size : 0);
2109 BlitBitmap(src_bitmap, drawto_field,
2110 src_x + cx * TILESIZE_VAR / TILESIZE,
2111 src_y + cy * TILESIZE_VAR / TILESIZE,
2112 width * TILESIZE_VAR / TILESIZE,
2113 height * TILESIZE_VAR / TILESIZE,
2114 FX + sx * TILEX_VAR + cx * TILESIZE_VAR / TILESIZE,
2115 FY + sy * TILEY_VAR + cy * TILESIZE_VAR / TILESIZE);
2117 BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy,
2118 width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy);
2121 /* (remaining middle border part must be at least as big as corner part) */
2122 if (!(graphic_info[graphic].style & STYLE_ACCURATE_BORDERS) ||
2123 crumbled_border_size >= TILESIZE / 3)
2126 /* correct corners of crumbled border, if needed */
2129 for (i = -1; i <= 1; i+=2)
2131 int xx = x + (dir == 0 || dir == 3 ? i : 0);
2132 int yy = y + (dir == 1 || dir == 2 ? i : 0);
2133 int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) :
2136 /* check if neighbour field is of same crumble type */
2137 if (IS_CRUMBLED_TILE(xx, yy, element) &&
2138 graphic_info[graphic].class ==
2139 graphic_info[el_act2crm(element, ACTION_DEFAULT)].class)
2141 /* no crumbled corner, but continued crumbled border */
2143 int c1 = (dir == 2 || dir == 3 ? TILESIZE - crumbled_border_size : 0);
2144 int c2 = (i == 1 ? TILESIZE - crumbled_border_size : 0);
2145 int b1 = (i == 1 ? crumbled_border_size :
2146 TILESIZE - 2 * crumbled_border_size);
2148 width = crumbled_border_size;
2149 height = crumbled_border_size;
2151 if (dir == 1 || dir == 2)
2167 BlitBitmap(src_bitmap, drawto_field,
2168 src_x + bx * TILESIZE_VAR / TILESIZE,
2169 src_y + by * TILESIZE_VAR / TILESIZE,
2170 width * TILESIZE_VAR / TILESIZE,
2171 height * TILESIZE_VAR / TILESIZE,
2172 FX + sx * TILEX_VAR + cx * TILESIZE_VAR / TILESIZE,
2173 FY + sy * TILEY_VAR + cy * TILESIZE_VAR / TILESIZE);
2175 BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by,
2176 width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy);
2181 if (dir == 1 || dir == 2) /* left or right crumbled border */
2183 for (i = -1; i <= 1; i+=2)
2187 int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) :
2190 /* check if neighbour field is of same crumble type */
2191 if (IS_CRUMBLED_TILE(xx, yy, element) &&
2192 graphic_info[graphic].class ==
2193 graphic_info[el_act2crm(element, ACTION_DEFAULT)].class)
2195 /* no crumbled corner, but continued crumbled border */
2197 width = crumbled_border_size;
2198 height = crumbled_border_size;
2199 cx = (dir == 2 ? TILEX - crumbled_border_size : 0);
2200 cy = (i == 1 ? TILEY - crumbled_border_size : 0);
2202 by = (i == 1 ? crumbled_border_size :
2203 TILEY - 2 * crumbled_border_size);
2205 BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by,
2206 width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy);
2210 else /* top or bottom crumbled border */
2212 for (i = -1; i <= 1; i+=2)
2216 int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) :
2219 /* check if neighbour field is of same crumble type */
2220 if (IS_CRUMBLED_TILE(xx, yy, element) &&
2221 graphic_info[graphic].class ==
2222 graphic_info[el_act2crm(element, ACTION_DEFAULT)].class)
2224 /* no crumbled corner, but continued crumbled border */
2226 width = crumbled_border_size;
2227 height = crumbled_border_size;
2228 cx = (i == 1 ? TILEX - crumbled_border_size : 0);
2229 cy = (dir == 3 ? TILEY - crumbled_border_size : 0);
2230 bx = (i == 1 ? crumbled_border_size :
2231 TILEX - 2 * crumbled_border_size);
2234 BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by,
2235 width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy);
2242 static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame)
2244 int sx = SCREENX(x), sy = SCREENY(y);
2247 static int xy[4][2] =
2255 if (!IN_LEV_FIELD(x, y))
2258 element = TILE_GFX_ELEMENT(x, y);
2260 /* crumble field itself */
2261 if (IS_CRUMBLED_TILE(x, y, element))
2263 if (!IN_SCR_FIELD(sx, sy))
2266 for (i = 0; i < 4; i++)
2268 int xx = x + xy[i][0];
2269 int yy = y + xy[i][1];
2271 element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) :
2274 /* check if neighbour field is of same crumble type */
2276 if (IS_CRUMBLED_TILE(xx, yy, element) &&
2277 graphic_info[graphic].class ==
2278 graphic_info[el_act2crm(element, ACTION_DEFAULT)].class)
2281 if (IS_CRUMBLED_TILE(xx, yy, element))
2285 DrawLevelFieldCrumbledBorders(x, y, graphic, frame, i);
2288 if ((graphic_info[graphic].style & STYLE_INNER_CORNERS) &&
2289 graphic_info[graphic].anim_frames == 2)
2291 for (i = 0; i < 4; i++)
2293 int dx = (i & 1 ? +1 : -1);
2294 int dy = (i & 2 ? +1 : -1);
2296 DrawLevelFieldCrumbledInnerCorners(x, y, dx, dy, graphic);
2300 MarkTileDirty(sx, sy);
2302 else /* center field not crumbled -- crumble neighbour fields */
2304 for (i = 0; i < 4; i++)
2306 int xx = x + xy[i][0];
2307 int yy = y + xy[i][1];
2308 int sxx = sx + xy[i][0];
2309 int syy = sy + xy[i][1];
2311 if (!IN_LEV_FIELD(xx, yy) ||
2312 !IN_SCR_FIELD(sxx, syy))
2315 if (Feld[xx][yy] == EL_ELEMENT_SNAPPING)
2318 element = TILE_GFX_ELEMENT(xx, yy);
2320 if (!IS_CRUMBLED_TILE(xx, yy, element))
2323 graphic = el_act2crm(element, ACTION_DEFAULT);
2325 DrawLevelFieldCrumbledBorders(xx, yy, graphic, 0, 3 - i);
2327 MarkTileDirty(sxx, syy);
2332 void DrawLevelFieldCrumbled(int x, int y)
2336 if (!IN_LEV_FIELD(x, y))
2340 /* !!! CHECK THIS !!! */
2343 if (Feld[x][y] == EL_ELEMENT_SNAPPING &&
2344 GFX_CRUMBLED(GfxElement[x][y]))
2347 if (Feld[x][y] == EL_ELEMENT_SNAPPING &&
2348 GfxElement[x][y] != EL_UNDEFINED &&
2349 GFX_CRUMBLED(GfxElement[x][y]))
2351 DrawLevelFieldCrumbledDigging(x, y, GfxDir[x][y], GfxFrame[x][y]);
2358 graphic = el_act2crm(TILE_GFX_ELEMENT(x, y), ACTION_DEFAULT);
2360 graphic = el_act2crm(Feld[x][y], ACTION_DEFAULT);
2363 DrawLevelFieldCrumbledExt(x, y, graphic, 0);
2366 void DrawLevelFieldCrumbledDigging(int x, int y, int direction,
2369 int graphic1 = el_act_dir2img(GfxElement[x][y], ACTION_DIGGING, direction);
2370 int graphic2 = el_act_dir2crm(GfxElement[x][y], ACTION_DIGGING, direction);
2371 int frame1 = getGraphicAnimationFrame(graphic1, step_frame);
2372 int frame2 = getGraphicAnimationFrame(graphic2, step_frame);
2373 int sx = SCREENX(x), sy = SCREENY(y);
2375 DrawGraphic(sx, sy, graphic1, frame1);
2376 DrawLevelFieldCrumbledExt(x, y, graphic2, frame2);
2379 void DrawLevelFieldCrumbledNeighbours(int x, int y)
2381 int sx = SCREENX(x), sy = SCREENY(y);
2382 static int xy[4][2] =
2391 for (i = 0; i < 4; i++)
2393 int xx = x + xy[i][0];
2394 int yy = y + xy[i][1];
2395 int sxx = sx + xy[i][0];
2396 int syy = sy + xy[i][1];
2398 if (!IN_LEV_FIELD(xx, yy) ||
2399 !IN_SCR_FIELD(sxx, syy) ||
2400 !GFX_CRUMBLED(Feld[xx][yy]) ||
2404 DrawLevelField(xx, yy);
2408 static int getBorderElement(int x, int y)
2412 { EL_STEELWALL_TOPLEFT, EL_INVISIBLE_STEELWALL_TOPLEFT },
2413 { EL_STEELWALL_TOPRIGHT, EL_INVISIBLE_STEELWALL_TOPRIGHT },
2414 { EL_STEELWALL_BOTTOMLEFT, EL_INVISIBLE_STEELWALL_BOTTOMLEFT },
2415 { EL_STEELWALL_BOTTOMRIGHT, EL_INVISIBLE_STEELWALL_BOTTOMRIGHT },
2416 { EL_STEELWALL_VERTICAL, EL_INVISIBLE_STEELWALL_VERTICAL },
2417 { EL_STEELWALL_HORIZONTAL, EL_INVISIBLE_STEELWALL_HORIZONTAL },
2418 { EL_STEELWALL, EL_INVISIBLE_STEELWALL }
2420 int steel_type = (BorderElement == EL_STEELWALL ? 0 : 1);
2421 int steel_position = (x == -1 && y == -1 ? 0 :
2422 x == lev_fieldx && y == -1 ? 1 :
2423 x == -1 && y == lev_fieldy ? 2 :
2424 x == lev_fieldx && y == lev_fieldy ? 3 :
2425 x == -1 || x == lev_fieldx ? 4 :
2426 y == -1 || y == lev_fieldy ? 5 : 6);
2428 return border[steel_position][steel_type];
2431 void DrawScreenElement(int x, int y, int element)
2433 DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, NO_MASKING);
2434 DrawLevelFieldCrumbled(LEVELX(x), LEVELY(y));
2437 void DrawLevelElement(int x, int y, int element)
2439 if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
2440 DrawScreenElement(SCREENX(x), SCREENY(y), element);
2443 void DrawScreenField(int x, int y)
2445 int lx = LEVELX(x), ly = LEVELY(y);
2446 int element, content;
2448 if (!IN_LEV_FIELD(lx, ly))
2450 if (lx < -1 || lx > lev_fieldx || ly < -1 || ly > lev_fieldy)
2453 element = getBorderElement(lx, ly);
2455 DrawScreenElement(x, y, element);
2460 element = Feld[lx][ly];
2461 content = Store[lx][ly];
2463 if (IS_MOVING(lx, ly))
2465 int horiz_move = (MovDir[lx][ly] == MV_LEFT || MovDir[lx][ly] == MV_RIGHT);
2466 boolean cut_mode = NO_CUTTING;
2468 if (element == EL_QUICKSAND_EMPTYING ||
2469 element == EL_QUICKSAND_FAST_EMPTYING ||
2470 element == EL_MAGIC_WALL_EMPTYING ||
2471 element == EL_BD_MAGIC_WALL_EMPTYING ||
2472 element == EL_DC_MAGIC_WALL_EMPTYING ||
2473 element == EL_AMOEBA_DROPPING)
2474 cut_mode = CUT_ABOVE;
2475 else if (element == EL_QUICKSAND_FILLING ||
2476 element == EL_QUICKSAND_FAST_FILLING ||
2477 element == EL_MAGIC_WALL_FILLING ||
2478 element == EL_BD_MAGIC_WALL_FILLING ||
2479 element == EL_DC_MAGIC_WALL_FILLING)
2480 cut_mode = CUT_BELOW;
2483 if (lx == 9 && ly == 1)
2484 printf("::: %s [%d] [%d, %d] [%d]\n",
2485 EL_NAME(TILE_GFX_ELEMENT(lx, ly)),
2486 el_act2crm(TILE_GFX_ELEMENT(lx, ly), ACTION_DEFAULT),
2487 element_info[EL_QUICKSAND_EMPTYING].graphic[ACTION_DEFAULT],
2488 element_info[EL_QUICKSAND_EMPTYING].crumbled[ACTION_DEFAULT],
2489 GFX_CRUMBLED(TILE_GFX_ELEMENT(lx, ly)));
2492 if (cut_mode == CUT_ABOVE)
2494 DrawScreenElement(x, y, element);
2496 DrawScreenElementShifted(x, y, 0, 0, element, NO_CUTTING);
2499 DrawScreenElement(x, y, EL_EMPTY);
2502 DrawScreenElementShifted(x, y, MovPos[lx][ly], 0, element, NO_CUTTING);
2503 else if (cut_mode == NO_CUTTING)
2504 DrawScreenElementShifted(x, y, 0, MovPos[lx][ly], element, cut_mode);
2507 DrawScreenElementShifted(x, y, 0, MovPos[lx][ly], content, cut_mode);
2510 if (cut_mode == CUT_BELOW &&
2511 IN_LEV_FIELD(lx, ly + 1) && IN_SCR_FIELD(x, y + 1))
2512 DrawLevelElement(lx, ly + 1, element);
2516 if (content == EL_ACID)
2518 int dir = MovDir[lx][ly];
2519 int newlx = lx + (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0);
2520 int newly = ly + (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0);
2522 DrawLevelElementThruMask(newlx, newly, EL_ACID);
2525 else if (IS_BLOCKED(lx, ly))
2530 boolean cut_mode = NO_CUTTING;
2531 int element_old, content_old;
2533 Blocked2Moving(lx, ly, &oldx, &oldy);
2536 horiz_move = (MovDir[oldx][oldy] == MV_LEFT ||
2537 MovDir[oldx][oldy] == MV_RIGHT);
2539 element_old = Feld[oldx][oldy];
2540 content_old = Store[oldx][oldy];
2542 if (element_old == EL_QUICKSAND_EMPTYING ||
2543 element_old == EL_QUICKSAND_FAST_EMPTYING ||
2544 element_old == EL_MAGIC_WALL_EMPTYING ||
2545 element_old == EL_BD_MAGIC_WALL_EMPTYING ||
2546 element_old == EL_DC_MAGIC_WALL_EMPTYING ||
2547 element_old == EL_AMOEBA_DROPPING)
2548 cut_mode = CUT_ABOVE;
2550 DrawScreenElement(x, y, EL_EMPTY);
2553 DrawScreenElementShifted(sx, sy, MovPos[oldx][oldy], 0, element_old,
2555 else if (cut_mode == NO_CUTTING)
2556 DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], element_old,
2559 DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], content_old,
2562 else if (IS_DRAWABLE(element))
2563 DrawScreenElement(x, y, element);
2565 DrawScreenElement(x, y, EL_EMPTY);
2568 void DrawLevelField(int x, int y)
2570 if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
2571 DrawScreenField(SCREENX(x), SCREENY(y));
2572 else if (IS_MOVING(x, y))
2576 Moving2Blocked(x, y, &newx, &newy);
2577 if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy)))
2578 DrawScreenField(SCREENX(newx), SCREENY(newy));
2580 else if (IS_BLOCKED(x, y))
2584 Blocked2Moving(x, y, &oldx, &oldy);
2585 if (IN_SCR_FIELD(SCREENX(oldx), SCREENY(oldy)))
2586 DrawScreenField(SCREENX(oldx), SCREENY(oldy));
2590 void DrawMiniElement(int x, int y, int element)
2594 graphic = el2edimg(element);
2595 DrawMiniGraphic(x, y, graphic);
2598 void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y)
2600 int x = sx + scroll_x, y = sy + scroll_y;
2602 if (x < -1 || x > lev_fieldx || y < -1 || y > lev_fieldy)
2603 DrawMiniElement(sx, sy, EL_EMPTY);
2604 else if (x > -1 && x < lev_fieldx && y > -1 && y < lev_fieldy)
2605 DrawMiniElement(sx, sy, Feld[x][y]);
2607 DrawMiniGraphic(sx, sy, el2edimg(getBorderElement(x, y)));
2610 void DrawEnvelopeBackgroundTiles(int graphic, int startx, int starty,
2611 int x, int y, int xsize, int ysize,
2612 int tile_width, int tile_height)
2616 int dst_x = startx + x * tile_width;
2617 int dst_y = starty + y * tile_height;
2618 int width = graphic_info[graphic].width;
2619 int height = graphic_info[graphic].height;
2620 int inner_width_raw = MAX(width - 2 * tile_width, tile_width);
2621 int inner_height_raw = MAX(height - 2 * tile_height, tile_height);
2622 int inner_width = inner_width_raw - (inner_width_raw % tile_width);
2623 int inner_height = inner_height_raw - (inner_height_raw % tile_height);
2624 int inner_sx = (width >= 3 * tile_width ? tile_width : 0);
2625 int inner_sy = (height >= 3 * tile_height ? tile_height : 0);
2626 boolean draw_masked = graphic_info[graphic].draw_masked;
2628 getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
2630 if (src_bitmap == NULL || width < tile_width || height < tile_height)
2632 ClearRectangle(drawto, dst_x, dst_y, tile_width, tile_height);
2636 src_x += (x == 0 ? 0 : x == xsize - 1 ? width - tile_width :
2637 inner_sx + (x - 1) * tile_width % inner_width);
2638 src_y += (y == 0 ? 0 : y == ysize - 1 ? height - tile_height :
2639 inner_sy + (y - 1) * tile_height % inner_height);
2643 SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
2644 dst_x - src_x, dst_y - src_y);
2645 BlitBitmapMasked(src_bitmap, drawto, src_x, src_y, tile_width, tile_height,
2649 BlitBitmap(src_bitmap, drawto, src_x, src_y, tile_width, tile_height,
2653 void DrawEnvelopeBackground(int graphic, int startx, int starty,
2654 int x, int y, int xsize, int ysize, int font_nr)
2656 int font_width = getFontWidth(font_nr);
2657 int font_height = getFontHeight(font_nr);
2659 DrawEnvelopeBackgroundTiles(graphic, startx, starty, x, y, xsize, ysize,
2660 font_width, font_height);
2663 void AnimateEnvelope(int envelope_nr, int anim_mode, int action)
2665 int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr;
2666 Bitmap *src_bitmap = graphic_info[graphic].bitmap;
2667 int mask_mode = (src_bitmap != NULL ? BLIT_MASKED : BLIT_ON_BACKGROUND);
2668 boolean ffwd_delay = (tape.playing && tape.fast_forward);
2669 boolean no_delay = (tape.warp_forward);
2670 unsigned int anim_delay = 0;
2671 int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
2672 int anim_delay_value = (no_delay ? 0 : frame_delay_value);
2673 int font_nr = FONT_ENVELOPE_1 + envelope_nr;
2674 int font_width = getFontWidth(font_nr);
2675 int font_height = getFontHeight(font_nr);
2676 int max_xsize = level.envelope[envelope_nr].xsize;
2677 int max_ysize = level.envelope[envelope_nr].ysize;
2678 int xstart = (anim_mode & ANIM_VERTICAL ? max_xsize : 0);
2679 int ystart = (anim_mode & ANIM_HORIZONTAL ? max_ysize : 0);
2680 int xend = max_xsize;
2681 int yend = (anim_mode != ANIM_DEFAULT ? max_ysize : 0);
2682 int xstep = (xstart < xend ? 1 : 0);
2683 int ystep = (ystart < yend || xstep == 0 ? 1 : 0);
2686 for (x = xstart, y = ystart; x <= xend && y <= yend; x += xstep, y += ystep)
2688 int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2;
2689 int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2;
2690 int sx = SX + (SXSIZE - xsize * font_width) / 2;
2691 int sy = SY + (SYSIZE - ysize * font_height) / 2;
2694 SetDrawtoField(DRAW_BUFFERED);
2697 BlitScreenToBitmap(backbuffer);
2699 BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY);
2702 SetDrawtoField(DRAW_BACKBUFFER);
2704 for (yy = 0; yy < ysize; yy++)
2705 for (xx = 0; xx < xsize; xx++)
2706 DrawEnvelopeBackground(graphic, sx, sy, xx, yy, xsize, ysize, font_nr);
2709 DrawTextBuffer(sx + font_width, sy + font_height,
2710 level.envelope[envelope_nr].text, font_nr, max_xsize,
2711 xsize - 2, ysize - 2, 0, mask_mode,
2712 level.envelope[envelope_nr].autowrap,
2713 level.envelope[envelope_nr].centered, FALSE);
2715 DrawTextToTextArea(sx + font_width, sy + font_height,
2716 level.envelope[envelope_nr].text, font_nr, max_xsize,
2717 xsize - 2, ysize - 2, mask_mode);
2720 redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
2723 WaitUntilDelayReached(&anim_delay, anim_delay_value / 2);
2727 void ShowEnvelope(int envelope_nr)
2729 int element = EL_ENVELOPE_1 + envelope_nr;
2730 int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr;
2731 int sound_opening = element_info[element].sound[ACTION_OPENING];
2732 int sound_closing = element_info[element].sound[ACTION_CLOSING];
2733 boolean ffwd_delay = (tape.playing && tape.fast_forward);
2734 boolean no_delay = (tape.warp_forward);
2735 int normal_delay_value = ONE_SECOND_DELAY / (ffwd_delay ? 2 : 1);
2736 int wait_delay_value = (no_delay ? 0 : normal_delay_value);
2737 int anim_mode = graphic_info[graphic].anim_mode;
2738 int main_anim_mode = (anim_mode == ANIM_NONE ? ANIM_VERTICAL|ANIM_HORIZONTAL:
2739 anim_mode == ANIM_DEFAULT ? ANIM_VERTICAL : anim_mode);
2741 game.envelope_active = TRUE; /* needed for RedrawPlayfield() events */
2743 PlayMenuSoundStereo(sound_opening, SOUND_MIDDLE);
2745 if (anim_mode == ANIM_DEFAULT)
2746 AnimateEnvelope(envelope_nr, ANIM_DEFAULT, ACTION_OPENING);
2748 AnimateEnvelope(envelope_nr, main_anim_mode, ACTION_OPENING);
2751 Delay(wait_delay_value);
2753 WaitForEventToContinue();
2755 PlayMenuSoundStereo(sound_closing, SOUND_MIDDLE);
2757 if (anim_mode != ANIM_NONE)
2758 AnimateEnvelope(envelope_nr, main_anim_mode, ACTION_CLOSING);
2760 if (anim_mode == ANIM_DEFAULT)
2761 AnimateEnvelope(envelope_nr, ANIM_DEFAULT, ACTION_CLOSING);
2763 game.envelope_active = FALSE;
2765 SetDrawtoField(DRAW_BUFFERED);
2767 redraw_mask |= REDRAW_FIELD;
2771 static void setRequestPosition(int *x, int *y, boolean add_border_size)
2773 int border_size = request.border_size;
2774 int sx_center = (request.x != -1 ? request.x : SX + SXSIZE / 2);
2775 int sy_center = (request.y != -1 ? request.y : SY + SYSIZE / 2);
2776 int sx = sx_center - request.width / 2;
2777 int sy = sy_center - request.height / 2;
2779 if (add_border_size)
2789 void DrawEnvelopeRequest(char *text)
2791 char *text_final = text;
2792 char *text_door_style = NULL;
2793 int graphic = IMG_BACKGROUND_REQUEST;
2794 Bitmap *src_bitmap = graphic_info[graphic].bitmap;
2795 int mask_mode = (src_bitmap != NULL ? BLIT_MASKED : BLIT_ON_BACKGROUND);
2796 int font_nr = FONT_REQUEST;
2797 int font_width = getFontWidth(font_nr);
2798 int font_height = getFontHeight(font_nr);
2799 int border_size = request.border_size;
2800 int line_spacing = request.line_spacing;
2801 int line_height = font_height + line_spacing;
2802 int text_width = request.width - 2 * border_size;
2803 int text_height = request.height - 2 * border_size;
2804 int line_length = text_width / font_width;
2805 int max_lines = text_height / line_height;
2806 int width = request.width;
2807 int height = request.height;
2808 int tile_size = request.step_offset;
2809 int x_steps = width / tile_size;
2810 int y_steps = height / tile_size;
2814 if (request.wrap_single_words)
2816 char *src_text_ptr, *dst_text_ptr;
2818 text_door_style = checked_malloc(2 * strlen(text) + 1);
2820 src_text_ptr = text;
2821 dst_text_ptr = text_door_style;
2823 while (*src_text_ptr)
2825 if (*src_text_ptr == ' ' ||
2826 *src_text_ptr == '?' ||
2827 *src_text_ptr == '!')
2828 *dst_text_ptr++ = '\n';
2830 if (*src_text_ptr != ' ')
2831 *dst_text_ptr++ = *src_text_ptr;
2836 *dst_text_ptr = '\0';
2838 text_final = text_door_style;
2841 setRequestPosition(&sx, &sy, FALSE);
2843 ClearRectangle(backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE);
2845 for (y = 0; y < y_steps; y++)
2846 for (x = 0; x < x_steps; x++)
2847 DrawEnvelopeBackgroundTiles(graphic, sx, sy,
2848 x, y, x_steps, y_steps,
2849 tile_size, tile_size);
2851 DrawTextBuffer(sx + border_size, sy + border_size, text_final, font_nr,
2852 line_length, -1, max_lines, line_spacing, mask_mode,
2853 request.autowrap, request.centered, FALSE);
2855 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
2856 RedrawGadget(tool_gadget[i]);
2858 // store readily prepared envelope request for later use when animating
2859 BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
2863 BlitBitmap(bitmap_db_store, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
2864 BlitBitmap(bitmap_db_cross, backbuffer, sx, sy, width, height, sx, sy);
2866 redraw_mask = REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
2871 BlitBitmap(bitmap_db_store, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
2873 redraw_mask = REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
2879 if (text_door_style)
2880 free(text_door_style);
2885 void AnimateEnvelopeRequest(int anim_mode, int action)
2887 int graphic = IMG_BACKGROUND_REQUEST;
2888 boolean draw_masked = graphic_info[graphic].draw_masked;
2890 int delay_value_normal = request.step_delay;
2891 int delay_value_fast = delay_value_normal / 2;
2893 int delay_value_normal = GameFrameDelay;
2894 int delay_value_fast = FfwdFrameDelay;
2896 boolean ffwd_delay = (tape.playing && tape.fast_forward);
2897 boolean no_delay = (tape.warp_forward);
2898 int delay_value = (ffwd_delay ? delay_value_fast : delay_value_normal);
2899 int anim_delay_value = (no_delay ? 0 : delay_value + 500 * 0);
2900 unsigned int anim_delay = 0;
2902 int width = request.width;
2903 int height = request.height;
2904 int tile_size = request.step_offset;
2905 int max_xsize = width / tile_size;
2906 int max_ysize = height / tile_size;
2907 int max_xsize_inner = max_xsize - 2;
2908 int max_ysize_inner = max_ysize - 2;
2910 int xstart = (anim_mode & ANIM_VERTICAL ? max_xsize_inner : 0);
2911 int ystart = (anim_mode & ANIM_HORIZONTAL ? max_ysize_inner : 0);
2912 int xend = max_xsize_inner;
2913 int yend = (anim_mode != ANIM_DEFAULT ? max_ysize_inner : 0);
2914 int xstep = (xstart < xend ? 1 : 0);
2915 int ystep = (ystart < yend || xstep == 0 ? 1 : 0);
2918 for (x = xstart, y = ystart; x <= xend && y <= yend; x += xstep, y += ystep)
2920 int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2;
2921 int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2;
2922 int sx_center = (request.x != -1 ? request.x : SX + SXSIZE / 2);
2923 int sy_center = (request.y != -1 ? request.y : SY + SYSIZE / 2);
2924 int src_x = sx_center - width / 2;
2925 int src_y = sy_center - height / 2;
2926 int dst_x = sx_center - xsize * tile_size / 2;
2927 int dst_y = sy_center - ysize * tile_size / 2;
2928 int xsize_size_left = (xsize - 1) * tile_size;
2929 int ysize_size_top = (ysize - 1) * tile_size;
2930 int max_xsize_pos = (max_xsize - 1) * tile_size;
2931 int max_ysize_pos = (max_ysize - 1) * tile_size;
2934 BlitBitmap(bitmap_db_store, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
2937 for (yy = 0; yy < 2; yy++)
2939 for (xx = 0; xx < 2; xx++)
2941 int src_xx = src_x + xx * max_xsize_pos;
2942 int src_yy = src_y + yy * max_ysize_pos;
2943 int dst_xx = dst_x + xx * xsize_size_left;
2944 int dst_yy = dst_y + yy * ysize_size_top;
2945 int xx_size = (xx ? tile_size : xsize_size_left);
2946 int yy_size = (yy ? tile_size : ysize_size_top);
2949 BlitBitmapMasked(bitmap_db_cross, backbuffer,
2950 src_xx, src_yy, xx_size, yy_size, dst_xx, dst_yy);
2952 BlitBitmap(bitmap_db_cross, backbuffer,
2953 src_xx, src_yy, xx_size, yy_size, dst_xx, dst_yy);
2957 BlitBitmap(bitmap_db_cross, backbuffer,
2959 xsize_size_left, ysize_size_top,
2961 BlitBitmap(bitmap_db_cross, backbuffer,
2962 src_x + max_xsize_pos, src_y,
2963 tile_size, ysize_size_top,
2964 dst_x + xsize_size_left, dst_y);
2965 BlitBitmap(bitmap_db_cross, backbuffer,
2966 src_x, src_y + max_ysize_pos,
2967 xsize_size_left, tile_size,
2968 dst_x, dst_y + ysize_size_top);
2969 BlitBitmap(bitmap_db_cross, backbuffer,
2970 src_x + max_xsize_pos, src_y + max_ysize_pos,
2971 tile_size, tile_size,
2972 dst_x + xsize_size_left, dst_y + ysize_size_top);
2976 redraw_mask = REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
2977 // redraw_mask |= REDRAW_ALL | REDRAW_FROM_BACKBUFFER;
2979 redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
2989 WaitUntilDelayReached(&anim_delay, anim_delay_value / 2);
2995 void AnimateEnvelopeRequest(char *text, int anim_mode, int action)
2998 int envelope_nr = 0;
3001 int graphic = IMG_BACKGROUND_REQUEST;
3003 int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr;
3005 Bitmap *src_bitmap = graphic_info[graphic].bitmap;
3006 int mask_mode = (src_bitmap != NULL ? BLIT_MASKED : BLIT_ON_BACKGROUND);
3007 boolean ffwd_delay = (tape.playing && tape.fast_forward);
3008 boolean no_delay = (tape.warp_forward);
3009 unsigned int anim_delay = 0;
3010 int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
3011 int anim_delay_value = (no_delay ? 0 : frame_delay_value + 500 * 0);
3013 int max_word_len = maxWordLengthInString(text);
3014 int font_nr = (max_word_len > 7 ? FONT_TEXT_1 : FONT_TEXT_2);
3016 int font_nr = FONT_ENVELOPE_1 + envelope_nr;
3018 int font_width = getFontWidth(font_nr);
3019 int font_height = getFontHeight(font_nr);
3020 int line_spacing = 2 * 1;
3024 int max_xsize = DXSIZE / font_width;
3025 // int max_ysize = DYSIZE / font_height;
3026 int max_ysize = DYSIZE / (font_height + line_spacing);
3028 int max_xsize = 7; /* tools.c: MAX_REQUEST_LINE_FONT1_LEN == 7 */
3029 int max_ysize = 13; /* tools.c: MAX_REQUEST_LINES == 13 */
3033 int max_xsize = level.envelope[envelope_nr].xsize;
3034 int max_ysize = level.envelope[envelope_nr].ysize;
3036 int xstart = (anim_mode & ANIM_VERTICAL ? max_xsize : 0);
3037 int ystart = (anim_mode & ANIM_HORIZONTAL ? max_ysize : 0);
3038 int xend = max_xsize;
3039 int yend = (anim_mode != ANIM_DEFAULT ? max_ysize : 0);
3040 int xstep = (xstart < xend ? 1 : 0);
3041 int ystep = (ystart < yend || xstep == 0 ? 1 : 0);
3046 char *text_copy = getStringCopy(text);
3049 font_nr = FONT_TEXT_2;
3051 if (maxWordLengthInString(text) > 7) /* MAX_REQUEST_LINE_FONT1_LEN == 7 */
3053 max_xsize = 10; /* tools.c: MAX_REQUEST_LINE_FONT2_LEN == 10 */
3054 font_nr = FONT_TEXT_1;
3057 int max_word_len = 0;
3059 char *text_copy = getStringCopy(text);
3061 font_nr = FONT_TEXT_2;
3063 for (text_ptr = text; *text_ptr; text_ptr++)
3065 max_word_len = (*text_ptr != ' ' ? max_word_len + 1 : 0);
3067 if (max_word_len > 7) /* tools.c: MAX_REQUEST_LINE_FONT1_LEN == 7 */
3069 max_xsize = 10; /* tools.c: MAX_REQUEST_LINE_FONT2_LEN == 10 */
3070 font_nr = FONT_TEXT_1;
3079 for (text_ptr = text_copy; *text_ptr; text_ptr++)
3080 if (*text_ptr == ' ')
3085 dDX = SX + (SXSIZE - DXSIZE) / 2 - DX;
3086 dDY = SY + (SYSIZE - DYSIZE) / 2 - DY;
3088 dDX = SX + SXSIZE / 2 - max_xsize * font_width / 2 - DX;
3089 dDY = SY + SYSIZE / 2 - max_ysize * font_height / 2 - DY;
3092 for (x = xstart, y = ystart; x <= xend && y <= yend; x += xstep, y += ystep)
3094 int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2;
3095 int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2;
3096 int sx = SX + (SXSIZE - xsize * font_width) / 2;
3097 // int sy = SX + (SYSIZE - ysize * font_height) / 2;
3098 int sy = SY + (SYSIZE - ysize * (font_height + line_spacing)) / 2;
3102 BlitBitmap(bitmap_db_store, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
3104 SetDrawtoField(DRAW_BUFFERED);
3107 BlitScreenToBitmap(backbuffer);
3109 BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY);
3112 SetDrawtoField(DRAW_BACKBUFFER);
3115 for (yy = 0; yy < ysize; yy++)
3116 for (xx = 0; xx < xsize; xx++)
3117 DrawEnvelopeBackgroundTiles(graphic, sx, sy, xx, yy, xsize, ysize,
3118 getFontWidth(font_nr),
3119 getFontHeight(font_nr) + line_spacing);
3124 DrawTextBuffer(sx + font_width, sy + font_height + 8,
3125 text_copy, font_nr, max_xsize,
3126 xsize - 2, ysize - 2, line_spacing, mask_mode,
3127 FALSE, TRUE, FALSE);
3129 DrawTextBuffer(sx + font_width, sy + font_height,
3130 level.envelope[envelope_nr].text, font_nr, max_xsize,
3131 xsize - 2, ysize - 2, 0, mask_mode,
3132 level.envelope[envelope_nr].autowrap,
3133 level.envelope[envelope_nr].centered, FALSE);
3137 DrawTextToTextArea(sx + font_width, sy + font_height,
3138 level.envelope[envelope_nr].text, font_nr, max_xsize,
3139 xsize - 2, ysize - 2, mask_mode);
3142 /* copy request gadgets to door backbuffer */
3145 if ((ysize - 2) > 13)
3146 BlitBitmap(bitmap_db_door, drawto,
3147 DOOR_GFX_PAGEX1 + (DXSIZE - (xsize - 2) * font_width) / 2,
3148 DOOR_GFX_PAGEY1 + 13 * font_height,
3149 (xsize - 2) * font_width,
3150 (ysize - 2 - 13) * font_height,
3152 sy + font_height * (1 + 13));
3154 if ((ysize - 2) > 13)
3155 BlitBitmap(bitmap_db_door, drawto,
3156 DOOR_GFX_PAGEX1 + (DXSIZE - (xsize - 2) * font_width) / 2,
3157 DOOR_GFX_PAGEY1 + 11 * (font_height + line_spacing * 0),
3158 (xsize - 2) * font_width,
3159 (ysize - 2 - 13) * (font_height + line_spacing),
3161 sy + (font_height + line_spacing) * (1 + 13));
3163 if ((ysize - 2) > 13)
3164 BlitBitmap(bitmap_db_door, drawto,
3165 DOOR_GFX_PAGEX1 + (DXSIZE - (xsize - 2) * font_width) / 2,
3166 DOOR_GFX_PAGEY1 + 13 * font_height,
3167 (xsize - 2) * font_width,
3168 (ysize - 2 - 13) * font_height,
3170 sy + font_height * (1 + 13));
3174 redraw_mask = REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
3175 // redraw_mask |= REDRAW_ALL | REDRAW_FROM_BACKBUFFER;
3177 redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
3187 WaitUntilDelayReached(&anim_delay, anim_delay_value / 2);
3197 void ShowEnvelopeRequest(char *text, unsigned int req_state, int action)
3200 int last_game_status = game_status; /* save current game status */
3201 // int last_draw_background_mask = gfx.draw_background_mask;
3204 int graphic = IMG_BACKGROUND_REQUEST;
3205 int sound_opening = SND_REQUEST_OPENING;
3206 int sound_closing = SND_REQUEST_CLOSING;
3208 int envelope_nr = 0;
3209 int element = EL_ENVELOPE_1 + envelope_nr;
3210 int graphic = IMG_BACKGROUND_ENVELOPE_1 + envelope_nr;
3211 int sound_opening = element_info[element].sound[ACTION_OPENING];
3212 int sound_closing = element_info[element].sound[ACTION_CLOSING];
3215 boolean ffwd_delay = (tape.playing && tape.fast_forward);
3216 boolean no_delay = (tape.warp_forward);
3217 int normal_delay_value = ONE_SECOND_DELAY / (ffwd_delay ? 2 : 1);
3218 int wait_delay_value = (no_delay ? 0 : normal_delay_value);
3220 int anim_mode = graphic_info[graphic].anim_mode;
3221 int main_anim_mode = (anim_mode == ANIM_NONE ? ANIM_VERTICAL|ANIM_HORIZONTAL:
3222 anim_mode == ANIM_DEFAULT ? ANIM_VERTICAL : anim_mode);
3224 char *text_copy = getStringCopy(text);
3227 for (text_ptr = text_copy; *text_ptr; text_ptr++)
3228 if (*text_ptr == ' ')
3233 if (game_status == GAME_MODE_PLAYING)
3235 if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
3236 BlitScreenToBitmap_EM(backbuffer);
3237 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
3238 BlitScreenToBitmap_SP(backbuffer);
3241 BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY);
3245 SetDrawtoField(DRAW_BACKBUFFER);
3247 // SetDrawBackgroundMask(REDRAW_NONE);
3249 if (action == ACTION_OPENING)
3251 BlitBitmap(backbuffer, bitmap_db_store, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
3254 if (req_state & REQ_ASK)
3256 MapGadget(tool_gadget[TOOL_CTRL_ID_YES]);
3257 MapGadget(tool_gadget[TOOL_CTRL_ID_NO]);
3259 else if (req_state & REQ_CONFIRM)
3261 MapGadget(tool_gadget[TOOL_CTRL_ID_CONFIRM]);
3263 else if (req_state & REQ_PLAYER)
3265 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_1]);
3266 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_2]);
3267 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_3]);
3268 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_4]);
3273 DrawEnvelopeRequest(text);
3275 DrawEnvelopeRequest(text_copy);
3278 if (game_status != GAME_MODE_MAIN)
3282 /* force DOOR font inside door area */
3283 game_status = GAME_MODE_PSEUDO_DOOR;
3286 game.envelope_active = TRUE; /* needed for RedrawPlayfield() events */
3288 if (action == ACTION_OPENING)
3290 PlayMenuSoundStereo(sound_opening, SOUND_MIDDLE);
3292 if (anim_mode == ANIM_DEFAULT)
3293 AnimateEnvelopeRequest(ANIM_DEFAULT, ACTION_OPENING);
3295 AnimateEnvelopeRequest(main_anim_mode, ACTION_OPENING);
3299 Delay(wait_delay_value);
3301 WaitForEventToContinue();
3306 PlayMenuSoundStereo(sound_closing, SOUND_MIDDLE);
3308 if (anim_mode != ANIM_NONE)
3309 AnimateEnvelopeRequest(main_anim_mode, ACTION_CLOSING);
3311 if (anim_mode == ANIM_DEFAULT)
3312 AnimateEnvelopeRequest(ANIM_DEFAULT, ACTION_CLOSING);
3315 game.envelope_active = FALSE;
3318 // game_status = last_game_status; /* restore current game status */
3320 if (action == ACTION_CLOSING)
3322 if (game_status != GAME_MODE_MAIN)
3325 BlitBitmap(bitmap_db_store, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
3328 SetDrawtoField(DRAW_BUFFERED);
3331 // SetDrawBackgroundMask(last_draw_background_mask);
3334 redraw_mask = REDRAW_FIELD;
3335 // redraw_mask |= REDRAW_ALL;
3337 redraw_mask |= REDRAW_FIELD;
3341 if (game_status == GAME_MODE_MAIN)
3346 /* (important: after "BackToFront()", but before "SetDrawtoField()") */
3347 game_status = last_game_status; /* restore current game status */
3350 if (action == ACTION_CLOSING &&
3351 game_status == GAME_MODE_PLAYING &&
3352 level.game_engine_type == GAME_ENGINE_TYPE_RND)
3353 SetDrawtoField(DRAW_BUFFERED);
3355 if (game_status == GAME_MODE_PLAYING &&
3356 level.game_engine_type == GAME_ENGINE_TYPE_RND)
3357 SetDrawtoField(DRAW_BUFFERED);
3369 void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize)
3373 int graphic = el2preimg(element);
3375 getSizedGraphicSource(graphic, 0, tilesize, &src_bitmap, &src_x, &src_y);
3376 BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, dst_x,dst_y);
3384 SetMainBackgroundImage(IMG_BACKGROUND_PLAYING);
3385 SetDrawBackgroundMask(REDRAW_FIELD);
3387 SetDrawBackgroundMask(REDRAW_NONE);
3392 for (x = BX1; x <= BX2; x++)
3393 for (y = BY1; y <= BY2; y++)
3394 DrawScreenField(x, y);
3396 redraw_mask |= REDRAW_FIELD;
3399 void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y)
3403 for (x = 0; x < size_x; x++)
3404 for (y = 0; y < size_y; y++)
3405 DrawMiniElementOrWall(x, y, scroll_x, scroll_y);
3407 redraw_mask |= REDRAW_FIELD;
3410 static void DrawPreviewLevelPlayfieldExt(int from_x, int from_y)
3412 boolean show_level_border = (BorderElement != EL_EMPTY);
3413 int level_xsize = lev_fieldx + (show_level_border ? 2 : 0);
3414 int level_ysize = lev_fieldy + (show_level_border ? 2 : 0);
3415 int tile_size = preview.tile_size;
3416 int preview_width = preview.xsize * tile_size;
3417 int preview_height = preview.ysize * tile_size;
3418 int real_preview_xsize = MIN(level_xsize, preview.xsize);
3419 int real_preview_ysize = MIN(level_ysize, preview.ysize);
3420 int dst_x = SX + ALIGNED_XPOS(preview.x, preview_width, preview.align);
3421 int dst_y = SY + ALIGNED_YPOS(preview.y, preview_height, preview.valign);
3424 DrawBackground(dst_x, dst_y, preview_width, preview_height);
3426 dst_x += (preview_width - real_preview_xsize * tile_size) / 2;
3427 dst_y += (preview_height - real_preview_ysize * tile_size) / 2;
3429 for (x = 0; x < real_preview_xsize; x++)
3431 for (y = 0; y < real_preview_ysize; y++)
3433 int lx = from_x + x + (show_level_border ? -1 : 0);
3434 int ly = from_y + y + (show_level_border ? -1 : 0);
3435 int element = (IN_LEV_FIELD(lx, ly) ? level.field[lx][ly] :
3436 getBorderElement(lx, ly));
3438 DrawPreviewElement(dst_x + x * tile_size, dst_y + y * tile_size,
3439 element, tile_size);
3443 redraw_mask |= REDRAW_MICROLEVEL;
3446 #define MICROLABEL_EMPTY 0
3447 #define MICROLABEL_LEVEL_NAME 1
3448 #define MICROLABEL_LEVEL_AUTHOR_HEAD 2
3449 #define MICROLABEL_LEVEL_AUTHOR 3
3450 #define MICROLABEL_IMPORTED_FROM_HEAD 4
3451 #define MICROLABEL_IMPORTED_FROM 5
3452 #define MICROLABEL_IMPORTED_BY_HEAD 6
3453 #define MICROLABEL_IMPORTED_BY 7
3455 static int getMaxTextLength(struct TextPosInfo *pos, int font_nr)
3457 int max_text_width = SXSIZE;
3458 int font_width = getFontWidth(font_nr);
3460 if (pos->align == ALIGN_CENTER)
3461 max_text_width = (pos->x < SXSIZE / 2 ? pos->x * 2 : (SXSIZE - pos->x) * 2);
3462 else if (pos->align == ALIGN_RIGHT)
3463 max_text_width = pos->x;
3465 max_text_width = SXSIZE - pos->x;
3467 return max_text_width / font_width;
3470 static void DrawPreviewLevelLabelExt(int mode)
3472 struct TextPosInfo *pos = &menu.main.text.level_info_2;
3473 char label_text[MAX_OUTPUT_LINESIZE + 1];
3474 int max_len_label_text;
3476 int font_nr = pos->font;
3479 if (mode == MICROLABEL_LEVEL_AUTHOR_HEAD ||
3480 mode == MICROLABEL_IMPORTED_FROM_HEAD ||
3481 mode == MICROLABEL_IMPORTED_BY_HEAD)
3482 font_nr = pos->font_alt;
3484 int font_nr = FONT_TEXT_2;
3487 if (mode == MICROLABEL_LEVEL_AUTHOR_HEAD ||
3488 mode == MICROLABEL_IMPORTED_FROM_HEAD ||
3489 mode == MICROLABEL_IMPORTED_BY_HEAD)
3490 font_nr = FONT_TEXT_3;
3494 max_len_label_text = getMaxTextLength(pos, font_nr);
3496 max_len_label_text = SXSIZE / getFontWidth(font_nr);
3500 if (pos->size != -1)
3501 max_len_label_text = pos->size;
3504 for (i = 0; i < max_len_label_text; i++)
3505 label_text[i] = ' ';
3506 label_text[max_len_label_text] = '\0';
3508 if (strlen(label_text) > 0)
3511 DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align);
3513 int lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2;
3514 int lypos = MICROLABEL2_YPOS;
3516 DrawText(lxpos, lypos, label_text, font_nr);
3521 (mode == MICROLABEL_LEVEL_NAME ? level.name :
3522 mode == MICROLABEL_LEVEL_AUTHOR_HEAD ? "created by" :
3523 mode == MICROLABEL_LEVEL_AUTHOR ? level.author :
3524 mode == MICROLABEL_IMPORTED_FROM_HEAD ? "imported from" :
3525 mode == MICROLABEL_IMPORTED_FROM ? leveldir_current->imported_from :
3526 mode == MICROLABEL_IMPORTED_BY_HEAD ? "imported by" :
3527 mode == MICROLABEL_IMPORTED_BY ? leveldir_current->imported_by :""),
3528 max_len_label_text);
3529 label_text[max_len_label_text] = '\0';
3531 if (strlen(label_text) > 0)
3534 DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align);
3536 int lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2;
3537 int lypos = MICROLABEL2_YPOS;
3539 DrawText(lxpos, lypos, label_text, font_nr);
3543 redraw_mask |= REDRAW_MICROLEVEL;
3546 static void DrawPreviewLevelExt(boolean restart)
3548 static unsigned int scroll_delay = 0;
3549 static unsigned int label_delay = 0;
3550 static int from_x, from_y, scroll_direction;
3551 static int label_state, label_counter;
3552 unsigned int scroll_delay_value = preview.step_delay;
3553 boolean show_level_border = (BorderElement != EL_EMPTY);
3554 int level_xsize = lev_fieldx + (show_level_border ? 2 : 0);
3555 int level_ysize = lev_fieldy + (show_level_border ? 2 : 0);
3556 int last_game_status = game_status; /* save current game status */
3559 /* force PREVIEW font on preview level */
3560 game_status = GAME_MODE_PSEUDO_PREVIEW;
3568 if (preview.anim_mode == ANIM_CENTERED)
3570 if (level_xsize > preview.xsize)
3571 from_x = (level_xsize - preview.xsize) / 2;
3572 if (level_ysize > preview.ysize)
3573 from_y = (level_ysize - preview.ysize) / 2;
3576 from_x += preview.xoffset;
3577 from_y += preview.yoffset;
3579 scroll_direction = MV_RIGHT;
3583 DrawPreviewLevelPlayfieldExt(from_x, from_y);
3584 DrawPreviewLevelLabelExt(label_state);
3586 /* initialize delay counters */
3587 DelayReached(&scroll_delay, 0);
3588 DelayReached(&label_delay, 0);
3590 if (leveldir_current->name)
3592 struct TextPosInfo *pos = &menu.main.text.level_info_1;
3593 char label_text[MAX_OUTPUT_LINESIZE + 1];
3595 int font_nr = pos->font;
3597 int font_nr = FONT_TEXT_1;
3600 int max_len_label_text = getMaxTextLength(pos, font_nr);
3602 int max_len_label_text = SXSIZE / getFontWidth(font_nr);
3610 if (pos->size != -1)
3611 max_len_label_text = pos->size;
3614 strncpy(label_text, leveldir_current->name, max_len_label_text);
3615 label_text[max_len_label_text] = '\0';
3618 DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align);
3620 lxpos = SX + (SXSIZE - getTextWidth(label_text, font_nr)) / 2;
3621 lypos = SY + MICROLABEL1_YPOS;
3623 DrawText(lxpos, lypos, label_text, font_nr);
3627 game_status = last_game_status; /* restore current game status */
3632 /* scroll preview level, if needed */
3633 if (preview.anim_mode != ANIM_NONE &&
3634 (level_xsize > preview.xsize || level_ysize > preview.ysize) &&
3635 DelayReached(&scroll_delay, scroll_delay_value))
3637 switch (scroll_direction)
3642 from_x -= preview.step_offset;
3643 from_x = (from_x < 0 ? 0 : from_x);
3646 scroll_direction = MV_UP;
3650 if (from_x < level_xsize - preview.xsize)
3652 from_x += preview.step_offset;
3653 from_x = (from_x > level_xsize - preview.xsize ?
3654 level_xsize - preview.xsize : from_x);
3657 scroll_direction = MV_DOWN;
3663 from_y -= preview.step_offset;
3664 from_y = (from_y < 0 ? 0 : from_y);
3667 scroll_direction = MV_RIGHT;
3671 if (from_y < level_ysize - preview.ysize)
3673 from_y += preview.step_offset;
3674 from_y = (from_y > level_ysize - preview.ysize ?
3675 level_ysize - preview.ysize : from_y);
3678 scroll_direction = MV_LEFT;
3685 DrawPreviewLevelPlayfieldExt(from_x, from_y);
3688 /* !!! THIS ALL SUCKS -- SHOULD BE CLEANLY REWRITTEN !!! */
3689 /* redraw micro level label, if needed */
3690 if (!strEqual(level.name, NAMELESS_LEVEL_NAME) &&
3691 !strEqual(level.author, ANONYMOUS_NAME) &&
3692 !strEqual(level.author, leveldir_current->name) &&
3693 DelayReached(&label_delay, MICROLEVEL_LABEL_DELAY))
3695 int max_label_counter = 23;
3697 if (leveldir_current->imported_from != NULL &&
3698 strlen(leveldir_current->imported_from) > 0)
3699 max_label_counter += 14;
3700 if (leveldir_current->imported_by != NULL &&
3701 strlen(leveldir_current->imported_by) > 0)
3702 max_label_counter += 14;
3704 label_counter = (label_counter + 1) % max_label_counter;
3705 label_state = (label_counter >= 0 && label_counter <= 7 ?
3706 MICROLABEL_LEVEL_NAME :
3707 label_counter >= 9 && label_counter <= 12 ?
3708 MICROLABEL_LEVEL_AUTHOR_HEAD :
3709 label_counter >= 14 && label_counter <= 21 ?
3710 MICROLABEL_LEVEL_AUTHOR :
3711 label_counter >= 23 && label_counter <= 26 ?
3712 MICROLABEL_IMPORTED_FROM_HEAD :
3713 label_counter >= 28 && label_counter <= 35 ?
3714 MICROLABEL_IMPORTED_FROM :
3715 label_counter >= 37 && label_counter <= 40 ?
3716 MICROLABEL_IMPORTED_BY_HEAD :
3717 label_counter >= 42 && label_counter <= 49 ?
3718 MICROLABEL_IMPORTED_BY : MICROLABEL_EMPTY);
3720 if (leveldir_current->imported_from == NULL &&
3721 (label_state == MICROLABEL_IMPORTED_FROM_HEAD ||
3722 label_state == MICROLABEL_IMPORTED_FROM))
3723 label_state = (label_state == MICROLABEL_IMPORTED_FROM_HEAD ?
3724 MICROLABEL_IMPORTED_BY_HEAD : MICROLABEL_IMPORTED_BY);
3726 DrawPreviewLevelLabelExt(label_state);
3729 game_status = last_game_status; /* restore current game status */
3732 void DrawPreviewLevelInitial()
3734 DrawPreviewLevelExt(TRUE);
3737 void DrawPreviewLevelAnimation()
3739 DrawPreviewLevelExt(FALSE);
3742 inline void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y,
3743 int graphic, int sync_frame, int mask_mode)
3745 int frame = getGraphicAnimationFrame(graphic, sync_frame);
3747 if (mask_mode == USE_MASKING)
3748 DrawGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame);
3750 DrawGraphicExt(dst_bitmap, x, y, graphic, frame);
3753 inline void DrawFixedGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y,
3754 int graphic, int sync_frame,
3757 int frame = getGraphicAnimationFrame(graphic, sync_frame);
3759 if (mask_mode == USE_MASKING)
3760 DrawFixedGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame);
3762 DrawFixedGraphicExt(dst_bitmap, x, y, graphic, frame);
3765 inline void DrawGraphicAnimation(int x, int y, int graphic)
3767 int lx = LEVELX(x), ly = LEVELY(y);
3769 if (!IN_SCR_FIELD(x, y))
3773 DrawGraphicAnimationExt(drawto_field, FX + x * TILEX_VAR, FY + y * TILEY_VAR,
3774 graphic, GfxFrame[lx][ly], NO_MASKING);
3776 DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY,
3777 graphic, GfxFrame[lx][ly], NO_MASKING);
3779 MarkTileDirty(x, y);
3782 inline void DrawFixedGraphicAnimation(int x, int y, int graphic)
3784 int lx = LEVELX(x), ly = LEVELY(y);
3786 if (!IN_SCR_FIELD(x, y))
3789 DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY,
3790 graphic, GfxFrame[lx][ly], NO_MASKING);
3791 MarkTileDirty(x, y);
3794 void DrawLevelGraphicAnimation(int x, int y, int graphic)
3796 DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
3799 void DrawLevelElementAnimation(int x, int y, int element)
3801 int graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
3803 DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
3806 inline void DrawLevelGraphicAnimationIfNeeded(int x, int y, int graphic)
3808 int sx = SCREENX(x), sy = SCREENY(y);
3810 if (!IN_LEV_FIELD(x, y) || !IN_SCR_FIELD(sx, sy))
3813 if (!IS_NEW_FRAME(GfxFrame[x][y], graphic))
3816 DrawGraphicAnimation(sx, sy, graphic);
3819 if (GFX_CRUMBLED(TILE_GFX_ELEMENT(x, y)))
3820 DrawLevelFieldCrumbled(x, y);
3822 if (GFX_CRUMBLED(Feld[x][y]))
3823 DrawLevelFieldCrumbled(x, y);
3827 void DrawLevelElementAnimationIfNeeded(int x, int y, int element)
3829 int sx = SCREENX(x), sy = SCREENY(y);
3832 if (!IN_LEV_FIELD(x, y) || !IN_SCR_FIELD(sx, sy))
3835 graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
3837 if (!IS_NEW_FRAME(GfxFrame[x][y], graphic))
3840 DrawGraphicAnimation(sx, sy, graphic);
3842 if (GFX_CRUMBLED(element))
3843 DrawLevelFieldCrumbled(x, y);
3846 static int getPlayerGraphic(struct PlayerInfo *player, int move_dir)
3848 if (player->use_murphy)
3850 /* this works only because currently only one player can be "murphy" ... */
3851 static int last_horizontal_dir = MV_LEFT;
3852 int graphic = el_act_dir2img(EL_SP_MURPHY, player->GfxAction, move_dir);
3854 if (move_dir == MV_LEFT || move_dir == MV_RIGHT)
3855 last_horizontal_dir = move_dir;
3857 if (graphic == IMG_SP_MURPHY) /* undefined => use special graphic */
3859 int direction = (player->is_snapping ? move_dir : last_horizontal_dir);
3861 graphic = el_act_dir2img(EL_SP_MURPHY, player->GfxAction, direction);
3867 return el_act_dir2img(player->artwork_element, player->GfxAction,move_dir);
3870 static boolean equalGraphics(int graphic1, int graphic2)
3872 struct GraphicInfo *g1 = &graphic_info[graphic1];
3873 struct GraphicInfo *g2 = &graphic_info[graphic2];
3875 return (g1->bitmap == g2->bitmap &&
3876 g1->src_x == g2->src_x &&
3877 g1->src_y == g2->src_y &&
3878 g1->anim_frames == g2->anim_frames &&
3879 g1->anim_delay == g2->anim_delay &&
3880 g1->anim_mode == g2->anim_mode);
3883 void DrawAllPlayers()
3887 for (i = 0; i < MAX_PLAYERS; i++)
3888 if (stored_player[i].active)
3889 DrawPlayer(&stored_player[i]);
3892 void DrawPlayerField(int x, int y)
3894 if (!IS_PLAYER(x, y))
3897 DrawPlayer(PLAYERINFO(x, y));
3900 #define DRAW_PLAYER_OVER_PUSHED_ELEMENT 1
3902 void DrawPlayer(struct PlayerInfo *player)
3904 int jx = player->jx;
3905 int jy = player->jy;
3906 int move_dir = player->MovDir;
3907 int dx = (move_dir == MV_LEFT ? -1 : move_dir == MV_RIGHT ? +1 : 0);
3908 int dy = (move_dir == MV_UP ? -1 : move_dir == MV_DOWN ? +1 : 0);
3909 int last_jx = (player->is_moving ? jx - dx : jx);
3910 int last_jy = (player->is_moving ? jy - dy : jy);
3911 int next_jx = jx + dx;
3912 int next_jy = jy + dy;
3913 boolean player_is_moving = (player->MovPos ? TRUE : FALSE);
3914 boolean player_is_opaque = FALSE;
3915 int sx = SCREENX(jx), sy = SCREENY(jy);
3916 int sxx = 0, syy = 0;
3917 int element = Feld[jx][jy], last_element = Feld[last_jx][last_jy];
3919 int action = ACTION_DEFAULT;
3920 int last_player_graphic = getPlayerGraphic(player, move_dir);
3921 int last_player_frame = player->Frame;
3924 /* GfxElement[][] is set to the element the player is digging or collecting;
3925 remove also for off-screen player if the player is not moving anymore */
3926 if (IN_LEV_FIELD(jx, jy) && !player_is_moving)
3927 GfxElement[jx][jy] = EL_UNDEFINED;
3929 if (!player->active || !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy)))
3933 if (!IN_LEV_FIELD(jx, jy))
3935 printf("DrawPlayerField(): x = %d, y = %d\n",jx,jy);
3936 printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
3937 printf("DrawPlayerField(): This should never happen!\n");
3942 if (element == EL_EXPLOSION)
3945 action = (player->is_pushing ? ACTION_PUSHING :
3946 player->is_digging ? ACTION_DIGGING :
3947 player->is_collecting ? ACTION_COLLECTING :
3948 player->is_moving ? ACTION_MOVING :
3949 player->is_snapping ? ACTION_SNAPPING :
3950 player->is_dropping ? ACTION_DROPPING :
3951 player->is_waiting ? player->action_waiting : ACTION_DEFAULT);
3953 if (player->is_waiting)
3954 move_dir = player->dir_waiting;
3956 InitPlayerGfxAnimation(player, action, move_dir);
3958 /* ----------------------------------------------------------------------- */
3959 /* draw things in the field the player is leaving, if needed */
3960 /* ----------------------------------------------------------------------- */
3962 if (player->is_moving)
3964 if (Back[last_jx][last_jy] && IS_DRAWABLE(last_element))
3966 DrawLevelElement(last_jx, last_jy, Back[last_jx][last_jy]);
3968 if (last_element == EL_DYNAMITE_ACTIVE ||
3969 last_element == EL_EM_DYNAMITE_ACTIVE ||
3970 last_element == EL_SP_DISK_RED_ACTIVE)
3971 DrawDynamite(last_jx, last_jy);
3973 DrawLevelFieldThruMask(last_jx, last_jy);
3975 else if (last_element == EL_DYNAMITE_ACTIVE ||
3976 last_element == EL_EM_DYNAMITE_ACTIVE ||
3977 last_element == EL_SP_DISK_RED_ACTIVE)
3978 DrawDynamite(last_jx, last_jy);
3980 /* !!! this is not enough to prevent flickering of players which are
3981 moving next to each others without a free tile between them -- this
3982 can only be solved by drawing all players layer by layer (first the
3983 background, then the foreground etc.) !!! => TODO */
3984 else if (!IS_PLAYER(last_jx, last_jy))
3985 DrawLevelField(last_jx, last_jy);
3988 DrawLevelField(last_jx, last_jy);
3991 if (player->is_pushing && IN_SCR_FIELD(SCREENX(next_jx), SCREENY(next_jy)))
3992 DrawLevelElement(next_jx, next_jy, EL_EMPTY);
3995 if (!IN_SCR_FIELD(sx, sy))
3998 /* ----------------------------------------------------------------------- */
3999 /* draw things behind the player, if needed */
4000 /* ----------------------------------------------------------------------- */
4003 DrawLevelElement(jx, jy, Back[jx][jy]);
4004 else if (IS_ACTIVE_BOMB(element))
4005 DrawLevelElement(jx, jy, EL_EMPTY);
4008 if (player_is_moving && GfxElement[jx][jy] != EL_UNDEFINED)
4010 int old_element = GfxElement[jx][jy];
4011 int old_graphic = el_act_dir2img(old_element, action, move_dir);
4012 int frame = getGraphicAnimationFrame(old_graphic, player->StepFrame);
4014 if (GFX_CRUMBLED(old_element))
4015 DrawLevelFieldCrumbledDigging(jx, jy, move_dir, player->StepFrame);
4017 DrawGraphic(sx, sy, old_graphic, frame);
4019 if (graphic_info[old_graphic].anim_mode & ANIM_OPAQUE_PLAYER)
4020 player_is_opaque = TRUE;
4024 GfxElement[jx][jy] = EL_UNDEFINED;
4026 /* make sure that pushed elements are drawn with correct frame rate */
4028 graphic = el_act_dir2img(element, ACTION_PUSHING, move_dir);
4030 if (player->is_pushing && player->is_moving && !IS_ANIM_MODE_CE(graphic))
4031 GfxFrame[jx][jy] = player->StepFrame;
4033 if (player->is_pushing && player->is_moving)
4034 GfxFrame[jx][jy] = player->StepFrame;
4037 DrawLevelField(jx, jy);
4041 #if !DRAW_PLAYER_OVER_PUSHED_ELEMENT
4042 /* ----------------------------------------------------------------------- */
4043 /* draw player himself */
4044 /* ----------------------------------------------------------------------- */
4046 graphic = getPlayerGraphic(player, move_dir);
4048 /* in the case of changed player action or direction, prevent the current
4049 animation frame from being restarted for identical animations */
4050 if (player->Frame == 0 && equalGraphics(graphic, last_player_graphic))
4051 player->Frame = last_player_frame;
4053 frame = getGraphicAnimationFrame(graphic, player->Frame);
4057 if (move_dir == MV_LEFT || move_dir == MV_RIGHT)
4058 sxx = player->GfxPos;
4060 syy = player->GfxPos;
4063 if (!setup.soft_scrolling && ScreenMovPos)
4066 if (player_is_opaque)
4067 DrawGraphicShifted(sx, sy, sxx, syy, graphic, frame,NO_CUTTING,NO_MASKING);
4069 DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING);
4071 if (SHIELD_ON(player))
4073 int graphic = (player->shield_deadly_time_left ? IMG_SHIELD_DEADLY_ACTIVE :
4074 IMG_SHIELD_NORMAL_ACTIVE);
4075 int frame = getGraphicAnimationFrame(graphic, -1);
4077 DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING);
4081 #if DRAW_PLAYER_OVER_PUSHED_ELEMENT
4084 if (move_dir == MV_LEFT || move_dir == MV_RIGHT)
4085 sxx = player->GfxPos;
4087 syy = player->GfxPos;
4091 /* ----------------------------------------------------------------------- */
4092 /* draw things the player is pushing, if needed */
4093 /* ----------------------------------------------------------------------- */
4096 printf("::: %d, %d [%d, %d] [%d]\n",
4097 player->is_pushing, player_is_moving, player->GfxAction,
4098 player->is_moving, player_is_moving);
4102 if (player->is_pushing && player->is_moving)
4104 int px = SCREENX(jx), py = SCREENY(jy);
4105 int pxx = (TILEX - ABS(sxx)) * dx;
4106 int pyy = (TILEY - ABS(syy)) * dy;
4107 int gfx_frame = GfxFrame[jx][jy];
4113 if (!IS_MOVING(jx, jy)) /* push movement already finished */
4115 element = Feld[next_jx][next_jy];
4116 gfx_frame = GfxFrame[next_jx][next_jy];
4119 graphic = el_act_dir2img(element, ACTION_PUSHING, move_dir);
4122 sync_frame = (IS_ANIM_MODE_CE(graphic) ? gfx_frame : player->StepFrame);
4123 frame = getGraphicAnimationFrame(graphic, sync_frame);
4125 frame = getGraphicAnimationFrame(graphic, player->StepFrame);
4128 /* draw background element under pushed element (like the Sokoban field) */
4130 if (game.use_masked_pushing && IS_MOVING(jx, jy))
4132 /* this allows transparent pushing animation over non-black background */
4135 DrawLevelElement(jx, jy, Back[jx][jy]);
4137 DrawLevelElement(jx, jy, EL_EMPTY);
4139 if (Back[next_jx][next_jy])
4140 DrawLevelElement(next_jx, next_jy, Back[next_jx][next_jy]);
4142 DrawLevelElement(next_jx, next_jy, EL_EMPTY);
4144 else if (Back[next_jx][next_jy])
4145 DrawLevelElement(next_jx, next_jy, Back[next_jx][next_jy]);
4147 if (Back[next_jx][next_jy])
4148 DrawLevelElement(next_jx, next_jy, Back[next_jx][next_jy]);
4152 printf("::: %d, %d, %d, %d [%d] [%d, %d, %d] [%d] [%d, %d] [%d, %d]\n",
4153 jx, px, player->GfxPos, player->StepFrame,
4158 GfxFrame[jx][jy], GfxFrame[next_jx][next_jy]);
4162 /* do not draw (EM style) pushing animation when pushing is finished */
4163 /* (two-tile animations usually do not contain start and end frame) */
4164 if (graphic_info[graphic].double_movement && !IS_MOVING(jx, jy))
4165 DrawLevelElement(next_jx, next_jy, Feld[next_jx][next_jy]);
4167 DrawGraphicShiftedThruMask(px, py, pxx, pyy, graphic, frame, NO_CUTTING);
4169 /* masked drawing is needed for EMC style (double) movement graphics */
4170 /* !!! (ONLY WHEN DRAWING PUSHED ELEMENT OVER THE PLAYER) !!! */
4171 DrawGraphicShiftedThruMask(px, py, pxx, pyy, graphic, frame, NO_CUTTING);
4176 #if DRAW_PLAYER_OVER_PUSHED_ELEMENT
4177 /* ----------------------------------------------------------------------- */
4178 /* draw player himself */
4179 /* ----------------------------------------------------------------------- */
4181 graphic = getPlayerGraphic(player, move_dir);
4183 /* in the case of changed player action or direction, prevent the current
4184 animation frame from being restarted for identical animations */
4185 if (player->Frame == 0 && equalGraphics(graphic, last_player_graphic))
4186 player->Frame = last_player_frame;
4188 frame = getGraphicAnimationFrame(graphic, player->Frame);
4192 if (move_dir == MV_LEFT || move_dir == MV_RIGHT)
4193 sxx = player->GfxPos;
4195 syy = player->GfxPos;
4198 if (!setup.soft_scrolling && ScreenMovPos)
4201 if (player_is_opaque)
4202 DrawGraphicShifted(sx, sy, sxx, syy, graphic, frame,NO_CUTTING,NO_MASKING);
4204 DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING);
4206 if (SHIELD_ON(player))
4208 int graphic = (player->shield_deadly_time_left ? IMG_SHIELD_DEADLY_ACTIVE :
4209 IMG_SHIELD_NORMAL_ACTIVE);
4210 int frame = getGraphicAnimationFrame(graphic, -1);
4212 DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING);
4216 /* ----------------------------------------------------------------------- */
4217 /* draw things in front of player (active dynamite or dynabombs) */
4218 /* ----------------------------------------------------------------------- */
4220 if (IS_ACTIVE_BOMB(element))
4222 graphic = el2img(element);
4223 frame = getGraphicAnimationFrame(graphic, GfxFrame[jx][jy]);
4225 if (game.emulation == EMU_SUPAPLEX)
4226 DrawGraphic(sx, sy, IMG_SP_DISK_RED, frame);
4228 DrawGraphicThruMask(sx, sy, graphic, frame);
4231 if (player_is_moving && last_element == EL_EXPLOSION)
4233 int element = (GfxElement[last_jx][last_jy] != EL_UNDEFINED ?
4234 GfxElement[last_jx][last_jy] : EL_EMPTY);
4235 int graphic = el_act2img(element, ACTION_EXPLODING);
4236 int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2);
4237 int phase = ExplodePhase[last_jx][last_jy] - 1;
4238 int frame = getGraphicAnimationFrame(graphic, phase - delay);
4241 DrawGraphicThruMask(SCREENX(last_jx), SCREENY(last_jy), graphic, frame);
4244 /* ----------------------------------------------------------------------- */
4245 /* draw elements the player is just walking/passing through/under */
4246 /* ----------------------------------------------------------------------- */
4248 if (player_is_moving)
4250 /* handle the field the player is leaving ... */
4251 if (IS_ACCESSIBLE_INSIDE(last_element))
4252 DrawLevelField(last_jx, last_jy);
4253 else if (IS_ACCESSIBLE_UNDER(last_element))
4254 DrawLevelFieldThruMask(last_jx, last_jy);
4257 /* do not redraw accessible elements if the player is just pushing them */
4258 if (!player_is_moving || !player->is_pushing)
4260 /* ... and the field the player is entering */
4261 if (IS_ACCESSIBLE_INSIDE(element))
4262 DrawLevelField(jx, jy);
4263 else if (IS_ACCESSIBLE_UNDER(element))
4264 DrawLevelFieldThruMask(jx, jy);
4267 MarkTileDirty(sx, sy);
4270 /* ------------------------------------------------------------------------- */
4272 void WaitForEventToContinue()
4274 boolean still_wait = TRUE;
4276 /* simulate releasing mouse button over last gadget, if still pressed */
4278 HandleGadgets(-1, -1, 0);
4280 button_status = MB_RELEASED;
4296 case EVENT_BUTTONPRESS:
4297 case EVENT_KEYPRESS:
4301 case EVENT_KEYRELEASE:
4302 ClearPlayerAction();
4306 HandleOtherEvents(&event);
4310 else if (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED)
4317 /* don't eat all CPU time */
4322 #define MAX_REQUEST_LINES 13
4323 #define MAX_REQUEST_LINE_FONT1_LEN 7
4324 #define MAX_REQUEST_LINE_FONT2_LEN 10
4328 static int RequestHandleEvents(unsigned int req_state)
4330 int last_game_status = game_status; /* save current game status */
4334 button_status = MB_RELEASED;
4336 request_gadget_id = -1;
4349 case EVENT_BUTTONPRESS:
4350 case EVENT_BUTTONRELEASE:
4351 case EVENT_MOTIONNOTIFY:
4353 if (event.type == EVENT_MOTIONNOTIFY)
4355 if (!PointerInWindow(window))
4356 continue; /* window and pointer are on different screens */
4361 motion_status = TRUE;
4362 mx = ((MotionEvent *) &event)->x;
4363 my = ((MotionEvent *) &event)->y;
4367 motion_status = FALSE;
4368 mx = ((ButtonEvent *) &event)->x;
4369 my = ((ButtonEvent *) &event)->y;
4370 if (event.type == EVENT_BUTTONPRESS)
4371 button_status = ((ButtonEvent *) &event)->button;
4373 button_status = MB_RELEASED;
4376 /* this sets 'request_gadget_id' */
4377 HandleGadgets(mx, my, button_status);
4379 switch (request_gadget_id)
4381 case TOOL_CTRL_ID_YES:
4384 case TOOL_CTRL_ID_NO:
4387 case TOOL_CTRL_ID_CONFIRM:
4388 result = TRUE | FALSE;
4391 case TOOL_CTRL_ID_PLAYER_1:
4394 case TOOL_CTRL_ID_PLAYER_2:
4397 case TOOL_CTRL_ID_PLAYER_3:
4400 case TOOL_CTRL_ID_PLAYER_4:
4411 case EVENT_KEYPRESS:
4412 switch (GetEventKey((KeyEvent *)&event, TRUE))
4415 if (req_state & REQ_CONFIRM)
4424 #if defined(TARGET_SDL2)
4434 if (req_state & REQ_PLAYER)
4438 case EVENT_KEYRELEASE:
4439 ClearPlayerAction();
4443 HandleOtherEvents(&event);
4447 else if (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED)
4449 int joy = AnyJoystick();
4451 if (joy & JOY_BUTTON_1)
4453 else if (joy & JOY_BUTTON_2)
4459 if (game_status == GAME_MODE_PLAYING && local_player->LevelSolved_GameEnd)
4461 HandleGameActions();
4467 if (!PendingEvent()) /* delay only if no pending events */
4472 game_status = GAME_MODE_PSEUDO_DOOR;
4478 game_status = last_game_status; /* restore current game status */
4486 if (!PendingEvent()) /* delay only if no pending events */
4489 /* don't eat all CPU time */
4499 static boolean RequestDoor(char *text, unsigned int req_state)
4501 unsigned int old_door_state;
4502 int last_game_status = game_status; /* save current game status */
4503 int max_request_line_len = MAX_REQUEST_LINE_FONT1_LEN;
4504 int font_nr = FONT_TEXT_2;
4509 if (maxWordLengthInString(text) > MAX_REQUEST_LINE_FONT1_LEN)
4511 max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN;
4512 font_nr = FONT_TEXT_1;
4515 if (game_status == GAME_MODE_PLAYING)
4517 if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
4518 BlitScreenToBitmap_EM(backbuffer);
4519 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
4520 BlitScreenToBitmap_SP(backbuffer);
4523 /* disable deactivated drawing when quick-loading level tape recording */
4524 if (tape.playing && tape.deactivate_display)
4525 TapeDeactivateDisplayOff(TRUE);
4527 SetMouseCursor(CURSOR_DEFAULT);
4529 #if defined(NETWORK_AVALIABLE)
4530 /* pause network game while waiting for request to answer */
4531 if (options.network &&
4532 game_status == GAME_MODE_PLAYING &&
4533 req_state & REQUEST_WAIT_FOR_INPUT)
4534 SendToServer_PausePlaying();
4537 old_door_state = GetDoorState();
4539 /* simulate releasing mouse button over last gadget, if still pressed */
4541 HandleGadgets(-1, -1, 0);
4545 /* draw released gadget before proceeding */
4548 if (old_door_state & DOOR_OPEN_1)
4550 CloseDoor(DOOR_CLOSE_1);
4552 /* save old door content */
4553 BlitBitmap(bitmap_db_door, bitmap_db_door,
4554 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE,
4555 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1);
4558 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
4559 SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
4561 /* clear door drawing field */
4562 DrawBackground(DX, DY, DXSIZE, DYSIZE);
4564 /* force DOOR font inside door area */
4565 game_status = GAME_MODE_PSEUDO_DOOR;
4567 /* write text for request */
4568 for (text_ptr = text, ty = 0; ty < MAX_REQUEST_LINES; ty++)
4570 char text_line[max_request_line_len + 1];
4576 for (tl = 0, tx = 0; tx < max_request_line_len; tl++, tx++)
4578 tc = *(text_ptr + tx);
4579 // if (!tc || tc == ' ')
4580 if (!tc || tc == ' ' || tc == '?' || tc == '!')
4584 if ((tc == '?' || tc == '!') && tl == 0)
4594 strncpy(text_line, text_ptr, tl);
4597 DrawText(DX + (DXSIZE - tl * getFontWidth(font_nr)) / 2,
4598 DY + 8 + ty * (getFontHeight(font_nr) + 2),
4599 text_line, font_nr);
4601 text_ptr += tl + (tc == ' ' ? 1 : 0);
4602 // text_ptr += tl + (tc == ' ' || tc == '?' || tc == '!' ? 1 : 0);
4605 game_status = last_game_status; /* restore current game status */
4607 if (req_state & REQ_ASK)
4609 MapGadget(tool_gadget[TOOL_CTRL_ID_YES]);
4610 MapGadget(tool_gadget[TOOL_CTRL_ID_NO]);
4612 else if (req_state & REQ_CONFIRM)
4614 MapGadget(tool_gadget[TOOL_CTRL_ID_CONFIRM]);
4616 else if (req_state & REQ_PLAYER)
4618 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_1]);
4619 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_2]);
4620 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_3]);
4621 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_4]);
4624 /* copy request gadgets to door backbuffer */
4625 BlitBitmap(drawto, bitmap_db_door,
4626 DX, DY, DXSIZE, DYSIZE,
4627 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
4629 OpenDoor(DOOR_OPEN_1);
4631 if (!(req_state & REQUEST_WAIT_FOR_INPUT))
4633 if (game_status == GAME_MODE_PLAYING)
4635 SetPanelBackground();
4636 SetDrawBackgroundMask(REDRAW_DOOR_1);
4640 SetDrawBackgroundMask(REDRAW_FIELD);
4646 if (game_status != GAME_MODE_MAIN)
4649 SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
4651 // ---------- handle request buttons ----------
4652 result = RequestHandleEvents(req_state);
4654 if (game_status != GAME_MODE_MAIN)
4659 if (!(req_state & REQ_STAY_OPEN))
4661 CloseDoor(DOOR_CLOSE_1);
4663 if (((old_door_state & DOOR_OPEN_1) && !(req_state & REQ_STAY_CLOSED)) ||
4664 (req_state & REQ_REOPEN))
4665 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
4670 if (game_status == GAME_MODE_PLAYING)
4672 SetPanelBackground();
4673 SetDrawBackgroundMask(REDRAW_DOOR_1);
4677 SetDrawBackgroundMask(REDRAW_FIELD);
4680 #if defined(NETWORK_AVALIABLE)
4681 /* continue network game after request */
4682 if (options.network &&
4683 game_status == GAME_MODE_PLAYING &&
4684 req_state & REQUEST_WAIT_FOR_INPUT)
4685 SendToServer_ContinuePlaying();
4688 /* restore deactivated drawing when quick-loading level tape recording */
4689 if (tape.playing && tape.deactivate_display)
4690 TapeDeactivateDisplayOn();
4695 static boolean RequestEnvelope(char *text, unsigned int req_state)
4702 if (game_status == GAME_MODE_PLAYING)
4704 if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
4705 BlitScreenToBitmap_EM(backbuffer);
4706 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
4707 BlitScreenToBitmap_SP(backbuffer);
4710 /* disable deactivated drawing when quick-loading level tape recording */
4711 if (tape.playing && tape.deactivate_display)
4712 TapeDeactivateDisplayOff(TRUE);
4714 SetMouseCursor(CURSOR_DEFAULT);
4716 #if defined(NETWORK_AVALIABLE)
4717 /* pause network game while waiting for request to answer */
4718 if (options.network &&
4719 game_status == GAME_MODE_PLAYING &&
4720 req_state & REQUEST_WAIT_FOR_INPUT)
4721 SendToServer_PausePlaying();
4724 /* simulate releasing mouse button over last gadget, if still pressed */
4726 HandleGadgets(-1, -1, 0);
4730 // (replace with setting corresponding request background)
4731 // SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
4732 // SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
4734 /* clear door drawing field */
4735 // DrawBackground(DX, DY, DXSIZE, DYSIZE);
4738 if (global.use_envelope_request)
4742 CreateToolButtons();
4748 if (req_state & REQ_ASK)
4750 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_YES], FALSE);
4751 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_NO], FALSE);
4753 else if (req_state & REQ_CONFIRM)
4755 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_CONFIRM], FALSE);
4757 else if (req_state & REQ_PLAYER)
4759 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_PLAYER_1], FALSE);
4760 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_PLAYER_2], FALSE);
4761 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_PLAYER_3], FALSE);
4762 MapGadgetExt(tool_gadget[TOOL_CTRL_ID_PLAYER_4], FALSE);
4765 if (req_state & REQ_ASK)
4767 MapGadget(tool_gadget[TOOL_CTRL_ID_YES]);
4768 MapGadget(tool_gadget[TOOL_CTRL_ID_NO]);
4770 else if (req_state & REQ_CONFIRM)
4772 MapGadget(tool_gadget[TOOL_CTRL_ID_CONFIRM]);
4774 else if (req_state & REQ_PLAYER)
4776 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_1]);
4777 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_2]);
4778 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_3]);
4779 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_4]);
4784 ShowEnvelopeRequest(text, req_state, ACTION_OPENING);
4787 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
4789 if ((req_state & REQ_ASK && (i == TOOL_CTRL_ID_YES ||
4790 i == TOOL_CTRL_ID_NO)) ||
4791 (req_state & REQ_CONFIRM && i == TOOL_CTRL_ID_CONFIRM) ||
4792 (req_state & REQ_PLAYER && (i == TOOL_CTRL_ID_PLAYER_1 &&
4793 i == TOOL_CTRL_ID_PLAYER_2 &&
4794 i == TOOL_CTRL_ID_PLAYER_3 &&
4795 i == TOOL_CTRL_ID_PLAYER_4)))
4797 int x = tool_gadget[i]->x + dDX;
4798 int y = tool_gadget[i]->y + dDY;
4800 ModifyGadget(tool_gadget[i], GDI_X, x, GDI_Y, y, GDI_END);
4805 if (!(req_state & REQUEST_WAIT_FOR_INPUT))
4807 if (game_status == GAME_MODE_PLAYING)
4809 SetPanelBackground();
4810 SetDrawBackgroundMask(REDRAW_DOOR_1);
4814 SetDrawBackgroundMask(REDRAW_FIELD);
4821 if (game_status != GAME_MODE_MAIN)
4825 SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
4827 // ---------- handle request buttons ----------
4828 result = RequestHandleEvents(req_state);
4830 if (game_status != GAME_MODE_MAIN)
4835 ShowEnvelopeRequest(text, req_state, ACTION_CLOSING);
4839 if (game_status == GAME_MODE_PLAYING)
4841 SetPanelBackground();
4842 SetDrawBackgroundMask(REDRAW_DOOR_1);
4846 SetDrawBackgroundMask(REDRAW_FIELD);
4849 #if defined(NETWORK_AVALIABLE)
4850 /* continue network game after request */
4851 if (options.network &&
4852 game_status == GAME_MODE_PLAYING &&
4853 req_state & REQUEST_WAIT_FOR_INPUT)
4854 SendToServer_ContinuePlaying();
4857 /* restore deactivated drawing when quick-loading level tape recording */
4858 if (tape.playing && tape.deactivate_display)
4859 TapeDeactivateDisplayOn();
4864 boolean Request(char *text, unsigned int req_state)
4866 if (global.use_envelope_request)
4867 return RequestEnvelope(text, req_state);
4869 return RequestDoor(text, req_state);
4872 #else // =====================================================================
4874 boolean Request(char *text, unsigned int req_state)
4876 int mx, my, ty, result = -1;
4877 unsigned int old_door_state;
4878 int last_game_status = game_status; /* save current game status */
4879 int max_request_line_len = MAX_REQUEST_LINE_FONT1_LEN;
4880 int font_nr = FONT_TEXT_2;
4882 int max_word_len = 0;
4888 global.use_envelope_request = 1;
4892 if (maxWordLengthInString(text) > MAX_REQUEST_LINE_FONT1_LEN)
4894 max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN;
4895 font_nr = FONT_TEXT_1;
4898 for (text_ptr = text; *text_ptr; text_ptr++)
4900 max_word_len = (*text_ptr != ' ' ? max_word_len + 1 : 0);
4902 if (max_word_len > MAX_REQUEST_LINE_FONT1_LEN)
4904 max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN;
4906 font_nr = FONT_TEXT_1;
4908 font_nr = FONT_LEVEL_NUMBER;
4916 if (game_status == GAME_MODE_PLAYING)
4918 if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
4919 BlitScreenToBitmap_EM(backbuffer);
4920 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
4921 BlitScreenToBitmap_SP(backbuffer);
4924 /* disable deactivated drawing when quick-loading level tape recording */
4925 if (tape.playing && tape.deactivate_display)
4926 TapeDeactivateDisplayOff(TRUE);
4928 SetMouseCursor(CURSOR_DEFAULT);
4930 #if defined(NETWORK_AVALIABLE)
4931 /* pause network game while waiting for request to answer */
4932 if (options.network &&
4933 game_status == GAME_MODE_PLAYING &&
4934 req_state & REQUEST_WAIT_FOR_INPUT)
4935 SendToServer_PausePlaying();
4938 old_door_state = GetDoorState();
4940 /* simulate releasing mouse button over last gadget, if still pressed */
4942 HandleGadgets(-1, -1, 0);
4946 /* draw released gadget before proceeding */
4950 if (old_door_state & DOOR_OPEN_1 && !global.use_envelope_request)
4952 if (old_door_state & DOOR_OPEN_1)
4956 if (!global.use_envelope_request)
4957 CloseDoor(DOOR_CLOSE_1);
4959 CloseDoor(DOOR_CLOSE_1);
4962 /* save old door content */
4963 BlitBitmap(bitmap_db_door, bitmap_db_door,
4964 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE,
4965 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1);
4969 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
4972 SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
4974 /* clear door drawing field */
4975 DrawBackground(DX, DY, DXSIZE, DYSIZE);
4977 /* force DOOR font inside door area */
4978 game_status = GAME_MODE_PSEUDO_DOOR;
4980 /* write text for request */
4981 for (text_ptr = text, ty = 0; ty < MAX_REQUEST_LINES; ty++)
4983 char text_line[max_request_line_len + 1];
4989 for (tl = 0, tx = 0; tx < max_request_line_len; tl++, tx++)
4991 tc = *(text_ptr + tx);
4992 if (!tc || tc == ' ')
5003 strncpy(text_line, text_ptr, tl);
5006 DrawText(DX + (DXSIZE - tl * getFontWidth(font_nr)) / 2,
5007 DY + 8 + ty * (getFontHeight(font_nr) + 2),
5008 text_line, font_nr);
5010 text_ptr += tl + (tc == ' ' ? 1 : 0);
5013 game_status = last_game_status; /* restore current game status */
5016 if (global.use_envelope_request)
5020 CreateToolButtons();
5024 if (req_state & REQ_ASK)
5026 MapGadget(tool_gadget[TOOL_CTRL_ID_YES]);
5027 MapGadget(tool_gadget[TOOL_CTRL_ID_NO]);
5029 else if (req_state & REQ_CONFIRM)
5031 MapGadget(tool_gadget[TOOL_CTRL_ID_CONFIRM]);
5033 else if (req_state & REQ_PLAYER)
5035 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_1]);
5036 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_2]);
5037 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_3]);
5038 MapGadget(tool_gadget[TOOL_CTRL_ID_PLAYER_4]);
5041 /* copy request gadgets to door backbuffer */
5042 BlitBitmap(drawto, bitmap_db_door,
5043 DX, DY, DXSIZE, DYSIZE,
5044 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
5047 if (global.use_envelope_request)
5049 ShowEnvelopeRequest(text, ACTION_OPENING);
5051 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
5053 if ((req_state & REQ_ASK && (i == TOOL_CTRL_ID_YES ||
5054 i == TOOL_CTRL_ID_NO)) ||
5055 (req_state & REQ_CONFIRM && i == TOOL_CTRL_ID_CONFIRM) ||
5056 (req_state & REQ_PLAYER && (i == TOOL_CTRL_ID_PLAYER_1 &&
5057 i == TOOL_CTRL_ID_PLAYER_2 &&
5058 i == TOOL_CTRL_ID_PLAYER_3 &&
5059 i == TOOL_CTRL_ID_PLAYER_4)))
5061 int x = tool_gadget[i]->x + dDX;
5062 int y = tool_gadget[i]->y + dDY;
5064 ModifyGadget(tool_gadget[i], GDI_X, x, GDI_Y, y, GDI_END);
5071 if (!global.use_envelope_request)
5072 OpenDoor(DOOR_OPEN_1);
5074 OpenDoor(DOOR_OPEN_1);
5077 if (!(req_state & REQUEST_WAIT_FOR_INPUT))
5079 if (game_status == GAME_MODE_PLAYING)
5081 SetPanelBackground();
5082 SetDrawBackgroundMask(REDRAW_DOOR_1);
5086 SetDrawBackgroundMask(REDRAW_FIELD);
5093 if (game_status != GAME_MODE_MAIN && !global.use_envelope_request)
5096 if (game_status != GAME_MODE_MAIN)
5100 button_status = MB_RELEASED;
5102 request_gadget_id = -1;
5104 SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
5116 case EVENT_BUTTONPRESS:
5117 case EVENT_BUTTONRELEASE:
5118 case EVENT_MOTIONNOTIFY:
5120 if (event.type == EVENT_MOTIONNOTIFY)
5122 if (!PointerInWindow(window))
5123 continue; /* window and pointer are on different screens */
5128 motion_status = TRUE;
5129 mx = ((MotionEvent *) &event)->x;
5130 my = ((MotionEvent *) &event)->y;
5134 motion_status = FALSE;
5135 mx = ((ButtonEvent *) &event)->x;
5136 my = ((ButtonEvent *) &event)->y;
5137 if (event.type == EVENT_BUTTONPRESS)
5138 button_status = ((ButtonEvent *) &event)->button;
5140 button_status = MB_RELEASED;
5143 /* this sets 'request_gadget_id' */
5144 HandleGadgets(mx, my, button_status);
5146 switch (request_gadget_id)
5148 case TOOL_CTRL_ID_YES:
5151 case TOOL_CTRL_ID_NO:
5154 case TOOL_CTRL_ID_CONFIRM:
5155 result = TRUE | FALSE;
5158 case TOOL_CTRL_ID_PLAYER_1:
5161 case TOOL_CTRL_ID_PLAYER_2:
5164 case TOOL_CTRL_ID_PLAYER_3:
5167 case TOOL_CTRL_ID_PLAYER_4:
5178 case EVENT_KEYPRESS:
5179 switch (GetEventKey((KeyEvent *)&event, TRUE))
5182 if (req_state & REQ_CONFIRM)
5191 #if defined(TARGET_SDL2)
5201 if (req_state & REQ_PLAYER)
5205 case EVENT_KEYRELEASE:
5206 ClearPlayerAction();
5210 HandleOtherEvents(&event);
5214 else if (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED)
5216 int joy = AnyJoystick();
5218 if (joy & JOY_BUTTON_1)
5220 else if (joy & JOY_BUTTON_2)
5226 if (game_status == GAME_MODE_PLAYING && local_player->LevelSolved_GameEnd)
5228 HandleGameActions();
5234 if (!PendingEvent()) /* delay only if no pending events */
5239 game_status = GAME_MODE_PSEUDO_DOOR;
5245 game_status = last_game_status; /* restore current game status */
5253 if (!PendingEvent()) /* delay only if no pending events */
5256 /* don't eat all CPU time */
5263 if (game_status != GAME_MODE_MAIN)
5269 if (global.use_envelope_request)
5270 ShowEnvelopeRequest(text, ACTION_CLOSING);
5274 if (!(req_state & REQ_STAY_OPEN) && !global.use_envelope_request)
5276 if (!(req_state & REQ_STAY_OPEN))
5279 CloseDoor(DOOR_CLOSE_1);
5281 if (((old_door_state & DOOR_OPEN_1) && !(req_state & REQ_STAY_CLOSED)) ||
5282 (req_state & REQ_REOPEN))
5283 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
5288 if (game_status == GAME_MODE_PLAYING)
5290 SetPanelBackground();
5291 SetDrawBackgroundMask(REDRAW_DOOR_1);
5295 SetDrawBackgroundMask(REDRAW_FIELD);
5298 #if defined(NETWORK_AVALIABLE)
5299 /* continue network game after request */
5300 if (options.network &&
5301 game_status == GAME_MODE_PLAYING &&
5302 req_state & REQUEST_WAIT_FOR_INPUT)
5303 SendToServer_ContinuePlaying();
5306 /* restore deactivated drawing when quick-loading level tape recording */
5307 if (tape.playing && tape.deactivate_display)
5308 TapeDeactivateDisplayOn();
5315 static int compareDoorPartOrderInfo(const void *object1, const void *object2)
5317 const struct DoorPartOrderInfo *dpo1 = (struct DoorPartOrderInfo *)object1;
5318 const struct DoorPartOrderInfo *dpo2 = (struct DoorPartOrderInfo *)object2;
5321 if (dpo1->sort_priority != dpo2->sort_priority)
5322 compare_result = dpo1->sort_priority - dpo2->sort_priority;
5324 compare_result = dpo1->nr - dpo2->nr;
5326 return compare_result;
5329 void InitGraphicCompatibilityInfo_Doors()
5335 struct DoorInfo *door;
5339 { DOOR_1, IMG_DOOR_1_GFX_PART_1, IMG_DOOR_1_GFX_PART_8, &door_1 },
5340 { DOOR_2, IMG_DOOR_2_GFX_PART_1, IMG_DOOR_2_GFX_PART_8, &door_2 },
5342 { -1, -1, -1, NULL }
5344 struct Rect door_rect_list[] =
5346 { DX, DY, DXSIZE, DYSIZE },
5347 { VX, VY, VXSIZE, VYSIZE }
5351 for (i = 0; doors[i].door_token != -1; i++)
5353 int door_token = doors[i].door_token;
5354 int door_index = DOOR_INDEX_FROM_TOKEN(door_token);
5355 int part_1 = doors[i].part_1;
5356 int part_8 = doors[i].part_8;
5357 int part_2 = part_1 + 1;
5358 int part_3 = part_1 + 2;
5359 struct DoorInfo *door = doors[i].door;
5360 struct Rect *door_rect = &door_rect_list[door_index];
5361 boolean door_gfx_redefined = FALSE;
5363 /* check if any door part graphic definitions have been redefined */
5365 for (j = 0; door_part_controls[j].door_token != -1; j++)
5367 struct DoorPartControlInfo *dpc = &door_part_controls[j];
5368 struct FileInfo *fi = getImageListEntryFromImageID(dpc->graphic);
5370 if (dpc->door_token == door_token && fi->redefined)
5371 door_gfx_redefined = TRUE;
5374 /* check for old-style door graphic/animation modifications */
5376 if (!door_gfx_redefined)
5378 if (door->anim_mode & ANIM_STATIC_PANEL)
5380 door->panel.step_xoffset = 0;
5381 door->panel.step_yoffset = 0;
5384 if (door->anim_mode & (ANIM_HORIZONTAL | ANIM_VERTICAL))
5386 struct GraphicInfo *g_part_1 = &graphic_info[part_1];
5387 struct GraphicInfo *g_part_2 = &graphic_info[part_2];
5388 int num_door_steps, num_panel_steps;
5390 /* remove door part graphics other than the two default wings */
5392 for (j = 0; door_part_controls[j].door_token != -1; j++)
5394 struct DoorPartControlInfo *dpc = &door_part_controls[j];
5395 struct GraphicInfo *g = &graphic_info[dpc->graphic];
5397 if (dpc->graphic >= part_3 &&
5398 dpc->graphic <= part_8)
5402 /* set graphics and screen positions of the default wings */
5404 g_part_1->width = door_rect->width;
5405 g_part_1->height = door_rect->height;
5406 g_part_2->width = door_rect->width;
5407 g_part_2->height = door_rect->height;
5408 g_part_2->src_x = door_rect->width;
5409 g_part_2->src_y = g_part_1->src_y;
5411 door->part_2.x = door->part_1.x;
5412 door->part_2.y = door->part_1.y;
5414 if (door->width != -1)
5416 g_part_1->width = door->width;
5417 g_part_2->width = door->width;
5419 // special treatment for graphics and screen position of right wing
5420 g_part_2->src_x += door_rect->width - door->width;
5421 door->part_2.x += door_rect->width - door->width;
5424 if (door->height != -1)
5426 g_part_1->height = door->height;
5427 g_part_2->height = door->height;
5429 // special treatment for graphics and screen position of bottom wing
5430 g_part_2->src_y += door_rect->height - door->height;
5431 door->part_2.y += door_rect->height - door->height;
5434 /* set animation delays for the default wings and panels */
5436 door->part_1.step_delay = door->step_delay;
5437 door->part_2.step_delay = door->step_delay;
5438 door->panel.step_delay = door->step_delay;
5440 /* set animation draw order for the default wings */
5442 door->part_1.sort_priority = 2; /* draw left wing over ... */
5443 door->part_2.sort_priority = 1; /* ... right wing */
5445 /* set animation draw offset for the default wings */
5447 if (door->anim_mode & ANIM_HORIZONTAL)
5449 door->part_1.step_xoffset = door->step_offset;
5450 door->part_1.step_yoffset = 0;
5451 door->part_2.step_xoffset = door->step_offset * -1;
5452 door->part_2.step_yoffset = 0;
5454 num_door_steps = g_part_1->width / door->step_offset;
5456 else // ANIM_VERTICAL
5458 door->part_1.step_xoffset = 0;
5459 door->part_1.step_yoffset = door->step_offset;
5460 door->part_2.step_xoffset = 0;
5461 door->part_2.step_yoffset = door->step_offset * -1;
5463 num_door_steps = g_part_1->height / door->step_offset;
5466 /* set animation draw offset for the default panels */
5468 if (door->step_offset > 1)
5470 num_panel_steps = 2 * door_rect->height / door->step_offset;
5471 door->panel.start_step = num_panel_steps - num_door_steps;
5475 num_panel_steps = door_rect->height / door->step_offset;
5476 door->panel.start_step = num_panel_steps - num_door_steps / 2;
5477 door->panel.step_delay *= 2;
5488 for (i = 0; door_part_controls[i].door_token != -1; i++)
5490 struct DoorPartControlInfo *dpc = &door_part_controls[i];
5491 struct DoorPartOrderInfo *dpo = &door_part_order[i];
5493 /* initialize "start_step_opening" and "start_step_closing", if needed */
5494 if (dpc->pos->start_step_opening == 0 &&
5495 dpc->pos->start_step_closing == 0)
5497 // dpc->pos->start_step_opening = dpc->pos->start_step;
5498 dpc->pos->start_step_closing = dpc->pos->start_step;
5501 /* fill structure for door part draw order (sorted below) */
5503 dpo->sort_priority = dpc->pos->sort_priority;
5506 struct DoorPartPosInfo *pos = dpc->pos;
5508 printf(":0: step_xoffset == %d, step_yoffset == %d\n",
5509 pos->step_xoffset, pos->step_yoffset);
5513 /* sort door part controls according to sort_priority and graphic number */
5514 qsort(door_part_order, MAX_DOOR_PARTS,
5515 sizeof(struct DoorPartOrderInfo), compareDoorPartOrderInfo);
5518 unsigned int OpenDoor(unsigned int door_state)
5520 if (door_state & DOOR_COPY_BACK)
5522 if (door_state & DOOR_OPEN_1)
5523 BlitBitmap(bitmap_db_door, bitmap_db_door,
5524 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE,
5525 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
5527 if (door_state & DOOR_OPEN_2)
5528 BlitBitmap(bitmap_db_door, bitmap_db_door,
5529 DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY2, VXSIZE, VYSIZE,
5530 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
5532 door_state &= ~DOOR_COPY_BACK;
5535 return MoveDoor(door_state);
5538 unsigned int CloseDoor(unsigned int door_state)
5540 unsigned int old_door_state = GetDoorState();
5542 if (!(door_state & DOOR_NO_COPY_BACK))
5544 if (old_door_state & DOOR_OPEN_1)
5545 BlitBitmap(backbuffer, bitmap_db_door,
5546 DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
5548 if (old_door_state & DOOR_OPEN_2)
5549 BlitBitmap(backbuffer, bitmap_db_door,
5550 VX, VY, VXSIZE, VYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2);
5552 door_state &= ~DOOR_NO_COPY_BACK;
5555 return MoveDoor(door_state);
5558 unsigned int GetDoorState()
5560 return MoveDoor(DOOR_GET_STATE);
5563 unsigned int SetDoorState(unsigned int door_state)
5565 return MoveDoor(door_state | DOOR_SET_STATE);
5570 // ========== TEST 1 ===========================================================
5572 int euclid(int a, int b)
5574 return (b ? euclid(b, a % b) : a);
5577 unsigned int MoveDoor(unsigned int door_state)
5579 struct XY panel_pos_list[] =
5581 { DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 },
5582 { DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2 },
5584 struct Rect door_rect_list[] =
5586 { DX, DY, DXSIZE, DYSIZE },
5587 { VX, VY, VXSIZE, VYSIZE }
5589 static int door1 = DOOR_OPEN_1;
5590 static int door2 = DOOR_CLOSE_2;
5591 unsigned int door_delay = 0;
5592 unsigned int door_delay_value;
5596 if (door_1.width < 0 || door_1.width > DXSIZE)
5597 door_1.width = DXSIZE;
5598 if (door_1.height < 0 || door_1.height > DYSIZE)
5599 door_1.height = DYSIZE;
5600 if (door_2.width < 0 || door_2.width > VXSIZE)
5601 door_2.width = VXSIZE;
5602 if (door_2.height < 0 || door_2.height > VYSIZE)
5603 door_2.height = VYSIZE;
5606 if (door_state == DOOR_GET_STATE)
5607 return (door1 | door2);
5609 if (door_state & DOOR_SET_STATE)
5611 if (door_state & DOOR_ACTION_1)
5612 door1 = door_state & DOOR_ACTION_1;
5613 if (door_state & DOOR_ACTION_2)
5614 door2 = door_state & DOOR_ACTION_2;
5616 return (door1 | door2);
5619 if (!(door_state & DOOR_FORCE_REDRAW))
5621 if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
5622 door_state &= ~DOOR_OPEN_1;
5623 else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
5624 door_state &= ~DOOR_CLOSE_1;
5625 if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2)
5626 door_state &= ~DOOR_OPEN_2;
5627 else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2)
5628 door_state &= ~DOOR_CLOSE_2;
5632 door_delay_value = (door_state & DOOR_ACTION_1 ? door_1.step_delay :
5635 if (setup.quick_doors)
5637 stepsize = 20; /* must be chosen to always draw last frame */
5638 door_delay_value = 0;
5642 if (global.autoplay_leveldir)
5644 door_state |= DOOR_NO_DELAY;
5645 door_state &= ~DOOR_CLOSE_ALL;
5649 if (game_status == GAME_MODE_EDITOR)
5650 door_state |= DOOR_NO_DELAY;
5653 if (door_state & DOOR_ACTION)
5655 boolean door_panel_drawn[NUM_DOORS];
5656 boolean door_part_done[MAX_DOOR_PARTS];
5658 boolean door_part_done_all;
5660 int num_steps[MAX_DOOR_PARTS];
5661 int max_move_delay = 0; // delay for complete animations of all doors
5662 int max_step_delay = 0; // delay (ms) between two animation frames
5663 int num_move_steps = 0; // number of animation steps for all doors
5664 int current_move_delay = 0;
5667 for (i = 0; i < MAX_DOOR_PARTS; i++)
5669 struct DoorPartControlInfo *dpc = &door_part_controls[i];
5670 struct GraphicInfo *g = &graphic_info[dpc->graphic];
5671 int door_token = dpc->door_token;
5673 door_part_done[i] = (!(door_state & door_token) ||
5678 for (i = 0; i < MAX_DOOR_PARTS; i++)
5680 struct DoorPartControlInfo *dpc = &door_part_controls[i];
5681 struct DoorPartPosInfo *pos = dpc->pos;
5682 int start_step = pos->start_step;
5684 printf("::: ---> %d: start_step == %d [%d]\n",
5685 i, start_step, door_part_done[i]);
5689 for (i = 0; i < MAX_DOOR_PARTS; i++)
5691 int nr = door_part_order[i].nr;
5692 struct DoorPartControlInfo *dpc = &door_part_controls[nr];
5693 struct DoorPartPosInfo *pos = dpc->pos;
5694 struct GraphicInfo *g = &graphic_info[dpc->graphic];
5695 int door_token = dpc->door_token;
5696 boolean is_panel = DOOR_PART_IS_PANEL(nr);
5697 int step_xoffset = ABS(pos->step_xoffset);
5698 int step_yoffset = ABS(pos->step_yoffset);
5699 int step_delay = pos->step_delay;
5700 int current_door_state = door_state & door_token;
5701 boolean door_opening = ((current_door_state & DOOR_OPEN) != 0);
5702 boolean door_closing = ((current_door_state & DOOR_CLOSE) != 0);
5703 boolean part_opening = (is_panel ? door_closing : door_opening);
5704 int start_step = (part_opening ? pos->start_step_opening :
5705 pos->start_step_closing);
5706 float move_xsize = (step_xoffset ? g->width : 0);
5707 float move_ysize = (step_yoffset ? g->height : 0);
5708 int move_xsteps = (step_xoffset ? ceil(move_xsize / step_xoffset) : 0);
5709 int move_ysteps = (step_yoffset ? ceil(move_ysize / step_yoffset) : 0);
5710 int move_steps = (move_xsteps && move_ysteps ?
5711 MIN(move_xsteps, move_ysteps) :
5712 move_xsteps ? move_xsteps : move_ysteps) - start_step;
5713 int move_delay = move_steps * step_delay;
5715 if (door_part_done[nr])
5718 max_move_delay = MAX(max_move_delay, move_delay);
5719 max_step_delay = (max_step_delay == 0 ? step_delay :
5720 euclid(max_step_delay, step_delay));
5721 num_steps[nr] = move_steps;
5725 printf("::: %d: move_delay == %d, start_step == %d [%d]\n",
5726 i, move_delay, start_step, door_part_order[i].nr);
5728 if (DOOR_PART_IS_PANEL(i))
5729 printf("::: %d: move_delay == %d, start_step == %d\n",
5730 i, move_delay, start_step);
5735 num_move_steps = max_move_delay / max_step_delay;
5737 door_delay_value = max_step_delay;
5740 door_delay_value *= 10;
5744 printf("::: num_move_steps == %d, max_move_delay == %d, max_step_delay == %d\n", num_move_steps, max_move_delay, max_step_delay);
5747 for (k = 0; k < num_move_steps; k++)
5749 for (i = 0; i < NUM_DOORS; i++)
5750 door_panel_drawn[i] = FALSE;
5752 for (i = 0; i < MAX_DOOR_PARTS; i++)
5754 int nr = door_part_order[i].nr;
5755 struct DoorPartControlInfo *dpc = &door_part_controls[nr];
5756 struct DoorPartPosInfo *pos = dpc->pos;
5757 struct GraphicInfo *g = &graphic_info[dpc->graphic];
5758 int door_token = dpc->door_token;
5759 int door_index = DOOR_INDEX_FROM_TOKEN(door_token);
5760 boolean is_panel = DOOR_PART_IS_PANEL(nr);
5761 struct XY *panel_pos = &panel_pos_list[door_index];
5762 struct Rect *door_rect = &door_rect_list[door_index];
5763 Bitmap *bitmap = (is_panel ? bitmap_db_door : g->bitmap);
5764 int current_door_state = door_state & door_token;
5765 boolean door_opening = ((current_door_state & DOOR_OPEN) != 0);
5766 boolean door_closing = ((current_door_state & DOOR_CLOSE) != 0);
5767 boolean part_opening = (is_panel ? door_closing : door_opening);
5768 int start_step = (part_opening ? pos->start_step_opening :
5769 pos->start_step_closing);
5770 int step_delay = pos->step_delay;
5771 int step_factor = step_delay / max_step_delay;
5772 int k1 = (step_factor ? k / step_factor + 1 : k);
5773 int k2 = (part_opening ? k1 + start_step : num_steps[nr] - k1);
5774 int kk = (k2 < 0 ? 0 : k2);
5775 int src_x, src_y, src_xx, src_yy;
5776 int dst_x, dst_y, dst_xx, dst_yy;
5780 if (DOOR_PART_IS_PANEL(nr))
5782 int start_step = pos->start_step;
5784 k2 = (door_closing ? k1 : num_steps[nr] - k1);// - start_step;
5785 kk = (k2 < 0 ? 0 : k2);
5791 if (nr != 16 && nr != 0)
5796 if (door_part_done[nr])
5800 if (!(door_state & door_token))
5807 if (current_move_delay % step_delay)
5813 if (!door_panel_drawn[door_index])
5816 ClearRectangle(drawto, door_rect->x, door_rect->y,
5817 door_rect->width, door_rect->height);
5819 BlitBitmap(bitmap_db_door, drawto, panel_pos->x, panel_pos->y,
5820 door_rect->width, door_rect->height,
5821 door_rect->x, door_rect->y);
5824 door_panel_drawn[door_index] = TRUE;
5827 // draw opening or closing door parts
5829 if (pos->step_xoffset < 0) // door part on right side
5832 dst_xx = pos->x + ABS(kk * pos->step_xoffset);
5835 if (dst_xx + width > door_rect->width)
5836 width = door_rect->width - dst_xx;
5838 else // door part on left side
5841 dst_xx = pos->x - kk * pos->step_xoffset;
5845 src_xx = ABS(dst_xx);
5849 width = g->width - src_xx;
5851 // printf("::: k == %d [%d] \n", k, start_step);
5854 if (pos->step_yoffset < 0) // door part on bottom side
5857 dst_yy = pos->y + ABS(kk * pos->step_yoffset);
5860 if (dst_yy + height > door_rect->height)
5861 height = door_rect->height - dst_yy;
5863 else // door part on top side
5866 dst_yy = pos->y - kk * pos->step_yoffset;
5870 src_yy = ABS(dst_yy);
5874 height = g->height - src_yy;
5879 src_x = panel_pos->x + src_xx;
5880 src_y = panel_pos->y + src_yy;
5884 src_x = g->src_x + src_xx;
5885 src_y = g->src_y + src_yy;
5888 dst_x = door_rect->x + dst_xx;
5889 dst_y = door_rect->y + dst_yy;
5892 if (DOOR_PART_IS_PANEL(nr))
5894 printf("::: width == %d, height == %d [%d, %d] [%d, %d]\n",
5895 width, height, g->width, g->height, src_x, src_y);
5899 if (width >= 0 && width <= g->width &&
5900 height >= 0 && height <= g->height)
5902 if (is_panel || !pos->draw_masked)
5903 BlitBitmap(bitmap, drawto, src_x, src_y, width, height,
5906 BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height,
5911 if (DOOR_PART_IS_PANEL(nr))
5913 bitmap = bitmap_db_door;
5914 src_x = panel_pos->x + src_xx;
5915 src_y = panel_pos->y + src_yy;
5917 printf("::: width == %d, height == %d [%d, %d] [%d, %d]\n",
5918 width, height, g->width, g->height, src_x, src_y);
5920 if (width >= 0 && width <= g->width &&
5921 height >= 0 && height <= g->height)
5922 BlitBitmap(bitmap, drawto, src_x, src_y,
5928 redraw_mask |= REDRAW_DOOR_FROM_TOKEN(door_token);
5930 if ((door_opening && (width < 0 || height < 0)) ||
5931 (door_closing && (width >= g->width && height >= g->height)))
5932 door_part_done[nr] = TRUE;
5935 if (!(door_state & DOOR_NO_DELAY))
5939 if (game_status == GAME_MODE_MAIN)
5942 WaitUntilDelayReached(&door_delay, door_delay_value);
5944 current_move_delay += max_step_delay;
5948 door_part_done_all = TRUE;
5950 for (i = 0; i < MAX_DOOR_PARTS; i++)
5951 if (!door_part_done[i] && !DOOR_PART_IS_PANEL(i))
5952 door_part_done_all = FALSE;
5954 if (door_part_done_all)
5960 if (door_state & DOOR_ACTION_1)
5961 door1 = door_state & DOOR_ACTION_1;
5962 if (door_state & DOOR_ACTION_2)
5963 door2 = door_state & DOOR_ACTION_2;
5965 return (door1 | door2);
5970 // ========== OLD ==============================================================
5972 unsigned int MoveDoor(unsigned int door_state)
5974 static int door1 = DOOR_OPEN_1;
5975 static int door2 = DOOR_CLOSE_2;
5976 unsigned int door_delay = 0;
5977 unsigned int door_delay_value;
5981 if (door_1.width < 0 || door_1.width > DXSIZE)
5982 door_1.width = DXSIZE;
5983 if (door_1.height < 0 || door_1.height > DYSIZE)
5984 door_1.height = DYSIZE;
5985 if (door_2.width < 0 || door_2.width > VXSIZE)
5986 door_2.width = VXSIZE;
5987 if (door_2.height < 0 || door_2.height > VYSIZE)
5988 door_2.height = VYSIZE;
5991 if (door_state == DOOR_GET_STATE)
5992 return (door1 | door2);
5994 if (door_state & DOOR_SET_STATE)
5996 if (door_state & DOOR_ACTION_1)
5997 door1 = door_state & DOOR_ACTION_1;
5998 if (door_state & DOOR_ACTION_2)
5999 door2 = door_state & DOOR_ACTION_2;
6001 return (door1 | door2);
6004 if (!(door_state & DOOR_FORCE_REDRAW))
6006 if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
6007 door_state &= ~DOOR_OPEN_1;
6008 else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
6009 door_state &= ~DOOR_CLOSE_1;
6010 if (door2 == DOOR_OPEN_2 && door_state & DOOR_OPEN_2)
6011 door_state &= ~DOOR_OPEN_2;
6012 else if (door2 == DOOR_CLOSE_2 && door_state & DOOR_CLOSE_2)
6013 door_state &= ~DOOR_CLOSE_2;
6016 door_delay_value = (door_state & DOOR_ACTION_1 ? door_1.step_delay :
6019 // door_delay_value *= 4; // !!! TEST ONLY !!!
6021 if (setup.quick_doors)
6023 stepsize = 20; /* must be chosen to always draw last frame */
6024 door_delay_value = 0;
6027 if (global.autoplay_leveldir)
6029 door_state |= DOOR_NO_DELAY;
6030 door_state &= ~DOOR_CLOSE_ALL;
6034 if (game_status == GAME_MODE_EDITOR)
6035 door_state |= DOOR_NO_DELAY;
6038 if (door_state & DOOR_ACTION)
6041 struct GraphicInfo *g1_left = &graphic_info[IMG_DOOR_1_WING_LEFT];
6042 struct GraphicInfo *g1_right = &graphic_info[IMG_DOOR_1_WING_RIGHT];
6043 struct GraphicInfo *g2_left = &graphic_info[IMG_DOOR_2_WING_LEFT];
6044 struct GraphicInfo *g2_right = &graphic_info[IMG_DOOR_2_WING_RIGHT];
6045 int door_1_left_width = g1_left->width;
6046 int door_1_left_height = g1_left->height;
6047 int door_1_right_width = g1_right->width;
6048 int door_1_right_height = g1_right->height;
6049 int door_2_left_width = g2_left->width;
6050 int door_2_left_height = g2_left->height;
6051 int door_2_right_width = g2_right->width;
6052 int door_2_right_height = g2_right->height;
6053 int door_1_width = MAX(door_1_left_width, door_1_right_width);
6054 int door_1_height = MAX(door_1_left_height, door_1_right_height);
6055 int door_2_width = MAX(door_2_left_width, door_2_right_width);
6056 int door_2_height = MAX(door_2_left_height, door_2_right_height);
6058 boolean handle_door_1 = (door_state & DOOR_ACTION_1);
6059 boolean handle_door_2 = (door_state & DOOR_ACTION_2);
6060 boolean door_1_done = (!handle_door_1);
6061 boolean door_2_done = (!handle_door_2);
6062 boolean door_1_vertical = (door_1.anim_mode & ANIM_VERTICAL);
6063 boolean door_2_vertical = (door_2.anim_mode & ANIM_VERTICAL);
6066 int door_size_1 = (door_1_vertical ? door_1_height : door_1_width);
6067 int door_size_2 = (door_2_vertical ? door_2_height : door_2_width);
6069 int door_size_1 = (door_1_vertical ? DYSIZE : DXSIZE);
6070 int door_size_2 = (door_2_vertical ? VYSIZE : VXSIZE);
6073 int door_size_1 = (door_1_vertical ? door_1.height : door_1.width);
6074 int door_size_2 = (door_2_vertical ? door_2.height : door_2.width);
6076 int max_door_size_1 = (door_1_vertical ? DYSIZE : DXSIZE);
6077 int max_door_size_2 = (door_2_vertical ? VYSIZE : VXSIZE);
6078 // int door_size = (handle_door_1 ? door_size_1 : door_size_2);
6079 int door_size = (handle_door_2 ? door_size_2 : door_size_1);
6080 int max_door_size = (handle_door_1 ? max_door_size_1 : max_door_size_2);
6081 int door_skip = max_door_size - door_size;
6082 int end = door_size;
6083 int start = ((door_state & DOOR_NO_DELAY) ? end : 0);
6086 if (!(door_state & DOOR_NO_DELAY) && !setup.quick_doors)
6088 /* opening door sound has priority over simultaneously closing door */
6089 if (door_state & (DOOR_OPEN_1 | DOOR_OPEN_2))
6090 PlayMenuSoundStereo(SND_DOOR_OPENING, SOUND_MIDDLE);
6091 else if (door_state & (DOOR_CLOSE_1 | DOOR_CLOSE_2))
6092 PlayMenuSoundStereo(SND_DOOR_CLOSING, SOUND_MIDDLE);
6095 for (k = start; k <= end && !(door_1_done && door_2_done); k += stepsize)
6099 Bitmap *bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6100 GC gc = bitmap->stored_clip_gc;
6103 if (door_state & DOOR_ACTION_1 &&
6104 x * door_1.step_offset <= door_size_1)
6106 int a = MIN(x * door_1.step_offset, end);
6107 int p = (door_state & DOOR_OPEN_1 ? end - a : a);
6111 int i = p + door_skip;
6115 struct GraphicInfo *g_left = &graphic_info[IMG_DOOR_1_WING_LEFT];
6116 struct GraphicInfo *g_right = &graphic_info[IMG_DOOR_1_WING_RIGHT];
6117 Bitmap *bm_left = g_left->bitmap;
6118 Bitmap *bm_right = g_right->bitmap;
6119 GC gc_left = bm_left->stored_clip_gc;
6120 GC gc_right = bm_right->stored_clip_gc;
6123 int classic_dxsize = 100;
6124 int classic_dysize = 280;
6125 boolean classic_door_1_size = (DXSIZE == classic_dxsize &&
6126 DYSIZE == classic_dysize);
6128 if (door_1.anim_mode & ANIM_STATIC_PANEL)
6130 BlitBitmap(bitmap_db_door, drawto,
6131 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1,
6132 DXSIZE, DYSIZE, DX, DY);
6136 BlitBitmap(bitmap_db_door, drawto,
6137 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 + p / 2,
6138 DXSIZE, DYSIZE - p / 2, DX, DY);
6141 // printf("::: p == %d\n", p);
6142 ClearRectangle(drawto, DX, DY + DYSIZE - p / 2, DXSIZE, p / 2);
6146 if (door_1.anim_mode & ANIM_HORIZONTAL && x <= DXSIZE)
6149 int src1_x = g_right->src_x;
6150 int src1_y = g_right->src_y;
6151 int src2_x = g_left->src_x + g_left->width - i;
6152 int src2_y = g_left->src_y;
6153 int dst1_x = DX + DXSIZE - i;
6158 int height = DYSIZE;
6160 SetClipOrigin(bm_right, gc_right, dst1_x - src1_x, dst1_y - src1_y);
6161 BlitBitmapMasked(bm_right, drawto, src1_x, src1_y, width, height,
6164 SetClipOrigin(bm_left, gc_left, dst2_x - src2_x, dst2_y - src2_y);
6165 BlitBitmapMasked(bm_left, drawto, src2_x, src2_y, width, height,
6168 int src1_x = DXSIZE, src1_y = DOOR_GFX_PAGEY1;
6169 int src2_x = DXSIZE - i, src2_y = DOOR_GFX_PAGEY1;
6170 int dst1_x = DX + DXSIZE - i, dst1_y = DY;
6171 int dst2_x = DX, dst2_y = DY;
6172 int width = i, height = DYSIZE;
6174 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y);
6175 BlitBitmapMasked(bitmap, drawto, src1_x, src1_y, width, height,
6178 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y);
6179 BlitBitmapMasked(bitmap, drawto, src2_x, src2_y, width, height,
6183 else if (door_1.anim_mode & ANIM_VERTICAL && x <= DYSIZE)
6186 int src1_x = g_right->src_x;
6187 int src1_y = g_right->src_y;
6188 int src2_x = g_left->src_x;
6189 int src2_y = g_left->src_y + g_left->height - i;
6191 int dst1_y = DY + DYSIZE - i;
6197 SetClipOrigin(bm_right, gc_right, dst1_x - src1_x, dst1_y - src1_y);
6198 BlitBitmapMasked(bm_right, drawto, src1_x, src1_y, width, height,
6201 SetClipOrigin(bm_left, gc_left, dst2_x - src2_x, dst2_y - src2_y);
6202 BlitBitmapMasked(bm_left, drawto, src2_x, src2_y, width, height,
6205 int src1_x = DXSIZE, src1_y = DOOR_GFX_PAGEY1;
6206 int src2_x = 0, src2_y = DOOR_GFX_PAGEY1 + DYSIZE - i;
6207 int dst1_x = DX, dst1_y = DY + DYSIZE - i;
6208 int dst2_x = DX, dst2_y = DY;
6209 int width = DXSIZE, height = i;
6211 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y);
6212 BlitBitmapMasked(bitmap, drawto, src1_x, src1_y, width, height,
6215 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y);
6216 BlitBitmapMasked(bitmap, drawto, src2_x, src2_y, width, height,
6220 else if (classic_door_1_size && x <= DXSIZE) /* ANIM_DEFAULT */
6222 int j = (door_1.anim_mode == ANIM_DEFAULT ? (DXSIZE - i) / 3 : 0);
6225 int src1_x = g_right->src_x;
6226 int src1_y = g_right->src_y;
6227 int src2_x = g_left->src_x + g_left->width - i;
6228 int src2_y = g_left->src_y;
6229 int dst1_x = DX + DXSIZE - i;
6234 int height1 = 63, height2 = DYSIZE / 2 - height1;
6235 int ypos1 = 0, ypos2 = height2;
6236 int ypos3 = DYSIZE / 2, ypos4 = DYSIZE - height2;
6238 SetClipOrigin(bm_right, gc_right,
6239 dst1_x - src1_x, dst1_y - src1_y + j);
6240 BlitBitmapMasked(bm_right, drawto,
6241 src1_x, src1_y + ypos1, width, height2,
6242 dst1_x, dst1_y + ypos1 + j);
6243 BlitBitmapMasked(bm_right, drawto,
6244 src1_x, src1_y + ypos3, width, height1,
6245 dst1_x, dst1_y + ypos3 + j);
6246 SetClipOrigin(bm_left, gc_left,
6247 dst2_x - src2_x, dst2_y - src2_y - j);
6248 BlitBitmapMasked(bm_left, drawto,
6249 src2_x, src2_y + ypos1 + j, width, height2 - j,
6250 dst2_x, dst2_y + ypos1);
6251 BlitBitmapMasked(bm_left, drawto,
6252 src2_x, src2_y + ypos3, width, height1,
6253 dst2_x, dst2_y + ypos3 - j);
6255 SetClipOrigin(bm_left, gc_left,
6256 dst2_x - src2_x, dst2_y - src2_y - j);
6257 BlitBitmapMasked(bm_left, drawto,
6258 src2_x, src2_y + ypos2, width, height1,
6259 dst2_x, dst2_y + ypos2 - j);
6260 BlitBitmapMasked(bm_left, drawto,
6261 src2_x, src2_y + ypos4, width, height2,
6262 dst2_x, dst2_y + ypos4 - j);
6263 SetClipOrigin(bm_right, gc_right,
6264 dst1_x - src1_x, dst1_y - src1_y + j);
6265 BlitBitmapMasked(bm_right, drawto,
6266 src1_x, src1_y + ypos2, width, height1,
6267 dst1_x, dst1_y + ypos2 + j);
6268 BlitBitmapMasked(bm_right, drawto,
6269 src1_x, src1_y + ypos4, width, height2 - j,
6270 dst1_x, dst1_y + ypos4 + j);
6273 int src1_x = DXSIZE, src1_y = DOOR_GFX_PAGEY1;
6274 int src2_x = DXSIZE - i, src2_y = DOOR_GFX_PAGEY1;
6275 int dst1_x = DX + DXSIZE - i, dst1_y = DY;
6276 int dst2_x = DX, dst2_y = DY;
6277 int width = i, height = DYSIZE;
6278 int ypos1 = 63, ypos2 = 77, ypos3 = 140, ypos4 = 203;
6280 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
6281 BlitBitmapMasked(bitmap, drawto,
6282 src1_x, src1_y, width, ypos2,
6283 dst1_x, dst1_y + j);
6284 BlitBitmapMasked(bitmap, drawto,
6285 src1_x, src1_y + ypos3, width, ypos1,
6286 dst1_x, dst1_y + ypos3 + j);
6287 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y - j);
6288 BlitBitmapMasked(bitmap, drawto,
6289 src2_x, src2_y + j, width, ypos2 - j,
6291 BlitBitmapMasked(bitmap, drawto,
6292 src2_x, src2_y + ypos3, width, ypos1,
6293 dst2_x, dst2_y + ypos3 - j);
6295 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y - j);
6296 BlitBitmapMasked(bitmap, drawto,
6297 src2_x, src2_y + ypos2, width, ypos1,
6298 dst2_x, dst2_y + ypos2 - j);
6299 BlitBitmapMasked(bitmap, drawto,
6300 src2_x, src2_y + ypos4, width, ypos2,
6301 dst2_x, dst2_y + ypos4 - j);
6302 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
6303 BlitBitmapMasked(bitmap, drawto,
6304 src1_x, src1_y + ypos2, width, ypos1,
6305 dst1_x, dst1_y + ypos2 + j);
6306 BlitBitmapMasked(bitmap, drawto,
6307 src1_x, src1_y + ypos4, width, ypos2 - j,
6308 dst1_x, dst1_y + ypos4 + j);
6311 SetClipOrigin(bitmap, gc, DX - i, (DY + j) - DOOR_GFX_PAGEY1);
6312 BlitBitmapMasked(bitmap, drawto,
6313 DXSIZE, DOOR_GFX_PAGEY1, i, 77,
6314 DX + DXSIZE - i, DY + j);
6315 BlitBitmapMasked(bitmap, drawto,
6316 DXSIZE, DOOR_GFX_PAGEY1 + 140, i, 63,
6317 DX + DXSIZE - i, DY + 140 + j);
6318 SetClipOrigin(bitmap, gc, DX - DXSIZE + i,
6319 DY - (DOOR_GFX_PAGEY1 + j));
6320 BlitBitmapMasked(bitmap, drawto,
6321 DXSIZE - i, DOOR_GFX_PAGEY1 + j, i, 77 - j,
6323 BlitBitmapMasked(bitmap, drawto,
6324 DXSIZE-i, DOOR_GFX_PAGEY1 + 140, i, 63,
6327 BlitBitmapMasked(bitmap, drawto,
6328 DXSIZE - i, DOOR_GFX_PAGEY1 + 77, i, 63,
6330 BlitBitmapMasked(bitmap, drawto,
6331 DXSIZE - i, DOOR_GFX_PAGEY1 + 203, i, 77,
6333 SetClipOrigin(bitmap, gc, DX - i, (DY + j) - DOOR_GFX_PAGEY1);
6334 BlitBitmapMasked(bitmap, drawto,
6335 DXSIZE, DOOR_GFX_PAGEY1 + 77, i, 63,
6336 DX + DXSIZE - i, DY + 77 + j);
6337 BlitBitmapMasked(bitmap, drawto,
6338 DXSIZE, DOOR_GFX_PAGEY1 + 203, i, 77 - j,
6339 DX + DXSIZE - i, DY + 203 + j);
6344 redraw_mask |= REDRAW_DOOR_1;
6345 door_1_done = (a == end);
6348 if (door_state & DOOR_ACTION_2 &&
6349 x * door_2.step_offset <= door_size_2)
6351 int a = MIN(x * door_2.step_offset, door_size);
6352 int p = (door_state & DOOR_OPEN_2 ? door_size - a : a);
6353 int i = p + door_skip;
6356 struct GraphicInfo *g_left = &graphic_info[IMG_DOOR_2_WING_LEFT];
6357 struct GraphicInfo *g_right = &graphic_info[IMG_DOOR_2_WING_RIGHT];
6358 Bitmap *bm_left = g_left->bitmap;
6359 Bitmap *bm_right = g_right->bitmap;
6360 GC gc_left = bm_left->stored_clip_gc;
6361 GC gc_right = bm_right->stored_clip_gc;
6364 int classic_vxsize = 100;
6365 int classic_vysize = 100;
6366 boolean classic_door_2_size = (VXSIZE == classic_vxsize &&
6367 VYSIZE == classic_vysize);
6369 if (door_2.anim_mode & ANIM_STATIC_PANEL)
6371 BlitBitmap(bitmap_db_door, drawto,
6372 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2,
6373 VXSIZE, VYSIZE, VX, VY);
6375 else if (x <= VYSIZE)
6377 BlitBitmap(bitmap_db_door, drawto,
6378 DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2 + p / 2,
6379 VXSIZE, VYSIZE - p / 2, VX, VY);
6381 ClearRectangle(drawto, VX, VY + VYSIZE - p / 2, VXSIZE, p / 2);
6384 if (door_2.anim_mode & ANIM_HORIZONTAL && x <= VXSIZE)
6387 int src1_x = g_right->src_x;
6388 int src1_y = g_right->src_y;
6389 int src2_x = g_left->src_x + g_left->width - i;
6390 int src2_y = g_left->src_y;
6391 int dst1_x = VX + VXSIZE - i;
6396 int height = VYSIZE;
6398 SetClipOrigin(bm_right, gc_right, dst1_x - src1_x, dst1_y - src1_y);
6399 BlitBitmapMasked(bm_right, drawto, src1_x, src1_y, width, height,
6402 SetClipOrigin(bm_left, gc_left, dst2_x - src2_x, dst2_y - src2_y);
6403 BlitBitmapMasked(bm_left, drawto, src2_x, src2_y, width, height,
6406 int src1_x = VXSIZE, src1_y = DOOR_GFX_PAGEY2;
6407 int src2_x = VXSIZE - i, src2_y = DOOR_GFX_PAGEY2;
6408 int dst1_x = VX + VXSIZE - i, dst1_y = VY;
6409 int dst2_x = VX, dst2_y = VY;
6410 int width = i, height = VYSIZE;
6412 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y);
6413 BlitBitmapMasked(bitmap, drawto, src1_x, src1_y, width, height,
6416 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y);
6417 BlitBitmapMasked(bitmap, drawto, src2_x, src2_y, width, height,
6421 else if (door_2.anim_mode & ANIM_VERTICAL && x <= VYSIZE)
6424 int src1_x = g_right->src_x;
6425 int src1_y = g_right->src_y;
6426 int src2_x = g_left->src_x;
6427 int src2_y = g_left->src_y + g_left->height - i;
6429 int dst1_y = VY + VYSIZE - i;
6435 SetClipOrigin(bm_right, gc_right, dst1_x - src1_x, dst1_y - src1_y);
6436 BlitBitmapMasked(bm_right, drawto, src1_x, src1_y, width, height,
6439 SetClipOrigin(bm_left, gc_left, dst2_x - src2_x, dst2_y - src2_y);
6440 BlitBitmapMasked(bm_left, drawto, src2_x, src2_y, width, height,
6443 int src1_x = VXSIZE, src1_y = DOOR_GFX_PAGEY2;
6444 int src2_x = 0, src2_y = DOOR_GFX_PAGEY2 + VYSIZE - i;
6445 int dst1_x = VX, dst1_y = VY + VYSIZE - i;
6446 int dst2_x = VX, dst2_y = VY;
6447 int width = VXSIZE, height = i;
6449 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y);
6450 BlitBitmapMasked(bitmap, drawto, src1_x, src1_y, width, height,
6453 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src2_y);
6454 BlitBitmapMasked(bitmap, drawto, src2_x, src2_y, width, height,
6458 else if (classic_door_2_size && x <= VXSIZE) /* ANIM_DEFAULT */
6460 int j = (door_2.anim_mode == ANIM_DEFAULT ? (VXSIZE - i) / 3 : 0);
6463 int src1_x = g_right->src_x;
6464 int src1_y = g_right->src_y;
6465 int src2_x = g_left->src_x + g_left->width - i;
6466 int src2_y = g_left->src_y;
6467 int dst1_x = VX + VXSIZE - i;
6472 int height = VYSIZE / 2;
6473 int ypos1 = 0, ypos2 = VYSIZE / 2;
6475 SetClipOrigin(bm_right, gc_right,
6476 dst1_x - src1_x, dst1_y - src1_y + j);
6477 BlitBitmapMasked(bm_right, drawto,
6478 src1_x, src1_y + ypos1, width, height,
6479 dst1_x, dst1_y + ypos1 + j);
6480 SetClipOrigin(bm_left, gc_left,
6481 dst2_x - src2_x, dst2_y - src2_y - j);
6482 BlitBitmapMasked(bm_left, drawto,
6483 src2_x, src2_y + ypos1 + j, width, height - j,
6484 dst2_x, dst2_y + ypos1);
6486 SetClipOrigin(bm_left, gc_left,
6487 dst2_x - src2_x, dst2_y - src2_y - j);
6488 BlitBitmapMasked(bm_left, drawto,
6489 src2_x, src2_y + ypos2, width, height,
6490 dst2_x, dst2_y + ypos2 - j);
6491 SetClipOrigin(bm_right, gc_right,
6492 dst1_x - src1_x, dst1_y - src1_y + j);
6493 BlitBitmapMasked(bm_right, drawto,
6494 src1_x, src1_y + ypos2, width, height - j,
6495 dst1_x, dst1_y + ypos2 + j);
6497 int src1_x = VXSIZE, src1_y = DOOR_GFX_PAGEY2;
6498 int src2_x = VXSIZE - i, src2_y = DOOR_GFX_PAGEY2;
6499 int dst1_x = VX + VXSIZE - i, dst1_y = VY;
6500 int dst2_x = VX, dst2_y = VY;
6501 int width = i, height = VYSIZE;
6502 int ypos = VYSIZE / 2;
6504 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
6505 BlitBitmapMasked(bitmap, drawto,
6506 src1_x, src1_y, width, ypos,
6507 dst1_x, dst1_y + j);
6508 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src1_y - j);
6509 BlitBitmapMasked(bitmap, drawto,
6510 src2_x, src2_y + j, width, ypos - j,
6513 SetClipOrigin(bitmap, gc, dst2_x - src2_x, dst2_y - src1_y - j);
6514 BlitBitmapMasked(bitmap, drawto,
6515 src2_x, src2_y + ypos, width, ypos,
6516 dst2_x, dst2_y + ypos - j);
6517 SetClipOrigin(bitmap, gc, dst1_x - src1_x, dst1_y - src1_y + j);
6518 BlitBitmapMasked(bitmap, drawto,
6519 src1_x, src1_y + ypos, width, ypos - j,
6520 dst1_x, dst1_y + ypos + j);
6523 SetClipOrigin(bitmap, gc, VX - i, (VY + j) - DOOR_GFX_PAGEY2);
6524 BlitBitmapMasked(bitmap, drawto,
6525 VXSIZE, DOOR_GFX_PAGEY2, i, VYSIZE / 2,
6526 VX + VXSIZE - i, VY + j);
6527 SetClipOrigin(bitmap, gc,
6528 VX - VXSIZE + i, VY - (DOOR_GFX_PAGEY2 + j));
6529 BlitBitmapMasked(bitmap, drawto,
6530 VXSIZE - i, DOOR_GFX_PAGEY2 + j, i, VYSIZE / 2 - j,
6533 BlitBitmapMasked(bitmap, drawto,
6534 VXSIZE - i, DOOR_GFX_PAGEY2 + VYSIZE / 2,
6535 i, VYSIZE / 2, VX, VY + VYSIZE / 2 - j);
6536 SetClipOrigin(bitmap, gc, VX - i, (VY + j) - DOOR_GFX_PAGEY2);
6537 BlitBitmapMasked(bitmap, drawto,
6538 VXSIZE, DOOR_GFX_PAGEY2 + VYSIZE / 2,
6540 VX + VXSIZE - i, VY + VYSIZE / 2 + j);
6545 redraw_mask |= REDRAW_DOOR_2;
6546 door_2_done = (a == VXSIZE);
6549 if (!(door_state & DOOR_NO_DELAY))
6553 if (game_status == GAME_MODE_MAIN)
6556 WaitUntilDelayReached(&door_delay, door_delay_value);
6561 if (door_state & DOOR_ACTION_1)
6562 door1 = door_state & DOOR_ACTION_1;
6563 if (door_state & DOOR_ACTION_2)
6564 door2 = door_state & DOOR_ACTION_2;
6566 return (door1 | door2);
6571 void DrawSpecialEditorDoor()
6574 struct GraphicInfo *gfx1 = &graphic_info[IMG_DOOR_2_TOP_BORDER_CORRECTION];
6575 int top_border_width = gfx1->width;
6576 int top_border_height = gfx1->height;
6577 int outer_border = viewport.door_2[GAME_MODE_EDITOR].border_size;
6578 int ex = EX - outer_border;
6579 int ey = EY - outer_border;
6580 int vy = VY - outer_border;
6581 int exsize = EXSIZE + 2 * outer_border;
6583 CloseDoor(DOOR_CLOSE_2);
6585 /* draw bigger level editor toolbox window */
6586 BlitBitmap(gfx1->bitmap, drawto, gfx1->src_x, gfx1->src_y,
6587 top_border_width, top_border_height, ex, ey - top_border_height);
6588 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, ex, vy,
6589 exsize, EYSIZE - VYSIZE + outer_border, ex, ey);
6591 /* draw bigger level editor toolbox window */
6592 BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
6593 DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8,
6595 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
6596 EX - 6, VY - 4, EXSIZE + 12, EYSIZE - VYSIZE + 4,
6600 redraw_mask |= REDRAW_ALL;
6603 void UndrawSpecialEditorDoor()
6606 struct GraphicInfo *gfx1 = &graphic_info[IMG_DOOR_2_TOP_BORDER_CORRECTION];
6607 int top_border_width = gfx1->width;
6608 int top_border_height = gfx1->height;
6609 int outer_border = viewport.door_2[GAME_MODE_EDITOR].border_size;
6610 int ex = EX - outer_border;
6611 int ey = EY - outer_border;
6612 int ey_top = ey - top_border_height;
6613 int exsize = EXSIZE + 2 * outer_border;
6614 int eysize = EYSIZE + 2 * outer_border;
6616 /* draw normal tape recorder window */
6617 if (graphic_info[IMG_GLOBAL_BORDER].bitmap)
6619 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
6620 ex, ey_top, top_border_width, top_border_height,
6622 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
6623 ex, ey, exsize, eysize, ex, ey);
6627 // if screen background is set to "[NONE]", clear editor toolbox window
6628 ClearRectangle(drawto, ex, ey_top, top_border_width, top_border_height);
6629 ClearRectangle(drawto, ex, ey, exsize, eysize);
6632 /* draw normal tape recorder window */
6633 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
6634 EX - 6, EY - 12, EXSIZE + 12, EYSIZE - VYSIZE + 12,
6638 redraw_mask |= REDRAW_ALL;
6642 /* ---------- new tool button stuff ---------------------------------------- */
6649 struct TextPosInfo *pos;
6652 } toolbutton_info[NUM_TOOL_BUTTONS] =
6655 IMG_REQUEST_BUTTON_GFX_YES, &request.button.yes,
6656 TOOL_CTRL_ID_YES, "yes"
6659 IMG_REQUEST_BUTTON_GFX_NO, &request.button.no,
6660 TOOL_CTRL_ID_NO, "no"
6663 IMG_REQUEST_BUTTON_GFX_CONFIRM, &request.button.confirm,
6664 TOOL_CTRL_ID_CONFIRM, "confirm"
6667 IMG_REQUEST_BUTTON_GFX_PLAYER_1, &request.button.player_1,
6668 TOOL_CTRL_ID_PLAYER_1, "player 1"
6671 IMG_REQUEST_BUTTON_GFX_PLAYER_2, &request.button.player_2,
6672 TOOL_CTRL_ID_PLAYER_2, "player 2"
6675 IMG_REQUEST_BUTTON_GFX_PLAYER_3, &request.button.player_3,
6676 TOOL_CTRL_ID_PLAYER_3, "player 3"
6679 IMG_REQUEST_BUTTON_GFX_PLAYER_4, &request.button.player_4,
6680 TOOL_CTRL_ID_PLAYER_4, "player 4"
6684 void CreateToolButtons()
6688 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
6690 struct GraphicInfo *gfx = &graphic_info[toolbutton_info[i].graphic];
6691 struct TextPosInfo *pos = toolbutton_info[i].pos;
6692 struct GadgetInfo *gi;
6693 Bitmap *deco_bitmap = None;
6694 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6695 unsigned int event_mask = GD_EVENT_RELEASED;
6698 int gd_x = gfx->src_x;
6699 int gd_y = gfx->src_y;
6700 int gd_xp = gfx->src_x + gfx->pressed_xoffset;
6701 int gd_yp = gfx->src_y + gfx->pressed_yoffset;
6704 if (global.use_envelope_request)
6705 setRequestPosition(&dx, &dy, TRUE);
6707 if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4)
6709 int player_nr = id - TOOL_CTRL_ID_PLAYER_1;
6711 getSizedGraphicSource(PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0,
6712 pos->size, &deco_bitmap, &deco_x, &deco_y);
6713 deco_xpos = (gfx->width - pos->size) / 2;
6714 deco_ypos = (gfx->height - pos->size) / 2;
6717 gi = CreateGadget(GDI_CUSTOM_ID, id,
6718 GDI_INFO_TEXT, toolbutton_info[i].infotext,
6721 GDI_WIDTH, gfx->width,
6722 GDI_HEIGHT, gfx->height,
6723 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6724 GDI_STATE, GD_BUTTON_UNPRESSED,
6725 GDI_DESIGN_UNPRESSED, gfx->bitmap, gd_x, gd_y,
6726 GDI_DESIGN_PRESSED, gfx->bitmap, gd_xp, gd_yp,
6727 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6728 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6729 GDI_DECORATION_SIZE, pos->size, pos->size,
6730 GDI_DECORATION_SHIFTING, 1, 1,
6731 GDI_DIRECT_DRAW, FALSE,
6732 GDI_EVENT_MASK, event_mask,
6733 GDI_CALLBACK_ACTION, HandleToolButtons,
6737 Error(ERR_EXIT, "cannot create gadget");
6739 tool_gadget[id] = gi;
6745 /* graphic position values for tool buttons */
6746 #define TOOL_BUTTON_YES_XPOS 2
6747 #define TOOL_BUTTON_YES_YPOS 250
6748 #define TOOL_BUTTON_YES_GFX_YPOS 0
6749 #define TOOL_BUTTON_YES_XSIZE 46
6750 #define TOOL_BUTTON_YES_YSIZE 28
6751 #define TOOL_BUTTON_NO_XPOS 52
6752 #define TOOL_BUTTON_NO_YPOS TOOL_BUTTON_YES_YPOS
6753 #define TOOL_BUTTON_NO_GFX_YPOS TOOL_BUTTON_YES_GFX_YPOS
6754 #define TOOL_BUTTON_NO_XSIZE TOOL_BUTTON_YES_XSIZE
6755 #define TOOL_BUTTON_NO_YSIZE TOOL_BUTTON_YES_YSIZE
6756 #define TOOL_BUTTON_CONFIRM_XPOS TOOL_BUTTON_YES_XPOS
6757 #define TOOL_BUTTON_CONFIRM_YPOS TOOL_BUTTON_YES_YPOS
6758 #define TOOL_BUTTON_CONFIRM_GFX_YPOS 30
6759 #define TOOL_BUTTON_CONFIRM_XSIZE 96
6760 #define TOOL_BUTTON_CONFIRM_YSIZE TOOL_BUTTON_YES_YSIZE
6761 #define TOOL_BUTTON_PLAYER_XSIZE 30
6762 #define TOOL_BUTTON_PLAYER_YSIZE 30
6763 #define TOOL_BUTTON_PLAYER_GFX_XPOS 5
6764 #define TOOL_BUTTON_PLAYER_GFX_YPOS 185
6765 #define TOOL_BUTTON_PLAYER_XPOS (5 + TOOL_BUTTON_PLAYER_XSIZE / 2)
6766 #define TOOL_BUTTON_PLAYER_YPOS (215 - TOOL_BUTTON_PLAYER_YSIZE / 2)
6767 #define TOOL_BUTTON_PLAYER1_XPOS (TOOL_BUTTON_PLAYER_XPOS \
6768 + 0 * TOOL_BUTTON_PLAYER_XSIZE)
6769 #define TOOL_BUTTON_PLAYER2_XPOS (TOOL_BUTTON_PLAYER_XPOS \
6770 + 1 * TOOL_BUTTON_PLAYER_XSIZE)
6771 #define TOOL_BUTTON_PLAYER3_XPOS (TOOL_BUTTON_PLAYER_XPOS \
6772 + 0 * TOOL_BUTTON_PLAYER_XSIZE)
6773 #define TOOL_BUTTON_PLAYER4_XPOS (TOOL_BUTTON_PLAYER_XPOS \
6774 + 1 * TOOL_BUTTON_PLAYER_XSIZE)
6775 #define TOOL_BUTTON_PLAYER1_YPOS (TOOL_BUTTON_PLAYER_YPOS \
6776 + 0 * TOOL_BUTTON_PLAYER_YSIZE)
6777 #define TOOL_BUTTON_PLAYER2_YPOS (TOOL_BUTTON_PLAYER_YPOS \
6778 + 0 * TOOL_BUTTON_PLAYER_YSIZE)
6779 #define TOOL_BUTTON_PLAYER3_YPOS (TOOL_BUTTON_PLAYER_YPOS \
6780 + 1 * TOOL_BUTTON_PLAYER_YSIZE)
6781 #define TOOL_BUTTON_PLAYER4_YPOS (TOOL_BUTTON_PLAYER_YPOS \
6782 + 1 * TOOL_BUTTON_PLAYER_YSIZE)
6791 } toolbutton_info[NUM_TOOL_BUTTONS] =
6794 TOOL_BUTTON_YES_XPOS, TOOL_BUTTON_YES_GFX_YPOS,
6795 TOOL_BUTTON_YES_XPOS, TOOL_BUTTON_YES_YPOS,
6796 TOOL_BUTTON_YES_XSIZE, TOOL_BUTTON_YES_YSIZE,
6801 TOOL_BUTTON_NO_XPOS, TOOL_BUTTON_NO_GFX_YPOS,
6802 TOOL_BUTTON_NO_XPOS, TOOL_BUTTON_NO_YPOS,
6803 TOOL_BUTTON_NO_XSIZE, TOOL_BUTTON_NO_YSIZE,
6808 TOOL_BUTTON_CONFIRM_XPOS, TOOL_BUTTON_CONFIRM_GFX_YPOS,
6809 TOOL_BUTTON_CONFIRM_XPOS, TOOL_BUTTON_CONFIRM_YPOS,
6810 TOOL_BUTTON_CONFIRM_XSIZE, TOOL_BUTTON_CONFIRM_YSIZE,
6811 TOOL_CTRL_ID_CONFIRM,
6815 TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
6816 TOOL_BUTTON_PLAYER1_XPOS, TOOL_BUTTON_PLAYER1_YPOS,
6817 TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
6818 TOOL_CTRL_ID_PLAYER_1,
6822 TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
6823 TOOL_BUTTON_PLAYER2_XPOS, TOOL_BUTTON_PLAYER2_YPOS,
6824 TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
6825 TOOL_CTRL_ID_PLAYER_2,
6829 TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
6830 TOOL_BUTTON_PLAYER3_XPOS, TOOL_BUTTON_PLAYER3_YPOS,
6831 TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
6832 TOOL_CTRL_ID_PLAYER_3,
6836 TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
6837 TOOL_BUTTON_PLAYER4_XPOS, TOOL_BUTTON_PLAYER4_YPOS,
6838 TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
6839 TOOL_CTRL_ID_PLAYER_4,
6844 void CreateToolButtons()
6848 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
6850 Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
6851 Bitmap *deco_bitmap = None;
6852 int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
6853 struct GadgetInfo *gi;
6854 unsigned int event_mask;
6855 int gd_xoffset, gd_yoffset;
6856 int gd_x1, gd_x2, gd_y;
6859 event_mask = GD_EVENT_RELEASED;
6861 gd_xoffset = toolbutton_info[i].xpos;
6862 gd_yoffset = toolbutton_info[i].ypos;
6863 gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
6864 gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
6865 gd_y = DOOR_GFX_PAGEY1 + gd_yoffset;
6867 if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4)
6869 int player_nr = id - TOOL_CTRL_ID_PLAYER_1;
6871 getMiniGraphicSource(PLAYER_NR_GFX(IMG_PLAYER_1, player_nr),
6872 &deco_bitmap, &deco_x, &deco_y);
6873 deco_xpos = (toolbutton_info[i].width - MINI_TILEX) / 2;
6874 deco_ypos = (toolbutton_info[i].height - MINI_TILEY) / 2;
6877 gi = CreateGadget(GDI_CUSTOM_ID, id,
6878 GDI_INFO_TEXT, toolbutton_info[i].infotext,
6879 GDI_X, DX + toolbutton_info[i].x,
6880 GDI_Y, DY + toolbutton_info[i].y,
6881 GDI_WIDTH, toolbutton_info[i].width,
6882 GDI_HEIGHT, toolbutton_info[i].height,
6883 GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
6884 GDI_STATE, GD_BUTTON_UNPRESSED,
6885 GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
6886 GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
6887 GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
6888 GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
6889 GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
6890 GDI_DECORATION_SHIFTING, 1, 1,
6891 GDI_DIRECT_DRAW, FALSE,
6892 GDI_EVENT_MASK, event_mask,
6893 GDI_CALLBACK_ACTION, HandleToolButtons,
6897 Error(ERR_EXIT, "cannot create gadget");
6899 tool_gadget[id] = gi;
6905 void FreeToolButtons()
6909 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
6910 FreeGadget(tool_gadget[i]);
6913 static void UnmapToolButtons()
6917 for (i = 0; i < NUM_TOOL_BUTTONS; i++)
6918 UnmapGadget(tool_gadget[i]);
6921 static void HandleToolButtons(struct GadgetInfo *gi)
6923 request_gadget_id = gi->custom_id;
6926 static struct Mapping_EM_to_RND_object
6929 boolean is_rnd_to_em_mapping; /* unique mapping EM <-> RND */
6930 boolean is_backside; /* backside of moving element */
6936 em_object_mapping_list[] =
6939 Xblank, TRUE, FALSE,
6943 Yacid_splash_eB, FALSE, FALSE,
6944 EL_ACID_SPLASH_RIGHT, -1, -1
6947 Yacid_splash_wB, FALSE, FALSE,
6948 EL_ACID_SPLASH_LEFT, -1, -1
6951 #ifdef EM_ENGINE_BAD_ROLL
6953 Xstone_force_e, FALSE, FALSE,
6954 EL_ROCK, -1, MV_BIT_RIGHT
6957 Xstone_force_w, FALSE, FALSE,
6958 EL_ROCK, -1, MV_BIT_LEFT
6961 Xnut_force_e, FALSE, FALSE,
6962 EL_NUT, -1, MV_BIT_RIGHT
6965 Xnut_force_w, FALSE, FALSE,
6966 EL_NUT, -1, MV_BIT_LEFT
6969 Xspring_force_e, FALSE, FALSE,
6970 EL_SPRING, -1, MV_BIT_RIGHT
6973 Xspring_force_w, FALSE, FALSE,
6974 EL_SPRING, -1, MV_BIT_LEFT
6977 Xemerald_force_e, FALSE, FALSE,
6978 EL_EMERALD, -1, MV_BIT_RIGHT
6981 Xemerald_force_w, FALSE, FALSE,
6982 EL_EMERALD, -1, MV_BIT_LEFT
6985 Xdiamond_force_e, FALSE, FALSE,
6986 EL_DIAMOND, -1, MV_BIT_RIGHT
6989 Xdiamond_force_w, FALSE, FALSE,
6990 EL_DIAMOND, -1, MV_BIT_LEFT
6993 Xbomb_force_e, FALSE, FALSE,
6994 EL_BOMB, -1, MV_BIT_RIGHT
6997 Xbomb_force_w, FALSE, FALSE,
6998 EL_BOMB, -1, MV_BIT_LEFT
7000 #endif /* EM_ENGINE_BAD_ROLL */
7003 Xstone, TRUE, FALSE,
7007 Xstone_pause, FALSE, FALSE,
7011 Xstone_fall, FALSE, FALSE,
7015 Ystone_s, FALSE, FALSE,
7016 EL_ROCK, ACTION_FALLING, -1
7019 Ystone_sB, FALSE, TRUE,
7020 EL_ROCK, ACTION_FALLING, -1
7023 Ystone_e, FALSE, FALSE,
7024 EL_ROCK, ACTION_MOVING, MV_BIT_RIGHT
7027 Ystone_eB, FALSE, TRUE,
7028 EL_ROCK, ACTION_MOVING, MV_BIT_RIGHT
7031 Ystone_w, FALSE, FALSE,
7032 EL_ROCK, ACTION_MOVING, MV_BIT_LEFT
7035 Ystone_wB, FALSE, TRUE,
7036 EL_ROCK, ACTION_MOVING, MV_BIT_LEFT
7043 Xnut_pause, FALSE, FALSE,
7047 Xnut_fall, FALSE, FALSE,
7051 Ynut_s, FALSE, FALSE,
7052 EL_NUT, ACTION_FALLING, -1
7055 Ynut_sB, FALSE, TRUE,
7056 EL_NUT, ACTION_FALLING, -1
7059 Ynut_e, FALSE, FALSE,
7060 EL_NUT, ACTION_MOVING, MV_BIT_RIGHT
7063 Ynut_eB, FALSE, TRUE,
7064 EL_NUT, ACTION_MOVING, MV_BIT_RIGHT
7067 Ynut_w, FALSE, FALSE,
7068 EL_NUT, ACTION_MOVING, MV_BIT_LEFT
7071 Ynut_wB, FALSE, TRUE,
7072 EL_NUT, ACTION_MOVING, MV_BIT_LEFT
7075 Xbug_n, TRUE, FALSE,
7079 Xbug_e, TRUE, FALSE,
7080 EL_BUG_RIGHT, -1, -1
7083 Xbug_s, TRUE, FALSE,
7087 Xbug_w, TRUE, FALSE,
7091 Xbug_gon, FALSE, FALSE,
7095 Xbug_goe, FALSE, FALSE,
7096 EL_BUG_RIGHT, -1, -1
7099 Xbug_gos, FALSE, FALSE,
7103 Xbug_gow, FALSE, FALSE,
7107 Ybug_n, FALSE, FALSE,
7108 EL_BUG, ACTION_MOVING, MV_BIT_UP
7111 Ybug_nB, FALSE, TRUE,
7112 EL_BUG, ACTION_MOVING, MV_BIT_UP
7115 Ybug_e, FALSE, FALSE,
7116 EL_BUG, ACTION_MOVING, MV_BIT_RIGHT
7119 Ybug_eB, FALSE, TRUE,
7120 EL_BUG, ACTION_MOVING, MV_BIT_RIGHT
7123 Ybug_s, FALSE, FALSE,
7124 EL_BUG, ACTION_MOVING, MV_BIT_DOWN
7127 Ybug_sB, FALSE, TRUE,
7128 EL_BUG, ACTION_MOVING, MV_BIT_DOWN
7131 Ybug_w, FALSE, FALSE,
7132 EL_BUG, ACTION_MOVING, MV_BIT_LEFT
7135 Ybug_wB, FALSE, TRUE,
7136 EL_BUG, ACTION_MOVING, MV_BIT_LEFT
7139 Ybug_w_n, FALSE, FALSE,
7140 EL_BUG, ACTION_TURNING_FROM_LEFT, MV_BIT_UP
7143 Ybug_n_e, FALSE, FALSE,
7144 EL_BUG, ACTION_TURNING_FROM_UP, MV_BIT_RIGHT
7147 Ybug_e_s, FALSE, FALSE,
7148 EL_BUG, ACTION_TURNING_FROM_RIGHT, MV_BIT_DOWN
7151 Ybug_s_w, FALSE, FALSE,
7152 EL_BUG, ACTION_TURNING_FROM_DOWN, MV_BIT_LEFT
7155 Ybug_e_n, FALSE, FALSE,
7156 EL_BUG, ACTION_TURNING_FROM_RIGHT, MV_BIT_UP
7159 Ybug_s_e, FALSE, FALSE,
7160 EL_BUG, ACTION_TURNING_FROM_DOWN, MV_BIT_RIGHT
7163 Ybug_w_s, FALSE, FALSE,
7164 EL_BUG, ACTION_TURNING_FROM_LEFT, MV_BIT_DOWN
7167 Ybug_n_w, FALSE, FALSE,
7168 EL_BUG, ACTION_TURNING_FROM_UP, MV_BIT_LEFT
7171 Ybug_stone, FALSE, FALSE,
7172 EL_BUG, ACTION_SMASHED_BY_ROCK, -1
7175 Ybug_spring, FALSE, FALSE,
7176 EL_BUG, ACTION_SMASHED_BY_SPRING, -1
7179 Xtank_n, TRUE, FALSE,
7180 EL_SPACESHIP_UP, -1, -1
7183 Xtank_e, TRUE, FALSE,
7184 EL_SPACESHIP_RIGHT, -1, -1
7187 Xtank_s, TRUE, FALSE,
7188 EL_SPACESHIP_DOWN, -1, -1
7191 Xtank_w, TRUE, FALSE,
7192 EL_SPACESHIP_LEFT, -1, -1
7195 Xtank_gon, FALSE, FALSE,
7196 EL_SPACESHIP_UP, -1, -1
7199 Xtank_goe, FALSE, FALSE,
7200 EL_SPACESHIP_RIGHT, -1, -1
7203 Xtank_gos, FALSE, FALSE,
7204 EL_SPACESHIP_DOWN, -1, -1
7207 Xtank_gow, FALSE, FALSE,
7208 EL_SPACESHIP_LEFT, -1, -1
7211 Ytank_n, FALSE, FALSE,
7212 EL_SPACESHIP, ACTION_MOVING, MV_BIT_UP
7215 Ytank_nB, FALSE, TRUE,
7216 EL_SPACESHIP, ACTION_MOVING, MV_BIT_UP
7219 Ytank_e, FALSE, FALSE,
7220 EL_SPACESHIP, ACTION_MOVING, MV_BIT_RIGHT
7223 Ytank_eB, FALSE, TRUE,
7224 EL_SPACESHIP, ACTION_MOVING, MV_BIT_RIGHT
7227 Ytank_s, FALSE, FALSE,
7228 EL_SPACESHIP, ACTION_MOVING, MV_BIT_DOWN
7231 Ytank_sB, FALSE, TRUE,
7232 EL_SPACESHIP, ACTION_MOVING, MV_BIT_DOWN
7235 Ytank_w, FALSE, FALSE,
7236 EL_SPACESHIP, ACTION_MOVING, MV_BIT_LEFT
7239 Ytank_wB, FALSE, TRUE,
7240 EL_SPACESHIP, ACTION_MOVING, MV_BIT_LEFT
7243 Ytank_w_n, FALSE, FALSE,
7244 EL_SPACESHIP, ACTION_TURNING_FROM_LEFT, MV_BIT_UP
7247 Ytank_n_e, FALSE, FALSE,
7248 EL_SPACESHIP, ACTION_TURNING_FROM_UP, MV_BIT_RIGHT
7251 Ytank_e_s, FALSE, FALSE,
7252 EL_SPACESHIP, ACTION_TURNING_FROM_RIGHT, MV_BIT_DOWN
7255 Ytank_s_w, FALSE, FALSE,
7256 EL_SPACESHIP, ACTION_TURNING_FROM_DOWN, MV_BIT_LEFT
7259 Ytank_e_n, FALSE, FALSE,
7260 EL_SPACESHIP, ACTION_TURNING_FROM_RIGHT, MV_BIT_UP
7263 Ytank_s_e, FALSE, FALSE,
7264 EL_SPACESHIP, ACTION_TURNING_FROM_DOWN, MV_BIT_RIGHT
7267 Ytank_w_s, FALSE, FALSE,
7268 EL_SPACESHIP, ACTION_TURNING_FROM_LEFT, MV_BIT_DOWN
7271 Ytank_n_w, FALSE, FALSE,
7272 EL_SPACESHIP, ACTION_TURNING_FROM_UP, MV_BIT_LEFT
7275 Ytank_stone, FALSE, FALSE,
7276 EL_SPACESHIP, ACTION_SMASHED_BY_ROCK, -1
7279 Ytank_spring, FALSE, FALSE,
7280 EL_SPACESHIP, ACTION_SMASHED_BY_SPRING, -1
7283 Xandroid, TRUE, FALSE,
7284 EL_EMC_ANDROID, ACTION_ACTIVE, -1
7287 Xandroid_1_n, FALSE, FALSE,
7288 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_UP
7291 Xandroid_2_n, FALSE, FALSE,
7292 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_UP
7295 Xandroid_1_e, FALSE, FALSE,
7296 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_RIGHT
7299 Xandroid_2_e, FALSE, FALSE,
7300 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_RIGHT
7303 Xandroid_1_w, FALSE, FALSE,
7304 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_LEFT
7307 Xandroid_2_w, FALSE, FALSE,
7308 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_LEFT
7311 Xandroid_1_s, FALSE, FALSE,
7312 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_DOWN
7315 Xandroid_2_s, FALSE, FALSE,
7316 EL_EMC_ANDROID, ACTION_ACTIVE, MV_BIT_DOWN
7319 Yandroid_n, FALSE, FALSE,
7320 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_UP
7323 Yandroid_nB, FALSE, TRUE,
7324 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_UP
7327 Yandroid_ne, FALSE, FALSE,
7328 EL_EMC_ANDROID, ACTION_GROWING, MV_BIT_UPRIGHT
7331 Yandroid_neB, FALSE, TRUE,
7332 EL_EMC_ANDROID, ACTION_SHRINKING, MV_BIT_UPRIGHT
7335 Yandroid_e, FALSE, FALSE,
7336 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_RIGHT
7339 Yandroid_eB, FALSE, TRUE,
7340 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_RIGHT
7343 Yandroid_se, FALSE, FALSE,
7344 EL_EMC_ANDROID, ACTION_GROWING, MV_BIT_DOWNRIGHT
7347 Yandroid_seB, FALSE, TRUE,
7348 EL_EMC_ANDROID, ACTION_SHRINKING, MV_BIT_DOWNRIGHT
7351 Yandroid_s, FALSE, FALSE,
7352 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_DOWN
7355 Yandroid_sB, FALSE, TRUE,
7356 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_DOWN
7359 Yandroid_sw, FALSE, FALSE,
7360 EL_EMC_ANDROID, ACTION_GROWING, MV_BIT_DOWNLEFT
7363 Yandroid_swB, FALSE, TRUE,
7364 EL_EMC_ANDROID, ACTION_SHRINKING, MV_BIT_DOWNLEFT
7367 Yandroid_w, FALSE, FALSE,
7368 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_LEFT
7371 Yandroid_wB, FALSE, TRUE,
7372 EL_EMC_ANDROID, ACTION_MOVING, MV_BIT_LEFT
7375 Yandroid_nw, FALSE, FALSE,
7376 EL_EMC_ANDROID, ACTION_GROWING, MV_BIT_UPLEFT
7379 Yandroid_nwB, FALSE, TRUE,
7380 EL_EMC_ANDROID, ACTION_SHRINKING, MV_BIT_UPLEFT
7383 Xspring, TRUE, FALSE,
7387 Xspring_pause, FALSE, FALSE,
7391 Xspring_e, FALSE, FALSE,
7395 Xspring_w, FALSE, FALSE,
7399 Xspring_fall, FALSE, FALSE,
7403 Yspring_s, FALSE, FALSE,
7404 EL_SPRING, ACTION_FALLING, -1
7407 Yspring_sB, FALSE, TRUE,
7408 EL_SPRING, ACTION_FALLING, -1
7411 Yspring_e, FALSE, FALSE,
7412 EL_SPRING, ACTION_MOVING, MV_BIT_RIGHT
7415 Yspring_eB, FALSE, TRUE,
7416 EL_SPRING, ACTION_MOVING, MV_BIT_RIGHT
7419 Yspring_w, FALSE, FALSE,
7420 EL_SPRING, ACTION_MOVING, MV_BIT_LEFT
7423 Yspring_wB, FALSE, TRUE,
7424 EL_SPRING, ACTION_MOVING, MV_BIT_LEFT
7427 Yspring_kill_e, FALSE, FALSE,
7428 EL_SPRING, ACTION_EATING, MV_BIT_RIGHT
7431 Yspring_kill_eB, FALSE, TRUE,
7432 EL_SPRING, ACTION_EATING, MV_BIT_RIGHT
7435 Yspring_kill_w, FALSE, FALSE,
7436 EL_SPRING, ACTION_EATING, MV_BIT_LEFT
7439 Yspring_kill_wB, FALSE, TRUE,
7440 EL_SPRING, ACTION_EATING, MV_BIT_LEFT
7443 Xeater_n, TRUE, FALSE,
7444 EL_YAMYAM_UP, -1, -1
7447 Xeater_e, TRUE, FALSE,
7448 EL_YAMYAM_RIGHT, -1, -1
7451 Xeater_w, TRUE, FALSE,
7452 EL_YAMYAM_LEFT, -1, -1
7455 Xeater_s, TRUE, FALSE,
7456 EL_YAMYAM_DOWN, -1, -1
7459 Yeater_n, FALSE, FALSE,
7460 EL_YAMYAM, ACTION_MOVING, MV_BIT_UP
7463 Yeater_nB, FALSE, TRUE,
7464 EL_YAMYAM, ACTION_MOVING, MV_BIT_UP
7467 Yeater_e, FALSE, FALSE,
7468 EL_YAMYAM, ACTION_MOVING, MV_BIT_RIGHT
7471 Yeater_eB, FALSE, TRUE,
7472 EL_YAMYAM, ACTION_MOVING, MV_BIT_RIGHT
7475 Yeater_s, FALSE, FALSE,
7476 EL_YAMYAM, ACTION_MOVING, MV_BIT_DOWN
7479 Yeater_sB, FALSE, TRUE,
7480 EL_YAMYAM, ACTION_MOVING, MV_BIT_DOWN
7483 Yeater_w, FALSE, FALSE,
7484 EL_YAMYAM, ACTION_MOVING, MV_BIT_LEFT
7487 Yeater_wB, FALSE, TRUE,
7488 EL_YAMYAM, ACTION_MOVING, MV_BIT_LEFT
7491 Yeater_stone, FALSE, FALSE,
7492 EL_YAMYAM, ACTION_SMASHED_BY_ROCK, -1
7495 Yeater_spring, FALSE, FALSE,
7496 EL_YAMYAM, ACTION_SMASHED_BY_SPRING, -1
7499 Xalien, TRUE, FALSE,
7503 Xalien_pause, FALSE, FALSE,
7507 Yalien_n, FALSE, FALSE,
7508 EL_ROBOT, ACTION_MOVING, MV_BIT_UP
7511 Yalien_nB, FALSE, TRUE,
7512 EL_ROBOT, ACTION_MOVING, MV_BIT_UP
7515 Yalien_e, FALSE, FALSE,
7516 EL_ROBOT, ACTION_MOVING, MV_BIT_RIGHT
7519 Yalien_eB, FALSE, TRUE,
7520 EL_ROBOT, ACTION_MOVING, MV_BIT_RIGHT
7523 Yalien_s, FALSE, FALSE,
7524 EL_ROBOT, ACTION_MOVING, MV_BIT_DOWN
7527 Yalien_sB, FALSE, TRUE,
7528 EL_ROBOT, ACTION_MOVING, MV_BIT_DOWN
7531 Yalien_w, FALSE, FALSE,
7532 EL_ROBOT, ACTION_MOVING, MV_BIT_LEFT
7535 Yalien_wB, FALSE, TRUE,
7536 EL_ROBOT, ACTION_MOVING, MV_BIT_LEFT
7539 Yalien_stone, FALSE, FALSE,
7540 EL_ROBOT, ACTION_SMASHED_BY_ROCK, -1
7543 Yalien_spring, FALSE, FALSE,
7544 EL_ROBOT, ACTION_SMASHED_BY_SPRING, -1
7547 Xemerald, TRUE, FALSE,
7551 Xemerald_pause, FALSE, FALSE,
7555 Xemerald_fall, FALSE, FALSE,
7559 Xemerald_shine, FALSE, FALSE,
7560 EL_EMERALD, ACTION_TWINKLING, -1
7563 Yemerald_s, FALSE, FALSE,
7564 EL_EMERALD, ACTION_FALLING, -1
7567 Yemerald_sB, FALSE, TRUE,
7568 EL_EMERALD, ACTION_FALLING, -1
7571 Yemerald_e, FALSE, FALSE,
7572 EL_EMERALD, ACTION_MOVING, MV_BIT_RIGHT
7575 Yemerald_eB, FALSE, TRUE,
7576 EL_EMERALD, ACTION_MOVING, MV_BIT_RIGHT
7579 Yemerald_w, FALSE, FALSE,
7580 EL_EMERALD, ACTION_MOVING, MV_BIT_LEFT
7583 Yemerald_wB, FALSE, TRUE,
7584 EL_EMERALD, ACTION_MOVING, MV_BIT_LEFT
7587 Yemerald_eat, FALSE, FALSE,
7588 EL_EMERALD, ACTION_COLLECTING, -1
7591 Yemerald_stone, FALSE, FALSE,
7592 EL_NUT, ACTION_BREAKING, -1
7595 Xdiamond, TRUE, FALSE,
7599 Xdiamond_pause, FALSE, FALSE,
7603 Xdiamond_fall, FALSE, FALSE,
7607 Xdiamond_shine, FALSE, FALSE,
7608 EL_DIAMOND, ACTION_TWINKLING, -1
7611 Ydiamond_s, FALSE, FALSE,
7612 EL_DIAMOND, ACTION_FALLING, -1
7615 Ydiamond_sB, FALSE, TRUE,
7616 EL_DIAMOND, ACTION_FALLING, -1
7619 Ydiamond_e, FALSE, FALSE,
7620 EL_DIAMOND, ACTION_MOVING, MV_BIT_RIGHT
7623 Ydiamond_eB, FALSE, TRUE,
7624 EL_DIAMOND, ACTION_MOVING, MV_BIT_RIGHT
7627 Ydiamond_w, FALSE, FALSE,
7628 EL_DIAMOND, ACTION_MOVING, MV_BIT_LEFT
7631 Ydiamond_wB, FALSE, TRUE,
7632 EL_DIAMOND, ACTION_MOVING, MV_BIT_LEFT
7635 Ydiamond_eat, FALSE, FALSE,
7636 EL_DIAMOND, ACTION_COLLECTING, -1
7639 Ydiamond_stone, FALSE, FALSE,
7640 EL_DIAMOND, ACTION_SMASHED_BY_ROCK, -1
7643 Xdrip_fall, TRUE, FALSE,
7644 EL_AMOEBA_DROP, -1, -1
7647 Xdrip_stretch, FALSE, FALSE,
7648 EL_AMOEBA_DROP, ACTION_FALLING, -1
7651 Xdrip_stretchB, FALSE, TRUE,
7652 EL_AMOEBA_DROP, ACTION_FALLING, -1
7655 Xdrip_eat, FALSE, FALSE,
7656 EL_AMOEBA_DROP, ACTION_GROWING, -1
7659 Ydrip_s1, FALSE, FALSE,
7660 EL_AMOEBA_DROP, ACTION_FALLING, -1
7663 Ydrip_s1B, FALSE, TRUE,
7664 EL_AMOEBA_DROP, ACTION_FALLING, -1
7667 Ydrip_s2, FALSE, FALSE,
7668 EL_AMOEBA_DROP, ACTION_FALLING, -1
7671 Ydrip_s2B, FALSE, TRUE,
7672 EL_AMOEBA_DROP, ACTION_FALLING, -1
7679 Xbomb_pause, FALSE, FALSE,
7683 Xbomb_fall, FALSE, FALSE,
7687 Ybomb_s, FALSE, FALSE,
7688 EL_BOMB, ACTION_FALLING, -1
7691 Ybomb_sB, FALSE, TRUE,
7692 EL_BOMB, ACTION_FALLING, -1
7695 Ybomb_e, FALSE, FALSE,
7696 EL_BOMB, ACTION_MOVING, MV_BIT_RIGHT
7699 Ybomb_eB, FALSE, TRUE,
7700 EL_BOMB, ACTION_MOVING, MV_BIT_RIGHT
7703 Ybomb_w, FALSE, FALSE,
7704 EL_BOMB, ACTION_MOVING, MV_BIT_LEFT
7707 Ybomb_wB, FALSE, TRUE,
7708 EL_BOMB, ACTION_MOVING, MV_BIT_LEFT
7711 Ybomb_eat, FALSE, FALSE,
7712 EL_BOMB, ACTION_ACTIVATING, -1
7715 Xballoon, TRUE, FALSE,
7719 Yballoon_n, FALSE, FALSE,
7720 EL_BALLOON, ACTION_MOVING, MV_BIT_UP
7723 Yballoon_nB, FALSE, TRUE,
7724 EL_BALLOON, ACTION_MOVING, MV_BIT_UP
7727 Yballoon_e, FALSE, FALSE,
7728 EL_BALLOON, ACTION_MOVING, MV_BIT_RIGHT
7731 Yballoon_eB, FALSE, TRUE,
7732 EL_BALLOON, ACTION_MOVING, MV_BIT_RIGHT
7735 Yballoon_s, FALSE, FALSE,
7736 EL_BALLOON, ACTION_MOVING, MV_BIT_DOWN
7739 Yballoon_sB, FALSE, TRUE,
7740 EL_BALLOON, ACTION_MOVING, MV_BIT_DOWN
7743 Yballoon_w, FALSE, FALSE,
7744 EL_BALLOON, ACTION_MOVING, MV_BIT_LEFT
7747 Yballoon_wB, FALSE, TRUE,
7748 EL_BALLOON, ACTION_MOVING, MV_BIT_LEFT
7751 Xgrass, TRUE, FALSE,
7752 EL_EMC_GRASS, -1, -1
7755 Ygrass_nB, FALSE, FALSE,
7756 EL_EMC_GRASS, ACTION_DIGGING, MV_BIT_UP
7759 Ygrass_eB, FALSE, FALSE,
7760 EL_EMC_GRASS, ACTION_DIGGING, MV_BIT_RIGHT
7763 Ygrass_sB, FALSE, FALSE,
7764 EL_EMC_GRASS, ACTION_DIGGING, MV_BIT_DOWN
7767 Ygrass_wB, FALSE, FALSE,
7768 EL_EMC_GRASS, ACTION_DIGGING, MV_BIT_LEFT
7775 Ydirt_nB, FALSE, FALSE,
7776 EL_SAND, ACTION_DIGGING, MV_BIT_UP
7779 Ydirt_eB, FALSE, FALSE,
7780 EL_SAND, ACTION_DIGGING, MV_BIT_RIGHT
7783 Ydirt_sB, FALSE, FALSE,
7784 EL_SAND, ACTION_DIGGING, MV_BIT_DOWN
7787 Ydirt_wB, FALSE, FALSE,
7788 EL_SAND, ACTION_DIGGING, MV_BIT_LEFT
7791 Xacid_ne, TRUE, FALSE,
7792 EL_ACID_POOL_TOPRIGHT, -1, -1
7795 Xacid_se, TRUE, FALSE,
7796 EL_ACID_POOL_BOTTOMRIGHT, -1, -1
7799 Xacid_s, TRUE, FALSE,
7800 EL_ACID_POOL_BOTTOM, -1, -1
7803 Xacid_sw, TRUE, FALSE,
7804 EL_ACID_POOL_BOTTOMLEFT, -1, -1
7807 Xacid_nw, TRUE, FALSE,
7808 EL_ACID_POOL_TOPLEFT, -1, -1
7811 Xacid_1, TRUE, FALSE,
7815 Xacid_2, FALSE, FALSE,
7819 Xacid_3, FALSE, FALSE,
7823 Xacid_4, FALSE, FALSE,
7827 Xacid_5, FALSE, FALSE,
7831 Xacid_6, FALSE, FALSE,
7835 Xacid_7, FALSE, FALSE,
7839 Xacid_8, FALSE, FALSE,
7843 Xball_1, TRUE, FALSE,
7844 EL_EMC_MAGIC_BALL, -1, -1
7847 Xball_1B, FALSE, FALSE,
7848 EL_EMC_MAGIC_BALL, ACTION_ACTIVE, -1
7851 Xball_2, FALSE, FALSE,
7852 EL_EMC_MAGIC_BALL, ACTION_ACTIVE, -1
7855 Xball_2B, FALSE, FALSE,
7856 EL_EMC_MAGIC_BALL, ACTION_ACTIVE, -1
7859 Yball_eat, FALSE, FALSE,
7860 EL_EMC_MAGIC_BALL, ACTION_DROPPING, -1
7863 Ykey_1_eat, FALSE, FALSE,
7864 EL_EM_KEY_1, ACTION_COLLECTING, -1
7867 Ykey_2_eat, FALSE, FALSE,
7868 EL_EM_KEY_2, ACTION_COLLECTING, -1
7871 Ykey_3_eat, FALSE, FALSE,
7872 EL_EM_KEY_3, ACTION_COLLECTING, -1
7875 Ykey_4_eat, FALSE, FALSE,
7876 EL_EM_KEY_4, ACTION_COLLECTING, -1
7879 Ykey_5_eat, FALSE, FALSE,
7880 EL_EMC_KEY_5, ACTION_COLLECTING, -1
7883 Ykey_6_eat, FALSE, FALSE,
7884 EL_EMC_KEY_6, ACTION_COLLECTING, -1
7887 Ykey_7_eat, FALSE, FALSE,
7888 EL_EMC_KEY_7, ACTION_COLLECTING, -1
7891 Ykey_8_eat, FALSE, FALSE,
7892 EL_EMC_KEY_8, ACTION_COLLECTING, -1
7895 Ylenses_eat, FALSE, FALSE,
7896 EL_EMC_LENSES, ACTION_COLLECTING, -1
7899 Ymagnify_eat, FALSE, FALSE,
7900 EL_EMC_MAGNIFIER, ACTION_COLLECTING, -1
7903 Ygrass_eat, FALSE, FALSE,
7904 EL_EMC_GRASS, ACTION_SNAPPING, -1
7907 Ydirt_eat, FALSE, FALSE,
7908 EL_SAND, ACTION_SNAPPING, -1
7911 Xgrow_ns, TRUE, FALSE,
7912 EL_EXPANDABLE_WALL_VERTICAL, -1, -1
7915 Ygrow_ns_eat, FALSE, FALSE,
7916 EL_EXPANDABLE_WALL_VERTICAL, ACTION_GROWING, -1
7919 Xgrow_ew, TRUE, FALSE,
7920 EL_EXPANDABLE_WALL_HORIZONTAL, -1, -1
7923 Ygrow_ew_eat, FALSE, FALSE,
7924 EL_EXPANDABLE_WALL_HORIZONTAL, ACTION_GROWING, -1
7927 Xwonderwall, TRUE, FALSE,
7928 EL_MAGIC_WALL, -1, -1
7931 XwonderwallB, FALSE, FALSE,
7932 EL_MAGIC_WALL, ACTION_ACTIVE, -1
7935 Xamoeba_1, TRUE, FALSE,
7936 EL_AMOEBA_DRY, ACTION_OTHER, -1
7939 Xamoeba_2, FALSE, FALSE,
7940 EL_AMOEBA_DRY, ACTION_OTHER, -1
7943 Xamoeba_3, FALSE, FALSE,
7944 EL_AMOEBA_DRY, ACTION_OTHER, -1
7947 Xamoeba_4, FALSE, FALSE,
7948 EL_AMOEBA_DRY, ACTION_OTHER, -1
7951 Xamoeba_5, TRUE, FALSE,
7952 EL_AMOEBA_WET, ACTION_OTHER, -1
7955 Xamoeba_6, FALSE, FALSE,
7956 EL_AMOEBA_WET, ACTION_OTHER, -1
7959 Xamoeba_7, FALSE, FALSE,
7960 EL_AMOEBA_WET, ACTION_OTHER, -1
7963 Xamoeba_8, FALSE, FALSE,
7964 EL_AMOEBA_WET, ACTION_OTHER, -1
7967 Xdoor_1, TRUE, FALSE,
7968 EL_EM_GATE_1, -1, -1
7971 Xdoor_2, TRUE, FALSE,
7972 EL_EM_GATE_2, -1, -1
7975 Xdoor_3, TRUE, FALSE,
7976 EL_EM_GATE_3, -1, -1
7979 Xdoor_4, TRUE, FALSE,
7980 EL_EM_GATE_4, -1, -1
7983 Xdoor_5, TRUE, FALSE,
7984 EL_EMC_GATE_5, -1, -1
7987 Xdoor_6, TRUE, FALSE,
7988 EL_EMC_GATE_6, -1, -1
7991 Xdoor_7, TRUE, FALSE,
7992 EL_EMC_GATE_7, -1, -1
7995 Xdoor_8, TRUE, FALSE,
7996 EL_EMC_GATE_8, -1, -1
7999 Xkey_1, TRUE, FALSE,
8003 Xkey_2, TRUE, FALSE,
8007 Xkey_3, TRUE, FALSE,
8011 Xkey_4, TRUE, FALSE,
8015 Xkey_5, TRUE, FALSE,
8016 EL_EMC_KEY_5, -1, -1
8019 Xkey_6, TRUE, FALSE,
8020 EL_EMC_KEY_6, -1, -1
8023 Xkey_7, TRUE, FALSE,
8024 EL_EMC_KEY_7, -1, -1
8027 Xkey_8, TRUE, FALSE,
8028 EL_EMC_KEY_8, -1, -1
8031 Xwind_n, TRUE, FALSE,
8032 EL_BALLOON_SWITCH_UP, -1, -1
8035 Xwind_e, TRUE, FALSE,
8036 EL_BALLOON_SWITCH_RIGHT, -1, -1
8039 Xwind_s, TRUE, FALSE,
8040 EL_BALLOON_SWITCH_DOWN, -1, -1
8043 Xwind_w, TRUE, FALSE,
8044 EL_BALLOON_SWITCH_LEFT, -1, -1
8047 Xwind_nesw, TRUE, FALSE,
8048 EL_BALLOON_SWITCH_ANY, -1, -1
8051 Xwind_stop, TRUE, FALSE,
8052 EL_BALLOON_SWITCH_NONE, -1, -1
8056 EL_EM_EXIT_CLOSED, -1, -1
8059 Xexit_1, TRUE, FALSE,
8060 EL_EM_EXIT_OPEN, -1, -1
8063 Xexit_2, FALSE, FALSE,
8064 EL_EM_EXIT_OPEN, -1, -1
8067 Xexit_3, FALSE, FALSE,
8068 EL_EM_EXIT_OPEN, -1, -1
8071 Xdynamite, TRUE, FALSE,
8072 EL_EM_DYNAMITE, -1, -1
8075 Ydynamite_eat, FALSE, FALSE,
8076 EL_EM_DYNAMITE, ACTION_COLLECTING, -1
8079 Xdynamite_1, TRUE, FALSE,
8080 EL_EM_DYNAMITE_ACTIVE, -1, -1
8083 Xdynamite_2, FALSE, FALSE,
8084 EL_EM_DYNAMITE_ACTIVE, -1, -1
8087 Xdynamite_3, FALSE, FALSE,
8088 EL_EM_DYNAMITE_ACTIVE, -1, -1
8091 Xdynamite_4, FALSE, FALSE,
8092 EL_EM_DYNAMITE_ACTIVE, -1, -1
8095 Xbumper, TRUE, FALSE,
8096 EL_EMC_SPRING_BUMPER, -1, -1
8099 XbumperB, FALSE, FALSE,
8100 EL_EMC_SPRING_BUMPER, ACTION_ACTIVE, -1
8103 Xwheel, TRUE, FALSE,
8104 EL_ROBOT_WHEEL, -1, -1
8107 XwheelB, FALSE, FALSE,
8108 EL_ROBOT_WHEEL, ACTION_ACTIVE, -1
8111 Xswitch, TRUE, FALSE,
8112 EL_EMC_MAGIC_BALL_SWITCH, -1, -1
8115 XswitchB, FALSE, FALSE,
8116 EL_EMC_MAGIC_BALL_SWITCH, ACTION_ACTIVE, -1
8120 EL_QUICKSAND_EMPTY, -1, -1
8123 Xsand_stone, TRUE, FALSE,
8124 EL_QUICKSAND_FULL, -1, -1
8127 Xsand_stonein_1, FALSE, TRUE,
8128 EL_ROCK, ACTION_FILLING, -1
8131 Xsand_stonein_2, FALSE, TRUE,
8132 EL_ROCK, ACTION_FILLING, -1
8135 Xsand_stonein_3, FALSE, TRUE,
8136 EL_ROCK, ACTION_FILLING, -1
8139 Xsand_stonein_4, FALSE, TRUE,
8140 EL_ROCK, ACTION_FILLING, -1
8144 Xsand_stonesand_1, FALSE, FALSE,
8145 EL_QUICKSAND_EMPTYING, -1, -1
8148 Xsand_stonesand_2, FALSE, FALSE,
8149 EL_QUICKSAND_EMPTYING, -1, -1
8152 Xsand_stonesand_3, FALSE, FALSE,
8153 EL_QUICKSAND_EMPTYING, -1, -1
8156 Xsand_stonesand_4, FALSE, FALSE,
8157 EL_QUICKSAND_EMPTYING, -1, -1
8160 Xsand_stonesand_quickout_1, FALSE, FALSE,
8161 EL_QUICKSAND_EMPTYING, -1, -1
8164 Xsand_stonesand_quickout_2, FALSE, FALSE,
8165 EL_QUICKSAND_EMPTYING, -1, -1
8169 Xsand_stonesand_1, FALSE, FALSE,
8170 EL_QUICKSAND_FULL, -1, -1
8173 Xsand_stonesand_2, FALSE, FALSE,
8174 EL_QUICKSAND_FULL, -1, -1
8177 Xsand_stonesand_3, FALSE, FALSE,
8178 EL_QUICKSAND_FULL, -1, -1
8181 Xsand_stonesand_4, FALSE, FALSE,
8182 EL_QUICKSAND_FULL, -1, -1
8186 Xsand_stoneout_1, FALSE, FALSE,
8187 EL_ROCK, ACTION_EMPTYING, -1
8190 Xsand_stoneout_2, FALSE, FALSE,
8191 EL_ROCK, ACTION_EMPTYING, -1
8195 Xsand_sandstone_1, FALSE, FALSE,
8196 EL_QUICKSAND_FILLING, -1, -1
8199 Xsand_sandstone_2, FALSE, FALSE,
8200 EL_QUICKSAND_FILLING, -1, -1
8203 Xsand_sandstone_3, FALSE, FALSE,
8204 EL_QUICKSAND_FILLING, -1, -1
8207 Xsand_sandstone_4, FALSE, FALSE,
8208 EL_QUICKSAND_FILLING, -1, -1
8212 Xsand_sandstone_1, FALSE, FALSE,
8213 EL_QUICKSAND_FULL, -1, -1
8216 Xsand_sandstone_2, FALSE, FALSE,
8217 EL_QUICKSAND_FULL, -1, -1
8220 Xsand_sandstone_3, FALSE, FALSE,
8221 EL_QUICKSAND_FULL, -1, -1
8224 Xsand_sandstone_4, FALSE, FALSE,
8225 EL_QUICKSAND_FULL, -1, -1
8229 Xplant, TRUE, FALSE,
8230 EL_EMC_PLANT, -1, -1
8233 Yplant, FALSE, FALSE,
8234 EL_EMC_PLANT, -1, -1
8237 Xlenses, TRUE, FALSE,
8238 EL_EMC_LENSES, -1, -1
8241 Xmagnify, TRUE, FALSE,
8242 EL_EMC_MAGNIFIER, -1, -1
8245 Xdripper, TRUE, FALSE,
8246 EL_EMC_DRIPPER, -1, -1
8249 XdripperB, FALSE, FALSE,
8250 EL_EMC_DRIPPER, ACTION_ACTIVE, -1
8253 Xfake_blank, TRUE, FALSE,
8254 EL_INVISIBLE_WALL, -1, -1
8257 Xfake_blankB, FALSE, FALSE,
8258 EL_INVISIBLE_WALL, ACTION_ACTIVE, -1
8261 Xfake_grass, TRUE, FALSE,
8262 EL_EMC_FAKE_GRASS, -1, -1
8265 Xfake_grassB, FALSE, FALSE,
8266 EL_EMC_FAKE_GRASS, ACTION_ACTIVE, -1
8269 Xfake_door_1, TRUE, FALSE,
8270 EL_EM_GATE_1_GRAY, -1, -1
8273 Xfake_door_2, TRUE, FALSE,
8274 EL_EM_GATE_2_GRAY, -1, -1
8277 Xfake_door_3, TRUE, FALSE,
8278 EL_EM_GATE_3_GRAY, -1, -1
8281 Xfake_door_4, TRUE, FALSE,
8282 EL_EM_GATE_4_GRAY, -1, -1
8285 Xfake_door_5, TRUE, FALSE,
8286 EL_EMC_GATE_5_GRAY, -1, -1
8289 Xfake_door_6, TRUE, FALSE,
8290 EL_EMC_GATE_6_GRAY, -1, -1
8293 Xfake_door_7, TRUE, FALSE,
8294 EL_EMC_GATE_7_GRAY, -1, -1
8297 Xfake_door_8, TRUE, FALSE,
8298 EL_EMC_GATE_8_GRAY, -1, -1
8301 Xfake_acid_1, TRUE, FALSE,
8302 EL_EMC_FAKE_ACID, -1, -1
8305 Xfake_acid_2, FALSE, FALSE,
8306 EL_EMC_FAKE_ACID, -1, -1
8309 Xfake_acid_3, FALSE, FALSE,
8310 EL_EMC_FAKE_ACID, -1, -1
8313 Xfake_acid_4, FALSE, FALSE,
8314 EL_EMC_FAKE_ACID, -1, -1
8317 Xfake_acid_5, FALSE, FALSE,
8318 EL_EMC_FAKE_ACID, -1, -1
8321 Xfake_acid_6, FALSE, FALSE,
8322 EL_EMC_FAKE_ACID, -1, -1
8325 Xfake_acid_7, FALSE, FALSE,
8326 EL_EMC_FAKE_ACID, -1, -1
8329 Xfake_acid_8, FALSE, FALSE,
8330 EL_EMC_FAKE_ACID, -1, -1
8333 Xsteel_1, TRUE, FALSE,
8334 EL_STEELWALL, -1, -1
8337 Xsteel_2, TRUE, FALSE,
8338 EL_EMC_STEELWALL_2, -1, -1
8341 Xsteel_3, TRUE, FALSE,
8342 EL_EMC_STEELWALL_3, -1, -1
8345 Xsteel_4, TRUE, FALSE,
8346 EL_EMC_STEELWALL_4, -1, -1
8349 Xwall_1, TRUE, FALSE,
8353 Xwall_2, TRUE, FALSE,
8354 EL_EMC_WALL_14, -1, -1
8357 Xwall_3, TRUE, FALSE,
8358 EL_EMC_WALL_15, -1, -1
8361 Xwall_4, TRUE, FALSE,
8362 EL_EMC_WALL_16, -1, -1
8365 Xround_wall_1, TRUE, FALSE,
8366 EL_WALL_SLIPPERY, -1, -1
8369 Xround_wall_2, TRUE, FALSE,
8370 EL_EMC_WALL_SLIPPERY_2, -1, -1
8373 Xround_wall_3, TRUE, FALSE,
8374 EL_EMC_WALL_SLIPPERY_3, -1, -1
8377 Xround_wall_4, TRUE, FALSE,
8378 EL_EMC_WALL_SLIPPERY_4, -1, -1
8381 Xdecor_1, TRUE, FALSE,
8382 EL_EMC_WALL_8, -1, -1
8385 Xdecor_2, TRUE, FALSE,
8386 EL_EMC_WALL_6, -1, -1
8389 Xdecor_3, TRUE, FALSE,
8390 EL_EMC_WALL_4, -1, -1
8393 Xdecor_4, TRUE, FALSE,
8394 EL_EMC_WALL_7, -1, -1
8397 Xdecor_5, TRUE, FALSE,
8398 EL_EMC_WALL_5, -1, -1
8401 Xdecor_6, TRUE, FALSE,
8402 EL_EMC_WALL_9, -1, -1
8405 Xdecor_7, TRUE, FALSE,
8406 EL_EMC_WALL_10, -1, -1
8409 Xdecor_8, TRUE, FALSE,
8410 EL_EMC_WALL_1, -1, -1
8413 Xdecor_9, TRUE, FALSE,
8414 EL_EMC_WALL_2, -1, -1
8417 Xdecor_10, TRUE, FALSE,
8418 EL_EMC_WALL_3, -1, -1
8421 Xdecor_11, TRUE, FALSE,
8422 EL_EMC_WALL_11, -1, -1
8425 Xdecor_12, TRUE, FALSE,
8426 EL_EMC_WALL_12, -1, -1
8429 Xalpha_0, TRUE, FALSE,
8430 EL_CHAR('0'), -1, -1
8433 Xalpha_1, TRUE, FALSE,
8434 EL_CHAR('1'), -1, -1
8437 Xalpha_2, TRUE, FALSE,
8438 EL_CHAR('2'), -1, -1
8441 Xalpha_3, TRUE, FALSE,
8442 EL_CHAR('3'), -1, -1
8445 Xalpha_4, TRUE, FALSE,
8446 EL_CHAR('4'), -1, -1
8449 Xalpha_5, TRUE, FALSE,
8450 EL_CHAR('5'), -1, -1
8453 Xalpha_6, TRUE, FALSE,
8454 EL_CHAR('6'), -1, -1
8457 Xalpha_7, TRUE, FALSE,
8458 EL_CHAR('7'), -1, -1
8461 Xalpha_8, TRUE, FALSE,
8462 EL_CHAR('8'), -1, -1
8465 Xalpha_9, TRUE, FALSE,
8466 EL_CHAR('9'), -1, -1
8469 Xalpha_excla, TRUE, FALSE,
8470 EL_CHAR('!'), -1, -1
8473 Xalpha_quote, TRUE, FALSE,
8474 EL_CHAR('"'), -1, -1
8477 Xalpha_comma, TRUE, FALSE,
8478 EL_CHAR(','), -1, -1
8481 Xalpha_minus, TRUE, FALSE,
8482 EL_CHAR('-'), -1, -1
8485 Xalpha_perio, TRUE, FALSE,
8486 EL_CHAR('.'), -1, -1
8489 Xalpha_colon, TRUE, FALSE,
8490 EL_CHAR(':'), -1, -1
8493 Xalpha_quest, TRUE, FALSE,
8494 EL_CHAR('?'), -1, -1
8497 Xalpha_a, TRUE, FALSE,
8498 EL_CHAR('A'), -1, -1
8501 Xalpha_b, TRUE, FALSE,
8502 EL_CHAR('B'), -1, -1
8505 Xalpha_c, TRUE, FALSE,
8506 EL_CHAR('C'), -1, -1
8509 Xalpha_d, TRUE, FALSE,
8510 EL_CHAR('D'), -1, -1
8513 Xalpha_e, TRUE, FALSE,
8514 EL_CHAR('E'), -1, -1
8517 Xalpha_f, TRUE, FALSE,
8518 EL_CHAR('F'), -1, -1
8521 Xalpha_g, TRUE, FALSE,
8522 EL_CHAR('G'), -1, -1
8525 Xalpha_h, TRUE, FALSE,
8526 EL_CHAR('H'), -1, -1
8529 Xalpha_i, TRUE, FALSE,
8530 EL_CHAR('I'), -1, -1
8533 Xalpha_j, TRUE, FALSE,
8534 EL_CHAR('J'), -1, -1
8537 Xalpha_k, TRUE, FALSE,
8538 EL_CHAR('K'), -1, -1
8541 Xalpha_l, TRUE, FALSE,
8542 EL_CHAR('L'), -1, -1
8545 Xalpha_m, TRUE, FALSE,
8546 EL_CHAR('M'), -1, -1
8549 Xalpha_n, TRUE, FALSE,
8550 EL_CHAR('N'), -1, -1
8553 Xalpha_o, TRUE, FALSE,
8554 EL_CHAR('O'), -1, -1
8557 Xalpha_p, TRUE, FALSE,
8558 EL_CHAR('P'), -1, -1
8561 Xalpha_q, TRUE, FALSE,
8562 EL_CHAR('Q'), -1, -1
8565 Xalpha_r, TRUE, FALSE,
8566 EL_CHAR('R'), -1, -1
8569 Xalpha_s, TRUE, FALSE,
8570 EL_CHAR('S'), -1, -1
8573 Xalpha_t, TRUE, FALSE,
8574 EL_CHAR('T'), -1, -1
8577 Xalpha_u, TRUE, FALSE,
8578 EL_CHAR('U'), -1, -1
8581 Xalpha_v, TRUE, FALSE,
8582 EL_CHAR('V'), -1, -1
8585 Xalpha_w, TRUE, FALSE,
8586 EL_CHAR('W'), -1, -1
8589 Xalpha_x, TRUE, FALSE,
8590 EL_CHAR('X'), -1, -1
8593 Xalpha_y, TRUE, FALSE,
8594 EL_CHAR('Y'), -1, -1
8597 Xalpha_z, TRUE, FALSE,
8598 EL_CHAR('Z'), -1, -1
8601 Xalpha_arrow_e, TRUE, FALSE,
8602 EL_CHAR('>'), -1, -1
8605 Xalpha_arrow_w, TRUE, FALSE,
8606 EL_CHAR('<'), -1, -1
8609 Xalpha_copyr, TRUE, FALSE,
8610 EL_CHAR('©'), -1, -1
8614 Xboom_bug, FALSE, FALSE,
8615 EL_BUG, ACTION_EXPLODING, -1
8618 Xboom_bomb, FALSE, FALSE,
8619 EL_BOMB, ACTION_EXPLODING, -1
8622 Xboom_android, FALSE, FALSE,
8623 EL_EMC_ANDROID, ACTION_OTHER, -1
8626 Xboom_1, FALSE, FALSE,
8627 EL_DEFAULT, ACTION_EXPLODING, -1
8630 Xboom_2, FALSE, FALSE,
8631 EL_DEFAULT, ACTION_EXPLODING, -1
8634 Znormal, FALSE, FALSE,
8638 Zdynamite, FALSE, FALSE,
8642 Zplayer, FALSE, FALSE,
8646 ZBORDER, FALSE, FALSE,
8656 static struct Mapping_EM_to_RND_player
8665 em_player_mapping_list[] =
8669 EL_PLAYER_1, ACTION_MOVING, MV_BIT_UP,
8673 EL_PLAYER_1, ACTION_MOVING, MV_BIT_RIGHT,
8677 EL_PLAYER_1, ACTION_MOVING, MV_BIT_DOWN,
8681 EL_PLAYER_1, ACTION_MOVING, MV_BIT_LEFT,
8685 EL_PLAYER_1, ACTION_PUSHING, MV_BIT_UP,
8689 EL_PLAYER_1, ACTION_PUSHING, MV_BIT_RIGHT,
8693 EL_PLAYER_1, ACTION_PUSHING, MV_BIT_DOWN,
8697 EL_PLAYER_1, ACTION_PUSHING, MV_BIT_LEFT,
8701 EL_PLAYER_1, ACTION_SNAPPING, MV_BIT_UP,
8705 EL_PLAYER_1, ACTION_SNAPPING, MV_BIT_RIGHT,
8709 EL_PLAYER_1, ACTION_SNAPPING, MV_BIT_DOWN,
8713 EL_PLAYER_1, ACTION_SNAPPING, MV_BIT_LEFT,
8717 EL_PLAYER_2, ACTION_MOVING, MV_BIT_UP,
8721 EL_PLAYER_2, ACTION_MOVING, MV_BIT_RIGHT,
8725 EL_PLAYER_2, ACTION_MOVING, MV_BIT_DOWN,
8729 EL_PLAYER_2, ACTION_MOVING, MV_BIT_LEFT,
8733 EL_PLAYER_2, ACTION_PUSHING, MV_BIT_UP,
8737 EL_PLAYER_2, ACTION_PUSHING, MV_BIT_RIGHT,
8741 EL_PLAYER_2, ACTION_PUSHING, MV_BIT_DOWN,
8745 EL_PLAYER_2, ACTION_PUSHING, MV_BIT_LEFT,
8749 EL_PLAYER_2, ACTION_SNAPPING, MV_BIT_UP,
8753 EL_PLAYER_2, ACTION_SNAPPING, MV_BIT_RIGHT,
8757 EL_PLAYER_2, ACTION_SNAPPING, MV_BIT_DOWN,
8761 EL_PLAYER_2, ACTION_SNAPPING, MV_BIT_LEFT,
8765 EL_PLAYER_1, ACTION_DEFAULT, -1,
8769 EL_PLAYER_2, ACTION_DEFAULT, -1,
8773 EL_PLAYER_3, ACTION_MOVING, MV_BIT_UP,
8777 EL_PLAYER_3, ACTION_MOVING, MV_BIT_RIGHT,
8781 EL_PLAYER_3, ACTION_MOVING, MV_BIT_DOWN,
8785 EL_PLAYER_3, ACTION_MOVING, MV_BIT_LEFT,
8789 EL_PLAYER_3, ACTION_PUSHING, MV_BIT_UP,
8793 EL_PLAYER_3, ACTION_PUSHING, MV_BIT_RIGHT,
8797 EL_PLAYER_3, ACTION_PUSHING, MV_BIT_DOWN,
8801 EL_PLAYER_3, ACTION_PUSHING, MV_BIT_LEFT,
8805 EL_PLAYER_3, ACTION_SNAPPING, MV_BIT_UP,
8809 EL_PLAYER_3, ACTION_SNAPPING, MV_BIT_RIGHT,
8813 EL_PLAYER_3, ACTION_SNAPPING, MV_BIT_DOWN,
8817 EL_PLAYER_3, ACTION_SNAPPING, MV_BIT_LEFT,
8821 EL_PLAYER_4, ACTION_MOVING, MV_BIT_UP,
8825 EL_PLAYER_4, ACTION_MOVING, MV_BIT_RIGHT,
8829 EL_PLAYER_4, ACTION_MOVING, MV_BIT_DOWN,
8833 EL_PLAYER_4, ACTION_MOVING, MV_BIT_LEFT,
8837 EL_PLAYER_4, ACTION_PUSHING, MV_BIT_UP,
8841 EL_PLAYER_4, ACTION_PUSHING, MV_BIT_RIGHT,
8845 EL_PLAYER_4, ACTION_PUSHING, MV_BIT_DOWN,
8849 EL_PLAYER_4, ACTION_PUSHING, MV_BIT_LEFT,
8853 EL_PLAYER_4, ACTION_SNAPPING, MV_BIT_UP,
8857 EL_PLAYER_4, ACTION_SNAPPING, MV_BIT_RIGHT,
8861 EL_PLAYER_4, ACTION_SNAPPING, MV_BIT_DOWN,
8865 EL_PLAYER_4, ACTION_SNAPPING, MV_BIT_LEFT,
8869 EL_PLAYER_3, ACTION_DEFAULT, -1,
8873 EL_PLAYER_4, ACTION_DEFAULT, -1,
8882 int map_element_RND_to_EM(int element_rnd)
8884 static unsigned short mapping_RND_to_EM[NUM_FILE_ELEMENTS];
8885 static boolean mapping_initialized = FALSE;
8887 if (!mapping_initialized)
8891 /* return "Xalpha_quest" for all undefined elements in mapping array */
8892 for (i = 0; i < NUM_FILE_ELEMENTS; i++)
8893 mapping_RND_to_EM[i] = Xalpha_quest;
8895 for (i = 0; em_object_mapping_list[i].element_em != -1; i++)
8896 if (em_object_mapping_list[i].is_rnd_to_em_mapping)
8897 mapping_RND_to_EM[em_object_mapping_list[i].element_rnd] =
8898 em_object_mapping_list[i].element_em;
8900 mapping_initialized = TRUE;
8903 if (element_rnd >= 0 && element_rnd < NUM_FILE_ELEMENTS)
8904 return mapping_RND_to_EM[element_rnd];
8906 Error(ERR_WARN, "invalid RND level element %d", element_rnd);
8911 int map_element_EM_to_RND(int element_em)
8913 static unsigned short mapping_EM_to_RND[TILE_MAX];
8914 static boolean mapping_initialized = FALSE;
8916 if (!mapping_initialized)
8920 /* return "EL_UNKNOWN" for all undefined elements in mapping array */
8921 for (i = 0; i < TILE_MAX; i++)
8922 mapping_EM_to_RND[i] = EL_UNKNOWN;
8924 for (i = 0; em_object_mapping_list[i].element_em != -1; i++)
8925 mapping_EM_to_RND[em_object_mapping_list[i].element_em] =
8926 em_object_mapping_list[i].element_rnd;
8928 mapping_initialized = TRUE;
8931 if (element_em >= 0 && element_em < TILE_MAX)
8932 return mapping_EM_to_RND[element_em];
8934 Error(ERR_WARN, "invalid EM level element %d", element_em);
8939 void map_android_clone_elements_RND_to_EM(struct LevelInfo *level)
8941 struct LevelInfo_EM *level_em = level->native_em_level;
8942 struct LEVEL *lev = level_em->lev;
8945 for (i = 0; i < TILE_MAX; i++)
8946 lev->android_array[i] = Xblank;
8948 for (i = 0; i < level->num_android_clone_elements; i++)
8950 int element_rnd = level->android_clone_element[i];
8951 int element_em = map_element_RND_to_EM(element_rnd);
8953 for (j = 0; em_object_mapping_list[j].element_em != -1; j++)
8954 if (em_object_mapping_list[j].element_rnd == element_rnd)
8955 lev->android_array[em_object_mapping_list[j].element_em] = element_em;
8959 void map_android_clone_elements_EM_to_RND(struct LevelInfo *level)
8961 struct LevelInfo_EM *level_em = level->native_em_level;
8962 struct LEVEL *lev = level_em->lev;
8965 level->num_android_clone_elements = 0;
8967 for (i = 0; i < TILE_MAX; i++)
8969 int element_em = lev->android_array[i];
8971 boolean element_found = FALSE;
8973 if (element_em == Xblank)
8976 element_rnd = map_element_EM_to_RND(element_em);
8978 for (j = 0; j < level->num_android_clone_elements; j++)
8979 if (level->android_clone_element[j] == element_rnd)
8980 element_found = TRUE;
8984 level->android_clone_element[level->num_android_clone_elements++] =
8987 if (level->num_android_clone_elements == MAX_ANDROID_ELEMENTS)
8992 if (level->num_android_clone_elements == 0)
8994 level->num_android_clone_elements = 1;
8995 level->android_clone_element[0] = EL_EMPTY;
8999 int map_direction_RND_to_EM(int direction)
9001 return (direction == MV_UP ? 0 :
9002 direction == MV_RIGHT ? 1 :
9003 direction == MV_DOWN ? 2 :
9004 direction == MV_LEFT ? 3 :
9008 int map_direction_EM_to_RND(int direction)
9010 return (direction == 0 ? MV_UP :
9011 direction == 1 ? MV_RIGHT :
9012 direction == 2 ? MV_DOWN :
9013 direction == 3 ? MV_LEFT :
9017 int map_element_RND_to_SP(int element_rnd)
9019 int element_sp = 0x20; /* map unknown elements to yellow "hardware" */
9021 if (element_rnd >= EL_SP_START &&
9022 element_rnd <= EL_SP_END)
9023 element_sp = element_rnd - EL_SP_START;
9024 else if (element_rnd == EL_EMPTY_SPACE)
9026 else if (element_rnd == EL_INVISIBLE_WALL)
9032 int map_element_SP_to_RND(int element_sp)
9034 int element_rnd = EL_UNKNOWN;
9036 if (element_sp >= 0x00 &&
9038 element_rnd = EL_SP_START + element_sp;
9039 else if (element_sp == 0x28)
9040 element_rnd = EL_INVISIBLE_WALL;
9045 int map_action_SP_to_RND(int action_sp)
9049 case actActive: return ACTION_ACTIVE;
9050 case actImpact: return ACTION_IMPACT;
9051 case actExploding: return ACTION_EXPLODING;
9052 case actDigging: return ACTION_DIGGING;
9053 case actSnapping: return ACTION_SNAPPING;
9054 case actCollecting: return ACTION_COLLECTING;
9055 case actPassing: return ACTION_PASSING;
9056 case actPushing: return ACTION_PUSHING;
9057 case actDropping: return ACTION_DROPPING;
9059 default: return ACTION_DEFAULT;
9063 int get_next_element(int element)
9067 case EL_QUICKSAND_FILLING: return EL_QUICKSAND_FULL;
9068 case EL_QUICKSAND_EMPTYING: return EL_QUICKSAND_EMPTY;
9069 case EL_QUICKSAND_FAST_FILLING: return EL_QUICKSAND_FAST_FULL;
9070 case EL_QUICKSAND_FAST_EMPTYING: return EL_QUICKSAND_FAST_EMPTY;
9071 case EL_MAGIC_WALL_FILLING: return EL_MAGIC_WALL_FULL;
9072 case EL_MAGIC_WALL_EMPTYING: return EL_MAGIC_WALL_ACTIVE;
9073 case EL_BD_MAGIC_WALL_FILLING: return EL_BD_MAGIC_WALL_FULL;
9074 case EL_BD_MAGIC_WALL_EMPTYING: return EL_BD_MAGIC_WALL_ACTIVE;
9075 case EL_DC_MAGIC_WALL_FILLING: return EL_DC_MAGIC_WALL_FULL;
9076 case EL_DC_MAGIC_WALL_EMPTYING: return EL_DC_MAGIC_WALL_ACTIVE;
9077 case EL_AMOEBA_DROPPING: return EL_AMOEBA_WET;
9079 default: return element;
9084 int el_act_dir2img(int element, int action, int direction)
9086 element = GFX_ELEMENT(element);
9088 if (direction == MV_NONE)
9089 return element_info[element].graphic[action];
9091 direction = MV_DIR_TO_BIT(direction);
9093 return element_info[element].direction_graphic[action][direction];
9096 int el_act_dir2img(int element, int action, int direction)
9098 element = GFX_ELEMENT(element);
9099 direction = MV_DIR_TO_BIT(direction); /* default: MV_NONE => MV_DOWN */
9101 /* direction_graphic[][] == graphic[] for undefined direction graphics */
9102 return element_info[element].direction_graphic[action][direction];
9107 static int el_act_dir2crm(int element, int action, int direction)
9109 element = GFX_ELEMENT(element);
9111 if (direction == MV_NONE)
9112 return element_info[element].crumbled[action];
9114 direction = MV_DIR_TO_BIT(direction);
9116 return element_info[element].direction_crumbled[action][direction];
9119 static int el_act_dir2crm(int element, int action, int direction)
9121 element = GFX_ELEMENT(element);
9122 direction = MV_DIR_TO_BIT(direction); /* default: MV_NONE => MV_DOWN */
9124 /* direction_graphic[][] == graphic[] for undefined direction graphics */
9125 return element_info[element].direction_crumbled[action][direction];
9129 int el_act2img(int element, int action)
9131 element = GFX_ELEMENT(element);
9133 return element_info[element].graphic[action];
9136 int el_act2crm(int element, int action)
9138 element = GFX_ELEMENT(element);
9140 return element_info[element].crumbled[action];
9143 int el_dir2img(int element, int direction)
9145 element = GFX_ELEMENT(element);
9147 return el_act_dir2img(element, ACTION_DEFAULT, direction);
9150 int el2baseimg(int element)
9152 return element_info[element].graphic[ACTION_DEFAULT];
9155 int el2img(int element)
9157 element = GFX_ELEMENT(element);
9159 return element_info[element].graphic[ACTION_DEFAULT];
9162 int el2edimg(int element)
9164 element = GFX_ELEMENT(element);
9166 return element_info[element].special_graphic[GFX_SPECIAL_ARG_EDITOR];
9169 int el2preimg(int element)
9171 element = GFX_ELEMENT(element);
9173 return element_info[element].special_graphic[GFX_SPECIAL_ARG_PREVIEW];
9176 int el2panelimg(int element)
9178 element = GFX_ELEMENT(element);
9180 return element_info[element].special_graphic[GFX_SPECIAL_ARG_PANEL];
9183 int font2baseimg(int font_nr)
9185 return font_info[font_nr].special_graphic[GFX_SPECIAL_ARG_DEFAULT];
9188 int getBeltNrFromBeltElement(int element)
9190 return (element < EL_CONVEYOR_BELT_2_LEFT ? 0 :
9191 element < EL_CONVEYOR_BELT_3_LEFT ? 1 :
9192 element < EL_CONVEYOR_BELT_4_LEFT ? 2 : 3);
9195 int getBeltNrFromBeltActiveElement(int element)
9197 return (element < EL_CONVEYOR_BELT_2_LEFT_ACTIVE ? 0 :
9198 element < EL_CONVEYOR_BELT_3_LEFT_ACTIVE ? 1 :
9199 element < EL_CONVEYOR_BELT_4_LEFT_ACTIVE ? 2 : 3);
9202 int getBeltNrFromBeltSwitchElement(int element)
9204 return (element < EL_CONVEYOR_BELT_2_SWITCH_LEFT ? 0 :
9205 element < EL_CONVEYOR_BELT_3_SWITCH_LEFT ? 1 :
9206 element < EL_CONVEYOR_BELT_4_SWITCH_LEFT ? 2 : 3);
9209 int getBeltDirNrFromBeltElement(int element)
9211 static int belt_base_element[4] =
9213 EL_CONVEYOR_BELT_1_LEFT,
9214 EL_CONVEYOR_BELT_2_LEFT,
9215 EL_CONVEYOR_BELT_3_LEFT,
9216 EL_CONVEYOR_BELT_4_LEFT
9219 int belt_nr = getBeltNrFromBeltElement(element);
9220 int belt_dir_nr = element - belt_base_element[belt_nr];
9222 return (belt_dir_nr % 3);
9225 int getBeltDirNrFromBeltSwitchElement(int element)
9227 static int belt_base_element[4] =
9229 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
9230 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
9231 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
9232 EL_CONVEYOR_BELT_4_SWITCH_LEFT
9235 int belt_nr = getBeltNrFromBeltSwitchElement(element);
9236 int belt_dir_nr = element - belt_base_element[belt_nr];
9238 return (belt_dir_nr % 3);
9241 int getBeltDirFromBeltElement(int element)
9243 static int belt_move_dir[3] =
9250 int belt_dir_nr = getBeltDirNrFromBeltElement(element);
9252 return belt_move_dir[belt_dir_nr];
9255 int getBeltDirFromBeltSwitchElement(int element)
9257 static int belt_move_dir[3] =
9264 int belt_dir_nr = getBeltDirNrFromBeltSwitchElement(element);
9266 return belt_move_dir[belt_dir_nr];
9269 int getBeltElementFromBeltNrAndBeltDirNr(int belt_nr, int belt_dir_nr)
9271 static int belt_base_element[4] =
9273 EL_CONVEYOR_BELT_1_LEFT,
9274 EL_CONVEYOR_BELT_2_LEFT,
9275 EL_CONVEYOR_BELT_3_LEFT,
9276 EL_CONVEYOR_BELT_4_LEFT
9279 return belt_base_element[belt_nr] + belt_dir_nr;
9282 int getBeltElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir)
9284 int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1);
9286 return getBeltElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr);
9289 int getBeltSwitchElementFromBeltNrAndBeltDirNr(int belt_nr, int belt_dir_nr)
9291 static int belt_base_element[4] =
9293 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
9294 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
9295 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
9296 EL_CONVEYOR_BELT_4_SWITCH_LEFT
9299 return belt_base_element[belt_nr] + belt_dir_nr;
9302 int getBeltSwitchElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir)
9304 int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1);
9306 return getBeltSwitchElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr);
9310 boolean getTeamMode_EM()
9312 return game.team_mode;
9315 int getNumActivePlayers_EM()
9318 int num_players = 0;
9322 return (setup.team_mode ? MAX_PLAYERS : 1);
9324 for (i = 0; i < MAX_PLAYERS; i++)
9325 if (tape.player_participates[i])
9328 return (num_players > 1 ? MAX_PLAYERS : 1);
9332 int num_players = 0;
9335 /* when recording game, activate all connected players */
9339 for (i = 0; i < MAX_PLAYERS; i++)
9340 if (tape.player_participates[i])
9348 int getGameFrameDelay_EM(int native_em_game_frame_delay)
9350 int game_frame_delay_value;
9352 game_frame_delay_value =
9353 (tape.playing && tape.fast_forward ? FfwdFrameDelay :
9354 GameFrameDelay == GAME_FRAME_DELAY ? native_em_game_frame_delay :
9357 if (tape.playing && tape.warp_forward && !tape.pausing)
9358 game_frame_delay_value = 0;
9360 return game_frame_delay_value;
9363 unsigned int InitRND(int seed)
9365 if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
9366 return InitEngineRandom_EM(seed);
9367 else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
9368 return InitEngineRandom_SP(seed);
9370 return InitEngineRandom_RND(seed);
9374 static struct Mapping_EM_to_RND_object object_mapping[TILE_MAX];
9375 static struct Mapping_EM_to_RND_player player_mapping[MAX_PLAYERS][SPR_MAX];
9378 inline static int get_effective_element_EM(int tile, int frame_em)
9380 int element = object_mapping[tile].element_rnd;
9381 int action = object_mapping[tile].action;
9382 boolean is_backside = object_mapping[tile].is_backside;
9383 boolean action_removing = (action == ACTION_DIGGING ||
9384 action == ACTION_SNAPPING ||
9385 action == ACTION_COLLECTING);
9391 case Yacid_splash_eB:
9392 case Yacid_splash_wB:
9393 return (frame_em > 5 ? EL_EMPTY : element);
9397 case Ydiamond_stone:
9398 // if (!game.use_native_emc_graphics_engine)
9406 else /* frame_em == 7 */
9410 case Yacid_splash_eB:
9411 case Yacid_splash_wB:
9414 case Yemerald_stone:
9417 case Ydiamond_stone:
9421 case Xdrip_stretchB:
9440 case Xsand_stonein_1:
9441 case Xsand_stonein_2:
9442 case Xsand_stonein_3:
9443 case Xsand_stonein_4:
9447 return (is_backside || action_removing ? EL_EMPTY : element);
9452 inline static boolean check_linear_animation_EM(int tile)
9456 case Xsand_stonesand_1:
9457 case Xsand_stonesand_quickout_1:
9458 case Xsand_sandstone_1:
9459 case Xsand_stonein_1:
9460 case Xsand_stoneout_1:
9480 case Yacid_splash_eB:
9481 case Yacid_splash_wB:
9482 case Yemerald_stone:
9490 inline static void set_crumbled_graphics_EM(struct GraphicInfo_EM *g_em,
9491 boolean has_crumbled_graphics,
9492 int crumbled, int sync_frame)
9494 /* if element can be crumbled, but certain action graphics are just empty
9495 space (like instantly snapping sand to empty space in 1 frame), do not
9496 treat these empty space graphics as crumbled graphics in EMC engine */
9497 if (crumbled == IMG_EMPTY_SPACE)
9498 has_crumbled_graphics = FALSE;
9500 if (has_crumbled_graphics)
9502 struct GraphicInfo *g_crumbled = &graphic_info[crumbled];
9503 int frame_crumbled = getAnimationFrame(g_crumbled->anim_frames,
9504 g_crumbled->anim_delay,
9505 g_crumbled->anim_mode,
9506 g_crumbled->anim_start_frame,
9509 getGraphicSource(crumbled, frame_crumbled, &g_em->crumbled_bitmap,
9510 &g_em->crumbled_src_x, &g_em->crumbled_src_y);
9512 g_em->crumbled_border_size = graphic_info[crumbled].border_size;
9514 g_em->has_crumbled_graphics = TRUE;
9518 g_em->crumbled_bitmap = NULL;
9519 g_em->crumbled_src_x = 0;
9520 g_em->crumbled_src_y = 0;
9521 g_em->crumbled_border_size = 0;
9523 g_em->has_crumbled_graphics = FALSE;
9527 void ResetGfxAnimation_EM(int x, int y, int tile)
9532 void SetGfxAnimation_EM(struct GraphicInfo_EM *g_em,
9533 int tile, int frame_em, int x, int y)
9535 int action = object_mapping[tile].action;
9537 int direction = object_mapping[tile].direction;
9538 int effective_element = get_effective_element_EM(tile, frame_em);
9539 int graphic = (direction == MV_NONE ?
9540 el_act2img(effective_element, action) :
9541 el_act_dir2img(effective_element, action, direction));
9542 struct GraphicInfo *g = &graphic_info[graphic];
9545 boolean action_removing = (action == ACTION_DIGGING ||
9546 action == ACTION_SNAPPING ||
9547 action == ACTION_COLLECTING);
9548 boolean action_moving = (action == ACTION_FALLING ||
9549 action == ACTION_MOVING ||
9550 action == ACTION_PUSHING ||
9551 action == ACTION_EATING ||
9552 action == ACTION_FILLING ||
9553 action == ACTION_EMPTYING);
9554 boolean action_falling = (action == ACTION_FALLING ||
9555 action == ACTION_FILLING ||
9556 action == ACTION_EMPTYING);
9558 /* special case: graphic uses "2nd movement tile" and has defined
9559 7 frames for movement animation (or less) => use default graphic
9560 for last (8th) frame which ends the movement animation */
9561 if (g->double_movement && g->anim_frames < 8 && frame_em == 7)
9563 action = ACTION_DEFAULT; /* (keep action_* unchanged for now) */
9564 graphic = (direction == MV_NONE ?
9565 el_act2img(effective_element, action) :
9566 el_act_dir2img(effective_element, action, direction));
9568 g = &graphic_info[graphic];
9572 if (tile == Xsand_stonesand_1 ||
9573 tile == Xsand_stonesand_2 ||
9574 tile == Xsand_stonesand_3 ||
9575 tile == Xsand_stonesand_4)
9576 printf("::: 1: quicksand frame %d [%d]\n", GfxFrame[x][y], tile);
9580 if ((action_removing || check_linear_animation_EM(tile)) && frame_em == 0)
9584 // printf("::: resetting... [%d]\n", tile);
9587 if (action_removing || check_linear_animation_EM(tile))
9589 GfxFrame[x][y] = frame_em;
9591 // printf("::: resetting... [%d]\n", tile);
9594 else if (action_moving)
9596 boolean is_backside = object_mapping[tile].is_backside;
9600 int direction = object_mapping[tile].direction;
9601 int move_dir = (action_falling ? MV_DOWN : direction);
9606 /* !!! TEST !!! NEW !!! DOES NOT WORK RIGHT YET !!! */
9607 if (g->double_movement && frame_em == 0)
9611 // printf("::: resetting... [%d]\n", tile);
9615 if (move_dir == MV_LEFT)
9616 GfxFrame[x - 1][y] = GfxFrame[x][y];
9617 else if (move_dir == MV_RIGHT)
9618 GfxFrame[x + 1][y] = GfxFrame[x][y];
9619 else if (move_dir == MV_UP)
9620 GfxFrame[x][y - 1] = GfxFrame[x][y];
9621 else if (move_dir == MV_DOWN)
9622 GfxFrame[x][y + 1] = GfxFrame[x][y];
9629 /* special case: animation for Xsand_stonesand_quickout_1/2 twice as fast */
9630 if (tile == Xsand_stonesand_quickout_1 ||
9631 tile == Xsand_stonesand_quickout_2)
9636 if (tile == Xsand_stonesand_1 ||
9637 tile == Xsand_stonesand_2 ||
9638 tile == Xsand_stonesand_3 ||
9639 tile == Xsand_stonesand_4)
9640 printf("::: 2: quicksand frame %d [%d]\n", GfxFrame[x][y], tile);
9644 if (graphic_info[graphic].anim_global_sync)
9645 sync_frame = FrameCounter;
9646 else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY))
9647 sync_frame = GfxFrame[x][y];
9649 sync_frame = 0; /* playfield border (pseudo steel) */
9651 SetRandomAnimationValue(x, y);
9653 int frame = getAnimationFrame(g->anim_frames,
9656 g->anim_start_frame,
9659 g_em->unique_identifier =
9660 (graphic << 16) | ((frame % 8) << 12) | (g_em->width << 6) | g_em->height;
9664 void getGraphicSourceObjectExt_EM(struct GraphicInfo_EM *g_em,
9665 int tile, int frame_em, int x, int y)
9667 int action = object_mapping[tile].action;
9668 int direction = object_mapping[tile].direction;
9669 boolean is_backside = object_mapping[tile].is_backside;
9670 int effective_element = get_effective_element_EM(tile, frame_em);
9672 int effective_action = action;
9674 int effective_action = (frame_em < 7 ? action : ACTION_DEFAULT);
9676 int graphic = (direction == MV_NONE ?
9677 el_act2img(effective_element, effective_action) :
9678 el_act_dir2img(effective_element, effective_action,
9680 int crumbled = (direction == MV_NONE ?
9681 el_act2crm(effective_element, effective_action) :
9682 el_act_dir2crm(effective_element, effective_action,
9684 int base_graphic = el_act2img(effective_element, ACTION_DEFAULT);
9685 int base_crumbled = el_act2crm(effective_element, ACTION_DEFAULT);
9686 boolean has_crumbled_graphics = (base_crumbled != base_graphic);
9687 struct GraphicInfo *g = &graphic_info[graphic];
9689 struct GraphicInfo *g_crumbled = &graphic_info[crumbled];
9693 /* special case: graphic uses "2nd movement tile" and has defined
9694 7 frames for movement animation (or less) => use default graphic
9695 for last (8th) frame which ends the movement animation */
9696 if (g->double_movement && g->anim_frames < 8 && frame_em == 7)
9698 effective_action = ACTION_DEFAULT;
9699 graphic = (direction == MV_NONE ?
9700 el_act2img(effective_element, effective_action) :
9701 el_act_dir2img(effective_element, effective_action,
9703 crumbled = (direction == MV_NONE ?
9704 el_act2crm(effective_element, effective_action) :
9705 el_act_dir2crm(effective_element, effective_action,
9708 g = &graphic_info[graphic];
9718 if (frame_em == 0) /* reset animation frame for certain elements */
9720 if (check_linear_animation_EM(tile))
9725 if (graphic_info[graphic].anim_global_sync)
9726 sync_frame = FrameCounter;
9727 else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY))
9728 sync_frame = GfxFrame[x][y];
9730 sync_frame = 0; /* playfield border (pseudo steel) */
9732 SetRandomAnimationValue(x, y);
9737 int xxx_sync_frame = (i == Xdrip_stretch ? 7 :
9738 i == Xdrip_stretchB ? 7 :
9739 i == Ydrip_s2 ? j + 8 :
9740 i == Ydrip_s2B ? j + 8 :
9749 i == Xfake_acid_1 ? 0 :
9750 i == Xfake_acid_2 ? 10 :
9751 i == Xfake_acid_3 ? 20 :
9752 i == Xfake_acid_4 ? 30 :
9753 i == Xfake_acid_5 ? 40 :
9754 i == Xfake_acid_6 ? 50 :
9755 i == Xfake_acid_7 ? 60 :
9756 i == Xfake_acid_8 ? 70 :
9758 i == Xball_2B ? j + 8 :
9759 i == Yball_eat ? j + 1 :
9760 i == Ykey_1_eat ? j + 1 :
9761 i == Ykey_2_eat ? j + 1 :
9762 i == Ykey_3_eat ? j + 1 :
9763 i == Ykey_4_eat ? j + 1 :
9764 i == Ykey_5_eat ? j + 1 :
9765 i == Ykey_6_eat ? j + 1 :
9766 i == Ykey_7_eat ? j + 1 :
9767 i == Ykey_8_eat ? j + 1 :
9768 i == Ylenses_eat ? j + 1 :
9769 i == Ymagnify_eat ? j + 1 :
9770 i == Ygrass_eat ? j + 1 :
9771 i == Ydirt_eat ? j + 1 :
9772 i == Xamoeba_1 ? 0 :
9773 i == Xamoeba_2 ? 1 :
9774 i == Xamoeba_3 ? 2 :
9775 i == Xamoeba_4 ? 3 :
9776 i == Xamoeba_5 ? 0 :
9777 i == Xamoeba_6 ? 1 :
9778 i == Xamoeba_7 ? 2 :
9779 i == Xamoeba_8 ? 3 :
9780 i == Xexit_2 ? j + 8 :
9781 i == Xexit_3 ? j + 16 :
9782 i == Xdynamite_1 ? 0 :
9783 i == Xdynamite_2 ? 8 :
9784 i == Xdynamite_3 ? 16 :
9785 i == Xdynamite_4 ? 24 :
9786 i == Xsand_stonein_1 ? j + 1 :
9787 i == Xsand_stonein_2 ? j + 9 :
9788 i == Xsand_stonein_3 ? j + 17 :
9789 i == Xsand_stonein_4 ? j + 25 :
9790 i == Xsand_stoneout_1 && j == 0 ? 0 :
9791 i == Xsand_stoneout_1 && j == 1 ? 0 :
9792 i == Xsand_stoneout_1 && j == 2 ? 1 :
9793 i == Xsand_stoneout_1 && j == 3 ? 2 :
9794 i == Xsand_stoneout_1 && j == 4 ? 2 :
9795 i == Xsand_stoneout_1 && j == 5 ? 3 :
9796 i == Xsand_stoneout_1 && j == 6 ? 4 :
9797 i == Xsand_stoneout_1 && j == 7 ? 4 :
9798 i == Xsand_stoneout_2 && j == 0 ? 5 :
9799 i == Xsand_stoneout_2 && j == 1 ? 6 :
9800 i == Xsand_stoneout_2 && j == 2 ? 7 :
9801 i == Xsand_stoneout_2 && j == 3 ? 8 :
9802 i == Xsand_stoneout_2 && j == 4 ? 9 :
9803 i == Xsand_stoneout_2 && j == 5 ? 11 :
9804 i == Xsand_stoneout_2 && j == 6 ? 13 :
9805 i == Xsand_stoneout_2 && j == 7 ? 15 :
9806 i == Xboom_bug && j == 1 ? 2 :
9807 i == Xboom_bug && j == 2 ? 2 :
9808 i == Xboom_bug && j == 3 ? 4 :
9809 i == Xboom_bug && j == 4 ? 4 :
9810 i == Xboom_bug && j == 5 ? 2 :
9811 i == Xboom_bug && j == 6 ? 2 :
9812 i == Xboom_bug && j == 7 ? 0 :
9813 i == Xboom_bomb && j == 1 ? 2 :
9814 i == Xboom_bomb && j == 2 ? 2 :
9815 i == Xboom_bomb && j == 3 ? 4 :
9816 i == Xboom_bomb && j == 4 ? 4 :
9817 i == Xboom_bomb && j == 5 ? 2 :
9818 i == Xboom_bomb && j == 6 ? 2 :
9819 i == Xboom_bomb && j == 7 ? 0 :
9820 i == Xboom_android && j == 7 ? 6 :
9821 i == Xboom_1 && j == 1 ? 2 :
9822 i == Xboom_1 && j == 2 ? 2 :
9823 i == Xboom_1 && j == 3 ? 4 :
9824 i == Xboom_1 && j == 4 ? 4 :
9825 i == Xboom_1 && j == 5 ? 6 :
9826 i == Xboom_1 && j == 6 ? 6 :
9827 i == Xboom_1 && j == 7 ? 8 :
9828 i == Xboom_2 && j == 0 ? 8 :
9829 i == Xboom_2 && j == 1 ? 8 :
9830 i == Xboom_2 && j == 2 ? 10 :
9831 i == Xboom_2 && j == 3 ? 10 :
9832 i == Xboom_2 && j == 4 ? 10 :
9833 i == Xboom_2 && j == 5 ? 12 :
9834 i == Xboom_2 && j == 6 ? 12 :
9835 i == Xboom_2 && j == 7 ? 12 :
9837 special_animation && j == 4 ? 3 :
9838 effective_action != action ? 0 :
9844 int xxx_effective_action;
9845 int xxx_has_action_graphics;
9848 int element = object_mapping[i].element_rnd;
9849 int action = object_mapping[i].action;
9850 int direction = object_mapping[i].direction;
9851 boolean is_backside = object_mapping[i].is_backside;
9853 boolean action_removing = (action == ACTION_DIGGING ||
9854 action == ACTION_SNAPPING ||
9855 action == ACTION_COLLECTING);
9857 boolean action_exploding = ((action == ACTION_EXPLODING ||
9858 action == ACTION_SMASHED_BY_ROCK ||
9859 action == ACTION_SMASHED_BY_SPRING) &&
9860 element != EL_DIAMOND);
9861 boolean action_active = (action == ACTION_ACTIVE);
9862 boolean action_other = (action == ACTION_OTHER);
9866 int effective_element = get_effective_element_EM(i, j);
9868 int effective_element = (j > 5 && i == Yacid_splash_eB ? EL_EMPTY :
9869 j > 5 && i == Yacid_splash_wB ? EL_EMPTY :
9871 i == Xdrip_stretch ? element :
9872 i == Xdrip_stretchB ? element :
9873 i == Ydrip_s1 ? element :
9874 i == Ydrip_s1B ? element :
9875 i == Xball_1B ? element :
9876 i == Xball_2 ? element :
9877 i == Xball_2B ? element :
9878 i == Yball_eat ? element :
9879 i == Ykey_1_eat ? element :
9880 i == Ykey_2_eat ? element :
9881 i == Ykey_3_eat ? element :
9882 i == Ykey_4_eat ? element :
9883 i == Ykey_5_eat ? element :
9884 i == Ykey_6_eat ? element :
9885 i == Ykey_7_eat ? element :
9886 i == Ykey_8_eat ? element :
9887 i == Ylenses_eat ? element :
9888 i == Ymagnify_eat ? element :
9889 i == Ygrass_eat ? element :
9890 i == Ydirt_eat ? element :
9891 i == Yemerald_stone ? EL_EMERALD :
9892 i == Ydiamond_stone ? EL_ROCK :
9893 i == Xsand_stonein_1 ? element :
9894 i == Xsand_stonein_2 ? element :
9895 i == Xsand_stonein_3 ? element :
9896 i == Xsand_stonein_4 ? element :
9897 is_backside ? EL_EMPTY :
9898 action_removing ? EL_EMPTY :
9901 int effective_action = (j < 7 ? action :
9902 i == Xdrip_stretch ? action :
9903 i == Xdrip_stretchB ? action :
9904 i == Ydrip_s1 ? action :
9905 i == Ydrip_s1B ? action :
9906 i == Xball_1B ? action :
9907 i == Xball_2 ? action :
9908 i == Xball_2B ? action :
9909 i == Yball_eat ? action :
9910 i == Ykey_1_eat ? action :
9911 i == Ykey_2_eat ? action :
9912 i == Ykey_3_eat ? action :
9913 i == Ykey_4_eat ? action :
9914 i == Ykey_5_eat ? action :
9915 i == Ykey_6_eat ? action :
9916 i == Ykey_7_eat ? action :
9917 i == Ykey_8_eat ? action :
9918 i == Ylenses_eat ? action :
9919 i == Ymagnify_eat ? action :
9920 i == Ygrass_eat ? action :
9921 i == Ydirt_eat ? action :
9922 i == Xsand_stonein_1 ? action :
9923 i == Xsand_stonein_2 ? action :
9924 i == Xsand_stonein_3 ? action :
9925 i == Xsand_stonein_4 ? action :
9926 i == Xsand_stoneout_1 ? action :
9927 i == Xsand_stoneout_2 ? action :
9928 i == Xboom_android ? ACTION_EXPLODING :
9929 action_exploding ? ACTION_EXPLODING :
9930 action_active ? action :
9931 action_other ? action :
9933 int graphic = (el_act_dir2img(effective_element, effective_action,
9935 int crumbled = (el_act_dir2crm(effective_element, effective_action,
9937 int base_graphic = el_act2img(effective_element, ACTION_DEFAULT);
9938 int base_crumbled = el_act2crm(effective_element, ACTION_DEFAULT);
9939 boolean has_action_graphics = (graphic != base_graphic);
9940 boolean has_crumbled_graphics = (base_crumbled != base_graphic);
9941 struct GraphicInfo *g = &graphic_info[graphic];
9943 struct GraphicInfo *g_crumbled = &graphic_info[crumbled];
9945 struct GraphicInfo_EM *g_em = &graphic_info_em_object[i][7 - j];
9948 /* ensure to get symmetric 3-frame, 2-delay animations as used in EM */
9949 boolean special_animation = (action != ACTION_DEFAULT &&
9950 g->anim_frames == 3 &&
9951 g->anim_delay == 2 &&
9952 g->anim_mode & ANIM_LINEAR);
9953 xxx_sync_frame = (i == Xdrip_stretch ? 7 :
9954 i == Xdrip_stretchB ? 7 :
9955 i == Ydrip_s2 ? j + 8 :
9956 i == Ydrip_s2B ? j + 8 :
9965 i == Xfake_acid_1 ? 0 :
9966 i == Xfake_acid_2 ? 10 :
9967 i == Xfake_acid_3 ? 20 :
9968 i == Xfake_acid_4 ? 30 :
9969 i == Xfake_acid_5 ? 40 :
9970 i == Xfake_acid_6 ? 50 :
9971 i == Xfake_acid_7 ? 60 :
9972 i == Xfake_acid_8 ? 70 :
9974 i == Xball_2B ? j + 8 :
9975 i == Yball_eat ? j + 1 :
9976 i == Ykey_1_eat ? j + 1 :
9977 i == Ykey_2_eat ? j + 1 :
9978 i == Ykey_3_eat ? j + 1 :
9979 i == Ykey_4_eat ? j + 1 :
9980 i == Ykey_5_eat ? j + 1 :
9981 i == Ykey_6_eat ? j + 1 :
9982 i == Ykey_7_eat ? j + 1 :
9983 i == Ykey_8_eat ? j + 1 :
9984 i == Ylenses_eat ? j + 1 :
9985 i == Ymagnify_eat ? j + 1 :
9986 i == Ygrass_eat ? j + 1 :
9987 i == Ydirt_eat ? j + 1 :
9988 i == Xamoeba_1 ? 0 :
9989 i == Xamoeba_2 ? 1 :
9990 i == Xamoeba_3 ? 2 :
9991 i == Xamoeba_4 ? 3 :
9992 i == Xamoeba_5 ? 0 :
9993 i == Xamoeba_6 ? 1 :
9994 i == Xamoeba_7 ? 2 :
9995 i == Xamoeba_8 ? 3 :
9996 i == Xexit_2 ? j + 8 :
9997 i == Xexit_3 ? j + 16 :
9998 i == Xdynamite_1 ? 0 :
9999 i == Xdynamite_2 ? 8 :
10000 i == Xdynamite_3 ? 16 :
10001 i == Xdynamite_4 ? 24 :
10002 i == Xsand_stonein_1 ? j + 1 :
10003 i == Xsand_stonein_2 ? j + 9 :
10004 i == Xsand_stonein_3 ? j + 17 :
10005 i == Xsand_stonein_4 ? j + 25 :
10006 i == Xsand_stoneout_1 && j == 0 ? 0 :
10007 i == Xsand_stoneout_1 && j == 1 ? 0 :
10008 i == Xsand_stoneout_1 && j == 2 ? 1 :
10009 i == Xsand_stoneout_1 && j == 3 ? 2 :
10010 i == Xsand_stoneout_1 && j == 4 ? 2 :
10011 i == Xsand_stoneout_1 && j == 5 ? 3 :
10012 i == Xsand_stoneout_1 && j == 6 ? 4 :
10013 i == Xsand_stoneout_1 && j == 7 ? 4 :
10014 i == Xsand_stoneout_2 && j == 0 ? 5 :
10015 i == Xsand_stoneout_2 && j == 1 ? 6 :
10016 i == Xsand_stoneout_2 && j == 2 ? 7 :
10017 i == Xsand_stoneout_2 && j == 3 ? 8 :
10018 i == Xsand_stoneout_2 && j == 4 ? 9 :
10019 i == Xsand_stoneout_2 && j == 5 ? 11 :
10020 i == Xsand_stoneout_2 && j == 6 ? 13 :
10021 i == Xsand_stoneout_2 && j == 7 ? 15 :
10022 i == Xboom_bug && j == 1 ? 2 :
10023 i == Xboom_bug && j == 2 ? 2 :
10024 i == Xboom_bug && j == 3 ? 4 :
10025 i == Xboom_bug && j == 4 ? 4 :
10026 i == Xboom_bug && j == 5 ? 2 :
10027 i == Xboom_bug && j == 6 ? 2 :
10028 i == Xboom_bug && j == 7 ? 0 :
10029 i == Xboom_bomb && j == 1 ? 2 :
10030 i == Xboom_bomb && j == 2 ? 2 :
10031 i == Xboom_bomb && j == 3 ? 4 :
10032 i == Xboom_bomb && j == 4 ? 4 :
10033 i == Xboom_bomb && j == 5 ? 2 :
10034 i == Xboom_bomb && j == 6 ? 2 :
10035 i == Xboom_bomb && j == 7 ? 0 :
10036 i == Xboom_android && j == 7 ? 6 :
10037 i == Xboom_1 && j == 1 ? 2 :
10038 i == Xboom_1 && j == 2 ? 2 :
10039 i == Xboom_1 && j == 3 ? 4 :
10040 i == Xboom_1 && j == 4 ? 4 :
10041 i == Xboom_1 && j == 5 ? 6 :
10042 i == Xboom_1 && j == 6 ? 6 :
10043 i == Xboom_1 && j == 7 ? 8 :
10044 i == Xboom_2 && j == 0 ? 8 :
10045 i == Xboom_2 && j == 1 ? 8 :
10046 i == Xboom_2 && j == 2 ? 10 :
10047 i == Xboom_2 && j == 3 ? 10 :
10048 i == Xboom_2 && j == 4 ? 10 :
10049 i == Xboom_2 && j == 5 ? 12 :
10050 i == Xboom_2 && j == 6 ? 12 :
10051 i == Xboom_2 && j == 7 ? 12 :
10052 special_animation && j == 4 ? 3 :
10053 effective_action != action ? 0 :
10056 xxx_effective_action = effective_action;
10057 xxx_has_action_graphics = has_action_graphics;
10062 int frame = getAnimationFrame(g->anim_frames,
10065 g->anim_start_frame,
10079 int old_src_x = g_em->src_x;
10080 int old_src_y = g_em->src_y;
10084 getGraphicSourceExt(graphic, frame, &g_em->bitmap, &g_em->src_x, &g_em->src_y,
10085 g->double_movement && is_backside);
10087 getGraphicSourceExt(graphic, frame, &g_em->bitmap,
10088 &g_em->src_x, &g_em->src_y, FALSE);
10093 if (tile == Ydiamond_stone)
10094 printf("::: stone smashing diamond... %d: %d, %d, %d, %d, %d -> %d [%d, %d, %d, %d, %d, %d] [%d]\n",
10099 g->anim_start_frame,
10102 g_em->src_x, g_em->src_y,
10103 g_em->src_offset_x, g_em->src_offset_y,
10104 g_em->dst_offset_x, g_em->dst_offset_y,
10116 if (graphic == IMG_BUG_MOVING_RIGHT)
10117 printf("::: %d, %d, %d: %d, %d [%d, %d -> %d, %d]\n", graphic, x, y,
10118 g->double_movement, is_backside,
10119 old_src_x, old_src_y, g_em->src_x, g_em->src_y);
10127 g_em->src_offset_x = 0;
10128 g_em->src_offset_y = 0;
10129 g_em->dst_offset_x = 0;
10130 g_em->dst_offset_y = 0;
10131 g_em->width = TILEX;
10132 g_em->height = TILEY;
10134 g_em->preserve_background = FALSE;
10137 /* (updating the "crumbled" graphic definitions is probably not really needed,
10138 as animations for crumbled graphics can't be longer than one EMC cycle) */
10140 set_crumbled_graphics_EM(g_em, has_crumbled_graphics, crumbled,
10145 g_em->crumbled_bitmap = NULL;
10146 g_em->crumbled_src_x = 0;
10147 g_em->crumbled_src_y = 0;
10149 g_em->has_crumbled_graphics = FALSE;
10151 if (has_crumbled_graphics && crumbled != IMG_EMPTY_SPACE)
10153 int frame_crumbled = getAnimationFrame(g_crumbled->anim_frames,
10154 g_crumbled->anim_delay,
10155 g_crumbled->anim_mode,
10156 g_crumbled->anim_start_frame,
10159 getGraphicSource(crumbled, frame_crumbled, &g_em->crumbled_bitmap,
10160 &g_em->crumbled_src_x, &g_em->crumbled_src_y);
10162 g_em->has_crumbled_graphics = TRUE;
10168 int effective_action = xxx_effective_action;
10169 int has_action_graphics = xxx_has_action_graphics;
10171 if ((!g->double_movement && (effective_action == ACTION_FALLING ||
10172 effective_action == ACTION_MOVING ||
10173 effective_action == ACTION_PUSHING ||
10174 effective_action == ACTION_EATING)) ||
10175 (!has_action_graphics && (effective_action == ACTION_FILLING ||
10176 effective_action == ACTION_EMPTYING)))
10179 (effective_action == ACTION_FALLING ||
10180 effective_action == ACTION_FILLING ||
10181 effective_action == ACTION_EMPTYING ? MV_DOWN : direction);
10182 int dx = (move_dir == MV_LEFT ? -1 : move_dir == MV_RIGHT ? 1 : 0);
10183 int dy = (move_dir == MV_UP ? -1 : move_dir == MV_DOWN ? 1 : 0);
10184 int num_steps = (i == Ydrip_s1 ? 16 :
10185 i == Ydrip_s1B ? 16 :
10186 i == Ydrip_s2 ? 16 :
10187 i == Ydrip_s2B ? 16 :
10188 i == Xsand_stonein_1 ? 32 :
10189 i == Xsand_stonein_2 ? 32 :
10190 i == Xsand_stonein_3 ? 32 :
10191 i == Xsand_stonein_4 ? 32 :
10192 i == Xsand_stoneout_1 ? 16 :
10193 i == Xsand_stoneout_2 ? 16 : 8);
10194 int cx = ABS(dx) * (TILEX / num_steps);
10195 int cy = ABS(dy) * (TILEY / num_steps);
10196 int step_frame = (i == Ydrip_s2 ? j + 8 :
10197 i == Ydrip_s2B ? j + 8 :
10198 i == Xsand_stonein_2 ? j + 8 :
10199 i == Xsand_stonein_3 ? j + 16 :
10200 i == Xsand_stonein_4 ? j + 24 :
10201 i == Xsand_stoneout_2 ? j + 8 : j) + 1;
10202 int step = (is_backside ? step_frame : num_steps - step_frame);
10204 if (is_backside) /* tile where movement starts */
10206 if (dx < 0 || dy < 0)
10208 g_em->src_offset_x = cx * step;
10209 g_em->src_offset_y = cy * step;
10213 g_em->dst_offset_x = cx * step;
10214 g_em->dst_offset_y = cy * step;
10217 else /* tile where movement ends */
10219 if (dx < 0 || dy < 0)
10221 g_em->dst_offset_x = cx * step;
10222 g_em->dst_offset_y = cy * step;
10226 g_em->src_offset_x = cx * step;
10227 g_em->src_offset_y = cy * step;
10231 g_em->width = TILEX - cx * step;
10232 g_em->height = TILEY - cy * step;
10235 /* create unique graphic identifier to decide if tile must be redrawn */
10236 /* bit 31 - 16 (16 bit): EM style graphic
10237 bit 15 - 12 ( 4 bit): EM style frame
10238 bit 11 - 6 ( 6 bit): graphic width
10239 bit 5 - 0 ( 6 bit): graphic height */
10240 g_em->unique_identifier =
10241 (graphic << 16) | (frame << 12) | (g_em->width << 6) | g_em->height;
10247 void getGraphicSourcePlayerExt_EM(struct GraphicInfo_EM *g_em,
10248 int player_nr, int anim, int frame_em)
10250 int element = player_mapping[player_nr][anim].element_rnd;
10251 int action = player_mapping[player_nr][anim].action;
10252 int direction = player_mapping[player_nr][anim].direction;
10253 int graphic = (direction == MV_NONE ?
10254 el_act2img(element, action) :
10255 el_act_dir2img(element, action, direction));
10256 struct GraphicInfo *g = &graphic_info[graphic];
10259 InitPlayerGfxAnimation(&stored_player[player_nr], action, direction);
10261 stored_player[player_nr].StepFrame = frame_em;
10263 sync_frame = stored_player[player_nr].Frame;
10265 int frame = getAnimationFrame(g->anim_frames,
10268 g->anim_start_frame,
10271 getGraphicSourceExt(graphic, frame, &g_em->bitmap,
10272 &g_em->src_x, &g_em->src_y, FALSE);
10275 printf("::: %d: %d, %d [%d]\n",
10277 stored_player[player_nr].Frame,
10278 stored_player[player_nr].StepFrame,
10283 void InitGraphicInfo_EM(void)
10286 struct Mapping_EM_to_RND_object object_mapping[TILE_MAX];
10287 struct Mapping_EM_to_RND_player player_mapping[MAX_PLAYERS][SPR_MAX];
10292 int num_em_gfx_errors = 0;
10294 if (graphic_info_em_object[0][0].bitmap == NULL)
10296 /* EM graphics not yet initialized in em_open_all() */
10301 printf("::: [4 errors can be ignored (1 x 'bomb', 3 x 'em_dynamite']\n");
10304 /* always start with reliable default values */
10305 for (i = 0; i < TILE_MAX; i++)
10307 object_mapping[i].element_rnd = EL_UNKNOWN;
10308 object_mapping[i].is_backside = FALSE;
10309 object_mapping[i].action = ACTION_DEFAULT;
10310 object_mapping[i].direction = MV_NONE;
10313 /* always start with reliable default values */
10314 for (p = 0; p < MAX_PLAYERS; p++)
10316 for (i = 0; i < SPR_MAX; i++)
10318 player_mapping[p][i].element_rnd = EL_UNKNOWN;
10319 player_mapping[p][i].action = ACTION_DEFAULT;
10320 player_mapping[p][i].direction = MV_NONE;
10324 for (i = 0; em_object_mapping_list[i].element_em != -1; i++)
10326 int e = em_object_mapping_list[i].element_em;
10328 object_mapping[e].element_rnd = em_object_mapping_list[i].element_rnd;
10329 object_mapping[e].is_backside = em_object_mapping_list[i].is_backside;
10331 if (em_object_mapping_list[i].action != -1)
10332 object_mapping[e].action = em_object_mapping_list[i].action;
10334 if (em_object_mapping_list[i].direction != -1)
10335 object_mapping[e].direction =
10336 MV_DIR_FROM_BIT(em_object_mapping_list[i].direction);
10339 for (i = 0; em_player_mapping_list[i].action_em != -1; i++)
10341 int a = em_player_mapping_list[i].action_em;
10342 int p = em_player_mapping_list[i].player_nr;
10344 player_mapping[p][a].element_rnd = em_player_mapping_list[i].element_rnd;
10346 if (em_player_mapping_list[i].action != -1)
10347 player_mapping[p][a].action = em_player_mapping_list[i].action;
10349 if (em_player_mapping_list[i].direction != -1)
10350 player_mapping[p][a].direction =
10351 MV_DIR_FROM_BIT(em_player_mapping_list[i].direction);
10354 for (i = 0; i < TILE_MAX; i++)
10356 int element = object_mapping[i].element_rnd;
10357 int action = object_mapping[i].action;
10358 int direction = object_mapping[i].direction;
10359 boolean is_backside = object_mapping[i].is_backside;
10361 boolean action_removing = (action == ACTION_DIGGING ||
10362 action == ACTION_SNAPPING ||
10363 action == ACTION_COLLECTING);
10365 boolean action_exploding = ((action == ACTION_EXPLODING ||
10366 action == ACTION_SMASHED_BY_ROCK ||
10367 action == ACTION_SMASHED_BY_SPRING) &&
10368 element != EL_DIAMOND);
10369 boolean action_active = (action == ACTION_ACTIVE);
10370 boolean action_other = (action == ACTION_OTHER);
10372 for (j = 0; j < 8; j++)
10375 int effective_element = get_effective_element_EM(i, j);
10377 int effective_element = (j > 5 && i == Yacid_splash_eB ? EL_EMPTY :
10378 j > 5 && i == Yacid_splash_wB ? EL_EMPTY :
10380 i == Xdrip_stretch ? element :
10381 i == Xdrip_stretchB ? element :
10382 i == Ydrip_s1 ? element :
10383 i == Ydrip_s1B ? element :
10384 i == Xball_1B ? element :
10385 i == Xball_2 ? element :
10386 i == Xball_2B ? element :
10387 i == Yball_eat ? element :
10388 i == Ykey_1_eat ? element :
10389 i == Ykey_2_eat ? element :
10390 i == Ykey_3_eat ? element :
10391 i == Ykey_4_eat ? element :
10392 i == Ykey_5_eat ? element :
10393 i == Ykey_6_eat ? element :
10394 i == Ykey_7_eat ? element :
10395 i == Ykey_8_eat ? element :
10396 i == Ylenses_eat ? element :
10397 i == Ymagnify_eat ? element :
10398 i == Ygrass_eat ? element :
10399 i == Ydirt_eat ? element :
10400 i == Yemerald_stone ? EL_EMERALD :
10401 i == Ydiamond_stone ? EL_ROCK :
10402 i == Xsand_stonein_1 ? element :
10403 i == Xsand_stonein_2 ? element :
10404 i == Xsand_stonein_3 ? element :
10405 i == Xsand_stonein_4 ? element :
10406 is_backside ? EL_EMPTY :
10407 action_removing ? EL_EMPTY :
10410 int effective_action = (j < 7 ? action :
10411 i == Xdrip_stretch ? action :
10412 i == Xdrip_stretchB ? action :
10413 i == Ydrip_s1 ? action :
10414 i == Ydrip_s1B ? action :
10415 i == Xball_1B ? action :
10416 i == Xball_2 ? action :
10417 i == Xball_2B ? action :
10418 i == Yball_eat ? action :
10419 i == Ykey_1_eat ? action :
10420 i == Ykey_2_eat ? action :
10421 i == Ykey_3_eat ? action :
10422 i == Ykey_4_eat ? action :
10423 i == Ykey_5_eat ? action :
10424 i == Ykey_6_eat ? action :
10425 i == Ykey_7_eat ? action :
10426 i == Ykey_8_eat ? action :
10427 i == Ylenses_eat ? action :
10428 i == Ymagnify_eat ? action :
10429 i == Ygrass_eat ? action :
10430 i == Ydirt_eat ? action :
10431 i == Xsand_stonein_1 ? action :
10432 i == Xsand_stonein_2 ? action :
10433 i == Xsand_stonein_3 ? action :
10434 i == Xsand_stonein_4 ? action :
10435 i == Xsand_stoneout_1 ? action :
10436 i == Xsand_stoneout_2 ? action :
10437 i == Xboom_android ? ACTION_EXPLODING :
10438 action_exploding ? ACTION_EXPLODING :
10439 action_active ? action :
10440 action_other ? action :
10442 int graphic = (el_act_dir2img(effective_element, effective_action,
10444 int crumbled = (el_act_dir2crm(effective_element, effective_action,
10446 int base_graphic = el_act2img(effective_element, ACTION_DEFAULT);
10447 int base_crumbled = el_act2crm(effective_element, ACTION_DEFAULT);
10448 boolean has_action_graphics = (graphic != base_graphic);
10449 boolean has_crumbled_graphics = (base_crumbled != base_graphic);
10450 struct GraphicInfo *g = &graphic_info[graphic];
10452 struct GraphicInfo *g_crumbled = &graphic_info[crumbled];
10454 struct GraphicInfo_EM *g_em = &graphic_info_em_object[i][7 - j];
10455 Bitmap *src_bitmap;
10457 /* ensure to get symmetric 3-frame, 2-delay animations as used in EM */
10458 boolean special_animation = (action != ACTION_DEFAULT &&
10459 g->anim_frames == 3 &&
10460 g->anim_delay == 2 &&
10461 g->anim_mode & ANIM_LINEAR);
10462 int sync_frame = (i == Xdrip_stretch ? 7 :
10463 i == Xdrip_stretchB ? 7 :
10464 i == Ydrip_s2 ? j + 8 :
10465 i == Ydrip_s2B ? j + 8 :
10467 i == Xacid_2 ? 10 :
10468 i == Xacid_3 ? 20 :
10469 i == Xacid_4 ? 30 :
10470 i == Xacid_5 ? 40 :
10471 i == Xacid_6 ? 50 :
10472 i == Xacid_7 ? 60 :
10473 i == Xacid_8 ? 70 :
10474 i == Xfake_acid_1 ? 0 :
10475 i == Xfake_acid_2 ? 10 :
10476 i == Xfake_acid_3 ? 20 :
10477 i == Xfake_acid_4 ? 30 :
10478 i == Xfake_acid_5 ? 40 :
10479 i == Xfake_acid_6 ? 50 :
10480 i == Xfake_acid_7 ? 60 :
10481 i == Xfake_acid_8 ? 70 :
10483 i == Xball_2B ? j + 8 :
10484 i == Yball_eat ? j + 1 :
10485 i == Ykey_1_eat ? j + 1 :
10486 i == Ykey_2_eat ? j + 1 :
10487 i == Ykey_3_eat ? j + 1 :
10488 i == Ykey_4_eat ? j + 1 :
10489 i == Ykey_5_eat ? j + 1 :
10490 i == Ykey_6_eat ? j + 1 :
10491 i == Ykey_7_eat ? j + 1 :
10492 i == Ykey_8_eat ? j + 1 :
10493 i == Ylenses_eat ? j + 1 :
10494 i == Ymagnify_eat ? j + 1 :
10495 i == Ygrass_eat ? j + 1 :
10496 i == Ydirt_eat ? j + 1 :
10497 i == Xamoeba_1 ? 0 :
10498 i == Xamoeba_2 ? 1 :
10499 i == Xamoeba_3 ? 2 :
10500 i == Xamoeba_4 ? 3 :
10501 i == Xamoeba_5 ? 0 :
10502 i == Xamoeba_6 ? 1 :
10503 i == Xamoeba_7 ? 2 :
10504 i == Xamoeba_8 ? 3 :
10505 i == Xexit_2 ? j + 8 :
10506 i == Xexit_3 ? j + 16 :
10507 i == Xdynamite_1 ? 0 :
10508 i == Xdynamite_2 ? 8 :
10509 i == Xdynamite_3 ? 16 :
10510 i == Xdynamite_4 ? 24 :
10511 i == Xsand_stonein_1 ? j + 1 :
10512 i == Xsand_stonein_2 ? j + 9 :
10513 i == Xsand_stonein_3 ? j + 17 :
10514 i == Xsand_stonein_4 ? j + 25 :
10515 i == Xsand_stoneout_1 && j == 0 ? 0 :
10516 i == Xsand_stoneout_1 && j == 1 ? 0 :
10517 i == Xsand_stoneout_1 && j == 2 ? 1 :
10518 i == Xsand_stoneout_1 && j == 3 ? 2 :
10519 i == Xsand_stoneout_1 && j == 4 ? 2 :
10520 i == Xsand_stoneout_1 && j == 5 ? 3 :
10521 i == Xsand_stoneout_1 && j == 6 ? 4 :
10522 i == Xsand_stoneout_1 && j == 7 ? 4 :
10523 i == Xsand_stoneout_2 && j == 0 ? 5 :
10524 i == Xsand_stoneout_2 && j == 1 ? 6 :
10525 i == Xsand_stoneout_2 && j == 2 ? 7 :
10526 i == Xsand_stoneout_2 && j == 3 ? 8 :
10527 i == Xsand_stoneout_2 && j == 4 ? 9 :
10528 i == Xsand_stoneout_2 && j == 5 ? 11 :
10529 i == Xsand_stoneout_2 && j == 6 ? 13 :
10530 i == Xsand_stoneout_2 && j == 7 ? 15 :
10531 i == Xboom_bug && j == 1 ? 2 :
10532 i == Xboom_bug && j == 2 ? 2 :
10533 i == Xboom_bug && j == 3 ? 4 :
10534 i == Xboom_bug && j == 4 ? 4 :
10535 i == Xboom_bug && j == 5 ? 2 :
10536 i == Xboom_bug && j == 6 ? 2 :
10537 i == Xboom_bug && j == 7 ? 0 :
10538 i == Xboom_bomb && j == 1 ? 2 :
10539 i == Xboom_bomb && j == 2 ? 2 :
10540 i == Xboom_bomb && j == 3 ? 4 :
10541 i == Xboom_bomb && j == 4 ? 4 :
10542 i == Xboom_bomb && j == 5 ? 2 :
10543 i == Xboom_bomb && j == 6 ? 2 :
10544 i == Xboom_bomb && j == 7 ? 0 :
10545 i == Xboom_android && j == 7 ? 6 :
10546 i == Xboom_1 && j == 1 ? 2 :
10547 i == Xboom_1 && j == 2 ? 2 :
10548 i == Xboom_1 && j == 3 ? 4 :
10549 i == Xboom_1 && j == 4 ? 4 :
10550 i == Xboom_1 && j == 5 ? 6 :
10551 i == Xboom_1 && j == 6 ? 6 :
10552 i == Xboom_1 && j == 7 ? 8 :
10553 i == Xboom_2 && j == 0 ? 8 :
10554 i == Xboom_2 && j == 1 ? 8 :
10555 i == Xboom_2 && j == 2 ? 10 :
10556 i == Xboom_2 && j == 3 ? 10 :
10557 i == Xboom_2 && j == 4 ? 10 :
10558 i == Xboom_2 && j == 5 ? 12 :
10559 i == Xboom_2 && j == 6 ? 12 :
10560 i == Xboom_2 && j == 7 ? 12 :
10561 special_animation && j == 4 ? 3 :
10562 effective_action != action ? 0 :
10566 Bitmap *debug_bitmap = g_em->bitmap;
10567 int debug_src_x = g_em->src_x;
10568 int debug_src_y = g_em->src_y;
10571 int frame = getAnimationFrame(g->anim_frames,
10574 g->anim_start_frame,
10577 getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y,
10578 g->double_movement && is_backside);
10580 g_em->bitmap = src_bitmap;
10581 g_em->src_x = src_x;
10582 g_em->src_y = src_y;
10583 g_em->src_offset_x = 0;
10584 g_em->src_offset_y = 0;
10585 g_em->dst_offset_x = 0;
10586 g_em->dst_offset_y = 0;
10587 g_em->width = TILEX;
10588 g_em->height = TILEY;
10590 g_em->preserve_background = FALSE;
10593 set_crumbled_graphics_EM(g_em, has_crumbled_graphics, crumbled,
10598 g_em->crumbled_bitmap = NULL;
10599 g_em->crumbled_src_x = 0;
10600 g_em->crumbled_src_y = 0;
10601 g_em->crumbled_border_size = 0;
10603 g_em->has_crumbled_graphics = FALSE;
10606 if (has_crumbled_graphics && crumbled == IMG_EMPTY_SPACE)
10607 printf("::: empty crumbled: %d [%s], %d, %d\n",
10608 effective_element, element_info[effective_element].token_name,
10609 effective_action, direction);
10612 /* if element can be crumbled, but certain action graphics are just empty
10613 space (like instantly snapping sand to empty space in 1 frame), do not
10614 treat these empty space graphics as crumbled graphics in EMC engine */
10615 if (has_crumbled_graphics && crumbled != IMG_EMPTY_SPACE)
10617 int frame_crumbled = getAnimationFrame(g_crumbled->anim_frames,
10618 g_crumbled->anim_delay,
10619 g_crumbled->anim_mode,
10620 g_crumbled->anim_start_frame,
10623 getGraphicSource(crumbled, frame_crumbled, &src_bitmap, &src_x, &src_y);
10625 g_em->has_crumbled_graphics = TRUE;
10626 g_em->crumbled_bitmap = src_bitmap;
10627 g_em->crumbled_src_x = src_x;
10628 g_em->crumbled_src_y = src_y;
10629 g_em->crumbled_border_size = graphic_info[crumbled].border_size;
10633 if (g_em == &graphic_info_em_object[207][0])
10634 printf("... %d, %d [%d, %d, %d, %d] [%d, %d, %d, %d, %d, %d => %d]\n",
10635 graphic_info_em_object[207][0].crumbled_src_x,
10636 graphic_info_em_object[207][0].crumbled_src_y,
10638 crumbled, frame, src_x, src_y,
10643 g->anim_start_frame,
10645 gfx.anim_random_frame,
10650 printf("::: EMC tile %d is crumbled\n", i);
10656 if (element == EL_ROCK &&
10657 effective_action == ACTION_FILLING)
10658 printf("::: has_action_graphics == %d\n", has_action_graphics);
10661 if ((!g->double_movement && (effective_action == ACTION_FALLING ||
10662 effective_action == ACTION_MOVING ||
10663 effective_action == ACTION_PUSHING ||
10664 effective_action == ACTION_EATING)) ||
10665 (!has_action_graphics && (effective_action == ACTION_FILLING ||
10666 effective_action == ACTION_EMPTYING)))
10669 (effective_action == ACTION_FALLING ||
10670 effective_action == ACTION_FILLING ||
10671 effective_action == ACTION_EMPTYING ? MV_DOWN : direction);
10672 int dx = (move_dir == MV_LEFT ? -1 : move_dir == MV_RIGHT ? 1 : 0);
10673 int dy = (move_dir == MV_UP ? -1 : move_dir == MV_DOWN ? 1 : 0);
10674 int num_steps = (i == Ydrip_s1 ? 16 :
10675 i == Ydrip_s1B ? 16 :
10676 i == Ydrip_s2 ? 16 :
10677 i == Ydrip_s2B ? 16 :
10678 i == Xsand_stonein_1 ? 32 :
10679 i == Xsand_stonein_2 ? 32 :
10680 i == Xsand_stonein_3 ? 32 :
10681 i == Xsand_stonein_4 ? 32 :
10682 i == Xsand_stoneout_1 ? 16 :
10683 i == Xsand_stoneout_2 ? 16 : 8);
10684 int cx = ABS(dx) * (TILEX / num_steps);
10685 int cy = ABS(dy) * (TILEY / num_steps);
10686 int step_frame = (i == Ydrip_s2 ? j + 8 :
10687 i == Ydrip_s2B ? j + 8 :
10688 i == Xsand_stonein_2 ? j + 8 :
10689 i == Xsand_stonein_3 ? j + 16 :
10690 i == Xsand_stonein_4 ? j + 24 :
10691 i == Xsand_stoneout_2 ? j + 8 : j) + 1;
10692 int step = (is_backside ? step_frame : num_steps - step_frame);
10694 if (is_backside) /* tile where movement starts */
10696 if (dx < 0 || dy < 0)
10698 g_em->src_offset_x = cx * step;
10699 g_em->src_offset_y = cy * step;
10703 g_em->dst_offset_x = cx * step;
10704 g_em->dst_offset_y = cy * step;
10707 else /* tile where movement ends */
10709 if (dx < 0 || dy < 0)
10711 g_em->dst_offset_x = cx * step;
10712 g_em->dst_offset_y = cy * step;
10716 g_em->src_offset_x = cx * step;
10717 g_em->src_offset_y = cy * step;
10721 g_em->width = TILEX - cx * step;
10722 g_em->height = TILEY - cy * step;
10725 /* create unique graphic identifier to decide if tile must be redrawn */
10726 /* bit 31 - 16 (16 bit): EM style graphic
10727 bit 15 - 12 ( 4 bit): EM style frame
10728 bit 11 - 6 ( 6 bit): graphic width
10729 bit 5 - 0 ( 6 bit): graphic height */
10730 g_em->unique_identifier =
10731 (graphic << 16) | (frame << 12) | (g_em->width << 6) | g_em->height;
10735 /* skip check for EMC elements not contained in original EMC artwork */
10736 if (element == EL_EMC_FAKE_ACID)
10739 if (g_em->bitmap != debug_bitmap ||
10740 g_em->src_x != debug_src_x ||
10741 g_em->src_y != debug_src_y ||
10742 g_em->src_offset_x != 0 ||
10743 g_em->src_offset_y != 0 ||
10744 g_em->dst_offset_x != 0 ||
10745 g_em->dst_offset_y != 0 ||
10746 g_em->width != TILEX ||
10747 g_em->height != TILEY)
10749 static int last_i = -1;
10757 printf("::: EMC GFX ERROR for element %d -> %d ('%s', '%s', %d)",
10758 i, element, element_info[element].token_name,
10759 element_action_info[effective_action].suffix, direction);
10761 if (element != effective_element)
10762 printf(" [%d ('%s')]",
10764 element_info[effective_element].token_name);
10768 if (g_em->bitmap != debug_bitmap)
10769 printf(" %d (%d): different bitmap! (0x%08x != 0x%08x)\n",
10770 j, is_backside, (int)(g_em->bitmap), (int)(debug_bitmap));
10772 if (g_em->src_x != debug_src_x ||
10773 g_em->src_y != debug_src_y)
10774 printf(" frame %d (%c): %d,%d (%d,%d) should be %d,%d (%d,%d)\n",
10775 j, (is_backside ? 'B' : 'F'),
10776 g_em->src_x, g_em->src_y,
10777 g_em->src_x / 32, g_em->src_y / 32,
10778 debug_src_x, debug_src_y,
10779 debug_src_x / 32, debug_src_y / 32);
10781 if (g_em->src_offset_x != 0 ||
10782 g_em->src_offset_y != 0 ||
10783 g_em->dst_offset_x != 0 ||
10784 g_em->dst_offset_y != 0)
10785 printf(" %d (%d): offsets %d,%d and %d,%d should be all 0\n",
10787 g_em->src_offset_x, g_em->src_offset_y,
10788 g_em->dst_offset_x, g_em->dst_offset_y);
10790 if (g_em->width != TILEX ||
10791 g_em->height != TILEY)
10792 printf(" %d (%d): size %d,%d should be %d,%d\n",
10794 g_em->width, g_em->height, TILEX, TILEY);
10796 num_em_gfx_errors++;
10803 for (i = 0; i < TILE_MAX; i++)
10805 for (j = 0; j < 8; j++)
10807 int element = object_mapping[i].element_rnd;
10808 int action = object_mapping[i].action;
10809 int direction = object_mapping[i].direction;
10810 boolean is_backside = object_mapping[i].is_backside;
10811 int graphic_action = el_act_dir2img(element, action, direction);
10812 int graphic_default = el_act_dir2img(element, ACTION_DEFAULT, direction);
10814 if ((action == ACTION_SMASHED_BY_ROCK ||
10815 action == ACTION_SMASHED_BY_SPRING ||
10816 action == ACTION_EATING) &&
10817 graphic_action == graphic_default)
10819 int e = (action == ACTION_SMASHED_BY_ROCK ? Ystone_s :
10820 action == ACTION_SMASHED_BY_SPRING ? Yspring_s :
10821 direction == MV_LEFT ? (is_backside? Yspring_wB: Yspring_w) :
10822 direction == MV_RIGHT ? (is_backside? Yspring_eB: Yspring_e) :
10825 /* no separate animation for "smashed by rock" -- use rock instead */
10826 struct GraphicInfo_EM *g_em = &graphic_info_em_object[i][7 - j];
10827 struct GraphicInfo_EM *g_xx = &graphic_info_em_object[e][7 - j];
10829 g_em->bitmap = g_xx->bitmap;
10830 g_em->src_x = g_xx->src_x;
10831 g_em->src_y = g_xx->src_y;
10832 g_em->src_offset_x = g_xx->src_offset_x;
10833 g_em->src_offset_y = g_xx->src_offset_y;
10834 g_em->dst_offset_x = g_xx->dst_offset_x;
10835 g_em->dst_offset_y = g_xx->dst_offset_y;
10836 g_em->width = g_xx->width;
10837 g_em->height = g_xx->height;
10838 g_em->unique_identifier = g_xx->unique_identifier;
10841 g_em->preserve_background = TRUE;
10846 for (p = 0; p < MAX_PLAYERS; p++)
10848 for (i = 0; i < SPR_MAX; i++)
10850 int element = player_mapping[p][i].element_rnd;
10851 int action = player_mapping[p][i].action;
10852 int direction = player_mapping[p][i].direction;
10854 for (j = 0; j < 8; j++)
10856 int effective_element = element;
10857 int effective_action = action;
10858 int graphic = (direction == MV_NONE ?
10859 el_act2img(effective_element, effective_action) :
10860 el_act_dir2img(effective_element, effective_action,
10862 struct GraphicInfo *g = &graphic_info[graphic];
10863 struct GraphicInfo_EM *g_em = &graphic_info_em_player[p][i][7 - j];
10864 Bitmap *src_bitmap;
10866 int sync_frame = j;
10869 Bitmap *debug_bitmap = g_em->bitmap;
10870 int debug_src_x = g_em->src_x;
10871 int debug_src_y = g_em->src_y;
10874 int frame = getAnimationFrame(g->anim_frames,
10877 g->anim_start_frame,
10880 getGraphicSourceExt(graphic, frame, &src_bitmap, &src_x, &src_y, FALSE);
10882 g_em->bitmap = src_bitmap;
10883 g_em->src_x = src_x;
10884 g_em->src_y = src_y;
10885 g_em->src_offset_x = 0;
10886 g_em->src_offset_y = 0;
10887 g_em->dst_offset_x = 0;
10888 g_em->dst_offset_y = 0;
10889 g_em->width = TILEX;
10890 g_em->height = TILEY;
10894 /* skip check for EMC elements not contained in original EMC artwork */
10895 if (element == EL_PLAYER_3 ||
10896 element == EL_PLAYER_4)
10899 if (g_em->bitmap != debug_bitmap ||
10900 g_em->src_x != debug_src_x ||
10901 g_em->src_y != debug_src_y)
10903 static int last_i = -1;
10911 printf("::: EMC GFX ERROR for p/a %d/%d -> %d ('%s', '%s', %d)",
10912 p, i, element, element_info[element].token_name,
10913 element_action_info[effective_action].suffix, direction);
10915 if (element != effective_element)
10916 printf(" [%d ('%s')]",
10918 element_info[effective_element].token_name);
10922 if (g_em->bitmap != debug_bitmap)
10923 printf(" %d: different bitmap! (0x%08x != 0x%08x)\n",
10924 j, (int)(g_em->bitmap), (int)(debug_bitmap));
10926 if (g_em->src_x != debug_src_x ||
10927 g_em->src_y != debug_src_y)
10928 printf(" frame %d: %d,%d (%d,%d) should be %d,%d (%d,%d)\n",
10930 g_em->src_x, g_em->src_y,
10931 g_em->src_x / 32, g_em->src_y / 32,
10932 debug_src_x, debug_src_y,
10933 debug_src_x / 32, debug_src_y / 32);
10935 num_em_gfx_errors++;
10945 printf("::: [%d errors found]\n", num_em_gfx_errors);
10951 void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame,
10952 boolean any_player_moving,
10953 boolean player_is_dropping)
10955 if (tape.single_step && tape.recording && !tape.pausing)
10958 boolean active_players = FALSE;
10961 for (i = 0; i < MAX_PLAYERS; i++)
10962 if (action[i] != JOY_NO_ACTION)
10963 active_players = TRUE;
10967 if (frame == 0 && !player_is_dropping)
10968 TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
10972 void CheckSingleStepMode_SP(boolean murphy_is_waiting,
10973 boolean murphy_is_dropping)
10976 printf("::: waiting: %d, dropping: %d\n",
10977 murphy_is_waiting, murphy_is_dropping);
10980 if (tape.single_step && tape.recording && !tape.pausing)
10982 // if (murphy_is_waiting || murphy_is_dropping)
10983 if (murphy_is_waiting)
10986 printf("::: murphy is waiting -> pause mode\n");
10989 TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
10994 void getGraphicSource_SP(struct GraphicInfo_SP *g_sp,
10995 int graphic, int sync_frame, int x, int y)
10997 int frame = getGraphicAnimationFrame(graphic, sync_frame);
10999 getGraphicSource(graphic, frame, &g_sp->bitmap, &g_sp->src_x, &g_sp->src_y);
11002 boolean isNextAnimationFrame_SP(int graphic, int sync_frame)
11004 return (IS_NEXT_FRAME(sync_frame, graphic));
11007 int getGraphicInfo_Delay(int graphic)
11009 return graphic_info[graphic].anim_delay;
11012 void PlayMenuSoundExt(int sound)
11014 if (sound == SND_UNDEFINED)
11017 if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
11018 (!setup.sound_loops && IS_LOOP_SOUND(sound)))
11021 if (IS_LOOP_SOUND(sound))
11022 PlaySoundLoop(sound);
11027 void PlayMenuSound()
11029 PlayMenuSoundExt(menu.sound[game_status]);
11032 void PlayMenuSoundStereo(int sound, int stereo_position)
11034 if (sound == SND_UNDEFINED)
11037 if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
11038 (!setup.sound_loops && IS_LOOP_SOUND(sound)))
11041 if (IS_LOOP_SOUND(sound))
11042 PlaySoundExt(sound, SOUND_MAX_VOLUME, stereo_position, SND_CTRL_PLAY_LOOP);
11044 PlaySoundStereo(sound, stereo_position);
11047 void PlayMenuSoundIfLoopExt(int sound)
11049 if (sound == SND_UNDEFINED)
11052 if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
11053 (!setup.sound_loops && IS_LOOP_SOUND(sound)))
11056 if (IS_LOOP_SOUND(sound))
11057 PlaySoundLoop(sound);
11060 void PlayMenuSoundIfLoop()
11062 PlayMenuSoundIfLoopExt(menu.sound[game_status]);
11065 void PlayMenuMusicExt(int music)
11067 if (music == MUS_UNDEFINED)
11070 if (!setup.sound_music)
11076 void PlayMenuMusic()
11078 PlayMenuMusicExt(menu.music[game_status]);
11081 void PlaySoundActivating()
11084 PlaySound(SND_MENU_ITEM_ACTIVATING);
11088 void PlaySoundSelecting()
11091 PlaySound(SND_MENU_ITEM_SELECTING);
11095 void ToggleFullscreenOrChangeWindowScalingIfNeeded()
11097 boolean change_fullscreen = (setup.fullscreen !=
11098 video.fullscreen_enabled);
11099 boolean change_fullscreen_mode = (video.fullscreen_enabled &&
11100 !strEqual(setup.fullscreen_mode,
11101 video.fullscreen_mode_current));
11102 boolean change_window_scaling_percent = (!video.fullscreen_enabled &&
11103 setup.window_scaling_percent !=
11104 video.window_scaling_percent);
11106 if (change_window_scaling_percent && video.fullscreen_enabled)
11109 if (!change_window_scaling_percent && !video.fullscreen_available)
11112 #if defined(TARGET_SDL2)
11113 if (change_window_scaling_percent)
11115 SDLSetWindowScaling(setup.window_scaling_percent);
11119 else if (change_fullscreen)
11121 SDLSetWindowFullscreen(setup.fullscreen);
11123 /* set setup value according to successfully changed fullscreen mode */
11124 setup.fullscreen = video.fullscreen_enabled;
11130 if (change_fullscreen ||
11131 change_fullscreen_mode ||
11132 change_window_scaling_percent)
11134 Bitmap *tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH);
11136 /* save backbuffer content which gets lost when toggling fullscreen mode */
11137 BlitBitmap(backbuffer, tmp_backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
11139 if (change_fullscreen_mode)
11141 /* keep fullscreen, but change fullscreen mode (screen resolution) */
11142 video.fullscreen_enabled = FALSE; /* force new fullscreen mode */
11145 if (change_window_scaling_percent)
11147 /* keep window mode, but change window scaling */
11148 video.fullscreen_enabled = TRUE; /* force new window scaling */
11151 /* toggle fullscreen */
11152 ChangeVideoModeIfNeeded(setup.fullscreen);
11154 /* set setup value according to successfully changed fullscreen mode */
11155 setup.fullscreen = video.fullscreen_enabled;
11157 /* restore backbuffer content from temporary backbuffer backup bitmap */
11158 BlitBitmap(tmp_backbuffer, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
11160 FreeBitmap(tmp_backbuffer);
11163 /* update visible window/screen */
11164 BlitBitmap(backbuffer, window, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
11166 redraw_mask = REDRAW_ALL;
11171 void ChangeViewportPropertiesIfNeeded()
11174 int *door_1_x = &DX;
11175 int *door_1_y = &DY;
11176 int *door_2_x = (game_status == GAME_MODE_EDITOR ? &EX : &VX);
11177 int *door_2_y = (game_status == GAME_MODE_EDITOR ? &EY : &VY);
11179 int gfx_game_mode = (game_status == GAME_MODE_PLAYING ||
11180 game_status == GAME_MODE_EDITOR ? game_status :
11182 int gfx_game_mode2 = (game_status == GAME_MODE_EDITOR ? GAME_MODE_DEFAULT :
11184 struct RectWithBorder *vp_playfield = &viewport.playfield[gfx_game_mode];
11185 struct RectWithBorder *vp_door_1 = &viewport.door_1[gfx_game_mode];
11186 struct RectWithBorder *vp_door_2 = &viewport.door_2[gfx_game_mode2];
11187 struct RectWithBorder *vp_door_3 = &viewport.door_2[GAME_MODE_EDITOR];
11188 int border_size = vp_playfield->border_size;
11189 int new_sx = vp_playfield->x + border_size;
11190 int new_sy = vp_playfield->y + border_size;
11191 int new_sxsize = vp_playfield->width - 2 * border_size;
11192 int new_sysize = vp_playfield->height - 2 * border_size;
11193 int new_real_sx = vp_playfield->x;
11194 int new_real_sy = vp_playfield->y;
11195 int new_full_sxsize = vp_playfield->width;
11196 int new_full_sysize = vp_playfield->height;
11197 int new_dx = vp_door_1->x;
11198 int new_dy = vp_door_1->y;
11199 int new_dxsize = vp_door_1->width;
11200 int new_dysize = vp_door_1->height;
11201 int new_vx = vp_door_2->x;
11202 int new_vy = vp_door_2->y;
11203 int new_vxsize = vp_door_2->width;
11204 int new_vysize = vp_door_2->height;
11205 int new_ex = vp_door_3->x;
11206 int new_ey = vp_door_3->y;
11207 int new_exsize = vp_door_3->width;
11208 int new_eysize = vp_door_3->height;
11210 int new_tilesize_var = TILESIZE / (setup.small_game_graphics ? 2 : 1);
11211 int tilesize = (gfx_game_mode == GAME_MODE_PLAYING ? new_tilesize_var :
11212 gfx_game_mode == GAME_MODE_EDITOR ? MINI_TILESIZE : TILESIZE);
11213 int new_scr_fieldx = new_sxsize / tilesize;
11214 int new_scr_fieldy = new_sysize / tilesize;
11215 int new_scr_fieldx_buffers = new_sxsize / new_tilesize_var;
11216 int new_scr_fieldy_buffers = new_sysize / new_tilesize_var;
11218 int new_scr_fieldx = (vp_playfield->width - 2 * border_size) / TILESIZE;
11219 int new_scr_fieldy = (vp_playfield->height - 2 * border_size) / TILESIZE;
11221 boolean init_gfx_buffers = FALSE;
11222 boolean init_video_buffer = FALSE;
11223 boolean init_gadgets_and_toons = FALSE;
11226 /* !!! TEST ONLY !!! */
11227 // InitGfxBuffers();
11231 if (viewport.window.width != WIN_XSIZE ||
11232 viewport.window.height != WIN_YSIZE)
11234 WIN_XSIZE = viewport.window.width;
11235 WIN_YSIZE = viewport.window.height;
11238 init_video_buffer = TRUE;
11239 init_gfx_buffers = TRUE;
11241 InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
11245 SetDrawDeactivationMask(REDRAW_NONE);
11246 SetDrawBackgroundMask(REDRAW_FIELD);
11248 // RedrawBackground();
11252 // printf("::: video: init_video_buffer, init_gfx_buffers\n");
11255 if (new_scr_fieldx != SCR_FIELDX ||
11256 new_scr_fieldy != SCR_FIELDY)
11258 /* this always toggles between MAIN and GAME when using small tile size */
11260 SCR_FIELDX = new_scr_fieldx;
11261 SCR_FIELDY = new_scr_fieldy;
11263 // printf("::: new_scr_fieldx != SCR_FIELDX ...\n");
11267 if (new_tilesize_var != TILESIZE_VAR &&
11268 gfx_game_mode == GAME_MODE_PLAYING)
11270 /* doing this outside GAME_MODE_PLAYING would give wrong playfield size */
11272 TILESIZE_VAR = new_tilesize_var;
11274 init_gfx_buffers = TRUE;
11276 // printf("::: tilesize: init_gfx_buffers\n");
11280 if (new_sx != SX ||
11288 new_sxsize != SXSIZE ||
11289 new_sysize != SYSIZE ||
11290 new_dxsize != DXSIZE ||
11291 new_dysize != DYSIZE ||
11292 new_vxsize != VXSIZE ||
11293 new_vysize != VYSIZE ||
11294 new_exsize != EXSIZE ||
11295 new_eysize != EYSIZE ||
11296 new_real_sx != REAL_SX ||
11297 new_real_sy != REAL_SY ||
11298 new_full_sxsize != FULL_SXSIZE ||
11299 new_full_sysize != FULL_SYSIZE ||
11300 new_tilesize_var != TILESIZE_VAR
11303 vp_door_1->x != *door_1_x ||
11304 vp_door_1->y != *door_1_y ||
11305 vp_door_2->x != *door_2_x ||
11306 vp_door_2->y != *door_2_y
11318 SXSIZE = new_sxsize;
11319 SYSIZE = new_sysize;
11320 DXSIZE = new_dxsize;
11321 DYSIZE = new_dysize;
11322 VXSIZE = new_vxsize;
11323 VYSIZE = new_vysize;
11324 EXSIZE = new_exsize;
11325 EYSIZE = new_eysize;
11326 REAL_SX = new_real_sx;
11327 REAL_SY = new_real_sy;
11328 FULL_SXSIZE = new_full_sxsize;
11329 FULL_SYSIZE = new_full_sysize;
11330 TILESIZE_VAR = new_tilesize_var;
11333 printf("::: %d, %d, %d [%d]\n",
11334 SCR_FIELDX, SCR_FIELDY, TILESIZE_VAR,
11335 setup.small_game_graphics);
11339 *door_1_x = vp_door_1->x;
11340 *door_1_y = vp_door_1->y;
11341 *door_2_x = vp_door_2->x;
11342 *door_2_y = vp_door_2->y;
11346 init_gfx_buffers = TRUE;
11348 // printf("::: viewports: init_gfx_buffers\n");
11353 if (gfx_game_mode == GAME_MODE_MAIN)
11356 init_gadgets_and_toons = TRUE;
11358 // printf("::: viewports: init_gadgets_and_toons\n");
11366 if (init_gfx_buffers)
11368 // printf("::: init_gfx_buffers\n");
11370 SCR_FIELDX = new_scr_fieldx_buffers;
11371 SCR_FIELDY = new_scr_fieldy_buffers;
11375 SCR_FIELDX = new_scr_fieldx;
11376 SCR_FIELDY = new_scr_fieldy;
11379 if (init_video_buffer)
11381 // printf("::: init_video_buffer\n");
11383 InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
11385 SetDrawDeactivationMask(REDRAW_NONE);
11386 SetDrawBackgroundMask(REDRAW_FIELD);
11389 if (init_gadgets_and_toons)
11391 // printf("::: init_gadgets_and_toons\n");
11398 printf("::: %d, %d / %d, %d [%d]\n", VX, VY, EX, EY, game_status);