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 !!! */
31 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
32 ClearRectangle(bitmap_db_field_sp, 0, 0, FXSIZE, FYSIZE);
40 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
41 for (X = DisplayMinX; X <= DisplayMaxX; X++)
42 DrawFieldNoAnimated(X, Y);
44 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
45 for (X = DisplayMinX; X <= DisplayMaxX; X++)
46 DrawFieldAnimated(X, Y);
50 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
51 for (X = DisplayMinX; X <= DisplayMaxX; X++)
63 static void DrawFrame(int Delta)
65 int i, LX, tY, RX, BY;
69 RX = FieldWidth - Delta;
70 BY = FieldHeight - Delta;
72 DrawImage(LX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
73 DrawImage(LX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
74 DrawImage(RX, tY, (Delta > 0 ? imgFrameCorner : aniSpace));
75 DrawImage(RX, BY, (Delta > 0 ? imgFrameCorner : aniSpace));
77 for (i = LX + 1; i <= RX - 1; i++)
79 DrawImage(i, tY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
80 DrawImage(i, BY, (Delta > 0 ? imgFrameHorizontal : aniSpace));
83 for (i = tY + 1; i <= BY - 1; i++)
85 DrawImage(LX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
86 DrawImage(RX, i, (Delta > 0 ? imgFrameVertical : aniSpace));
92 // ClearRectangle(bitmap_db_field_sp,
96 static void RestoreFrame()
98 int i, LX, tY, RX, BY;
103 BY = FieldHeight - 1;
105 for (i = LX; i <= RX; i++)
111 for (i = tY + 1; i <= BY - 1; i++)
118 void SetDisplayRegion()
124 DisplayMaxX = FieldWidth - 2;
125 DisplayMaxY = FieldHeight - 2;
134 DisplayMaxX = FieldWidth - 1;
135 DisplayMaxY = FieldHeight - 1;
146 subFetchAndInitLevelB();
150 subMainGameLoop_Init();
153 static void ReStretch()
161 ScrollTo(ScrollX, ScrollY);
166 subCalculateScreenScrollPos();
168 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
171 void SetScrollEdges()
173 int border1_offset = (menBorder ? 1 : 2);
174 int border2_offset = (menBorder ? 0 : TILESIZE / 2);
176 /* scroll correction for border frame (1 tile) or border element (2 tiles) */
179 ScrollMaxX = (DisplayMaxX + border1_offset - SCR_FIELDX) * TILEX;
180 ScrollMaxY = (DisplayMaxY + border1_offset - SCR_FIELDY) * TILEY;
182 /* scroll correction for border element (half tile on left and right side) */
183 ScrollMinX += border2_offset;
184 ScrollMinY += border2_offset;
185 ScrollMaxX -= border2_offset;
186 ScrollMaxY -= border2_offset;
188 /* scroll correction for even number of visible tiles (half tile shifted) */
189 ScrollMinX -= game_sp.scroll_xoffset;
190 ScrollMaxX -= game_sp.scroll_xoffset;
191 ScrollMinY -= game_sp.scroll_yoffset;
192 ScrollMaxY -= game_sp.scroll_yoffset;
195 void DrawField(int X, int Y)
197 int tsi = GetSI(X, Y);
198 int Tmp = LowByte(PlayField16[tsi]);
200 if (Tmp < fiFirst || Tmp > fiLast)
207 Tmp = DisPlayField[tsi];
209 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
211 if (Tmp != fiSpace &&
214 GfxGraphic[X][Y] = fiGraphic[Tmp];
217 void DrawFieldAnimated(int X, int Y)
219 int tsi = GetSI(X, Y);
220 int Tmp = LowByte(PlayField16[tsi]);
225 subDrawAnimatedSnikSnaks(tsi);
229 subDrawAnimatedElectrons(tsi);
237 void DrawFieldNoAnimated(int X, int Y)
239 int tsi = GetSI(X, Y);
240 int Tmp = LowByte(PlayField16[tsi]);
245 subCopyImageToScreen(tsi, aniSpace);
249 subCopyImageToScreen(tsi, aniSpace);
258 void DrawImage(int X, int Y, int graphic)
260 DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0);