First, I know I haven’t posted for around 2 weeks, but I had to take a break as my semester just ended and I really got happy to finally be back on glitch hunting Super Paper Mario.  Now, as I was streaming my glitch hunting session, I realised that I could use my blog to post about complex findings I would do that talks deeply about the engineering of the game I am testing.  One of the in my opinion most complex mechanic of Super Paper Mario (which I will call SPM from now on) is the core one: the flipping mechanic.  It is such a simple mechanic to use, but when testing it, it took me 2 weeks to completely figure it out due to how much stuff I had to figure out to just TEST it.  I hope I can find more so I can bring more glitch hunting related post to this blog, but this one was a good start at least.

Let’s first do the basic

What is flipping in SPM?

If you are asking this question, you probably haven’t heard or played SPM because it is the very core mechanic of the game.  It was an attempt to bridge 2 distinct genre: the platforming of a 2D classic Super Mario Bros game and the RPG aspect of the Paper Mario series.  There’s a lot of ways the game achieves this bridge, but the flipping focus more on bridging the exploration and puzzle parts as well as making the cubic design of the game easier to implement.

How it works is very simple for any casual players: the game by default renders maps in 2D (just like a Super Mario Bros game) and if you press A, the maps flips and now it’s rendered in 3D and your movement is also affected.  The idea is, the map will have a different perspective and different structure in 3D, some not even visible in 2D which the game exploits to basically force the player to use it as a lot of puzzles revolves around flipping and you would need both render to complete each level.  To go back to 2D, you just press A again and the map goes back to 2D as if it was magic because everything just behave the way you would expect them to behave.

It’s magical!

So, as you can probably tell, a lot of stuff are hidden from us because ALL you do is push A, you can;t get more simple than that, but if you have some knowledge in software engineering or just computer in general, you probably wonder what even happens?  You can’t just magically say to turn a map in 3D and go back to 2D at will, that’s not how program works (if it did, it wouldn’t take so much effort to build them lol).  Of course it involves a lot of stuff that happens behind the scene and being curious myself (also because……idk why I would glitch hunt this game without knowing its core mechanic), well I spent 2 weeks trying to look for interesting addresses, test them in multiple scenarios to finally come to a conclusion which happens to be…..quite long but this is why I post it 🙂

A little disclaimer

These findings were done by monitoring how the game manipulates its memory, NOT by looking at the source code because that is obviously not possible (you can check the assembly, but good luck figuring anything off of that because it wont; tell you everything and is very advanced to figure out).  What I mean is as I test more this game, my theories and visions MIGHT CHANGES as I learn more, I do post it because I did enough tests to be confident on this vision so far.  It’s just to remind that I might say there’s unclear stuff and I find their meaning months later.  You never know what you are going to find if you glitch hunt.

There is one concept I must explain first

The concept of panes

A pane in Super Paper Mario is a determined region in a map.  There’s usually clear separation done by the game to tell you that you changed pane……but this isn’t always consistent.  Usually, if you cross a clear line and the camera shift, this could likely mean you changed pane.  I did found an address that holds the index of the pane you are in the current map so i can know for sure when I changed pane.

Here’s an example of what I mean, here, this is pane 0 of Flipside:

Screenshot from 2016-06-02 12:59:26

This is pane 1 as we crossed the clear line here and the camera shifted:

Screenshot from 2016-06-02 12:59:37

This is pane 2:

Screenshot from 2016-06-02 12:59:57

And as for the area in between, it actually is still on pane 1 even though it looks the same as pane 2 and the camera does shift here.  There is a probable reason for why they did this, but it will become a bit more clear later.

Screenshot from 2016-06-02 12:59:47

With this explained, the following will now make a lot more sense.

How the flipping is controlled

There is 2 main variable that are very important in flipping.  The first one is the 3D mode flag and the second one is the map render mode (name by me, but I try to be descriptive so, bear with me).  I’ll explain the map render mode later for simplicity sake.

The 3D mode flag

A flag is just a boolean value so it’s 0 (false) or 1 (true). If it’s false, then you are NOT in 3D mode, so you are in 2D mode and if it’s true, you are in 3D mode.  Here is a list of the main properties within each of these modes:

2D

  • Movements are only allowed vertically and horizontally, you cannot control the movement backward and forward; your movement range is dependant on the camera angle.
  • Pressing the down button will allow the use of the respective character’s ability for pressing that button
  • Every objects except the one you can interact has their hitbox expanded on the Z axis, basically, they extend all the way back and forth.
  • Every objects you can interact with such as npc or door works similarly than other objects, but the difference is their hitboxes are a radius and it is that radius that is expanded.  it is also not always on the Z axis, it’s dependant on the camera angle which in 2D should always be facing directly the map and move only vertically or horizontally.
  • Features snapping depending on the map (basically, it can under certain conditions by the map set your position to a deterministic values).  For example, the long narrow walkway in pane 1 above, if you are there and you go to 2D, you are going to get snapped just in front of the sign in pane 1).
  • Except if you get snapped, you cannot move between each pane.

3D

  • The camera turns around 90 degrees (it’s automatic, if you go to 3D mode, it WILL change the camera even if you manually flip the flag)
  • Movements are allowed in all directions except in space where you can only move back and fort or left and right, also dependant on the camera angle.
  • You cannot use the down button to use a character ability because it will cause you to move instead.
  • No special effects are done on hitboxes.
  • Snapping is disabled.
  • You are allowed to move between each pane.

The map render mode

This is where things gets very interesting.  You see, in the definition of what the 3D mode flag does, I say nothing about how the game renders which is really the most complex thing here.  this is because it is done by this flag which does not control movement, but controls a lot on the render and loading.  It has 3 possible values, 0 is raw mode, 1 is 2D render mode and 2 is……I don’t know???

Well let me show what 2 does on Flipside:

Screenshot from 2016-06-02 12:36:22

Can you tell what is this?  Because I don’t and honestly, I never saw this used in-game so far so I don’t even know what it’s for lol 🙂

So we will only concentrate on the first two, and I will do the same thing with the 3D mode:

Raw render mode

Screenshot from 2016-06-02 12:59:26

  • Used to render the map without any effect, as is, used in any 3D render and in 3D mode.
  • Everything close enough to the character’s position will be loaded, this includes hitboxes and graphics.  If you are too far, you just will start to see lines and a lack of graphics.  it does not matter which pane you are in, it will load everything it can.
  • The camera can be tilted to see the map on a different angle (this also enables to use free look on Dolphin emulator).

2D render mode

Screenshot from 2016-06-02 13:16:32

  • Will only render the front face of every texture on the map meaning there is a lack of any perspective and depth effect, it’s as if everything was flat.
  • Loads ONLY the current pane you are in and nothing else, this is true for hitboxes and their objects.  However, it can load graphics if the panes beyond are close enough.
  • The camera cannot be tilted to see the map differently and trying to use free look on Dolphin will just move the HUD.

There so now, I explained everything I needed to now tell you how these features interact

What occurs under normal circumstances

Well in 3D mode, you get a raw render of the map so the map is basically untouched.  everything close enough will be loaded and you can freely move…..it’s really like playing any other Paper Mario game to be honest 🙂

In 2D however, more stuff is happening.  You get a “flattened” render of the map with the only thing loaded are the one in your current pane so your vision of the map is limited and the hitboxes of object are expanded.  This means that no matter if you are EXACTLY underneath a block or just a bit more on the front of it, you WILL hit it if you jump because that block has its hitbox expanded, but only on the current pane since this is the only thing the 2D render mode loaded.  Also, you can get forced movement by the game if you get snapped.  Lastly, your movement is quite limited, mostly by the camera angle which just can’t be really changed in 2D render mode, but you can at least use the character’s abilities.

Now, all I have said up until now could really be simple observation……but what happens if I manually switch the addresses since I found them?  Well….this is where everything becomes silly…..but make sense.

