It may appear to be stored "backwards" to you, but it represents the exact same value. That's just how the CPU does things.
The PPU appears to like the high byte first. You write $8D to $2006, and then $9A to $2006. $2007 would be geared to write to $8D9A, not $9A8D. On one console, you get to deal with with both types of endianness!
If the 6502 is going to read a 16 bit value as an address or pointer, it has to be two contiguous bytes, low byte first.
But... any other time (like adding to an objects position), it doesn't matter.
consider this code:
Code: Select all
highbyte = $04
lowbyte = $EF
lda lowbyte
clc
adc #$08
sta lowbyte
lda highbyte
adc #$00
sta highbyte
I tend to store things high byte first because it's much easier to read when I'm peeking at the RAM in a debugger. It doesn't matter one way or the other except with pointers and addresses, which the 6502 will always read in its own way.
Just be consistent in your own code, and do what makes sense for you. I hope this post didn't serve to confuse you more.
edit: Wait. Is this the heart of the matter that you expect ox, ox+1, ox+2, and ox+3 to have the same values in the same order as position_hi etc?
Reversing those .ds statements for position_hi etc. wouldn't change the represented value at all. Even if they appeared in the "right" order after reversal, they represent the same thing either way. You could even do this:
Code: Select all
position_hi .DS 1
oX .ds 4
position_medium .DS 1
position_lo .ds 1
position_medihi .ds 1
edit2: nevermind for what was once here. Not reading closely