1 /* 2000-08-13T14:36:17Z
3 * graphics manipulation crap
8 #define MIN_SCREEN_XPOS 1
9 #define MIN_SCREEN_YPOS 1
10 #define MAX_SCREEN_XPOS MAX(1, lev.width - (SCR_FIELDX - 1))
11 #define MAX_SCREEN_YPOS MAX(1, lev.height - (SCR_FIELDY - 1))
13 #define MIN_SCREEN_X (MIN_SCREEN_XPOS * TILEX)
14 #define MIN_SCREEN_Y (MIN_SCREEN_YPOS * TILEY)
15 #define MAX_SCREEN_X (MAX_SCREEN_XPOS * TILEX)
16 #define MAX_SCREEN_Y (MAX_SCREEN_YPOS * TILEY)
18 #define VALID_SCREEN_X(x) ((x) < MIN_SCREEN_X ? MIN_SCREEN_X : \
19 (x) > MAX_SCREEN_X ? MAX_SCREEN_X : (x))
20 #define VALID_SCREEN_Y(y) ((y) < MIN_SCREEN_Y ? MIN_SCREEN_Y : \
21 (y) > MAX_SCREEN_Y ? MAX_SCREEN_Y : (y))
23 #define PLAYER_SCREEN_X(p) ((( frame) * ply[p].oldx + \
24 (8 - frame) * ply[p].x) * TILEX / 8 \
25 - ((SCR_FIELDX - 1) * TILEX) / 2)
26 #define PLAYER_SCREEN_Y(p) ((( frame) * ply[p].oldy + \
27 (8 - frame) * ply[p].y) * TILEY / 8 \
28 - ((SCR_FIELDY - 1) * TILEY) / 2)
30 #define USE_EXTENDED_GRAPHICS_ENGINE 1
33 int frame; /* current screen frame */
34 int screen_x, screen_y; /* current scroll position */
36 /* tiles currently on screen */
37 static int screentiles[MAX_PLAYFIELD_HEIGHT + 2][MAX_PLAYFIELD_WIDTH + 2];
38 static int crumbled_state[MAX_PLAYFIELD_HEIGHT + 2][MAX_PLAYFIELD_WIDTH + 2];
40 int getFieldbufferOffsetX_EM()
42 return screen_x % TILEX;
45 int getFieldbufferOffsetY_EM()
47 return screen_y % TILEY;
50 void BlitScreenToBitmap_EM(Bitmap *target_bitmap)
52 /* blit all (up to four) parts of the scroll buffer to the target bitmap */
54 int x = screen_x % (MAX_BUF_XSIZE * TILEX);
55 int y = screen_y % (MAX_BUF_YSIZE * TILEY);
58 int full_xsize = lev.width * TILEX;
59 int full_ysize = lev.height * TILEY;
60 int sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
61 int sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
62 int sxsize = (full_xsize < xsize ? full_xsize : xsize);
63 int sysize = (full_ysize < ysize ? full_ysize : ysize);
65 if (x < 2 * TILEX && y < 2 * TILEY)
67 BlitBitmap(screenBitmap, target_bitmap, x, y,
68 sxsize, sysize, sx, sy);
70 else if (x < 2 * TILEX && y >= 2 * TILEY)
72 BlitBitmap(screenBitmap, target_bitmap, x, y,
73 sxsize, MAX_BUF_YSIZE * TILEY - y,
75 BlitBitmap(screenBitmap, target_bitmap, x, 0,
76 sxsize, y - 2 * TILEY,
77 sx, sy + MAX_BUF_YSIZE * TILEY - y);
79 else if (x >= 2 * TILEX && y < 2 * TILEY)
81 BlitBitmap(screenBitmap, target_bitmap, x, y,
82 MAX_BUF_XSIZE * TILEX - x, sysize,
84 BlitBitmap(screenBitmap, target_bitmap, 0, y,
85 x - 2 * TILEX, sysize,
86 sx + MAX_BUF_XSIZE * TILEX - x, sy);
90 BlitBitmap(screenBitmap, target_bitmap, x, y,
91 MAX_BUF_XSIZE * TILEX - x, MAX_BUF_YSIZE * TILEY - y,
93 BlitBitmap(screenBitmap, target_bitmap, 0, y,
94 x - 2 * TILEX, MAX_BUF_YSIZE * TILEY - y,
95 sx + MAX_BUF_XSIZE * TILEX - x, sy);
96 BlitBitmap(screenBitmap, target_bitmap, x, 0,
97 MAX_BUF_XSIZE * TILEX - x, y - 2 * TILEY,
98 sx, sy + MAX_BUF_YSIZE * TILEY - y);
99 BlitBitmap(screenBitmap, target_bitmap, 0, 0,
100 x - 2 * TILEX, y - 2 * TILEY,
101 sx + MAX_BUF_XSIZE * TILEX - x, sy + MAX_BUF_YSIZE * TILEY - y);
105 void BackToFront_EM(void)
107 BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY);
110 static struct GraphicInfo_EM *getObjectGraphic(int x, int y)
112 int tile = Draw[y][x];
113 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
115 if (!game.use_native_emc_graphics_engine)
116 getGraphicSourceObjectExt_EM(g, tile, 7 - frame, x - 2, y - 2);
121 static struct GraphicInfo_EM *getPlayerGraphic(int player_nr, int anim)
123 struct GraphicInfo_EM *g = &graphic_info_em_player[player_nr][anim][frame];
125 if (!game.use_native_emc_graphics_engine)
126 getGraphicSourcePlayerExt_EM(g, player_nr, anim, 7 - frame);
131 static void DrawLevelField_EM(int x, int y, int sx, int sy,
134 struct GraphicInfo_EM *g = getObjectGraphic(x, y);
135 int src_x = g->src_x + g->src_offset_x * TILESIZE_VAR / TILESIZE;
136 int src_y = g->src_y + g->src_offset_y * TILESIZE_VAR / TILESIZE;
137 int dst_x = sx * TILEX + g->dst_offset_x * TILESIZE_VAR / TILESIZE;
138 int dst_y = sy * TILEY + g->dst_offset_y * TILESIZE_VAR / TILESIZE;
139 int width = g->width * TILESIZE_VAR / TILESIZE;
140 int height = g->height * TILESIZE_VAR / TILESIZE;
141 int left = screen_x / TILEX;
142 int top = screen_y / TILEY;
144 /* do not draw fields that are outside the visible screen area */
145 if (x < left || x >= left + MAX_BUF_XSIZE ||
146 y < top || y >= top + MAX_BUF_YSIZE)
151 if (width > 0 && height > 0)
152 BlitBitmapMasked(g->bitmap, screenBitmap,
153 src_x, src_y, width, height, dst_x, dst_y);
157 if ((width != TILEX || height != TILEY) && !g->preserve_background)
158 ClearRectangle(screenBitmap, sx * TILEX, sy * TILEY, TILEX, TILEY);
160 if (width > 0 && height > 0)
161 BlitBitmap(g->bitmap, screenBitmap,
162 src_x, src_y, width, height, dst_x, dst_y);
166 static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy,
167 int crm, boolean draw_masked)
169 struct GraphicInfo_EM *g;
170 int crumbled_border_size;
171 int left = screen_x / TILEX;
172 int top = screen_y / TILEY;
175 /* do not draw fields that are outside the visible screen area */
176 if (x < left || x >= left + MAX_BUF_XSIZE ||
177 y < top || y >= top + MAX_BUF_YSIZE)
180 if (crm == 0) /* no crumbled edges for this tile */
183 g = getObjectGraphic(x, y);
185 crumbled_border_size =
186 g->crumbled_border_size * TILESIZE_VAR / g->crumbled_tile_size;
188 for (i = 0; i < 4; i++)
192 int width, height, cx, cy;
194 if (i == 1 || i == 2)
196 width = crumbled_border_size;
198 cx = (i == 2 ? TILEX - crumbled_border_size : 0);
204 height = crumbled_border_size;
206 cy = (i == 3 ? TILEY - crumbled_border_size : 0);
209 if (width > 0 && height > 0)
211 int src_x = g->crumbled_src_x + cx;
212 int src_y = g->crumbled_src_y + cy;
213 int dst_x = sx * TILEX + cx;
214 int dst_y = sy * TILEY + cy;
217 BlitBitmapMasked(g->crumbled_bitmap, screenBitmap,
218 src_x, src_y, width, height, dst_x, dst_y);
220 BlitBitmap(g->crumbled_bitmap, screenBitmap,
221 src_x, src_y, width, height, dst_x, dst_y);
227 static void DrawLevelPlayer_EM(int x1, int y1, int player_nr, int anim,
230 struct GraphicInfo_EM *g = getPlayerGraphic(player_nr, anim);
231 int src_x = g->src_x, src_y = g->src_y;
234 /* do not draw fields that are outside the visible screen area */
235 if (x1 < screen_x - TILEX || x1 >= screen_x + MAX_BUF_XSIZE * TILEX ||
236 y1 < screen_y - TILEY || y1 >= screen_y + MAX_BUF_YSIZE * TILEY)
239 x1 %= MAX_BUF_XSIZE * TILEX;
240 y1 %= MAX_BUF_YSIZE * TILEY;
244 /* draw the player to current location */
247 BlitBitmapMasked(g->bitmap, screenBitmap,
248 src_x, src_y, TILEX, TILEY, dst_x, dst_y);
250 /* draw the player to opposite wrap-around column */
251 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
253 BlitBitmapMasked(g->bitmap, screenBitmap,
254 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
256 /* draw the player to opposite wrap-around row */
258 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
259 BlitBitmapMasked(g->bitmap, screenBitmap,
260 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
264 /* draw the player to current location */
267 BlitBitmap(g->bitmap, screenBitmap,
268 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
270 /* draw the player to opposite wrap-around column */
271 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
273 BlitBitmap(g->bitmap, screenBitmap,
274 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
276 /* draw the player to opposite wrap-around row */
278 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
279 BlitBitmap(g->bitmap, screenBitmap,
280 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
284 /* draw differences between game tiles and screen tiles
286 * implicitly handles scrolling and restoring background under the sprites
289 static void animscreen(void)
292 int left = screen_x / TILEX;
293 int top = screen_y / TILEY;
294 static int xy[4][2] =
302 if (!game.use_native_emc_graphics_engine)
303 for (y = 2; y < EM_MAX_CAVE_HEIGHT - 2; y++)
304 for (x = 2; x < EM_MAX_CAVE_WIDTH - 2; x++)
305 SetGfxAnimation_EM(&graphic_info_em_object[Draw[y][x]][frame],
306 Draw[y][x], 7 - frame, x - 2, y - 2);
308 for (y = top; y < top + MAX_BUF_YSIZE; y++)
310 for (x = left; x < left + MAX_BUF_XSIZE; x++)
312 int sx = x % MAX_BUF_XSIZE;
313 int sy = y % MAX_BUF_YSIZE;
314 int tile = Draw[y][x];
315 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
316 int obj = g->unique_identifier;
318 boolean redraw_screen_tile = FALSE;
320 /* re-calculate crumbled state of this tile */
321 if (g->has_crumbled_graphics)
323 for (i = 0; i < 4; i++)
325 int xx = x + xy[i][0];
326 int yy = y + xy[i][1];
329 if (xx < 0 || xx >= EM_MAX_CAVE_WIDTH ||
330 yy < 0 || yy >= EM_MAX_CAVE_HEIGHT)
333 tile_next = Draw[yy][xx];
335 if (!graphic_info_em_object[tile_next][frame].has_crumbled_graphics)
340 redraw_screen_tile = (screentiles[sy][sx] != obj ||
341 crumbled_state[sy][sx] != crm);
343 /* only redraw screen tiles if they (or their crumbled state) changed */
344 if (redraw_screen_tile)
346 DrawLevelField_EM(x, y, sx, sy, FALSE);
347 DrawLevelFieldCrumbled_EM(x, y, sx, sy, crm, FALSE);
349 screentiles[sy][sx] = obj;
350 crumbled_state[sy][sx] = crm;
357 /* blit players to the screen
359 * handles transparency and movement
362 static void blitplayer(struct PLAYER *ply)
369 /* x1/y1 are left/top and x2/y2 are right/down part of the player movement */
370 x1 = (frame * ply->oldx + (8 - frame) * ply->x) * TILEX / 8;
371 y1 = (frame * ply->oldy + (8 - frame) * ply->y) * TILEY / 8;
375 if ((int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) &&
376 (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1))
378 /* some casts to "int" are needed because of negative calculation values */
379 int dx = (int)ply->x - (int)ply->oldx;
380 int dy = (int)ply->y - (int)ply->oldy;
381 int old_x = (int)ply->oldx + (7 - (int)frame) * dx / 8;
382 int old_y = (int)ply->oldy + (7 - (int)frame) * dy / 8;
383 int new_x = old_x + SIGN(dx);
384 int new_y = old_y + SIGN(dy);
385 int old_sx = old_x % MAX_BUF_XSIZE;
386 int old_sy = old_y % MAX_BUF_YSIZE;
387 int new_sx = new_x % MAX_BUF_XSIZE;
388 int new_sy = new_y % MAX_BUF_YSIZE;
389 int new_crm = crumbled_state[new_sy][new_sx];
391 /* only diggable elements can be crumbled in the classic EM engine */
392 boolean player_is_digging = (new_crm != 0);
394 if (player_is_digging)
396 /* draw the field the player is moving to (under the player) */
397 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, FALSE);
398 DrawLevelFieldCrumbled_EM(new_x, new_y, new_sx, new_sy, new_crm, FALSE);
400 /* draw the player (masked) over the element he is just digging away */
401 DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, TRUE);
403 /* draw the field the player is moving from (masked over the player) */
404 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
408 /* draw the player under the element which is on the same field */
409 DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, FALSE);
411 /* draw the field the player is moving from (masked over the player) */
412 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
414 /* draw the field the player is moving to (masked over the player) */
415 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, TRUE);
418 /* redraw screen tiles in the next frame (player may have left the tiles) */
419 screentiles[old_sy][old_sx] = -1;
420 screentiles[new_sy][new_sx] = -1;
424 void game_initscreen(void)
431 player_nr = (game.centered_player_nr != -1 ? game.centered_player_nr : 0);
433 screen_x = VALID_SCREEN_X(PLAYER_SCREEN_X(player_nr));
434 screen_y = VALID_SCREEN_Y(PLAYER_SCREEN_Y(player_nr));
436 for (y = 0; y < MAX_BUF_YSIZE; y++)
438 for (x = 0; x < MAX_BUF_XSIZE; x++)
440 screentiles[y][x] = -1;
441 crumbled_state[y][x] = 0;
446 static int getMaxCenterDistancePlayerNr(int center_x, int center_y)
448 int max_dx = 0, max_dy = 0;
449 int player_nr = game_em.last_moving_player;
452 for (i = 0; i < MAX_PLAYERS; i++)
456 int sx = PLAYER_SCREEN_X(i);
457 int sy = PLAYER_SCREEN_Y(i);
459 if (game_em.last_player_direction[i] != MV_NONE &&
460 (ABS(sx - center_x) > max_dx ||
461 ABS(sy - center_y) > max_dy))
463 max_dx = MAX(max_dx, ABS(sx - center_x));
464 max_dy = MAX(max_dy, ABS(sy - center_y));
474 static void setMinimalPlayerBoundaries(int *sx1, int *sy1, int *sx2, int *sy2)
476 boolean num_checked_players = 0;
479 for (i = 0; i < MAX_PLAYERS; i++)
483 int sx = PLAYER_SCREEN_X(i);
484 int sy = PLAYER_SCREEN_Y(i);
486 if (num_checked_players == 0)
493 *sx1 = MIN(*sx1, sx);
494 *sy1 = MIN(*sy1, sy);
495 *sx2 = MAX(*sx2, sx);
496 *sy2 = MAX(*sy2, sy);
499 num_checked_players++;
504 boolean checkIfAllPlayersFitToScreen()
506 int sx1 = 0, sy1 = 0, sx2 = 0, sy2 = 0;
508 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
510 return (sx2 - sx1 <= SCR_FIELDX * TILEX &&
511 sy2 - sy1 <= SCR_FIELDY * TILEY);
514 static void setScreenCenteredToAllPlayers(int *sx, int *sy)
516 int sx1 = screen_x, sy1 = screen_y, sx2 = screen_x, sy2 = screen_y;
518 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
520 *sx = (sx1 + sx2) / 2;
521 *sy = (sy1 + sy2) / 2;
524 static void setMaxCenterDistanceForAllPlayers(int *max_dx, int *max_dy,
525 int center_x, int center_y)
527 int sx1 = center_x, sy1 = center_y, sx2 = center_x, sy2 = center_y;
529 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
531 *max_dx = MAX(ABS(sx1 - center_x), ABS(sx2 - center_x));
532 *max_dy = MAX(ABS(sy1 - center_y), ABS(sy2 - center_y));
535 static boolean checkIfAllPlayersAreVisible(int center_x, int center_y)
539 setMaxCenterDistanceForAllPlayers(&max_dx, &max_dy, center_x, center_y);
541 return (max_dx <= SCR_FIELDX * TILEX / 2 &&
542 max_dy <= SCR_FIELDY * TILEY / 2);
545 void RedrawPlayfield_EM(boolean force_redraw)
547 boolean draw_new_player_location = FALSE;
548 boolean quick_relocation = setup.quick_switch;
549 int max_center_distance_player_nr =
550 getMaxCenterDistancePlayerNr(screen_x, screen_y);
551 int stepsize = TILEX / 8;
552 int offset = game.scroll_delay_value * TILEX;
553 int offset_x = offset;
554 int offset_y = offset;
555 int screen_x_old = screen_x;
556 int screen_y_old = screen_y;
560 if (game.set_centered_player)
562 boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen();
564 /* switching to "all players" only possible if all players fit to screen */
565 if (game.centered_player_nr_next == -1 && !all_players_fit_to_screen)
567 game.centered_player_nr_next = game.centered_player_nr;
568 game.set_centered_player = FALSE;
571 /* do not switch focus to non-existing (or non-active) player */
572 if (game.centered_player_nr_next >= 0 &&
573 !ply[game.centered_player_nr_next].alive)
575 game.centered_player_nr_next = game.centered_player_nr;
576 game.set_centered_player = FALSE;
580 /* also allow focus switching when screen is scrolled to half tile */
581 if (game.set_centered_player)
583 game.centered_player_nr = game.centered_player_nr_next;
585 draw_new_player_location = TRUE;
588 game.set_centered_player = FALSE;
591 if (game.centered_player_nr == -1)
593 if (draw_new_player_location || offset == 0)
595 setScreenCenteredToAllPlayers(&sx, &sy);
599 sx = PLAYER_SCREEN_X(max_center_distance_player_nr);
600 sy = PLAYER_SCREEN_Y(max_center_distance_player_nr);
605 sx = PLAYER_SCREEN_X(game.centered_player_nr);
606 sy = PLAYER_SCREEN_Y(game.centered_player_nr);
609 if (draw_new_player_location && quick_relocation)
611 screen_x = VALID_SCREEN_X(sx);
612 screen_y = VALID_SCREEN_Y(sy);
613 screen_x_old = screen_x;
614 screen_y_old = screen_y;
617 if (draw_new_player_location && !quick_relocation)
619 unsigned int game_frame_delay_value = getGameFrameDelay_EM(20);
620 int wait_delay_value = game_frame_delay_value;
621 int screen_xx = VALID_SCREEN_X(sx);
622 int screen_yy = VALID_SCREEN_Y(sy);
624 while (screen_x != screen_xx || screen_y != screen_yy)
626 int dx = (screen_xx < screen_x ? +1 : screen_xx > screen_x ? -1 : 0);
627 int dy = (screen_yy < screen_y ? +1 : screen_yy > screen_y ? -1 : 0);
628 int dxx = 0, dyy = 0;
630 if (dx == 0 && dy == 0) /* no scrolling needed at all */
633 if (ABS(screen_xx - screen_x) >= TILEX)
635 screen_x -= dx * TILEX;
636 dxx = dx * TILEX / 2;
640 screen_x = screen_xx;
644 if (ABS(screen_yy - screen_y) >= TILEY)
646 screen_y -= dy * TILEY;
647 dyy = dy * TILEY / 2;
651 screen_y = screen_yy;
655 /* scroll in two steps of half tile size to make things smoother */
661 for (i = 0; i < MAX_PLAYERS; i++)
664 BlitScreenToBitmap_EM(backbuffer);
667 Delay(wait_delay_value);
669 /* scroll second step to align at full tile size */
675 for (i = 0; i < MAX_PLAYERS; i++)
678 BlitScreenToBitmap_EM(backbuffer);
681 Delay(wait_delay_value);
684 screen_x_old = screen_x;
685 screen_y_old = screen_y;
690 for (y = 0; y < MAX_BUF_YSIZE; y++)
692 for (x = 0; x < MAX_BUF_XSIZE; x++)
694 screentiles[y][x] = -1;
695 crumbled_state[y][x] = 0;
700 /* calculate new screen scrolling position, with regard to scroll delay */
701 screen_x = VALID_SCREEN_X(sx + offset_x < screen_x ? sx + offset_x :
702 sx - offset_x > screen_x ? sx - offset_x :
704 screen_y = VALID_SCREEN_Y(sy + offset_y < screen_y ? sy + offset_y :
705 sy - offset_y > screen_y ? sy - offset_y :
708 /* prevent scrolling further than double player step size when scrolling */
709 if (ABS(screen_x - screen_x_old) > 2 * stepsize)
711 int dx = SIGN(screen_x - screen_x_old);
713 screen_x = screen_x_old + dx * 2 * stepsize;
715 if (ABS(screen_y - screen_y_old) > 2 * stepsize)
717 int dy = SIGN(screen_y - screen_y_old);
719 screen_y = screen_y_old + dy * 2 * stepsize;
722 /* prevent scrolling away from the other players when focus on all players */
723 if (game.centered_player_nr == -1)
725 /* check if all players are still visible with new scrolling position */
726 if (checkIfAllPlayersAreVisible(screen_x_old, screen_y_old) &&
727 !checkIfAllPlayersAreVisible(screen_x, screen_y))
729 /* reset horizontal scroll position to last value, if needed */
730 if (!checkIfAllPlayersAreVisible(screen_x, screen_y_old))
731 screen_x = screen_x_old;
733 /* reset vertical scroll position to last value, if needed */
734 if (!checkIfAllPlayersAreVisible(screen_x_old, screen_y))
735 screen_y = screen_y_old;
739 /* prevent scrolling (for screen correcting) if no player is moving */
740 if (!game_em.any_player_moving)
742 screen_x = screen_x_old;
743 screen_y = screen_y_old;
747 /* prevent scrolling against the players move direction */
748 int player_nr = (game.centered_player_nr == -1 ?
749 max_center_distance_player_nr : game.centered_player_nr);
750 int player_move_dir = game_em.last_player_direction[player_nr];
751 int dx = SIGN(screen_x - screen_x_old);
752 int dy = SIGN(screen_y - screen_y_old);
754 if ((dx < 0 && player_move_dir != MV_LEFT) ||
755 (dx > 0 && player_move_dir != MV_RIGHT))
756 screen_x = screen_x_old;
758 if ((dy < 0 && player_move_dir != MV_UP) ||
759 (dy > 0 && player_move_dir != MV_DOWN))
760 screen_y = screen_y_old;
765 for (i = 0; i < MAX_PLAYERS; i++)