+ int x1, y1, x2, y2;
+
+ if (!ply->alive)
+ return;
+
+ /* x1/y1 are left/top and x2/y2 are right/down part of the player movement */
+ x1 = (frame * ply->oldx + (8 - frame) * ply->x) * TILEX / 8;
+ y1 = (frame * ply->oldy + (8 - frame) * ply->y) * TILEY / 8;
+ x2 = x1 + TILEX - 1;
+ y2 = y1 + TILEY - 1;
+
+ if ((int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) &&
+ (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1))
+ {
+ /* some casts to "int" are needed because of negative calculation values */
+ int dx = (int)ply->x - (int)ply->oldx;
+ int dy = (int)ply->y - (int)ply->oldy;
+ int old_x = (int)ply->oldx + (7 - (int)frame) * dx / 8;
+ int old_y = (int)ply->oldy + (7 - (int)frame) * dy / 8;
+ int new_x = old_x + SIGN(dx);
+ int new_y = old_y + SIGN(dy);
+ int old_sx = old_x % MAX_BUF_XSIZE;
+ int old_sy = old_y % MAX_BUF_XSIZE;
+ int new_sx = new_x % MAX_BUF_XSIZE;
+ int new_sy = new_y % MAX_BUF_XSIZE;
+#if 0
+ int old_crm = crumbled_state[old_sy][old_sx];
+#endif
+ int new_crm = crumbled_state[new_sy][new_sx];
+
+ /* only diggable elements can be crumbled in the classic EM engine */
+ boolean player_is_digging = (new_crm != 0);
+
+#if 0
+ x1 %= MAX_BUF_XSIZE * TILEX;
+ y1 %= MAX_BUF_YSIZE * TILEY;
+ x2 %= MAX_BUF_XSIZE * TILEX;
+ y2 %= MAX_BUF_YSIZE * TILEY;
+#endif
+
+ if (player_is_digging)
+ {
+#if 0
+ /* draw the field the player is moving from (under the player) */
+ DrawLevelField_EM(old_x, old_y, old_sx, old_sy, FALSE);
+ DrawLevelFieldCrumbled_EM(old_x, old_y, old_sx, old_sy, old_crm, FALSE);
+#endif
+
+ /* draw the field the player is moving to (under the player) */
+ DrawLevelField_EM(new_x, new_y, new_sx, new_sy, FALSE);
+ DrawLevelFieldCrumbled_EM(new_x, new_y, new_sx, new_sy, new_crm, FALSE);
+
+ /* draw the player (masked) over the element he is just digging away */
+ DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, TRUE);
+
+#if 1
+ /* draw the field the player is moving from (masked over the player) */
+ DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
+#endif
+ }
+ else
+ {
+ /* draw the player under the element which is on the same field */
+ DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, FALSE);
+
+ /* draw the field the player is moving from (masked over the player) */
+ DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
+
+ /* draw the field the player is moving to (masked over the player) */
+ DrawLevelField_EM(new_x, new_y, new_sx, new_sy, TRUE);
+ }
+
+ /* redraw screen tiles in the next frame (player may have left the tiles) */
+ screentiles[old_sy][old_sx] = -1;
+ screentiles[new_sy][new_sx] = -1;
+
+ /* mark screen tiles as dirty (force screen refresh with changed content) */
+ redraw[old_sx][old_sy] = TRUE;
+ redraw[new_sx][new_sy] = TRUE;
+ redraw_tiles += 2;
+ }
+}
+
+void game_initscreen(void)
+{
+ int x,y;
+ int dynamite_state = ply[0].dynamite; /* !!! ONLY PLAYER 1 !!! */
+ int all_keys_state = ply[0].keys | ply[1].keys | ply[2].keys | ply[3].keys;
+ int player_nr;
+
+ frame = 6;
+
+#if 0
+ game.centered_player_nr = getCenteredPlayerNr_EM();
+#endif
+
+ player_nr = (game.centered_player_nr != -1 ? game.centered_player_nr : 0);
+
+ screen_x = VALID_SCREEN_X(PLAYER_SCREEN_X(player_nr));
+ screen_y = VALID_SCREEN_Y(PLAYER_SCREEN_Y(player_nr));
+
+ for (y = 0; y < MAX_BUF_YSIZE; y++)
+ {
+ for (x = 0; x < MAX_BUF_XSIZE; x++)
+ {
+ screentiles[y][x] = -1;
+ crumbled_state[y][x] = 0;
+ }
+ }
+
+ DrawAllGameValues(lev.required, dynamite_state, lev.score,
+ lev.time, all_keys_state);
+}
+
+#if 0
+void DrawRelocatePlayer(struct PlayerInfo *player, boolean quick_relocation)
+{
+ boolean ffwd_delay = (tape.playing && tape.fast_forward);
+ boolean no_delay = (tape.warp_forward);
+ int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
+ int wait_delay_value = (no_delay ? 0 : frame_delay_value);
+ int jx = player->jx;
+ int jy = player->jy;
+
+ if (quick_relocation)
+ {
+ int offset = (setup.scroll_delay ? 3 : 0);
+
+ if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
+ {
+ scroll_x = (player->jx < SBX_Left + MIDPOSX ? SBX_Left :
+ player->jx > SBX_Right + MIDPOSX ? SBX_Right :
+ player->jx - MIDPOSX);
+
+ scroll_y = (player->jy < SBY_Upper + MIDPOSY ? SBY_Upper :
+ player->jy > SBY_Lower + MIDPOSY ? SBY_Lower :
+ player->jy - MIDPOSY);
+ }
+ else
+ {
+ if ((player->MovDir == MV_LEFT && scroll_x > jx - MIDPOSX + offset) ||
+ (player->MovDir == MV_RIGHT && scroll_x < jx - MIDPOSX - offset))
+ scroll_x = jx - MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
+
+ if ((player->MovDir == MV_UP && scroll_y > jy - MIDPOSY + offset) ||
+ (player->MovDir == MV_DOWN && scroll_y < jy - MIDPOSY - offset))
+ scroll_y = jy - MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
+
+ /* don't scroll over playfield boundaries */
+ if (scroll_x < SBX_Left || scroll_x > SBX_Right)
+ scroll_x = (scroll_x < SBX_Left ? SBX_Left : SBX_Right);
+
+ /* don't scroll over playfield boundaries */
+ if (scroll_y < SBY_Upper || scroll_y > SBY_Lower)
+ scroll_y = (scroll_y < SBY_Upper ? SBY_Upper : SBY_Lower);
+ }