[Game Genie] Super Mario Bros. - "Start-and-Stay" Code Troubles

Started by Josephine Lithius, August 03, 2019, 06:34:05 AM

Previous topic - Next topic

Josephine Lithius

Alrighty, so... I've been trying to make some Game Genie™ codes for Super Mario Bros. (stand-alone version, for now).  Basically, I was fooling around with searching for values (as I often do), and I found out that Mario's "power" state is controlled by two addresses:
- $0754 controls whether he's actually Super ($00) or Small ($01)
  Just for laughs, set this to $02 and try bashing some blocks, sometime!  I chuckled, at least!
- $0756 controls whether he has zero hits (Small ($00)), one hit (Super ($01)),  or can toss fire (Fiery ($02))

Now, using using Tony Headstrom's helpful guide, I was able to make some codes that do... certain things.  Thusfar, I've made a "Power-ups Have No Effect" code, a "Get Power-Up, Can't Be Powered Down" code, and an "Always Small Mario Regardless of Power" code.  The lattermost is good for my purposes... but, I'd also like to make codes to set and lock Mario's initial state, so I can do things like "Start-and-Stay as Fiery Super Mario," which would be a two-line code.

I'm not very good at 6502 Disassembly, but I was able to track down and figure out the following through a combination of FCE Ultra X and a Wikibooks page on the subject:

Edit: Updated some value information and added another value I discovered.

[POWER-UP STATE ($0756, default value $00)]
_Reading From_
00:859F:AD 56 07  LDA $0756 = #$00                  ; Load value from $0756 (Mario power state), Game Start (Frame 9)
00:85FD:AD 56 07  LDA $0756 = #$00                  ; Load value from $0756 (Mario power state), Game Start (Frames 9, 27, 33)
00:B624:AD 56 07  LDA $0756 = #$??                  ; Load value from $0756 (Mario power state), CONSTANT (Frame 33 onward)

_Writing To_
00:90DC:91 06     STA ($06),Y @ $0756 = #$00        ; Make Y Set $0756 to $00 (Small Mario)?  Executed on title screen
00:85A5:8D 56 07  STA $0756 = #$00                  ; Set $0756 to $00 (Small Mario), executed on lives screen
                                                     (Temporarily removes power-up state to show Mario/Luigi player colors)
00:85B1:8D 56 07  STA $0756 = #$00                  ; Set $0756 to $00 (Small Mario), executed on lives screen after 85A5
                                                     (Restores power-up state back to what it was before the lives screen)

01:D842:8D 56 07  STA $0756 = #$01                  ; Set $0756 to $01 (Big Mario), executed on Super Mushroom pick-up
01:D82D:8D 56 07  STA $0756 = #$02                  ; Set $0756 to $02 (Fiery Mario), executed on Fire Flower pick-up
01:D936:8D 56 07  STA $0756 = #$00                  ; Set $0756 to $00 (Small Mario), executed when player hurt while powered-up
00:9274:8D 56 07  STA $0756 = #$00                  ; Set $0756 to $00 (Small Mario), executed after player death

[BIG/SMALL STATE ($0754, default value $01)]
_Reading From_
01:F091:AD 54 07  LDA $0754 = #$01                  ; Load value from $0754 (Mario big/small state), CONSTANT (Frame 33 onward)
00:B32B:AC 54 07  LDY $0754 = #$01                  ; Load value from $0754 (Mario big/small state), CONSTANT (Frame 35 onward)
00:B130:AD 54 07  LDA $0754 = #$01                  ; Load value from $0754 (Mario big/small state), CONSTANT (Frame 35 onward)
01:DC9F:AD 54 07  LDA $0754 = #$01                  ; Load value from $0754 (Mario big/small state), CONSTANT (Frame 35 onward)
01:DCB1:AE 54 07  LDX $0754 = #$01                  ; Load value from $0754 (Mario big/small state), CONSTANT (Frame 35 onward)
01:F091:AD 54 07  LDA $0754 = #$01                  ; Load value from $0754 (Mario big/small state), CONSTANT (Frame 35 onward)

_Writing To_
00:90DC:91 06     STA ($06),Y @ $0754 = #$01        ; Make Y Set $0754 to $01? (Small Mario), Game Start (Frames 3, 5)
00:9066:8D 54 07  STA $0754 = #$00                  ; Set $0754 to $00 (Big Mario), Game Start (Frame 32)
00:B265:8D 54 07  STA $0754 = #$00                  ; Set $0754 to $00 (Big Mario), executed on Super Mushroom pick-up
                                                     (6 frames after $D842 executes)
