hedgewars/uLandGraphics.pas
branchtransitional_engine
changeset 15900 128ace913837
parent 15141 af14c418c92f
child 15901 f39f0f614dbf
equal deleted inserted replaced
15899:73cdc306888f 15900:128ace913837
    45 function  LandBackPixel(x, y: LongInt): LongWord;
    45 function  LandBackPixel(x, y: LongInt): LongWord;
    46 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
    46 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
    47 function  DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword): Longword;
    47 function  DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword): Longword;
    48 procedure DumpLandToLog(x, y, r: LongInt);
    48 procedure DumpLandToLog(x, y, r: LongInt);
    49 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
    49 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
    50 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline;
    50 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean;
    51 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline;
    51 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean;
    52 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline;
    52 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean;
    53 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean;
    53 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean;
    54 procedure EraseLandRectRaw(X, Y, width, height: LongWord);
    54 procedure EraseLandRectRaw(X, Y, width, height: LongWord);
    55 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean);
    55 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean);
    56 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;
    56 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;
    57 
    57 
    58 implementation
    58 implementation
    59 uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug, uScript;
    59 uses SDLh, uLandTexture, uTextures, uVariables, uUtils, uDebug, uScript, uLandUtils;
    60 
    60 
    61 
    61 
    62 procedure calculatePixelsCoordinates(landX, landY: Longint; var pixelX, pixelY: Longint); inline;
    62 procedure calculatePixelsCoordinates(landX, landY: Longint; var pixelX, pixelY: Longint);
    63 begin
    63 begin
    64 if (cReducedQuality and rqBlurryLand) = 0 then
    64 if (cReducedQuality and rqBlurryLand) = 0 then
    65     begin
    65     begin
    66     pixelX := landX;
    66     pixelX := landX;
    67     pixelY := landY;
    67     pixelY := landY;
    71     pixelX := LandX div 2;
    71     pixelX := LandX div 2;
    72     pixelY := LandY div 2;
    72     pixelY := LandY div 2;
    73     end;
    73     end;
    74 end;
    74 end;
    75 
    75 
    76 function drawPixelBG(landX, landY, pixelX, pixelY: Longint): Longword; inline;
    76 function drawPixelBG(landX, landY, pixelX, pixelY: Longint): Longword;
    77 begin
    77 begin
    78 drawPixelBG := 0;
    78 drawPixelBG := 0;
    79 if (Land[LandY, landX] and lfIndestructible) = 0 then
    79 if (LandGet(LandY, landX) and lfIndestructible) = 0 then
    80     begin
    80     begin
    81         if ((Land[landY, landX] and lfBasic) <> 0) and (((LandPixels[pixelY, pixelX] and AMask) shr AShift) = 255) and (not disableLandBack) then
    81         if ((LandGet(landY, landX) and lfBasic) <> 0) and (((LandPixels[pixelY, pixelX] and AMask) shr AShift) = 255) and (not disableLandBack) then
    82         begin
    82         begin
    83             LandPixels[pixelY, pixelX]:= LandBackPixel(landX, landY);
    83             LandPixels[pixelY, pixelX]:= LandBackPixel(landX, landY);
    84             inc(drawPixelBG);
    84             inc(drawPixelBG);
    85         end
    85         end
    86         else if ((Land[landY, landX] and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then
    86         else if ((LandGet(landY, landX) and lfObject) <> 0) or (((LandPixels[pixelY, pixelX] and AMask) shr AShift) < 255) then
    87             LandPixels[pixelY, pixelX]:= ExplosionBorderColorNoA
    87             LandPixels[pixelY, pixelX]:= ExplosionBorderColorNoA
    88     end;
    88     end;
    89 end;
    89 end;
    90 
    90 
    91 procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint); inline;
    91 procedure drawPixelEBC(landX, landY, pixelX, pixelY: Longint);
    92 begin
    92 begin
    93 if (Land[landY, landX] and lfIndestructible = 0) and 
    93 if (LandGet(landY, landX) and lfIndestructible = 0) and
    94     (((Land[landY, landX] and lfBasic) <> 0) or ((Land[landY, landX] and lfObject) <> 0)) then
    94     (((LandGet(landY, landX) and lfBasic) <> 0) or ((LandGet(landY, landX) and lfObject) <> 0)) then
    95     begin
    95     begin
    96     LandPixels[pixelY, pixelX]:= ExplosionBorderColor;
    96     LandPixels[pixelY, pixelX]:= ExplosionBorderColor;
    97     Land[landY, landX]:= (Land[landY, landX] or lfDamaged) and (not lfIce);
    97     LandSet(landY, landX, (LandGet(landY, landX) or lfDamaged) and (not lfIce));
    98     LandDirty[landY div 32, landX div 32]:= 1;
    98     LandDirty[landY div 32, landX div 32]:= 1;
    99     end;
    99     end;
   100 end;
   100 end;
   101 
   101 
   102 function isLandscapeEdge(weight:Longint):boolean; inline;
   102 function isLandscapeEdge(weight:Longint):boolean;
   103 begin
   103 begin
   104 isLandscapeEdge := (weight < 8) and (weight >= 2);
   104 isLandscapeEdge := (weight < 8) and (weight >= 2);
   105 end;
   105 end;
   106 
   106 
   107 function getPixelWeight(x, y:Longint): Longint;
   107 function getPixelWeight(x, y:Longint): Longint;
   116        (i > LAND_WIDTH - 1) or
   116        (i > LAND_WIDTH - 1) or
   117        (j < 0) or
   117        (j < 0) or
   118        (j > LAND_HEIGHT -1) then
   118        (j > LAND_HEIGHT -1) then
   119        exit(9);
   119        exit(9);
   120 
   120 
   121     if Land[j, i] and lfLandMask and (not lfIce) = 0 then
   121     if LandGet(j, i) and lfLandMask and (not lfIce) = 0 then
   122        inc(r)
   122        inc(r)
   123     end;
   123     end;
   124 
   124 
   125     getPixelWeight:= r
   125     getPixelWeight:= r
   126 end;
   126 end;
   127 
   127 
   128 
   128 
   129 procedure fillPixelFromIceSprite(pixelX, pixelY:Longint); inline;
   129 procedure fillPixelFromIceSprite(pixelX, pixelY:Longint);
   130 var
   130 var
   131     iceSurface: PSDL_Surface;
   131     iceSurface: PSDL_Surface;
   132     icePixels: PLongwordArray;
   132     icePixels: PLongwordArray;
   133     w: LongWord;
   133     w: LongWord;
   134 begin
   134 begin
   157             LandPixels[pixelY, pixelX]:= LandPixels[pixelY, pixelX] and (not AMask) or 254 shl AShift;
   157             LandPixels[pixelY, pixelX]:= LandPixels[pixelY, pixelX] and (not AMask) or 254 shl AShift;
   158         end;
   158         end;
   159 end;
   159 end;
   160 
   160 
   161 
   161 
   162 procedure DrawPixelIce(landX, landY, pixelX, pixelY: Longint); inline;
   162 procedure DrawPixelIce(landX, landY, pixelX, pixelY: Longint);
   163 begin
   163 begin
   164 if ((Land[landY, landX] and lfIce) <> 0) then exit;
   164 if ((LandGet(landY, landX) and lfIce) <> 0) then exit;
   165 if (pixelX < LeftX) or (pixelX > RightX) or (pixelY < TopY) then exit;
   165 if (pixelX < LeftX) or (pixelX > RightX) or (pixelY < TopY) then exit;
   166 if isLandscapeEdge(getPixelWeight(landX, landY)) then
   166 if isLandscapeEdge(getPixelWeight(landX, landY)) then
   167     begin
   167     begin
   168     if (LandPixels[pixelY, pixelX] and AMask < 255) and (LandPixels[pixelY, pixelX] and AMask > 0) then
   168     if (LandPixels[pixelY, pixelX] and AMask < 255) and (LandPixels[pixelY, pixelX] and AMask > 0) then
   169         LandPixels[pixelY, pixelX] := (IceEdgeColor and (not AMask)) or (LandPixels[pixelY, pixelX] and AMask)
   169         LandPixels[pixelY, pixelX] := (IceEdgeColor and (not AMask)) or (LandPixels[pixelY, pixelX] and AMask)
   170     else if (LandPixels[pixelY, pixelX] and AMask < 255) or (Land[landY, landX] > 255) then
   170     else if (LandPixels[pixelY, pixelX] and AMask < 255) or (LandGet(landY, landX) > 255) then
   171         LandPixels[pixelY, pixelX] := IceEdgeColor
   171         LandPixels[pixelY, pixelX] := IceEdgeColor
   172     end
   172     end
   173 else if Land[landY, landX] > 255 then
   173 else if LandGet(landY, landX) > 255 then
   174     begin
   174     begin
   175         fillPixelFromIceSprite(pixelX, pixelY);
   175         fillPixelFromIceSprite(pixelX, pixelY);
   176     end;
   176     end;
   177 if Land[landY, landX] > 255 then Land[landY, landX] := Land[landY, landX] or lfIce and (not lfDamaged);
   177 if LandGet(landY, landX) > 255 then LandSet(landY, landX, LandGet(landY, landX) or lfIce and (not lfDamaged));
   178 end;
   178 end;
   179 
   179 
   180 
   180 
   181 function FillLandCircleLineFT(y, fromPix, toPix: LongInt; fill : fillType): Longword;
   181 function FillLandCircleLineFT(y, fromPix, toPix: LongInt; fill : fillType): Longword;
   182 var px, py, i: LongInt;
   182 var px, py, i: LongInt;
   200             end;
   200             end;
   201     nullPixel:
   201     nullPixel:
   202         for i:= fromPix to toPix do
   202         for i:= fromPix to toPix do
   203             begin
   203             begin
   204             calculatePixelsCoordinates(i, y, px, py);
   204             calculatePixelsCoordinates(i, y, px, py);
   205             if ((Land[y, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[y, i] > 255))  then
   205             if ((LandGet(y, i) and lfIndestructible) = 0) and (not disableLandBack or (LandGet(y, i) > 255))  then
   206                 LandPixels[py, px]:= ExplosionBorderColorNoA;
   206                 LandPixels[py, px]:= ExplosionBorderColorNoA;
   207             end;
   207             end;
   208     icePixel:
   208     icePixel:
   209         for i:= fromPix to toPix do
   209         for i:= fromPix to toPix do
   210             begin
   210             begin
   212             DrawPixelIce(i, y, px, py);
   212             DrawPixelIce(i, y, px, py);
   213             end;
   213             end;
   214     addNotHHObj:
   214     addNotHHObj:
   215         for i:= fromPix to toPix do
   215         for i:= fromPix to toPix do
   216             begin
   216             begin
   217             if Land[y, i] and lfNotHHObjMask shr lfNotHHObjShift < lfNotHHObjSize then
   217             if LandGet(y, i) and lfNotHHObjMask shr lfNotHHObjShift < lfNotHHObjSize then
   218                 Land[y, i]:= (Land[y, i] and (not lfNotHHObjMask)) or ((Land[y, i] and lfNotHHObjMask shr lfNotHHObjShift + 1) shl lfNotHHObjShift);
   218                 LandSet(y, i, (LandGet(y, i) and (not lfNotHHObjMask)) or ((LandGet(y, i) and lfNotHHObjMask shr lfNotHHObjShift + 1) shl lfNotHHObjShift));
   219             end;
   219             end;
   220     removeNotHHObj:
   220     removeNotHHObj:
   221         for i:= fromPix to toPix do
   221         for i:= fromPix to toPix do
   222             begin
   222             begin
   223             if Land[y, i] and lfNotHHObjMask <> 0 then
   223             if LandGet(y, i) and lfNotHHObjMask <> 0 then
   224                 Land[y, i]:= (Land[y, i] and (not lfNotHHObjMask)) or ((Land[y, i] and lfNotHHObjMask shr lfNotHHObjShift - 1) shl lfNotHHObjShift);
   224                 LandSet(y, i, (LandGet(y, i) and (not lfNotHHObjMask)) or ((LandGet(y, i) and lfNotHHObjMask shr lfNotHHObjShift - 1) shl lfNotHHObjShift));
   225             end;
   225             end;
   226     addHH:
   226     addHH:
   227         for i:= fromPix to toPix do
   227         for i:= fromPix to toPix do
   228             begin
   228             begin
   229             if Land[y, i] and lfHHMask < lfHHMask then
   229             if LandGet(y, i) and lfHHMask < lfHHMask then
   230                 Land[y, i]:= Land[y, i] + 1
   230                 LandSet(y, i, LandGet(y, i) + 1)
   231             end;
   231             end;
   232     removeHH:
   232     removeHH:
   233         for i:= fromPix to toPix do
   233         for i:= fromPix to toPix do
   234             begin
   234             begin
   235             if Land[y, i] and lfHHMask > 0 then
   235             if LandGet(y, i) and lfHHMask > 0 then
   236                 Land[y, i]:= Land[y, i] - 1;
   236                 LandSet(y, i, LandGet(y, i) - 1);
   237             end;
   237             end;
   238     setCurrentHog:
   238     setCurrentHog:
   239         for i:= fromPix to toPix do
   239         for i:= fromPix to toPix do
   240             begin
   240             begin
   241             Land[y, i]:= Land[y, i] or lfCurHogCrate
   241             LandSet(y, i, LandGet(y, i) or lfCurHogCrate)
   242             end;
   242             end;
   243     removeCurrentHog:
   243     removeCurrentHog:
   244         for i:= fromPix to toPix do
   244         for i:= fromPix to toPix do
   245             begin
   245             begin
   246             Land[y, i]:= Land[y, i] and lfNotCurHogCrate;
   246             LandSet(y, i, LandGet(y, i) and lfNotCurHogCrate);
   247             end;
   247             end;
   248     end;
   248     end;
   249 end;
   249 end;
   250 
   250 
   251 function FillLandCircleSegmentFT(x, y, dx, dy: LongInt; fill : fillType): Longword; inline;
   251 function FillLandCircleSegmentFT(x, y, dx, dy: LongInt; fill : fillType): Longword;
   252 begin
   252 begin
   253     FillLandCircleSegmentFT := 0;
   253     FillLandCircleSegmentFT := 0;
   254 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   254 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   255     inc(FillLandCircleSegmentFT, FillLandCircleLineFT(y + dy, Max(x - dx, 0), Min(x + dx, LAND_WIDTH - 1), fill));
   255     inc(FillLandCircleSegmentFT, FillLandCircleLineFT(y + dy, Max(x - dx, 0), Min(x + dx, LAND_WIDTH - 1), fill));
   256 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   256 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   259     inc(FillLandCircleSegmentFT, FillLandCircleLineFT(y + dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   259     inc(FillLandCircleSegmentFT, FillLandCircleLineFT(y + dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   260 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   260 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   261     inc(FillLandCircleSegmentFT, FillLandCircleLineFT(y - dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   261     inc(FillLandCircleSegmentFT, FillLandCircleLineFT(y - dx, Max(x - dy, 0), Min(x + dy, LAND_WIDTH - 1), fill));
   262 end;
   262 end;
   263 
   263 
   264 function FillRoundInLandFT(X, Y, Radius: LongInt; fill: fillType): Longword; inline;
   264 function FillRoundInLandFT(X, Y, Radius: LongInt; fill: fillType): Longword;
   265 var dx, dy, d: LongInt;
   265 var dx, dy, d: LongInt;
   266 begin
   266 begin
   267 dx:= 0;
   267 dx:= 0;
   268 dy:= Radius;
   268 dy:= Radius;
   269 d:= 3 - 2 * Radius;
   269 d:= 3 - 2 * Radius;
   321 begin
   321 begin
   322     FillCircleLines:= 0;
   322     FillCircleLines:= 0;
   323 
   323 
   324     if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   324     if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   325         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   325         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   326             if (Land[y + dy, i] and lfIndestructible) = 0 then
   326             if (LandGet(y + dy, i) and lfIndestructible) = 0 then
   327             begin
   327             begin
   328                 if Land[y + dy, i] <> Value then inc(FillCircleLines);
   328                 if LandGet(y + dy, i) <> Value then inc(FillCircleLines);
   329                 Land[y + dy, i]:= Value;
   329                 LandSet(y + dy, i, Value);
   330             end;
   330             end;
   331     if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   331     if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   332         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   332         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   333             if (Land[y - dy, i] and lfIndestructible) = 0 then
   333             if (LandGet(y - dy, i) and lfIndestructible) = 0 then
   334             begin
   334             begin
   335                 if Land[y - dy, i] <> Value then inc(FillCircleLines);
   335                 if LandGet(y - dy, i) <> Value then inc(FillCircleLines);
   336                 Land[y - dy, i]:= Value;
   336                 LandSet(y - dy, i, Value);
   337             end;
   337             end;
   338     if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   338     if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   339         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   339         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   340             if (Land[y + dx, i] and lfIndestructible) = 0 then
   340             if (LandGet(y + dx, i) and lfIndestructible) = 0 then
   341             begin
   341             begin
   342                 if Land[y + dx, i] <> Value then inc(FillCircleLines);
   342                 if LandGet(y + dx, i) <> Value then inc(FillCircleLines);
   343                 Land[y + dx, i]:= Value;
   343                 LandSet(y + dx, i, Value);
   344             end;
   344             end;
   345     if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   345     if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   346         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   346         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   347             if (Land[y - dx, i] and lfIndestructible) = 0 then
   347             if (LandGet(y - dx, i) and lfIndestructible) = 0 then
   348             begin
   348             begin
   349                 if Land[y - dx, i] <> Value then inc(FillCircleLines);
   349                 if LandGet(y - dx, i) <> Value then inc(FillCircleLines);
   350                 Land[y - dx, i]:= Value;
   350                 LandSet(y - dx, i, Value);
   351             end;
   351             end;
   352 end;
   352 end;
   353 
   353 
   354 function FillRoundInLand(X, Y, Radius: LongInt; Value: Longword): Longword;
   354 function FillRoundInLand(X, Y, Radius: LongInt; Value: Longword): Longword;
   355 var dx, dy, d: LongInt;
   355 var dx, dy, d: LongInt;
   433 
   433 
   434 for i := iceL to iceR do
   434 for i := iceL to iceR do
   435     begin
   435     begin
   436     for j := iceT to iceB do
   436     for j := iceT to iceB do
   437         begin
   437         begin
   438         if Land[j, i] = 0 then
   438         if LandGet(j, i) = 0 then
   439             begin
   439             begin
   440             Land[j, i] := lfIce;
   440             LandSet(j, i, lfIce);
   441             if (cReducedQuality and rqBlurryLand) = 0 then
   441             if (cReducedQuality and rqBlurryLand) = 0 then
   442                 fillPixelFromIceSprite(i, j)
   442                 fillPixelFromIceSprite(i, j)
   443             else
   443             else
   444                 fillPixelFromIceSprite(i div 2, j div 2);
   444                 fillPixelFromIceSprite(i div 2, j div 2);
   445             end;
   445             end;
   476 for i:= 0 to Pred(Count) do
   476 for i:= 0 to Pred(Count) do
   477     begin
   477     begin
   478     for ty:= Max(y - Radius, 0) to Min(y + Radius, TopY) do
   478     for ty:= Max(y - Radius, 0) to Min(y + Radius, TopY) do
   479         for tx:= Max(LeftX, ar^[i].Left - Radius) to Min(RightX, ar^[i].Right + Radius) do
   479         for tx:= Max(LeftX, ar^[i].Left - Radius) to Min(RightX, ar^[i].Right + Radius) do
   480             begin
   480             begin
   481             if (Land[ty, tx] and lfIndestructible) = 0 then
   481             if (LandGet(ty, tx) and lfIndestructible) = 0 then
   482                 begin
   482                 begin
   483                 if (cReducedQuality and rqBlurryLand) = 0 then
   483                 if (cReducedQuality and rqBlurryLand) = 0 then
   484                     begin
   484                     begin
   485                     by:= ty; bx:= tx;
   485                     by:= ty; bx:= tx;
   486                     end
   486                     end
   487                 else
   487                 else
   488                     begin
   488                     begin
   489                     by:= ty div 2; bx:= tx div 2;
   489                     by:= ty div 2; bx:= tx div 2;
   490                     end;
   490                     end;
   491                 if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   491                 if ((LandGet(ty, tx) and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   492                     LandPixels[by, bx]:= LandBackPixel(tx, ty)
   492                     LandPixels[by, bx]:= LandBackPixel(tx, ty)
   493                 else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   493                 else if ((LandGet(ty, tx) and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   494                     LandPixels[by, bx]:= LandPixels[by, bx] and (not AMASK)
   494                     LandPixels[by, bx]:= LandPixels[by, bx] and (not AMASK)
   495                 end
   495                 end
   496             end;
   496             end;
   497     inc(y, dY)
   497     inc(y, dY)
   498     end;
   498     end;
   502 
   502 
   503 for i:= 0 to Pred(Count) do
   503 for i:= 0 to Pred(Count) do
   504     begin
   504     begin
   505     for ty:= Max(y - Radius, 0) to Min(y + Radius, TopY) do
   505     for ty:= Max(y - Radius, 0) to Min(y + Radius, TopY) do
   506         for tx:= Max(LeftX, ar^[i].Left - Radius) to Min(RightX, ar^[i].Right + Radius) do
   506         for tx:= Max(LeftX, ar^[i].Left - Radius) to Min(RightX, ar^[i].Right + Radius) do
   507             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   507             if ((LandGet(ty, tx) and lfBasic) <> 0) or ((LandGet(ty, tx) and lfObject) <> 0) then
   508                 begin
   508                 begin
   509                  if (cReducedQuality and rqBlurryLand) = 0 then
   509                  if (cReducedQuality and rqBlurryLand) = 0 then
   510                     LandPixels[ty, tx]:= ExplosionBorderColor
   510                     LandPixels[ty, tx]:= ExplosionBorderColor
   511                 else
   511                 else
   512                     LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor;
   512                     LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor;
   513 
   513 
   514                 Land[ty, tx]:= (Land[ty, tx] or lfDamaged) and (not lfIce);
   514                 LandSet(ty, tx, (LandGet(ty, tx) or lfDamaged) and (not lfIce));
   515                 LandDirty[ty div 32, tx div 32]:= 1;
   515                 LandDirty[ty div 32, tx div 32]:= 1;
   516                 end;
   516                 end;
   517     inc(y, dY)
   517     inc(y, dY)
   518     end;
   518     end;
   519 
   519 
   531     begin
   531     begin
   532     X:= X + dX;
   532     X:= X + dX;
   533     Y:= Y + dY;
   533     Y:= Y + dY;
   534     tx:= hwRound(X);
   534     tx:= hwRound(X);
   535     ty:= hwRound(Y);
   535     ty:= hwRound(Y);
   536     if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0)
   536     if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((LandGet(ty, tx) and lfBasic) <> 0)
   537     or ((Land[ty, tx] and lfObject) <> 0)) then
   537     or ((LandGet(ty, tx) and lfObject) <> 0)) then
   538         begin
   538         begin
   539         Land[ty, tx]:= (Land[ty, tx] or lfDamaged) and (not lfIce);
   539         LandSet(ty, tx, (LandGet(ty, tx) or lfDamaged) and (not lfIce));
   540         if despeckle then
   540         if despeckle then
   541             LandDirty[ty div 32, tx div 32]:= 1;
   541             LandDirty[ty div 32, tx div 32]:= 1;
   542         if (cReducedQuality and rqBlurryLand) = 0 then
   542         if (cReducedQuality and rqBlurryLand) = 0 then
   543             LandPixels[ty, tx]:= ExplosionBorderColor
   543             LandPixels[ty, tx]:= ExplosionBorderColor
   544         else
   544         else
   579     Y:= Y + dY;
   579     Y:= Y + dY;
   580     tx:= hwRound(X);
   580     tx:= hwRound(X);
   581     ty:= hwRound(Y);
   581     ty:= hwRound(Y);
   582     if ((ty and LAND_HEIGHT_MASK) = 0)
   582     if ((ty and LAND_HEIGHT_MASK) = 0)
   583     and ((tx and LAND_WIDTH_MASK) = 0)
   583     and ((tx and LAND_WIDTH_MASK) = 0)
   584     and (((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0)) then
   584     and (((LandGet(ty, tx) and lfBasic) <> 0) or ((LandGet(ty, tx) and lfObject) <> 0)) then
   585         begin
   585         begin
   586         Land[ty, tx]:= Land[ty, tx] and (not lfIce);
   586         LandSet(ty, tx, LandGet(ty, tx) and (not lfIce));
   587         if despeckle then
   587         if despeckle then
   588             begin
   588             begin
   589             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   589             LandSet(ty, tx, LandGet(ty, tx) or lfDamaged);
   590             LandDirty[ty div 32, tx div 32]:= 1
   590             LandDirty[ty div 32, tx div 32]:= 1
   591             end;
   591             end;
   592         if (cReducedQuality and rqBlurryLand) = 0 then
   592         if (cReducedQuality and rqBlurryLand) = 0 then
   593             LandPixels[ty, tx]:= ExplosionBorderColor
   593             LandPixels[ty, tx]:= ExplosionBorderColor
   594         else
   594         else
   610         begin
   610         begin
   611         X:= X + dX;
   611         X:= X + dX;
   612         Y:= Y + dY;
   612         Y:= Y + dY;
   613         tx:= hwRound(X);
   613         tx:= hwRound(X);
   614         ty:= hwRound(Y);
   614         ty:= hwRound(Y);
   615         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((Land[ty, tx] and lfIndestructible) = 0) then
   615         if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and ((LandGet(ty, tx) and lfIndestructible) = 0) then
   616             begin
   616             begin
   617             if (cReducedQuality and rqBlurryLand) = 0 then
   617             if (cReducedQuality and rqBlurryLand) = 0 then
   618                 begin
   618                 begin
   619                 by:= ty; bx:= tx;
   619                 by:= ty; bx:= tx;
   620                 end
   620                 end
   621             else
   621             else
   622                 begin
   622                 begin
   623                 by:= ty div 2; bx:= tx div 2;
   623                 by:= ty div 2; bx:= tx div 2;
   624                 end;
   624                 end;
   625             if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   625             if ((LandGet(ty, tx) and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   626                 LandPixels[by, bx]:= LandBackPixel(tx, ty)
   626                 LandPixels[by, bx]:= LandBackPixel(tx, ty)
   627             else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   627             else if ((LandGet(ty, tx) and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   628                 LandPixels[by, bx]:= LandPixels[by, bx] and (not AMASK);
   628                 LandPixels[by, bx]:= LandPixels[by, bx] and (not AMASK);
   629             Land[ty, tx]:= 0;
   629             LandSet(ty, tx, 0);
   630             end
   630             end
   631         end;
   631         end;
   632     DrawExplosionBorder(X, Y, dx, dy, despeckle);
   632     DrawExplosionBorder(X, Y, dx, dy, despeckle);
   633     nx:= nx - dY;
   633     nx:= nx - dY;
   634     ny:= ny + dX;
   634     ny:= ny + dX;
   642     begin
   642     begin
   643     X:= X + dX;
   643     X:= X + dX;
   644     Y:= Y + dY;
   644     Y:= Y + dY;
   645     tx:= hwRound(X);
   645     tx:= hwRound(X);
   646     ty:= hwRound(Y);
   646     ty:= hwRound(Y);
   647     if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0)
   647     if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((LandGet(ty, tx) and lfBasic) <> 0)
   648     or ((Land[ty, tx] and lfObject) <> 0)) then
   648     or ((LandGet(ty, tx) and lfObject) <> 0)) then
   649         begin
   649         begin
   650         Land[ty, tx]:= (Land[ty, tx] or lfDamaged) and (not lfIce);
   650         LandSet(ty, tx, (LandGet(ty, tx) or lfDamaged) and (not lfIce));
   651         if despeckle then
   651         if despeckle then
   652             LandDirty[ty div 32, tx div 32]:= 1;
   652             LandDirty[ty div 32, tx div 32]:= 1;
   653         if (cReducedQuality and rqBlurryLand) = 0 then
   653         if (cReducedQuality and rqBlurryLand) = 0 then
   654             LandPixels[ty, tx]:= ExplosionBorderColor
   654             LandPixels[ty, tx]:= ExplosionBorderColor
   655         else
   655         else
   690     else
   690     else
   691         DrawTunnel_real(X - int2hwFloat(playWidth), Y, dX, dY, ticks, HalfWidth);
   691         DrawTunnel_real(X - int2hwFloat(playWidth), Y, dX, dY, ticks, HalfWidth);
   692     end;
   692     end;
   693 end;
   693 end;
   694 
   694 
   695 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline;
   695 function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean;
   696 var lf: Word;
   696 var lf: Word;
   697 begin
   697 begin
   698 if indestructible then
   698 if indestructible then
   699     lf:= lfIndestructible
   699     lf:= lfIndestructible
   700 else
   700 else
   701     lf:= 0;
   701     lf:= 0;
   702 TryPlaceOnLandSimple:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, false, false, false, lf, $FFFFFFFF);
   702 TryPlaceOnLandSimple:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, false, false, false, lf, $FFFFFFFF);
   703 end;
   703 end;
   704 
   704 
   705 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline;
   705 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean;
   706 begin
   706 begin
   707 TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, false, false, false, LandFlags, $FFFFFFFF);
   707 TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, false, false, false, LandFlags, $FFFFFFFF);
   708 end;
   708 end;
   709 
   709 
   710 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline;
   710 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean;
   711 begin
   711 begin
   712     ForcePlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, true, false, true, behind, flipHoriz, flipVert, LandFlags, Tint)
   712     ForcePlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, true, false, true, behind, flipHoriz, flipVert, LandFlags, Tint)
   713 end;
   713 end;
   714 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean;
   714 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean;
   715 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   715 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   750         for x:= 0 to Pred(w) do
   750         for x:= 0 to Pred(w) do
   751             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
   751             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
   752                 if (outOfMap and
   752                 if (outOfMap and
   753                    ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and
   753                    ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and
   754                    ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and
   754                    ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and
   755                    ((not force) and (Land[cpY + y, cpX + x] <> 0))) or
   755                    ((not force) and (LandGet(cpY + y, cpX + x) <> 0))) or
   756 
   756 
   757                    (not outOfMap and
   757                    (not outOfMap and
   758                        (((cpY + y) <= topY) or ((cpY + y) >= LAND_HEIGHT) or
   758                        (((cpY + y) <= topY) or ((cpY + y) >= LAND_HEIGHT) or
   759                        ((cpX + x) <= leftX) or ((cpX + x) >= rightX) or
   759                        ((cpX + x) <= leftX) or ((cpX + x) >= rightX) or
   760                        ((not force) and (Land[cpY + y, cpX + x] <> 0)))) then
   760                        ((not force) and (LandGet(cpY + y, cpX + x) <> 0)))) then
   761                    begin
   761                    begin
   762                    if SDL_MustLock(Image) then
   762                    if SDL_MustLock(Image) then
   763                        SDL_UnlockSurface(Image);
   763                        SDL_UnlockSurface(Image);
   764                    exit
   764                    exit
   765                    end;
   765                    end;
   791                 else
   791                 else
   792                     begin
   792                     begin
   793                     gX:= (cpX + x) div 2;
   793                     gX:= (cpX + x) div 2;
   794                     gY:= (cpY + y) div 2;
   794                     gY:= (cpY + y) div 2;
   795                     end;
   795                     end;
   796                 if (not behind) or (Land[cpY + y, cpX + x] and lfLandMask = 0) then
   796                 if (not behind) or (LandGet(cpY + y, cpX + x) and lfLandMask = 0) then
   797                     begin
   797                     begin
   798                     if (LandFlags and lfBasic <> 0) or 
   798                     if (LandFlags and lfBasic <> 0) or
   799                        ((LandPixels[gY, gX] and AMask shr AShift > 128) and  // This test assumes lfBasic and lfObject differ only graphically
   799                        ((LandPixels[gY, gX] and AMask shr AShift > 128) and  // This test assumes lfBasic and lfObject differ only graphically
   800                          (LandFlags and (lfObject or lfIce) = 0)) then
   800                          (LandFlags and (lfObject or lfIce) = 0)) then
   801                          Land[cpY + y, cpX + x]:= lfBasic or LandFlags
   801                          LandSet(cpY + y, cpX + x, lfBasic or LandFlags)
   802                     else if (LandFlags and lfIce = 0) then
   802                     else if (LandFlags and lfIce = 0) then
   803 						 Land[cpY + y, cpX + x]:= lfObject or LandFlags
   803 						 LandSet(cpY + y, cpX + x, lfObject or LandFlags)
   804 					else Land[cpY + y, cpX + x]:= LandFlags
   804 					else LandSet(cpY + y, cpX + x, LandFlags)
   805                     end;
   805                     end;
   806                 if (not behind) or (LandPixels[gY, gX] = 0) then
   806                 if (not behind) or (LandPixels[gY, gX] = 0) then
   807                     begin
   807                     begin
   808                     if tint = $FFFFFFFF then
   808                     if tint = $FFFFFFFF then
   809                         LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^
   809                         LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^
   810                     else 
   810                     else
   811                         begin
   811                         begin
   812                         pixel:= PLongword(@(p^[x * 4]))^;
   812                         pixel:= PLongword(@(p^[x * 4]))^;
   813                         LandPixels[gY, gX]:= 
   813                         LandPixels[gY, gX]:=
   814                            ceil((pixel shr RShift and $FF) * ((tint shr 24) / 255)) shl RShift or
   814                            ceil((pixel shr RShift and $FF) * ((tint shr 24) / 255)) shl RShift or
   815                            ceil((pixel shr GShift and $FF) * ((tint shr 16 and $ff) / 255)) shl GShift or
   815                            ceil((pixel shr GShift and $FF) * ((tint shr 16 and $ff) / 255)) shl GShift or
   816                            ceil((pixel shr BShift and $FF) * ((tint shr  8 and $ff) / 255)) shl BShift or
   816                            ceil((pixel shr BShift and $FF) * ((tint shr  8 and $ff) / 255)) shl BShift or
   817                            ceil((pixel shr AShift and $FF) * ((tint and $ff) / 255)) shl AShift;
   817                            ceil((pixel shr AShift and $FF) * ((tint and $ff) / 255)) shl AShift;
   818                         end
   818                         end
   846 begin
   846 begin
   847 for ty:= 0 to height - 1 do
   847 for ty:= 0 to height - 1 do
   848     for tx:= 0 to width - 1 do
   848     for tx:= 0 to width - 1 do
   849         begin
   849         begin
   850         LandPixels[ty, tx]:= 0;
   850         LandPixels[ty, tx]:= 0;
   851         Land[Y + ty, X + tx]:= 0;
   851         LandSet(Y + ty, X + tx, 0);
   852         end;
   852         end;
   853 end;
   853 end;
   854 
   854 
   855 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean);
   855 procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean);
   856 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   856 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
   911                 else
   911                 else
   912                     begin
   912                     begin
   913                     gX:= (cpX + x) div 2;
   913                     gX:= (cpX + x) div 2;
   914                     gY:= (cpY + y) div 2;
   914                     gY:= (cpY + y) div 2;
   915                     end;
   915                     end;
   916                 if (not eraseOnLFMatch or (Land[cpY + y, cpX + x] and LandFlags <> 0)) and
   916                 if (not eraseOnLFMatch or (LandGet(cpY + y, cpX + x) and LandFlags <> 0)) and
   917                     ((PLongword(@(p^[x * 4]))^) and AMask <> 0) then
   917                     ((PLongword(@(p^[x * 4]))^) and AMask <> 0) then
   918                     begin
   918                     begin
   919                     if not onlyEraseLF then
   919                     if not onlyEraseLF then
   920                         begin
   920                         begin
   921                         LandPixels[gY, gX]:= 0;
   921                         LandPixels[gY, gX]:= 0;
   922                         Land[cpY + y, cpX + x]:= 0
   922                         LandSet(cpY + y, cpX + x, 0)
   923                         end
   923                         end
   924                     else Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] and (not LandFlags)
   924                     else LandSet(cpY + y, cpX + x, LandGet(cpY + y, cpX + x) and (not LandFlags))
   925                     end
   925                     end
   926                 end;
   926                 end;
   927         p:= PByteArray(@(p^[Image^.pitch]));
   927         p:= PByteArray(@(p^[Image^.pitch]));
   928         end;
   928         end;
   929 if SDL_MustLock(Image) then
   929 if SDL_MustLock(Image) then
   988 for y:= 0 to Pred(h) do
   988 for y:= 0 to Pred(h) do
   989     begin
   989     begin
   990     for x:= 0 to Pred(w) do
   990     for x:= 0 to Pred(w) do
   991         if ((p^[x] and AMask) <> 0)
   991         if ((p^[x] and AMask) <> 0)
   992             and (((cpY + y) < topY) or ((cpY + y) >= LAND_HEIGHT) or
   992             and (((cpY + y) < topY) or ((cpY + y) >= LAND_HEIGHT) or
   993             ((cpX + x) < leftX) or ((cpX + x) > rightX) or (Land[cpY + y, cpX + x] <> 0)) then
   993             ((cpX + x) < leftX) or ((cpX + x) > rightX) or (LandGet(cpY + y, cpX + x) <> 0)) then
   994                 pt^[x]:= cWhiteColor
   994                 pt^[x]:= cWhiteColor
   995         else
   995         else
   996             (pt^[x]):= cWhiteColor and (not AMask);
   996             (pt^[x]):= cWhiteColor and (not AMask);
   997     p:= PLongWordArray(@(p^[Image^.pitch div 4]));
   997     p:= PLongWordArray(@(p^[Image^.pitch div 4]));
   998     pt:= PLongWordArray(@(pt^[finalSurface^.pitch div 4]));
   998     pt:= PLongWordArray(@(pt^[finalSurface^.pitch div 4]));
  1026     begin
  1026     begin
  1027         xx:= X div 2;
  1027         xx:= X div 2;
  1028         yy:= Y div 2;
  1028         yy:= Y div 2;
  1029     end;
  1029     end;
  1030 
  1030 
  1031     pixelsweep:= (Land[Y, X] <= lfAllObjMask) and ((LandPixels[yy, xx] and AMask) <> 0);
  1031     pixelsweep:= (LandGet(Y, X) <= lfAllObjMask) and ((LandPixels[yy, xx] and AMask) <> 0);
  1032     if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then
  1032     if (((LandGet(Y, X) and lfDamaged) <> 0) and ((LandGet(Y, X) and lfIndestructible) = 0)) or pixelsweep then
  1033     begin
  1033     begin
  1034         c:= 0;
  1034         c:= 0;
  1035         for i:= -1 to 1 do
  1035         for i:= -1 to 1 do
  1036             for j:= -1 to 1 do
  1036             for j:= -1 to 1 do
  1037                 if (i <> 0) or (j <> 0) then
  1037                 if (i <> 0) or (j <> 0) then
  1051                                         inc(c);
  1051                                         inc(c);
  1052                             end
  1052                             end
  1053                             else if (LandPixels[ny, nx] and AMASK)  <> 0 then
  1053                             else if (LandPixels[ny, nx] and AMASK)  <> 0 then
  1054                                     inc(c);
  1054                                     inc(c);
  1055                         end
  1055                         end
  1056                     else if Land[ny, nx] > 255 then
  1056                     else if LandGet(ny, nx) > 255 then
  1057                         inc(c);
  1057                         inc(c);
  1058                     end
  1058                     end
  1059                 end;
  1059                 end;
  1060 
  1060 
  1061         if c < 4 then // 0-3 neighbours
  1061         if c < 4 then // 0-3 neighbours
  1062         begin
  1062         begin
  1063             if ((Land[Y, X] and lfBasic) <> 0) and (not disableLandBack) then
  1063             if ((LandGet(Y, X) and lfBasic) <> 0) and (not disableLandBack) then
  1064                 LandPixels[yy, xx]:= LandBackPixel(X, Y)
  1064                 LandPixels[yy, xx]:= LandBackPixel(X, Y)
  1065             else
  1065             else
  1066                 LandPixels[yy, xx]:= LandPixels[yy, xx] and (not AMASK);
  1066                 LandPixels[yy, xx]:= LandPixels[yy, xx] and (not AMASK);
  1067 
  1067 
  1068             if not pixelsweep then
  1068             if not pixelsweep then
  1069             begin
  1069             begin
  1070                 Land[Y, X]:= 0;
  1070                 LandSet(Y, X, 0);
  1071                 exit
  1071                 exit
  1072             end
  1072             end
  1073         end;
  1073         end;
  1074     end;
  1074     end;
  1075     Despeckle:= false
  1075     Despeckle:= false
  1081     nx, ny: LongInt;
  1081     nx, ny: LongInt;
  1082     pixel: LongWord;
  1082     pixel: LongWord;
  1083 begin
  1083 begin
  1084 
  1084 
  1085 // only AA inwards
  1085 // only AA inwards
  1086 if (Land[Y, X] and lfDamaged) = 0 then
  1086 if (LandGet(Y, X) and lfDamaged) = 0 then
  1087     exit;
  1087     exit;
  1088 
  1088 
  1089 // check location
  1089 // check location
  1090 if (Y <= topY + 1) or (Y >= LAND_HEIGHT-2)
  1090 if (Y <= topY + 1) or (Y >= LAND_HEIGHT-2)
  1091 or (X <= leftX + 1) or (X >= rightX - 1) then
  1091 or (X <= leftX + 1) or (X >= rightX - 1) then
  1102 
  1102 
  1103 // iterate over all neighbor pixels (also itself, will be skipped anyway)
  1103 // iterate over all neighbor pixels (also itself, will be skipped anyway)
  1104 for nx:= X-1 to X+1 do
  1104 for nx:= X-1 to X+1 do
  1105     for ny:= Y-1 to Y+1 do
  1105     for ny:= Y-1 to Y+1 do
  1106         // only consider undamaged neighbors (also leads to skipping itself)
  1106         // only consider undamaged neighbors (also leads to skipping itself)
  1107         if (Land[ny, nx] and lfDamaged) = 0 then
  1107         if (LandGet(ny, nx) and lfDamaged) = 0 then
  1108             begin
  1108             begin
  1109             pixel:= LandPixels[ny, nx];
  1109             pixel:= LandPixels[ny, nx];
  1110             inc(r, (pixel and RMask) shr RShift);
  1110             inc(r, (pixel and RMask) shr RShift);
  1111             inc(g, (pixel and GMask) shr GShift);
  1111             inc(g, (pixel and GMask) shr GShift);
  1112             inc(b, (pixel and BMask) shr BShift);
  1112             inc(b, (pixel and BMask) shr BShift);
  1137 end;
  1137 end;
  1138 
  1138 
  1139 procedure Smooth_oldImpl(X, Y: LongInt);
  1139 procedure Smooth_oldImpl(X, Y: LongInt);
  1140 begin
  1140 begin
  1141 // a bit of AA for explosions
  1141 // a bit of AA for explosions
  1142 if (Land[Y, X] = 0) and (Y > topY + 1) and
  1142 if (LandGet(Y, X) = 0) and (Y > topY + 1) and
  1143     (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
  1143     (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
  1144     begin
  1144     begin
  1145     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
  1145     if ((((LandGet(y, x-1) and lfDamaged) <> 0) and (((LandGet(y+1,x) and lfDamaged) <> 0)) or ((LandGet(y-1,x) and lfDamaged) <> 0))
  1146     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
  1146     or (((LandGet(y, x+1) and lfDamaged) <> 0) and (((LandGet(y-1,x) and lfDamaged) <> 0) or ((LandGet(y+1,x) and lfDamaged) <> 0)))) then
  1147         begin
  1147         begin
  1148         if (cReducedQuality and rqBlurryLand) = 0 then
  1148         if (cReducedQuality and rqBlurryLand) = 0 then
  1149             begin
  1149             begin
  1150             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
  1150             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
  1151                 LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (128 shl AShift)
  1151                 LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (128 shl AShift)
  1154                                 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
  1154                                 (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
  1155                                 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
  1155                                 (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
  1156                                 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
  1156                                 (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
  1157             end;
  1157             end;
  1158 {
  1158 {
  1159         if (Land[y, x-1] = lfObject) then
  1159         if (LandGet(y, x-1) = lfObject) then
  1160             Land[y,x]:= lfObject
  1160             LandGet(y,x):= lfObject
  1161         else if (Land[y, x+1] = lfObject) then
  1161         else if (LandGet(y, x+1) = lfObject) then
  1162             Land[y,x]:= lfObject
  1162             LandGet(y,x):= lfObject
  1163         else
  1163         else
  1164             Land[y,x]:= lfBasic;
  1164             LandGet(y,x):= lfBasic;
  1165 }
  1165 }
  1166         end
  1166         end
  1167     else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
  1167     else if ((((LandGet(y, x-1) and lfDamaged) <> 0) and ((LandGet(y+1,x-1) and lfDamaged) <> 0) and ((LandGet(y+2,x) and lfDamaged) <> 0))
  1168     or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
  1168     or (((LandGet(y, x-1) and lfDamaged) <> 0) and ((LandGet(y-1,x-1) and lfDamaged) <> 0) and ((LandGet(y-2,x) and lfDamaged) <> 0))
  1169     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
  1169     or (((LandGet(y, x+1) and lfDamaged) <> 0) and ((LandGet(y+1,x+1) and lfDamaged) <> 0) and ((LandGet(y+2,x) and lfDamaged) <> 0))
  1170     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
  1170     or (((LandGet(y, x+1) and lfDamaged) <> 0) and ((LandGet(y-1,x+1) and lfDamaged) <> 0) and ((LandGet(y-2,x) and lfDamaged) <> 0))
  1171     or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0))
  1171     or (((LandGet(y+1, x) and lfDamaged) <> 0) and ((LandGet(y+1,x+1) and lfDamaged) <> 0) and ((LandGet(y,x+2) and lfDamaged) <> 0))
  1172     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0))
  1172     or (((LandGet(y-1, x) and lfDamaged) <> 0) and ((LandGet(y-1,x+1) and lfDamaged) <> 0) and ((LandGet(y,x+2) and lfDamaged) <> 0))
  1173     or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))
  1173     or (((LandGet(y+1, x) and lfDamaged) <> 0) and ((LandGet(y+1,x-1) and lfDamaged) <> 0) and ((LandGet(y,x-2) and lfDamaged) <> 0))
  1174     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
  1174     or (((LandGet(y-1, x) and lfDamaged) <> 0) and ((LandGet(y-1,x-1) and lfDamaged) <> 0) and ((LandGet(y,x-2) and lfDamaged) <> 0))) then
  1175         begin
  1175         begin
  1176         if (cReducedQuality and rqBlurryLand) = 0 then
  1176         if (cReducedQuality and rqBlurryLand) = 0 then
  1177             begin
  1177             begin
  1178             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
  1178             if ((LandPixels[y,x] and AMask) shr AShift) < 10 then
  1179                 LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (64 shl AShift)
  1179                 LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (64 shl AShift)
  1182                                 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
  1182                                 (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
  1183                                 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
  1183                                 (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
  1184                                 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
  1184                                 (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
  1185             end;
  1185             end;
  1186 {
  1186 {
  1187         if (Land[y, x-1] = lfObject) then
  1187         if (LandGet(y, x-1) = lfObject) then
  1188             Land[y, x]:= lfObject
  1188             LandGet(y, x):= lfObject
  1189         else if (Land[y, x+1] = lfObject) then
  1189         else if (LandGet(y, x+1) = lfObject) then
  1190             Land[y, x]:= lfObject
  1190             LandGet(y, x):= lfObject
  1191         else if (Land[y+1, x] = lfObject) then
  1191         else if (LandGet(y+1, x) = lfObject) then
  1192             Land[y, x]:= lfObject
  1192             LandGet(y, x):= lfObject
  1193         else if (Land[y-1, x] = lfObject) then
  1193         else if (LandGet(y-1, x) = lfObject) then
  1194         Land[y, x]:= lfObject
  1194         LandGet(y, x):= lfObject
  1195         else Land[y,x]:= lfBasic
  1195         else LandGet(y,x):= lfBasic
  1196 }
  1196 }
  1197         end
  1197         end
  1198     end
  1198     end
  1199 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask)
  1199 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask)
  1200 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)
  1200 and (LandGet(Y, X) and (lfDamaged or lfBasic) = lfBasic)
  1201 and (Y > topY + 1) and (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
  1201 and (Y > topY + 1) and (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
  1202     begin
  1202     begin
  1203     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
  1203     if ((((LandGet(y, x-1) and lfDamaged) <> 0) and (((LandGet(y+1,x) and lfDamaged) <> 0)) or ((LandGet(y-1,x) and lfDamaged) <> 0))
  1204     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
  1204     or (((LandGet(y, x+1) and lfDamaged) <> 0) and (((LandGet(y-1,x) and lfDamaged) <> 0) or ((LandGet(y+1,x) and lfDamaged) <> 0)))) then
  1205         begin
  1205         begin
  1206         LandPixels[y,x]:=
  1206         LandPixels[y,x]:=
  1207                         (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
  1207                         (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or
  1208                         (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
  1208                         (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or
  1209                         (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
  1209                         (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift)
  1210         end
  1210         end
  1211     else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
  1211     else if ((((LandGet(y, x-1) and lfDamaged) <> 0) and ((LandGet(y+1,x-1) and lfDamaged) <> 0) and ((LandGet(y+2,x) and lfDamaged) <> 0))
  1212     or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
  1212     or (((LandGet(y, x-1) and lfDamaged) <> 0) and ((LandGet(y-1,x-1) and lfDamaged) <> 0) and ((LandGet(y-2,x) and lfDamaged) <> 0))
  1213     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0))
  1213     or (((LandGet(y, x+1) and lfDamaged) <> 0) and ((LandGet(y+1,x+1) and lfDamaged) <> 0) and ((LandGet(y+2,x) and lfDamaged) <> 0))
  1214     or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0))
  1214     or (((LandGet(y, x+1) and lfDamaged) <> 0) and ((LandGet(y-1,x+1) and lfDamaged) <> 0) and ((LandGet(y-2,x) and lfDamaged) <> 0))
  1215     or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0))
  1215     or (((LandGet(y+1, x) and lfDamaged) <> 0) and ((LandGet(y+1,x+1) and lfDamaged) <> 0) and ((LandGet(y,x+2) and lfDamaged) <> 0))
  1216     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0))
  1216     or (((LandGet(y-1, x) and lfDamaged) <> 0) and ((LandGet(y-1,x+1) and lfDamaged) <> 0) and ((LandGet(y,x+2) and lfDamaged) <> 0))
  1217     or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))
  1217     or (((LandGet(y+1, x) and lfDamaged) <> 0) and ((LandGet(y+1,x-1) and lfDamaged) <> 0) and ((LandGet(y,x-2) and lfDamaged) <> 0))
  1218     or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then
  1218     or (((LandGet(y-1, x) and lfDamaged) <> 0) and ((LandGet(y-1,x-1) and lfDamaged) <> 0) and ((LandGet(y,x-2) and lfDamaged) <> 0))) then
  1219         begin
  1219         begin
  1220         LandPixels[y,x]:=
  1220         LandPixels[y,x]:=
  1221                         (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
  1221                         (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or
  1222                         (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
  1222                         (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or
  1223                         (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
  1223                         (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift)
  1306 SweepDirty:= bRes;
  1306 SweepDirty:= bRes;
  1307 end;
  1307 end;
  1308 
  1308 
  1309 
  1309 
  1310 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
  1310 // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc
  1311 function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; inline;
  1311 function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean;
  1312 begin
  1312 begin
  1313     CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0)
  1313     CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((LandGet(Y, X) and LandFlag) = 0)
  1314 end;
  1314 end;
  1315 
  1315 
  1316 function LandBackPixel(x, y: LongInt): LongWord; inline;
  1316 function LandBackPixel(x, y: LongInt): LongWord;
  1317 var p: PLongWordArray;
  1317 var p: PLongWordArray;
  1318 begin
  1318 begin
  1319     if LandBackSurface = nil then
  1319     if LandBackSurface = nil then
  1320         LandBackPixel:= 0
  1320         LandBackPixel:= 0
  1321     else
  1321     else
  1380         dec(eY, d);
  1380         dec(eY, d);
  1381         inc(y, sY);
  1381         inc(y, sY);
  1382         end;
  1382         end;
  1383 
  1383 
  1384     if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then
  1384     if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then
  1385         Land[y, x]:= Color;
  1385         LandSet(y, x, Color);
  1386     end
  1386     end
  1387 end;
  1387 end;
  1388 
  1388 
  1389 function DrawDots(x, y, xx, yy: Longint; Color: Longword): Longword; inline;
  1389 function DrawDots(x, y, xx, yy: Longint; Color: Longword): Longword;
  1390 begin
  1390 begin
  1391     DrawDots:= 0;
  1391     DrawDots:= 0;
  1392 
  1392 
  1393     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (Land[y + yy, x + xx] <> Color) then
  1393     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (LandGet(y + yy, x + xx) <> Color) then
  1394         begin inc(DrawDots); Land[y + yy, x + xx]:= Color; end;
  1394         begin inc(DrawDots); LandSet(y + yy, x + xx, Color); end;
  1395     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (Land[y - yy, x + xx] <> Color) then
  1395     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (LandGet(y - yy, x + xx) <> Color) then
  1396         begin inc(DrawDots); Land[y - yy, x + xx]:= Color; end;
  1396         begin inc(DrawDots); LandSet(y - yy, x + xx, Color); end;
  1397     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (Land[y + yy, x - xx] <> Color) then
  1397     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (LandGet(y + yy, x - xx) <> Color) then
  1398         begin inc(DrawDots); Land[y + yy, x - xx]:= Color; end;
  1398         begin inc(DrawDots); LandSet(y + yy, x - xx, Color); end;
  1399     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (Land[y - yy, x - xx] <> Color) then
  1399     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (LandGet(y - yy, x - xx) <> Color) then
  1400         begin inc(DrawDots); Land[y - yy, x - xx]:= Color; end;
  1400         begin inc(DrawDots); LandSet(y - yy, x - xx, Color); end;
  1401     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (Land[y + xx, x + yy] <> Color) then
  1401     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (LandGet(y + xx, x + yy) <> Color) then
  1402         begin inc(DrawDots); Land[y + xx, x + yy]:= Color; end;
  1402         begin inc(DrawDots); LandSet(y + xx, x + yy, Color); end;
  1403     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (Land[y - xx, x + yy] <> Color) then
  1403     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (LandGet(y - xx, x + yy) <> Color) then
  1404         begin inc(DrawDots); Land[y - xx, x + yy]:= Color; end;
  1404         begin inc(DrawDots); LandSet(y - xx, x + yy, Color); end;
  1405     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (Land[y + xx, x - yy] <> Color) then
  1405     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (LandGet(y + xx, x - yy) <> Color) then
  1406         begin inc(DrawDots); Land[y + xx, x - yy]:= Color; end;
  1406         begin inc(DrawDots); LandSet(y + xx, x - yy, Color); end;
  1407     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (Land[y - xx, x - yy] <> Color) then
  1407     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (LandGet(y - xx, x - yy) <> Color) then
  1408         begin inc(DrawDots); Land[y - xx, x - yy]:= Color; end;
  1408         begin inc(DrawDots); LandSet(y - xx, x - yy, Color); end;
  1409 end;
  1409 end;
  1410 
  1410 
  1411 function DrawLines(X1, Y1, X2, Y2, XX, YY: LongInt; color: Longword): Longword;
  1411 function DrawLines(X1, Y1, X2, Y2, XX, YY: LongInt; color: Longword): Longword;
  1412 var
  1412 var
  1413   eX, eY, dX, dY: LongInt;
  1413   eX, eY, dX, dY: LongInt;
  1510         for dx:= 0 to r*2 do
  1510         for dx:= 0 to r*2 do
  1511             begin
  1511             begin
  1512             xx:= dx - r + x;
  1512             xx:= dx - r + x;
  1513             if (xx = x) and (yy = y) then
  1513             if (xx = x) and (yy = y) then
  1514                 s[dx + 1]:= 'X'
  1514                 s[dx + 1]:= 'X'
  1515             else if Land[yy, xx] > 255 then
  1515             else if LandGet(yy, xx) > 255 then
  1516                 s[dx + 1]:= 'O'
  1516                 s[dx + 1]:= 'O'
  1517             else if Land[yy, xx] > 0 then
  1517             else if LandGet(yy, xx) > 0 then
  1518                 s[dx + 1]:= '*'
  1518                 s[dx + 1]:= '*'
  1519             else
  1519             else
  1520                 s[dx + 1]:= '.'
  1520                 s[dx + 1]:= '.'
  1521             end;
  1521             end;
  1522         AddFileLog('Land dump: ' + s);
  1522         AddFileLog('Land dump: ' + s);