18+ only

Hey it's Drake, 35yo trans pan otherkin goddess hedgederg who will eat your whole universe X3. Mainly playing ffxiv or writing, or chattin folks up.

A pretty 50/50 switch who loves her darling girlfriend @HedgehogGoddess so so much. <3

animated avatar by @ConstellationArtGallery , awesome job! <3

Main character on XIV is Drake Silvos on Coeurl.

AD account: @drakeofthelewdaxe

I'm also drakesilvos on discord.


rgmechex
@rgmechex

There's a trick in Super Mario World that allows you to always get every 1up from the small bonus rooms with 3 ? blocks in a row. All you have to do is swing Mario's cape into the left side of each block, and it will always result in a green circle.

Mario getting a 1up from one of the rows of ? blocks in a bonus roomIt's not just a game of chance any more!

Why on earth would that affect the random result of these blocks? Time to dig into the code.


Here's the block of code responsible for determining whether hitting one of these blocks will give a green circle, or a brown block:

;$00F226: Check if a bonus ? block should
;         be a green circle or brown block
CheckBonusBlock:
    LDA VisitedBonusGameAlreadyFlag
    BNE ProduceBrownBlocks
    TXA
    BEQ .firstBlockHit
    LDA #2
.firstBlockHit:
    EOR #%11
    AND FrameCounter
    BNE ProduceGreenBlock
ProduceBrownBlocks:
    ;...

The first couple lines detect if you have already visited the bonus room already in this level. This flag gets set when you leave the room, so you can't just go back and reenter the room over and over again to rack up lives. Instead, if you reenter the room, all the blocks will always turn brown.

Then the X register is transferred to the A register. All you need to know at this point is that X will contain zero if no block has been hit in this row yet. If a block has been hit already and this is the second block to be hit, X will be something other than zero. (We'll talk about what exactly another time.) If X had zero, then A gets zero, and is exclusively OR'd with 3 (11 in binary, the lowest 2 bits), which results in 3. Otherwise, A gets 2 before being XOR'd, which results in 1 (01 in binary).

This finally gets AND'd with the game's frame counter to determine the final result. If the result of the AND is zero, then you get a brown block, otherwise you get a green circle. Here's a neat table of all the results that could possibly happen:

Frame Counter's lower 2 bitsFirst Block (A = 11)Second Block (A = 01)
0000 00
0101 01
1010 00
1111 01
Hitting the third block always results in a green circle, so this code never gets run in that case.

This means that you have a 3/4 chance of getting the first green circle, then a 1/2 chance of getting the second. This means in total, you have a 3/8 chance of getting the 1up in each row. Your expected number of 1ups per bonus room is then 5 times that (there are 5 rows of blocks), so 15/8, or just under 2 1up mushrooms.


This doesn't explain why the cape trick works though. What here makes the probability go from 37.5% to 100%?

It's pretty simple really. Simulating physics can be pretty resource intensive. Calculating interactions between every object in the level every frame is a lot of work. So some processes are only done every other frame, or every fourth frame.

When Mario spins his cape, the game checks four separate locations for cape-to-block collisions.

The four cape interaction points the game uses for calculations. Points A and B are to the left of Mario--A being at the tip of the cape and B at the base. Points C and D are to the right--C being at the base and D at the tip.Points A and D are at the extent of the cape's range, while points B and C are right next to Mario himself.

Only one of these points is checked each frame. When cape spinning, the cape is on either side of Mario for four frames each. The game also alternates which of the two collision points per side to check. This means that there is an 8 frame pattern that the points are checked: A, B, A, B, C, D, C, D. (Yes, that means that it's not symmetrical--notice that this pattern results in far, near, far, near, near, far, near, far in terms of proximity to Mario.)

This means points A and C are checked when the lowest bits of the frame counter are 00 and 10, while points B and D are checked when the lowest bits are 01 and 11. Let's revisit that table:

Frame Counter's lower 2 bitsFirst Block (A = 11)Second Block (A = 01)Cape Interaction Points Checked
000000A & C
010101B & D
101000A & C
111101B & D

If you look carefully, that means that if cape interaction points B or D are the points that happen to collide with the ? block, it will always be a green circle.

Point B is hard to isolate--you're pretty much always going to have point A also colliding with the block at the same time. However, point D is easier to isolate since it is on the very tip of Mario's cape when it is on the right side of him. Therefore, just by standing a few pixels away from the left side of each of the ? blocks, we can ensure that cape interaction point D will always be the one to collide with the block (and never point C), and we will always get a green circle every time.

Now your expected number of 1ups to get from these bonus rooms is 5 1up mushrooms!

Mario getting all 5 1up mushrooms from a bonus roomThere's no excuse for not getting all of the 1ups now.


You can support Retro Game Mechanics Explained on Patreon here! Any and all support is greatly appreciated!


You must log in to comment.

in reply to @rgmechex's post:

I have learned a thing!

I knew of the cape trick, but I also knew that it would sometimes fail. My assumption was that it failed when you accidentally hit the bottom of the block with your cape instead of the left side--that "hitting the left side" was the secret, not "hitting it with the correct part of your cape".

Video game code: wild stuff.

I just saw a video of that being done with a Goomba!

Another video's description claimed it works if you hit the blocks when the question marks are in the center, but that didn't seem well demonstrated by the video itself. It might be an indicator of the frame counter, but it would still take some serious precision, the way I imagine it.

Oh cool! I knew this trick back in the 90s when my cousins taught it to me on their SNES. How they learned it, I never knew. But I think we all assumed it was a deliberate secret. This makes more sense though!