int mScrollX_last, mScrollY_last;
int ScreenBuffer[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
-boolean redraw[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
-void RestorePlayfield()
+int getFieldbufferOffsetX_SP(void)
+{
+ int px = 2 * TILEX + (mScrollX - mScrollX_last) % TILEX;
+
+ // scroll correction for even number of visible tiles (half tile shifted)
+ px += game_sp.scroll_xoffset;
+
+ if (ExplosionShakeMurphy != 0)
+ px += TILEX / 2 - GetSimpleRandom(TILEX + 1);
+
+ px = px * TILESIZE_VAR / TILESIZE;
+
+ return px;
+}
+
+int getFieldbufferOffsetY_SP(void)
+{
+ int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY;
+
+ // scroll correction for even number of visible tiles (half tile shifted)
+ py += game_sp.scroll_yoffset;
+
+ if (ExplosionShakeMurphy != 0)
+ py += TILEY / 2 - GetSimpleRandom(TILEX + 1);
+
+ py = py * TILESIZE_VAR / TILESIZE;
+
+ return py;
+}
+
+void RestorePlayfield(void)
{
int x1 = mScrollX / TILEX - 2;
int y1 = mScrollY / TILEY - 2;
TILEX_VAR * (dx == 1),
TILEY_VAR * (dy == 1));
- /* when scrolling the whole playfield, do not redraw single tiles */
- for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++)
- for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++)
- redraw[x][y] = FALSE;
- redraw_tiles = 0;
-
DrawFrameIfNeeded();
for (y = DisplayMinY; y <= DisplayMaxY; y++)
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 ||
}
}
-static void ScrollPlayfieldIfNeeded()
+static void ScrollPlayfieldIfNeeded(void)
{
ScrollPlayfieldIfNeededExt(FALSE);
}
-void InitScrollPlayfield()
+void InitScrollPlayfield(void)
{
ScrollPlayfieldIfNeededExt(TRUE);
}
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++)
{
int element = LowByte(PlayField16[GetSI(x, y)]);
int graphic = GfxGraphic[x][y];
- int sync_frame = GfxFrame[x][y];
+ int sync_frame = GfxFrameSP[x][y];
boolean redraw = force_redraw;
if (graphic < 0)
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;
GfxElementLast[x][y] = element;
GfxGraphicLast[x][y] = GfxGraphic[x][y];
- sync_frame = GfxFrame[x][y] = 0;
+ sync_frame = GfxFrameSP[x][y] = 0;
}
else if (isNextAnimationFrame_SP(graphic, sync_frame)) // new frame
{
#endif
}
-/* copy the entire screen to the window at the scroll position */
-
void BlitScreenToBitmap_SP(Bitmap *target_bitmap)
{
- int px = 2 * TILEX + (mScrollX - mScrollX_last) % TILEX;
- int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY;
- int sx, sy, sxsize, sysize;
+ // copy playfield buffer to target bitmap at scroll position
+
+ int px = getFieldbufferOffsetX_SP();
+ int py = getFieldbufferOffsetY_SP();
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);
-
- /* scroll correction for even number of visible tiles (half tile shifted) */
- px += game_sp.scroll_xoffset;
- py += game_sp.scroll_yoffset;
-
- if (ExplosionShakeMurphy != 0)
- {
- px += TILEX / 2 - GetSimpleRandom(TILEX + 1);
- py += TILEY / 2 - GetSimpleRandom(TILEX + 1);
- }
-
- px = px * TILESIZE_VAR / TILESIZE;
- py = py * TILESIZE_VAR / TILESIZE;
+ 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);
}
-void BackToFront_SP(void)
-{
- int x, y;
-
- BlitScreenToBitmap_SP(window);
-
- for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++)
- for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++)
- redraw[x][y] = FALSE;
- redraw_tiles = 0;
-}
-
void DDScrollBuffer_ScrollTo(int X, int Y)
{
if (NoDisplayFlag)