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

Author Topic: Super Mario 3 - Pipes to Death?  (Read 1987 times)

Fcoughlin

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Super Mario 3 - Pipes to Death?
« on: March 23, 2015, 09:15:19 am »
Hi all,

I was working a bit on a ROMhack for Super Mario 3.  I was going to start with the very simple "change memory addresses to move some levels around".  So I remapped 5-5 ( http://www.nesmaps.com/maps/SuperMarioBrothers3/SuperMarioBros3Map5-5.html ) to 1-5 (among others).  Most of the other changes have worked OK, but for the pipe in 5-5 where you normally go into the room for the Tanooki suit, something is not properly loading:

https://youtu.be/V_1XAII2D5w

To make this change, I went into the Pointers Table.  I specifically changed the Object Set, Enemy Data, and the Object Data addresses for the levels.  For most other levels it has worked, but that one room is trouble (it also showed up moving 7 - Fortress 1  which has the same room type:  http://www.nesmaps.com/maps/SuperMarioBrothers3/SuperMarioBros3Map7MiniFortress1.html).  It's possible I'm loading something incorrectly, but thus far this is one of the only places that is causing this.

Has anyone encountered this before?  If so, do you know what's causing it?  I've been trying to look into this, but with incredibly limited success thus far.

Thanks in advance!


Quick Curly

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super Mario 3 - Pipes to Death?
« Reply #1 on: March 27, 2015, 01:15:55 pm »
The pipe leading to the underground bonus areas, generally with the bonus items, is a different downward pipe than the normal one. It doesn't actually point to the next area set in the level header, but instead uses a different system elsewhere in the ROM, which actually goes by which world you are in.

Therefore, while 5-5 is originally in World 5, by moving it so that you can enter it in World 1, that special downward pipe is actually pointing to what would be World 1's underground bonus area instead, which is just an empty underground area leading to death.

If you recall, no levels in World 1 in the original game have any underground bonus areas with items or anything, so there was no need to set one.

However, this can easily be changed if you have experience with hex editors and working with the ROM directly (as opposed to changing things through SMB3 Workshop, SMB3 Map Editor, etc.).

This post on Board 2 in the General SMB3 Hacking Thread from a while ago has the ROM offsets for the underground bonus areas for each world formatted quite nicely, but I'll also re-post them here as well.

Object Data: 0x3491B - 0x3492A (0x10)
Enemy Data: 0x3492B - 0x3493A (0x10)
Object Set: 0x3493B - 0x34942 (0x8)

Object Data
$A90B (0x3491B)
----------------------
World 1: AF B1 = 0x1B1BF
World 2: BC B1 = 0x1B1CC
World 3: 8B B2 = 0x1B29B
World 4: 72 B3 = 0x1B382
World 5: D8 B3 = 0x1B3E8
World 6: 70 B4 = 0x1B480
World 7: E2 B5 = 0x1B5F2
World 8: 5B B6 = 0x1B66B

Enemy Data
$A91B (0x3492B)
----------------------
World 1: 76 C9 = 0xC986
World 2: 78 C9 = 0xC988
World 3: 7D C9 = 0xC98D
World 4: 88 C9 = 0xC998
World 5: 90 C9 = 0xC9A0
World 6: 98 C9 = 0xC9A8
World 7: A3 C9 = 0xC9B3
World 8: AB C9 = 0xC9BB

Object Set
$A92B (0x3493B)
----------------------
World 1: 0E = Underground
World 2: 0E = Underground
World 3: 0E = Underground
World 4: 0E = Underground
World 5: 0E = Underground
World 6: 0E = Underground
World 7: 0E = Underground
World 8: 0E = Underground

So, here is the hopeful fix. In a hex editor, for Object Data, change AF B1 for World 1 to D8 B3 to match that for World 5.
For Enemy Data, change 76 C9 to 90 C9.
Now, when you enter 5-5 in World 1, the underground bonus pipe should work.
Happy hacking! :)

Jorpho

  • Hero Member
  • *****
  • Posts: 3734
  • The cat screams with the voice of a man.
    • View Profile
Re: Super Mario 3 - Pipes to Death?
« Reply #2 on: March 29, 2015, 09:58:07 pm »
If you recall, no levels in World 1 in the original game have any underground bonus areas with items or anything, so there was no need to set one.
What about the one in 1-1 with the switch block that makes the big "3" appear?
This depresses me. I feel like a goldfish right now...

Quick Curly

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super Mario 3 - Pipes to Death?
« Reply #3 on: March 29, 2015, 11:21:10 pm »
What about the one in 1-1 with the switch block that makes the big "3" appear?
The pipe is the 90-9F downward pipe that uses the next area set in the level header, not the B0-BF downward pipe that uses the system for the underground bonus areas.
In addition, the 1-1 bonus area is a Plains Object Set level, not an Underground Object Set level.

Similarly, the 1-2 bonus area is also a Plains Object Set level, accessed by the 90-9F downward pipe as well.

No level in World 1 uses the B0-BF downward pipe, and if it did, much like what happened with Fcoughlin, without changing the pointers for World 1 as listed in my previous post, the current pointers for World 1 are just for an empty Underground area which leads to death. This is why other hackers in the past have accidentally stumbled upon the "underground death room" when they accidentally tried to use the B0-BF downward pipe instead of the 90-9F downward pipe without realizing the difference.

World 1-5, the Underground level, uses the "Upward Pipe to End of Level" (Bank 4, Type E0-EF) which uses yet another separate system to point to a next area besides the next area set in the level header, which also differs by which world you are currently in, even though the game actually has the same Plains ending area set for every single world.

Object Data: 0x34B27 - 0x34B36 (0x10)
Enemy Data: 0x34B37 - 0x34B46 (0x10)
Object Set: 0x34B47 - 0x34B4E (0x8)

Object Data
$AB17 (0x34B27)
----------------------
World 1: 68 BD = 0x1FD78
World 2: 68 BD = 0x1FD78
World 3: 68 BD = 0x1FD78
World 4: 68 BD = 0x1FD78
World 5: 68 BD = 0x1FD78
World 6: 68 BD = 0x1FD78
World 7: 68 BD = 0x1FD78
World 8: 68 BD = 0x1FD78

Enemy Data
$AB27 (0x34B37)
----------------------
World 1: 60 C5 = 0xC570
World 2: 60 C5 = 0xC570
World 3: 60 C5 = 0xC570
World 4: 60 C5 = 0xC570
World 5: 60 C5 = 0xC570
World 6: 60 C5 = 0xC570
World 7: 60 C5 = 0xC570
World 8: 60 C5 = 0xC570

Object Set
$AB37 (0x34B47)
----------------------
World 1: 01 = Plains
World 2: 01 = Plains
World 3: 01 = Plains
World 4: 01 = Plains
World 5: 01 = Plains
World 6: 01 = Plains
World 7: 01 = Plains
World 8: 01 = Plains

However, hackers can change the pointers for the Underground Bonus Areas and Plains Endings for each world as they see fit and to their needs. They just need to use a hex editor and modify the ROM file directly.

Fcoughlin - please do let us know if you were able to successfully fix the issue. If not, please post and let me or others know what else you might need help with. :)

