1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
8 static void DrawFrame(int Delta);
9 static void ReStretch(float NewStretch);
10 static void picViewPort_Resize();
12 void DrawField(int X, int Y);
13 void DrawFieldAnimated(int X, int Y);
14 void DrawFieldNoAnimated(int X, int Y);
18 void DrawFrameIfNeeded()
22 /* !!! CHECK THIS !!! */
39 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
40 ClearRectangle(screenBitmap, 0, 0,
41 MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY);
49 /* !!! CHECK THIS !!! */
58 printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n",
59 DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
60 FieldWidth, FieldHeight);
63 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
65 for (X = DisplayMinX; X <= DisplayMaxX; X++)
67 DrawFieldNoAnimated(X, Y);
71 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
73 for (X = DisplayMinX; X <= DisplayMaxX; X++)
75 DrawFieldAnimated(X, Y);
82 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
84 for (X = DisplayMinX; X <= DisplayMaxX; X++)
103 static void DrawFrame(int Delta)
105 int i, LX, tY, RX, BY;
109 RX = FieldWidth - Delta;
110 BY = FieldHeight - Delta;
111 DrawImage(LX, tY, imgFrameCorner);
112 DrawImage(LX, BY, imgFrameCorner);
113 DrawImage(RX, tY, imgFrameCorner);
114 DrawImage(RX, BY, imgFrameCorner);
115 for (i = LX + 1; i <= RX - 1; i++)
117 DrawImage(i, tY, imgFrameHorizontal);
118 DrawImage(i, BY, imgFrameHorizontal);
121 for (i = tY + 1; i <= BY - 1; i++)
123 DrawImage(LX, i, imgFrameVertical);
124 DrawImage(RX, i, imgFrameVertical);
128 static void RestoreFrame()
130 int i, LX, tY, RX, BY;
135 BY = FieldHeight - 1;
137 for (i = LX; i <= RX; i++)
143 for (i = tY + 1; i <= BY - 1; i++)
150 void SetDisplayRegion()
155 DisplayMaxX = FieldWidth - 2;
156 DisplayWidth = FieldWidth;
158 DisplayMaxY = FieldHeight - 2;
159 DisplayHeight = FieldHeight;
167 DisplayMaxX = FieldWidth - 1;
168 DisplayWidth = FieldWidth + 2;
170 DisplayMaxY = FieldHeight - 1;
171 DisplayHeight = FieldHeight + 2;
182 subFetchAndInitLevelB();
186 subMainGameLoop_Init();
194 subFetchAndInitLevel();
197 static void ReStretch(float NewStretch)
203 Stretch = NewStretch;
208 Stretch = NewStretch;
210 BW2 = StretchWidth / 2;
211 LW = (FieldWidth + 2) * BaseWidth; // StretchWidth
212 LH = (FieldHeight + 2) * BaseWidth; // StretchWidth
214 if (Loaded && LevelLoaded)
217 picViewPort_Resize();
221 subCalculateScreenScrollPos();
223 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
226 void SetScrollEdges()
228 ScrollMinX = (int)(DisplayMinX - 0.5) * Stretch * BaseWidth;
229 ScrollMinY = (int)(DisplayMinY - 0.5) * Stretch * BaseWidth;
230 ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - SXSIZE;
231 ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - SYSIZE;
234 void DrawField(int X, int Y)
239 Tmp = LowByte(PlayField16[tsi]);
243 if (Tmp == fiRAM || Tmp == fiHardWare)
244 Tmp = DisPlayField[tsi];
246 if (Tmp == fiBug || Tmp == 40)
247 Tmp = DisPlayField[tsi];
250 if (Tmp >= 0 && Tmp <= 40)
252 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
255 if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron)
256 GfxGraphic[X][Y] = fiGraphic[Tmp];
260 DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
264 void DrawFieldAnimated(int X, int Y)
269 Tmp = LowByte(PlayField16[tsi]);
273 subDrawAnimatedSnikSnaks(tsi);
277 subDrawAnimatedElectrons(tsi);
281 // If 40 < Tmp Then Tmp = 0
282 // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi)
283 // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi)
285 // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi)
287 // DDSpriteBuffer_BltEx StretchWidth * X, StretchWidth * Y, Tmp
292 void DrawFieldNoAnimated(int X, int Y)
297 Tmp = LowByte(PlayField16[tsi]);
301 subCopyImageToScreen(tsi, aniSpace);
305 subCopyImageToScreen(tsi, aniSpace);
312 if (Tmp == fiRAM || Tmp == fiHardWare)
313 Tmp = DisPlayField[tsi];
315 if (Tmp == fiBug || Tmp == 40)
316 Tmp = DisPlayField[tsi];
319 if (Tmp >= 0 && Tmp <= 40)
321 subCopyImageToScreen(tsi, fiGraphic[Tmp]);
324 if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron)
325 GfxGraphic[X][Y] = fiGraphic[Tmp];
329 DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
336 void DrawImage(int X, int Y, int graphic)
338 DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0);
341 static void picViewPort_Resize()
345 ScrollTo(ScrollX, ScrollY);