shibboleet's Blog — The Infamous Kinoko

Overview
Super Mario Galaxy was released in 2007 for the Nintendo Wii and has been a favorite of many. The game has one of the nicest codebases that I have seen in a Super Mario game. Obviously, with a game like Super Mario Galaxy, it should not be surprising that the codebase is also complicated. One of the more interesting areas of the game is the file and memory management. The way that this is structured allows us to better understand a oddly specific game crash. Without further ado...let's get into it!

The File

Super Mario Galaxy stores all of the object archives in the game inside of a folder named ObjectData. Inside of these archives contains various assets such as models, animations, textures, leftover files, and more. However, there is one specific archive that caught people's eyes: /ObjectData/Kinoko.arc. Here are the contents of that file:
While not the most interesting file, it just contains three files. One of them is the model itself (Kinoko.bdl) and the other two are animations (Appear.bck and Land.bck). Here is the model of the object:

So, what exactly was the use of this file? From an Iwata Asks interview, the following is stated:

So according to this interview, the Mushroom model was most likely the model that was used in place of Mario while Super Mario Galaxy was in development. So, what exactly is the crash?

The Crash

The crash is simple to replicate. You simply just delete the archive /ObjectData/Kinoko.arc from the disc, and start the game. The game will crash immediately. So, what exactly causes it?

The Cause

Super Mario Galaxy has a system called a StationedArchiveLoader. This loader is responsible for loading specific archives using specific heaps at the game's start. All of these archives are consolidated into a table defined as such:

  • mHeapType is the type of heap to use when loading the object (0 = NAPA - which is a chip on the Wii's MCM, 1 = GDDR3 - Graphics card memory)
  • mLoadType is the way that the archive is loaded. Values of 0 are loaded straight into the main RAM, where types 1-5 are only mounted.
  • mArchiveName is a string consisting of the name of the archive to load.
So, if we look into the archive table itself:

There it is! The cause of the crash is simple to explain once we look into how the StationedArchiveLoader loads the archives. Let's take a look:

The crash is caused by the game attempting to load the archive without checking if it exists or not. So this was likely a leftover when the Mushroom was a playable character over Mario in the early stages of development of Super Mario Galaxy, and they simply forgot to take it out, and it sat on the disc. Interestingly, the file even made it over to Super Mario Galaxy 2, and remained in the StationedArchiveLoader table, so that game also crashes when the file is removed.

Conclusion

In conclusion, the crash is caused by the archive loader failing to check if the file exists before attempting to load it into main RAM or mounting it. However, it is very easy to see how they did not worry about this because these archives were specifically chosen to be loaded because it is easier to load them once at game start instead of loading them when they are needed. Thanks for reading!
© 2019-2023 shibboleet