• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

Meta NTSC 1.02.02 - Expanded DOL (More space for custom codes!)

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Not long ago I updated DTW to be able to import differently sized DOL files. A small update, and a small feature (though not so simple as replacing other differently sized files), but not a small deal! Here's an example of how this can be useful; creating a DOL with more codespace.


Update: The original file that I uploaded, NTSC 1.02.01, had an error in it (Data 8's RAM offset was incorrect). While it worked on Dolphin, it did not work on console. This has been fixed and tested, and works on both emulator and hardware.

Currently, out of 0x438500 bytes of code in the original NTSC 1.02 DOL, we have defined a bit more than 0x114B0 bytes of it as "free space". That is, codespace that's [as far as we know] safe to be overwritten for custom code. (I'm not counting the space CrazyHand uses in that number, since the end point of the region it overwrites is not set.) This is how much space you would currently have available in MCM if you enable all of the default custom code regions. The DOL above has been expanded to accommodate 0xE900 more bytes of free space for custom code, for a new total of 0x1FDB0 bytes of space. That's 84% more codespace for us to use!

Conceivably we could also shrink the DOL, to reduce the game boot time. But the amount of space we currently have defined as "free" is only a few percent of the total size of the file, which wouldn't make for a big difference if we removed it.

This is not compatible with versions of MCM before 4.0. Making further iterations of this such as to add more space might be possible, but I'll go into that at the end of the Documentation section below.

This file has been planned for, so this space will already automatically show up in MCM's Code-Space Options menu when this DOL is loaded, as "Gecko Code Handler Storage" and "Gecko Code List Storage". This is because, if you use Gecko codes, I recommend changing the save locations for those to use these new areas, since both of those items are relatively large and must be contiguous.

To change the save locations for those items, so that they're stored in the new regions of this DOL when Gecko codes are used, open the settings.py file, found in the root directory of MCM. You can open it in any standard text editor. Scroll most of the way down to about line 116, where you should see some Gecko configuration info. Here you can specify the name of the region to store the codelist/codehandler in. So change,
"'codelistRegion': 'Tournament Mode Region'," to "'codelistRegion': 'Gecko Code List Storage'," and change,
"'codehandlerRegion': 'Aux Code Regions'" to "'codehandlerRegion': 'Gecko Code Handler Storage'".

And that it. You now have space for 37% more Gecko codes, plus, the space that was taken by those before can now be used for standard injection mods.

And again, this is merely recommendation, and you could instead rename those regions if you'd like (all of the names are defined in the settings.py file), or even combine them to be one. In any case, if you don't have any Gecko codes selected and/or don't plan to use them, then the codelist and codehandler won't be added to the DOL, and all regions will be used for normal custom code as usual.

Documentation:

Perhaps besides the fact that it's written in assembly, the DOL is a pretty simple and straitforward dude. As probably most of you know at this point, the DOL is the main game executable, and contains the game's functions and logic. But it does have a small quirk, which is one of the reasons things like adding code injections, doing branch calculations, or converting codes to other game versions manually used to be such a pain. The quirk is that it's not loaded into RAM as one 1:1 block of code. Before the DOL is loaded, the first thing that the GameCube IPL (Initial Program Loader) runs on the game disc is the Apploader. Part of what that does is break up the DOL file a bit and place each section into various places in RAM, before it then hands execution off to it. The locations are defined in the DOL, and vary for different games.

For Melee, if you've ever wondered how the DOL is distributed in RAM, it's this:

cluster_Start (Vanilla NTSC 1.02).dol_graph_source.gv.png

This was created by a script I wrote, which you can download here. Should work for almost any GameCube/Wii game; just drag-and-drop your DOL onto the batch file and it will create a png (or you can edit the python script to create an svg). So far, I've noticed that other games have similar section patterns, with different sizes and start/end locations.
New section highlighted in green.
cluster_NTSC 1.02.01.dol_graph_source.gv.png

So basically I just defined a new region in the file header to follow immediately after the last vanilla region. I tried adding a larger area at first, but I found that, even though it appeared to have loaded fine, the area was soon later overwritten in RAM by other things. The apploader and the SDK both define the upper limit to usable RAM space for the DOL (DOL_ADDRESS_LIMIT) as 0x80700000. But I saw RAM being overwritten well before that (and I don't remember it being the BSS section). The section I've defined in this current file I observed as OK after booting the game and loading some matches in some 1 Player & VS. modes.

Update: The original file that I uploaded, NTSC 1.02.01, had an error in it (Data 8's RAM offset was incorrect). While it worked on Dolphin, it did not work on console. I haven't retested larger DOL areas yet, so I don't know if the problem I mention above is still relavant. Please let me know if you test this, so I can update this post.

I'm not sure what exactly is "reserving" the space where the DOL is being placed, or how the system knows not to place anything into where the DOL will be, but I know there's a global __OSDOLSize that the Apploader sets. I haven't double-checked it, but logically that should be correct even for this custom DOL, since its new section is built exactly as a real one would be.

If we figure out more about this, we could most likely load even larger DOLs. We don't want to go too crazy with it though, if we care about loading times. The SDK, in "Nintendo GameCube Optical Disc Drive Guidelines Version 1.41.pdf", section 5.3, says that the recommended size limit is 4 MB, to help curb loading times, and vanilla Melee is already 4.21 MB (now 4.27 with this). It also says 'the total section size must be less than 4 Mbytes', but that doesn't appear to actually be true/necessary, at least in terms of loading the file. The apploader checks the DOL size when loading it, and compares its size to a variable called "dolLimit", which is in 'DVD Boot Info' (the DVDBI2 struct) which I believe comes from the Bi2.bin file on the disc, as part of the disc header. In there, as with everything else, the variable appears to be just 0. Maybe the struct is different when in-RAM than when in-file. In this case, zero means unlimited, so I don't think the apploader cares how big the DOL is, as long as it doesn't go beyond that huge upper limit.
 
Last edited:

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Here's a file you guys can play with for 20XX 4.07++. The extra Data 8 section described above has been added to it.

Start - 1.02.02 for 20XX 4.07++ (Expanded).dol

Edit: Fixed Data8's RAM address. Still haven't tested this specific file on Dolphin or console though, so if anyone else does, let me know and I'll update this post.

This is just a quick edit I made for some others, so I haven't tested it. But I thought I would share in case anyone else is interested. Please refer to the spoiler in the OP titled, 'Using this codespace in MCM 4+', if you'd like to try it with Gecko codes.
 
Last edited:

TDRR

Smash Journeyman
Joined
Sep 18, 2017
Messages
286
Location
Venezuela
Can i just throw in injection/static overwrite DOL mods and they will take advantage of this space or is it only Gecko codes?

The reason being that i don't want to remove/break any original game functionality (Right now i'm only overwriting the screenshots region) nor interfere with other mods (such as 20XXTE) installing a gecko codehandler, as in the mod i'm doing, 100% compatibility is top priority.

EDIT: I tried using it for DOL mods and i just got a black screen.
What does the aux code region contain? If it's no real functionality then i suppose i can switch to that region instead of overwriting the screenshot mode.
 
Last edited:

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Can i just throw in injection/static overwrite DOL mods and they will take advantage of this space or is it only Gecko codes?

The reason being that i don't want to remove/break any original game functionality (Right now i'm only overwriting the screenshots region) nor interfere with other mods (such as 20XXTE) installing a gecko codehandler, as in the mod i'm doing, 100% compatibility is top priority.

EDIT: I tried using it for DOL mods and i just got a black screen.
What does the aux code region contain? If it's no real functionality then i suppose i can switch to that region instead of overwriting the screenshot mode.
You can configure MCM to use or avoid whatever regions you want, for which types of code you want, by editing the settings.py file. There are some explanations in there, and the formatting to define new regions should be easy to figure out by looking at the default regions. Note that each region must have a unique name. Below the region definitions, you'll see a section called "geckoConfiguration". The values given for "codelistRegion" and "codehandlerRegion" tell MCM where to place the list of Gecko codes and the Gecko codehandler, respectively, using the region names you've defined. If you don't want anything regarding Gecko codes to be installed there, you can change those back to the usual defaults of 'codelistRegion': 'Tournament Mode Region' and 'codehandlerRegion': 'Aux Code Regions'.

Aux Code Regions are some areas containing text that was probably used by the developers to help debug the game. So if you want UnclePunch's Enable OSReport Print on Crash code, I believe you'll need to leave the Aux Code Regions intact.

But you may not need to do anything; I should point out that the Gecko codelist and codehandler are only added to the game if some Gecko codes are actually selected for installation when you hit save. And whether or not they are, any space left over in the regions the codelist/codehandler are assigned to will also be used for injection code, if needed. (MCM will first try to use space starting from the "top" (i.e. lowest offset regions) of the free space, and work its way down.)

It's safest to only deselect/remove regions in the Code-Space Options if you've first uninstalled any mods that are even partially installed to them. Otherwise, you could create "phantom mods", which are to some extent installed, but will no longer be detected as installed during subsequent scans for installed mods (naturally, a mod in that state would then be uninstalled the next time you tried to save, since it thinks it shouldn't be.) You can use the Summary tab to check where mods' custom code is installed to. (Enabling/adding regions however shouldn't cause any problems.) I may add safeguards for this at some point, but for now, another -and perhaps simpler- workaround if you need to remove regions from use, could be to just start with a fresh, unmodified DOL (since you'll know there are no mods installed anywhere in it) and add your mods to that. Keep in mind you can use the 'Create Installed Mods List / Install Mods List' features to quickly install a specific set of mods to a disc or DOL.
 

dreamsyntax

Smash Rookie
Joined
Aug 3, 2019
Messages
7
Does MCM explicitly check the header? I'm trying to extend a DOL with a similar process, but MCM does not recognize the extended regions set in settings.py.
 

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
Does MCM explicitly check the header? I'm trying to extend a DOL with a similar process, but MCM does not recognize the extended regions set in settings.py.
Yeah, it does parse the header to determine the sections. Do you mean that the new regions aren't showing up in the Code-Space Options window?

There's a way you can check exactly what regions MCM is recognizing. Run the executable with a '-d' or '--debugMode' argument to run the program in debug mode. Then when you load a file in the program, a text file called "Debug Log.txt" will be generated in the same directory as the program executable. Open that, and you should see some information describing the sections, plus some other info and any error messages.
 

dreamsyntax

Smash Rookie
Joined
Aug 3, 2019
Messages
7
Does doing this create incompatibility with real hardware? I'm able to expand a DOL and use the space successfully on Dolphin, but can't boot on hardware.
 

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
Does doing this create incompatibility with real hardware? I'm able to expand a DOL and use the space successfully on Dolphin, but can't boot on hardware.
Have you made other room on disc? The disc still has a file size limit, so you'd need to make room by removing another file.
 

dreamsyntax

Smash Rookie
Joined
Aug 3, 2019
Messages
7
Have you made other room on disc? The disc still has a file size limit, so you'd need to make room by removing another file.
I have lots of modification on the disc which makes the total ISO smaller than original. It boots fine with the changes so long as I don't use the expanded DOL.
I have confirmed the issue is if I use the expanded DOL.

I find it odd it works fine on Dolphin yet not Nintendont with the added 0x1000 bytes.
 
Last edited:

DRGN

Technowizard
Moderator
Joined
Aug 20, 2005
Messages
2,178
Location
Sacramento, CA
I have lots of modification on the disc which makes the total ISO smaller than original. It boots fine with the changes so long as I don't use the expanded DOL.
I have confirmed the issue is if I use the expanded DOL.

I find it odd it works fine on Dolphin yet not Nintendont with the added 0x1000 bytes.
I'm sad it took me so long to get back to this issue, but DIOS MIOS and Nintendont haven't been working on my Wii at all for a while. I finally borrowed a different Wii though so I could test, and I found the problem. Basically it was just one missed byte in this DOL file; the byte at 0x84 is 00, and should have been 80. I.e. the first byte of the RAM address for Data8 didn't account for the 0x80000000 base address. I've uploaded a fixed file and linked it in the OP. I've tested it, and it works on both Dolphin and console.

This could also potentially explain why I was having weird issues with adding larger DOL sections. So the area may be able to made bigger, but more testing would be needed. I will probably not be coming back to this for a while, so if anyone else is interested, go for it. As I mentioned in the OP, I so far haven't been working beyond any hard limits to the DOL's size that I know of. I'd definitely be interested to hear others more knowledgeable than myself on file loading and RAM usage shed some light on theoretical limitations, or explain why I saw RAM being overwritten well before the apploader's DOL_ADDRESS_LIMIT. My only guess atm is that because that RAM offset was off, that area wasn't actually being properly reserved. Though, back when I made this, I feel like for sure I had tested the new area with some injection codes, and did see the injected code being copied to the correct in place in RAM. Could be I'm misremembering, or it was with a different copy of the file that didn't have this error.
 
Last edited:
Top Bottom