So I'm still working on the 4 byte Hex to float. I am trying to figure out if the format used is little endian byte order - AABBCCDD = DDCCBBAA .
Since the location of the toon is stored as a float, I need to convert the 4x8 bits (32 bits) to float..., but the byte order is important
edit
some progress. Looks like little endian format - low byte to hi byte order AABBCCDD = DDCCBBAA
Thus a 4 hex byte of '00 00 C7 41' decodes to '24.875' if my code is good.
Code:
'/*4700*/ float y; // Player y position
'/*4704*/ float x; // Player x position
'/*4708*/ float z; // Player z position
'/*4712*/ float heading; // Direction player is facing
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Function Hex2Float(ByVal tmpHex As String) As Single
Dim TmpSng As Single
Dim tmpLng As Long
tmpLng = CLng("&H" & tmpHex)
Call CopyMemory(ByVal VarPtr(TmpSng), ByVal VarPtr(tmpLng), 4)
Hex2Float = TmpSng
End Function
..and my float to hex (32bits) converter
Code:
Public Function Float2Hex(ByVal TmpFloat As Single) As String
Dim TmpBytes(0 To 3) As Byte
Dim TmpSng As Single
Dim tmpStr As String
Dim X As Long
TmpSng = TmpFloat
Call CopyMemory(ByVal VarPtr(TmpBytes(0)), ByVal VarPtr(TmpSng), 4)
For X = 3 To 0 Step -1
If Len(HEX(TmpBytes(X))) = 1 Then
tmpStr = tmpStr & "0" & HEX(TmpBytes(X))
Else: tmpStr = tmpStr & HEX(TmpBytes(X))
End If
Next X
Float2Hex = tmpStr
End Function
GeorgeS