Reverse Byte Order?

Share and discuss all facets of DKC ROM hacking...

Reverse Byte Order?

Postby Cyclone » October 14th, 2008, 6:51 am

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
Attachments
ByteOrder.jpg
ByteOrder.jpg (231.45 KiB) Viewed 11421 times
Expedition Leader
Bananas received 559
Posts: 1211
Joined: 2008

Re: Reverse Byte Order?

Postby Simion32 » October 14th, 2008, 7:22 am

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.
Sage of Discovery
Bananas received 332
Posts: 2738
Joined: 2008

Re: Reverse Byte Order?

Postby Cyclone » October 14th, 2008, 8:22 am

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.
Expedition Leader
Bananas received 559
Posts: 1211
Joined: 2008

Re: Reverse Byte Order?

Postby Simion32 » October 14th, 2008, 8:34 am

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
Sage of Discovery
Bananas received 332
Posts: 2738
Joined: 2008

Re: Reverse Byte Order?

Postby Cyclone » October 14th, 2008, 6:46 pm

Thanks. I 'think ' I understand it now. :)
Expedition Leader
Bananas received 559
Posts: 1211
Joined: 2008

Re: Reverse Byte Order?

Postby Blaziken257 » October 23rd, 2008, 4:43 am

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.
Treasure Hunter
Bananas received 114
Posts: 340
Joined: 2008

Re: Reverse Byte Order?

Postby Simion32 » October 23rd, 2008, 6:47 am

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
Sage of Discovery
Bananas received 332
Posts: 2738
Joined: 2008


Return to ROM Hacking

Who is online

Users browsing this forum: No registered users and 10 guests