1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
8 static void DrawFrame(int Delta);
9 static void ReStretch();
11 void DrawField(int X, int Y);
12 void DrawFieldAnimated(int X, int Y);
13 void DrawFieldNoAnimated(int X, int Y);
15 void DrawFrameIfNeeded()
19 /* !!! CHECK THIS !!! */
33 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
35 ClearRectangle(bitmap_db_field_sp, 0, 0, FXSIZE, FYSIZE);
37 ClearRectangle(bitmap_db_field_sp, 0, 0,
38 MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
49 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
50 for (X = DisplayMinX; X <= DisplayMaxX; X++)
51 DrawFieldNoAnimated(X, Y);
53 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
54 for (X = DisplayMinX; X <= DisplayMaxX; X++)
55 DrawFieldAnimated(X, Y);
59 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
60 for (X = DisplayMinX; X <= DisplayMaxX; X++)
72 static void DrawFrame(int Delta)
74 int i, LX, tY, RX, BY;
78 RX = FieldWidth - Delta;
79 BY = FieldHeight - Delta;
81 DrawImage(LX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
82 DrawImage(LX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
83 DrawImage(RX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
84 DrawImage(RX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
86 for (i = LX + 1; i <= RX - 1; i++)
88 DrawImage(i, tY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
89 DrawImage(i, BY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
92 for (i = tY + 1; i <= BY - 1; i++)
94 DrawImage(LX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
95 DrawImage(RX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
101 // ClearRectangle(bitmap_db_field_sp,
105 static void RestoreFrame()
107 int i, LX, tY, RX, BY;
112 BY = FieldHeight - 1;
114 for (i = LX; i <= RX; i++)
120 for (i = tY + 1; i <= BY - 1; i++)
127 void SetDisplayRegion()
133 DisplayMaxX = FieldWidth - 2;
134 DisplayMaxY = FieldHeight - 2;
143 DisplayMaxX = FieldWidth - 1;
144 DisplayMaxY = FieldHeight - 1;
155 subFetchAndInitLevelB();
159 subMainGameLoop_Init();
167 subFetchAndInitLevel();
170 static void ReStretch()
178 ScrollTo(ScrollX, ScrollY);
183 subCalculateScreenScrollPos();
185 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
188 void SetScrollEdges()
192 int pseudo_sxsize = SXSIZE * TILESIZE / TILESIZE_VAR;
193 int pseudo_sysize = SYSIZE * TILESIZE / TILESIZE_VAR;
196 int border1_offset = (menBorder ? 1 : 2);
197 int border2_offset = (menBorder ? 0 : TILESIZE / 2);
199 /* scroll correction for border frame (1 tile) or border element (2 tiles) */
204 ScrollMaxX = (DisplayMaxX + border1_offset - SCR_FIELDX) * TILEX;
205 ScrollMaxY = (DisplayMaxY + border1_offset - SCR_FIELDY) * TILEY;
207 ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - pseudo_sxsize;
208 ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - pseudo_sysize;
211 ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - SXSIZE;
212 ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - SYSIZE;
215 /* scroll correction for border element (half tile on left and right side) */
216 ScrollMinX += border2_offset;
217 ScrollMinY += border2_offset;
218 ScrollMaxX -= border2_offset;
219 ScrollMaxY -= border2_offset;
221 /* scroll correction for even number of visible tiles (half tile shifted) */
222 ScrollMinX -= game_sp.scroll_xoffset;
223 ScrollMaxX -= game_sp.scroll_xoffset;
224 ScrollMinY -= game_sp.scroll_yoffset;
225 ScrollMaxY -= game_sp.scroll_yoffset;
228 printf("::: (%ld, %ld), (%ld, %ld) -> (%d, %d), (%d, %d)\n",
229 DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
230 ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
234 void DrawField(int X, int Y)
236 int tsi = GetSI(X, Y);
237 int Tmp = LowByte(PlayField16[tsi]);
239 if (Tmp < fiFirst || Tmp > fiLast)
246 Tmp = DisPlayField[tsi];
248 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
250 if (Tmp != fiSpace &&
253 GfxGraphic[X][Y] = fiGraphic[Tmp];
256 void DrawFieldAnimated(int X, int Y)
258 int tsi = GetSI(X, Y);
259 int Tmp = LowByte(PlayField16[tsi]);
264 subDrawAnimatedSnikSnaks(tsi);
268 subDrawAnimatedElectrons(tsi);
276 void DrawFieldNoAnimated(int X, int Y)
278 int tsi = GetSI(X, Y);
279 int Tmp = LowByte(PlayField16[tsi]);
284 subCopyImageToScreen(tsi, aniSpace);
288 subCopyImageToScreen(tsi, aniSpace);
295 if (Tmp < fiFirst || Tmp > fiLast)
302 Tmp = DisPlayField[tsi];
304 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
306 if (Tmp != fiSpace &&
309 GfxGraphic[X][Y] = fiGraphic[Tmp];
315 void DrawImage(int X, int Y, int graphic)
317 DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0);