Page 1 of 1

Reverse Byte Order?

PostPosted: October 14th, 2008, 6:51 am
by Cyclone
I’m tying to learn some hacking and I think I got my head around the very basics but I’m a little confused here.

Giangurgolo’s Object Document and the Japanese Editor say that the byte value for a Gnawty is B413 but the Hex editor shows it as 13 B4. Can Simion or anyone explain why the bytes are reversed? Would be much appreciated. Thanks

Re: Reverse Byte Order?

PostPosted: October 14th, 2008, 7:22 am
by Simion32
It's because the SNES's processors use little endian. Essentially this means any value larger than a byte will be read in reverse.

If you are looking at a two byte value such as 34 12 in ROM, it would really be read as 12 34... 78 56 34 12 would be 12 34 56 78, and so on.

Re: Reverse Byte Order?

PostPosted: October 14th, 2008, 8:22 am
by Cyclone
Thanks.

How does one know which bytes to reverse and which stay the same? Looking at the hex values you don't know if it's a 1,2,3,4, etc byte value.

I am using a Hex editor called Translhextion it has modes for little/big endian but it didn't seem to change how the bytes were displayed. How does one interpret/convert these values to make sure they are correct?

Also is the way that Giangurgolo’s docs show the offset/byte values a standard way displaying things? I don't want to document everything in reverse lol.

Re: Reverse Byte Order?

PostPosted: October 14th, 2008, 8:34 am
by Simion32
I also use Translhextion, but I don't bother messing with its settings. I just type the bytes in backwards (or whichever way they should go).

With objects, each object is a set of four 2-byte values: object function, x position, y position, and object short. Each of those values are stored reversed.

It would be easier to have objects written the way Giangurgolo has them. No idea if it's a standard but it may as well be. :P

Re: Reverse Byte Order?

PostPosted: October 14th, 2008, 6:46 pm
by Cyclone
Thanks. I 'think ' I understand it now. :)

Re: Reverse Byte Order?

PostPosted: October 23rd, 2008, 4:43 am
by Blaziken257
Ha ha... when I first started using a hex editor, that would throw me off a lot at first, but now I'm used to it. I think every other Nintendo system is little endian as well (I know for a fact that all Game Boy variants are little endian).

Also, here are some other things that are little endian: pointers and colors.

I have one question though: What's the point of little endian anyway? That just makes it more confusing for the hacker.

Re: Reverse Byte Order?

PostPosted: October 23rd, 2008, 6:47 am
by Simion32
Blaziken257 wrote:I have one question though: What's the point of little endian anyway? That just makes it more confusing for the hacker.
Well, there may be some advantages to using little-endian (such as the way the hardware works or something). And I definitely don't think they wanted it to be easy for people to hack. :P