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

Author Topic: Super Mario Bros 3 (New inventory item help?)  (Read 10575 times)

ahakomi

  • Jr. Member
  • **
  • Posts: 20
  • I'm just channeling my creativity
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #20 on: April 13, 2015, 07:54:34 am »
I don't really think I have an assembler though.... is there a special place you can download one? lol I'm not trying to be difficult. Having the engaged mind to track down the hex isn't something that'd stop me. I just wanna make my job as easy as I can. :) It took me a while to learn how to change the items in the mushroom houses and I did so I'm proud of myself for that. I figure if I could do that, I could do anything. :)

Quick Curly

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #21 on: April 13, 2015, 11:49:11 am »
Speaking of my hack from before... The Super Mario Bros 3 hack I made wouldn't have been made possible if Quick Curly hadn't helped me with the rom addresses and what not so thank you so much. I was able to create a game I wanted at the time and you'll never know just how grateful I am. Even if it my first hack ever (please don't judge it's level designs lol some of them are noticable as to what levels i used, others of them are damn near impossible to beat simply because I'm also a massotherapist and I really need to keep up with my eye hand coordination)
You're very welcome! :) It's a great feeling to be able to create something, whether it's a game, hack, translation, or anything else. We also learn more with each new creation as well. Don't try to worry too much about people who have negative things to say, mainly if it's the kind of negative that isn't aiming to help positively, because there's always someone somewhere who will enjoy your work regardless! All you know, you'll motivate people to pursue their own hacking dreams as well! ;D
By chance, do you mean those documents that I submitted to Romhacking.net years ago? Ha ha. Those bring back memories, though looking back now, they were more of a personal learning experience. I didn't know anything from the start either (not that I necessarily know much more now :laugh:), as I didn't initially know about space limits, and like many people, overwrote original levels without even realizing how any of it worked, and then wondered what happened when I came around to 1-4 and 1-6 (which are right beside each other).

I don't really think I have an assembler though.... is there a special place you can download one? lol I'm not trying to be difficult. Having the engaged mind to track down the hex isn't something that'd stop me. I just wanna make my job as easy as I can. :) It took me a while to learn how to change the items in the mushroom houses and I did so I'm proud of myself for that. I figure if I could do that, I could do anything. :)
That's the right attitude to have! Always believe you can, and don't be afraid to try; and in the case that you can't figure something out, don't be afraid to ask. :)

I don't necessarily work with assembly tools myself, but you can search for them here on Romhacking.net in the Utilities section. There are currently 60 results, and you can narrow the search down more if you set the platform to NES, since you're specifically working with Super Mario Bros. 3 right now (though multi-platform utilities can definitely be useful, like YY-CHR or Tile Layer Pro for editing graphics, as you can use those for more than NES games).
Perhaps people more experienced in the area can recommend some specific programs that are the most user-friendly and effective.

Search Assembly Tools on Romhacking.net

Like Dr. Floppy, I've generally always used FCEUX/FCEUXD and its/their many built-in tools to modify anything directly that I've ever wanted or found the need to. You can log data and code while the game is running to find where it is in the ROM. You can edit bytes directly in the hex editor, and then reset/load a save from before the changes were made so that you can see how the game is affected, to test the changes before you actually save them to make sure that they do what you want, and to make sure that the game doesn't crash as a result.

Now, of course, such methods are sometimes time-consuming, and perhaps assembly helps save time and also keeps all your data and code neat, organized, and efficient.
It doesn't necessarily mean that you should feel forced to try it if you truly feel that it's not for you, and you feel more comfortable working with the tools and hacking methods that you have been.
True, you don't absolutely know for sure until you give it a chance, but all I'm sharing from personal experience is that you still have the freedom to choose, and don't have to do what a few people tell you to, especially if they're methods unfamiliar to you. Heck, you don't even have to follow anything that I'm saying. :P Everyone works differently. What might be easy for them might be difficult for you, and vice versa.

For me personally, I've always been able to do what I've had to with FCEUX/FCEUXD. If I have to track down some troublesome code or mystery data somewhere, I generally know how the PRG-ROM banks in SMB3 are laid out and ordered, so after logging data and code while the game is running to load the bytes that I'm searching for, I stop the logging, pause the emulator (with F2), and then click in the hex editor to see what lights up. I test different areas out if I have to until I track down the correct bytes, and then I edit them how I need to.

