- Fixed game loading
authorunc0rr
Fri, 20 Jan 2006 19:02:50 +0000
changeset 54 839fd258ae6f
parent 53 0e27949850e3
child 55 e09f7c952a40
- Fixed game loading - New unit for graphic functions
hedgewars/hwengine.dpr
hedgewars/uCollisions.pas
hedgewars/uGears.pas
hedgewars/uLand.pas
hedgewars/uLandGraphics.pas
hedgewars/uLandObjects.pas
hedgewars/uStore.pas
--- a/hedgewars/hwengine.dpr	Thu Jan 19 21:12:20 2006 +0000
+++ b/hedgewars/hwengine.dpr	Fri Jan 20 19:02:50 2006 +0000
@@ -54,7 +54,8 @@
   uCollisions in 'uCollisions.pas',
   uLand in 'uLand.pas',
   uLandTemplates in 'uLandTemplates.pas',
-  uLandObjects in 'uLandObjects.pas';
+  uLandObjects in 'uLandObjects.pas',
+  uLandGraphics in 'uLandGraphics.pas';
 
 {$INCLUDE options.inc}
 
--- a/hedgewars/uCollisions.pas	Thu Jan 19 21:12:20 2006 +0000
+++ b/hedgewars/uCollisions.pas	Fri Jan 20 19:02:50 2006 +0000
@@ -46,7 +46,6 @@
                   Count: Longword
                   end;
 
-procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword);
 procedure AddGearCI(Gear: PGear);
 procedure DeleteCI(Gear: PGear);
 function CheckGearsCollision(Gear: PGear): PGearArray;
@@ -57,7 +56,7 @@
 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
 
 implementation
-uses uMisc, uConsts, uLand;
+uses uMisc, uConsts, uLand, uGraphics;
 
 type TCollisionEntry = record
                        X, Y, Radius: integer;
@@ -69,17 +68,9 @@
     cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
     ga: TGearArray;
 
-procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword);
-var ty, tx: integer;
-begin
-for ty:= max(-Radius, -y) to min(radius, 1023 - y) do
-    for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047,round(x+radius*sqrt(1-sqr(ty/radius)))) do
-        Land[ty + y, tx]:= Value;
-end;
-
 procedure AddGearCI(Gear: PGear);
 begin
-if Gear.CollIndex < High(Longword) then exit; 
+if Gear.CollIndex < High(Longword) then exit;
 TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
 with cinfos[Count] do
      begin
--- a/hedgewars/uGears.pas	Thu Jan 19 21:12:20 2006 +0000
+++ b/hedgewars/uGears.pas	Fri Jan 20 19:02:50 2006 +0000
@@ -75,7 +75,7 @@
 var CurAmmoGear: PGear = nil;
 
 implementation
-uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, uLand, uIO;
+uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, uLand, uIO, uGraphics;
 var GearsList: PGear = nil;
     RopePoints: record
                 Count: Longword;
--- a/hedgewars/uLand.pas	Thu Jan 19 21:12:20 2006 +0000
+++ b/hedgewars/uLand.pas	Fri Jan 20 19:02:50 2006 +0000
@@ -268,7 +268,7 @@
 var tmpsurf: PSDL_Surface;
     r: TSDL_Rect;
 begin
-tmpsurf:= LoadImage(Pathz[ptThemeCurrent] + 'LandTex.png', false);
+tmpsurf:= LoadImage(Pathz[ptThemeCurrent] + '/LandTex.png', false);
 r.y:= 0;
 while r.y < 1024 do
       begin
@@ -294,7 +294,7 @@
     r, rr: TSDL_Rect;
     x, yd, yu: integer;
 begin
-tmpsurf:= LoadImage(Pathz[ptThemeCurrent] + 'Border.png', false);
+tmpsurf:= LoadImage(Pathz[ptThemeCurrent] + '/Border.png', false);
 for x:= 0 to 2047 do
     begin
     yd:= 1023;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uLandGraphics.pas	Fri Jan 20 19:02:50 2006 +0000
@@ -0,0 +1,237 @@
+unit uLandGraphics;
+interface
+
+type PRangeArray = ^TRangeArray;
+     TRangeArray = array[0..31] of record
+                                   Left, Right: integer;
+                                   end;
+
+procedure DrawExplosion(X, Y, Radius: integer);
+procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
+procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
+procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword);
+
+implementation
+uses SDLh, uStore, uMisc, uLand;
+
+procedure FillCircleLines(x, y, dx, dy: integer; Value: Longword);
+var i: integer;
+begin
+if ((y + dy) and $FFFFFC00) = 0 then
+   for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y + dy, i]:= Value;
+if ((y - dy) and $FFFFFC00) = 0 then
+   for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y - dy, i]:= Value;
+if ((y + dx) and $FFFFFC00) = 0 then
+   for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y + dx, i]:= Value;
+if ((y - dx) and $FFFFFC00) = 0 then
+   for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y - dx, i]:= Value;
+end;
+
+procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword);
+var dx, dy, d: integer;
+begin
+  dx:= 0;
+  dy:= Radius;
+  d:= 3 - 2 * Radius;
+  while (dx < dy) do
+     begin
+     FillCircleLines(x, y, dx, dy, Value);
+     if (d < 0)
+     then d:= d + 4 * dx + 6
+     else begin
+          d:= d + 4 * (dx - dy) + 10;
+          dec(dy)
+          end;
+     inc(dx)
+     end;
+  if (dx = dy) then FillCircleLines(x, y, dx, dy, Value);
+end;
+
+procedure DrawExplosion(X, Y, Radius: integer);
+var ty, tx, p: integer;
+begin
+FillRoundInLand(X, Y, Radius, 0);
+
+if SDL_MustLock(LandSurface) then
+   SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
+
+p:= integer(LandSurface.pixels);
+case LandSurface.format.BytesPerPixel of
+     1: ;// not supported
+     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
+                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
+     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
+                begin
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
+                end;
+     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
+                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
+     end;
+
+inc(Radius, 4);
+
+case LandSurface.format.BytesPerPixel of
+     1: ;// not supported
+     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
+               if Land[y + ty, tx] = $FFFFFF then
+                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
+     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
+               if Land[y + ty, tx] = $FFFFFF then
+                begin
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
+                end;
+     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
+               if Land[y + ty, tx] = $FFFFFF then
+                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
+     end;
+
+if SDL_MustLock(LandSurface) then
+   SDL_UnlockSurface(LandSurface);
+
+SDL_UpdateRect(LandSurface, X - Radius, Y - Radius, Radius * 2, Radius * 2)
+end;
+
+procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
+var tx, ty, i, p: integer;
+begin
+if SDL_MustLock(LandSurface) then
+   SDL_LockSurface(LandSurface);
+
+p:= integer(LandSurface.pixels);
+for i:= 0 to Pred(Count) do
+    begin
+    case LandSurface.format.BytesPerPixel of
+     1: ;
+     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
+                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
+     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
+                begin
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
+                end;
+     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
+                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
+     end;
+    inc(y, dY)
+    end;
+
+inc(Radius, 4);
+dec(y, Count*dY);
+
+for i:= 0 to Pred(Count) do
+    begin
+    case LandSurface.format.BytesPerPixel of
+     1: ;
+     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
+               if Land[y + ty, tx] = $FFFFFF then
+                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
+     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
+               if Land[y + ty, tx] = $FFFFFF then
+                begin
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
+                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
+                end;
+     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
+            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
+               if Land[y + ty, tx] = $FFFFFF then
+                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
+     end;
+    inc(y, dY)
+    end;
+
+if SDL_MustLock(LandSurface) then
+   SDL_UnlockSurface(LandSurface);
+end;
+
+//
+//  - (dX, dY) - direction, vector of length = 0.5
+//
+procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
+var nx, ny: real;
+    i, t, tx, ty, p: integer;
+begin  // (-dY, dX) is (dX, dY) turned by PI/2
+if SDL_MustLock(LandSurface) then
+   SDL_LockSurface(LandSurface);
+
+nx:= X + dY * (HalfWidth + 8);
+ny:= Y - dX * (HalfWidth + 8);
+p:= integer(LandSurface.pixels);
+
+for i:= 0 to 7 do
+    begin
+    X:= nx - 8 * dX;
+    Y:= ny - 8 * dY;
+    for t:= -8 to ticks + 8 do
+        {$include tunsetborder.inc}
+    nx:= nx - dY;
+    ny:= ny + dX;
+    end;
+
+for i:= -HalfWidth to HalfWidth do
+    begin
+    X:= nx - dX * 8;
+    Y:= ny - dY * 8;
+    for t:= 0 to 7 do
+        {$include tunsetborder.inc}
+    X:= nx;
+    Y:= ny;
+    for t:= 0 to ticks do
+        begin
+        X:= X + dX;
+        Y:= Y + dY;
+        tx:= round(X);
+        ty:= round(Y);
+        if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then
+           begin
+           Land[ty, tx]:= 0;
+           case LandSurface.format.BytesPerPixel of
+                1: ;
+                2: PWord(p + LandSurface.pitch * ty + tx * 2)^:= 0;
+                3: begin
+                   PByte(p + LandSurface.pitch * ty + tx * 3 + 0)^:= 0;
+                   PByte(p + LandSurface.pitch * ty + tx * 3 + 1)^:= 0;
+                   PByte(p + LandSurface.pitch * ty + tx * 3 + 2)^:= 0;
+                   end;
+                4: PLongword(p + LandSurface.pitch * ty + tx * 4)^:= 0;
+                end
+           end
+        end;
+    for t:= 0 to 7 do
+        {$include tunsetborder.inc}
+    nx:= nx - dY;
+    ny:= ny + dX;
+    end;
+
+for i:= 0 to 7 do
+    begin
+    X:= nx - 8 * dX;
+    Y:= ny - 8 * dY;
+    for t:= -8 to ticks + 8 do
+        {$include tunsetborder.inc}
+    nx:= nx - dY;
+    ny:= ny + dX;
+    end;
+
+if SDL_MustLock(LandSurface) then
+   SDL_UnlockSurface(LandSurface)
+end;
+
+
+end.
--- a/hedgewars/uLandObjects.pas	Thu Jan 19 21:12:20 2006 +0000
+++ b/hedgewars/uLandObjects.pas	Fri Jan 20 19:02:50 2006 +0000
@@ -185,7 +185,7 @@
 if x1 > 0 then
    begin
    Result:= true;
-   tmpsurf:= LoadImage(Pathz[ptGraphics] + 'Girder.png', false);
+   tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder.png', false);
    rr.x:= x1;
    rr.y:= y;
    while rr.x + 100 < x2 do
@@ -292,7 +292,7 @@
     i, ii, t, n: Longword;
     b: boolean;
 begin
-s:= Pathz[ptThemeCurrent] + cThemeCFGFilename;
+s:= Pathz[ptThemeCurrent] + '/' + cThemeCFGFilename;
 WriteLnToConsole('Adding objects...');
 AssignFile(f, s);
 {$I-}
@@ -304,7 +304,7 @@
     Readln(f, s); // filename
     with ThemeObjects[i] do
          begin
-         Surf:= LoadImage(Pathz[ptThemeCurrent] + s + '.png', false);
+         Surf:= LoadImage(Pathz[ptThemeCurrent] + '/' + s + '.png', false);
          Read(f, Width, Height);
          with inland do Read(f, x, y, w, h);
          Read(f, rectcnt);
@@ -315,7 +315,7 @@
     end;
 Closefile(f);
 {$I+}
-TryDo(IOResult = 0, 'Bad data or cannot access file', true);
+TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
 
 // loaded objects, try to put on land
 if n = 0 then exit;
--- a/hedgewars/uStore.pas	Thu Jan 19 21:12:20 2006 +0000
+++ b/hedgewars/uStore.pas	Fri Jan 20 19:02:50 2006 +0000
@@ -36,11 +36,6 @@
 uses uConsts, uTeams, SDLh;
 {$INCLUDE options.inc}
 
-type PRangeArray = ^TRangeArray;
-     TRangeArray = array[0..31] of record
-                                   Left, Right: integer;
-                                   end;
-
 procedure StoreInit;
 procedure StoreLoad;
 procedure StoreRelease;
@@ -53,9 +48,6 @@
 procedure DrawCaption(X, Y: integer; Rect: TSDL_Rect; Surface: PSDL_Surface; const fromTempSurf: boolean = false);
 procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface);
 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface);
-procedure DrawExplosion(X, Y, Radius: integer);
-procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
-procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
 procedure RenderHealth(var Hedgehog: THedgehog);
 function  RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
 procedure AddProgress;
@@ -71,192 +63,6 @@
      TempSurface,
        HHSurface: PSDL_Surface;
 
