Where to start and Stop looking in the debugger output

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
gukingofheart
Posts: 44
Joined: Tue Dec 04, 2018 2:28 pm

Where to start and Stop looking in the debugger output

Post by gukingofheart »

I got a simple question (hopefully)...

In Super Mario Bros, there's an infinite life address of 075A.. and when you debug it, you get the address 90DC.. and on this line is STA.
To create this game genie code, you have to go up one line to the LDA.


https://forums.nesdev.com/viewtopic.php?f=2&t=18140
In this thread, I'm getting the advice of scroll down, not up.. so what do I scroll down to? (Or what place do I absolutely need to stop)
Do I keep messing with every line til I reach RTS? (that be 12 or more lines to experiment with)

Are there certain lines that you most likely will never mess with like BPL.
Should you always scroll up to a LDA, and then work down??

I'm trying to at least narrow things down.
PS. I know things like LDA/RTS/STA are just hex values.
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Where to start and Stop looking in the debugger output

Post by nesrocks »

There's no rule about where to scroll to. It's a series of instructions and you have to really understand what you're reading. LDA loads a number to the accumulator A (LDA loads a direct value like #80 or an indirect value stored in a memory location like a value stored on $80) and then A can be manipulated and generally a result is stored on an address with STA or the A result can be compared to another number.

I don't understand what this is: "there's an infinite life address of 075A"
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Where to start and Stop looking in the debugger output

Post by tepples »

It means "Super Mario Bros. uses address $075A in CPU RAM in such a way that if a given Game Genie code modifies the value that is written to that address, the player will have infinite lives."
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Where to start and Stop looking in the debugger output

Post by nesrocks »

Ok so what is the goal the OP is trying to achieve? To understand exactly what the GG code changes or to simply achieve the same effect?

To clarify: this address doesn't hold infinite lives, it probably holds current lives. The gg code is changing how this address is manipulated.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Where to start and Stop looking in the debugger output

Post by tepples »

nesrocks wrote:Ok so what is the goal the OP is trying to achieve? To understand exactly what the GG code changes or to simply achieve the same effect?
To understand how Game Genie codes in general do their work, if I correctly understand this post by the same user with respect to a code that manipulates acceleration in Excitebike.
gukingofheart wrote:(I'm also writing all this info down.. and will be asking questions for different games in the future... and will try to find a pattern of what to try, and what would be a total waste of time).
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Where to start and Stop looking in the debugger output

Post by rainwarrior »

gukingofheart wrote:In this thread, I'm getting the advice of scroll down, not up.. so what do I scroll down to? (Or what place do I absolutely need to stop)
Do I keep messing with every line til I reach RTS? (that be 12 or more lines to experiment with)

Are there certain lines that you most likely will never mess with like BPL.
Should you always scroll up to a LDA, and then work down??
Most code runs line by line, so scrolling up or down does show you what happens before and after the current instruction.

However, code can jump around too. JMP, JSR, RTS, Bxx, and some other instructions will go to a new location, so the previous line was not necessarily the one directly above. If you want to be sure of where you came from, use the trace logging feature (another thing in the debug menu) which will keep a big text log, line by line, of every executed instruction as it happens.

Mesen makes it even easier with a "step back" button, so really that's even better.

I can't tell you which instructions are important or not. Really almost all of them will be important in the vicinity of the thing you're working on. Just look them up as you come across them, and eventually you'll know them all. Here's a good reference:
http://www.obelisk.me.uk/6502/reference.html
gukingofheart
Posts: 44
Joined: Tue Dec 04, 2018 2:28 pm

Re: Where to start and Stop looking in the debugger output

Post by gukingofheart »

Welp, either way I got some new info to work with.. so that's a start.
My next plan is to look at a bunch of different NES game speed gamegenie codes to see if there's a similar style in any way.
Bavi_H
Posts: 193
Joined: Sun Mar 03, 2013 1:52 am
Location: Texas, USA
Contact:

Re: Where to start and Stop looking in the debugger output

Post by Bavi_H »

Perhaps gukingofheart is referring to "RAM freezing" cheat ability of FCEUX when saying 075A is an "infinite life address".

In FCEUX, you can freeze a RAM address to have a constant value that never changes. In Super Mario Bros., the address 075A stores the current lives. (See this RAM map for Super Mario Bros. from the romhacking.net Data Crystal wiki.) So if you freeze address 075A to a non-zero value, you will effectively have inifinite lives, because the lives value will never change. (When the game tries to change it, the emulator keeps it frozen at the value you specified.)

Gukingofheart, just to make sure you're aware, you can't create a Game Genie code to "freeze" a RAM address like you can in the FCEUX Cheat menu. Details: On the NES, the RAM is at CPU addresses 0000 to 07FF. However, a Game Genie can only modify the values at CPU addresses 8000 to FFFF. So to make a Game Genie code affect a RAM address, you have to find something in addresses 8000 to FFFF that affects that RAM address, then change that.
Post Reply