hedgewars/uLandGraphics.pas
changeset 7492 3188794b9d87
parent 7270 93e92e82d5c8
child 7509 76e3a3fc17cd
equal deleted inserted replaced
7489:43a998fbacfe 7492:3188794b9d87
    57     // shortcircuit
    57     // shortcircuit
    58     if (oAlpha = 0) or (nAlpha = $FF) then
    58     if (oAlpha = 0) or (nAlpha = $FF) then
    59         begin
    59         begin
    60         addBgColor:= NewColor;
    60         addBgColor:= NewColor;
    61         exit
    61         exit
    62         end; 
    62         end;
    63     // Get colors
    63     // Get colors
    64     oRed   := (OldColor shr RShift);
    64     oRed   := (OldColor shr RShift);
    65     oGreen := (OldColor shr GShift);
    65     oGreen := (OldColor shr GShift);
    66     oBlue  := (OldColor shr BShift);
    66     oBlue  := (OldColor shr BShift);
    67 
    67 
    70     nBlue  := (NewColor shr BShift);
    70     nBlue  := (NewColor shr BShift);
    71 
    71 
    72     // Mix colors
    72     // Mix colors
    73     nRed   := min(255,((nRed*nAlpha) div 255) + ((oRed*oAlpha*byte(255-nAlpha)) div 65025));
    73     nRed   := min(255,((nRed*nAlpha) div 255) + ((oRed*oAlpha*byte(255-nAlpha)) div 65025));
    74     nGreen := min(255,((nGreen*nAlpha) div 255) + ((oGreen*oAlpha*byte(255-nAlpha)) div 65025));
    74     nGreen := min(255,((nGreen*nAlpha) div 255) + ((oGreen*oAlpha*byte(255-nAlpha)) div 65025));
    75     nBlue  := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*byte(255-nAlpha)) div 65025)); 
    75     nBlue  := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*byte(255-nAlpha)) div 65025));
    76     nAlpha := min(255, oAlpha + nAlpha);
    76     nAlpha := min(255, oAlpha + nAlpha);
    77 
    77 
    78     addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
    78     addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
    79 end;
    79 end;
    80 
    80 
    81 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    81 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    82 var i: LongInt;
    82 var i: LongInt;
    83 begin
    83 begin
    84 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    84 if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
    85     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    85     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do
    86         if (Land[y + dy, i] and lfIndestructible) = 0 then
    86         if (Land[y + dy, i] and lfIndestructible) = 0 then
    87             Land[y + dy, i]:= Value;
    87             Land[y + dy, i]:= Value;
    88 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    88 if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
    89     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
    89     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do
    90         if (Land[y - dy, i] and lfIndestructible) = 0 then
    90         if (Land[y - dy, i] and lfIndestructible) = 0 then
    91             Land[y - dy, i]:= Value;
    91             Land[y - dy, i]:= Value;
    92 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    92 if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
    93     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    93     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do
    94         if (Land[y + dx, i] and lfIndestructible) = 0 then
    94         if (Land[y + dx, i] and lfIndestructible) = 0 then
    95             Land[y + dx, i]:= Value;
    95             Land[y + dx, i]:= Value;
    96 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    96 if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
    97     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
    97     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do
    98         if (Land[y - dx, i] and lfIndestructible) = 0 then
    98         if (Land[y - dx, i] and lfIndestructible) = 0 then
    99             Land[y - dx, i]:= Value;
    99             Land[y - dx, i]:= Value;
   100 end;
   100 end;
   101 
   101 
   102 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet, isCurrent: boolean);
   102 procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet, isCurrent: boolean);
   103 var i: LongInt;
   103 var i: LongInt;
   104 begin
   104 begin
   105 if not doSet then
   105 if not doSet then
   106     begin
   106     begin
   107     if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   107     if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   108         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   108         for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do
   109             if isCurrent then 
   109             if isCurrent then
   110                 Land[y + dy, i]:= Land[y + dy, i] and $FF7F
   110                 Land[y + dy, i]:= Land[y + dy, i] and $FF7F
   111             else if Land[y + dy, i] and $007F > 0 then
   111             else if Land[y + dy, i] and $007F > 0 then
   112                 Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) - 1);
   112                 Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) - 1);
   113     if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   113     if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   114         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   114         for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do
   115             if isCurrent then 
   115             if isCurrent then
   116                 Land[y - dy, i]:= Land[y - dy, i] and $FF7F
   116                 Land[y - dy, i]:= Land[y - dy, i] and $FF7F
   117             else if Land[y - dy, i] and $007F > 0 then
   117             else if Land[y - dy, i] and $007F > 0 then
   118                 Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) - 1);
   118                 Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) - 1);
   119     if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   119     if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   120         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   120         for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do
   121             if isCurrent then 
   121             if isCurrent then
   122                 Land[y + dx, i]:= Land[y + dx, i] and $FF7F
   122                 Land[y + dx, i]:= Land[y + dx, i] and $FF7F
   123             else if Land[y + dx, i] and $007F > 0 then
   123             else if Land[y + dx, i] and $007F > 0 then
   124                 Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) - 1);
   124                 Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) - 1);
   125     if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   125     if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   126         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   126         for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do
   127             if isCurrent then 
   127             if isCurrent then
   128                 Land[y - dx, i]:= Land[y - dx, i] and $FF7F
   128                 Land[y - dx, i]:= Land[y - dx, i] and $FF7F
   129             else if Land[y - dx, i] and $007F > 0 then
   129             else if Land[y - dx, i] and $007F > 0 then
   130                 Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) - 1)
   130                 Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) - 1)
   131     end
   131     end
   132 else
   132 else
   133     begin
   133     begin
   134     if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   134     if ((y + dy) and LAND_HEIGHT_MASK) = 0 then
   135         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   135         for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do
   136             if isCurrent then 
   136             if isCurrent then
   137                 Land[y + dy, i]:= Land[y + dy, i] or $80
   137                 Land[y + dy, i]:= Land[y + dy, i] or $80
   138             else if Land[y + dy, i] and $007F < 127 then
   138             else if Land[y + dy, i] and $007F < 127 then
   139                 Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) + 1);
   139                 Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) + 1);
   140     if ((y - dy) and LAND_HEIGHT_MASK) = 0 then                                                   
   140     if ((y - dy) and LAND_HEIGHT_MASK) = 0 then
   141         for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do                                  
   141         for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do
   142             if isCurrent then                                                                     
   142             if isCurrent then
   143                 Land[y - dy, i]:= Land[y - dy, i] or $80                                          
   143                 Land[y - dy, i]:= Land[y - dy, i] or $80
   144             else if Land[y - dy, i] and $007F < 127 then                                          
   144             else if Land[y - dy, i] and $007F < 127 then
   145                 Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) + 1);
   145                 Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) + 1);
   146     if ((y + dx) and LAND_HEIGHT_MASK) = 0 then                                                   
   146     if ((y + dx) and LAND_HEIGHT_MASK) = 0 then
   147         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do                                  
   147         for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do
   148             if isCurrent then                                                                     
   148             if isCurrent then
   149                 Land[y + dx, i]:= Land[y + dx, i] or $80                                          
   149                 Land[y + dx, i]:= Land[y + dx, i] or $80
   150             else if Land[y + dx, i] and $007F < 127 then                                          
   150             else if Land[y + dx, i] and $007F < 127 then
   151                 Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) + 1);
   151                 Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) + 1);
   152     if ((y - dx) and LAND_HEIGHT_MASK) = 0 then                                                   
   152     if ((y - dx) and LAND_HEIGHT_MASK) = 0 then
   153         for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do                                  
   153         for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   154             if isCurrent then                                                                     
   154             if isCurrent then
   155                 Land[y - dx, i]:= Land[y - dx, i] or $80                                          
   155                 Land[y - dx, i]:= Land[y - dx, i] or $80
   156             else if Land[y - dx, i] and $007F < 127 then                                          
   156             else if Land[y - dx, i] and $007F < 127 then
   157                 Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) + 1)
   157                 Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) + 1)
   158     end
   158     end
   159 end;
   159 end;
   160 
   160 
   161 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
   161 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
   205 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   205 procedure FillLandCircleLines0(x, y, dx, dy: LongInt);
   206 var i, t: LongInt;
   206 var i, t: LongInt;
   207 begin
   207 begin
   208 t:= y + dy;
   208 t:= y + dy;
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   209 if (t and LAND_HEIGHT_MASK) = 0 then
   210     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   210     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do 
   211         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   211         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   212             if (cReducedQuality and rqBlurryLand) = 0 then
   212             if (cReducedQuality and rqBlurryLand) = 0 then
   213                 LandPixels[t, i]:= 0
   213                 LandPixels[t, i]:= 0
   214             else
   214             else
   215                 LandPixels[t div 2, i div 2]:= 0;
   215                 LandPixels[t div 2, i div 2]:= 0;
   216 
   216 
   217 t:= y - dy;
   217 t:= y - dy;
   218 if (t and LAND_HEIGHT_MASK) = 0 then
   218 if (t and LAND_HEIGHT_MASK) = 0 then
   219     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   219     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do 
   220         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   220         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   221             if (cReducedQuality and rqBlurryLand) = 0 then
   221             if (cReducedQuality and rqBlurryLand) = 0 then
   222                 LandPixels[t, i]:= 0
   222                 LandPixels[t, i]:= 0
   223             else
   223             else
   224                 LandPixels[t div 2, i div 2]:= 0;
   224                 LandPixels[t div 2, i div 2]:= 0;
   225 
   225 
   226 t:= y + dx;
   226 t:= y + dx;
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   227 if (t and LAND_HEIGHT_MASK) = 0 then
   228     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   228     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   229         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   229         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   230             if (cReducedQuality and rqBlurryLand) = 0 then
   230             if (cReducedQuality and rqBlurryLand) = 0 then
   231                 LandPixels[t, i]:= 0
   231                 LandPixels[t, i]:= 0
   232             else
   232             else
   233                 LandPixels[t div 2, i div 2]:= 0;
   233                 LandPixels[t div 2, i div 2]:= 0;
   234 
   234 
   235 t:= y - dx;
   235 t:= y - dx;
   236 if (t and LAND_HEIGHT_MASK) = 0 then
   236 if (t and LAND_HEIGHT_MASK) = 0 then
   237     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   237     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   238         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   238         if ((Land[t, i] and lfIndestructible) = 0) and (not disableLandBack or (Land[t, i] > 255))  then
   239             if (cReducedQuality and rqBlurryLand) = 0 then
   239             if (cReducedQuality and rqBlurryLand) = 0 then
   240                 LandPixels[t, i]:= 0
   240                 LandPixels[t, i]:= 0
   241             else
   241             else
   242                 LandPixels[t div 2, i div 2]:= 0;
   242                 LandPixels[t div 2, i div 2]:= 0;
   248     cnt: Longword;
   248     cnt: Longword;
   249 begin
   249 begin
   250 cnt:= 0;
   250 cnt:= 0;
   251 t:= y + dy;
   251 t:= y + dy;
   252 if (t and LAND_HEIGHT_MASK) = 0 then
   252 if (t and LAND_HEIGHT_MASK) = 0 then
   253     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   253     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do 
   254         if (Land[t, i] and lfIndestructible) = 0 then
   254         if (Land[t, i] and lfIndestructible) = 0 then
   255             begin
   255             begin
   256             if (cReducedQuality and rqBlurryLand) = 0 then
   256             if (cReducedQuality and rqBlurryLand) = 0 then
   257                 begin
   257                 begin
   258                 by:= t; bx:= i;
   258                 by:= t; bx:= i;
   264             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   264             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   265                 begin
   265                 begin
   266                 inc(cnt);
   266                 inc(cnt);
   267                 LandPixels[by, bx]:= LandBackPixel(i, t)
   267                 LandPixels[by, bx]:= LandBackPixel(i, t)
   268                 end
   268                 end
   269             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
   269             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   270                 LandPixels[by, bx]:= 0
   270                 LandPixels[by, bx]:= 0
   271             end;
   271             end;
   272 
   272 
   273 t:= y - dy;
   273 t:= y - dy;
   274 if (t and LAND_HEIGHT_MASK) = 0 then
   274 if (t and LAND_HEIGHT_MASK) = 0 then
   275     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   275     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do 
   276         if (Land[t, i] and lfIndestructible) = 0 then
   276         if (Land[t, i] and lfIndestructible) = 0 then
   277             begin
   277             begin
   278             if (cReducedQuality and rqBlurryLand) = 0 then
   278             if (cReducedQuality and rqBlurryLand) = 0 then
   279                 begin
   279                 begin
   280                 by:= t; bx:= i;
   280                 by:= t; bx:= i;
   286             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   286             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   287                 begin
   287                 begin
   288                 inc(cnt);
   288                 inc(cnt);
   289                 LandPixels[by, bx]:= LandBackPixel(i, t)
   289                 LandPixels[by, bx]:= LandBackPixel(i, t)
   290                 end
   290                 end
   291             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
   291             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   292                 LandPixels[by, bx]:= 0
   292                 LandPixels[by, bx]:= 0
   293             end;
   293             end;
   294 
   294 
   295 t:= y + dx;
   295 t:= y + dx;
   296 if (t and LAND_HEIGHT_MASK) = 0 then
   296 if (t and LAND_HEIGHT_MASK) = 0 then
   297     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   297     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   298         if (Land[t, i] and lfIndestructible) = 0 then
   298         if (Land[t, i] and lfIndestructible) = 0 then
   299             begin
   299             begin
   300             if (cReducedQuality and rqBlurryLand) = 0 then
   300             if (cReducedQuality and rqBlurryLand) = 0 then
   301                 begin
   301                 begin
   302                 by:= t; bx:= i;
   302                 by:= t; bx:= i;
   308             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   308             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   309                 begin
   309                 begin
   310                 inc(cnt);
   310                 inc(cnt);
   311                 LandPixels[by, bx]:= LandBackPixel(i, t)
   311                 LandPixels[by, bx]:= LandBackPixel(i, t)
   312                 end
   312                 end
   313             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
   313             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   314                 LandPixels[by, bx]:= 0
   314                 LandPixels[by, bx]:= 0
   315             end;
   315             end;
   316 t:= y - dx;
   316 t:= y - dx;
   317 if (t and LAND_HEIGHT_MASK) = 0 then
   317 if (t and LAND_HEIGHT_MASK) = 0 then
   318     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   318     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   319         if (Land[t, i] and lfIndestructible) = 0 then
   319         if (Land[t, i] and lfIndestructible) = 0 then
   320             begin
   320             begin
   321             if (cReducedQuality and rqBlurryLand) = 0 then
   321             if (cReducedQuality and rqBlurryLand) = 0 then
   322                 begin
   322                 begin
   323                 by:= t; bx:= i;
   323                 by:= t; bx:= i;
   329             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   329             if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   330                 begin
   330                 begin
   331                 inc(cnt);
   331                 inc(cnt);
   332                 LandPixels[by, bx]:= LandBackPixel(i, t)
   332                 LandPixels[by, bx]:= LandBackPixel(i, t)
   333                 end
   333                 end
   334             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
   334             else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   335                 LandPixels[by, bx]:= 0
   335                 LandPixels[by, bx]:= 0
   336             end;
   336             end;
   337 FillLandCircleLinesBG:= cnt;
   337 FillLandCircleLinesBG:= cnt;
   338 end;
   338 end;
   339 
   339 
   340 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   340 procedure FillLandCircleLinesEBC(x, y, dx, dy: LongInt);
   341 var i, t: LongInt;
   341 var i, t: LongInt;
   342 begin
   342 begin
   343 t:= y + dy;
   343 t:= y + dy;
   344 if (t and LAND_HEIGHT_MASK) = 0 then
   344 if (t and LAND_HEIGHT_MASK) = 0 then
   345     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   345     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do 
   346         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   346         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   347             begin
   347             begin
   348             if (cReducedQuality and rqBlurryLand) = 0 then
   348             if (cReducedQuality and rqBlurryLand) = 0 then
   349                 LandPixels[t, i]:= ExplosionBorderColor
   349                 LandPixels[t, i]:= ExplosionBorderColor
   350             else
   350             else
   355             LandDirty[t div 32, i div 32]:= 1;
   355             LandDirty[t div 32, i div 32]:= 1;
   356             end;
   356             end;
   357 
   357 
   358 t:= y - dy;
   358 t:= y - dy;
   359 if (t and LAND_HEIGHT_MASK) = 0 then
   359 if (t and LAND_HEIGHT_MASK) = 0 then
   360     for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do
   360     for i:= Min(x + dx, LAND_WIDTH - 1) downto Max(x - dx, 0) do 
   361         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   361         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   362             begin
   362             begin
   363             if (cReducedQuality and rqBlurryLand) = 0 then
   363             if (cReducedQuality and rqBlurryLand) = 0 then
   364                 LandPixels[t, i]:= ExplosionBorderColor
   364                 LandPixels[t, i]:= ExplosionBorderColor
   365             else
   365             else
   369             LandDirty[t div 32, i div 32]:= 1;
   369             LandDirty[t div 32, i div 32]:= 1;
   370             end;
   370             end;
   371 
   371 
   372 t:= y + dx;
   372 t:= y + dx;
   373 if (t and LAND_HEIGHT_MASK) = 0 then
   373 if (t and LAND_HEIGHT_MASK) = 0 then
   374     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   374     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   375         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   375         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   376             begin
   376             begin
   377             if (cReducedQuality and rqBlurryLand) = 0 then
   377             if (cReducedQuality and rqBlurryLand) = 0 then
   378                 LandPixels[t, i]:= ExplosionBorderColor
   378                 LandPixels[t, i]:= ExplosionBorderColor
   379             else
   379             else
   384             LandDirty[t div 32, i div 32]:= 1;
   384             LandDirty[t div 32, i div 32]:= 1;
   385             end;
   385             end;
   386 
   386 
   387 t:= y - dx;
   387 t:= y - dx;
   388 if (t and LAND_HEIGHT_MASK) = 0 then
   388 if (t and LAND_HEIGHT_MASK) = 0 then
   389     for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do
   389     for i:= Min(x + dy, LAND_WIDTH - 1) downto Max(x - dy, 0) do 
   390         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   390         if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
   391             begin
   391             begin
   392             if (cReducedQuality and rqBlurryLand) = 0 then
   392             if (cReducedQuality and rqBlurryLand) = 0 then
   393                 LandPixels[t, i]:= ExplosionBorderColor
   393                 LandPixels[t, i]:= ExplosionBorderColor
   394             else
   394             else
   487 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   487 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
   488 var tx, ty, by, bx,  i: LongInt;
   488 var tx, ty, by, bx,  i: LongInt;
   489 begin
   489 begin
   490 for i:= 0 to Pred(Count) do
   490 for i:= 0 to Pred(Count) do
   491     begin
   491     begin
   492     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   492     for ty:= Min(y + Radius, LAND_HEIGHT) downto Max(y - Radius, 0) do 
   493         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   493         for tx:= Min(LAND_WIDTH, ar^[i].Right + Radius) downto Max(0, ar^[i].Left - Radius) do 
   494             begin
   494             begin
   495             if (Land[ty, tx] and lfIndestructible) = 0 then
   495             if (Land[ty, tx] and lfIndestructible) = 0 then
   496                 begin
   496                 begin
   497                 if (cReducedQuality and rqBlurryLand) = 0 then
   497                 if (cReducedQuality and rqBlurryLand) = 0 then
   498                     begin
   498                     begin
   502                     begin
   502                     begin
   503                     by:= ty div 2; bx:= tx div 2;
   503                     by:= ty div 2; bx:= tx div 2;
   504                     end;
   504                     end;
   505                 if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   505                 if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then
   506                     LandPixels[by, bx]:= LandBackPixel(tx, ty)
   506                     LandPixels[by, bx]:= LandBackPixel(tx, ty)
   507                 else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then 
   507                 else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then
   508                     LandPixels[by, bx]:= 0
   508                     LandPixels[by, bx]:= 0
   509                 end
   509                 end
   510             end;
   510             end;
   511     inc(y, dY)
   511     inc(y, dY)
   512     end;
   512     end;
   514 inc(Radius, 4);
   514 inc(Radius, 4);
   515 dec(y, Count * dY);
   515 dec(y, Count * dY);
   516 
   516 
   517 for i:= 0 to Pred(Count) do
   517 for i:= 0 to Pred(Count) do
   518     begin
   518     begin
   519     for ty:= Max(y - Radius, 0) to Min(y + Radius, LAND_HEIGHT) do
   519     for ty:= Min(y + Radius, LAND_HEIGHT) downto Max(y - Radius, 0) do 
   520         for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do
   520         for tx:= Min(LAND_WIDTH, ar^[i].Right + Radius) downto Max(0, ar^[i].Left - Radius) do 
   521             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   521             if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then
   522                 begin
   522                 begin
   523                  if (cReducedQuality and rqBlurryLand) = 0 then
   523                  if (cReducedQuality and rqBlurryLand) = 0 then
   524                     LandPixels[ty, tx]:= ExplosionBorderColor
   524                     LandPixels[ty, tx]:= ExplosionBorderColor
   525                 else
   525                 else
   565     ty:= hwRound(Y);
   565     ty:= hwRound(Y);
   566     if ((ty and LAND_HEIGHT_MASK) = 0)
   566     if ((ty and LAND_HEIGHT_MASK) = 0)
   567     and ((tx and LAND_WIDTH_MASK) = 0)
   567     and ((tx and LAND_WIDTH_MASK) = 0)
   568     and (((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0)) then
   568     and (((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0)) then
   569         begin
   569         begin
   570         if despeckle then 
   570         if despeckle then
   571             begin
   571             begin
   572             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   572             Land[ty, tx]:= Land[ty, tx] or lfDamaged;
   573             LandDirty[ty div 32, tx div 32]:= 1
   573             LandDirty[ty div 32, tx div 32]:= 1
   574             end;
   574             end;
   575         if (cReducedQuality and rqBlurryLand) = 0 then
   575         if (cReducedQuality and rqBlurryLand) = 0 then
   835 end;
   835 end;
   836 
   836 
   837 procedure Smooth(X, Y: LongInt);
   837 procedure Smooth(X, Y: LongInt);
   838 begin
   838 begin
   839 // a bit of AA for explosions
   839 // a bit of AA for explosions
   840 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and 
   840 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and
   841     (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
   841     (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
   842     begin
   842     begin
   843     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
   843     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
   844     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
   844     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
   845         begin
   845         begin