+ int jx = player->jx, jy = player->jy;
+ int last_jx = player->last_jx, last_jy = player->last_jy;
+ int next_jx = jx + (jx - last_jx), next_jy = jy + (jy - last_jy);
+ int sx = SCREENX(jx), sy = SCREENY(jy);
+ int sxx = 0, syy = 0;
+ int element = Feld[jx][jy];
+ int graphic, phase;
+
+ if (!player->active || player->gone ||
+ !IN_SCR_FIELD(SCREENX(last_jx),SCREENY(last_jy)))
+ return;
+
+#if DEBUG
+ if (!IN_LEV_FIELD(jx,jy))
+ {
+ printf("DrawPlayerField(): x = %d, y = %d\n",jx,jy);
+ printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
+ printf("DrawPlayerField(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ if (element == EL_EXPLODING)
+ return;
+
+ /* draw things in the field the player is leaving, if needed */
+
+ if (last_jx != jx || last_jy != jy)
+ {
+ if (Store[last_jx][last_jy])
+ {
+ DrawLevelElement(last_jx,last_jy, Store[last_jx][last_jy]);
+ DrawLevelFieldThruMask(last_jx,last_jy);
+ }
+ else if (Feld[last_jx][last_jy] == EL_DYNAMIT)
+ DrawDynamite(last_jx,last_jy);
+ else
+ DrawLevelField(last_jx,last_jy);
+
+ if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx),SCREENY(next_jy)))
+ {
+ if (player->GfxPos)
+ {
+ if (Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL)
+ DrawLevelElement(next_jx,next_jy, EL_SOKOBAN_FELD_LEER);
+ else
+ DrawLevelElement(next_jx,next_jy, EL_LEERRAUM);
+ }
+ else
+ DrawLevelField(next_jx,next_jy);
+ }
+ }
+
+ if (!IN_SCR_FIELD(sx,sy))
+ return;
+
+ if (setup.direct_draw)
+ SetDrawtoField(DRAW_BUFFERED);
+
+ /* draw things behind the player, if needed */
+
+ if (Store[jx][jy])
+ DrawLevelElement(jx,jy, Store[jx][jy]);
+ else if (element != EL_DYNAMIT && element != EL_DYNABOMB)
+ DrawLevelField(jx,jy);
+
+ /* draw player himself */
+
+ if (player->MovDir==MV_LEFT)
+ graphic = (player->Pushing ? GFX_SPIELER1_PUSH_LEFT : GFX_SPIELER1_LEFT);
+ else if (player->MovDir==MV_RIGHT)
+ graphic = (player->Pushing ? GFX_SPIELER1_PUSH_RIGHT : GFX_SPIELER1_RIGHT);
+ else if (player->MovDir==MV_UP)
+ graphic = GFX_SPIELER1_UP;
+ else /* MV_DOWN || MV_NO_MOVING */
+ graphic = GFX_SPIELER1_DOWN;
+
+ graphic += player->index_nr * 3*HEROES_PER_LINE;
+ graphic += player->Frame;
+
+ if (player->GfxPos)
+ {
+ if (player->MovDir == MV_LEFT || player->MovDir == MV_RIGHT)
+ sxx = player->GfxPos;
+ else
+ syy = player->GfxPos;
+ }
+
+ if (!setup.soft_scrolling && ScreenMovPos)
+ sxx = syy = 0;
+
+ DrawGraphicShiftedThruMask(sx,sy, sxx,syy, graphic, NO_CUTTING);
+
+ if (player->Pushing && player->GfxPos)
+ {
+ int px = SCREENX(next_jx), py = SCREENY(next_jy);
+
+ if (Feld[jx][jy] == EL_SOKOBAN_FELD_LEER ||
+ Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL)
+ DrawGraphicShiftedThruMask(px,py,sxx,syy, GFX_SOKOBAN_OBJEKT,NO_CUTTING);
+ else
+ {
+ int element = Feld[next_jx][next_jy];
+ int graphic = el2gfx(element);
+
+ if (element == EL_FELSBROCKEN && sxx)
+ {
+ int phase = (player->GfxPos / (TILEX/4));
+
+ if (player->MovDir == MV_LEFT)
+ graphic += phase;
+ else
+ graphic += (phase+4)%4;
+ }
+
+ DrawGraphicShifted(px,py, sxx,syy, graphic, NO_CUTTING, NO_MASKING);
+ }
+ }
+
+ /* draw things in front of player (EL_DYNAMIT || EL_DYNABOMB) */
+
+ if (element == EL_DYNAMIT || element == EL_DYNABOMB)
+ {
+ graphic = el2gfx(element);
+
+ if (element == EL_DYNAMIT)
+ {
+ if ((phase = (96-MovDelay[jx][jy])/12) > 6)
+ phase = 6;
+ }
+ else
+ {
+ if ((phase = ((96-MovDelay[jx][jy])/6) % 8) > 3)
+ phase = 7-phase;
+ }
+
+ DrawGraphicThruMask(sx,sy, graphic + phase);
+ }
+
+ if ((last_jx != jx || last_jy != jy) && Feld[last_jx][last_jy]==EL_EXPLODING)
+ {
+ int phase = Frame[last_jx][last_jy];
+ int delay = 2;
+
+ if (phase > 2)
+ DrawGraphicThruMask(SCREENX(last_jx),SCREENY(last_jy),
+ GFX_EXPLOSION + ((phase-1)/delay-1));
+ }
+
+ if (setup.direct_draw)
+ {
+ int dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX;
+ int dest_y = SY + SCREENY(MIN(jy,last_jy))*TILEY;
+ int x_size = TILEX * (1 + ABS(jx - last_jx));
+ int y_size = TILEY * (1 + ABS(jy - last_jy));
+
+ XCopyArea(display,drawto_field,window,gc,
+ dest_x,dest_y, x_size,y_size, dest_x,dest_y);
+ SetDrawtoField(DRAW_DIRECT);
+ }
+
+ MarkTileDirty(sx,sy);
+}
+
+static int getGraphicAnimationPhase(int frames, int delay, int mode)
+{
+ int phase;
+
+ if (mode == ANIM_OSCILLATE)
+ {
+ int max_anim_frames = frames*2 - 2;
+ phase = (FrameCounter % (delay * max_anim_frames)) / delay;
+ phase = (phase < frames ? phase : max_anim_frames - phase);
+ }
+ else
+ phase = (FrameCounter % (delay * frames)) / delay;
+
+ if (mode == ANIM_REVERSE)
+ phase = -phase;
+
+ return(phase);
+}
+
+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;