X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FDDScrollBuffer.c;h=0db7e7fd2af75a00ef34dbc429e676d1c6395c92;hb=dec5093fc78bfe1356d764c2432fed6566b2af66;hp=026b80dd81c675681154a8f98cada0de810116e2;hpb=49e5cc70747062c45172e6106b8bec41d2e859ad;p=rocksndiamonds.git diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 026b80dd..0db7e7fd 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -13,11 +13,11 @@ int mScrollX_last, mScrollY_last; int ScreenBuffer[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2]; -int getFieldbufferOffsetX_SP() +int getFieldbufferOffsetX_SP(void) { int px = 2 * TILEX + (mScrollX - mScrollX_last) % TILEX; - /* scroll correction for even number of visible tiles (half tile shifted) */ + // scroll correction for even number of visible tiles (half tile shifted) px += game_sp.scroll_xoffset; if (ExplosionShakeMurphy != 0) @@ -28,11 +28,11 @@ int getFieldbufferOffsetX_SP() return px; } -int getFieldbufferOffsetY_SP() +int getFieldbufferOffsetY_SP(void) { int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY; - /* scroll correction for even number of visible tiles (half tile shifted) */ + // scroll correction for even number of visible tiles (half tile shifted) py += game_sp.scroll_yoffset; if (ExplosionShakeMurphy != 0) @@ -43,7 +43,7 @@ int getFieldbufferOffsetY_SP() return py; } -void RestorePlayfield() +void RestorePlayfield(void) { int x1 = mScrollX / TILEX - 2; int y1 = mScrollY / TILEY - 2; @@ -130,7 +130,7 @@ static void ScrollPlayfieldIfNeededExt(boolean reset) return; } - /* check if scrolling the playfield requires redrawing the viewport bitmap */ + // check if scrolling the playfield requires redrawing the viewport bitmap if ((mScrollX != mScrollX_last || mScrollY != mScrollY_last) && (ABS(mScrollX - mScrollX_last) >= TILEX || @@ -148,12 +148,12 @@ static void ScrollPlayfieldIfNeededExt(boolean reset) } } -static void ScrollPlayfieldIfNeeded() +static void ScrollPlayfieldIfNeeded(void) { ScrollPlayfieldIfNeededExt(FALSE); } -void InitScrollPlayfield() +void InitScrollPlayfield(void) { ScrollPlayfieldIfNeededExt(TRUE); } @@ -168,6 +168,17 @@ void UpdatePlayfield(boolean force_redraw) int num_redrawn = 0; #endif + if (force_redraw) + { + // force re-initialization of graphics status variables + for (y = DisplayMinY; y <= DisplayMaxY; y++) + for (x = DisplayMinX; x <= DisplayMaxX; x++) + GfxGraphic[x][y] = -1; + + // force complete playfield redraw + DisplayLevel(); + } + for (y = DisplayMinY; y <= DisplayMaxY; y++) { for (x = DisplayMinX; x <= DisplayMaxX; x++) @@ -187,7 +198,7 @@ void UpdatePlayfield(boolean force_redraw) if (element != GfxElementLast[x][y] && graphic == GfxGraphicLast[x][y]) { - /* element changed, but not graphic => disable updating graphic */ + // element changed, but not graphic => disable updating graphic GfxElementLast[x][y] = element; GfxGraphicLast[x][y] = GfxGraphic[x][y] = -1; @@ -229,20 +240,18 @@ void UpdatePlayfield(boolean force_redraw) void BlitScreenToBitmap_SP(Bitmap *target_bitmap) { - /* copy playfield buffer to target bitmap at scroll position */ + // copy playfield buffer to target bitmap at scroll position int px = getFieldbufferOffsetX_SP(); int py = getFieldbufferOffsetY_SP(); - int sx, sy, sxsize, sysize; int xsize = SXSIZE; int ysize = SYSIZE; int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR; int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR; - - sxsize = (full_xsize < xsize ? full_xsize : xsize); - sysize = (full_ysize < ysize ? full_ysize : ysize); - sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); - sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); + int sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); + int sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); + int sxsize = (full_xsize < xsize ? full_xsize : xsize); + int sysize = (full_ysize < ysize ? full_ysize : ysize); BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy); }