+ 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], last_element = Feld[last_jx][last_jy];
+ int graphic, phase;
+ boolean player_is_moving = (last_jx != jx || last_jy != jy ? TRUE : FALSE);
+
+ 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 (player_is_moving)
+ {
+ if (Store[last_jx][last_jy] && IS_DRAWABLE(last_element))
+ {
+ DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]);
+ DrawLevelFieldThruMask(last_jx, last_jy);
+ }
+ else if (last_element == 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 (game_emulation == EMU_SUPAPLEX)
+ {
+ static int last_dir = MV_LEFT;
+ boolean action_moving =
+ (player_is_moving ||
+ ((player->action & (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)) &&
+ !(player->action & ~(MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN))));
+
+ graphic = GFX_SP_MURPHY;
+
+ if (player->Pushing)
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic = GFX_MURPHY_PUSH_LEFT;
+ else if (player->MovDir == MV_RIGHT)
+ graphic = GFX_MURPHY_PUSH_RIGHT;
+ else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_LEFT)
+ graphic = GFX_MURPHY_PUSH_LEFT;
+ else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_RIGHT)
+ graphic = GFX_MURPHY_PUSH_RIGHT;
+ }
+ else if (player->snapped)
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic = GFX_MURPHY_SNAP_LEFT;
+ else if (player->MovDir == MV_RIGHT)
+ graphic = GFX_MURPHY_SNAP_RIGHT;
+ else if (player->MovDir == MV_UP)
+ graphic = GFX_MURPHY_SNAP_UP;
+ else if (player->MovDir == MV_DOWN)
+ graphic = GFX_MURPHY_SNAP_DOWN;
+ }
+ else if (action_moving)
+ {
+ if (player->MovDir == MV_LEFT)
+ graphic = GFX_MURPHY_GO_LEFT;
+ else if (player->MovDir == MV_RIGHT)
+ graphic = GFX_MURPHY_GO_RIGHT;
+ else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_LEFT)
+ graphic = GFX_MURPHY_GO_LEFT;
+ else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_RIGHT)
+ graphic = GFX_MURPHY_GO_RIGHT;
+
+ graphic += getGraphicAnimationPhase(3, 2, ANIM_OSCILLATE);
+ }
+
+ if (player->MovDir == MV_LEFT || player->MovDir == MV_RIGHT)
+ last_dir = player->MovDir;
+ }
+ else
+ {
+ 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 (element == 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 || element == EL_SP_ZONK) && 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 or 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;
+ }
+
+ if (game_emulation == EMU_SUPAPLEX)
+ DrawGraphic(sx, sy, GFX_SP_DISK_RED);
+ else
+ DrawGraphicThruMask(sx, sy, graphic + phase);
+ }
+
+ /*
+ if ((last_jx != jx || last_jy != jy) && last_element == EL_EXPLODING)
+ */
+
+ if (player_is_moving && last_element == 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));
+ }
+
+ /* draw elements that stay over the player */
+ /* handle the field the player is leaving ... */
+ if (player_is_moving && IS_OVER_PLAYER(last_element))
+ DrawLevelField(last_jx, last_jy);
+ /* ... and the field the player is entering */
+ if (IS_OVER_PLAYER(element))
+ DrawLevelField(jx, jy);
+
+ 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);