Fcoughlin

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: Super Mario 3 - Pipes to Death?
« Reply #4 on: March 30, 2015, 12:40:54 pm »
Thanks a ton Quick Curly (apologies for the delay- was a nasty weekend for me in terms of lack of free time)!  That definitely helps (it was my theory but I didn't have a chance to follow through on it to figure it out).

Thank you also for pointing out the link to the other site with that information, as well as the more detailed ROM map on page 9.  I think that'll probably help most of my project (though I'll have to think about it a bit, as my project has the potential for mixing worlds from different levels, so I may have to limit things to insure that I don't end up with 5-5 and 7-F1, for example, in the same world, as their bonus pipes may not be compatible).

I think all I need to find for now is a couple of other tables in memory, but hopefully I can figure that out pretty quickly.  I'm guessing similarly to these pipes, when you enter a pipe at the end of the airship, it points you to the appropriate koopa kid based on level.  And similarly, when you enter an airship not from the castle, there's a different table to hunt for in memory.  I'll be hunting for these today (assuming I can clear sufficient levels to test it!)

Thanks again for the help!  Massively appreciated.

Quick Curly

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Super Mario 3 - Pipes to Death?
« Reply #5 on: March 31, 2015, 03:55:08 pm »
You're welcome. No worries. There are instances when I'm not as free either, but I do try my best to make myself available. :)

Yes, you're correct. The Koopa Kids are determined by which world you're currently in, much like these other pipe systems. However, unfortunately, I've never bothered to try to seek out how the game controls them and their specific abilities by world yet, so I don't have any data to provide on that as of right now, but I do recall seeing the graphics for the Koopa Kids in Tile Layer Pro before, within the range of 0x52010 - 0x5300F. Depending on the current world selected, the game somehow determines which tiles to use from these graphics banks. I could maybe look into this further later on, if necessary.
The graphics bank is loaded into $071D in RAM, between #$48, #$49, and #$4A. The last quarter, #$4B, is used for when the Koopa Kid is spinning from a hit or defeat.

----------------------
Koopa Kids by World (Write to $071D graphics bank).

0x2ED4 ($AEC4)

$AEC4:AC 27 07  LDY $0727 = #$00
$AEC7:B9 72 AE  LDA $AE72,Y @ $AE72 = #$48
$AECA:8D 1D 07  STA $071D = #$12
$AECD:B9 79 AE  LDA $AE79,Y @ $AE79 = #$37
$AED0:8D 1E 07  STA $071E = #$4F
$AED3:AD BD 07  LDA $07BD = #$00
$AED6:20 99 FE  JSR $FE99

0x2E82 ($AE72) - 0x2E88 ($AE78) (0x7)
48 49 4A 48 49 48 4A