-procedure DrawExplosion(X, Y, Radius: integer);
-var ty, tx, p: integer;
-begin
-FillRoundInLand(X, Y, Radius, 0);
-
-if SDL_MustLock(LandSurface) then
-   SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
-
-p:= integer(LandSurface.pixels);
-case LandSurface.format.BytesPerPixel of
-     1: ;// not supported
-     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
-     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-                begin
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
-                end;
-     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
-     end;
-
-inc(Radius, 4);
-
-case LandSurface.format.BytesPerPixel of
-     1: ;// not supported
-     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
-     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                begin
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
-                end;
-     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
-     end;
-
-if SDL_MustLock(LandSurface) then
-   SDL_UnlockSurface(LandSurface);
-
-SDL_UpdateRect(LandSurface, X - Radius, Y - Radius, Radius * 2, Radius * 2)
-end;
-
-procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
-var tx, ty, i, p: integer;
-begin
-if SDL_MustLock(LandSurface) then
-   SDL_LockSurface(LandSurface);
-
-p:= integer(LandSurface.pixels);
-for i:= 0 to Pred(Count) do
-    begin
-    case LandSurface.format.BytesPerPixel of
-     1: ;
-     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
-                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
-     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
-                begin
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
-                end;
-     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
-                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
-     end;
-    inc(y, dY)
-    end;
-
-inc(Radius, 4);
-dec(y, Count*dY);
-
-for i:= 0 to Pred(Count) do
-    begin
-    case LandSurface.format.BytesPerPixel of
-     1: ;
-     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
-     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                begin
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
-                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
-                end;
-     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
-            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
-               if Land[y + ty, tx] = $FFFFFF then
-                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
-     end;
-    inc(y, dY)
-    end;
-
-if SDL_MustLock(LandSurface) then
-   SDL_UnlockSurface(LandSurface);
-end;
-
-//
-//  - (dX, dY) - direction, vector of length = 0.5
-//
-procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
-var nx, ny: real;
-    i, t, tx, ty, p: integer;
-begin  // (-dY, dX) is (dX, dY) turned by PI/2
-if SDL_MustLock(LandSurface) then
-   SDL_LockSurface(LandSurface);
-
-nx:= X + dY * (HalfWidth + 8);
-ny:= Y - dX * (HalfWidth + 8);
-p:= integer(LandSurface.pixels);
-
-for i:= 0 to 7 do
-    begin
-    X:= nx - 8 * dX;
-    Y:= ny - 8 * dY;
-    for t:= -8 to ticks + 8 do
-        {$include tunsetborder.inc}
-    nx:= nx - dY;
-    ny:= ny + dX;
-    end;
-
-for i:= -HalfWidth to HalfWidth do
-    begin
-    X:= nx - dX * 8;
-    Y:= ny - dY * 8;
-    for t:= 0 to 7 do
-        {$include tunsetborder.inc}
-    X:= nx;
-    Y:= ny;
-    for t:= 0 to ticks do
-        begin
-        X:= X + dX;
-        Y:= Y + dY;
-        tx:= round(X);
-        ty:= round(Y);
-        if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then
-           begin
-           Land[ty, tx]:= 0;
-           case LandSurface.format.BytesPerPixel of
-                1: ;
-                2: PWord(p + LandSurface.pitch * ty + tx * 2)^:= 0;
-                3: begin
-                   PByte(p + LandSurface.pitch * ty + tx * 3 + 0)^:= 0;
-                   PByte(p + LandSurface.pitch * ty + tx * 3 + 1)^:= 0;
-                   PByte(p + LandSurface.pitch * ty + tx * 3 + 2)^:= 0;
-                   end;
-                4: PLongword(p + LandSurface.pitch * ty + tx * 4)^:= 0;
-                end
-           end
-        end;
-    for t:= 0 to 7 do
-        {$include tunsetborder.inc}
-    nx:= nx - dY;
-    ny:= ny + dX;
-    end;
-
-for i:= 0 to 7 do
-    begin
-    X:= nx - 8 * dX;
-    Y:= ny - 8 * dY;
-    for t:= -8 to ticks + 8 do
-        {$include tunsetborder.inc}
-    nx:= nx - dY;
-    ny:= ny + dX;
-    end;
-
-if SDL_MustLock(LandSurface) then
-   SDL_UnlockSurface(LandSurface)
-end;
-
 procedure StoreInit;
 begin
 StoreSurface  := SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0);