00:B265:8D 54 07  STA $0754 = #$01                  ; Set $0754 to $01 (Small Mario), executed on player hurt while powered-up
                                                     (15 frames atter $D936 executes)
00:9269:8D 54 07  STA $0754 = #$01                  ; Set $0754 to $01 (Small Mario), executed after pitfall death


I've tried changing this-and-that to NOP (do nothing) codes, which is how I got the codes I mentioned, and I've tried changing things to "set to this value," sometimes with ugly results like game crashes, so... I really have no idea what I'm doing wrong, at this point.  I feel like I'm probably missing data, despite my research, or just using the wrong commands, or something.  If anyone has any ideas (or, better yet... simple solutions!), let me know.

Thanks for reading!

Cyneprepou4uk

You cannot start with fire mario that easy, because there is no code like LDA #00 + STA $0756 (there is one at $85A3, but it will be overriten at the same frame a bit later, so forger about it). Game writes #00 to almost the whole RAM (including $0756) at $90CC subroutine, so the game is basically like "hey, I have cleared RAM before, I'm sure $0756 will have #00 value when you start playing and I don't need to do anything else with this address". Which means you are gonna make a hell of a lot GG codes to change that, and considering mario doesn't have free space for new code... Good luck with that.

As I understand, you want mario always stay fire as well, so your best option might be to find out which of LDA $0756 instructions affect that by changing them to LDA #02 + NOP. You force the game into thinking it loads fire state in particular cases, while having #00 at $0756 for other LDA instructions. Or you can make your life easier by changing them all together and make GGs from it, without figuring out what they for, I bet it'll work. Similar goes for $0754.

Also, GG is a waste of time (and making notes about frame counter is too btw). I mean it's good that you are learning, but making actual GGs will slow you down. Concentrate on mastering assembly, try writing several subroutines. I think you have good potential by the looks of some of your code comments. And don't use that outdated piece of crap, fceux is your best friend from now on. Comments can be written via debugger itself by rightclicking at address

Josephine Lithius

First-and-foremost, thank you for your reply!  It's a little disappointing to hear that there's no way to try and do what I'm attempting, but I guess that's just how things go, sometimes.  I got the idea from similar Game Genie codes for Super Mario Bros. 3 and, for some reason, thought I might be able to do something like that for the first game.  Of course, as soon as I realized that Mario's "Super" status and his "hit counter" used two entirely separate values, I probably should have known better, ha hah.

But, I have to tell you... I'm not trying to learn Game Genie codes for any "useful" reason, and I'm certainly not trying to learn anything Assembly-related.  Actually, this is only my second encounter with it -- the first being the info DarkSamus993 offered up for our Mega Man 7 ROM hack.  I could learn Assembly, probably, but I don't really have the same burning desire that a lot of folks in the community have, when it comes to game modification.  In short: I'm a casual modder.  Which is why that somewhat-outdated guide that I referenced was so handy for me. (The way I commented those values is actually how he did it, for me!)
In regard to Game Genie, I mean... you can do much cooler stuff by just locking/freezing RAM values (like starting-and-staying as Super Fiery Mario).  I've done quite a lot of that on a wide range of emulated consoles and found some pretty interesting stuff by doing so. For example, I was pretty pleased when I found out you could play as True Akuma in Street Fighter Alpha 2, for the Super NES, via value freezing.  I'm sure I wasn't the first to find that, though.  But, really?  I'm just fiddling around and trying to make a unique Game Genie code for someone else, since they occasionally do videos where they try codes for Super Mario Bros.  Is it a waste of time?  Sure is.  But, it's my time to waste!  ;)

Anyway, I appreciate you clearing up the mystery I laid out, your suggestions, and your confidence in me.  Thank you.  But, I think I'll just stick to "tinkering," for now.
... how is writing down where and when a specific event executes useless, though?  Especially if it only fires off the one time, on-boot?  Ah, well...

Cyneprepou4uk

I didn't say it's impossible, I told you a way how you can achieve that. I understand that it is not as simple and quick as you have expected, but still pretty easy.

As for comments, I said that "frame number" seems useless to me, not the whole commenting part. Maybe it's good for sorting your comments in order for a particular address, but that's it. Too long to explain that.

Pay more attention  :police: