News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Charity ROM Hack!  (Read 2415 times)

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Charity ROM Hack!
« on: March 23, 2016, 05:23:20 am »
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]
« Last Edit: March 23, 2016, 11:33:07 am by KingMike »

zonk47

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Charity ROM Hack!
« Reply #1 on: March 23, 2016, 06:44:54 am »
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 http://www.ign.com/faqs/2002/pac-man-game-genie-codes-373150, with corrections)
Code: [Select]
  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.

SleepyFist

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Charity ROM Hack!
« Reply #2 on: March 23, 2016, 06:47:10 am »
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:
Sleepy's tune of the week|| 2 Mello - after midnight: unaired broadcasts || https://youtu.be/FKqLCJ4mStI

Quick Curly

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Re: Charity ROM Hack!
« Reply #3 on: March 23, 2016, 08:49:48 am »
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):

Code: [Select]
$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):

Code: [Select]
$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):

Code: [Select]
$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:

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #4 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!

jink640

  • Sr. Member
  • ****
  • Posts: 377
  • From nuggets to dust.
    • View Profile
Re: Charity ROM Hack!
« Reply #5 on: March 23, 2016, 01:15:06 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.

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #6 on: March 23, 2016, 06:32:39 pm »
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.)
« Last Edit: March 23, 2016, 06:42:14 pm by SlayZombi »

dougeff

  • Sr. Member
  • ****
  • Posts: 359
    • View Profile
Re: Charity ROM Hack!
« Reply #7 on: March 23, 2016, 07:22:43 pm »
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)

4E45531A010100000000000000000000


EDIT: why does it say offset A9C0 at the bottom? It should be offset 0A9C.
Right? (I don't use windhex)
« Last Edit: March 23, 2016, 07:33:33 pm by dougeff »
nesdoug.com -- blog/tutorial on programming for the NES

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #8 on: March 23, 2016, 07:30:25 pm »


Here's the very first line I have.

dougeff

  • Sr. Member
  • ****
  • Posts: 359
    • View Profile
Re: Charity ROM Hack!
« Reply #9 on: March 23, 2016, 07:31:42 pm »
That's the right file.

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


EDIT:
I mean, when the bottom line says 'offset A90', or anything in that range.
« Last Edit: March 23, 2016, 08:00:41 pm by dougeff »
nesdoug.com -- blog/tutorial on programming for the NES

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #10 on: March 23, 2016, 08:24:25 pm »
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?

SleepyFist

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Charity ROM Hack!
« Reply #11 on: March 23, 2016, 08:33:35 pm »
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.
Sleepy's tune of the week|| 2 Mello - after midnight: unaired broadcasts || https://youtu.be/FKqLCJ4mStI

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #12 on: March 23, 2016, 09:36:33 pm »
It wont let me type 01. It just changes to either 31 or 30 depending if I hit "0" or "1" on the keyboard.

zonk47

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Charity ROM Hack!
« Reply #13 on: March 23, 2016, 09:55:20 pm »
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.

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #14 on: March 23, 2016, 10:41:14 pm »


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".

mz

  • Sr. Member
  • ****
  • Posts: 439
  • Whore
    • View Profile
Re: Charity ROM Hack!
« Reply #15 on: March 23, 2016, 10:54:26 pm »
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.

SlayZombi

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: Charity ROM Hack!
« Reply #16 on: March 23, 2016, 11:06:48 pm »
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!