287 icePixels: PLongwordArray; |
277 icePixels: PLongwordArray; |
288 pictureX, pictureY: LongInt; |
278 pictureX, pictureY: LongInt; |
289 w, c: LongWord; |
279 w, c: LongWord; |
290 weight: Longint; |
280 weight: Longint; |
291 begin |
281 begin |
292 weight := getPixelWeight(x, y); |
282 // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness |
293 if isLandscape(weight) then |
283 iceSurface:= SpritesData[sprIceTexture].Surface; |
294 begin |
284 icePixels := iceSurface^.pixels; |
295 // So. 3 parameters here. Ice colour, Ice opacity, and a bias on the greyscaled pixel towards lightness |
285 w:= LandPixels[y, x]; |
296 iceSurface:= SpritesData[sprIceTexture].Surface; |
286 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + |
297 pictureX := x mod iceSurface^.w; |
287 (w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
298 pictureY := y mod iceSurface^.h; |
288 (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); |
299 icePixels := iceSurface^.pixels; |
289 if w < 128 then w:= w+128; |
300 w:= LandPixels[y, x]; |
290 if w > 255 then w:= 255; |
301 w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + |
291 w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask); |
302 (w shr BShift and $FF) * RGB_LUMINANCE_GREEN + |
292 //LandPixels[y, x]:= w; |
303 (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); |
293 LandPixels[y, x]:= addBgColor(w, IceColor); |
304 if w < 128 then w:= w+128; |
294 LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]); |
305 if w > 255 then w:= 255; |
295 end; |
306 w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[y,x] and AMask); |
296 |
307 //LandPixels[y, x]:= w; |
297 function getIncrementInquarter(dx, dy, quarter: Longint): Longint; inline; |
308 LandPixels[y, x]:= addBgColor(w, IceColor); |
|
309 LandPixels[y, x]:= addBgColor(LandPixels[y, x], icePixels^[iceSurface^.w * (y mod iceSurface^.h) + (x mod iceSurface^.w)]); |
|
310 Land[y, x] := land[y, x] or lfIce; |
|
311 end |
|
312 else if (isLandscapeEdge(weight)) then |
|
313 begin |
|
314 LandPixels[y, x] := IceEdgeColor; |
|
315 if Land[y, x] > 255 then Land[y, x] := Land[y, x] or lfIce and not lfDamaged; |
|
316 end; |
|
317 |
|
318 end; |
|
319 |
|
320 function getIncrementInquarter(dx, dy, quarter: Longint): Longint; |
|
321 const directionX : array [0..3] of Longint = (0, 0, 1, -1); |
298 const directionX : array [0..3] of Longint = (0, 0, 1, -1); |
322 const directionY : array [0..3] of Longint = (1, -1, 0, 0); |
299 const directionY : array [0..3] of Longint = (1, -1, 0, 0); |
323 begin |
300 begin |
324 getIncrementInquarter := directionX[quarter] * dx + directionY[quarter] * dy; |
301 getIncrementInquarter := directionX[quarter] * dx + directionY[quarter] * dy; |
325 end; |
302 end; |
326 |
303 |
327 function getIncrementInquarter2(dx, dy, quarter: Longint): Longint; |
304 function getIncrementInquarter2(dx, dy, quarter: Longint): Longint; inline; |
328 const directionY : array [0..3] of Longint = (0, 0, 1, 1); |
305 const directionY : array [0..3] of Longint = (0, 0, 1, 1); |
329 const directionX : array [0..3] of Longint = (1, 1, 0, 0); |
306 const directionX : array [0..3] of Longint = (1, 1, 0, 0); |
330 begin |
307 begin |
331 getIncrementInquarter2 := directionX[quarter] * dx + directionY[quarter] * dy; |
308 getIncrementInquarter2 := directionX[quarter] * dx + directionY[quarter] * dy; |
332 end; |
309 end; |
333 |
310 |
334 procedure FillLandCircleLinesIce(x, y, dx, dy: LongInt); |
311 procedure FillLandCircleLinesIce(x, y, dx, dy: LongInt); |
335 var q, i, t: LongInt; |
312 var q, i, t, px, py: LongInt; |
336 begin |
313 begin |
337 for q := 0 to 3 do |
314 for q := 0 to 3 do |
338 begin |
315 begin |
339 t:= y + getIncrementInquarter(dx, dy, q); |
316 t:= y + getIncrementInquarter(dx, dy, q); |
340 if (t and LAND_HEIGHT_MASK) = 0 then |
317 if (t and LAND_HEIGHT_MASK) = 0 then |
341 for i:= Max(x - getIncrementInquarter2(dx, dy, q), 0) to Min(x + getIncrementInquarter2(dx, dy, q), LAND_WIDTH - 1) do |
318 for i:= Max(x - getIncrementInquarter2(dx, dy, q), 0) to Min(x + getIncrementInquarter2(dx, dy, q), LAND_WIDTH - 1) do |
342 if (Land[t, i] and (lfIndestructible or lfIce) = 0) and (not disableLandBack or (Land[t, i] > 255)) then |
319 if Land[t, i] and lfIce = 0 then |
343 if (cReducedQuality and rqBlurryLand) = 0 then |
320 begin |
344 drawIcePixel(t, i) |
321 if (cReducedQuality and rqBlurryLand) = 0 then |
345 else |
322 begin |
346 drawIcePixel(t div 2, i div 2) ; |
323 px:= i; py:= t |
347 end; |
324 end |
|
325 else |
|
326 begin |
|
327 px:= i div 2; py:= t div 2 |
|
328 end; |
|
329 if isLandscapeEdge(getPixelWeight(i, t)) then |
|
330 begin |
|
331 if Land[t, i] > 255 then Land[t, i] := Land[t, i] or lfIce and not lfDamaged; |
|
332 if (LandPixels[py, px] and AMask < 255) and (LandPixels[py, px] and AMask > 0) then |
|
333 LandPixels[py, px] := (IceEdgeColor and not AMask) or (LandPixels[py, px] and AMask) |
|
334 else if (LandPixels[py, px] and AMask < 255) or (Land[t, i] > 255) then |
|
335 LandPixels[py, px] := IceEdgeColor |
|
336 end |
|
337 else if Land[t, i] > 255 then |
|
338 begin |
|
339 Land[t, i] := Land[t, i] or lfIce and not lfDamaged; |
|
340 drawIcePixel(py, px) |
|
341 end |
|
342 end |
|
343 end |
348 end; |
344 end; |
349 |
345 |
350 procedure FillRoundInLandWithIce(X, Y, Radius: LongInt); |
346 procedure FillRoundInLandWithIce(X, Y, Radius: LongInt); |
351 var dx, dy, d: LongInt; |
347 var dx, dy, d: LongInt; |
352 begin |
348 begin |