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);
56 int sx, sy, sxsize, sysize;
59 int full_xsize = lev.width * TILEX;
60 int full_ysize = lev.height * TILEY;
62 sxsize = (full_xsize < xsize ? full_xsize : xsize);
63 sysize = (full_ysize < ysize ? full_ysize : ysize);
64 sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
65 sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
67 if (x < 2 * TILEX && y < 2 * TILEY)
69 BlitBitmap(screenBitmap, target_bitmap, x, y,
70 sxsize, sysize, sx, sy);
72 else if (x < 2 * TILEX && y >= 2 * TILEY)
74 BlitBitmap(screenBitmap, target_bitmap, x, y,
75 sxsize, MAX_BUF_YSIZE * TILEY - y,
77 BlitBitmap(screenBitmap, target_bitmap, x, 0,
78 sxsize, y - 2 * TILEY,
79 sx, sy + MAX_BUF_YSIZE * TILEY - y);
81 else if (x >= 2 * TILEX && y < 2 * TILEY)
83 BlitBitmap(screenBitmap, target_bitmap, x, y,
84 MAX_BUF_XSIZE * TILEX - x, sysize,
86 BlitBitmap(screenBitmap, target_bitmap, 0, y,
87 x - 2 * TILEX, sysize,
88 sx + MAX_BUF_XSIZE * TILEX - x, sy);
92 BlitBitmap(screenBitmap, target_bitmap, x, y,
93 MAX_BUF_XSIZE * TILEX - x, MAX_BUF_YSIZE * TILEY - y,
95 BlitBitmap(screenBitmap, target_bitmap, 0, y,
96 x - 2 * TILEX, MAX_BUF_YSIZE * TILEY - y,
97 sx + MAX_BUF_XSIZE * TILEX - x, sy);
98 BlitBitmap(screenBitmap, target_bitmap, x, 0,
99 MAX_BUF_XSIZE * TILEX - x, y - 2 * TILEY,
100 sx, sy + MAX_BUF_YSIZE * TILEY - y);
101 BlitBitmap(screenBitmap, target_bitmap, 0, 0,
102 x - 2 * TILEX, y - 2 * TILEY,
103 sx + MAX_BUF_XSIZE * TILEX - x, sy + MAX_BUF_YSIZE * TILEY - y);
107 void BackToFront_EM(void)
109 BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY);
112 static struct GraphicInfo_EM *getObjectGraphic(int x, int y)
114 int tile = Draw[y][x];
115 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
117 if (!game.use_native_emc_graphics_engine)
118 getGraphicSourceObjectExt_EM(g, tile, 7 - frame, x - 2, y - 2);
123 static struct GraphicInfo_EM *getPlayerGraphic(int player_nr, int anim)
125 struct GraphicInfo_EM *g = &graphic_info_em_player[player_nr][anim][frame];
127 if (!game.use_native_emc_graphics_engine)
128 getGraphicSourcePlayerExt_EM(g, player_nr, anim, 7 - frame);
133 static void DrawLevelField_EM(int x, int y, int sx, int sy,
136 struct GraphicInfo_EM *g = getObjectGraphic(x, y);
137 int src_x = g->src_x + g->src_offset_x * TILESIZE_VAR / TILESIZE;
138 int src_y = g->src_y + g->src_offset_y * TILESIZE_VAR / TILESIZE;
139 int dst_x = sx * TILEX + g->dst_offset_x * TILESIZE_VAR / TILESIZE;
140 int dst_y = sy * TILEY + g->dst_offset_y * TILESIZE_VAR / TILESIZE;
141 int width = g->width * TILESIZE_VAR / TILESIZE;
142 int height = g->height * TILESIZE_VAR / TILESIZE;
143 int left = screen_x / TILEX;
144 int top = screen_y / TILEY;
146 /* do not draw fields that are outside the visible screen area */
147 if (x < left || x >= left + MAX_BUF_XSIZE ||
148 y < top || y >= top + MAX_BUF_YSIZE)
153 if (width > 0 && height > 0)
154 BlitBitmapMasked(g->bitmap, screenBitmap,
155 src_x, src_y, width, height, dst_x, dst_y);
159 if ((width != TILEX || height != TILEY) && !g->preserve_background)
160 ClearRectangle(screenBitmap, sx * TILEX, sy * TILEY, TILEX, TILEY);
162 if (width > 0 && height > 0)
163 BlitBitmap(g->bitmap, screenBitmap,
164 src_x, src_y, width, height, dst_x, dst_y);
168 static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy,
169 int crm, boolean draw_masked)
171 struct GraphicInfo_EM *g;
172 int crumbled_border_size;
173 int left = screen_x / TILEX;
174 int top = screen_y / TILEY;
177 /* do not draw fields that are outside the visible screen area */
178 if (x < left || x >= left + MAX_BUF_XSIZE ||
179 y < top || y >= top + MAX_BUF_YSIZE)
182 if (crm == 0) /* no crumbled edges for this tile */
185 g = getObjectGraphic(x, y);
187 crumbled_border_size =
188 g->crumbled_border_size * TILESIZE_VAR / g->crumbled_tile_size;
190 for (i = 0; i < 4; i++)
194 int width, height, cx, cy;
196 if (i == 1 || i == 2)
198 width = crumbled_border_size;
200 cx = (i == 2 ? TILEX - crumbled_border_size : 0);
206 height = crumbled_border_size;
208 cy = (i == 3 ? TILEY - crumbled_border_size : 0);
211 if (width > 0 && height > 0)
213 int src_x = g->crumbled_src_x + cx;
214 int src_y = g->crumbled_src_y + cy;
215 int dst_x = sx * TILEX + cx;
216 int dst_y = sy * TILEY + cy;
219 BlitBitmapMasked(g->crumbled_bitmap, screenBitmap,
220 src_x, src_y, width, height, dst_x, dst_y);
222 BlitBitmap(g->crumbled_bitmap, screenBitmap,
223 src_x, src_y, width, height, dst_x, dst_y);
229 static void DrawLevelPlayer_EM(int x1, int y1, int player_nr, int anim,
232 struct GraphicInfo_EM *g = getPlayerGraphic(player_nr, anim);
233 int src_x = g->src_x, src_y = g->src_y;
236 /* do not draw fields that are outside the visible screen area */
237 if (x1 < screen_x - TILEX || x1 >= screen_x + MAX_BUF_XSIZE * TILEX ||
238 y1 < screen_y - TILEY || y1 >= screen_y + MAX_BUF_YSIZE * TILEY)
241 x1 %= MAX_BUF_XSIZE * TILEX;
242 y1 %= MAX_BUF_YSIZE * TILEY;
246 /* draw the player to current location */
249 BlitBitmapMasked(g->bitmap, screenBitmap,
250 src_x, src_y, TILEX, TILEY, dst_x, dst_y);
252 /* draw the player to opposite wrap-around column */
253 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
255 BlitBitmapMasked(g->bitmap, screenBitmap,
256 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
258 /* draw the player to opposite wrap-around row */
260 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
261 BlitBitmapMasked(g->bitmap, screenBitmap,
262 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
266 /* draw the player to current location */
269 BlitBitmap(g->bitmap, screenBitmap,
270 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
272 /* draw the player to opposite wrap-around column */
273 dst_x = x1 - MAX_BUF_XSIZE * TILEX;
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 row */
280 dst_y = y1 - MAX_BUF_YSIZE * TILEY;
281 BlitBitmap(g->bitmap, screenBitmap,
282 g->src_x, g->src_y, TILEX, TILEY, dst_x, dst_y);
286 /* draw differences between game tiles and screen tiles
288 * implicitly handles scrolling and restoring background under the sprites
291 static void animscreen(void)
294 int left = screen_x / TILEX;
295 int top = screen_y / TILEY;
296 static int xy[4][2] =
304 if (!game.use_native_emc_graphics_engine)
305 for (y = 2; y < EM_MAX_CAVE_HEIGHT - 2; y++)
306 for (x = 2; x < EM_MAX_CAVE_WIDTH - 2; x++)
307 SetGfxAnimation_EM(&graphic_info_em_object[Draw[y][x]][frame],
308 Draw[y][x], 7 - frame, x - 2, y - 2);
310 for (y = top; y < top + MAX_BUF_YSIZE; y++)
312 for (x = left; x < left + MAX_BUF_XSIZE; x++)
314 int sx = x % MAX_BUF_XSIZE;
315 int sy = y % MAX_BUF_YSIZE;
316 int tile = Draw[y][x];
317 struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame];
318 int obj = g->unique_identifier;
320 boolean redraw_screen_tile = FALSE;
322 /* re-calculate crumbled state of this tile */
323 if (g->has_crumbled_graphics)
325 for (i = 0; i < 4; i++)
327 int xx = x + xy[i][0];
328 int yy = y + xy[i][1];
331 if (xx < 0 || xx >= EM_MAX_CAVE_WIDTH ||
332 yy < 0 || yy >= EM_MAX_CAVE_HEIGHT)
335 tile_next = Draw[yy][xx];
337 if (!graphic_info_em_object[tile_next][frame].has_crumbled_graphics)
342 redraw_screen_tile = (screentiles[sy][sx] != obj ||
343 crumbled_state[sy][sx] != crm);
345 /* only redraw screen tiles if they (or their crumbled state) changed */
346 if (redraw_screen_tile)
348 DrawLevelField_EM(x, y, sx, sy, FALSE);
349 DrawLevelFieldCrumbled_EM(x, y, sx, sy, crm, FALSE);
351 screentiles[sy][sx] = obj;
352 crumbled_state[sy][sx] = crm;
359 /* blit players to the screen
361 * handles transparency and movement
364 static void blitplayer(struct PLAYER *ply)
371 /* x1/y1 are left/top and x2/y2 are right/down part of the player movement */
372 x1 = (frame * ply->oldx + (8 - frame) * ply->x) * TILEX / 8;
373 y1 = (frame * ply->oldy + (8 - frame) * ply->y) * TILEY / 8;
377 if ((int)(x2 - screen_x) < ((MAX_BUF_XSIZE - 1) * TILEX - 1) &&
378 (int)(y2 - screen_y) < ((MAX_BUF_YSIZE - 1) * TILEY - 1))
380 /* some casts to "int" are needed because of negative calculation values */
381 int dx = (int)ply->x - (int)ply->oldx;
382 int dy = (int)ply->y - (int)ply->oldy;
383 int old_x = (int)ply->oldx + (7 - (int)frame) * dx / 8;
384 int old_y = (int)ply->oldy + (7 - (int)frame) * dy / 8;
385 int new_x = old_x + SIGN(dx);
386 int new_y = old_y + SIGN(dy);
387 int old_sx = old_x % MAX_BUF_XSIZE;
388 int old_sy = old_y % MAX_BUF_YSIZE;
389 int new_sx = new_x % MAX_BUF_XSIZE;
390 int new_sy = new_y % MAX_BUF_YSIZE;
391 int new_crm = crumbled_state[new_sy][new_sx];
393 /* only diggable elements can be crumbled in the classic EM engine */
394 boolean player_is_digging = (new_crm != 0);
396 if (player_is_digging)
398 /* draw the field the player is moving to (under the player) */
399 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, FALSE);
400 DrawLevelFieldCrumbled_EM(new_x, new_y, new_sx, new_sy, new_crm, FALSE);
402 /* draw the player (masked) over the element he is just digging away */
403 DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, TRUE);
405 /* draw the field the player is moving from (masked over the player) */
406 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
410 /* draw the player under the element which is on the same field */
411 DrawLevelPlayer_EM(x1, y1, ply->num, ply->anim, FALSE);
413 /* draw the field the player is moving from (masked over the player) */
414 DrawLevelField_EM(old_x, old_y, old_sx, old_sy, TRUE);
416 /* draw the field the player is moving to (masked over the player) */
417 DrawLevelField_EM(new_x, new_y, new_sx, new_sy, TRUE);
420 /* redraw screen tiles in the next frame (player may have left the tiles) */
421 screentiles[old_sy][old_sx] = -1;
422 screentiles[new_sy][new_sx] = -1;
426 void game_initscreen(void)
433 player_nr = (game.centered_player_nr != -1 ? game.centered_player_nr : 0);
435 screen_x = VALID_SCREEN_X(PLAYER_SCREEN_X(player_nr));
436 screen_y = VALID_SCREEN_Y(PLAYER_SCREEN_Y(player_nr));
438 for (y = 0; y < MAX_BUF_YSIZE; y++)
440 for (x = 0; x < MAX_BUF_XSIZE; x++)
442 screentiles[y][x] = -1;
443 crumbled_state[y][x] = 0;
448 static int getMaxCenterDistancePlayerNr(int center_x, int center_y)
450 int max_dx = 0, max_dy = 0;
451 int player_nr = game_em.last_moving_player;
454 for (i = 0; i < MAX_PLAYERS; i++)
458 int sx = PLAYER_SCREEN_X(i);
459 int sy = PLAYER_SCREEN_Y(i);
461 if (game_em.last_player_direction[i] != MV_NONE &&
462 (ABS(sx - center_x) > max_dx ||
463 ABS(sy - center_y) > max_dy))
465 max_dx = MAX(max_dx, ABS(sx - center_x));
466 max_dy = MAX(max_dy, ABS(sy - center_y));
476 static void setMinimalPlayerBoundaries(int *sx1, int *sy1, int *sx2, int *sy2)
478 boolean num_checked_players = 0;
481 for (i = 0; i < MAX_PLAYERS; i++)
485 int sx = PLAYER_SCREEN_X(i);
486 int sy = PLAYER_SCREEN_Y(i);
488 if (num_checked_players == 0)
495 *sx1 = MIN(*sx1, sx);
496 *sy1 = MIN(*sy1, sy);
497 *sx2 = MAX(*sx2, sx);
498 *sy2 = MAX(*sy2, sy);
501 num_checked_players++;
506 boolean checkIfAllPlayersFitToScreen()
508 int sx1 = 0, sy1 = 0, sx2 = 0, sy2 = 0;
510 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
512 return (sx2 - sx1 <= SCR_FIELDX * TILEX &&
513 sy2 - sy1 <= SCR_FIELDY * TILEY);
516 static void setScreenCenteredToAllPlayers(int *sx, int *sy)
518 int sx1 = screen_x, sy1 = screen_y, sx2 = screen_x, sy2 = screen_y;
520 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
522 *sx = (sx1 + sx2) / 2;
523 *sy = (sy1 + sy2) / 2;
526 static void setMaxCenterDistanceForAllPlayers(int *max_dx, int *max_dy,
527 int center_x, int center_y)
529 int sx1 = center_x, sy1 = center_y, sx2 = center_x, sy2 = center_y;
531 setMinimalPlayerBoundaries(&sx1, &sy1, &sx2, &sy2);
533 *max_dx = MAX(ABS(sx1 - center_x), ABS(sx2 - center_x));
534 *max_dy = MAX(ABS(sy1 - center_y), ABS(sy2 - center_y));
537 static boolean checkIfAllPlayersAreVisible(int center_x, int center_y)
541 setMaxCenterDistanceForAllPlayers(&max_dx, &max_dy, center_x, center_y);
543 return (max_dx <= SCR_FIELDX * TILEX / 2 &&
544 max_dy <= SCR_FIELDY * TILEY / 2);
547 void RedrawPlayfield_EM(boolean force_redraw)
549 boolean draw_new_player_location = FALSE;
550 boolean quick_relocation = setup.quick_switch;
551 int max_center_distance_player_nr =
552 getMaxCenterDistancePlayerNr(screen_x, screen_y);
553 int stepsize = TILEX / 8;
554 int offset = game.scroll_delay_value * TILEX;
555 int offset_x = offset;
556 int offset_y = offset;
557 int screen_x_old = screen_x;
558 int screen_y_old = screen_y;
562 if (game.set_centered_player)
564 boolean all_players_fit_to_screen = checkIfAllPlayersFitToScreen();
566 /* switching to "all players" only possible if all players fit to screen */
567 if (game.centered_player_nr_next == -1 && !all_players_fit_to_screen)
569 game.centered_player_nr_next = game.centered_player_nr;
570 game.set_centered_player = FALSE;
573 /* do not switch focus to non-existing (or non-active) player */
574 if (game.centered_player_nr_next >= 0 &&
575 !ply[game.centered_player_nr_next].alive)
577 game.centered_player_nr_next = game.centered_player_nr;
578 game.set_centered_player = FALSE;
582 /* also allow focus switching when screen is scrolled to half tile */
583 if (game.set_centered_player)
585 game.centered_player_nr = game.centered_player_nr_next;
587 draw_new_player_location = TRUE;
590 game.set_centered_player = FALSE;
593 if (game.centered_player_nr == -1)
595 if (draw_new_player_location || offset == 0)
597 setScreenCenteredToAllPlayers(&sx, &sy);
601 sx = PLAYER_SCREEN_X(max_center_distance_player_nr);
602 sy = PLAYER_SCREEN_Y(max_center_distance_player_nr);
607 sx = PLAYER_SCREEN_X(game.centered_player_nr);
608 sy = PLAYER_SCREEN_Y(game.centered_player_nr);
611 if (draw_new_player_location && quick_relocation)
613 screen_x = VALID_SCREEN_X(sx);
614 screen_y = VALID_SCREEN_Y(sy);
615 screen_x_old = screen_x;
616 screen_y_old = screen_y;
619 if (draw_new_player_location && !quick_relocation)
621 unsigned int game_frame_delay_value = getGameFrameDelay_EM(20);
622 int wait_delay_value = game_frame_delay_value;
623 int screen_xx = VALID_SCREEN_X(sx);
624 int screen_yy = VALID_SCREEN_Y(sy);
626 while (screen_x != screen_xx || screen_y != screen_yy)
628 int dx = (screen_xx < screen_x ? +1 : screen_xx > screen_x ? -1 : 0);
629 int dy = (screen_yy < screen_y ? +1 : screen_yy > screen_y ? -1 : 0);
630 int dxx = 0, dyy = 0;
632 if (dx == 0 && dy == 0) /* no scrolling needed at all */
635 if (ABS(screen_xx - screen_x) >= TILEX)
637 screen_x -= dx * TILEX;
638 dxx = dx * TILEX / 2;
642 screen_x = screen_xx;
646 if (ABS(screen_yy - screen_y) >= TILEY)
648 screen_y -= dy * TILEY;
649 dyy = dy * TILEY / 2;
653 screen_y = screen_yy;
657 /* scroll in two steps of half tile size to make things smoother */
663 for (i = 0; i < MAX_PLAYERS; i++)
666 BlitScreenToBitmap_EM(backbuffer);
669 Delay(wait_delay_value);
671 /* scroll second step to align at full tile size */
677 for (i = 0; i < MAX_PLAYERS; i++)
680 BlitScreenToBitmap_EM(backbuffer);
683 Delay(wait_delay_value);
686 screen_x_old = screen_x;
687 screen_y_old = screen_y;
692 for (y = 0; y < MAX_BUF_YSIZE; y++)
694 for (x = 0; x < MAX_BUF_XSIZE; x++)
696 screentiles[y][x] = -1;
697 crumbled_state[y][x] = 0;
702 /* calculate new screen scrolling position, with regard to scroll delay */
703 screen_x = VALID_SCREEN_X(sx + offset_x < screen_x ? sx + offset_x :
704 sx - offset_x > screen_x ? sx - offset_x :
706 screen_y = VALID_SCREEN_Y(sy + offset_y < screen_y ? sy + offset_y :
707 sy - offset_y > screen_y ? sy - offset_y :
710 /* prevent scrolling further than double player step size when scrolling */
711 if (ABS(screen_x - screen_x_old) > 2 * stepsize)
713 int dx = SIGN(screen_x - screen_x_old);
715 screen_x = screen_x_old + dx * 2 * stepsize;
717 if (ABS(screen_y - screen_y_old) > 2 * stepsize)
719 int dy = SIGN(screen_y - screen_y_old);
721 screen_y = screen_y_old + dy * 2 * stepsize;
724 /* prevent scrolling away from the other players when focus on all players */
725 if (game.centered_player_nr == -1)
727 /* check if all players are still visible with new scrolling position */
728 if (checkIfAllPlayersAreVisible(screen_x_old, screen_y_old) &&
729 !checkIfAllPlayersAreVisible(screen_x, screen_y))
731 /* reset horizontal scroll position to last value, if needed */
732 if (!checkIfAllPlayersAreVisible(screen_x, screen_y_old))
733 screen_x = screen_x_old;
735 /* reset vertical scroll position to last value, if needed */
736 if (!checkIfAllPlayersAreVisible(screen_x_old, screen_y))
737 screen_y = screen_y_old;
741 /* prevent scrolling (for screen correcting) if no player is moving */
742 if (!game_em.any_player_moving)
744 screen_x = screen_x_old;
745 screen_y = screen_y_old;
749 /* prevent scrolling against the players move direction */
750 int player_nr = (game.centered_player_nr == -1 ?
751 max_center_distance_player_nr : game.centered_player_nr);
752 int player_move_dir = game_em.last_player_direction[player_nr];
753 int dx = SIGN(screen_x - screen_x_old);
754 int dy = SIGN(screen_y - screen_y_old);
756 if ((dx < 0 && player_move_dir != MV_LEFT) ||
757 (dx > 0 && player_move_dir != MV_RIGHT))
758 screen_x = screen_x_old;
760 if ((dy < 0 && player_move_dir != MV_UP) ||
761 (dy > 0 && player_move_dir != MV_DOWN))
762 screen_y = screen_y_old;
767 for (i = 0; i < MAX_PLAYERS; i++)