Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
authornemo
Tue, 29 Jun 2010 23:30:49 -0400
changeset 3593 ae50f63e4fa9
parent 3592 0bcad5c38c9e
child 3594 aeca3d8f1b29
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
hedgewars/GSHandlers.inc
hedgewars/VGSHandlers.inc
hedgewars/uMisc.pas
hedgewars/uVisualGears.pas
--- a/hedgewars/GSHandlers.inc	Wed Jun 30 03:26:15 2010 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Jun 29 23:30:49 2010 -0400
@@ -148,8 +148,8 @@
                 particle := AddVisualGear(hwRound(Gear^.X) - 3 + Random(6), cWaterLine, vgtDroplet);
                 if particle <> nil then
                 begin
-                    particle^.dX := particle^.dX - (Gear^.dX / 10);
-                    particle^.dY := particle^.dY - (Gear^.dY / 5)
+                    particle^.dX := particle^.dX - (Gear^.dX.QWordValue / 42949672960);
+                    particle^.dY := particle^.dY - (Gear^.dY.QWordValue / 21474836480)
                 end
             end
         end;
@@ -181,7 +181,7 @@
         begin
             particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,
                         vgtDust);
-            if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX / 5);
+            if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480);
         end;
 
         if (Gear^.Invulnerable) then exit;
@@ -636,8 +636,8 @@
             shell := AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell);
             if shell <> nil then
             begin
-                shell^.dX := gear^.dX / -4;
-                shell^.dY := gear^.dY / -4;
+                shell^.dX := gear^.dX.QWordValue / -17179869184;
+                shell^.dY := gear^.dY.QWordValue / -17179869184;
                 shell^.Frame := 0
             end;
             Gear^.State := Gear^.State or gstAnimation
@@ -756,8 +756,8 @@
         shell := AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell);
         if shell <> nil then
         begin
-            shell^.dX := gear^.dX / -2;
-            shell^.dY := gear^.dY / -2;
+            shell^.dX := gear^.dX.QWordValue / -8589934592;
+            shell^.dY := gear^.dY.QWordValue / -8589934592;
             shell^.Frame := 1
         end;
         Gear^.State := Gear^.State or gstAnimation;
@@ -1481,7 +1481,7 @@
             begin
                 particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,
                             vgtDust);
-                if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX / 5)
+                if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480)
             end
         end
         else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1)
@@ -3185,7 +3185,7 @@
         begin
             vg := AddVisualGear(hwRound(Gear^.X) - 3 + Random(6), hwRound(Gear^.Y) - 3 + Random(6),
                   vgtDust);
-            if vg <> nil then vg^.dX := vg^.dX + (Gear^.dX / 5);
+            if vg <> nil then vg^.dX := vg^.dX + (Gear^.dX.QWordValue / 21474836480);
         end;
 
         DeleteGear(Gear);
--- a/hedgewars/VGSHandlers.inc	Wed Jun 30 03:26:15 2010 +0200
+++ b/hedgewars/VGSHandlers.inc	Tue Jun 29 23:30:49 2010 -0400
@@ -16,9 +16,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
-var sign: hwFloat;
+var sign: float;
 begin
-sign:= _1;
+sign:= 1;
 with Gear^ do
     begin
     inc(FrameTicks, Steps);
@@ -28,32 +28,34 @@
         inc(Frame);
         if Frame = vobFramesCount then Frame:= 0
         end;
-    X:= X + (cWindSpeed * 200 + dX + tdX) * Steps;
-    Y:= Y + (dY + tdY + cGravity * vobFallSpeed) * Steps;
+    X:= X + (cWindSpeedf * 200 + dX + tdX) * Steps;
+    Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps;
     Angle:= Angle + dAngle * Steps;
   
