Intel .HEX to cheat converter?

If you are having problems finding or using cheats for an Emulator (particularly MAME/MESS) or have found a trick that you wish to share this is the place to do it. But please read the Cheat FAQ first.
Post Reply
scott_tunstall
Posts: 14
Joined: Sun Feb 28, 2016 5:24 pm

Intel .HEX to cheat converter?

Post by scott_tunstall »

I was wondering if there's any existing programs that will take an intel .HEX file and produce a MAME cheats XML with them?

If not, no worries, I will be able to code something like that up.
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: Intel .HEX to cheat converter?

Post by crazyc »

As far as I know there's nothing like that anywhere. I'd like to know what you are trying to do though because I'm not sure what kind of cheats you could get from a hex object file.
scott_tunstall
Posts: 14
Joined: Sun Feb 28, 2016 5:24 pm

Re: Intel .HEX to cheat converter?

Post by scott_tunstall »

My Berzerk taunts cheat was a machine code routine (see mame cheats section). I created code to hook the speech synthesis of Berzerk. I took every byte output from the hex file and pasted it into an XML file, byte for byte.

The HEX file records the ORG (address) so you can compute the memory address to poke, and the bytes to poke. The only thing (well, AFAIK, with my very limited knowledge of MAME cheat system) is that when you POKE using a mame cheat (e.g. maincpu.mq@ xyz) it pokes using the endian-ness of the target processor, so I might have to rearrange the bytes from the HEX file to compensate.

For my Berzerk cheat it took an hour to take 256 bytes of machine code to translate to a XML file. A tool like I'm thinking would take a minute. Maybe there's a better MAME feature I could use to bulk change code?

One thing - I do not want to create my own ROMs with a custom patch routine. Someone's already asked why I don't do this, and my answer is I don't want to be sued. You know the drill, these games appear on "Arcade hits" all the time :)
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: Intel .HEX to cheat converter?

Post by crazyc »

Interesting. You could write a script for the lua plugin that would load the hex patches directly but the result would only be usable with the plugin, otherwise there isn't any existing mame feature to convert intel hex files to xml cheats.
User avatar
Pugsy
Posts: 3638
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 12 times
Contact:

Re: Intel .HEX to cheat converter?

Post by Pugsy »

I think you may be overthinking it a bit...you can make the raw commands quickly with just Hxd and NPP.

If you have the modified binary file starting from address 0, open it in HxD and change these settings (assuming you want to make 8 byte pokes):-

View>Byte Group Size set to 8
View>Visible Colums set to Hex
View>Bytes per Row set to 0
Then highlight the addresses+data you want to copy and:
Edit>Copy As>Editor View

Paste that into Notepad++ and if you want to replace the raw pasted data into debugger commands and swap the endianess of the data just do a regular expression find and replace

eg

Code: Select all

0000AF38  2C343831202D2D3E
0000AF40  2030303A33393A30
0000AF48  372C3035300D0A5B
to swap the endianess and convert into cheat/debugger commands set search mode to regular expression and do a Replace All

Code: Select all

Find:  ^(0.......)  (..)(..)(..)(..)(..)(..)(..)(..)
Replace With:  maincpu.mq@\1=\9\8\7\6\5\4\3\2
and you will get:

Code: Select all

maincpu.mq@0000AF38=3E2D2D203138342C
maincpu.mq@0000AF40=303A39333A303020
maincpu.mq@0000AF48=5B0A0D3035302C37
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.259 XML cheat collection (6 OCTOBER 2023) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/q4dHGZ6K#i-EUiqIjH ... KMz7hnbTfw (ZIP Archive 3.76MB)
Post Reply