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);
34 ClearRectangle(screenBitmap, 0, 0,
35 MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
45 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
46 for (X = DisplayMinX; X <= DisplayMaxX; X++)
47 DrawFieldNoAnimated(X, Y);
49 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
50 for (X = DisplayMinX; X <= DisplayMaxX; X++)
51 DrawFieldAnimated(X, Y);
55 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
56 for (X = DisplayMinX; X <= DisplayMaxX; X++)
68 static void DrawFrame(int Delta)
70 int i, LX, tY, RX, BY;
74 RX = FieldWidth - Delta;
75 BY = FieldHeight - Delta;
77 DrawImage(LX, tY, imgFrameCorner);
78 DrawImage(LX, BY, imgFrameCorner);
79 DrawImage(RX, tY, imgFrameCorner);
80 DrawImage(RX, BY, imgFrameCorner);
82 for (i = LX + 1; i <= RX - 1; i++)
84 DrawImage(i, tY, imgFrameHorizontal);
85 DrawImage(i, BY, imgFrameHorizontal);
88 for (i = tY + 1; i <= BY - 1; i++)
90 DrawImage(LX, i, imgFrameVertical);
91 DrawImage(RX, i, imgFrameVertical);
95 static void RestoreFrame()
97 int i, LX, tY, RX, BY;
102 BY = FieldHeight - 1;
104 for (i = LX; i <= RX; i++)
110 for (i = tY + 1; i <= BY - 1; i++)
117 void SetDisplayRegion()
123 DisplayMaxX = FieldWidth - 2;
124 DisplayMaxY = FieldHeight - 2;
133 DisplayMaxX = FieldWidth - 1;
134 DisplayMaxY = FieldHeight - 1;
145 subFetchAndInitLevelB();
149 subMainGameLoop_Init();
157 subFetchAndInitLevel();
160 static void ReStretch()
168 ScrollTo(ScrollX, ScrollY);
173 subCalculateScreenScrollPos();
175 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
178 void SetScrollEdges()
180 ScrollMinX = (int)(DisplayMinX - 0.5) * BaseWidth;
181 ScrollMinY = (int)(DisplayMinY - 0.5) * BaseWidth;
182 ScrollMaxX = (int)(DisplayMaxX + 1.5) * BaseWidth - SXSIZE;
183 ScrollMaxY = (int)(DisplayMaxY + 1.5) * BaseWidth - SYSIZE;
186 void DrawField(int X, int Y)
188 int tsi = GetSI(X, Y);
189 int Tmp = LowByte(PlayField16[tsi]);
191 if (Tmp < fiFirst || Tmp > fiLast)
198 Tmp = DisPlayField[tsi];
200 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
202 if (Tmp != fiSpace &&
205 GfxGraphic[X][Y] = fiGraphic[Tmp];
208 void DrawFieldAnimated(int X, int Y)
210 int tsi = GetSI(X, Y);
211 int Tmp = LowByte(PlayField16[tsi]);
216 subDrawAnimatedSnikSnaks(tsi);
220 subDrawAnimatedElectrons(tsi);
228 void DrawFieldNoAnimated(int X, int Y)
230 int tsi = GetSI(X, Y);
231 int Tmp = LowByte(PlayField16[tsi]);
236 subCopyImageToScreen(tsi, aniSpace);
240 subCopyImageToScreen(tsi, aniSpace);
247 if (Tmp < fiFirst || Tmp > fiLast)
254 Tmp = DisPlayField[tsi];
256 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
258 if (Tmp != fiSpace &&
261 GfxGraphic[X][Y] = fiGraphic[Tmp];
267 void DrawImage(int X, int Y, int graphic)
269 DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0);