-    if (hwRound(X) >= -cScreenWidth - 64) and
-       (hwRound(X) <= cScreenWidth + LAND_WIDTH) and
-       (hwRound(Y) <= (LAND_HEIGHT + 75)) and 
+    if (round(X) >= -cScreenWidth - 64) and
+       (round(X) <= cScreenWidth + LAND_WIDTH) and
+       (round(Y) <= (LAND_HEIGHT + 75)) and 
        (Timer > 0) and (Timer-Steps > 0) then
         begin
-        sign.isNegative:=tdX.isNegative;
-        tdX:= tdX - _0_005*Steps*sign;
-        if (sign.isNegative and (tdX > _0)) or (not sign.isNegative and (tdX < _0)) then tdX:= _0;
-        sign.isNegative:=tdY.isNegative;
-        tdY:= tdY - _0_005*Steps*sign;
-        if (sign.isNegative and (tdY > _0)) or (not sign.isNegative and (tdY < _0)) then tdY:= _0;
+        if tdX > 0 then sign := 1
+        else sign:= -1;
+        tdX:= tdX - 0.005*Steps*sign;
+        if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then tdX:= 0;
+        if tdX > 0 then sign := 1
+        else sign:= -1;
+        tdY:= tdY - 0.005*Steps*sign;
+        if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0;
         dec(Timer, Steps)
         end
     else
         begin
-        if hwRound(X) < -cScreenWidth - 64 then X:= int2hwFloat(cScreenWidth + LAND_WIDTH) else
-        if hwRound(X) > cScreenWidth + LAND_WIDTH then X:= int2hwFloat(-cScreenWidth - 64);
-        // if hwRound(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + int2hwFloat(25); // For if flag is set for flakes rising upwards?
-        if hwRound(Y) > (LAND_HEIGHT + 75) then Y:= Y - int2hwFloat(1024 + 150); // TODO - configure in theme (jellies for example could use limited range)
+        if round(X) < -cScreenWidth - 64 then X:= float(cScreenWidth + LAND_WIDTH) else
+        if round(X) > cScreenWidth + LAND_WIDTH then X:= float(-cScreenWidth - 64);
+        // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + float(25); // For if flag is set for flakes rising upwards?
+        if round(Y) > (LAND_HEIGHT + 75) then Y:= Y - float(1024 + 150); // TODO - configure in theme (jellies for example could use limited range)
         Timer:= 0;
-        tdX:= _0;
-        tdY:= _0
+        tdX:= 0;
+        tdY:= 0
         end;
     end;
 
@@ -71,21 +73,19 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepCloud(Gear: PVisualGear; Steps: Longword);
 var s: Longword;
-    t: hwFloat;
+    t: float;
 begin
-Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps;
+Gear^.X:= Gear^.X + (cWindSpeedf * 200 + Gear^.dX) * Steps;
 
 // up-and-down-bounce magic
-s := (GameTicks + Gear^.mdy) mod 4096;
-t := AngleSin(s mod 2048);
-t.isNegative := (s < 2048);
-t.QWordValue := t.QWordValue * 8;
+s := (GameTicks + Gear^.Timer) mod 4096;
+t := 8 * AngleSin(s mod 2048).QWordValue / 4294967296;
+if (s < 2048) then t *= -1;
 
-Gear^.Y := int2hwFloat(LAND_HEIGHT-1184 + Gear^.mdy mod 8) + t;
-
+Gear^.Y := LAND_HEIGHT-1184 + Gear^.Timer mod 8 + t;
 
-if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + LAND_WIDTH) else
-if hwRound(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= int2hwFloat(-cScreenWidth - 256)
+if round(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= float(cScreenWidth + LAND_WIDTH) else
+if round(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= float(-cScreenWidth - 256)
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -94,7 +94,7 @@
 Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
-//Gear^.dY:= Gear^.dY + cGravity;
+//Gear^.dY:= Gear^.dY + cGravityf;
 
 if Gear^.FrameTicks <= Steps then
     if Gear^.Frame = 0 then DeleteVisualGear(Gear)
@@ -112,7 +112,7 @@
 Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
-Gear^.dY:= Gear^.dY + cGravity * Steps;
+Gear^.dY:= Gear^.dY + cGravityf * Steps;
 
 Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle;
 
@@ -127,8 +127,8 @@
 begin
 Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
-Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravity * (Steps * Steps);
-Gear^.dY:= Gear^.dY + cGravity * Steps;
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * Steps);
+Gear^.dY:= Gear^.dY + cGravityf * Steps;
 
 if Gear^.FrameTicks <= Steps then
        DeleteVisualGear(Gear)
@@ -142,7 +142,7 @@
 Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
-Gear^.dY:= Gear^.dY + cGravity * Steps;
+Gear^.dY:= Gear^.dY + cGravityf * Steps;
 
 Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle;
 
@@ -154,7 +154,7 @@
 
 procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
 begin
-Gear^.Y:= Gear^.Y - _0_02 * Steps;
+Gear^.Y:= Gear^.Y - 0.02 * Steps;
 
 if Gear^.FrameTicks <= Steps then
     DeleteVisualGear(Gear)
@@ -165,10 +165,10 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepBubble(Gear: PVisualGear; Steps: Longword);
 begin
-    Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps;
-    Gear^.Y:= Gear^.Y - cDrownSpeed * Steps;
+    Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps;
+    Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
 
-    if (Gear^.FrameTicks <= Steps) or (hwRound(Gear^.Y) < cWaterLine) then
+    if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then
         DeleteVisualGear(Gear)
     else
         dec(Gear^.FrameTicks, Steps)
@@ -189,8 +189,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepSteam(Gear: PVisualGear; Steps: Longword);
 begin
-    Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps;
-    Gear^.Y:= Gear^.Y - cDrownSpeed * Steps;
+    Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps;
+    Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
 
     if Gear^.FrameTicks <= Steps then
         if Gear^.Frame = 0 then DeleteVisualGear(Gear)
@@ -205,7 +205,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepAmmo(Gear: PVisualGear; Steps: Longword);
 begin
-    Gear^.Y:= Gear^.Y - cDrownSpeed * Steps;
+    Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps;
 
     Gear^.scale:= Gear^.scale + 0.0025 * Steps;
     Gear^.alpha:= Gear^.alpha - 0.0015 * Steps;
@@ -216,11 +216,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepSmoke(Gear: PVisualGear; Steps: Longword);
 begin
-    Gear^.X:= Gear^.X + (cWindSpeed + Gear^.dX) * Steps;
-    Gear^.Y:= Gear^.Y - (cDrownSpeed + Gear^.dY) * Steps;
+    Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps;
+    Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps;
 
-    Gear^.dX := Gear^.dX + (cWindSpeed * _0_3 * Steps);
-    //Gear^.dY := Gear^.dY - (cDrownSpeed * _0_995);
+    Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps);
+    //Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995);
 
     if Gear^.FrameTicks <= Steps then
         if Gear^.Frame = 0 then DeleteVisualGear(Gear)
@@ -235,11 +235,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepDust(Gear: PVisualGear; Steps: Longword);
 begin
-    Gear^.X:= Gear^.X + (cWindSpeed + (cWindSpeed * _0_03 * Steps) + Gear^.dX) * Steps;
+    Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps;
     Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps;
 
-    Gear^.dX := Gear^.dX - (Gear^.dX * _0_005 * Steps);
-    Gear^.dY := Gear^.dY - (cDrownSpeed * _0_001 * Steps);
+    Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps);
+    Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps);
 
     if Gear^.FrameTicks <= Steps then
         if Gear^.Frame = 0 then DeleteVisualGear(Gear)
@@ -266,9 +266,9 @@
   Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
   Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
-  Gear^.dY:= Gear^.dY + cGravity * Steps;
+  Gear^.dY:= Gear^.dY + cGravityf * Steps;
 