While in 2D render mode, but the 3D mode flag is set to true

Beware the…..very weird visual!

Screenshot from 2016-06-02 13:37:27

Just look at this for some time just try to guess what happened?  no?  ok…..

If you come back to the definition about the 2D render mode:

Will only render the front face of every texture on the map meaning there is a lack of any perspective and depth effect, it’s as if everything was flat.

Well you can’t say it is NOT doing that because I have a hard time to find where I am in the perspective here 🙂  The other things that tells you that is that line on the left is actually the pane separator which had some cool looking fence.  If you walk with this state……it’s as if the entire world was moving, but you don’t feel any movement because of the lack of perspective.

To complete this explanation:

Loads ONLY the current pane you are in and nothing else, this is true for hitboxes and their objects.  However, it can load graphics if the panes beyond are close enough.

Well…..the problem is how is the 2D render mode supposed to even tell the pane you are in if you can change it with 3D mode?  it takes your current “pane” and loads everything in it and behind graphically so this is why you see so much weird stuff happening.

Unfortunately, despite that graphical effect, not much is very interesting, but it does show you what the render is doing a bit more clearly.

Lastly, remember when I said there was a likely reason to have a long walkway?  Well, consider the 2D render mode which only loads the current pane and graphically, loads the pane beyond it.  If you were to put the pane 2 close enough to the main portion of pane 1, you would be in 2D render mode with all the Pane 0 and 1 visible which would likely be a mess and look awful considering how different the pane 2 should look.  However, by putting a long walkway here, you force the game to not be able to load pane 1 and 0 since they would be way too far.  It’s a pretty clever solution and it also ensure you will flip back to 2D later because it takes time and you are on a timer for 3D mode usage.

While in 3D render mode, but the 3D mode flag is set to false

This is not only cool looking but allows to better grasp how flipping works with all the concept I covered:

Screenshot from 2016-06-02 13:53:51

So it screws the perspective a little bit, but it works and looks awesome 🙂

This shouldn’t be a surprise though because I did said it is a raw render and it tries to load everything it can (we can see pane 0 and 1 here).  It becomes even more interesting if you go to some points in the definition of the 3D mode flag when it is false:

Every objects except the one you can interact has their hitbox expanded on the Z axis, basically, they extend all the way back and forth.

This was still limited normally because the 2D mode would only load the current pane’s objects and hitboxes.  However, since we are in 3D render mode, this can occur:

Screenshot from 2016-06-02 14:01:25

As you can see I am clearly not even close to be underneath the save block, I am not even in the same pane and I am hitting it!

The reason is self-explanatory but it’s basically the save block loaded thanks to 3D render mode, but its hitbox got expanded back and forth since we are still in 2D mode.

interestingly enough, some objects like the blue door here only works in the current pane so I couldn’t open it from here.

Every objects you can interact with such as npc or door works similarly than other objects, but the difference is their hitboxes are a radius and it is that radius that is expanded.  it is also not always on the Z axis, it’s dependant on the camera angle which in 2D should always be facing directly the map and move only vertically or horizontally.

Well, this is simple if you consider the angle I had with an npc, but what happens if we tilt the camera?

This would happen:

Screenshot from 2015-11-01 00:27:23

Yes I am talking to the yellow npc in the center and indeed, I am very far from being supposed to.  This is because as I said, npc hitboxes are radius, but are expanded depending on the camera angle so in this case, it sort of….curves the expansions enough so that I could talk to him from there.

Oh also, you can only move from left to right relative to the camera so that camera tilt would also tilt the angles I can move.

Possible targets for exploits

There is some places that could be interesting to exploit if you were to take this mechanic to your advantage, but it has some limitations.  If the map has some snapping conditions, you are not going to get far because the game would set your position with arbitrary values.  If it doesn’t however, you could try to manipulate the ground detection mechanic to get an additional jump on where your normally cannot.  Also,, being able to lock your 3D mode flag could be interesting because you could have 3D render in 2D mode which allows to access objects you wouldn’t normally.  Being able to lock the camera angle can also be a good exploit since it changes what you can access at certain positions.

