#include <math.h>
-// --- VERSION 1.0 CLASS
-// --- BEGIN
-// --- MultiUse = -1 'True // True
-// --- Persistable = 0 'NotPersistable // NotPersistable
-// --- DataBindingBehavior = 0 'vbNone // vbNone
-// --- DataSourceBehavior = 0 'vbNone // vbNone
-// --- MTSTransactionMode = 0 'NotAnMTSObject // NotAnMTSObject
-// --- END
-
-// static char *VB_Name = "DDScrollBuffer";
-// static boolean VB_GlobalNameSpace = False;
-// static boolean VB_Creatable = True;
-// static boolean VB_PredeclaredId = False;
-// static boolean VB_Exposed = False;
-
-// --- Option Explicit
-
-// needs reference to: DirectX7 for Visual Basic Type Library
-
-DirectDrawSurface7 Buffer;
-DirectDrawSurface7 mPrimary;
-long mWidth, mHeight;
-long mhWnd;
long mScrollX, mScrollY;
-long mDestXOff, mDestYOff;
+long mScrollX_last, mScrollY_last;
+
+#if 1
+long ScreenBuffer[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
+boolean redraw[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2];
+#else
+long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#endif
-void DDScrollBuffer_Let_DestXOff(long NewVal)
-{
- mDestXOff = NewVal;
-}
-long DDScrollBuffer_Get_DestXOff()
+void RestorePlayfield()
{
- long DestXOff;
+ 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;
- DestXOff = mDestXOff;
+ DrawFrameIfNeeded();
- return DestXOff;
+ 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);
+ }
+ }
+ }
}
-void DDScrollBuffer_Let_DestYOff(long NewVal)
+static void ScrollPlayfield(int dx, int dy)
{
- mDestYOff = NewVal;
-}
+ int x1 = mScrollX_last / TILEX - 2;
+ int y1 = mScrollY_last / TILEY - 2;
+ int x2 = mScrollX_last / TILEX + (SCR_FIELDX - 1) + 2;
+ int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2;
+ int x, y;
+
+#if NEW_TILESIZE
+ BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp,
+ TILEX_VAR * (dx == -1),
+ TILEY_VAR * (dy == -1),
+ (MAX_BUF_XSIZE * TILEX_VAR) - TILEX_VAR * (dx != 0),
+ (MAX_BUF_YSIZE * TILEY_VAR) - TILEY_VAR * (dy != 0),
+ TILEX_VAR * (dx == 1),
+ TILEY_VAR * (dy == 1));
+#else
+ BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp,
+ TILEX * (dx == -1),
+ TILEY * (dy == -1),
+ (MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0),
+ (MAX_BUF_YSIZE * TILEY) - TILEY * (dy != 0),
+ TILEX * (dx == 1),
+ TILEY * (dy == 1));
+#endif
-long DDScrollBuffer_Get_DestYOff()
-{
- long DestYOff;
+ /* when scrolling the whole playfield, do not redraw single tiles */
+#if 1
+ for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++)
+ for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++)
+ redraw[x][y] = FALSE;
+#else
+ for (x = 0; x < MAX_BUF_XSIZE; x++)
+ for (y = 0; y < MAX_BUF_YSIZE; y++)
+ redraw[x][y] = FALSE;
+#endif
+ redraw_tiles = 0;
- DestYOff = mDestYOff;
+ DrawFrameIfNeeded();
- return DestYOff;
+ for (y = DisplayMinY; y <= DisplayMaxY; y++)
+ {
+ for (x = DisplayMinX; x <= DisplayMaxX; x++)
+ {
+ if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
+ {
+ int sx = x - x1;
+ int sy = y - y1;
+ int tsi = GetSI(x, y);
+ long id = ((PlayField16[tsi]) |
+ (PlayField8[tsi] << 16) |
+ (DisPlayField[tsi] << 24));
+
+ if ((dx == -1 && x == x2) ||
+ (dx == +1 && x == x1) ||
+ (dy == -1 && y == y2) ||
+ (dy == +1 && y == y1))
+ {
+ DrawFieldNoAnimated(x, y);
+ DrawFieldAnimated(x, y);
+ }
+
+ ScreenBuffer[sx][sy] = id;
+ }
+ }
+ }
}
-DirectDrawSurface7 DDScrollBuffer_Get_Surface()
+static void ScrollPlayfieldIfNeededExt(boolean reset)
{
- DirectDrawSurface7 Surface;
+ if (reset)
+ {
+ mScrollX_last = -1;
+ mScrollY_last = -1;
- Surface = Buffer;
+ return;
+ }
- return Surface;
-}
+ if (mScrollX_last == -1 || mScrollY_last == -1)
+ {
+#if 1
+ mScrollX_last = (mScrollX / TILESIZE) * TILESIZE;
+ mScrollY_last = (mScrollY / TILESIZE) * TILESIZE;
+#else
+ mScrollX_last = mScrollX;
+ mScrollY_last = mScrollY;
+#endif
-long DDScrollBuffer_Get_Width()
-{
- long Width;
+ return;
+ }
+
+ /* check if scrolling the playfield requires redrawing the viewport bitmap */
+ if ((mScrollX != mScrollX_last ||
+ mScrollY != mScrollY_last) &&
+ (ABS(mScrollX - mScrollX_last) >= TILEX ||
+ ABS(mScrollY - mScrollY_last) >= TILEY))
+ {
+ int dx = (ABS(mScrollX - mScrollX_last) < TILEX ? 0 :
+ mScrollX < mScrollX_last ? 1 : mScrollX > mScrollX_last ? -1 : 0);
+ int dy = (ABS(mScrollY - mScrollY_last) < TILEY ? 0 :
+ mScrollY < mScrollY_last ? 1 : mScrollY > mScrollY_last ? -1 : 0);
- Width = mWidth;
+ mScrollX_last -= dx * TILEX;
+ mScrollY_last -= dy * TILEY;
- return Width;
+ ScrollPlayfield(dx, dy);
+ }
}
-int DDScrollBuffer_Get_Height()
+static void ScrollPlayfieldIfNeeded()
{
- int Height;
-
- Height = mHeight;
+ ScrollPlayfieldIfNeededExt(FALSE);
+}
- return Height;
+void InitScrollPlayfield()
+{
+ ScrollPlayfieldIfNeededExt(TRUE);
}
-long DDScrollBuffer_CreateAtSize(long Width, long Height, long hWndViewPort)
+#define DEBUG_REDRAW 0
+
+void UpdatePlayfield(boolean force_redraw)
{
- long CreateAtSize;
+ int x, y;
- DDSURFACEDESC2 SD;
+#if DEBUG_REDRAW
+ int num_redrawn = 0;
+#endif
- CreateAtSize = 0;
- mhWnd = hWndViewPort;
- // Create ScrollBuffer:
+ for (y = DisplayMinY; y <= DisplayMaxY; y++)
{
- SD.lFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- SD.ddsCaps.lCaps = DDSCAPS_VIDEOMEMORY;
- // SD.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
- SD.LWidth = Width;
- SD.LHeight = Height;
- }
+ 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;
- // --- On Error Resume Next
- Buffer = DDraw.CreateSurface(SD);
- if (Err.Number != 0)
- return CreateAtSize;
+#if DEBUG_REDRAW
+#if 0
+ redraw = TRUE; // !!! TEST ONLY -- ALWAYS REDRAW !!!
+#endif
+#endif
- // --- On Error GoTo 0
+ if (graphic < 0)
+ {
+ GfxGraphicLast[x][y] = GfxGraphic[x][y];
- mWidth = Width;
- mHeight = Height;
- mScrollX = 0;
- mScrollY = 0;
- CreateAtSize = -1;
+ continue;
+ }
- return CreateAtSize;
-}
+ if (element != GfxElementLast[x][y] &&
+ graphic == GfxGraphicLast[x][y])
+ {
+ /* element changed, but not graphic => disable updating graphic */
-void DDScrollBuffer_Cls(int BackColor)
-{
- RECT EmptyRect;
+ GfxElementLast[x][y] = element;
+ GfxGraphicLast[x][y] = GfxGraphic[x][y] = -1;
- if (NoDisplayFlag)
- return;
+ continue;
+ }
- Buffer.BltColorFill(EmptyRect, BackColor);
-}
+ if (graphic != GfxGraphicLast[x][y]) // new graphic
+ {
+ redraw = TRUE;
-void DDScrollBuffer_Blt_Ext(Bitmap *target_bitmap)
-{
- RECT DR, SR;
- long tX, tY, L;
- // RECT ERect;
- // long Restore;
+ 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 (NoDisplayFlag)
- return;
+ if (redraw)
+ {
+ int sx = x * StretchWidth;
+ int sy = y * StretchWidth;
+#if DEBUG_REDRAW
#if 0
- // --- On Error GoTo BltEH
- DirectX.GetWindowRect(mhWnd, DR);
- // --- On Error GoTo 0
+ printf("::: REDRAW (%d, %d): %d, %d\n", x, y, graphic, sync_frame);
+#endif
#endif
- {
- tX = (DR.right - DR.left) / Stretch;
- tY = (DR.bottom - DR.top) / Stretch;
- }
- {
- SR.left = mScrollX + mDestXOff;
- SR.top = mScrollY + mDestYOff;
- SR.right = SR.left + tX;
- SR.bottom = SR.top + tY;
- // If mWidth < SR.right Then
- // SR.right = mWidth
- // DR.right = DR.left + Stretch * (SR.right - SR.left)
- // End If
- // If mHeight < SR.bottom Then
- // SR.bottom = mHeight
- // DR.bottom = DR.top + Stretch * (SR.bottom - SR.top)
- // End If
- // If (mScrollX + mDestXOff) < 0 Then
- // SR.left = 0
- // DR.left = DR.left - Stretch * (mScrollX + mDestXOff)
- // End If
- // If (mScrollY + mDestYOff) < 0 Then
- // SR.top = 0
- // DR.top = DR.top - Stretch * (mScrollY + mDestYOff)
- // End If
- }
-
-#if 1
+ DDSpriteBuffer_BltImg(sx, sy, graphic, sync_frame);
-#if 0
- printf("::: DDScrollBuffer.c: DDScrollBuffer_Blt(): blit from %d, %d [%ld, %ld] [%ld, %ld]\n",
- SR.left, SR.top, mScrollX, mScrollY, mDestXOff, mDestYOff);
+#if DEBUG_REDRAW
+ num_redrawn++;
#endif
+ }
+ }
+ }
-#if 0
- /* !!! quick and dirty -- FIX THIS !!! */
- if (tape.playing && tape.fast_forward &&
- target_bitmap == window &&
- (FrameCounter % 2) != 0)
- printf("::: FrameCounter == %d\n", FrameCounter);
+#if DEBUG_REDRAW
+ printf("::: FRAME %d: %d redrawn\n", FrameCounter, num_redrawn);
#endif
+}
-#if 1
- SyncDisplay();
-#endif
+/* copy the entire screen to the window at the scroll position */
-#if 1
- BlitBitmap(screenBitmap, target_bitmap,
- SR.left, SR.top,
- SCR_FIELDX * TILEX, SCR_FIELDY * TILEY, SX, SY);
+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;
+
+#if 0
+ printf("::: %d, %d / %d, %d / %ld, %ld (%ld, %ld) / %d, %d\n",
+ MurphyScreenXPos, MurphyScreenYPos,
+ ScreenScrollXPos, ScreenScrollYPos,
+ mScrollX, mScrollY,
+ mScrollX_last, mScrollY_last,
+ px, py);
#endif
-#if 1
- FlushDisplay();
+ int xsize = SXSIZE;
+ int ysize = SYSIZE;
+#if NEW_TILESIZE
+ int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR;
+ int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR;
+#else
+ int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX;
+ int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY;
#endif
- return;
+#if NEW_TILESIZE
#endif
- // DDraw.WaitForVerticalBlank DDWAITVB_BLOCKBEGIN, 0
- if (IS_NOTHING(&Buffer, sizeof(Buffer)))
- return;
+ 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);
- if (IS_NOTHING(&PrimarySurface, sizeof(PrimarySurface)))
- return;
+ /* scroll correction for even number of visible tiles (half tile shifted) */
+ px += game_sp.scroll_xoffset;
+ py += game_sp.scroll_yoffset;
- L = PrimarySurface.Blt(DR, &Buffer, SR, DDBLT_WAIT);
- if (L != DD_OK)
+#if 1
+ if (ExplosionShakeMurphy != 0)
{
- switch (L)
- {
-#if 0
- case DDERR_GENERIC:
- Debug.Assert(False);
- break;
-
- case DDERR_INVALIDCLIPLIST:
- Debug.Assert(False);
- break;
-
- case DDERR_INVALIDOBJECT:
- Debug.Assert(False);
- break;
-
- case DDERR_INVALIDPARAMS:
- Debug.Assert(False);
- break;
-
- case DDERR_INVALIDRECT:
- Debug.Assert(False);
- break;
-
- case DDERR_NOALPHAHW:
- Debug.Assert(False);
- break;
-
- case DDERR_NOBLTHW:
- Debug.Assert(False);
- break;
-
- case DDERR_NOCLIPLIST:
- Debug.Assert(False);
- break;
-
- case DDERR_NODDROPSHW:
- Debug.Assert(False);
- break;
+ px += TILEX / 2 - GetSimpleRandom(TILEX + 1);
+ py += TILEY / 2 - GetSimpleRandom(TILEX + 1);
+ }
+#endif
- case DDERR_NOMIRRORHW:
- Debug.Assert(False);
- break;
+#if NEW_TILESIZE
+ px = px * TILESIZE_VAR / TILESIZE;
+ py = py * TILESIZE_VAR / TILESIZE;
+#endif
- case DDERR_NORASTEROPHW:
- Debug.Assert(False);
- break;
+#if 0
+ printf("::: (%d, %d) (%d, %d) (%d, %d) [%d / %d]\n",
+ px, py, sxsize, sysize, sx, sy,
+ FieldHeight, menBorder);
+#endif
- case DDERR_NOROTATIONHW:
- Debug.Assert(False);
- break;
+#if 0
+ printf("::: (%d, %d)\n",
+ bitmap_db_field_sp->width, bitmap_db_field_sp->height);
+#endif
- case DDERR_NOSTRETCHHW:
- Debug.Assert(False);
- break;
+ BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy);
+}
- case DDERR_NOZBUFFERHW:
- Debug.Assert(False);
- break;
+void BackToFront_SP(void)
+{
+ static int scroll_x_last = -1, scroll_y_last = -1;
+ static boolean scrolling_last = FALSE;
+ static boolean ExplosionShakeMurphy_last = -1;
+#if 1
+ boolean scrolling = (mScrollX != scroll_x_last || mScrollY != scroll_y_last);
+ // boolean scrolling = (mScrollX != mScrollX_last || mScrollY != mScrollY_last);
+#else
+ boolean scrolling = (mScrollX % TILEX != 0 || mScrollY % TILEY != 0);
+#endif
+ int x, y;
- case DDERR_SURFACEBUSY:
- Debug.Assert(False);
- break;
+#if 0
+ printf("::: %d, %d / %d, %d [%d, %d]\n",
+ mScrollX, mScrollY,
+ mScrollX_last, mScrollY_last,
+ game_sp.scroll_xoffset, game_sp.scroll_yoffset);
#endif
- case DDERR_SURFACELOST:
- DDraw.RestoreAllSurfaces();
- if (! PrimarySurface.isLost())
- {
- subDisplayLevel();
- // Blt();
- }
+ SyncDisplay();
- // RestorePrimarySurface
- // ClipToWindow 0
- break;
+ if (redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last ||
+ ExplosionShakeMurphy != 0 || ExplosionShakeMurphy_last != 0)
+ {
+ BlitScreenToBitmap_SP(window);
+ }
+ else
+ {
+ int scroll_xoffset = mScrollX - mScrollX_last + game_sp.scroll_xoffset;
+ int scroll_yoffset = mScrollY - mScrollY_last + game_sp.scroll_yoffset;
+ int x1 = 0, x2 = SCR_FIELDX - (scroll_xoffset != 0 ? 0 : 1);
+ int y1 = 0, y2 = SCR_FIELDY - (scroll_yoffset != 0 ? 0 : 1);
+#if NEW_TILESIZE
+ int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR;
+ int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR;
+#else
+ int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX;
+ int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY;
+#endif
+ int sx = SX + (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0);
+ int sy = SY + (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0);
-#if 0
- case DDERR_UNSUPPORTED:
- Debug.Assert(False);
- break;
+ InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE);
- case DDERR_WASSTILLDRAWING:
- Debug.Assert(False);
- break;
+#if NEW_TILESIZE
+ scroll_xoffset = scroll_xoffset * TILESIZE_VAR / TILESIZE;
+ scroll_yoffset = scroll_yoffset * TILESIZE_VAR / TILESIZE;
+#endif
- default:
- Debug.Assert(False);
- break;
+ for (x = x1; x <= x2; x++)
+ {
+ for (y = y1; y <= y2; y++)
+ {
+ int xx = 2 + x;
+ int yy = 2 + y;
+
+#if NEW_TILESIZE
+ if (redraw[xx][yy])
+ BlitBitmap(bitmap_db_field_sp, window,
+ xx * TILEX_VAR, yy * TILEY_VAR, TILEX_VAR, TILEY_VAR,
+ sx + x * TILEX_VAR - scroll_xoffset,
+ sy + y * TILEY_VAR - scroll_yoffset);
+#else
+ if (redraw[xx][yy])
+ BlitBitmap(bitmap_db_field_sp, window,
+ xx * TILEX, yy * TILEY, TILEX, TILEY,
+ sx + x * TILEX - scroll_xoffset,
+ sy + y * TILEY - scroll_yoffset);
#endif
+ }
}
+
+ InitGfxClipRegion(FALSE, -1, -1, -1, -1);
}
-#if 0
- // Buffer.UpdateOverlay SR, PrimarySurface, DR, DDOVER_SHOW
- if (EditFlag)
- FMark.RefreshMarker();
-#endif
+ FlushDisplay();
- // BltEH:
-}
+#if 1
+ for (x = 0; x < 2 + MAX_PLAYFIELD_WIDTH + 2; x++)
+ for (y = 0; y < 2 + MAX_PLAYFIELD_HEIGHT + 2; y++)
+ redraw[x][y] = FALSE;
+#else
+ for (x = 0; x < MAX_BUF_XSIZE; x++)
+ for (y = 0; y < MAX_BUF_YSIZE; y++)
+ redraw[x][y] = FALSE;
+#endif
+ redraw_tiles = 0;
-void DDScrollBuffer_Blt()
-{
- DDScrollBuffer_Blt_Ext(window);
+ scroll_x_last = mScrollX;
+ scroll_y_last = mScrollY;
+ scrolling_last = scrolling;
+ ExplosionShakeMurphy_last = ExplosionShakeMurphy;
}
void DDScrollBuffer_ScrollTo(int X, int Y)
if (NoDisplayFlag)
return;
- X = X / Stretch;
- Y = Y / Stretch;
- mScrollX = X;
- mScrollY = Y;
- ScrollX = mScrollX;
- ScrollY = mScrollY;
+ ScrollX = mScrollX = X;
+ ScrollY = mScrollY = Y;
-#if 0
- printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTo(): mScroll: %ld, %ld [%d, %d]\n",
- mScrollX, mScrollY, X, Y);
-#endif
+ ScrollPlayfieldIfNeeded();
}
void DDScrollBuffer_ScrollTowards(int X, int Y, double Step)
if (NoDisplayFlag)
return;
-#if 0
- printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTowards(): (1) mScroll: %ld, %ld [%d, %d, %f]\n",
- mScrollX, mScrollY, X, Y, Step);
-#endif
-
- X = X / Stretch;
- Y = Y / Stretch;
dx = X - mScrollX;
dY = Y - mScrollY;
+
r = Sqr(dx * dx + dY * dY);
- if (r == 0) // we are there already
+ if (r == 0) // we are there already
return;
if (Step < r)
else
r = 1;
- mScrollX = mScrollX + dx * r;
- mScrollY = mScrollY + dY * r;
- ScrollX = mScrollX;
- ScrollY = mScrollY;
+ ScrollX = mScrollX = mScrollX + dx * r;
+ ScrollY = mScrollY = mScrollY + dY * r;
-#if 0
- printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTowards(): (2) mScroll: %ld, %ld [%d, %d, %f]\n",
- mScrollX, mScrollY, X, Y, Step);
-#endif
+ ScrollPlayfieldIfNeeded();
}
void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS)
{
double dx, dY;
-#if 0
- TickCountObject Tick;
-#endif
long dT, StepCount;
double T, tStep;
long oldX, oldY, maxD;
return;
if (AlreadyRunning)
- {
return;
- }
AlreadyRunning = True;
- X = X / Stretch;
- Y = Y / Stretch;
+
dx = X - mScrollX;
dY = Y - mScrollY;
maxD = (Abs(dx) < Abs(dY) ? Abs(dY) : Abs(dx));
+
StepCount = FPS * (TimeMS / (double)1000);
if (StepCount > maxD)
StepCount = maxD;
tStep = (double)1 / StepCount;
oldX = mScrollX;
oldY = mScrollY;
- // R = Sqr(dX * dX + dY * dY)
- // If R = 0 Then Exit Sub 'we are there already
+
for (T = (double)tStep; T <= (double)1; T += tStep)
{
- if (UserDragFlag)
- goto SoftScrollEH;
-
- // If Claim Then Exit For
-
-#if 0
- Tick.DelayMS(dT, False);
-#endif
-
- mScrollX = oldX + T * dx;
- mScrollY = oldY + T * dY;
- ScrollX = mScrollX;
- ScrollY = mScrollY;
- // Blt();
+ ScrollX = mScrollX = oldX + T * dx;
+ ScrollY = mScrollY = oldY + T * dY;
}
- if (UserDragFlag)
- goto SoftScrollEH;
-
-#if 0
- Tick.DelayMS(dT, False);
-#endif
-
- mScrollX = X;
- mScrollY = Y;
- ScrollX = mScrollX;
- ScrollY = mScrollY;
- // Blt();
+ ScrollX = mScrollX = X;
+ ScrollY = mScrollY = Y;
-SoftScrollEH:
AlreadyRunning = False;
-#if 0
- printf("::: DDScrollBuffer.c: DDScrollBuffer_SoftScrollTo(): mScroll: %ld, %ld\n",
- mScrollX, mScrollY);
-#endif
+ ScrollPlayfieldIfNeeded();
}