-  if hwRound(Gear^.Y) > cWaterLine then begin
+  if round(Gear^.Y) > cWaterLine then begin
     DeleteVisualGear(Gear);
     PlaySound(TSound(ord(sndDroplet1) + Random(3)));
     end;
@@ -293,7 +293,7 @@
 Gear^.X:= Gear^.X + Gear^.dX * Steps;
 
 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
-Gear^.dY:= Gear^.dY + cGravity * Steps;
+Gear^.dY:= Gear^.dY + cGravityf * Steps;
 
 Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle;
 
@@ -390,8 +390,8 @@
 
 if (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then
     begin
-    Gear^.X:= PHedgehog(Gear^.Hedgehog)^.Gear^.X + int2hwFloat(Gear^.Tex^.w div 2  - Gear^.FrameTicks);
-    Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y - int2hwFloat(16 + Gear^.Tex^.h);
+    Gear^.X:= PHedgehog(Gear^.Hedgehog)^.Gear^.X.QWordValue/4294967296 + (Gear^.Tex^.w div 2  - Gear^.FrameTicks);
+    Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y.QWordValue/4294967296 - (16 + Gear^.Tex^.h);
     end;
 
 if Gear^.Timer = 0 then
@@ -423,7 +423,7 @@
 
 Gear^.doStep:= @doStepSpeechBubbleWork;
 
-Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h)
+Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h)
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -440,10 +440,10 @@
 
 procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword);
 begin
-if hwRound(Gear^.Y) < cWaterLine + 10 then
+if round(Gear^.Y) < cWaterLine + 10 then
     DeleteVisualGear(Gear)
 else
-    Gear^.Y:= Gear^.Y - _0_08 * Steps;
+    Gear^.Y:= Gear^.Y - 0.08 * Steps;
 
 end;
 
@@ -452,7 +452,7 @@
 begin
 s:= '';
 
-Gear^.dY:= -_0_08;
+Gear^.dY:= -0.08;
 
 str(Gear^.State, s);
 if Gear^.Hedgehog <> nil then
@@ -460,12 +460,12 @@
 else
     Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16);
 
-if hwRound(Gear^.Y) < cWaterLine then
+if round(Gear^.Y) < cWaterLine then
     Gear^.doStep:= @doStepHealthTagWork
 else
     Gear^.doStep:= @doStepHealthTagWorkUnderWater;
 
-Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h);
+Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h);
 
 if Steps > 1 then Gear^.doStep(Gear, Steps-1);
 end;
@@ -479,7 +479,7 @@
     dec(Gear^.State, Gear^.Timer div 65);
     Gear^.Timer:= Gear^.Timer mod 65;
     end;
-Gear^.dX:= Gear^.dX + cWindSpeed * Steps;
+Gear^.dX:= Gear^.dX + cWindSpeedf * Steps;
 Gear^.X:= Gear^.X + Gear^.dX;
 if Gear^.State = 0 then DeleteVisualGear(Gear);
 end;
@@ -500,8 +500,8 @@
 var i: LongWord;
 gX,gY: LongInt;
 begin
-gX:= hwRound(Gear^.X);
-gY:= hwRound(Gear^.Y);
+gX:= round(Gear^.X);
+gY:= round(Gear^.Y);
 for i:= 0 to 31 do AddVisualGear(gX, gY, vgtFire);
 for i:= 0 to  8 do AddVisualGear(gX, gY, vgtExplPart);
 for i:= 0 to  8 do AddVisualGear(gX, gY, vgtExplPart2);
@@ -532,8 +532,8 @@
 var i: LongWord;
 gX,gY: LongInt;
 begin
-gX:= hwRound(Gear^.X);
-gY:= hwRound(Gear^.Y);
+gX:= round(Gear^.X);
+gY:= round(Gear^.Y);
 AddVisualGear(gX, gY, vgtSmokeRing);
 for i:= 0 to 46 do AddVisualGear(gX, gY, vgtFire);
 for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart);
