DAT Records - Help Please
Drone
Posts: 433
I'm struggling to do something seeming simple, combine bytes and longs in a single line (record if you will) of DAT data. Please see the simple code attached. I've read the manual pages on DAT, long, byte etc. tried mixed long byte etc. size and alignments in the DAT records - nope. Is there any way to do this? I really want to keep the long and bytes on the same line as that's how a complication spreadsheet generates the data. I feel like I'm missing something here - any suggestions appreciated.
David
David
Comments
The easiest thing to do is to use all longs and change the way the data is formatted. Instead of
byte $30,$C2,$AD,$A9,$D3,$52,long 1800000
you'd have
long $A9_AD_C2_30,$00_00_52_D3,1800000
Note that the order of the bytes is changed so the 1st 6 bytes still are in memory in the order you want (LSB first),
then two bytes of padding, then the long value.
In the end, using all longs as you suggest may use too much memory. I'll try formatting the data in such a way that the longs and bytes are in different lines or different tables.
Best Regards,
David
Just define field offsets and fieldtypes (so you know what is a long).
Storing a long into byte array at some index
byte[noparse][[/noparse]index+0] := longvar.byte[noparse][[/noparse]0]
byte[noparse][[/noparse]index+1] := longvar.byte[noparse][[/noparse]1]
byte[noparse][[/noparse]index+2] := longvar.byte[noparse][[/noparse]2]
byte[noparse][[/noparse]index+3] := longvar.byte[noparse][[/noparse]3]
Retrieving a long
longvar.byte[noparse][[/noparse]0] := byte[noparse][[/noparse]index+0]
longvar.byte[noparse][[/noparse]1] := byte[noparse][[/noparse]index+1]
longvar.byte[noparse][[/noparse]2] := byte[noparse][[/noparse]index+2]
longvar.byte[noparse][[/noparse]3] := byte[noparse][[/noparse]index+3]
You can define fieldsize and type in the offset
offset = (index<<2) + type
type 0 is byte
type 1 is word
type 2 is long
regards peter
byte $30,$C2,$AD,$A9,$D3,$52,long 1800000
could be
word $C2_30,$A9_AD,$52_D3,1800000>>16,180000&$FFFF
You could do the same thing with bytes, but the expressions involving the 32 bit value get more complex.
byte $30,$C2,$AD,$A9,$D3,$52,1800000,1800000>>8,1800000>>16,1800000>>24
Post Edited (Mike Green) : 5/26/2008 3:10:45 PM GMT