1 /* 2000-08-13T14:36:17Z
3 * graphics manipulation crap
8 #define MIN_SCREEN_XPOS_RAW 0
9 #define MIN_SCREEN_YPOS_RAW 0
10 #define MAX_SCREEN_XPOS_RAW MAX(0, lev.width - SCR_FIELDX)
11 #define MAX_SCREEN_YPOS_RAW MAX(0, lev.height - SCR_FIELDY)
13 #define MIN_SCREEN_XPOS (MIN_SCREEN_XPOS_RAW + CAVE_BUFFER_XOFFSET)
14 #define MIN_SCREEN_YPOS (MIN_SCREEN_YPOS_RAW + CAVE_BUFFER_YOFFSET)
15 #define MAX_SCREEN_XPOS (MAX_SCREEN_XPOS_RAW + CAVE_BUFFER_XOFFSET)
16 #define MAX_SCREEN_YPOS (MAX_SCREEN_YPOS_RAW + CAVE_BUFFER_YOFFSET)
18 #define MIN_SCREEN_X (MIN_SCREEN_XPOS * TILEX)
19 #define MIN_SCREEN_Y (MIN_SCREEN_YPOS * TILEY)
20 #define MAX_SCREEN_X (MAX_SCREEN_XPOS * TILEX)
21 #define MAX_SCREEN_Y (MAX_SCREEN_YPOS * TILEY)
23 #define VALID_SCREEN_X(x) ((x) < MIN_SCREEN_X ? MIN_SCREEN_X : \
24 (x) > MAX_SCREEN_X ? MAX_SCREEN_X : (x))
25 #define VALID_SCREEN_Y(y) ((y) < MIN_SCREEN_Y ? MIN_SCREEN_Y : \
26 (y) > MAX_SCREEN_Y ? MAX_SCREEN_Y : (y))
28 #define PLAYER_POS_X(nr) (((7 - frame) * ply[nr].oldx + \
29 (1 + frame) * ply[nr].x) * TILEX / 8)
30 #define PLAYER_POS_Y(nr) (((7 - frame) * ply[nr].oldy + \
31 (1 + frame) * ply[nr].y) * TILEY / 8)
33 #define PLAYER_SCREEN_X(nr) (PLAYER_POS_X(nr) - \
34 (SCR_FIELDX - 1) * TILEX / 2)
35 #define PLAYER_SCREEN_Y(nr) (PLAYER_POS_Y(nr) - \
36 (SCR_FIELDY - 1) * TILEY / 2)
38 #define USE_EXTENDED_GRAPHICS_ENGINE 1
41 int frame; /* current screen frame */
42 int screen_x, screen_y; /* current scroll position */
44 /* tiles currently on screen */
45 static int screen_tiles[MAX_PLAYFIELD_WIDTH + 2][MAX_PLAYFIELD_HEIGHT + 2];
46 static int crumbled_state[MAX_PLAYFIELD_WIDTH + 2][MAX_PLAYFIELD_HEIGHT + 2];
48 /* graphic info for game objects/frames and players/actions/frames */
49 struct GraphicInfo_EM graphic_info_em_object[GAME_TILE_MAX][8];
50 struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][PLY_MAX][8];
52 int getFieldbufferOffsetX_EM(void)
54 return screen_x % TILEX;
57 int getFieldbufferOffsetY_EM(void)
59 return screen_y % TILEY;
62 void BlitScreenToBitmap_EM(Bitmap *target_bitmap)
64 /* blit all (up to four) parts of the scroll buffer to the target bitmap */
66 int x = screen_x % (MAX_BUF_XSIZE * TILEX);
67 int y = screen_y % (MAX_BUF_YSIZE * TILEY);
70 int full_xsize = lev.width * TILEX;
71 int full_ysize = lev.height * TILEY;
72 int sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
73 int sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
74 int sxsize = (full_xsize < xsize ? full_xsize : xsize);
75 int sysize = (full_ysize < ysize ? full_ysize : ysize);
76 int xxsize = MAX_BUF_XSIZE * TILEX - x;
77 int yysize = MAX_BUF_YSIZE * TILEY - y;
78 int xoffset = 2 * CAVE_BUFFER_XOFFSET * TILEX;
79 int yoffset = 2 * CAVE_BUFFER_YOFFSET * TILEY;
81 if (x < xoffset && y < yoffset)
83 BlitBitmap(screenBitmap, target_bitmap, x, y, sxsize, sysize,
86 else if (x < xoffset && y >= yoffset)
88 BlitBitmap(screenBitmap, target_bitmap, x, y, sxsize, yysize,
90 BlitBitmap(screenBitmap, target_bitmap, x, 0, sxsize, y - yoffset,
93 else if (x >= xoffset && y < yoffset)
95 BlitBitmap(screenBitmap, target_bitmap, x, y, xxsize, sysize,
97 BlitBitmap(screenBitmap, target_bitmap, 0, y, x - xoffset, sysize,
102 BlitBitmap(screenBitmap, target_bitmap, x, y, xxsize, yysize,
104 BlitBitmap(screenBitmap, target_bitmap, 0, y, x - xoffset, yysize,
106 BlitBitmap(screenBitmap, target_bitmap, x, 0, xxsize, y - yoffset,
108 BlitBitmap(screenBitmap, target_bitmap, 0, 0, x - xoffset, y - yoffset,
109 sx + xxsize, sy + yysize);
113 static void BackToFront_EM(void)
115 BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY);
118 static struct GraphicInfo_EM *getObjectGraphic(int x, int y)
120 int tile = lev.draw[x][y];
121 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
123 if (!game.use_native_emc_graphics_engine)
124 getGraphicSourceObjectExt_EM(g, tile, frame, x - lev.left, y - lev.top);
129 static struct GraphicInfo_EM *getPlayerGraphic(int player_nr, int anim)
131 struct GraphicInfo_EM *g = &graphic_info_em_player[player_nr][anim][frame];
133 if (!game.use_native_emc_graphics_engine)
134 getGraphicSourcePlayerExt_EM(g, player_nr, anim, frame);
139 static void DrawLevelField_EM(int x, int y, int sx, int sy,
142 struct GraphicInfo_EM *g = getObjectGraphic(x, y);
143 int src_x = g->src_x + g->src_offset_x * TILESIZE_VAR / TILESIZE;
144 int src_y = g->src_y + g->src_offset_y * TILESIZE_VAR / TILESIZE;
145 int dst_x = sx * TILEX + g->dst_offset_x * TILESIZE_VAR / TILESIZE;
146 int dst_y = sy * TILEY + g->dst_offset_y * TILESIZE_VAR / TILESIZE;
147 int width = g->width * TILESIZE_VAR / TILESIZE;
148 int height = g->height * TILESIZE_VAR / TILESIZE;
149 int left = screen_x / TILEX;
150 int top = screen_y / TILEY;
152 /* do not draw fields that are outside the visible screen area */
153 if (x < left || x >= left + MAX_BUF_XSIZE ||
154 y < top || y >= top + MAX_BUF_YSIZE)
159 if (width > 0 && height > 0)
160 BlitBitmapMasked(g->bitmap, screenBitmap,
161 src_x, src_y, width, height, dst_x, dst_y);
165 if ((width != TILEX || height != TILEY) && !g->preserve_background)
166 ClearRectangle(screenBitmap, sx * TILEX, sy * TILEY, TILEX, TILEY);
168 if (width > 0 && height > 0)
169 BlitBitmap(g->bitmap, screenBitmap,
170 src_x, src_y, width, height, dst_x, dst_y);
174 static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy,
175 int crm, boolean draw_masked)
177 struct GraphicInfo_EM *g;
178 int crumbled_border_size;
179 int left = screen_x / TILEX;
180 int top = screen_y / TILEY;
183 /* do not draw fields that are outside the visible screen area */
184 if (x < left || x >= left + MAX_BUF_XSIZE ||
185 y < top || y >= top + MAX_BUF_YSIZE)
188 if (crm == 0) /* no crumbled edges for this tile */
191 g = getObjectGraphic(x, y);
193 crumbled_border_size =
194 g->crumbled_border_size * TILESIZE_VAR / g->crumbled_tile_size;
196 for (i = 0; i < 4; i++)
200 int width, height, cx, cy;
202 if (i == 1 || i == 2)
204 width = crumbled_border_size;
206 cx = (i == 2 ? TILEX - crumbled_border_size : 0);
212 height = crumbled_border_size;
214 cy = (i == 3 ? TILEY - crumbled_border_size : 0);
217 if (width > 0 && height > 0)
219 int src_x = g->crumbled_src_x + cx;
220 int src_y = g->crumbled_src_y + cy;
221 int dst_x = sx * TILEX + cx;
222 int dst_y = sy * TILEY + cy;
225 BlitBitmapMasked(g->crumbled_bitmap, screenBitmap,
226 src_x, src_y, width, height, dst_x, dst_y);
228 BlitBitmap(g->crumbled_bitmap, screenBitmap,
229 src_x, src_y, width, height, dst_x, dst_y);
235 static void DrawLevelPlayer_EM(int x1, int y1, int player_nr, int anim,
238 struct GraphicInfo_EM *g = getPlayerGraphic(player_nr, anim);
239 int src_x = g->src_x, src_y = g->src_y;
242 /* do not draw fields that are outside the visible screen area */
243 if (x1 < screen_x - TILEX || x1 >= screen_x + MAX_BUF_XSIZE * TILEX ||
244 y1 < screen_y - TILEY || y1 >= screen_y + MAX_BUF_YSIZE * TILEY)
247 x1 %= MAX_BUF_XSIZE * TILEX;
248 y1 %= MAX_BUF_YSIZE * TILEY;
252 /* draw the player to current location */
255 BlitBitmapMasked(g->bitmap, screenBitmap,
256 src_x, src_y, TILEX, TILEY, dst_x, dst_y);
258 /* draw the player to opposite wrap-around column */
259 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
261 BlitBitmapMasked(g->bitmap, screenBitmap,
262 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
264 /* draw the player to opposite wrap-around row */
266 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
267 BlitBitmapMasked(g->bitmap, screenBitmap,
268 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
272 /* draw the player to current location */
275 BlitBitmap(g->bitmap, screenBitmap,
276 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
278 /* draw the player to opposite wrap-around column */
279 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
281 BlitBitmap(g->bitmap, screenBitmap,
282 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
284 /* draw the player to opposite wrap-around row */
286 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
287 BlitBitmap(g->bitmap, screenBitmap,
288 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
292 /* draw differences between game tiles and screen tiles
294 * implicitly handles scrolling and restoring background under the sprites
297 static void animscreen(void)
300 int left = screen_x / TILEX;
301 int top = screen_y / TILEY;
302 static int xy[4][2] =
310 if (!game.use_native_emc_graphics_engine)
311 for (y = lev.top; y < lev.bottom; y++)
312 for (x = lev.left; x < lev.right; x++)
313 SetGfxAnimation_EM(&graphic_info_em_object[lev.draw[x][y]][frame],
314 lev.draw[x][y], frame,
315 x - lev.left, y - lev.top);
317 for (y = top; y < top + MAX_BUF_YSIZE; y++)
319 for (x = left; x < left + MAX_BUF_XSIZE; x++)
321 int sx = x % MAX_BUF_XSIZE;
322 int sy = y % MAX_BUF_YSIZE;
323 int tile = lev.draw[x][y];
324 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
325 int obj = g->unique_identifier;
327 boolean redraw_screen_tile = FALSE;
329 /* re-calculate crumbled state of this tile */
330 if (g->has_crumbled_graphics)
332 for (i = 0; i < 4; i++)
334 int xx = x + xy[i][0];
335 int yy = y + xy[i][1];
338 if (xx < 0 || xx >= CAVE_BUFFER_WIDTH ||
339 yy < 0 || yy >= CAVE_BUFFER_HEIGHT)
342 tile_next = lev.draw[xx][yy];
344 if (!graphic_info_em_object[tile_next][frame].has_crumbled_graphics)
349 redraw_screen_tile = (screen_tiles[sx][sy] != obj ||
350 crumbled_state[sx][sy] != crm);
352 /* only redraw screen tiles if they (or their crumbled state) changed */
353 if (redraw_screen_tile)
355 DrawLevelField_EM(x, y, sx, sy, FALSE);
356 DrawLevelFieldCrumbled_EM(x, y, sx, sy, crm, FALSE);
358 screen_tiles[sx][sy] = obj;
359 crumbled_state[sx][sy] = crm;
366 /* blit players to the screen
368 * handles transparency and movement
371 static void blitplayer(int nr)
378 /* x1/y1 are left/top and x2/y2 are right/down part of the player movement */
379 x1 = PLAYER_POS_X(nr);
380 y1 = PLAYER_POS_Y(nr);
384 if ((int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) &&
385 (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1))
387 /* some casts to "int" are needed because of negative calculation values */
388 int dx = (int)ply[nr].x - (int)ply[nr].oldx;
389 int dy = (int)ply[nr].y - (int)ply[nr].oldy;
390 int old_x = (int)ply[nr].oldx + (int)frame * dx / 8;
391 int old_y = (int)ply[nr].oldy + (int)frame * dy / 8;
392 int new_x = old_x + SIGN(dx);
393 int new_y = old_y + SIGN(dy);
394 int old_sx = old_x % MAX_BUF_XSIZE;
395 int old_sy = old_y % MAX_BUF_YSIZE;
396 int new_sx = new_x % MAX_BUF_XSIZE;
397 int new_sy = new_y % MAX_BUF_YSIZE;
398 int new_crm = crumbled_state[new_sx][new_sy];
400 /* only diggable elements can be crumbled in the classic EM engine */
401 boolean player_is_digging = (new_crm != 0);
403 if (player_is_digging)
405 /* draw the field the player is moving to (under the player) */
406 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, FALSE);
407 DrawLevelFieldCrumbled_EM(new_x, new_y, new_sx, new_sy, new_crm, FALSE);
409 /* draw the player (masked) over the element he is just digging away */
410 DrawLevelPlayer_EM(x1, y1, ply[nr].num, ply[nr].anim, TRUE);
412 /* draw the field the player is moving from (masked over the player) */
413 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
417 /* draw the player under the element which is on the same field */
418 DrawLevelPlayer_EM(x1, y1, ply[nr].num, ply[nr].anim, FALSE);
420 /* draw the field the player is moving from (masked over the player) */
421 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
423 /* draw the field the player is moving to (masked over the player) */
424 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, TRUE);
427 /* redraw screen tiles in the next frame (player may have left the tiles) */
428 screen_tiles[old_sx][old_sy] = -1;
429 screen_tiles[new_sx][new_sy] = -1;
433 void game_initscreen(void)
440 player_nr = (game.centered_player_nr != -1 ? game.centered_player_nr : 0);
442 screen_x = VALID_SCREEN_X(PLAYER_SCREEN_X(player_nr));
443 screen_y = VALID_SCREEN_Y(PLAYER_SCREEN_Y(player_nr));
445 for (y = 0; y < MAX_BUF_YSIZE; y++)
447 for (x = 0; x < MAX_BUF_XSIZE; x++)
449 screen_tiles[x][y] = -1;
450 crumbled_state[x][y] = 0;
455 static int getMaxCenterDistancePlayerNr(int center_x, int center_y)
457 int max_dx = 0, max_dy = 0;
458 int player_nr = game_em.last_moving_player;
461 for (i = 0; i < MAX_PLAYERS; i++)
465 int sx = PLAYER_SCREEN_X(i);
466 int sy = PLAYER_SCREEN_Y(i);
468 if (game_em.last_player_direction[i] != MV_NONE &&
469 (ABS(sx - center_x) > max_dx ||
470 ABS(sy - center_y) > max_dy))
472 max_dx = MAX(max_dx, ABS(sx - center_x));
473 max_dy = MAX(max_dy, ABS(sy - center_y));
483 static void setMinimalPlayerBoundaries(int *sx1, int *sy1, int *sx2, int *sy2)
485 boolean num_checked_players = 0;
488 for (i = 0; i < MAX_PLAYERS; i++)
492 int sx = PLAYER_SCREEN_X(i);
493 int sy = PLAYER_SCREEN_Y(i);
495 if (num_checked_players == 0)
502 *sx1 = MIN(*sx1, sx);
503 *sy1 = MIN(*sy1, sy);
504 *sx2 = MAX(*sx2, sx);
505 *sy2 = MAX(*sy2, sy);
508 num_checked_players++;
513 boolean checkIfAllPlayersFitToScreen(void)
515 int sx1 = 0, sy1 = 0, sx2 = 0, sy2 = 0;
517 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
519 return (sx2 - sx1 <= SCR_FIELDX * TILEX &&
520 sy2 - sy1 <= SCR_FIELDY * TILEY);
523 static void setScreenCenteredToAllPlayers(int *sx, int *sy)
525 int sx1 = screen_x, sy1 = screen_y, sx2 = screen_x, sy2 = screen_y;
527 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
529 *sx = (sx1 + sx2) / 2;
530 *sy = (sy1 + sy2) / 2;
533 static void setMaxCenterDistanceForAllPlayers(int *max_dx, int *max_dy,
534 int center_x, int center_y)
536 int sx1 = center_x, sy1 = center_y, sx2 = center_x, sy2 = center_y;
538 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
540 *max_dx = MAX(ABS(sx1 - center_x), ABS(sx2 - center_x));
541 *max_dy = MAX(ABS(sy1 - center_y), ABS(sy2 - center_y));
544 static boolean checkIfAllPlayersAreVisible(int center_x, int center_y)
548 setMaxCenterDistanceForAllPlayers(&max_dx, &max_dy, center_x, center_y);
550 return (max_dx <= SCR_FIELDX * TILEX / 2 &&
551 max_dy <= SCR_FIELDY * TILEY / 2);
554 void RedrawPlayfield_EM(boolean force_redraw)
556 boolean draw_new_player_location = FALSE;
557 boolean draw_new_player_location_fast = FALSE;
558 boolean quick_relocation = setup.quick_switch;
559 int max_center_distance_player_nr =
560 getMaxCenterDistancePlayerNr(screen_x, screen_y);
561 int stepsize = TILEX / 8;
562 int offset_raw = game.scroll_delay_value;
563 int offset_x = MIN(offset_raw, (SCR_FIELDX - 2) / 2) * TILEX;
564 int offset_y = MIN(offset_raw, (SCR_FIELDY - 2) / 2) * TILEY;
565 int screen_x_old = screen_x;
566 int screen_y_old = screen_y;
570 if (game.set_centered_player)
572 boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen();
574 /* switching to "all players" only possible if all players fit to screen */
575 if (game.centered_player_nr_next == -1 && !all_players_fit_to_screen)
577 game.centered_player_nr_next = game.centered_player_nr;
578 game.set_centered_player = FALSE;
581 /* do not switch focus to non-existing (or non-active) player */
582 if (game.centered_player_nr_next >= 0 &&
583 !ply[game.centered_player_nr_next].alive)
585 game.centered_player_nr_next = game.centered_player_nr;
586 game.set_centered_player = FALSE;
590 /* also allow focus switching when screen is scrolled to half tile */
591 if (game.set_centered_player)
593 game.centered_player_nr = game.centered_player_nr_next;
595 draw_new_player_location = TRUE;
596 draw_new_player_location_fast = game.set_centered_player_fast;
599 game.set_centered_player = FALSE;
600 game.set_centered_player_fast = FALSE;
603 if (game.centered_player_nr == -1)
605 if (draw_new_player_location || offset_raw == 0)
607 setScreenCenteredToAllPlayers(&sx, &sy);
611 sx = PLAYER_SCREEN_X(max_center_distance_player_nr);
612 sy = PLAYER_SCREEN_Y(max_center_distance_player_nr);
617 sx = PLAYER_SCREEN_X(game.centered_player_nr);
618 sy = PLAYER_SCREEN_Y(game.centered_player_nr);
621 if (draw_new_player_location && quick_relocation)
623 screen_x = VALID_SCREEN_X(sx);
624 screen_y = VALID_SCREEN_Y(sy);
625 screen_x_old = screen_x;
626 screen_y_old = screen_y;
629 if (draw_new_player_location && !quick_relocation)
631 unsigned int frame_delay_value_old = GetVideoFrameDelay();
632 int wait_delay_value = frame_delay_value_old;
633 int screen_xx = VALID_SCREEN_X(sx);
634 int screen_yy = VALID_SCREEN_Y(sy);
636 if (draw_new_player_location_fast)
637 wait_delay_value /= 4;
639 SetVideoFrameDelay(wait_delay_value);
641 while (screen_x != screen_xx || screen_y != screen_yy)
643 int dx = (screen_xx < screen_x ? +1 : screen_xx > screen_x ? -1 : 0);
644 int dy = (screen_yy < screen_y ? +1 : screen_yy > screen_y ? -1 : 0);
645 int dxx = 0, dyy = 0;
647 if (dx == 0 && dy == 0) /* no scrolling needed at all */
650 if (ABS(screen_xx - screen_x) >= TILEX)
652 screen_x -= dx * TILEX;
653 dxx = dx * TILEX / 2;
657 screen_x = screen_xx;
661 if (ABS(screen_yy - screen_y) >= TILEY)
663 screen_y -= dy * TILEY;
664 dyy = dy * TILEY / 2;
668 screen_y = screen_yy;
672 /* scroll in two steps of half tile size to make things smoother */
678 for (i = 0; i < MAX_PLAYERS; i++)
681 BlitScreenToBitmap_EM(backbuffer);
684 /* scroll second step to align at full tile size */
690 for (i = 0; i < MAX_PLAYERS; i++)
693 BlitScreenToBitmap_EM(backbuffer);
697 SetVideoFrameDelay(frame_delay_value_old);
699 screen_x_old = screen_x;
700 screen_y_old = screen_y;
705 for (y = 0; y < MAX_BUF_YSIZE; y++)
707 for (x = 0; x < MAX_BUF_XSIZE; x++)
709 screen_tiles[x][y] = -1;
710 crumbled_state[x][y] = 0;
715 /* calculate new screen scrolling position, with regard to scroll delay */
716 screen_x = VALID_SCREEN_X(sx + offset_x < screen_x ? sx + offset_x :
717 sx - offset_x > screen_x ? sx - offset_x :
719 screen_y = VALID_SCREEN_Y(sy + offset_y < screen_y ? sy + offset_y :
720 sy - offset_y > screen_y ? sy - offset_y :
723 /* prevent scrolling further than double player step size when scrolling */
724 if (ABS(screen_x - screen_x_old) > 2 * stepsize)
726 int dx = SIGN(screen_x - screen_x_old);
728 screen_x = screen_x_old + dx * 2 * stepsize;
730 if (ABS(screen_y - screen_y_old) > 2 * stepsize)
732 int dy = SIGN(screen_y - screen_y_old);
734 screen_y = screen_y_old + dy * 2 * stepsize;
737 /* prevent scrolling away from the other players when focus on all players */
738 if (game.centered_player_nr == -1)
740 /* check if all players are still visible with new scrolling position */
741 if (checkIfAllPlayersAreVisible(screen_x_old, screen_y_old) &&
742 !checkIfAllPlayersAreVisible(screen_x, screen_y))
744 /* reset horizontal scroll position to last value, if needed */
745 if (!checkIfAllPlayersAreVisible(screen_x, screen_y_old))
746 screen_x = screen_x_old;
748 /* reset vertical scroll position to last value, if needed */
749 if (!checkIfAllPlayersAreVisible(screen_x_old, screen_y))
750 screen_y = screen_y_old;
754 /* prevent scrolling (for screen correcting) if no player is moving */
755 if (!game_em.any_player_moving)
757 screen_x = screen_x_old;
758 screen_y = screen_y_old;
762 /* prevent scrolling against the players move direction */
763 int player_nr = (game.centered_player_nr == -1 ?
764 max_center_distance_player_nr : game.centered_player_nr);
765 int player_move_dir = game_em.last_player_direction[player_nr];
766 int dx = SIGN(screen_x - screen_x_old);
767 int dy = SIGN(screen_y - screen_y_old);
769 if ((dx < 0 && player_move_dir != MV_LEFT) ||
770 (dx > 0 && player_move_dir != MV_RIGHT))
771 screen_x = screen_x_old;
773 if ((dy < 0 && player_move_dir != MV_UP) ||
774 (dy > 0 && player_move_dir != MV_DOWN))
775 screen_y = screen_y_old;
778 // skip redrawing playfield in warp mode or when testing tapes with "autotest"
779 if (DrawingDeactivatedField())
784 for (i = 0; i < MAX_PLAYERS; i++)