79 end |
79 end |
80 else if ((Land[landY, landX] and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then |
80 else if ((Land[landY, landX] and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then |
81 LandPixels[pixelY, pixelX]:= 0 |
81 LandPixels[pixelY, pixelX]:= 0 |
82 end; |
82 end; |
83 end; |
83 end; |
84 |
84 |
85 procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint); inline; |
85 procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint); inline; |
86 begin |
86 begin |
87 if ((Land[landY, landX] and lfBasic) <> 0) or ((Land[landY, landX] and lfObject) <> 0) then |
87 if ((Land[landY, landX] and lfBasic) <> 0) or ((Land[landY, landX] and lfObject) <> 0) then |
88 begin |
88 begin |
89 LandPixels[pixelY, pixelX]:= ExplosionBorderColor; |
89 LandPixels[pixelY, pixelX]:= ExplosionBorderColor; |
90 Land[landY, landX]:= (Land[landY, landX] or lfDamaged) and not lfIce; |
90 Land[landY, landX]:= (Land[landY, landX] or lfDamaged) and not lfIce; |
91 LandDirty[landY div 32, landX div 32]:= 1; |
91 LandDirty[landY div 32, landX div 32]:= 1; |
92 end; |
92 end; |
93 end; |
93 end; |
94 |
94 |
95 function isLandscapeEdge(weight:Longint):boolean; inline; |
95 function isLandscapeEdge(weight:Longint):boolean; inline; |
96 begin |
96 begin |
97 result := (weight < 8) and (weight >= 2); |
97 result := (weight < 8) and (weight >= 2); |
98 end; |
98 end; |
99 |
99 |
100 function getPixelWeight(x, y:Longint): Longint; |
100 function getPixelWeight(x, y:Longint): Longint; |
101 var |
101 var |
102 i, j:Longint; |
102 i, j:Longint; |
103 begin |
103 begin |
104 result := 0; |
104 result := 0; |
138 if w > 255 then w:= 255; |
138 if w > 255 then w:= 255; |
139 w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[pixelY, pixelX] and AMask); |
139 w:= (w shl RShift) or (w shl BShift) or (w shl GShift) or (LandPixels[pixelY, pixelX] and AMask); |
140 LandPixels[pixelY, pixelX]:= addBgColor(w, IceColor); |
140 LandPixels[pixelY, pixelX]:= addBgColor(w, IceColor); |
141 LandPixels[pixelY, pixelX]:= addBgColor(LandPixels[pixelY, pixelX], icePixels^[iceSurface^.w * (pixelY mod iceSurface^.h) + (pixelX mod iceSurface^.w)]) |
141 LandPixels[pixelY, pixelX]:= addBgColor(LandPixels[pixelY, pixelX], icePixels^[iceSurface^.w * (pixelY mod iceSurface^.h) + (pixelX mod iceSurface^.w)]) |
142 end |
142 end |
143 else |
143 else |
144 begin |
144 begin |
145 LandPixels[pixelY, pixelX]:= IceColor and not AMask or $E8 shl AShift; |
145 LandPixels[pixelY, pixelX]:= IceColor and not AMask or $E8 shl AShift; |
146 LandPixels[pixelY, pixelX]:= addBgColor(LandPixels[pixelY, pixelX], icePixels^[iceSurface^.w * (pixelY mod iceSurface^.h) + (pixelX mod iceSurface^.w)]); |
146 LandPixels[pixelY, pixelX]:= addBgColor(LandPixels[pixelY, pixelX], icePixels^[iceSurface^.w * (pixelY mod iceSurface^.h) + (pixelX mod iceSurface^.w)]); |
147 // silly workaround to avoid having to make background erasure a tadb it smarter about sea ice |
147 // silly workaround to avoid having to make background erasure a tadb it smarter about sea ice |
148 if LandPixels[pixelY, pixelX] and AMask shr AShift = 255 then |
148 if LandPixels[pixelY, pixelX] and AMask shr AShift = 255 then |
149 LandPixels[pixelY, pixelX]:= LandPixels[pixelY, pixelX] and not AMask or 254 shl AShift; |
149 LandPixels[pixelY, pixelX]:= LandPixels[pixelY, pixelX] and not AMask or 254 shl AShift; |
150 end; |
150 end; |
151 end; |
151 end; |
152 |
152 |
153 |
153 |
175 //get rid of compiler warning |
175 //get rid of compiler warning |
176 px := 0; |
176 px := 0; |
177 py := 0; |
177 py := 0; |
178 FillLandCircleLine := 0; |
178 FillLandCircleLine := 0; |
179 case fill of |
179 case fill of |
180 backgroundPixel: |
180 backgroundPixel: |
181 for i:= fromPix to toPix do |
181 for i:= fromPix to toPix do |
182 begin |
182 begin |
183 calculatePixelsCoordinates(i, y, px, py); |
183 calculatePixelsCoordinates(i, y, px, py); |
184 inc(FillLandCircleLine, drawPixelBG(i, y, px, py)); |
184 inc(FillLandCircleLine, drawPixelBG(i, y, px, py)); |
185 end; |
185 end; |
186 ebcPixel: |
186 ebcPixel: |
187 for i:= fromPix to toPix do |
187 for i:= fromPix to toPix do |
188 begin |
188 begin |
189 calculatePixelsCoordinates(i, y, px, py); |
189 calculatePixelsCoordinates(i, y, px, py); |
190 drawPixelEBC(i, y, px, py); |
190 drawPixelEBC(i, y, px, py); |
191 end; |
191 end; |
192 nullPixel: |
192 nullPixel: |
193 for i:= fromPix to toPix do |
193 for i:= fromPix to toPix do |
194 begin |
194 begin |
195 calculatePixelsCoordinates(i, y, px, py); |
195 calculatePixelsCoordinates(i, y, px, py); |
196 if ((Land[y, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[y, i] > 255)) then |
196 if ((Land[y, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[y, i] > 255)) then |
197 LandPixels[py, px]:= 0 |
197 LandPixels[py, px]:= 0 |
198 end; |
198 end; |
199 icePixel: |
199 icePixel: |
200 for i:= fromPix to toPix do |
200 for i:= fromPix to toPix do |
201 begin |
201 begin |
202 calculatePixelsCoordinates(i, y, px, py); |
202 calculatePixelsCoordinates(i, y, px, py); |
203 DrawPixelIce(i, y, px, py); |
203 DrawPixelIce(i, y, px, py); |
204 end; |
204 end; |
205 setNotCurrentMask: |
205 setNotCurrentMask: |
206 for i:= fromPix to toPix do |
206 for i:= fromPix to toPix do |
207 begin |
207 begin |
208 Land[y, i]:= Land[y, i] and lfNotCurrentMask; |
208 Land[y, i]:= Land[y, i] and lfNotCurrentMask; |
209 end; |
209 end; |
210 changePixelSetNotCurrent: |
210 changePixelSetNotCurrent: |
211 for i:= fromPix to toPix do |
211 for i:= fromPix to toPix do |
212 begin |
212 begin |
213 if Land[y, i] and lfObjMask > 0 then |
213 if Land[y, i] and lfObjMask > 0 then |
214 Land[y, i]:= (Land[y, i] and lfNotObjMask) or ((Land[y, i] and lfObjMask) - 1); |
214 Land[y, i]:= (Land[y, i] and lfNotObjMask) or ((Land[y, i] and lfObjMask) - 1); |
215 end; |
215 end; |
216 setCurrentHog: |
216 setCurrentHog: |
217 for i:= fromPix to toPix do |
217 for i:= fromPix to toPix do |
218 begin |
218 begin |
219 Land[y, i]:= Land[y, i] or lfCurrentHog |
219 Land[y, i]:= Land[y, i] or lfCurrentHog |
220 end; |
220 end; |
221 changePixelNotSetNotCurrent: |
221 changePixelNotSetNotCurrent: |
222 for i:= fromPix to toPix do |
222 for i:= fromPix to toPix do |
223 begin |
223 begin |
224 if Land[y, i] and lfObjMask < lfObjMask then |
224 if Land[y, i] and lfObjMask < lfObjMask then |
225 Land[y, i]:= (Land[y, i] and lfNotObjMask) or ((Land[y, i] and lfObjMask) + 1) |
225 Land[y, i]:= (Land[y, i] and lfNotObjMask) or ((Land[y, i] and lfObjMask) + 1) |
226 end; |
226 end; |
227 end; |
227 end; |
228 end; |
228 end; |
229 |
229 |
230 function FillLandCircleSegment(x, y, dx, dy: LongInt; fill : fillType): Longword; inline; |
230 function FillLandCircleSegment(x, y, dx, dy: LongInt; fill : fillType): Longword; inline; |
231 begin |
231 begin |
232 FillLandCircleSegment := 0; |
232 FillLandCircleSegment := 0; |
233 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
233 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then |
234 inc(FillLandCircleSegment, FillLandCircleLine(y + dy, Max(x - dx, 0), Min(x + dx, LAND_WIDTH - 1), fill)); |
234 inc(FillLandCircleSegment, FillLandCircleLine(y + dy, Max(x - dx, 0), Min(x + dx, LAND_WIDTH - 1), fill)); |
359 begin |
359 begin |
360 for j := min(max(y, 0), LAND_HEIGHT - 1) to min(max(y + iceHeight, 0), LAND_HEIGHT - 1) do |
360 for j := min(max(y, 0), LAND_HEIGHT - 1) to min(max(y + iceHeight, 0), LAND_HEIGHT - 1) do |
361 begin |
361 begin |
362 if Land[j, i] = 0 then |
362 if Land[j, i] = 0 then |
363 begin |
363 begin |
364 Land[j, i] := lfIce; |
364 Land[j, i] := lfIce; |
365 fillPixelFromIceSprite(i, j); |
365 fillPixelFromIceSprite(i, j); |
366 end; |
366 end; |
367 end; |
367 end; |
368 end; |
368 end; |
369 landRect.x := min(max(x - iceRadius, 0), LAND_WIDTH - 1); |
369 landRect.x := min(max(x - iceRadius, 0), LAND_WIDTH - 1); |
370 landRect.y := min(max(y, 0), LAND_HEIGHT - 1); |
370 landRect.y := min(max(y, 0), LAND_HEIGHT - 1); |
371 landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1); |
371 landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1); |
372 landRect.h := min(iceHeight, LAND_HEIGHT - landRect.y - 1); |
372 landRect.h := min(iceHeight, LAND_HEIGHT - landRect.y - 1); |
373 UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true); |
373 UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true); |
374 end; |
374 end; |
375 |
375 |
376 function DrawExplosion(X, Y, Radius: LongInt): Longword; |
376 function DrawExplosion(X, Y, Radius: LongInt): Longword; |
377 var |
377 var |
378 tx, ty, dx, dy: Longint; |
378 tx, ty, dx, dy: Longint; |
379 begin |
379 begin |
380 DrawExplosion := FillRoundInLand(x, y, Radius, backgroundPixel); |
380 DrawExplosion := FillRoundInLand(x, y, Radius, backgroundPixel); |
381 if Radius > 20 then |
381 if Radius > 20 then |
382 FillRoundInLand(x, y, Radius - 15, nullPixel); |
382 FillRoundInLand(x, y, Radius - 15, nullPixel); |
383 FillRoundInLand(X, Y, Radius, 0); |
383 FillRoundInLand(X, Y, Radius, 0); |
384 FillRoundInLand(x, y, Radius + 4, ebcPixel); |
384 FillRoundInLand(x, y, Radius + 4, ebcPixel); |