X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FDDScrollBuffer.c;h=de5b237edceeea21b823462ed992fe30ca4e0943;hb=18863a5655e9e07d548e2d673e7f82336703c8fb;hp=53cc5ea06330f63bd4371ce94fef15c1275fe68b;hpb=9f688962eb90591205c511c1ae9bf752d276d1f5;p=rocksndiamonds.git diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 53cc5ea0..de5b237e 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -39,6 +39,28 @@ boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; int TEST_flag = 0; +void RestorePlayfield() +{ + int x1 = mScrollX / TILEX - 2; + int y1 = mScrollY / TILEY - 2; + int x2 = mScrollX / TILEX + (SCR_FIELDX - 1) + 2; + int y2 = mScrollY / TILEY + (SCR_FIELDY - 1) + 2; + int x, y; + + DrawFrameIfNeeded(); + + for (y = DisplayMinY; y <= DisplayMaxY; y++) + { + for (x = DisplayMinX; x <= DisplayMaxX; x++) + { + if (x >= x1 && x <= x2 && y >= y1 && y <= y2) + { + DrawFieldNoAnimated(x, y); + DrawFieldAnimated(x, y); + } + } + } +} static void ScrollPlayfield(int dx, int dy) { @@ -184,7 +206,81 @@ void InitScrollPlayfield() ScrollPlayfieldIfNeededExt(TRUE); } -void UpdatePlayfield() +void UpdatePlayfield(boolean force_redraw) +{ + int x, y; +#if 1 + int num_redrawn = 0; +#endif + + for (y = DisplayMinY; y <= DisplayMaxY; y++) + { + for (x = DisplayMinX; x <= DisplayMaxX; x++) + { + int element = LowByte(PlayField16[GetSI(x, y)]); + int graphic = GfxGraphic[x][y]; + int sync_frame = GfxFrame[x][y]; + boolean redraw = force_redraw; + +#if 0 + redraw = TRUE; // !!! TEST ONLY -- ALWAYS REDRAW !!! +#endif + + if (graphic < 0) + { + GfxGraphicLast[x][y] = GfxGraphic[x][y]; + + continue; + } + + if (element != GfxElementLast[x][y] && + graphic == GfxGraphicLast[x][y]) + { + /* element changed, but not graphic => disable updating graphic */ + + GfxElementLast[x][y] = element; + GfxGraphicLast[x][y] = GfxGraphic[x][y] = -1; + + continue; + } + + if (graphic != GfxGraphicLast[x][y]) // new graphic + { + redraw = TRUE; + + GfxElementLast[x][y] = element; + GfxGraphicLast[x][y] = GfxGraphic[x][y]; + sync_frame = GfxFrame[x][y] = 0; + } + else if (isNextAnimationFrame_SP(graphic, sync_frame)) // new frame + { + redraw = TRUE; + } + + if (redraw) + { + int sx = x * StretchWidth; + int sy = y * StretchWidth; + +#if 0 + printf("::: REDRAW (%d, %d): %d, %d\n", x, y, graphic, sync_frame); +#endif + + StretchedSprites.BltImg(sx, sy, graphic, sync_frame); + +#if 1 + num_redrawn++; +#endif + } + } + } + +#if 0 + printf("::: FRAME %d: %d redrawn\n", FrameCounter, num_redrawn); +#endif +} + +void UpdatePlayfield_TMP() { int x1 = mScrollX_last / TILEX - 2; int y1 = mScrollY_last / TILEY - 2;