--- a/hedgewars/uMisc.pas	Wed Jun 30 03:26:15 2010 +0200
+++ b/hedgewars/uMisc.pas	Tue Jun 29 23:30:49 2010 -0400
@@ -21,7 +21,7 @@
 unit uMisc;
 interface
 
-uses    SDLh, uConsts, uFloat, GLunit;
+uses    SDLh, uConsts, uFloat, GLunit, Math;
 
 var
     isCursorVisible : boolean;
@@ -101,9 +101,12 @@
     CursorMovementX : LongInt;
     CursorMovementY : LongInt;
     cDrownSpeed : hwFloat;
+    cDrownSpeedf : float;
     cMaxWindSpeed   : hwFloat;
     cWindSpeed  : hwFloat;
+    cWindSpeedf  : float;
     cGravity    : hwFloat;
+    cGravityf    : float;
     cDamageModifier : hwFloat;
     cLaserSighting  : boolean;
     cVampiric   : boolean;
@@ -170,7 +173,7 @@
 {$ENDIF}
 
 implementation
-uses Math, uConsole, uStore, uIO, uSound, typinfo, sysutils;
+uses uConsole, uStore, uIO, uSound, typinfo, sysutils;
 
 var KBnum: Longword;
 {$IFDEF DEBUGFILE}
@@ -677,9 +680,12 @@
 {$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF}
 begin
     cDrownSpeed.QWordValue  := 257698038;       // 0.06
+    cDrownSpeedf            := 0.06;
     cMaxWindSpeed.QWordValue:= 1073742;     // 0.00025
     cWindSpeed.QWordValue   := 429496;      // 0.0001
+    cWindSpeedf             := 0.0001;
     cGravity                := cMaxWindSpeed * 2;
+    cGravityf               := 0.00025 * 2;
     cDamageModifier         := _1;
     TargetPoint             := cTargetPointRef;
     TextureList             := nil;
--- a/hedgewars/uVisualGears.pas	Wed Jun 30 03:26:15 2010 +0200
+++ b/hedgewars/uVisualGears.pas	Tue Jun 29 23:30:49 2010 -0400
@@ -28,13 +28,12 @@
         NextGear, PrevGear: PVisualGear;
         Frame,
         FrameTicks: Longword;
-        X : hwFloat;
-        Y : hwFloat;
-        dX: hwFloat;
-        dY: hwFloat;
-        tdX: hwFloat;
-        tdY: hwFloat;
-        mdY: QWord;
+        X : float;
+        Y : float;
+        dX: float;
+        dY: float;
+        tdX: float;
+        tdY: float;
         State : Longword;
         Timer: Longword;
         Angle, dAngle: real;
@@ -123,7 +122,7 @@
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0): PVisualGear;
 var gear: PVisualGear;
     t: Longword;
-    sp: hwFloat;
+    sp: float;
 begin
 if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we are scrolling now
     if Kind <> vgtCloud then
@@ -148,8 +147,8 @@
 
 New(gear);
 FillChar(gear^, sizeof(TVisualGear), 0);
-gear^.X:= int2hwFloat(X);
-gear^.Y:= int2hwFloat(Y);
+gear^.X:= float(X);
+gear^.Y:= float(Y);
 gear^.Kind := Kind;
 gear^.doStep:= doStepHandlers[Kind];
 gear^.State:= 0;
@@ -159,51 +158,50 @@
     case Kind of
     vgtFlake: begin
                 Timer:= 0;
-                tdX:= _0;
-                tdY:= _0;
+                tdX:= 0;
+                tdY:= 0;
                 FrameTicks:= random(vobFrameTicks);
                 Frame:= random(vobFramesCount);
                 Angle:= random * 360;
-                dx.isNegative:= random(2) = 0;
-                dx.QWordValue:= random(100000000);
-                dy.isNegative:= false;
-                dy.QWordValue:= random(70000000);
+                dx:= 0.0000038654705 * random(10000);
+                dy:= 0.000003506096 * random(7000);
+                if random(2) = 0 then dx*=-1;
                 dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000
                 end;
     vgtCloud: begin
                 Frame:= random(4);
-                dx.isNegative:= random(2) = 0;
-                dx.QWordValue:= random(214748364);
-                mdY:= random(4096);
+                dx:= 0.000005 * random(10000);
+                if random(2) = 0 then dx*=-1;
+                timer:= random(4096);
                 end;
     vgtExplPart,
     vgtExplPart2: begin
                 t:= random(1024);
-                sp:= _0_001 * (random(95) + 70);
-                dx:= AngleSin(t) * sp;
-                dx.isNegative:= random(2) = 0;
-                dy:= AngleCos(t) * sp;
-                dy.isNegative:= random(2) = 0;
+                sp:= 0.001 * (random(95) + 70);
+                dx:= AngleSin(t).QWordValue/4294967296 * sp;
+                dy:= AngleCos(t).QWordValue/4294967296 * sp;
+                if random(2) = 0 then dx*=-1;
+                if random(2) = 0 then dy*=-1;
                 Frame:= 7 - random(3);
                 FrameTicks:= cExplFrameTicks
                 end;
         vgtFire: begin
                 t:= random(1024);
-                sp:= _0_001 * (random(85) + 95);
-                dx:= AngleSin(t) * sp;
-                dx.isNegative:= random(2) = 0;
-                dy:= AngleCos(t) * sp;
-                dy.isNegative:= random(2) = 0;
+                sp:= 0.001 * (random(85) + 95);
+                dx:= AngleSin(t).QWordValue/4294967296 * sp;
+                dy:= AngleCos(t).QWordValue/4294967296 * sp;
+                if random(2) = 0 then dx*=-1;
+                if random(2) = 0 then dy*=-1;
                 FrameTicks:= 650 + random(250);
                 Frame:= random(8)
                 end;
          vgtEgg: begin
                 t:= random(1024);
-                sp:= _0_001 * (random(85) + 95);
-                dx:= AngleSin(t) * sp;
-                dx.isNegative:= random(2) = 0;
-                dy:= AngleCos(t) * sp;
-                dy.isNegative:= random(2) = 0;
+                sp:= 0.001 * (random(85) + 95);
+                dx:= AngleSin(t).QWordValue/4294967296 * sp;
+                dy:= AngleCos(t).QWordValue/4294967296 * sp;
+                if random(2) = 0 then dx*=-1;
+                if random(2) = 0 then dy*=-1;
                 FrameTicks:= 650 + random(250);
                 Frame:= 1
                 end;
@@ -212,18 +210,16 @@
                 gear^.FrameTicks:= 1100
                 end;
     vgtBubble: begin
-                dx.isNegative:= random(2) = 0;
-                dx.QWordValue:= random(100000000);
-                dy:= _0_001 * (random(85) + 95);
-                dy.isNegative:= false;
+                dx:= 0.0000038654705 * random(10000);
+                dy:= 0.001 * (random(85) + 95);
+                if random(2) = 0 then dx*=-1;
                 FrameTicks:= 250 + random(1751);
                 Frame:= random(5)
                 end;
     vgtSteam: begin
-                dx.isNegative:= random(2) = 0;
-                dx.QWordValue:= random(100000000);
-                dy:= _0_001 * (random(85) + 95);
-                dy.isNegative:= false;
+                dx:= 0.0000038654705 * random(10000);
+                dy:= 0.001 * (random(85) + 95);
+                if random(2) = 0 then dx*=-1;
                 Frame:= 7 - random(3);
                 FrameTicks:= cExplFrameTicks * 2;
                 end;
@@ -233,39 +229,36 @@
                 end;
   vgtSmokeWhite, 
   vgtSmoke: begin
