Changeset 322 for trunk/LocalPlayer


Ignore:
Timestamp:
Mar 22, 2021, 11:21:11 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/IsoEngine.pas

    r321 r322  
    117117  BordersOK: integer;
    118118  OnInitEnemyModel: TInitEnemyModelEvent;
    119   LandPatch, OceanPatch, Borders: TBitmap;
    120   TSpriteSize: array [0 .. TerrainIconLines * 9 - 1] of TRect;
     119  LandPatch: TBitmap;
     120  OceanPatch: TBitmap;
     121  Borders: TBitmap;
     122  TSpriteSize: array [0 .. TerrainIconLines * TerrainIconCols - 1] of TRect;
    121123  DebugMap: ^TTileList;
    122124  CitiesPictures: array [2 .. 3, 0 .. 3] of TCityPicture;
    123   FoW, ShowLoc, ShowCityNames, ShowObjects, ShowBorder, ShowMyBorder,
    124     ShowGrWall, ShowDebug: boolean;
     125  FoW: Boolean;
     126  ShowLoc: Boolean;
     127  ShowCityNames: Boolean;
     128  ShowObjects: Boolean;
     129  ShowBorder: Boolean;
     130  ShowMyBorder: Boolean;
     131  ShowGrWall: Boolean;
     132  ShowDebug: Boolean;
    125133
    126134function IsJungle(y: integer): boolean;
     
    137145end;
    138146
    139 function ApplyTileSize(ATileSize: TTileSize): boolean;
    140 var
    141   i: Integer;
    142   x: Integer;
    143   y: Integer;
     147procedure ReduceTerrainIconsSize;
     148var
     149  MaskLine: array of TPixelPointer;
     150  Mask24: TBitmap;
    144151  xSrc: Integer;
    145152  ySrc: Integer;
    146   HGrTerrainNew: TGraphicSet;
    147   HGrCitiesNew: TGraphicSet;
    148   Age: Integer;
    149   Size: Integer;
    150   LandMore, OceanMore, DitherMask, Mask24: TBitmap;
    151   MaskLine: array [0 .. 50 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt
    152   Border: boolean;
    153   xxtNew: Integer;
    154   yytNew: Integer;
    155 begin
    156   xxtNew := TileSizes[ATileSize].X;
    157   yytNew := TileSizes[ATileSize].Y;
    158   result := false;
    159   HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png',
    160     [xxtNew * 2, yytNew * 2]));
    161   if not Assigned(HGrTerrainNew) then
    162     exit;
    163   HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png',
    164     [xxtNew * 2, yytNew * 2]));
    165   if not Assigned(HGrCitiesNew) then
    166     exit;
    167   xxt := xxtNew;
    168   yyt := yytNew;
    169   TileSize := ATileSize;
    170   HGrTerrain := HGrTerrainNew;
    171   HGrCities := HGrCitiesNew;
    172   result := true;
    173 
    174   // prepare age 2+3 cities
    175   for age := 2 to 3 do
    176     for size := 0 to 3 do
    177       with CitiesPictures[age, size] do
    178         FindPosition(HGrCities, size * (xxt * 2 + 1), (age - 2) * (yyt * 3 + 1),
    179           xxt * 2 - 1, yyt * 3 - 1, $00FFFF, xShield, yShield);
    180 
    181   { prepare dithered ground tiles }
    182   if LandPatch <> nil then
    183     FreeAndNil(LandPatch);
    184   LandPatch := TBitmap.Create;
    185   LandPatch.PixelFormat := pf24bit;
    186   LandPatch.Canvas.Brush.Color := 0;
    187   LandPatch.SetSize(xxt * 18, yyt * 9);
    188   LandPatch.Canvas.FillRect(0, 0, LandPatch.Width, LandPatch.Height);
    189   if OceanPatch <> nil then
    190     FreeAndNil(OceanPatch);
    191   OceanPatch := TBitmap.Create;
    192   OceanPatch.PixelFormat := pf24bit;
    193   OceanPatch.Canvas.Brush.Color := 0;
    194   OceanPatch.SetSize(xxt * 8, yyt * 4);
    195   OceanPatch.Canvas.FillRect(0, 0, OceanPatch.Width, OceanPatch.Height);
    196   LandMore := TBitmap.Create;
    197   LandMore.PixelFormat := pf24bit;
    198   LandMore.Canvas.Brush.Color := 0;
    199   LandMore.SetSize(xxt * 18, yyt * 9);
    200   LandMore.Canvas.FillRect(0, 0, LandMore.Width, LandMore.Height);
    201   OceanMore := TBitmap.Create;
    202   OceanMore.PixelFormat := pf24bit;
    203   OceanMore.Canvas.Brush.Color := 0;
    204   OceanMore.SetSize(xxt * 8, yyt * 4);
    205   OceanMore.Canvas.FillRect(0, 0, OceanMore.Width, OceanMore.Height);
    206   DitherMask := TBitmap.Create;
    207   DitherMask.PixelFormat := pf24bit;
    208   DitherMask.SetSize(xxt * 2, yyt * 2);
    209   DitherMask.Canvas.FillRect(0, 0, DitherMask.Width, DitherMask.Height);
    210   BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
    211     HGrTerrain.Mask.Canvas, 1 + 7 * (xxt * 2 + 1),
    212     1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    213 
    214   for x := -1 to 6 do
    215   begin
    216     if x = -1 then
    217     begin
    218       xSrc := ShoreDither * (xxt * 2 + 1) + 1;
    219       ySrc := 1 + yyt
    220     end
    221     else if x = 6 then
    222     begin
    223       xSrc := 1 + (xxt * 2 + 1) * 2;
    224       ySrc := 1 + yyt + (yyt * 3 + 1) * 2
    225     end
    226     else
    227     begin
    228       xSrc := (x + 2) * (xxt * 2 + 1) + 1;
    229       ySrc := 1 + yyt
    230     end;
    231     for y := -1 to 6 do
    232       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
    233         xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
    234     for y := -2 to 6 do
    235       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
    236         yyt, HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    237         SRCPAINT);
    238     for y := -2 to 6 do
    239       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
    240         xxt, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
    241         SRCPAINT);
    242     for y := -2 to 6 do
    243       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
    244         yyt, DitherMask.Canvas, xxt, yyt, SRCAND);
    245     for y := -2 to 6 do
    246       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
    247         xxt, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    248   end;
    249 
    250   for y := -1 to 6 do
    251   begin
    252     if y = -1 then
    253     begin
    254       xSrc := ShoreDither * (xxt * 2 + 1) + 1;
    255       ySrc := 1 + yyt
    256     end
    257     else if y = 6 then
    258     begin
    259       xSrc := 1 + 2 * (xxt * 2 + 1);
    260       ySrc := 1 + yyt + 2 * (yyt * 3 + 1)
    261     end
    262     else
    263     begin
    264       xSrc := (y + 2) * (xxt * 2 + 1) + 1;
    265       ySrc := 1 + yyt
    266     end;
    267     for x := -2 to 6 do
    268       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
    269         xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
    270     BitBltCanvas(LandMore.Canvas, xxt * 2, (y + 2) * yyt, xxt, yyt,
    271       HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT);
    272     for x := 0 to 7 do
    273       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
    274         xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
    275         SRCPAINT);
    276     for x := -2 to 6 do
    277       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
    278         xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
    279   end;
    280 
    281   for x := 0 to 3 do
    282     for y := 0 to 3 do
    283     begin
    284       if (x = 1) and (y = 1) then
    285         xSrc := 1
    286       else
    287         xSrc := (x mod 2) * (xxt * 2 + 1) + 1;
    288       ySrc := 1 + yyt;
    289       if (x >= 1) = (y >= 2) then
    290         BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    291           HGrTerrain.Data.Canvas, xSrc, ySrc);
    292       if (x >= 1) and ((y < 2) or (x >= 2)) then
    293       begin
    294         BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
    295           HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    296           SRCPAINT);
    297         BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    298           HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    299       end;
    300       BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
    301         DitherMask.Canvas, xxt, yyt, SRCAND);
    302       BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    303         DitherMask.Canvas, 0, yyt, SRCAND);
    304     end;
    305 
    306   for y := 0 to 3 do
    307     for x := 0 to 3 do
    308     begin
    309       if (x = 1) and (y = 1) then
    310         xSrc := 1
    311       else
    312         xSrc := (y mod 2) * (xxt * 2 + 1) + 1;
    313       ySrc := 1 + yyt;
    314       if (x < 1) or (y >= 2) then
    315         BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    316           HGrTerrain.Data.Canvas, xSrc, ySrc);
    317       if (x = 1) and (y < 2) or (x >= 2) and (y >= 1) then
    318       begin
    319         BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
    320           HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
    321           SRCPAINT);
    322         BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    323           HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    324       end;
    325       BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    326         DitherMask.Canvas, 0, 0, SRCAND);
    327     end;
    328 
    329   BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
    330     DitherMask.Canvas, 0, 0, DSTINVERT); { invert dither mask }
    331   BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
    332     HGrTerrain.Mask.Canvas, 1, 1 + yyt, SRCPAINT);
    333 
    334   for x := -1 to 6 do
    335     for y := -2 to 6 do
    336       BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
    337         xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
    338 
    339   for y := -1 to 6 do
    340     for x := -2 to 7 do
    341       BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
    342         xxt * 2, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    343 
    344   BitBltCanvas(LandPatch.Canvas, 0, 0, (xxt * 2) * 9, yyt * 9,
    345     LandMore.Canvas, 0, 0, SRCPAINT);
    346 
    347   for x := 0 to 3 do
    348     for y := 0 to 3 do
    349       BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    350         DitherMask.Canvas, 0, 0, SRCAND);
    351 
    352   for y := 0 to 3 do
    353     for x := 0 to 4 do
    354       BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) - xxt, y * yyt, xxt * 2,
    355         yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    356 
    357   BitBltCanvas(OceanPatch.Canvas, 0, 0, (xxt * 2) * 4, yyt * 4,
    358     OceanMore.Canvas, 0, 0, SRCPAINT);
    359 
    360   with DitherMask.Canvas do
    361   begin
    362     Brush.Color := $FFFFFF;
    363     FillRect(Rect(0, 0, xxt * 2, yyt));
    364   end;
    365   BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt,
    366     HGrTerrain.Mask.Canvas, 1, 1 + yyt);
    367 
    368   for x := 0 to 6 do
    369     BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), yyt, xxt * 2, yyt,
    370       DitherMask.Canvas, 0, 0, SRCAND);
    371   BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, DitherMask.Canvas,
    372     0, 0, DSTINVERT);
    373 
    374   for y := 0 to 6 do
    375     BitBltCanvas(LandPatch.Canvas, xxt * 2, (y + 2) * yyt, xxt * 2, yyt,
    376       DitherMask.Canvas, 0, 0, SRCAND);
    377 
    378   FreeAndNil(LandMore);
    379   FreeAndNil(OceanMore);
    380   FreeAndNil(DitherMask);
     153  I: Integer;
     154  X: Integer;
     155  Y: Integer;
     156  Border: Boolean;
     157begin
     158  SetLength(MaskLine, yyt * 3);
    381159
    382160  // reduce size of terrain icons
     
    385163  Mask24.PixelFormat := pf24bit;
    386164  Mask24.BeginUpdate;
    387   for ySrc := 0 to TerrainIconLines - 1 do
    388   begin
     165  for ySrc := 0 to TerrainIconLines - 1 do begin
    389166    for i := 0 to yyt * 3 - 1 do
    390167      MaskLine[i] := PixelPointer(Mask24, 0, 1 + ySrc * (yyt * 3 + 1) + i);
    391     for xSrc := 0 to 9 - 1 do
    392     begin
     168    for xSrc := 0 to TerrainIconCols - 1 do begin
    393169      i := ySrc * 9 + xSrc;
    394170      TSpriteSize[i].Left := 0;
     
    428204        if Border then Dec(TSpriteSize[i].Bottom);
    429205      until not Border or (TSpriteSize[i].Bottom = TSpriteSize[i].Top);
    430     end
     206    end;
    431207  end;
    432208  Mask24.EndUpdate;
    433209  FreeAndNil(Mask24);
    434 
    435   if Borders <> nil then
    436     FreeAndNil(Borders);
    437   Borders := TBitmap.Create;
    438   Borders.PixelFormat := pf24bit;
     210end;
     211
     212function ApplyTileSize(ATileSize: TTileSize): boolean;
     213var
     214  x: Integer;
     215  y: Integer;
     216  xSrc: Integer;
     217  ySrc: Integer;
     218  HGrTerrainNew: TGraphicSet;
     219  HGrCitiesNew: TGraphicSet;
     220  Age: Integer;
     221  Size: Integer;
     222  LandMore: TBitmap;
     223  OceanMore: TBitmap;
     224  DitherMask: TBitmap;
     225  xxtNew: Integer;
     226  yytNew: Integer;
     227begin
     228  xxtNew := TileSizes[ATileSize].X;
     229  yytNew := TileSizes[ATileSize].Y;
     230  result := false;
     231  HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png',
     232    [xxtNew * 2, yytNew * 2]));
     233  if not Assigned(HGrTerrainNew) then
     234    exit;
     235  HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png',
     236    [xxtNew * 2, yytNew * 2]));
     237  if not Assigned(HGrCitiesNew) then
     238    exit;
     239  xxt := xxtNew;
     240  yyt := yytNew;
     241  TileSize := ATileSize;
     242  HGrTerrain := HGrTerrainNew;
     243  HGrCities := HGrCitiesNew;
     244  Result := true;
     245
     246  // prepare age 2+3 cities
     247  for age := 2 to 3 do
     248    for size := 0 to 3 do
     249      with CitiesPictures[age, size] do
     250        FindPosition(HGrCities, size * (xxt * 2 + 1), (age - 2) * (yyt * 3 + 1),
     251          xxt * 2 - 1, yyt * 3 - 1, $00FFFF, xShield, yShield);
     252
     253  { prepare dithered ground tiles }
     254  if not Assigned(LandPatch) then begin
     255    LandPatch := TBitmap.Create;
     256    LandPatch.PixelFormat := pf24bit;
     257  end;
     258  LandPatch.Canvas.Brush.Color := 0;
     259  LandPatch.SetSize(xxt * 18, yyt * 9);
     260  LandPatch.Canvas.FillRect(0, 0, LandPatch.Width, LandPatch.Height);
     261  if not Assigned(OceanPatch) then begin
     262    OceanPatch := TBitmap.Create;
     263    OceanPatch.PixelFormat := pf24bit;
     264  end;
     265  OceanPatch.Canvas.Brush.Color := 0;
     266  OceanPatch.SetSize(xxt * 8, yyt * 4);
     267  OceanPatch.Canvas.FillRect(0, 0, OceanPatch.Width, OceanPatch.Height);
     268  LandMore := TBitmap.Create;
     269  LandMore.PixelFormat := pf24bit;
     270  LandMore.Canvas.Brush.Color := 0;
     271  LandMore.SetSize(xxt * 18, yyt * 9);
     272  LandMore.Canvas.FillRect(0, 0, LandMore.Width, LandMore.Height);
     273  OceanMore := TBitmap.Create;
     274  OceanMore.PixelFormat := pf24bit;
     275  OceanMore.Canvas.Brush.Color := 0;
     276  OceanMore.SetSize(xxt * 8, yyt * 4);
     277  OceanMore.Canvas.FillRect(0, 0, OceanMore.Width, OceanMore.Height);
     278  DitherMask := TBitmap.Create;
     279  DitherMask.PixelFormat := pf24bit;
     280  DitherMask.SetSize(xxt * 2, yyt * 2);
     281  DitherMask.Canvas.FillRect(0, 0, DitherMask.Width, DitherMask.Height);
     282  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
     283    HGrTerrain.Mask.Canvas, 1 + 7 * (xxt * 2 + 1),
     284    1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
     285
     286  for x := -1 to 6 do begin
     287    if x = -1 then begin
     288      xSrc := ShoreDither * (xxt * 2 + 1) + 1;
     289      ySrc := 1 + yyt;
     290    end
     291    else if x = 6 then begin
     292      xSrc := 1 + (xxt * 2 + 1) * 2;
     293      ySrc := 1 + yyt + (yyt * 3 + 1) * 2;
     294    end else begin
     295      xSrc := (x + 2) * (xxt * 2 + 1) + 1;
     296      ySrc := 1 + yyt;
     297    end;
     298    for y := -1 to 6 do
     299      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     300        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
     301    for y := -2 to 6 do
     302      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
     303        yyt, HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
     304        SRCPAINT);
     305    for y := -2 to 6 do
     306      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
     307        xxt, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
     308        SRCPAINT);
     309    for y := -2 to 6 do
     310      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
     311        yyt, DitherMask.Canvas, xxt, yyt, SRCAND);
     312    for y := -2 to 6 do
     313      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
     314        xxt, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
     315  end;
     316
     317  for y := -1 to 6 do begin
     318    if y = -1 then begin
     319      xSrc := ShoreDither * (xxt * 2 + 1) + 1;
     320      ySrc := 1 + yyt;
     321    end
     322    else if y = 6 then begin
     323      xSrc := 1 + 2 * (xxt * 2 + 1);
     324      ySrc := 1 + yyt + 2 * (yyt * 3 + 1);
     325    end else begin
     326      xSrc := (y + 2) * (xxt * 2 + 1) + 1;
     327      ySrc := 1 + yyt;
     328    end;
     329    for x := -2 to 6 do
     330      BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     331        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc);
     332    BitBltCanvas(LandMore.Canvas, xxt * 2, (y + 2) * yyt, xxt, yyt,
     333      HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT);
     334    for x := 0 to 7 do
     335      BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
     336        xxt * 2, yyt, HGrTerrain.Data.Canvas, xSrc, ySrc + yyt,
     337        SRCPAINT);
     338    for x := -2 to 6 do
     339      BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     340        xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
     341  end;
     342
     343  for x := 0 to 3 do begin
     344    for y := 0 to 3 do begin
     345      if (x = 1) and (y = 1) then xSrc := 1
     346      else
     347        xSrc := (x mod 2) * (xxt * 2 + 1) + 1;
     348      ySrc := 1 + yyt;
     349      if (x >= 1) = (y >= 2) then
     350        BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     351          HGrTerrain.Data.Canvas, xSrc, ySrc);
     352      if (x >= 1) and ((y < 2) or (x >= 2)) then
     353      begin
     354        BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     355          HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
     356          SRCPAINT);
     357        BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     358          HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
     359      end;
     360      BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     361        DitherMask.Canvas, xxt, yyt, SRCAND);
     362      BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     363        DitherMask.Canvas, 0, yyt, SRCAND);
     364    end;
     365  end;
     366
     367  for y := 0 to 3 do begin
     368    for x := 0 to 3 do begin
     369      if (x = 1) and (y = 1) then xSrc := 1
     370      else
     371        xSrc := (y mod 2) * (xxt * 2 + 1) + 1;
     372      ySrc := 1 + yyt;
     373      if (x < 1) or (y >= 2) then
     374        BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     375          HGrTerrain.Data.Canvas, xSrc, ySrc);
     376      if (x = 1) and (y < 2) or (x >= 2) and (y >= 1) then
     377      begin
     378        BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     379          HGrTerrain.Data.Canvas, xSrc + xxt, ySrc + yyt,
     380          SRCPAINT);
     381        BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     382          HGrTerrain.Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
     383      end;
     384      BitBltCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     385        DitherMask.Canvas, 0, 0, SRCAND);
     386    end;
     387  end;
     388
     389  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
     390    DitherMask.Canvas, 0, 0, DSTINVERT); { invert dither mask }
     391  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
     392    HGrTerrain.Mask.Canvas, 1, 1 + yyt, SRCPAINT);
     393
     394  for x := -1 to 6 do
     395    for y := -2 to 6 do
     396      BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     397        xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
     398
     399  for y := -1 to 6 do
     400    for x := -2 to 7 do
     401      BitBltCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
     402        xxt * 2, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
     403
     404  BitBltCanvas(LandPatch.Canvas, 0, 0, (xxt * 2) * 9, yyt * 9,
     405    LandMore.Canvas, 0, 0, SRCPAINT);
     406
     407  for x := 0 to 3 do
     408    for y := 0 to 3 do
     409      BitBltCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     410        DitherMask.Canvas, 0, 0, SRCAND);
     411
     412  for y := 0 to 3 do
     413    for x := 0 to 4 do
     414      BitBltCanvas(OceanMore.Canvas, x * (xxt * 2) - xxt, y * yyt, xxt * 2,
     415        yyt, DitherMask.Canvas, 0, yyt, SRCAND);
     416
     417  BitBltCanvas(OceanPatch.Canvas, 0, 0, (xxt * 2) * 4, yyt * 4,
     418    OceanMore.Canvas, 0, 0, SRCPAINT);
     419
     420  with DitherMask.Canvas do begin
     421    Brush.Color := $FFFFFF;
     422    FillRect(Rect(0, 0, xxt * 2, yyt));
     423  end;
     424  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt,
     425    HGrTerrain.Mask.Canvas, 1, 1 + yyt);
     426
     427  for x := 0 to 6 do
     428    BitBltCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), yyt, xxt * 2, yyt,
     429      DitherMask.Canvas, 0, 0, SRCAND);
     430  BitBltCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, DitherMask.Canvas,
     431    0, 0, DSTINVERT);
     432
     433  for y := 0 to 6 do
     434    BitBltCanvas(LandPatch.Canvas, xxt * 2, (y + 2) * yyt, xxt * 2, yyt,
     435      DitherMask.Canvas, 0, 0, SRCAND);
     436
     437  FreeAndNil(LandMore);
     438  FreeAndNil(OceanMore);
     439  FreeAndNil(DitherMask);
     440
     441  ReduceTerrainIconsSize;
     442
     443  if not Assigned(Borders) then begin
     444    Borders := TBitmap.Create;
     445    Borders.PixelFormat := pf24bit;
     446  end;
    439447  Borders.SetSize(xxt * 2, (yyt * 2) * nPl);
    440448  Borders.Canvas.FillRect(0, 0, Borders.Width, Borders.Height);
     
    548556  PureBlack: boolean = false);
    549557var
    550   Width, Height, xSrc, ySrc: integer;
     558  Width: Integer;
     559  Height: Integer;
     560  xSrc: Integer;
     561  ySrc: integer;
    551562begin
    552563  Width := TSpriteSize[grix].Right - TSpriteSize[grix].Left;
     
    556567  xDst := xDst + TSpriteSize[grix].Left;
    557568  yDst := yDst - yyt + TSpriteSize[grix].Top;
    558   if xDst < FLeft then
    559   begin
     569  if xDst < FLeft then begin
    560570    Width := Width - (FLeft - xDst);
    561571    xSrc := xSrc + (FLeft - xDst);
    562     xDst := FLeft
    563   end;
    564   if yDst < FTop then
    565   begin
     572    xDst := FLeft;
     573  end;
     574  if yDst < FTop then begin
    566575    Height := Height - (FTop - yDst);
    567576    ySrc := ySrc + (FTop - yDst);
    568     yDst := FTop
     577    yDst := FTop;
    569578  end;
    570579  if xDst + Width >= FRight then
     
    792801    if MyMap[dLoc(Loc, -1, 1)] and Mask = Cardinal(Value) then
    793802      inc(result, 4);
    794   end
     803  end;
    795804end;
    796805
     
    806815      (MyMap[ConnLoc] and Mask <> 0) then
    807816      inc(result, 1 shl Dir);
    808   end
     817  end;
    809818end;
    810819
     
    820829      ((MyMap[ConnLoc] - 2) and fTerrain < 13) then
    821830      inc(result, 1 shl Dir);
    822   end
     831  end;
    823832end;
    824833
     
    925934        if Conn and (1 shl Dir) <> 0 then { canal mouths }
    926935          TSprite(x, y, spCanalMouths + 1 + Dir);
    927     end
     936    end;
    928937  end;
    929938
     
    10681077                BitBltBitmap(Borders, x + dx * xxt, y + dy * yyt, xxt, yyt, dx * xxt,
    10691078                  p1 * (yyt * 2) + dy * yyt, SRCPAINT);
    1070               end
     1079              end;
    10711080            end;
    10721081          end
    1073       end
     1082      end;
    10741083    end;
    10751084  end;
     
    10941103    NameCity;
    10951104    ShowSpacePort;
    1096     exit
     1105    exit;
    10971106  end; { square not discovered }
    10981107
     
    13031312      moveto(x0, y + dy0 * yyt);
    13041313      lineto(x1, y + (dy0 + n) * yyt);
    1305     end
     1314    end;
    13061315  end;
    13071316
     
    14071416    lineto(xm + xxt * 4, ym - yyt * 1);
    14081417    pen.Width := 1;
    1409   end
     1418  end;
    14101419end;
    14111420
     
    15661575              BitBltBitmap(LandPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
    15671576                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
    1568           end
     1577          end;
    15691578      end;
    15701579
Note: See TracChangeset for help on using the changeset viewer.