0x2E82 - World 1: 48
0x2E83 - World 2: 49
0x2E84 - World 3: 4A
0x2E85 - World 4: 48
0x2E86 - World 5: 49
0x2E87 - World 6: 48
0x2E88 - World 7: 4A
----------------------

Do you think that your project might require you to swap the order that the Koopa Kids appear?

Insectduel recently completed a hack that adds an 8th Koopa Kid, available in the General SMB3 Hacking Thread as well, as seen here. Perhaps he has additional information that can be useful.

With regards to the airship sprite after it flies away from the castle, again, you're correct that there are other pointers used to determine which level to load, with a different level for each world.

----------------------
Ship levels by World after the ship leaves the End Castle.

0x19291 - World 1 Objects: B7 AD (0x2EDC7)
0x19293 - World 2 Objects: AB AE (0x2EEBB)
0x19295 - World 3 Objects: 09 B0 (0x2F019)
0x19297 - World 4 Objects: 3A B1 (0x2F14A)
0x19299 - World 5 Objects: 97 AC (0x2ECA7)
0x1929B - World 6 Objects: B3 B2 (0x2F2C3)
0x1929D - World 7 Objects: 89 B4 (0x2F499)
0x1929F - World 8 Objects: 17 B6 (0x2F627) (Crappy Ship)

0x192A1 - World 1 Enemies: EA D6 (0xD6FA)
0x192A3 - World 2 Enemies: 1C D7 (0xD72C)
0x192A5 - World 3 Enemies: 57 D7 (0xD767)
0x192A7 - World 4 Enemies: 98 D7 (0xD7A8)
0x192A9 - World 5 Enemies: A6 D6 (0xD6B6)
0x192AB - World 6 Enemies: E5 D7 (0xD7F5)
0x192AD - World 7 Enemies: 14 D8 (0xD824)
0x192AF - World 8 Enemies: 67 D8 (0xD877) (Crappy Ship)
----------------------

Similarly, the Coin Ship can be different for each world as well if the hacker so chooses, though in the original game, the same level is used for each world.

----------------------
Coin Ships by World.

0x19337 - World 1 Objects: 15 BC (0x2FC25)
0x19339 - World 2 Objects: 15 BC (0x2FC25)
0x1933B - World 3 Objects: 15 BC (0x2FC25)
0x1933D - World 4 Objects: 15 BC (0x2FC25)
0x1933F - World 5 Objects: 15 BC (0x2FC25)
0x19341 - World 6 Objects: 15 BC (0x2FC25)
0x19343 - World 7 Objects: 15 BC (0x2FC25)
0x19345 - World 8 Objects: 15 BC (0x2FC25)

0x19347 - World 1 Enemies: 04 DA (0xDA14)
0x19349 - World 2 Enemies: 04 DA (0xDA14)
0x1934B - World 3 Enemies: 04 DA (0xDA14)
0x1934D - World 4 Enemies: 04 DA (0xDA14)
0x1934F - World 5 Enemies: 04 DA (0xDA14)
0x19351 - World 6 Enemies: 04 DA (0xDA14)
0x19353 - World 7 Enemies: 04 DA (0xDA14)
0x19355 - World 8 Enemies: 04 DA (0xDA14)
----------------------

You might wonder, can a Coin Ship really appear in any world? In the original game, it would only appear in Worlds 1, 3, 5, and 6. Well, that's because there were only Hammer Brothers (Sprite #$03) in those worlds. In World 2, there were Boomerang and Fire Brothers; in World 4, there were Sledgehammer Brothers; and in World 7, there were Plants.
So, if the hacker includes a Hammer Brother in each world, there is the potential to access the Coin Ship in those worlds, possibly with the exception of World 8, much like how the N-Spade Bonus Game won't appear there, but I haven't actually bothered to test that out yet. Just throwing that out there.

The code that looks for a Hammer Brother (Sprite #$03) after clearing a stage with a coin total equal to a multiple of 11, and the tens digit of the player's score matching the multiple of 11, is located at 0x16D55 ($AD45) in the ROM.

0x16D55 ($AD45)

$AD45:B9 15 7F  LDA $7F15,Y @ $7F17 = #$03
$AD48:C9 03      CMP #$03
$AD4A:F0 06       BEQ $AD52
$AD4C:C8           INY
$AD4D:C0 0E      CPY #$0E
$AD4F:D0 F4       BNE $AD45
$AD51:60            RTS
$AD52:A9 0B       LDA #$0B
$AD54:99 15 7F  STA $7F15,Y @ $7F17 = #$03

Specifically, if the game finds a #$03, it will replace it with #$0B, the White Coin Ship (Takara! Kawaii).

This turned out to be a lot for one post, so sorry if it's too much. SMB3 is definitely my favourite game, and I enjoy seeing others working on SMB3-related projects! :beer:
If you wish, please feel free to PM or email me if you ever have any other questions about anything. I might not always have the full answer off-hand, but I can always try my best to help find something that might point you in the right direction. Just in case I might not always be able to get on here, either. :)
I wish you the best of luck with your project, and hope that your motivation stays strong to help you see it through to completion! :thumbsup: