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

Author Topic: Disabling "Attract Mode" on Galaga (nes)  (Read 268 times)

DirtierDan

  • Newbie
  • *
  • Posts: 2
    • View Profile
Disabling "Attract Mode" on Galaga (nes)
« on: October 18, 2017, 07:51:16 pm »
Hi there!

I'm trying to disable the Attract Mode on Galaga for the NES so when the game is left idle it never leaves the title screen.
I have next to no experience with rom hacking, having only messed around with tile editing.
I'm not even sure where to start with this.

Tony H

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • The Code Hut
Re: Disabling "Attract Mode" on Galaga (nes)
« Reply #1 on: October 19, 2017, 08:18:09 pm »
There is usually a timer that counts down to start the attract mode.  Just use any NES emulator that has RAM searching abilities and do a "Less Than" search leading up to the start of the attract mode (or possibly a Greater Than search).  Once you find the timer RAM address, use any value and it will freeze the timer.  Example: if the timer RAM address is 0123, then your code would be 0123:xx where xx is any value except zero.

EDIT: If the timer is used for other things and causes problems, then a simple assembly hack will be needed.
« Last Edit: October 19, 2017, 08:56:58 pm by Tony H »
The Code Hut: http://www.angelfire.com/games2/codehut/

Game Genie codes and ROM hacking guides

nesrocks

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
Re: Disabling "Attract Mode" on Galaga (nes)
« Reply #2 on: October 20, 2017, 05:46:07 am »
Simply hex edit rom address 0x4E1B to "EA18".

What I did is I used the cheat search in fceux to find the timer (it is in $48 and $49). Then on the title screen I set the debugger for breaks on read to 49, and I noticed it goes to demo when 49 changes to 3, so I hit next on the debugger until it compared to 3. There was this:
Code: [Select]
01:CE09:A5 49     LDA $0049 = #$02
01:CE0B:C9 03     CMP #$03
01:CE0D:90 D7     BCC $CDE6

So I changed the "compare to 3" into a "NOP" instruction and a "clear carry" instruction, and that's it. You may test the whole game and see if this broke something else but probably it didn't.

Code: [Select]
01:CE09:A5 49     LDA $0049 = #$0F
01:CE0B:EA        NOP
01:CE0C:18        CLC
01:CE0D:90 D7     BCC $CDE6
« Last Edit: October 20, 2017, 07:16:47 am by nesrocks »

Psyklax

  • Sr. Member
  • ****
  • Posts: 412
    • View Profile
    • Psyklax Translations
Re: Disabling "Attract Mode" on Galaga (nes)
« Reply #3 on: October 20, 2017, 08:55:20 am »
I've no idea why you'd want to do this :D but nesrocks gave an elegant solution. This will apply to any game where something seems to appear after some time: the game just increases or decreases an address in RAM every frame, and each time checks whether it's reached a certain number - in this case, 3. This is also a way to speed up text on the screen - or in the case of Simon's Quest, making the day/night transition go more quickly.

DirtierDan

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Disabling "Attract Mode" on Galaga (nes)
« Reply #4 on: October 21, 2017, 06:55:38 am »
Thank you all so much!!! Nesrocks's solution worked, also taught me a bit about hex editing.

nesrocks

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
Re: Disabling "Attract Mode" on Galaga (nes)
« Reply #5 on: October 21, 2017, 07:22:04 pm »
Fun, right?

You could also instead write "4CE6CD" to 0x4E09. $4C is a jump instruction and takes 3 cycles.
While a Load accumulator in this case takes 3, a NOP takes 2, a clear carry takes 2, and a taken branch (bcc in this case) takes 3 (sometimes 4), so 10 in total (or 11), which is considerably slower. You generally don't have to worry about this though, but it is good to know.

So, instead of this:
1 - load into "A" whatever is stored in address $49
2 - no operation
3 - clear carry
4 - branch to $CDE6 if carry is cleared (we know it is clear, we've just cleared it!)

You can simply go straight to the desired address:
1 - jump to $CDE6

This is different in that it will now go to that address with an unknown value stored in "A" (instead of what was on $49) and the carry status will also be unknown. But after some testing it doesn't seem to be a problem.

My first solution was based on fewer bytes to edit and less "randomness", but this is faster code.
« Last Edit: October 21, 2017, 07:31:36 pm by nesrocks »