changed comments from old to new style (one-line comments only)
[rocksndiamonds.git] / src / game_sp / DDSpriteBuffer.c
index 39f04e76011c4101cfeb8821e0181b28446ae9e6..9865b93053a3ab9467cdc455cf06267317ebb3e9 100644 (file)
@@ -5,53 +5,29 @@
 #include "DDSpriteBuffer.h"
 
 
-long mXSpriteCount, mYSpriteCount;
-long mSpriteWidth, mSpriteHeight;
-long mDestXOff, mDestYOff;
-
-void DDSpriteBuffer_Init()
-{
-  mSpriteWidth  = TILEX;
-  mSpriteHeight = TILEY;
-  mXSpriteCount = 16;
-  mYSpriteCount = 16;
-}
-
 static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY)
 {
-  MyRECT DR, SR;
-
   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 + SXSIZE + 1 * TILEX;
-  int sy2 = scy + SYSIZE + 1 * TILEY;
-
+  int sx2 = scx + (SCR_FIELDX + 1) * TILEX;
+  int sy2 = scy + (SCR_FIELDY + 1) * TILEY;
   int sx = pX - sx1;
   int sy = pY - sy1;
 
   if (NoDisplayFlag)
     return;
 
-  /* do not draw fields that are outside the visible screen area */
+  // do not draw fields that are outside the visible screen area
   if (pX < sx1 || pX > sx2 || pY < sy1 || pY > sy2)
     return;
 
-  DR.left = pX + mDestXOff;
-  DR.top = pY + mDestYOff;
-  DR.right = pX + mSpriteWidth + mDestXOff;
-  DR.bottom = pY + mSpriteHeight + mDestYOff;
-
-  SR.left = SpriteX;
-  SR.top = SpriteY;
-  SR.right = SR.left + mSpriteWidth;
-  SR.bottom = SR.top + mSpriteHeight;
+  sx = sx * TILESIZE_VAR / TILESIZE;
+  sy = sy * TILESIZE_VAR / TILESIZE;
 
-  BlitBitmap(bitmap, screenBitmap,
-            SR.left, SR.top,
-            mSpriteWidth, mSpriteHeight,
-            sx, sy);
+  BlitBitmap(bitmap, bitmap_db_field_sp, SpriteX, SpriteY,
+            TILEX_VAR, TILEY_VAR, sx, sy);
 }
 
 void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame)
@@ -61,6 +37,9 @@ void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame)
   if (NoDisplayFlag)
     return;
 
+  if (graphic < 0)
+    return;
+
   getGraphicSource_SP(&g, graphic, sync_frame, -1, -1);
 
   Blt(pX, pY, g.bitmap, g.src_x, g.src_y);