ROM Hacking : Reading Inputs (Coin Switches)

Scucci

Well-known member
Joined
Feb 6, 2003
Messages
4,498
Reaction score
95
Location
Nashville, Tennessee
Sorry if this has been covered, I searched a bit and didn't find anything.

I've been working on a few free play with attract mode ROMs and I've ran across a few games that have me stumped. I'm not strong with assembly, but I can usually stumble around enough to make something work. On most games I can find all the switch inputs in RAM and can bumble-screw my way through the hacks using those address. But I've ran across a few games where I just can't find where the programs are checking for inputs from the coin switches. I can see the joysticks, "fire" buttons, and start buttons in RAM... but not the coin switches. Seems to be mainly Universal games, but there's also at least 1 Midway game (Solar Fox) where I can see everything else in RAM, but just not the coin switches.

For example; in Lady Bug I can see the control panel inputs at around $9000, but the coin switches don't show up there, or seemingly anywhere else. With Solar Fox I can see the coin switches in IO Space Memory in MAME's debugger, but again, I'm not strong with assembly and I'm not sure what what checks I should be looking for in the code for that area of memory.

Any one have any tips or tricks for finding where some games are looking for these inputs?
 
Coinage is usually handled through interrupts, so you won't find code "looking" for a coin input.
For freeplay hacking, you should look for the memory location that stores the current coin/credit count (and then figure out where and how that is used).
 
Like Matt said, check the interrupts... for example, if you look at the Ladybug schematics, you can see that the right coin goes to /NMI and left coin to /INT. Someone asked about freeplay on this several years ago and I took a quick look at it... here are my notes (hardly remember anything about it, so no idea of they're accurate):
Credits at $605E
Right coin hits NMI, which executes address $66 (which jumps to $0234)
Left coin hits INT, which executes address $38 (which jumps to $019E)
At press start screen, checks for start 1 press at $038A, checks for start 2 press at $0395

IIRC, it turned out HSS had a kit, so I didn't bother making the hack.

DogP
 
Like Matt said, check the interrupts... for example, if you look at the Ladybug schematics, you can see that the right coin goes to /NMI and left coin to /INT. Someone asked about freeplay on this several years ago and I took a quick look at it... here are my notes (hardly remember anything about it, so no idea of they're accurate):


IIRC, it turned out HSS had a kit, so I didn't bother making the hack.

That opens up a whole new can of worms for me. lol

Apparently I can monitor INT in MAME using the "GI" or "GINT" command in the debugger (didn't know about that). I don't see any way to track NMI in the debugger, but I'm guessing watching INT is probably enough to get started as I don't really care if the coin mechs are hit in in free play; I just want to know what happens when they're hit and how to tell the program they were hit, if I need to do the FP like that (add the credit(s) when a start button is pressed). Knowing what I'm looking for with the INT and NMI helps out a LOT though... but I think I have a few courses at YouTube University ahead of me because my disassembly doesn't match what actually happens when the game is running (off a byte)... and that's voodoo to me right now.

But, the good news is my notes match everything else you had (credits, game mode, P1 / P2 start up routines).

Thank you. :)
 
In Z80-land, INT jumps to 0x38 and NMI to 0x66 when triggered. If you set a breakpoint in mame you can observe what happens when they get triggered.

I wrote the freeplay code for Astro Fighter (which fires an NMI when coins are inserted). I'd be happy to share my source code if it helps you, but bear in mind Astro Fighter uses a 6502
 
Any one have any tips or tricks for finding where some games are looking for these inputs?

For ladybug:
Code:
    ;; IRQ Vector (Left coin)
0038: C3 9E 01      jp   $019E

.
.

    ;; NMI Vector (Right coin)
0066: C3 34 02      jp   $0234

Trigger on $0038 / $019E for left coin or $0066 / $0234 for right.

There's a bunch of unused code space in Ladybug, so just jump to some empty space, insert your code to special case free play, then jump to the original routines.
$01E1 - $01FB is blank, as is $0277-$0291
 
Lady Bug is in the queue somewhere, but knowing about INT and NMI I was finally able to fix my "Magical Spot II" free play ROMs. 1st shot (before I knew about that INT mess) made you coin up the machine once and then it would stay in FP, but at the coined up screen. But now it's got attract mode, adds credits before the coined up screen (still goes to the coined up screen, but holding the button a little longer skips it, pressing the start button again on the screen starts as it should), then removes all credits when the game is over. Not pretty, but better than having to coin it up. It'll work for now. :)

I'm sure I'll run into the different modes in the future, but for now this has opened up a lot of stuff for me. Going to revisit a few old projects that I ran into a dead end with. Love learning new stuff... having a blast now!

Thank you again, everyone. I'm sure I'll have more questions in the future, but I don't want to wear out my welcome too much.
 

Attachments

  • MSII.zip
    4.9 KB · Views: 2
Lady Bug is in the queue somewhere, but knowing about INT and NMI I was finally able to fix my "Magical Spot II" free play ROMs. 1st shot (before I knew about that INT mess) made you coin up the machine once and then it would stay in FP, but at the coined up screen. But now it's got attract mode, adds credits before the coined up screen (still goes to the coined up screen, but holding the button a little longer skips it, pressing the start button again on the screen starts as it should), then removes all credits when the game is over. Not pretty, but better than having to coin it up. It'll work for now. :)

I'm sure I'll run into the different modes in the future, but for now this has opened up a lot of stuff for me. Going to revisit a few old projects that I ran into a dead end with. Love learning new stuff... having a blast now!

Thank you again, everyone. I'm sure I'll have more questions in the future, but I don't want to wear out my welcome too much.
BTW>
I just pulled up Ladybug in MAME, and it was running my high score save + attract mode free play mod.
By the dates on the files, I did that one in 2017 :)
 
First version of "Solar Fox" free play. (For the 4 people that actually have or play this game lol)

Not pretty (code-wise)... and not tested on real hardware yet (gimme a couple of days)... but it's done.

Was a fun one... ... Today we learned about reading ports (IN) and fun with flags (CP)! So yay!

Removed number of credits in the bottom right corner, press "Speed" to start, replaces "INSERT COINS FOR" with "FREE PLAY" during attract mode, and sadly disables coin 1 (for now... sorry, I'm still working on getting the hang of this).

I'll eventually stop loading this thread up with this stuff... just wanted to post the code and say thank you again for the helps.
 

Attachments

  • SolarFox FP.zip
    8.8 KB · Views: 8
Last edited:
First version of "Solar Fox" free play. (For the 4 people that actually have or play this game lol)

Not pretty (code-wise)... and not tested on real hardware yet (gimme a couple of days)... but it's done.

Was a fun one... ... Today we learned about reading ports (IN) and fun with flags (CP)! So yay!

Removed number of credits in the bottom right corner, press "Speed" to start, replaces "INSERT COINS FOR" with "FREE PLAY" during attract mode, and sadly disables coin 1 (for now... sorry, I'm still working on getting the hang of this).

I'll eventually stop loading this thread up with this stuff... just wanted to post the code and say thank you again for the helps.
Thank you, been waiting for this. I'll give this a try as soon as I can..
 
FWIW, tested in the cabinet and it worked fine.

Still want to tweak it in the future to make it look more like you'd expect from free play mode (have to edit an attract mode screen to make more sense) and need to get that coin switch reading again. But that might be a while.
 
Back
Top Bottom