It also depends on the game, too. In games that use more compression methods, it's definitely more difficult to work with directly. Tearing the game apart and building it back together in a more user-friendly manner is probably the way to go in such a case.

Nonetheless, Southbird did do a disassembly, and DahrkDaiz is currently using it to make a new advanced hack.

It depends on how much of the original game's elements beyond just the levels, maps, and possibly even graphics that you want to change.
« Last Edit: April 13, 2015, 12:15:07 pm by Quick Curly »

ahakomi

  • Jr. Member
  • **
  • Posts: 20
  • I'm just channeling my creativity
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #22 on: April 13, 2015, 03:39:27 pm »
I am currently using FCEUX 2.1.5 and I started using the Debugger to try to change mario from small to Frog using the mushroom

This tutorial:

http://acmlm.kafuka.org/uploader/get.php?id=2885

I've been on the trying the same damn thing for two hours and it's pissing me the F$%K off! I usually do so well with tutorials but this I feel isn't written very well and it's hard for me to understand. This isn't very thorough. To make a long story short, I'm stuck. I don't understand Jumping to a Subroutine or the whole putting the 20 at the beginning of the byte address. This is seriously making me wanna throw in the towel. If I can't understand something like this, I don't know how I'm going to even put in additional content in freespaces, or even, how the hell am i gonna modify the power up that i want to or potentially make my own. Sorry I'm having a moment and i feel like i suck really bad at this. I tried looking for freespace all over the damn rom in the rom file and I can't ~right click~ anything to help me find it.  Am I the only person who had this many problems using the debugger?! Or am I just that terrible.  :-[

Quick Curly

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #23 on: April 14, 2015, 01:11:57 am »
Warning: This turned out to be a considerably long post. I apologize in advance.

I remember seeing that tutorial a few years ago.

First, here is a handy link for 6502 Opcodes. I would recommend saving this page as an offline HTML file for easy access. Much like any information that you find online that is helpful and handy, you never know when it might randomly disappear.

6502.org: Tutorials and Aids

So, I went through the tutorial. I agree that it might seem confusing for those who are just beginning to try something like this, as it was written to provide the basic guidelines, but also leaves the user to come up with part of the solution themselves in a way, specifically how they determine to put in their jump, and the jump address itself where they decide to put in the custom code.

First, after entering a level, setting the write breakpoint to $00ED in RAM, and grabbing a Mushroom, the debugger freezes at $A3F0, just as it occurred in the tutorial. In the debugger, there is a vertical bar on the left side that shows the RAM and ROM addresses for each line displayed. $A3F0 is 0x10400 in the ROM file.

If you move up a few lines in the debugger, you can see the code the precedes the write to $00ED. There is a 60 (RTS) at $A3C9 (0x103D9), so this block of code that we're dealing with right now begins (or even possibly continues from somewhere else) at $A3CA (0x103DA).

Code: [Select]
$A3CA:AD 78 05  LDA $0578 = #$02
$A3CD:F0 2B     BEQ $A3FA
$A3CF:C9 0F     CMP #$0F
$A3D1:30 19     BMI $A3EC
$A3D3:C9 80     CMP #$80
$A3D5:D0 05     BNE $A3DC
$A3D7:EE 77 05  INC $0577 = #$00
$A3DA:D0 16     BNE $A3F2
$A3DC:C9 40     CMP #$40
$A3DE:F0 07     BEQ $A3E7
$A3E0:A9 C0     LDA #$C0
$A3E2:8D 7A 05  STA $057A = #$00
$A3E5:D0 0B     BNE $A3F2
$A3E7:EE 75 05  INC $0575 = #$00
$A3EA:D0 06     BNE $A3F2
$A3EC:29 0F     AND #$0F
$A3EE:A8        TAY
$A3EF:88        DEY
$A3F0:84 ED     STY $ED = #$00
$A3F2:A9 00     LDA #$00
$A3F4:8D 78 05  STA $0578 = #$02
$A3F7:20 49 A5  JSR $A549

When the tutorial is advising us to seek an appropriate offset to insert our "hijack", or "Jump to SubRoutine" (JSR), we first need to find some free space within the ROM banks that are currently loaded into RAM.
When we're being warned that it can't be RAM, it's because we can't run code through actual RAM addresses. Specifically, $0000 - $7FFF. If you hover the mouse over the vertical left bar, no information shows up, because these addresses aren't ROM banks.

Here are the ROM bank ranges currently loaded into RAM with the debugger frozen at this breakpoint:

Code: [Select]
$8000 - $9FFF = 0x3C010 - 0x3E00F
$A000 - $BFFF = 0x10010 - 0x1200F
$C000 - $DFFF = 0x00010 - 0x0200F
$E000 - $FFFF = 0x3E010 - 0x4000F

Looking through those ranges, I found some "FF" bytes at $FF2A (0x3FF3A). I saw in the tutorial that $E960 was used as an example for how to write the JSR, as the 60 is actually written first before the E9, and I saw that there are some "FF" bytes there, but in my case, I just chose to go with $FF2A.

By left-clicking in the debugger at $FF2A, the hex editor opens at 0x3FF3A, where I type in the code as directed by the tutorial.

Code: [Select]
0x3FF3A: A9 04 8D ED 00 60
As it is written if viewed in the debugger:

Code: [Select]
$FF2A:A9 04     LDA #$04
$FF2C:8D ED 00  STA $00ED = #$00
$FF2F:60        RTS

Next, we need to also add the JSR to $FF2A at the point where the debugger is frozen, back at $A3F0. Since there are multiple branches to $A3F2 (BNE) that I don't want to have to mess with, I decide that the 3 bytes I'll use for the JSR will be $A3EF - $A3F1.
So, at 0x103FF, I replace "88 84 ED" with "20 2A FF".

Code: [Select]
0x103FF: 20 2A FF
If I click Run, the debugger will actually freeze at $FF2C because we're writing to $00ED there now.

Now, I delete the write breakpoint so that I can play the game and test out the new code.
Turns out, however, that this code doesn't just hijack the Mushroom power-up, but even the Fire Flower and Leaf. After getting hit, the Frog Suit will still remain. Even after dying in a level by falling in a pit or lava, the Frog Suit still remains back on the World Map too.

We could always potentially look into how the original code determines which power-up to deal with, and modify the code (or whatever we find) so that the Mushroom truly acts as the Frog Suit, but everything else still behaves normally, and not just have the code overwrite everything by always using the Frog Suit.

What I decided to do in 1-1 was set a write breakpoint to $0578, and then I collected a Mushroom. You'll remember this address from $A3CA, where the game loads a value of #$02, meaning it has to be stored to $0578 at some point.

The debugger froze at $A8A0. This time, $A8A0 was 0x28B0 in the ROM. I scrolled up a line in the debugger to see the line of code that loads the value of #$02 and stores it to $0578 in the next.

Code: [Select]
$A89E:A9 02     LDA #$02
$A8A0:8D 78 05  STA $0578 = #$00

So, as a test, I went to 0x28AF in the ROM and changed 02 to 04, the value of the Frog Suit. I turned off the write breakpoint, clicked Run, and reset the game so that I could go to collect the Mushroom again.
The Mushroom power-up behaved as a Leaf. So, I had to go back in the debugger, add the write breakpoint to $0578 again, and then try again so that I could follow through the code to see what was going on.

This time, I hit the Mushroom block, dropped to the ground, and set both read and write breakpoints to $0578. I ran through until it froze at $A3CA (0x103DA). At this point, using "Step Into" showed the A, X and Y register values at each line of code to see exactly how each were changing.

Code: [Select]
$A3CA:AD 78 05  LDA $0578 = #$02    A:90 X:01 Y:FC
$A3CD:F0 2B     BEQ $A3FA           A:04 X:01 Y:FC
$A3CF:C9 0F     CMP #$0F            A:04 X:01 Y:FC
$A3D1:30 19     BMI $A3EC           A:04 X:01 Y:FC
$A3EC:29 0F     AND #$0F            A:04 X:01 Y:FC
$A3EE:A8        TAY                 A:04 X:01 Y:FC
$A3EF:88        DEY                 A:04 X:01 Y:04
$A3F0:84 ED     STY $ED = #$00      A:04 X:01 Y:03
$A3F2:A9 00     LDA #$00
$A3F4:8D 78 05  STA $0578 = #$02
$A3F7:20 49 A5  JSR $A549

So, due to the DEY, 04 actually became 03. So, the value loaded from $0578 is actually decreased by 01 before being stored into $00ED. Fire Flower has the value of 02, but 02 is stored into $0578 before 01 is stored into $00ED for the Mushroom. So, 05 should be decreased to 04 for the Frog Suit.
I guess it wasn't as complicated as it seemed, though this is part of the trial and error process that you shouldn't feel bad about working through, no matter how simple something might turn out to be, even if it seems confusing or complicated at first.

I went to 0x28AF in the ROM and changed the value to 05 instead, and went back to play through the game. Collecting the Mushroom turned Mario into Frog Mario. After getting hit, Frog Mario became Big Mario. After collecting a Leaf, Big Mario became Raccoon Mario. Getting hit twice, Raccoon Mario became Big Mario, and then Small Mario. After collecting another Mushroom, Mario became Frog Mario again.

So, at the end of all of this, it turns out the tutorial is just a means of testing out the fundamental basics of adding in a jump to custom code to do something different. The specific example of forcing the Frog Suit provided through the tutorial isn't necessarily practical in terms of SMB3 at its core, because you most likely wouldn't want a player to always be granted the Frog Suit, whether they're collecting any power-up or getting hit. However, it prompted us to look even deeper beyond where we were directed, and we ended up learning how a couple more things in SMB3 work, and implementing a more practical solution (disregarding how the green palette is applied and the transformation is still as though Mario is becoming Big Mario, so further hacking would be required to make the transformation seem more like the Frog Mario transformation) for the intended objective.

Finally, at the end of all this, and after working through this whole process...

I just have to say, please don't feel so bad and down on yourself. You're learning. We all do. There's no way that you're terrible. :)