-                dx:= _0_0002 * (random(45) + 10);
-                dx.isNegative:= random(2) = 0;
-                dy:= _0_0002 * (random(45) + 10);
-                dy.isNegative:= false;
+                dx:= 0.0002 * (random(45) + 10);
+                dy:= 0.0002 * (random(45) + 10);
+                if random(2) = 0 then dx*=-1;
                 Frame:= 7 - random(2);
                 FrameTicks:= cExplFrameTicks * 2;
                 end;
     vgtHealth: begin
-                dx:= _0_001 * random(45);
-                dx.isNegative:= random(2) = 0;
-                dy:= _0_001 * (random(20) + 25);
+                dx:= 0.001 * random(45);
+                dy:= 0.001 * (random(20) + 25);
+                if random(2) = 0 then dx*=-1;
                 Frame:= 0;
                 FrameTicks:= random(750) + 1250;
                 end;
   vgtDust: begin
-                dx:= _0_005 * (random(15) + 10);
-                dx.isNegative:= random(2) = 0;
-                dy:= _0_001 * (random(40) + 20);
+                dx:= 0.005 * (random(15) + 10);
+                dy:= 0.001 * (random(40) + 20);
+                if random(2) = 0 then dx*=-1;
                 Frame:= 7 - random(2);
                 FrameTicks:= random(20) + 15;
                 end;
   vgtSplash: begin
-                dx:= _0;
-                dx.isNegative:= false;
-                dy:= _0;
+                dx:= 0;
+                dy:= 0;
                 FrameTicks:= 740;
                 Frame:= 19;
                 end;
     vgtDroplet: begin
-                dx:= _0_001 * (random(75) + 15);
-                dx.isNegative:= random(2) = 0;
-                dy:= _0_001 * (random(80) + 120);
-                dy.isNegative:= true;
+                dx:= 0.001 * (random(75) + 15);
+                dy:= -0.001 * (random(80) + 120);
+                if random(2) = 0 then dx*=-1;
                 FrameTicks:= 250 + random(1751);
                 Frame:= random(3)
                 end;
@@ -274,10 +267,8 @@
                 Frame:= random(16);
                 end;
     vgtSmokeRing: begin
-                dx:= _0;
-                dx.isNegative:= false;
-                dy:= _0;
-                dy.isNegative:= false;
+                dx:= 0;
+                dy:= 0;
                 FrameTicks:= 600;
                 Timer:= 0;
                 Frame:= 0;
@@ -287,11 +278,11 @@
                 end;
      vgtFeather: begin
                 t:= random(1024);
-                sp:= _0_001 * (random(85) + 95);
-                dx:= AngleSin(t) * sp;
-                dx.isNegative:= random(2) = 0;
-                dy:= AngleCos(t) * sp;
-                dy.isNegative:= random(2) = 0;
+                sp:= 0.001 * (random(85) + 95);
+                dx:= AngleSin(t).QWordValue/4294967296 * sp;
+                dy:= AngleCos(t).QWordValue/4294967296 * sp;
+                if random(2) = 0 then dx*=-1;
+                if random(2) = 0 then dy*=-1;
                 FrameTicks:= 650 + random(250);
                 Frame:= 1
                 end;
@@ -301,8 +292,8 @@
                 end;
   vgtSmokeTrace,
   vgtEvilTrace: begin
-                gear^.X:= gear^.X - _16;
-                gear^.Y:= gear^.Y - _16;
+                gear^.X:= gear^.X - 16;
+                gear^.Y:= gear^.Y - 16;
                 gear^.State:= 8;
                 //gear^.Z:= cSmokeZ
                 end;
@@ -362,11 +353,13 @@
       if Gear^.Kind = vgtFlake then
           begin
           // Damage calc from doMakeExplosion
-          dmg:= min(100,Radius  + cHHRadius div 2 - (hwRound(hwAbs(Gear^.X - int2hwFloat(X))+hwAbs(Gear^.Y - int2hwFloat(Y))) div 5));
+          dmg:= min(101,Radius  + cHHRadius div 2 - (round(abs(Gear^.X - float(X))+abs(Gear^.Y - float(Y))) div 5));
           if dmg > 1 then
               begin
-              Gear^.tdX:= SignAs(_0_02 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
-              Gear^.tdY:= SignAs(_0_02 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
+              Gear^.tdX:= 0.02 * dmg + 0.01;
+              if Gear^.X - X < 0 then Gear^.tdX *= -1;
+              Gear^.tdY:= 0.02 * dmg + 0.01;
+              if Gear^.Y - Y < 0 then Gear^.tdY *= -1;
               Gear^.Timer:= 200
               end
           end;
@@ -384,10 +377,10 @@
         Tint(Gear^.Tint);
         case Gear^.Kind of
             vgtFlake: if vobVelocity = 0 then
-                        DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                        DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
                     else
-                        DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
-            vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
+                        DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
+            vgtCloud: DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
             end;
         Gear:= Gear^.NextGear
         end;
@@ -395,18 +388,18 @@
         begin
         Tint(Gear^.Tint);
         case Gear^.Kind of
-            vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
-            vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
+            vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
+            vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
         end;
             if not cReducedQuality then
                 case Gear^.Kind of
-                    vgtSmoke: DrawSprite(sprSmoke, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
-                    vgtSmokeWhite: DrawSprite(sprSmokeWhite, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
-                    vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                    vgtSmoke: DrawSprite(sprSmoke, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                    vgtSmokeWhite: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                    vgtDust: DrawSprite(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
                     vgtFeather: begin
                             if Gear^.FrameTicks < 255 then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
-                            DrawRotatedF(sprFeather, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+                            DrawRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                             end;
                  end;
         Gear:= Gear^.NextGear
@@ -415,59 +408,59 @@
         begin
         Tint(Gear^.Tint);
         case Gear^.Kind of
-            vgtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State);
+            vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
             vgtBigExplosion: begin
                              Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
-                             DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
+                             DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
                              end;
             end;
         if not cReducedQuality then
             case Gear^.Kind of
-                vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
-                vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
-                vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
-                vgtBubble: DrawSprite(sprBubbles, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
-                vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
+                vgtExplPart: DrawSprite(sprExplPart, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
+                vgtExplPart2: DrawSprite(sprExplPart2, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
+                vgtFire: DrawSprite(sprFlame, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
+                vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
+                vgtSteam: DrawSprite(sprExplPart, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
                 vgtAmmo: begin
                         Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
-                        DrawTextureF(ropeIconTex, Gear^.scale, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 32, 32);
-                        DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
+                        DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
+                        DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
                         end;
                 vgtHealth:  begin
                             case Gear^.Frame div 10 of
                                 0:Tint(0, $FF, 0, floor(Gear^.FrameTicks * $FF / 1000));
                                 1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
                             end;
-                            DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0);
+                            DrawSprite(sprHealth, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, 0);
                             end;
                 vgtShell: begin
                             if Gear^.FrameTicks < $FF then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
-                            DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+                            DrawRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                             end;
                   vgtEgg: begin
                             if Gear^.FrameTicks < $FF then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
-                            DrawRotatedF(sprEgg, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+                            DrawRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                             end;
-                vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 40, hwRound(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
-                vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
+                vgtSplash: DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
+                vgtDroplet: DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
                vgtBeeTrace: begin
                             if Gear^.FrameTicks < $FF then
                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
                             else
                                 Tint($FF, $FF, $FF, $80);
-                            DrawRotatedF(sprBeeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
+                            DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
                             end;
                 vgtSmokeRing: begin
                             Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
-                            DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
+                            DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
                             end;
             end;
         case Gear^.Kind of
-            vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
-            vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
-            vgtHealthTag: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
+            vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+            vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+            vgtHealthTag: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
         end;
         Gear:= Gear^.NextGear
         end