11 March 2016 - Forum Rules

Main Menu

Charity ROM Hack!

Started by SlayZombi, March 23, 2016, 05:23:20 AM

Previous topic - Next topic


So i'm doing a carnival booth as part of a Make-a-Wish foundation for my school. Everyone has to do a carnival booth (part of FBLA class) and I decided to bring some retro/nostalgia to my school by doing an arcade-style Pac-Man game! I outfitted my RaspberryPi with RetroPi to emulate TONS of games. I'm sure you guys know about emulators and RetroPi as well, but I thought I would like to ask you all to do a (most likely) simple task for me. I would like a Rom-Hack to change the amount of lives in Pac-Man down to one single life. I believe 3 is too many and the carnival is only for an hour over two days. So naturally, it would be way to time-consuming to allow people to play all the lives and I would rather not tell them to get off the game. That would be rude ya know? I would like to raise as much money as possible with the booth. Let me know if you would be able to change the amount of lives! I will attach the file as well. It's the NES version by the way. Thanks for reading!

[removed ROM link]


Open the ROM in an emulator with a debugger. Open the RAM watch window. Copy it at the start of the level. Die. When your next life comes up, pause and look for a number in the RAM watch that is lower than in your copy. This is the address of the life count in RAM.

If you want to edit the ROM, so that it runs with 1 life independent of the emulator, you have a few options:
- use a hex editor to search for the number 3 in the ROM file and keep making test copies of that file with various addresses edited until you hit on the right one.
- perform a trace of opcodes which write to the address in RAM where the lives are. This is probably the fastest way... use FCEUX if you do this.
- do a partial disassembly until you hit upon the address whereat 3 is loaded to a register

Here's what I found for GameGear if you want to go that route:
(from, with corrections)

  037 9C6 E66   
  Start with 3 Lives

  057 9C6 E66
  Start with 5 Lives

  077 9C6 E66
  Start with 7 Lives

Game Genie Code Converter (available here) says the ROM address for these writes is 0x179C. So, open a hex editor and change the byte at 0x179C from 3 to 1.

I tried to find the GG code for the NES lives, but nobody seems to know it.
A good slave does not realize he is one; the best slave will not accept that he has become one.


Dude, get rid of the link, its against the rules and it'll get this post nuked, you can name the rom and let us find it through google though. :thumbsup:

Quick Curly

First off, this is the specific ROM that is being used. The checksums were found using HxD.

Pac-Man (USA) (Namco).nes
Checksum-32: 002C1FC2
CRC-16: 5DAD
CRC-32: 15D202D8
MD-5: 3DDCA58C51DD38D59F9271D24E7105F9
SHA-1: E7D818E128593109B5C480497A050FACC0744F1B
SHA-256: 254FB93E16D0DB63B36FFA3EF1BC5A9E6CF9E9B1DE347712D9936FE2AB7B690D

I found that RAM addresses $0067 and $0077 are the lives for players 1 and 2 respectively.

The code that writes the starting number of lives for the players is located at 0x00A9B in the ROM ($CA8B in RAM):

$CA8B:A9 03     LDA #$03
$CA8D:85 67     STA $67 = #$00
$CA8F:85 77     STA $77 = #$00

So, in the ROM file itself (not the RAM or PPU), you'll want to change ROM offset 0x00A9C from 03 to 01.
You can do this with a hex editor such as WindHex32 or HxD, or with a hex editor tool in a special emulator like FCEUX/FCEUXD.

By testing this change out, I confirmed that each player only starts out with 1 life, and as soon as each player dies, it's game over for them.

However, another factor to consider is how there's a possibility that a player's lives can increase, like when they reach a score of 10,000 points. Do you want to prevent a player from being able to earn extra lives, so that they'll only ever have one, and as soon as they lose that life, their game is over?

If yes, then the code that increases a player's lives is located at 0x02153 in the ROM ($E143 in RAM):

$E143:E6 67     INC $67 = #$03

Replace E6 67 with EA EA. Now, the lives can never increase.

I can confirm that this code handles both players' possible life counter increases because of how the game handles which player is currently active and playing. It seems that, when player 1 dies, the game switches player 1's and 2's lives around so that the current player playing is using $0067. The following code is at 0x00DA6 in the ROM ($CD96 in RAM):

$CD96:B5 67     LDA $67,X @ $0067 = #$03    ; Load current player's remaining lives.
$CD98:85 00     STA $00 = #$02              ; Store here for later.
$CD9A:B5 77     LDA $77,X @ $0077 = #$03    ; Take other player's remaining lives.
$CD9C:95 67     STA $67,X @ $0067 = #$03    ; Replace as the active player.
$CD9E:A5 00     LDA $00 = #$02              ; Remember the other player?
$CDA0:95 77     STA $77,X @ $0077 = #$03    ; They have to wait for their turn again!

Enjoy, and best of luck with the carnival booth! :beer:


How exactly would I be able to find the codes? Is there a specific program I need to install? Thanks for the help!


Quote from: SlayZombi on March 23, 2016, 12:48:08 PM
How exactly would I be able to find the codes? Is there a specific program I need to install? Thanks for the help!
Use windhex, it seems to be the easiest one to use.


Ok, so I'm home now, and getting WindHex. I'll follow the instructions and let you guys know how it goes. This is my first time doing anything as far as messing with the internals of a ROM files so thanks for being so welcoming and helpful so far!

March 23, 2016, 06:41:11 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

So I went to where it says "0x00A9C" But I don't see where to change "03" to "01"

March 23, 2016, 06:42:14 PM - (Auto Merged - Double Posts are not allowed before 7 days.)


That can't be the right file.

I don't have a block of zeros at that location of ROM.

What do you have at the very first line...0x0000 ?

In an unmodified ROM, it should look like this (this is the iNes file header)


EDIT: why does it say offset A9C0 at the bottom? It should be offset 0A9C.
Right? (I don't use windhex) -- blog/tutorial on programming for the NES


Here's the very first line I have.


That's the right file.

Scroll down slowly to A9C. Is it still all zeros?

I mean, when the bottom line says 'offset A90', or anything in that range. -- blog/tutorial on programming for the NES


Ok, so after some fiddling I realized that some of the numbers were clipping off and I was in the wrong section. I found it and navigated to where it says "03", which indicates the 3 lives, but when I try to change it by pressing "1" on the keyboard, it changes to "31". I would rather not have 31 lives. Lol. Any ideas on where i'm going wrong?


Did that to me a couple times, gotta finesse it, click the number just before 03 and then use the arrow keys to scoot the cursor forward one space, then type 01.


It wont let me type 01. It just changes to either 31 or 30 depending if I hit "0" or "1" on the keyboard.


The values are at offsets of the line. Go to A9, C column. Click, type 0 then 3.
A good slave does not realize he is one; the best slave will not accept that he has become one.


I click on the value "03" to change it to "1" and it somehow changes to 31. Even if I try "01" it will replace it with "30" and the next value over will be "31".


That's because you're editing the text, not the hex.

Press the Tab key to change to Hex Edit mode.
There has to be a better life.


Well there we go! I tested it and it works! Thanks for being so welcoming and helpful guys! This should definitely work for the carnival booth. We can get more people through while still allowing them to have fun! I'll be coming back if I have any more questions about ROM-hacking. I'd love to learn more! Have a nice night!