Rom hacking in Mame

PhilT

Active member
vacBacker
Credits
154CR
Does anyone have any skills in hacking arcade roms in mame and mamehooker? I dont seem to be getting too far and could do with some guidance.

Basically, for Star Wars and Empire Strikes Back, I want to be able to tell if a game is in play or whether its cycling through attract screens. Perhaps push a state as an output from mame that I can pick up.

Or maybe I am going about in completely wrong to begin with. Anyone done anything similar?

thanks.
 

smf

Active member
Credits
15CR
If you want to know what the game is doing then you'll need to find the variable in ram.

I would try

mame starwars -d

in the debug window

use the "g" command or press f5 to start

ctrl-m

enter 4800 in the box

Then click in the memory window and start typing and seeing what happens. I just tried holding down the 1 key and it started affecting how many coins and then suddenly destroying the death star etc.

Once you make some notes of interesting addresses and values then you can then start a game and play through some screens and see what happens normally.

The current screen in starwars seems to be 4841, 6/8/a/c are attract mode, e is level select, 10 is high score entry, 20 is first wave, 30 is death star trench etc. I hadn't meant to do the hard work, but it only took about a minute to find the location and then I just spent some time poking values (you can also use b@4841=20 as typing values in the memory window can upset it as it writes a nybble at a time). Switching screens randomly makes it upset sometimes, you can find yourself just parked in space or in the death star trench. There are probably some other variables that need changing, but it's kinda out of scope.

I haven't ever used it, but there is a scripting system in mame using lua that I believe can pick up when there is a change and then call out somehow. https://docs.mamedev.org/techspecs/luaengine.html

smf2019-07-21 23:21:54
 

PhilT

Active member
vacBacker
Credits
154CR
thats brilliant thanks.

I am not very familiar with how to go about it and what tools to use yet so this has definitely pointed me there and helped me out. Not very familiar with mame really, always preferred the real pcbs.

I am playing with an old moving platform, though it would be cool if I could get star wars running on it with movement but need a way to switch off the movement when the game is not playing.
 

smf

Active member
Credits
15CR
PhilT said:
I am not very familiar with how to go about it and what tools to use yet so this has definitely pointed me there and helped me out.

Yeah, I didn't know what you knew & so I included all the steps.

If you try to do something similar for a different game then ram won't necessarily be at 4800. Normally you can find out where ram is by looking in the driver source:

https://github.com/mamedev/mame/blob/master/src/mame/drivers/starwars.cpp

and search for ram(). For starwars the first hit is actually the write only vector ram which shares the same address as the rom, so it's not going to be that. The next one is 4800, none of the others looked promising.

To get the driver source the easiest way is to use

I haven't looked at esb, it might be the same address for the screen number or not.

You can see that it uses the same starwars.cpp source file though

mame -listsource esb

esb starwars.cpp

and there are no other address maps in the source file & so I would expect ram to be at 4800 and going through the same process will likely find it.

PhilT said:
I am playing with an old moving platform, though it would be cool if I could get star wars running on it with movement but need a way to switch off the movement when the game is not playing.

That sound pretty amazing, I'd love to see this in action

smf2019-07-22 10:52:17
 

PhilT

Active member
vacBacker
Credits
154CR
Thanks again, some good info to get me started there.

I picked up a hydraulic game platform, pcbs that control everything long gone and the control mech was full of industrial PLC controller boxes so no chance of getting that lot working. so the hydraulics have been dumped in favour of some motors, controlled by arduinos, sabre32 controllers and simtools. Could turn out to be an expensive paperweight but had to have a go!
 
Top