- long Width;
-
- Width = mSpriteWidth * mXSpriteCount;
-
- return Width;
-}
-
-int DDSpriteBuffer_Get_Height()
-{
- int Height;
-
- Height = mSpriteHeight * mYSpriteCount;
-
- return Height;
-}
-
-boolean DDSpriteBuffer_CreateFromFile(char *Path, long xSprites, long ySprites)
-{
- boolean CreateFromFile;
-
- DDSURFACEDESC2 SD;
-
- {
- SD.lFlags = DDSD_CAPS; // Or DDSD_WIDTH Or DDSD_HEIGHT
- SD.ddsCaps.lCaps = DDSCAPS_VIDEOMEMORY; // DDSCAPS_SYSTEMMEMORY 'DDSCAPS_OFFSCREENPLAIN
- }
-
- // --- On Error GoTo CreateFromFileEH
-#if 1
- SD.LWidth = 16 * TILEX;
- SD.LHeight = 16 * TILEY;
-#else
- Buffer = DDraw.CreateSurfaceFromFile(Path, SD);
-#endif
- // --- On Error GoTo 0
-
-#if 0
- Buffer.GetSurfaceDesc(SD);
-#endif
-
- mSpriteWidth = SD.LWidth / xSprites;
- mSpriteHeight = SD.LHeight / ySprites;
- mXSpriteCount = xSprites;
- mYSpriteCount = ySprites;
-
- CreateFromFile = True;
- return CreateFromFile;
-
- // CreateFromFileEH:
- CreateFromFile = False;
-
- return CreateFromFile;
-}
-
-boolean DDSpriteBuffer_CreateAtSize(long Width, long Height, long xSprites, long ySprites)
-{
- boolean CreateAtSize;
-
- DDSURFACEDESC2 SD;
-
- {
- SD.lFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- SD.ddsCaps.lCaps = DDSCAPS_VIDEOMEMORY;
- // SD.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
- SD.LWidth = Width;
- SD.LHeight = Height;
- }
-
- // --- On Error GoTo CreateAtSizeEH
- Buffer = DDraw.CreateSurface(SD);
- // --- On Error GoTo 0
-
- mSpriteWidth = Width / xSprites;
- mSpriteHeight = Height / ySprites;
- mXSpriteCount = xSprites;
- mYSpriteCount = ySprites;
- CreateAtSize = True;
- return CreateAtSize;
-
- // CreateAtSizeEH:
- CreateAtSize = False;
-
- return CreateAtSize;
-}
-
-void DDSpriteBuffer_Cls(int BackColor)
-{
- RECT EmptyRect;
-
- Buffer.BltColorFill(EmptyRect, BackColor);
-}
-
-static void Blt(int pX, int pY, int SpriteX, int SpriteY)
-{
- RECT DR, SR;
-#if 0
- long Tmp;
-#endif
-
-#if 0
- printf("::: DDSpriteBuffer.c: Blt(): %d, %d\n", pX, pY);
-#endif
+ int scx = (mScrollX_last < 0 ? 0 : mScrollX_last);
+ int scy = (mScrollY_last < 0 ? 0 : mScrollY_last);
+ int sx1 = scx - 2 * TILEX;
+ int sy1 = scy - 2 * TILEY;
+ int sx2 = scx + (SCR_FIELDX + 1) * TILEX;
+ int sy2 = scy + (SCR_FIELDY + 1) * TILEY;
+ int sx = pX - sx1;
+ int sy = pY - sy1;