Unfortunately, we need to know more possible exploit for these to be possible without hacking.  the game is quite tight at places since it doesn’t allow to exploit it this much, but it might become possible with more findings.

In conclusion

Flipping is a really complex mechanic that dictates the core gameplay of SPM and as simple as it is to just push a button to use it, I covered how the reality is that it involves a lot of manipulations with rendering, hitboxes and even position management making it a very complex mechanic from an engineering standpoint.  The game seems to be designed around it and it actually seems to be consistent with that by even thinking about how the map would render under normal circumstances.

On another note, as I said I did got back to glitch hunting, but I am actually streaming my sessions on my Twitch channel.  I tend to give a more informative stream where I just express my theories and test them where you can see all the addresses going and my inputs.  So if you are interested in learning more about SPM inner mechanic, you should follow my channel because I am lately quite active on this game and I do check the chat (I even have a second monitor to do that 🙂 ).

 

Advertisements

12 thoughts on “My glitch hunting: how the flipping mechanic in Super Paper Mario works

    1. I decided to not make a post about it because it would mostly be me complaining about IS’s decisions, I plan to make a pseudo review (watchign soemone) when it comes out however.

      Like

      1. True. Have you seen the interview by one of the creators on GameXplain? The original video was edited. But I found a copy of it online. Here you go. https://youtu.be/-eXtK8oRcgM

        It was later set to private and reedited for some reason. But I think you need to watch this version first though. I saw this and the Lifestream and I cringe a lot. 😦

        Like

      2. I deleted my Twitter account after the hacking incident. Never again! Plus that website has it’s own problems to deal with? So maybe next year? lol

        Like

      3. I will. I just need to somehow do some things in my life first. Thanks for looking at the video though? 🙂

        Like

  1. Do you know the glitch in which you use dottie to get behind a pipe and switch from 3d to 2d use dottie to get to normal size again and switch back to 3d to clip midway through the ground boundary and switch to Bowser to fully clip out of bounds? After some messing around you really get some really really messed up rendering of the map. How is this map rendered according to your findings?

    Mega Mario Throughout the City at: http://www.mariowiki.com/List_of_Super_Paper_Mario_glitches

    Like

    1. The rendering happens when you are in 2D mode and not in any pane of the map (so you are out of bounds). The game can’t figure out where to center the camera because it’s not in any pane. How it fallbacks to this camera is not much known, but I do know that it’s the reason it’s messed up, it falls back to default camera.

      Like

      1. You mentioned there are three render modes. You showed us a screenshot of render mode 2, I may assume it was with the 3D flag set to false. How does the game acts with render mode 2 and 3d flag set to true?

        Also, my best guess is that render mode 2 turns the camera 180º around the x-axis (putting it behind everything, and upside-down), but renders the front-most objects in the back, like inverting the values on z-axis or something like that. That’s why the houses are not rendered, because they’re being looked by behind, but they’re visible only in one side. The wall of the elevator is still rendered because it is actually a 3D model (and the save block, too), and not a one-side flat object. The NPC is rendered because it is actually visible by both sides (just as Mario). That would explain why also some details (like the plants in the columns and the floor/ceiling details) are not visible, because they’re one-side. Also notice that when in 3D you can see those columns have no plants behind them, just as render mode 2.

        The inversion of the values on the z-axis would be only to explain why the columns and the black square with the red triangle are still on top of the tower.

        TL;DR
        Maybe it just takes the z values of every polygon from render mode 1 and turns the camera 180º around the x-axis (rendering any one-side object invisible and everything upside-down, but keeping their positions in the z-axis)

        It would be nice to try render mode 2 with more complex 3D objects on screen

        Like

      2. Actually, months later than I posted this, I figured it does indeed render the back faces of objects, it’s obvious on top of flipside tower where it renders the doors, but not the pattern on it so the back faces.

        I am not aware of any poitn it coudl be used in game tbh.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s