Type/Bank storage.

BlitzMax Forums/BlitzMax Programming/Type/Bank storage.

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Does anybody know what this prints 1,0,0,0 rather than 0,0,0,1?
Type ttest
  Field TG
End Type
mynew:ttest = New ttest
mynew.tg=1
'mynew.tg=256
Print "Sizeof : " + SizeOf(mynew)
Local mybank:TBank=CreateStaticBank(mynew,SizeOf(mynew))
For x = 0 To BankSize(mybank)-1
	Print "Byte"+x+" "+PeekByte(mybank,x)
Next
Local myfile:TStream=WriteStream("empty.txt")
WriteBank(mybank,myfile,0,BankSize(mybank))
CloseFile myfile

My guess is that the Object structure pads the field variable. e.g. 1 fits in 1 byte so pads with 3 X'00' bytes to make the 4 byte int or simply writes it back-to-front.
Am I missing something?

Thats normal. Bank position 0 is the 0th bit which is the last. (it follows the little endian enumeration. last is bit 0 ...)

As Banks are disconnected from OS bitordering, this should even show up the same on PPC based systems ...

As Dreamora nearly said legibly. ;o)

It's because the integer is being stored in little endian format. This is quite correct.

I'm also reasonably sure that bank operations *are* effected by system endianess (is that a word?). I'm more than willing to be proven wrong though.

Thanks Gents,
It makes sense. Makes it difficult in my situation where I am trying to work out a chunk of memory with only a vague idea of the format. It's like doing a puzzle with the picture side of each piece facing down.