X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=af0b7413103ef3c897535dbcdcc0af31be4e3d0e;hb=fe3196f07cb50ffb788c0073b82f94c26f93cfbf;hp=bb6e6ede2b2d259978b05380fef26368630f6027;hpb=dff0e0c8702770fe23992f07964ebe9ed54e9f7c;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index bb6e6ede..af0b7413 100644 --- a/src/game.c +++ b/src/game.c @@ -10565,25 +10565,34 @@ static boolean AllPlayersInVisibleScreen() void ScrollLevel(int dx, int dy) { - int softscroll_offset = (setup.soft_scrolling ? TILEX : 0); - int x, y; + int i, x, y; + + /* only horizontal XOR vertical scroll direction allowed */ + if ((dx == 0 && dy == 0) || (dx != 0 && dy != 0)) + return; #if 1 - BlitBitmap(drawto_field, bitmap_db_field2, - FX + TILEX * (dx == -1) - softscroll_offset, - FY + TILEY * (dy == -1) - softscroll_offset, - SXSIZE - TILEX * (dx != 0) + 2 * softscroll_offset, - SYSIZE - TILEY * (dy != 0) + 2 * softscroll_offset, - FX + TILEX * (dx == 1) - softscroll_offset, - FY + TILEY * (dy == 1) - softscroll_offset); - BlitBitmap(bitmap_db_field2, drawto_field, - FX + TILEX * (dx == 1) - softscroll_offset, - FY + TILEY * (dy == 1) - softscroll_offset, - SXSIZE - TILEX * (dx != 0) + 2 * softscroll_offset, - SYSIZE - TILEY * (dy != 0) + 2 * softscroll_offset, - FX + TILEX * (dx == 1) - softscroll_offset, - FY + TILEY * (dy == 1) - softscroll_offset); + int xsize = (BX2 - BX1 + 1); + int ysize = (BY2 - BY1 + 1); + int start = (dx != 0 ? (dx == -1 ? BX1 : BX2) : (dy == -1 ? BY1 : BY2)); + int end = (dx != 0 ? (dx == -1 ? BX2 : BX1) : (dy == -1 ? BY2 : BY1)); + int step = (start < end ? +1 : -1); + + for (i = start; i != end; i += step) + { + BlitBitmap(drawto_field, drawto_field, + FX + TILEX * (dx != 0 ? i + step : 0), + FY + TILEY * (dy != 0 ? i + step : 0), + TILEX * (dx != 0 ? 1 : xsize), + TILEY * (dy != 0 ? 1 : ysize), + FX + TILEX * (dx != 0 ? i : 0), + FY + TILEY * (dy != 0 ? i : 0)); + } + #else + + int softscroll_offset = (setup.soft_scrolling ? TILEX : 0); + BlitBitmap(drawto_field, drawto_field, FX + TILEX * (dx == -1) - softscroll_offset, FY + TILEY * (dy == -1) - softscroll_offset, @@ -10593,14 +10602,14 @@ void ScrollLevel(int dx, int dy) FY + TILEY * (dy == 1) - softscroll_offset); #endif - if (dx) + if (dx != 0) { x = (dx == 1 ? BX1 : BX2); for (y = BY1; y <= BY2; y++) DrawScreenField(x, y); } - if (dy) + if (dy != 0) { y = (dy == 1 ? BY1 : BY2); for (x = BX1; x <= BX2; x++)