Here's another quick example that you could try - implementing infinite lives in SMB3.
If the RAM address isn't known, then you have to find it first by trial and error methods. However, thanks to the SMB3 RAM Map on Data Crystal, we can discover that the RAM address for Mario's lives is $0736, and the RAM address for Luigi's lives is $0737.

In the case that we didn't, however, we could find those addresses by clicking in the Tools menu and selecting Cheats. Click Reset, and the values in RAM are displayed. Since Mario and Luigi start with 04 lives, try a Known Value of 04. The possibilities are reduced and narrowed down. Next, play through the game, lose a life, and then open the Cheats window again. The values on the left side are the original values of 04 from before, and the values on the right side are the updated/changed values. Only one value decreased to 03 - $0736 - and in most cases, we can conclude that it's the correct RAM address that we're looking for. In some cases, further testing to confirm this might be necessary. You would have to repeat the process for Luigi to find where his lives are stored. However, some games store common variables closely together in RAM, so you can sometimes find one and make an educated guess as to where the second player's lives are, like in this case for SMB3.

So, for testing purposes, we'll need a 2-player game to make sure that the infinite lives work for both players.

Set write breakpoints to the RAM addresses for both players' lives. In this case, set write breakpoints to both $0736 and $0737. Play through the game as Mario and lose a life. The debugger freezes at $9123, or 0x3D133 in the ROM:

Code: [Select]
$9123:DE 36 07  DEC $0736,X @ $0736 = #$04
See the X in "DEC $0736,X"? That means that, depending on what the value of the X register is, an address following $0736 has the potential to be decreased too, i.e. $0737, Luigi's lives.

By clicking Run, the debugger doesn't freeze again. Only one write to $0736.

Play through the game as Luigi and lose a life. The debugger freezes at $9123 again.

Code: [Select]
$9123:DE 36 07  DEC $0736,X @ $0737 = #$04
X is 01 this time. So, this one line of code - these 3 bytes - decrease the lives counters for both players whenever they lose lives.

Remember the NOP Opcode that the tutorial from earlier referred to? It's EA. Basically, it does nothing. So, go to 0x3D133 in the ROM, and replace "DE 36 07" with "EA EA EA". With the write breakpoints still active, click Run and play through the game with this change implemented. The debugger won't freeze again because the code that wrote to it is gone now, and the lives counters can't decrease, meaning that Mario and Luigi have infinite lives!

Now, the lives counters can still potentially increase by collecting 1-UPs, collecting coins, collecting 3 cards at the ends of levels, playing the spade games, etc. unless you decide to find all of the cases of code that will increase these counters and NOP them out too, but regardless of that, they can never reach 0!

Hopefully this helps somewhat in getting a little more insight to Assembly, Opcodes, and the debugger and other tools of the FCEUX/FCEUXD emulator(s) series.
And remember - you can do it! :)

