here's an Adler32-crc-generator. I hope I got it right.
Code: Select all
#Mod_Adler = 65521
Procedure.l Adler32(*Buffer,BufferSize)
Protected a.l=1,b.l,c.i,d.i=*Buffer+BufferSize-1
For c=*Buffer To d
a=(a+PeekA(c)) % #Mod_Adler
b=(b+a) % #Mod_Adler
Next
ProcedureReturn (b << 16) | a
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
Define *Test=AllocateMemory(1024),t
For t=0 To MemorySize(*Test)-1
PokeA(*Test+t,Random(255,0))
Next
Debug Hex(Adler32(*Test,MemorySize(*Test)) & $FFFFFFFF)
CompilerEndIf
However, that's the easiest implementation. There's obviously a better one, but I have to admit that I didn't understand the concept how it works (and this one should be the fast one). Maybe someone wants to add this:
https://en.wikipedia.org/wiki/Adler-32