Make adler32 friendlier for pas2c - this should work the same (needs testing ofc)
authornemo
Tue, 24 Apr 2012 16:58:19 -0400
changeset 6926 6e832f8f4d8e
parent 6925 1fbf9266ba52
child 6927 ee000959d645
Make adler32 friendlier for pas2c - this should work the same (needs testing ofc)
hedgewars/adler32.pas
hedgewars/pas2cSystem.pas
--- a/hedgewars/adler32.pas	Tue Apr 24 23:56:41 2012 +0400
+++ b/hedgewars/adler32.pas	Tue Apr 24 16:58:19 2012 -0400
@@ -63,6 +63,7 @@
 (*
 As per the license above, noting that this implementation of adler32 was stripped of everything we didn't need.
 That means no btypes, file loading, and the assembly version disabled.
+Also, the structure was removed to simplify C conversion
 *)
 
 procedure Adler32Update ( var adler     :longint; Msg     :pointer; Len     :longint );
@@ -128,16 +129,12 @@
     const
         BASE = 65521; {max. prime < 65536 }
         NMAX = 3854; {max. n with 255n(n+1)/2 + (n+1)(BASE-1) < 2^31}
-    type
-        LH = packed record
-            L, H: word;
-            end;
     var
         s1, s2: longint;
         i, n: integer;
     begin
-        s1 := LH(adler).L;
-        s2 := LH(adler).H;
+        s1 := adler and $FFFF;
+        s2 := adler shr 16;
         while Len>0 do
             begin
             if Len<NMAX then
@@ -155,8 +152,7 @@
             s2 := s2 mod BASE;
             dec(len, n);
             end;
-        LH(adler).L := word(s1);
-        LH(adler).H := word(s2);
+        adler:= (s2 shl 16) or s1;
     end;
 
 end.
--- a/hedgewars/pas2cSystem.pas	Tue Apr 24 23:56:41 2012 +0400
+++ b/hedgewars/pas2cSystem.pas	Tue Apr 24 16:58:19 2012 -0400
@@ -36,6 +36,7 @@
 
     char = char;
     PChar = ^char;
+    PPChar = ^Pchar;
     
     PByte = ^Byte;
     PLongInt = ^LongInt;