34 function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; |
34 function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; |
35 function DrawExplosion(X, Y, Radius: LongInt): Longword; |
35 function DrawExplosion(X, Y, Radius: LongInt): Longword; |
36 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
36 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); |
37 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
37 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); |
38 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
38 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); |
|
39 procedure FillRoundInLandWithIce(X, Y, Radius: LongInt); |
39 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean); |
40 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean); |
40 function LandBackPixel(x, y: LongInt): LongWord; |
41 function LandBackPixel(x, y: LongInt): LongWord; |
41 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); |
42 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); |
42 procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword); |
43 procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword); |
43 procedure DumpLandToLog(x, y, r: LongInt); |
44 procedure DumpLandToLog(x, y, r: LongInt); |
240 LandPixels[t, i]:= 0 |
243 LandPixels[t, i]:= 0 |
241 else |
244 else |
242 LandPixels[t div 2, i div 2]:= 0; |
245 LandPixels[t div 2, i div 2]:= 0; |
243 |
246 |
244 end; |
247 end; |
|
248 |
|
249 |
|
250 function isLandscapeEdge(weight:Longint):boolean; |
|
251 begin |
|
252 result := (weight < 8) and (weight >= 2); |
|
253 end; |
|
254 |
|
255 function isLandscape(weight:Longint):boolean; |
|
256 begin |
|
257 result := weight < 2; |
|
258 end; |
|
259 |
|
260 function isEmptySpace(weight:Longint):boolean; |
|
261 begin |
|
262 result := not isLandscape(weight) and not isLandscapeEdge(weight); |
|
263 end; |
|
264 |
|
265 function getPixelWeight(x, y:Longint): Longint; |
|
266 var |
|
267 i, j:Longint; |
|
268 begin |
|
269 result := 0; |
|
270 for i := x - 1 to x + 1 do |
|
271 for j := y - 1 to y + 1 do |
|
272 begin |
|
273 if (i < 0) or |
|
274 (i > LAND_WIDTH - 1) or |
|
275 (j < 0) or |
|
276 (j > LAND_HEIGHT -1) or |
|
277 ((Land[j, i] and $FF00) = 0) then |
|
278 begin |
|
279 result := result + 1; |
|
280 end; |
|
281 end; |
|
282 end; |
|
283 |
|
284 procedure drawIcePixel(y, x:Longint); |
|
285 var |
|
286 iceSurface: PSDL_Surface; |
|
287 icePixels: PLongwordArray; |
|
288 pictureX, pictureY: LongInt; |
|
289 w, c: LongWord; |
|
290 weight: Longint; |
|
291 begin |
|
292 weight := getPixelWeight(x, y); |
|
293 if isLandscape(weight) then |
|
294 begin |
|
295 // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness |
|
296 c:= $7dc1ccff; |
|
297 // FIXME should be a global value, not set every single pixel. Just for test purposes |
|
298 c:= ($44 shl RShift) or ($97 shl GShift) or ($A9 shl BShift) or ($A0 shl AShift); |
|
299 iceSurface:= SpritesData[sprIceTexture].Surface; |
|
300 pictureX := x mod iceSurface^.w; |
|
301 pictureY := y mod iceSurface^.h; |
|
302 icePixels := iceSurface^.pixels; |
|
303 w:= LandPixels[y, x]; |
|
304 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + |
|
305 (w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
|
306 (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); |
|
307 if w < 128 then w:= w+128; |
|
308 if w > 255 then w:= 255; |
|
309 w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask); |
|
310 //LandPixels[y, x]:= w; |
|
311 LandPixels[y, x]:= addBgColor(w, c); |
|
312 LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]); |
|
313 Land[y, x] := land[y, x] or lfIce; |
|
314 end |
|
315 else if (isLandscapeEdge(weight)) then |
|
316 begin |
|
317 LandPixels[y, x] := $FFB2AF8A; |
|
318 if Land[y, x] > 255 then Land[y, x] := Land[y, x] or lfIce; |
|
319 end; |
|
320 |
|
321 end; |
|
322 |
|
323 function getIncrementInquarter(dx, dy, quarter: Longint): Longint; |
|
324 const directionX : array [0..3] of Longint = (0, 0, 1, -1); |
|
325 const directionY : array [0..3] of Longint = (1, -1, 0, 0); |
|
326 begin |
|
327 getIncrementInquarter := directionX[quarter] * dx + directionY[quarter] * dy; |
|
328 end; |
|
329 |
|
330 function getIncrementInquarter2(dx, dy, quarter: Longint): Longint; |
|
331 const directionY : array [0..3] of Longint = (0, 0, 1, 1); |
|
332 const directionX : array [0..3] of Longint = (1, 1, 0, 0); |
|
333 begin |
|
334 getIncrementInquarter2 := directionX[quarter] * dx + directionY[quarter] * dy; |
|
335 end; |
|
336 |
|
337 procedure FillLandCircleLinesIce(x, y, dx, dy: LongInt); |
|
338 var q, i, t: LongInt; |
|
339 begin |
|
340 for q := 0 to 3 do |
|
341 begin |
|
342 t:= y + getIncrementInquarter(dx, dy, q); |
|
343 if (t and LAND_HEIGHT_MASK) = 0 then |
|
344 for i:= Max(x - getIncrementInquarter2(dx, dy, q), 0) to Min(x + getIncrementInquarter2(dx, dy, q), LAND_WIDTH - 1) do |
|
345 if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255)) then |
|
346 if (cReducedQuality and rqBlurryLand) = 0 then |
|
347 drawIcePixel(t, i) |
|
348 else |
|
349 drawIcePixel(t div 2, i div 2) ; |
|
350 end; |
|
351 end; |
|
352 |
|
353 procedure FillRoundInLandWithIce(X, Y, Radius: LongInt); |
|
354 var dx, dy, d: LongInt; |
|
355 begin |
|
356 dx:= 0; |
|
357 dy:= Radius; |
|
358 d:= 3 - 2 * Radius; |
|
359 while (dx < dy) do |
|
360 begin |
|
361 FillLandCircleLinesIce(x, y, dx, dy); |
|
362 if (d < 0) then |
|
363 d:= d + 4 * dx + 6 |
|
364 else |
|
365 begin |
|
366 d:= d + 4 * (dx - dy) + 10; |
|
367 dec(dy) |
|
368 end; |
|
369 inc(dx) |
|
370 end; |
|
371 if (dx = dy) then |
|
372 FillLandCircleLinesIce(x, y, dx, dy); |
|
373 end; |
|
374 |
245 |
375 |
246 function FillLandCircleLinesBG(x, y, dx, dy: LongInt): Longword; |
376 function FillLandCircleLinesBG(x, y, dx, dy: LongInt): Longword; |
247 var i, t, by, bx: LongInt; |
377 var i, t, by, bx: LongInt; |
248 cnt: Longword; |
378 cnt: Longword; |
249 begin |
379 begin |