ahakomi

  • Jr. Member
  • **
  • Posts: 20
  • I'm just channeling my creativity
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #24 on: April 14, 2015, 06:10:45 am »
LISTEN! I don't mind long posts. I'm going to read it right now. This gives me an opportunity to learn about how this damn thing works. I had a really bad near death experience and in my down time while I was sick, this occupied a lot of my time as I would play my IMBNES emulator with my mom because we took care of each other. I really wanted to do this hence came my first hack. And it was because you took the time to explain these things in documents and what not. I really feel like I'm a part of a community that still cares for creativity of the basics in video games. I know it might sound cheesy but I really miss feeling a part of that. My father killed most of my dream unfortunately however I feel like since my near death experience, my wonder and excitement about wanting to do this has come back and not only that but I'm grasping the hexadecimal and rom address concepts a lot better now than I ever was before. I don't really know why but I figure I'll go ahead and give it a try this time and I've honestly come so much further than I ever thought I would!

ANYWAYS lol the point of this post was, I seriously do not mind long posts, I appreciate someone willing to explain because when I was a freshman in high school my teacher had a hard time with me in javascript, i just didn't take and I had a good teacher. so it's nice to see something explained from another point of view and youre very easy to follow. So thank you. I'm going to read now and then I'll reply. :)

Quick Curly

  • Full Member
  • ***
  • Posts: 110
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #25 on: April 14, 2015, 11:42:53 am »
I'm sorry to hear about your situation. It's unfortunate that such things happen. :(
Such stories can be inspiring, though. I'm glad that you came out of it. :)

Thank you for believing that I'm easy to follow. That truly means a lot to hear. :angel:
I do try my best to be as detailed as possible, and I personally feel that providing visuals whenever possible also definitely helps clarify lengthy explanations that much better to show exactly what one means.

I just happened to notice a couple mistakes on my part in my last post. I wrote it late at night, so I guess I wasn't fully aware of everything that I was typing. Ha ha. :P

If you move up a few lines in the debugger, you can see the code that precedes the write to $00ED.

By right-clicking in the debugger at $FF2A, the hex editor opens at 0x3FF3A, where I type in the code as directed by the tutorial.

The first was just a word mistake, but the second was kind of a big one. Left-clicking on the left vertical bar in the debugger opens up a new, smaller window, and doesn't direct you to that point of the ROM file in the hex editor. That was what the previous tutorial meant from something that you can right-click on. I really don't know how I messed that up. I feel bad. I really shouldn't write 3-hour long tutorials from 10 p.m. to 1 a.m.! :crazy:

Anyway, Photobucket wasn't loading for me last night, but it did this morning, so I could upload a quick visual of the debugger to show you the left vertical bar that I was referring to, which I enclosed in red.



Hopefully there aren't anymore slip-ups, but I hope that the tutorial will be easy enough to follow either way. Best of luck! :)

Sliver X

  • Hero Member
  • *****
  • Posts: 1065
  • LIBERA·TE·EX·INFERIS
    • View Profile
    • Panicus - A Fragment of Memory
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #26 on: April 14, 2015, 10:47:39 pm »
Yeah... No. Assembly is much easier to work with than the hex representation of the same data. Let the assembler deal with variable length instructions and how to pack bits correctly.

I guess it depends on the CPU. The NES' had so few opcodes I just memorized the most used ones and did probably 90% of the assembly I ever did in pure hex.

Being able to do that turned FCEUXD into a very powerful tool; almost an IDE of sorts.
« Last Edit: April 14, 2015, 10:54:17 pm by Sliver X »

ahakomi

  • Jr. Member
  • **
  • Posts: 20
  • I'm just channeling my creativity
    • View Profile
Re: Super Mario Bros 3 (New inventory item help?)
« Reply #27 on: July 04, 2015, 03:59:03 am »
Okay, so I've decided, instead of taking out the frog suit I'm probably going to revamp the leaf into a different powerup where you could step on plant heads and spines (as well as regular enemies) and lose your ability to fly. My question is, if I made these modifications to the "leaf" powerup, would it affect the tanooki costume, I don't wanna mess up the tanooki at all and after finishing my second world (of the hack im currently working on) I really wanna invest in the frog suit more. I suppose i hated the damn thing (Weird with me being a pisces and all) so much now ive made it into something i like or more useful if i could say that. I'm going to start learning ASM now and 6502 processor since i quit my midnight job and im back to taking care of my mother. I'm keeping a notebook of all the great things i've found useful on this site and the other references i've received. thank you all very much for your help, im excited to see where i can go with this now that im not hella stressed out from caregiving.