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, imgFrameCorner);
82 DrawImage(LX, BY, imgFrameCorner);
83 DrawImage(RX, tY, imgFrameCorner);
84 DrawImage(RX, BY, imgFrameCorner);
86 for (i = LX + 1; i <= RX - 1; i++)
88 DrawImage(i, tY, imgFrameHorizontal);
89 DrawImage(i, BY, imgFrameHorizontal);
92 for (i = tY + 1; i <= BY - 1; i++)
94 DrawImage(LX, i, imgFrameVertical);
95 DrawImage(RX, i, imgFrameVertical);
99 static void RestoreFrame()
101 int i, LX, tY, RX, BY;
106 BY = FieldHeight - 1;
108 for (i = LX; i <= RX; i++)
114 for (i = tY + 1; i <= BY - 1; i++)
121 void SetDisplayRegion()
127 DisplayMaxX = FieldWidth - 2;
128 DisplayMaxY = FieldHeight - 2;
137 DisplayMaxX = FieldWidth - 1;
138 DisplayMaxY = FieldHeight - 1;
149 subFetchAndInitLevelB();
153 subMainGameLoop_Init();
161 subFetchAndInitLevel();
164 static void ReStretch()
172 ScrollTo(ScrollX, ScrollY);
177 subCalculateScreenScrollPos();
179 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
182 void SetScrollEdges()
185 int border_offset = (menBorder ? 1 : 2);
189 ScrollMaxX = (DisplayMaxX + border_offset) * BaseWidth - SXSIZE;
190 ScrollMaxY = (DisplayMaxY + border_offset) * BaseWidth - SYSIZE;
195 ScrollMinX += TILEX / 2;
196 ScrollMinY += TILEY / 2;
197 ScrollMaxX -= TILEX / 2;
198 ScrollMaxY -= TILEY / 2;
202 ScrollMinX -= game_sp.scroll_xoffset;
203 ScrollMaxX -= game_sp.scroll_xoffset;
204 ScrollMinY -= game_sp.scroll_yoffset;
205 ScrollMaxY -= game_sp.scroll_yoffset;
210 ScrollMinX -= TILEX / 2;
211 ScrollMaxX -= TILEX / 2;
212 ScrollMinY -= TILEY / 2;
213 ScrollMaxY -= TILEY / 2;
219 ScrollMinX += TILEX / 2;
220 ScrollMinY += TILEY / 2;
221 ScrollMaxX -= TILEX / 2;
222 ScrollMaxY -= TILEY / 2;
227 ScrollMinX = (int)(DisplayMinX - 0.5) * BaseWidth;
228 ScrollMinY = (int)(DisplayMinY - 0.5) * BaseWidth;
229 ScrollMaxX = (int)(DisplayMaxX + 1.5) * BaseWidth - SXSIZE;
230 ScrollMaxY = (int)(DisplayMaxY + 1.5) * BaseWidth - SYSIZE;
234 printf("::: (%ld, %ld), (%ld, %ld) -> (%d, %d), (%d, %d)\n",
235 DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
236 ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
240 void DrawField(int X, int Y)
242 int tsi = GetSI(X, Y);
243 int Tmp = LowByte(PlayField16[tsi]);
245 if (Tmp < fiFirst || Tmp > fiLast)
252 Tmp = DisPlayField[tsi];
254 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
256 if (Tmp != fiSpace &&
259 GfxGraphic[X][Y] = fiGraphic[Tmp];
262 void DrawFieldAnimated(int X, int Y)
264 int tsi = GetSI(X, Y);
265 int Tmp = LowByte(PlayField16[tsi]);
270 subDrawAnimatedSnikSnaks(tsi);
274 subDrawAnimatedElectrons(tsi);
282 void DrawFieldNoAnimated(int X, int Y)
284 int tsi = GetSI(X, Y);
285 int Tmp = LowByte(PlayField16[tsi]);
290 subCopyImageToScreen(tsi, aniSpace);
294 subCopyImageToScreen(tsi, aniSpace);
301 if (Tmp < fiFirst || Tmp > fiLast)
308 Tmp = DisPlayField[tsi];
310 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
312 if (Tmp != fiSpace &&
315 GfxGraphic[X][Y] = fiGraphic[Tmp];
321 void DrawImage(int X, int Y, int graphic)
323 DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0);