+void DrawGraphicAnimationExt(int x, int y, int graphic,
+ int frames, int delay, int mode, int mask_mode)
+{
+ int phase = getGraphicAnimationPhase(frames, delay, mode);
+
+ if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y)))
+ {
+ if (mask_mode == USE_MASKING)
+ DrawGraphicThruMask(SCREENX(x),SCREENY(y), graphic + phase);
+ else
+ DrawGraphic(SCREENX(x),SCREENY(y), graphic + phase);
+ }
+}
+
+void DrawGraphicAnimation(int x, int y, int graphic,
+ int frames, int delay, int mode)
+{
+ DrawGraphicAnimationExt(x,y, graphic, frames,delay,mode, NO_MASKING);
+}
+
+void DrawGraphicAnimationThruMask(int x, int y, int graphic,
+ int frames, int delay, int mode)
+{
+ DrawGraphicAnimationExt(x,y, graphic, frames,delay,mode, USE_MASKING);
+}
+
+void DrawGraphic(int x, int y, int graphic)
+{
+#if DEBUG
+ if (!IN_SCR_FIELD(x,y))
+ {
+ printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n",x,y,graphic);
+ printf("DrawGraphic(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ DrawGraphicExt(drawto_field, gc, FX+x*TILEX, FY+y*TILEY, graphic);
+ MarkTileDirty(x,y);
+}
+
+void DrawGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
+{
+ if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
+ {
+ graphic -= GFX_START_ROCKSSCREEN;
+ XCopyArea(display,pix[PIX_BACK],d,gc,
+ SX + (graphic % GFX_PER_LINE) * TILEX,
+ SY + (graphic / GFX_PER_LINE) * TILEY,
+ TILEX,TILEY, x,y);
+ }
+ else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
+ {
+ graphic -= GFX_START_ROCKSHEROES;
+ XCopyArea(display,pix[PIX_HEROES],d,gc,
+ (graphic % HEROES_PER_LINE) * TILEX,
+ (graphic / HEROES_PER_LINE) * TILEY,
+ TILEX,TILEY, x,y);
+ }
+ else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
+ {
+ graphic -= GFX_START_ROCKSFONT;
+ XCopyArea(display,pix[PIX_BIGFONT],d,gc,
+ (graphic % FONT_CHARS_PER_LINE) * TILEX,
+ (graphic / FONT_CHARS_PER_LINE) * TILEY +
+ FC_SPECIAL1 * FONT_LINES_PER_FONT * TILEY,
+ TILEX,TILEY, x,y);
+ }
+ else
+ XFillRectangle(display,d,gc, x,y, TILEX,TILEY);
+}
+
+void DrawGraphicThruMask(int x, int y, int graphic)
+{
+#if DEBUG
+ if (!IN_SCR_FIELD(x,y))
+ {
+ printf("DrawGraphicThruMask(): x = %d,y = %d, graphic = %d\n",x,y,graphic);
+ printf("DrawGraphicThruMask(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ DrawGraphicThruMaskExt(drawto_field, FX+x*TILEX, FY+y*TILEY, graphic);
+ MarkTileDirty(x,y);
+}
+
+void DrawGraphicThruMaskExt(Drawable d, int dest_x, int dest_y, int graphic)
+{
+ int src_x, src_y;
+ int tile = graphic;
+ Pixmap src_pixmap;
+ GC drawing_gc;
+
+ if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
+ {
+ src_pixmap = pix[PIX_BACK];
+ drawing_gc = clip_gc[PIX_BACK];
+ graphic -= GFX_START_ROCKSSCREEN;
+ src_x = SX+(graphic % GFX_PER_LINE)*TILEX;
+ src_y = SY+(graphic / GFX_PER_LINE)*TILEY;
+ }
+ else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
+ {
+ src_pixmap = pix[PIX_HEROES];
+ drawing_gc = clip_gc[PIX_HEROES];
+ graphic -= GFX_START_ROCKSHEROES;
+ src_x = (graphic % HEROES_PER_LINE)*TILEX;
+ src_y = (graphic / HEROES_PER_LINE)*TILEY;
+ }
+ else
+ {
+ DrawGraphicExt(d, gc, dest_x,dest_y, graphic);
+ return;
+ }
+
+ if (tile_clipmask[tile] != None)
+ {
+ XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
+ XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
+ XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ }
+ else
+ {
+#if DEBUG
+ printf("DrawGraphicThruMask(): tile '%d' needs clipping!\n", tile);
+#endif
+
+ XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y);
+ XCopyArea(display, src_pixmap, drawto_field, drawing_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ }
+}
+
+void DrawMiniGraphic(int x, int y, int graphic)
+{
+ DrawMiniGraphicExt(drawto,gc, SX+x*MINI_TILEX,SY+y*MINI_TILEY, graphic);
+ MarkTileDirty(x/2, y/2);
+}
+
+void DrawMiniGraphicExt(Drawable d, GC gc, int x, int y, int graphic)
+{
+ if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
+ {
+ graphic -= GFX_START_ROCKSSCREEN;
+ XCopyArea(display,pix[PIX_BACK],d,gc,
+ MINI_GFX_STARTX+(graphic % MINI_GFX_PER_LINE)*MINI_TILEX,
+ MINI_GFX_STARTY+(graphic / MINI_GFX_PER_LINE)*MINI_TILEY,
+ MINI_TILEX,MINI_TILEY, x,y);
+ }
+ else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT)
+ {
+ graphic -= GFX_START_ROCKSFONT;
+ XCopyArea(display,pix[PIX_SMALLFONT],d,gc,
+ (graphic % FONT_CHARS_PER_LINE)*FONT4_XSIZE,
+ (graphic / FONT_CHARS_PER_LINE)*FONT4_YSIZE +
+ FC_SPECIAL2*FONT2_YSIZE*FONT_LINES_PER_FONT,
+ MINI_TILEX,MINI_TILEY, x,y);
+ }
+ else
+ XFillRectangle(display,d,gc, x,y, MINI_TILEX,MINI_TILEY);
+}
+
+void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic,
+ int cut_mode, int mask_mode)
+{
+ int width = TILEX, height = TILEY;
+ int cx = 0, cy = 0;
+ int src_x,src_y, dest_x,dest_y;
+ int tile = graphic;
+ Pixmap src_pixmap;
+ GC drawing_gc;
+
+ if (graphic < 0)
+ {
+ DrawGraphic(x,y,graphic);
+ return;
+ }
+
+ if (dx || dy) /* Verschiebung der Grafik? */
+ {
+ if (x < BX1) /* Element kommt von links ins Bild */
+ {
+ x = BX1;
+ width = dx;
+ cx = TILEX - dx;
+ dx = 0;
+ }
+ else if (x > BX2) /* Element kommt von rechts ins Bild */
+ {
+ x = BX2;
+ width = -dx;
+ dx = TILEX + dx;
+ }
+ else if (x==BX1 && dx<0) /* Element verläßt links das Bild */
+ {
+ width += dx;
+ cx = -dx;
+ dx = 0;
+ }
+ else if (x==BX2 && dx>0) /* Element verläßt rechts das Bild */
+ width -= dx;
+ else if (dx) /* allg. Bewegung in x-Richtung */
+ MarkTileDirty(x + SIGN(dx), y);
+
+ if (y < BY1) /* Element kommt von oben ins Bild */
+ {
+ if (cut_mode==CUT_BELOW) /* Element oberhalb des Bildes */
+ return;
+
+ y = BY1;
+ height = dy;
+ cy = TILEY - dy;
+ dy = 0;
+ }
+ else if (y > BY2) /* Element kommt von unten ins Bild */
+ {
+ y = BY2;
+ height = -dy;
+ dy = TILEY + dy;
+ }
+ else if (y==BY1 && dy<0) /* Element verläßt oben das Bild */
+ {
+ height += dy;
+ cy = -dy;
+ dy = 0;
+ }
+ else if (dy > 0 && cut_mode==CUT_ABOVE)
+ {
+ if (y == BY2) /* Element unterhalb des Bildes */
+ return;
+
+ height = dy;
+ cy = TILEY-dy;
+ dy = TILEY;
+ MarkTileDirty(x, y + 1);
+ } /* Element verläßt unten das Bild */
+ else if (dy > 0 && (y == BY2 || cut_mode==CUT_BELOW))
+ height -= dy;
+ else if (dy) /* allg. Bewegung in y-Richtung */
+ MarkTileDirty(x, y + SIGN(dy));
+ }
+
+ if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN)
+ {
+ src_pixmap = pix[PIX_BACK];
+ drawing_gc = clip_gc[PIX_BACK];
+ graphic -= GFX_START_ROCKSSCREEN;
+ src_x = SX+(graphic % GFX_PER_LINE)*TILEX+cx;
+ src_y = SY+(graphic / GFX_PER_LINE)*TILEY+cy;
+ }
+ else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES)
+ {
+ src_pixmap = pix[PIX_HEROES];
+ drawing_gc = clip_gc[PIX_HEROES];
+ graphic -= GFX_START_ROCKSHEROES;
+ src_x = (graphic % HEROES_PER_LINE)*TILEX+cx;
+ src_y = (graphic / HEROES_PER_LINE)*TILEY+cy;
+ }
+
+ dest_x = FX + x*TILEX + dx;
+ dest_y = FY + y*TILEY + dy;
+
+#if DEBUG
+ if (!IN_SCR_FIELD(x,y))
+ {
+ printf("DrawGraphicShifted(): x = %d, y = %d, graphic = %d\n",x,y,graphic);
+ printf("DrawGraphicShifted(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ if (mask_mode == USE_MASKING)
+ {
+ if (tile_clipmask[tile] != None)
+ {
+ XSetClipMask(display, tile_clip_gc, tile_clipmask[tile]);
+ XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
+ XCopyArea(display, src_pixmap, drawto_field, tile_clip_gc,
+ src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+ }
+ else
+ {
+#if DEBUG
+ printf("DrawGraphicShifted(): tile '%d' needs clipping!\n", tile);
+#endif
+
+ XSetClipOrigin(display, drawing_gc, dest_x-src_x, dest_y-src_y);
+ XCopyArea(display, src_pixmap, drawto_field, drawing_gc,
+ src_x,src_y, width,height, dest_x,dest_y);
+ }
+ }
+ else
+ XCopyArea(display, src_pixmap, drawto_field, gc,
+ src_x,src_y, width,height, dest_x,dest_y);
+
+ MarkTileDirty(x,y);
+}
+
+void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic,
+ int cut_mode)
+{
+ DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, USE_MASKING);
+}
+
+void DrawScreenElementExt(int x, int y, int dx, int dy, int element,
+ int cut_mode, int mask_mode)
+{
+ int ux = LEVELX(x), uy = LEVELY(y);
+ int graphic = el2gfx(element);
+ int phase4 = ABS(MovPos[ux][uy])/(TILEX/4);
+ int phase = phase4 / 2;
+ int dir = MovDir[ux][uy];
+
+ if (element==EL_PACMAN || element==EL_KAEFER || element==EL_FLIEGER)
+ {
+ graphic += 4*!phase;
+
+ if (dir == MV_UP)
+ graphic += 1;
+ else if (dir == MV_LEFT)
+ graphic += 2;
+ else if (dir == MV_DOWN)
+ graphic += 3;
+ }
+ else if (element==EL_MAULWURF || element==EL_PINGUIN ||
+ element==EL_SCHWEIN || element==EL_DRACHE)
+ {
+ if (dir==MV_LEFT)
+ graphic = (element==EL_MAULWURF ? GFX_MAULWURF_LEFT :
+ element==EL_PINGUIN ? GFX_PINGUIN_LEFT :
+ element==EL_SCHWEIN ? GFX_SCHWEIN_LEFT : GFX_DRACHE_LEFT);
+ else if (dir==MV_RIGHT)
+ graphic = (element==EL_MAULWURF ? GFX_MAULWURF_RIGHT :
+ element==EL_PINGUIN ? GFX_PINGUIN_RIGHT :
+ element==EL_SCHWEIN ? GFX_SCHWEIN_RIGHT : GFX_DRACHE_RIGHT);
+ else if (dir==MV_UP)
+ graphic = (element==EL_MAULWURF ? GFX_MAULWURF_UP :
+ element==EL_PINGUIN ? GFX_PINGUIN_UP :
+ element==EL_SCHWEIN ? GFX_SCHWEIN_UP : GFX_DRACHE_UP);
+ else
+ graphic = (element==EL_MAULWURF ? GFX_MAULWURF_DOWN :
+ element==EL_PINGUIN ? GFX_PINGUIN_DOWN :
+ element==EL_SCHWEIN ? GFX_SCHWEIN_DOWN : GFX_DRACHE_DOWN);
+
+ graphic += phase4;
+ }
+ else if (element==EL_SONDE)
+ {
+ graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_NORMAL);
+ }
+ else if (element==EL_SALZSAEURE)
+ {
+ graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_NORMAL);
+ }
+ else if (element==EL_BUTTERFLY || element==EL_FIREFLY)
+ {
+ graphic += !phase;
+ }
+ else if ((element==EL_FELSBROCKEN || IS_GEM(element)) && !cut_mode)
+ {
+ graphic += phase * (element==EL_FELSBROCKEN ? 2 : 1);
+ }
+ else if ((element==EL_SIEB_LEER || element==EL_SIEB2_LEER ||
+ element==EL_SIEB_VOLL || element==EL_SIEB2_VOLL) && SiebAktiv)
+ {
+ graphic += 3-(SiebAktiv%8)/2;
+ }
+ else if (IS_AMOEBOID(element))
+ {
+ graphic = (element==EL_AMOEBE_TOT ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT);
+ graphic += (x+2*y) % 4;
+ }
+ else if (element==EL_MAUER_LEBT)
+ {
+ boolean links_massiv = FALSE, rechts_massiv = FALSE;
+
+ if (!IN_LEV_FIELD(ux-1,uy) || IS_MAUER(Feld[ux-1][uy]))
+ links_massiv = TRUE;
+ if (!IN_LEV_FIELD(ux+1,uy) || IS_MAUER(Feld[ux+1][uy]))
+ rechts_massiv = TRUE;
+
+ if (links_massiv && rechts_massiv)
+ graphic = GFX_MAUERWERK;
+ else if (links_massiv)
+ graphic = GFX_MAUER_R;
+ else if (rechts_massiv)
+ graphic = GFX_MAUER_L;
+ }
+
+ if (dx || dy)
+ DrawGraphicShifted(x,y, dx,dy, graphic, cut_mode, mask_mode);
+ else if (mask_mode == USE_MASKING)
+ DrawGraphicThruMask(x,y, graphic);
+ else
+ DrawGraphic(x,y, graphic);
+}
+
+void DrawLevelElementExt(int x, int y, int dx, int dy, int element,
+ int cut_mode, int mask_mode)
+{
+ if (IN_LEV_FIELD(x,y) && IN_SCR_FIELD(SCREENX(x),SCREENY(y)))
+ DrawScreenElementExt(SCREENX(x),SCREENY(y), dx,dy, element,
+ cut_mode, mask_mode);
+}
+
+void DrawScreenElementShifted(int x, int y, int dx, int dy, int element,
+ int cut_mode)
+{
+ DrawScreenElementExt(x,y, dx,dy, element, cut_mode, NO_MASKING);
+}
+
+void DrawLevelElementShifted(int x, int y, int dx, int dy, int element,
+ int cut_mode)
+{
+ DrawLevelElementExt(x,y, dx,dy, element, cut_mode, NO_MASKING);
+}
+
+void DrawScreenElementThruMask(int x, int y, int element)
+{
+ DrawScreenElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING);
+}
+
+void DrawLevelElementThruMask(int x, int y, int element)
+{
+ DrawLevelElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING);
+}
+
+void DrawLevelFieldThruMask(int x, int y)
+{
+ DrawLevelElementExt(x,y, 0,0, Feld[x][y], NO_CUTTING, USE_MASKING);
+}
+
+void ErdreichAnbroeckeln(int x, int y)