+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Need information on the Nintendo control scheme.
Pages: [1]
Author Topic: Need information on the Nintendo control scheme.  (Read 1 times)
ScrambledEggs
Guest
« on: July 11, 2010, 03:31:44 pm »

Could someone provide me with some information on changing the control scheme in a Nintendo game? I am hacking Alien 3, and would like to change the controls. Normally, the A button shoots and the B button jumps on that game. I want to swap the buttons, so that A jumps and B shoots, like in a normal game.
KingMike
Guest
« Reply #1 on: July 11, 2010, 06:14:04 pm »

NES games will read CPU address $4016 to read controller 1 and $4017 for controller 2.
Since each read only returns one button's status (pressed/not pressed), games will usually have a routine that reads each port 8 times (each read returning 1 bit, the game will combine the 8 reads into 1 byte).
Get FCEUX, go into the game, open the trace logger. I like to have it log to file (it'll ask where to save).
Begin a trace, wait a few frames, then end the trace. Open the trace file, look for LDA $4016.
Immediately after that, it is probably saving the result, so it'll tell you the RAM address being used to store controller input (probably as a ASL/LSR/ROL/ROR $xxxx command).
Now do a search for LDA $xxxx. It should turn up a place where it's reading the button input and then CMP (comparing) it to a certain value, or maybe an AND statement.
(depending on if it's storing the bits right to left, it'd be CMP #$01 for A and CMP #$02 for B, if left to right, it'd be CMP #$80 for A and CMP #$40 for B)
ScrambledEggs
Guest
« Reply #2 on: July 12, 2010, 04:19:32 pm »

Thanks, buddy! Smiley

July 12, 2010, 04:29:53 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Okay, so I followed your instructions and I found this value directly after LDA $4016:

$E7E8:4A        LSR                        A:40 X:00 Y:08 P:nvUbdIzC

But when I search for LDA $E7E8, it finds nothing. What did I do wrong?
« Last Edit: July 12, 2010, 04:29:53 pm by ScrambledEggs »
KingMike
Guest
« Reply #3 on: July 12, 2010, 05:15:36 pm »

Okay, it's the next code. I checked the ROM and it seems to be:
LDA $4016
LSR (shift the bits from the result)
ROR $28 (shift the bit into RAM $28)

So, RAM $0028 is used to store button data.
So, that should result in the button data being stored right to left (A = right most bit, B = second from right).
So, you should check for $0028 followed by a CMP or AND instuction.
ScrambledEggs
Guest
« Reply #4 on: July 13, 2010, 03:42:28 am »

Got it now! Thanks for the help, I'm still quite the newb at ASM.

Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC