I wonder how to decode a three-dimensional dynamic array of a custom type written to a binary file in VB6.
The custom type is defined as follows:
Type XYByte
X As Byte
Y As Byte
End Type
It represents two coordinates of a contact point.
The three-dimensional array represents pre-computed contact point positions for a minigolf track relief. The track is viewed as a two-dimensional height map. For each possible ball position on the map, contact points are computed that there can be more for a map coordinate, so hence the third dimension.
Dim ContactPointMap() As XYByte
ReDim ContactPointMap(Width - 1, Height - 1, MaxContactPointCount - 1)
That array gets saved into a binary file that includes that track shape.
Open FileName For Binary As #1
...
Put #1, , ContactPointMap()
...
Close #1
OK, this is how I did it in VB6. Now I re-write the mini-golf simulator in FPC/Lazarus and wonder how to decipher the three-dimensional array data witten by VB6.
It's interesting that it's pretty straightforward to read a two-dimensional array of "Single" precision float values that I use as the relief map itself and as a source for contact point calculation:
Dim Map() As Single
ReDim Map(Width - 1, Height - 1)
The data is saved in a logical order. I can recognize rows and columns and the reading goes well.
But by that three-dimensional contact point map, every try to read it fails. I used a hexeditor to see the binary data and it's stored in a way that I can't understand.
OK, I already can read the relief map and as a backup option, I can re-compute the contact points in FPC, change the format and save the contact point map in a non-cryptic way. BTW, I stored that information in the track files only for speed reasons (it was faster to read that array on play time than to calculate it).
I no longer have access to VB6. I only have the code and the compiled executable.
But does anyone know how would I basically decipher a three-dimensional dynamic array of user-defined type written by VisualBasic 6?