static void DrawFrame(int Delta);
-static void ReStretch(float NewStretch);
-static void picViewPort_Resize();
+static void ReStretch();
void DrawField(int X, int Y);
void DrawFieldAnimated(int X, int Y);
void DrawFieldNoAnimated(int X, int Y);
-boolean Loaded;
-
void DrawFrameIfNeeded()
{
DrawFrame(0);
{
int X, Y;
- if (! Loaded)
- return;
-
if (! LevelLoaded)
return;
ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
- ClearRectangle(screenBitmap, 0, 0,
+#if 1
+ ClearRectangle(bitmap_db_field_sp, 0, 0, FXSIZE, FYSIZE);
+#else
+ ClearRectangle(bitmap_db_field_sp, 0, 0,
MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
+#endif
#if 1
SetDisplayRegion();
#endif
- DrawFrame(0);
-
- /* !!! CHECK THIS !!! */
-#if 1
- if (! menBorder)
- DrawFrame(1);
-#endif
+ DrawFrameIfNeeded();
if (bPlaying)
{
-#if 0
- printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n",
- DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
- FieldWidth, FieldHeight);
-#endif
-
for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
- {
for (X = DisplayMinX; X <= DisplayMaxX; X++)
- {
DrawFieldNoAnimated(X, Y);
- }
- }
for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
- {
for (X = DisplayMinX; X <= DisplayMaxX; X++)
- {
DrawFieldAnimated(X, Y);
- }
- }
-
}
else
{
for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
- {
for (X = DisplayMinX; X <= DisplayMaxX; X++)
- {
DrawField(X, Y);
- }
- }
}
}
void Form_Load()
{
- Loaded = False;
-
InitGlobals();
- Loaded = True;
-
- ReStretch(Stretch);
+ ReStretch();
}
static void DrawFrame(int Delta)
tY = -1 + Delta;
RX = FieldWidth - Delta;
BY = FieldHeight - Delta;
- DrawImage(LX, tY, imgFrameCorner);
- DrawImage(LX, BY, imgFrameCorner);
- DrawImage(RX, tY, imgFrameCorner);
- DrawImage(RX, BY, imgFrameCorner);
+
+ DrawImage(LX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
+ DrawImage(LX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
+ DrawImage(RX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
+ DrawImage(RX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
+
for (i = LX + 1; i <= RX - 1; i++)
{
- DrawImage(i, tY, imgFrameHorizontal);
- DrawImage(i, BY, imgFrameHorizontal);
+ DrawImage(i, tY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
+ DrawImage(i, BY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
}
for (i = tY + 1; i <= BY - 1; i++)
{
- DrawImage(LX, i, imgFrameVertical);
- DrawImage(RX, i, imgFrameVertical);
+ DrawImage(LX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
+ DrawImage(RX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
+ }
+
+ if (Delta > 0)
+ {
+ // ...
+ // ClearRectangle(bitmap_db_field_sp,
}
}
if (! menBorder)
{
DisplayMinX = 1;
- DisplayMaxX = FieldWidth - 2;
- DisplayWidth = FieldWidth;
DisplayMinY = 1;
+ DisplayMaxX = FieldWidth - 2;
DisplayMaxY = FieldHeight - 2;
- DisplayHeight = FieldHeight;
if (LevelLoaded)
DrawFrame(1);
else
{
DisplayMinX = 0;
- DisplayMaxX = FieldWidth - 1;
- DisplayWidth = FieldWidth + 2;
DisplayMinY = 0;
+ DisplayMaxX = FieldWidth - 1;
DisplayMaxY = FieldHeight - 1;
- DisplayHeight = FieldHeight + 2;
if (LevelLoaded)
RestoreFrame();
subFetchAndInitLevelB();
- ReStretch(Stretch);
+ ReStretch();
subMainGameLoop_Init();
subFetchAndInitLevel();
}
-static void ReStretch(float NewStretch)
+static void ReStretch()
{
- long BW2, LW, LH;
-
- if (! Loaded)
+ if (LevelLoaded)
{
- Stretch = NewStretch;
-
- return;
- }
+ SetDisplayRegion();
- Stretch = NewStretch;
+ SetScrollEdges();
- BW2 = StretchWidth / 2;
- LW = (FieldWidth + 2) * BaseWidth; // StretchWidth
- LH = (FieldHeight + 2) * BaseWidth; // StretchWidth
+ ScrollTo(ScrollX, ScrollY);
- if (Loaded && LevelLoaded)
- {
- SetDisplayRegion();
- picViewPort_Resize();
DisplayLevel();
}
void SetScrollEdges()
{
- ScrollMinX = (int)(DisplayMinX - 0.5) * Stretch * BaseWidth;
- ScrollMinY = (int)(DisplayMinY - 0.5) * Stretch * BaseWidth;
- ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - SXSIZE;
- ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - SYSIZE;
+#if NEW_TILESIZE
+#if 0
+ int pseudo_sxsize = SXSIZE * TILESIZE / TILESIZE_VAR;
+ int pseudo_sysize = SYSIZE * TILESIZE / TILESIZE_VAR;
+#endif
+#endif
+ int border1_offset = (menBorder ? 1 : 2);
+ int border2_offset = (menBorder ? 0 : TILESIZE / 2);
+
+ /* scroll correction for border frame (1 tile) or border element (2 tiles) */
+ ScrollMinX = 0;
+ ScrollMinY = 0;
+#if NEW_TILESIZE
+#if 1
+ ScrollMaxX = (DisplayMaxX + border1_offset - SCR_FIELDX) * TILEX;
+ ScrollMaxY = (DisplayMaxY + border1_offset - SCR_FIELDY) * TILEY;
+#else
+ ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - pseudo_sxsize;
+ ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - pseudo_sysize;
+#endif
+#else
+ ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - SXSIZE;
+ ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - SYSIZE;
+#endif
+
+ /* scroll correction for border element (half tile on left and right side) */
+ ScrollMinX += border2_offset;
+ ScrollMinY += border2_offset;
+ ScrollMaxX -= border2_offset;
+ ScrollMaxY -= border2_offset;
+
+ /* scroll correction for even number of visible tiles (half tile shifted) */
+ ScrollMinX -= game_sp.scroll_xoffset;
+ ScrollMaxX -= game_sp.scroll_xoffset;
+ ScrollMinY -= game_sp.scroll_yoffset;
+ ScrollMaxY -= game_sp.scroll_yoffset;
+
+#if 0
+ printf("::: (%ld, %ld), (%ld, %ld) -> (%d, %d), (%d, %d)\n",
+ DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
+ ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
+#endif
}
void DrawField(int X, int Y)
{
- int Tmp, tsi;
+ int tsi = GetSI(X, Y);
+ int Tmp = LowByte(PlayField16[tsi]);
- tsi = GetSI(X, Y);
- Tmp = LowByte(PlayField16[tsi]);
- if (Tmp > 40)
- Tmp = 0;
+ if (Tmp < fiFirst || Tmp > fiLast)
+ Tmp = fiSpace;
- if (Tmp == fiRAM || Tmp == fiHardWare)
+ if (Tmp == fiRAM ||
+ Tmp == fiHardWare ||
+ Tmp == fiBug ||
+ Tmp == fiWallSpace)
Tmp = DisPlayField[tsi];
- if (Tmp == fiBug || Tmp == 40)
- Tmp = DisPlayField[tsi];
-
-#if 1
- if (Tmp >= 0 && Tmp <= 40)
- {
- subCopyImageToScreen(tsi, fiGraphic[Tmp]);
+ subCopyImageToScreen(tsi, fiGraphic[Tmp]);
-#if 1
- if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron)
- GfxGraphic[X][Y] = fiGraphic[Tmp];
-#endif
- }
-#else
- DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
-#endif
+ if (Tmp != fiSpace &&
+ Tmp != fiSnikSnak &&
+ Tmp != fiElectron)
+ GfxGraphic[X][Y] = fiGraphic[Tmp];
}
void DrawFieldAnimated(int X, int Y)
{
- int Tmp, tsi;
+ int tsi = GetSI(X, Y);
+ int Tmp = LowByte(PlayField16[tsi]);
- tsi = GetSI(X, Y);
- Tmp = LowByte(PlayField16[tsi]);
switch (Tmp)
{
case fiSnikSnak:
break;
default:
- // If 40 < Tmp Then Tmp = 0
- // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi)
- // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi)
- // If EditFlag Then
- // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi)
- // End If
- // DDSpriteBuffer_BltEx StretchWidth * X, StretchWidth * Y, Tmp
break;
}
}
void DrawFieldNoAnimated(int X, int Y)
{
- int Tmp, tsi;
+ int tsi = GetSI(X, Y);
+ int Tmp = LowByte(PlayField16[tsi]);
- tsi = GetSI(X, Y);
- Tmp = LowByte(PlayField16[tsi]);
switch (Tmp)
{
case fiSnikSnak:
break;
default:
- if (Tmp > 40)
- Tmp = 0;
-
- if (Tmp == fiRAM || Tmp == fiHardWare)
- Tmp = DisPlayField[tsi];
+#if 1
+ DrawField(X, Y);
+#else
+ if (Tmp < fiFirst || Tmp > fiLast)
+ Tmp = fiSpace;
- if (Tmp == fiBug || Tmp == 40)
- Tmp = DisPlayField[tsi];
+ if (Tmp == fiRAM ||
+ Tmp == fiHardWare ||
+ Tmp == fiBug ||
+ Tmp == fiWallSpace)
+ Tmp = DisPlayField[tsi];
-#if 1
- if (Tmp >= 0 && Tmp <= 40)
- {
- subCopyImageToScreen(tsi, fiGraphic[Tmp]);
+ subCopyImageToScreen(tsi, fiGraphic[Tmp]);
-#if 1
- if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron)
- GfxGraphic[X][Y] = fiGraphic[Tmp];
-#endif
- }
-#else
- DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
+ if (Tmp != fiSpace &&
+ Tmp != fiSnikSnak &&
+ Tmp != fiElectron)
+ GfxGraphic[X][Y] = fiGraphic[Tmp];
#endif
-
break;
}
}
{
DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0);
}
-
-static void picViewPort_Resize()
-{
- SetScrollEdges();
-
- ScrollTo(ScrollX, ScrollY);
-}