This forum contains all information about TDBAccess library for NHL 2004 roster access and general NHL coding questions.
5 posts • Page 1 of 1
Here is Pascal version. I just directly converted it from assembler so there is probably a way to make it more compact, I didn't bother.
When calling HashBuffer, Buffer is pointer to the section of TDB file you want to hash and InitHash is $FFFFFFFF.
Code: Select all
var HashTable: array[0..255] of LongWord; function HashBuffer(Buffer: PChar; BufSize: LongWord; InitHash: LongWord): LongWord; procedure CreateHashTable; var ax, si, cx: Longword; i: byte; begin cx := 0; for i := Low(HashTable) to High(HashTable) do begin ax := cx; ax := ax shl $18; for si := 0 to 7 do begin if (integer(ax) >= 0) then begin ax := ax shl 1; end else begin ax := ax + ax; ax := ax xor $4C11DB7; end; end; HashTable[i] := ax; Inc(cx); end; end; var ax, si: LongWord; di: byte; i: LongWord; begin if (integer(HashTable) >= 0) then begin CreateHashTable; ax := InitHash; end else ax := InitHash; for i := 0 to BufSize - 1 do begin di := Byte(Buffer[i]); si := ax; si := si shr $18; si := si xor di; si := HashTable[si]; ax := ax shl 8; ax := ax xor si; end; Result := ax; end;