Genesis endianness question

General Chit-Chat about MAME and other emulators.
Post Reply
User avatar
VisitntX
Posts: 28
Joined: Tue Apr 29, 2008 8:37 pm
Location: Buenos Aires, Argentina

Genesis endianness question

Post by VisitntX »

I have a doubt. The m68k was meant to be big-endian, yes, but it's true that in genesis at least most games work in little-endian. So then the genesis swap them when they are wrote to memory? Or just it's used in little-endian?
User avatar
Pugsy
Posts: 3688
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Post by Pugsy »

Welcome to the forum.

The 68k is big-endian - I can't see how it could be anything but big-endian, regardless of platform. Have you got any examples of games that work in little-endian?

If you want to poke 4e71.w to address 001234 then you poke 0x4E to 001234 & 0x71 to 001235 which makes it big-endian. The same applies whether it's program code or data that's being written

MAME I consider to be endian-independent, as it works fine across various platforms and the cheats work across them all. There are 'some' 68000 arcade emulators that as they are coded exclusively for x86 (little-endian) based platforms that can have issues with cheats. Single byte cheats for MAME have to be be converted by XORing the address with 0x01 to make them work for such emulators.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
User avatar
VisitntX
Posts: 28
Joined: Tue Apr 29, 2008 8:37 pm
Location: Buenos Aires, Argentina

Post by VisitntX »

Ok, let me see if i can find the code example. I read that the sonic 2 and 3 are little endian, so I need to take a look at them.
Mmm... I see my bad, i wrote "most", sorry by that.
Thanks Pugsy.
User avatar
Pugsy
Posts: 3688
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Post by Pugsy »

Another thought


If a game has a lives address of 001235, and the maximum lives is say 5 and it uses a .w value then

001234:0005 would give you infinite lives, but if the endianess is correct then if you turn the cheat off and lose two lives then 001235 should contain 3. If however the endianess is incorrect 001235 will contain 4 ( as on the first life lose 001234 will contain FF04, and on the 2nd life loss it will contain FE04).
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
User avatar
Pugsy
Posts: 3688
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Post by Pugsy »

Remember the megadrive/genesis also contains a Z80....that of course is a little-endian cpu which I think is used exclusively for the sound on genesis games and possibly as the main cpu when a SMS cartridge is fitted for full backwards compatability.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
User avatar
VisitntX
Posts: 28
Joined: Tue Apr 29, 2008 8:37 pm
Location: Buenos Aires, Argentina

Post by VisitntX »

Remember the megadrive/genesis also contains a Z80....that of course is a little-endian cpu which I think is used exclusively for the sound on genesis games and possibly as the main cpu when a SMS cartridge is fitted for full backwards compatability.
Yes, it was my fault, I read completely again about the Sonic games. It was meant for the sound, so that's the reason of the little-endian. Heh, it was my fault, I didn't read it completely the first time.
I fixed my post at GSHI, dunno for what reason I switched the endianness terms when I know what each ones means. It looks pretty awful, but well, I'm human after all.
BTW, you're right, the Z80 it's suppossed to be used as sound processor for the genesis and like the main CPU for the SMS.
001234:0005 would give you infinite lives, but if the endianess is correct then if you turn the cheat off and lose two lives then 001235 should contain 3. If however the endianess is incorrect 001235 will contain 4 ( as on the first life lose 001234 will contain FF04, and on the 2nd life loss it will contain FE04).
I can't remember in what of the Micromachines games I had to use advantage of this. I had to did it for a GG, it tooks me a while until I figure out than that was the easy and more accurate way to do it.

Thanks a lot Pugsy, as always. A pleasure have your help and learn from you.
Post Reply