Before you start reading this thread, I encourage you to take a quick look at SM64MainLevelScripts.txt, as this is the relevante file if you want to understand it. The main SM64 Hacking Doc included in TT64 is also a must, and the "level_commands.txt" file from Cellar Dweller's Hacking Notes contains some additional information.
Level scripts in SM64 are responsible for a lot of things, not just initializing the levels but also the menus and intro screen. The fact that almost all of the major commands are already documented makes SM64 a very interesting game to hack, because you don't need direct contact with the code itself to make some interesting things.
The first relevant Level Script is found at 269EA0-26A3A0 and loaded to RAM Segment 0x14. Let's take a look at the first code:
269EA4/0004: 16 10 00 00 80 16 F0 00 00 21 F4 C0 00 26 9E A0 --Loads ASM code into RAM at 8016F000
269EB4/0014: 17 0C 00 13 00 21 9E 00 00 21 F4 C0 --Loads Behavior Scripts into segment 0x13
269EC0/0020: 17 0C 00 07 00 AE D7 14 00 AF A0 54 --Loads MIO0 data in current level segment, 0x07 (18 0C 00 07 00 26 A3 A0 00 26 F4 20 in compressed ROM)
269ECC/002C: 1D 04 00 00
269ED0/0030: 1F 08 01 00 14 00 02 D0 --Points to Geometry Layout script for menus. (In levels, used to point to the main level Geometry Layout)
269ED8/0038: 20 04 00 00 --Usually means end of area in a normal level script.
This is the first intro screen code. The part that interest us are the Banks loaded with command 0x17 (Load uncompressed data). A ROM Bank is block of data loaded into a RAM segment identified by an ID number (the fourth byte of the 0x17 command). While the Bank ID is an arbitrary number, there is a consistent pattern used in the game. Bank 0x0E holds level scripts, Bank 0x09 Level textures, Bank 0x0A Background textures, Bank 0x07 Polygons/Animation/Collision, Banks 0x05, 0x06 and 0x08 usually contains the objects used in each level.
If you want to try a simple hack, go to the Bank 0x07 for this first menu and nope (replace with 0's) all the vertex data from AED714 to AF55A5. You have erased the "Super Mario 64" polygons from the intro screen.
The next command of interest is the Geometry Layout pointer:
1F 08 01 00 14 00 02 D0 = Offset 0x2D0 of Bank 0x14 = 0x2D0 + 269EA0 = 26A170 - This is the Geo Layout JUST for the first screen.
There are still some undocumented Geo Layout commands, but here are the main ones for this menu:
0800 0000 00A0 0078 00A0 0078 <-- Initializes the display Width/Height ?
1800 0000 8016 F670
1800 0000 8016 F984
The 0x18 command is used to load things directly from the RAM, not polygon data like the 0x15 one, but instead it points to ASM. Sometimes it is used to load water/lava polygons and if I'm not mistaken even regular ones in the Castle Grounds. The third and fourth byte sometimes provides arguments, which probably will be interpreted by the ASM loaded. Sometimes it seems to be the Drawing Layer, but other times it seems very different.
I can't do much for this screen so lets move on with the level script. Here are other Geo Layout pointers:
1F 08 01 00 14 00 03 5C -> Second Screen (press start) Geo Layout
In this second screen Geo Layout, there are two 0x18 commands
18 00 00 00 80 16 FE 70 - ??
18 00 00 02 80 27 64 B0 - Places Mario Face on screen
If you want to get rid of Mario's face, get rid of that second 0x18 command. Here is a way to nope 0x18 commands: if you just fill with 0's, the game will crash, so instead you just replace it with the first one. You can also try changing that 0x18 with the following:
1F 08 01 00 14 00 03 B8 -> Game Over Geo Layout
18 00 00 00 80 16 FF FC - Place Game Over GFX at BG
Another interesting thing in main level script is the list of 0x00 "Load script commands". This is very important if you want to extend the level script you are working with. Also, you may want to try changing it (or the conditionals above) so that the first level loaded is not the Castle Grounds but something else. It turns out that the first camera animation / letter is not loaded in the Castle Grounds level script, but somewhere else before the "New game" starts.
So, there are just some ideas. Maybe in the future we can change the very beginning of these level scrips to load something else . |