redolution / gekkoboot

A utilitarian bootloader for the GameCube
GNU General Public License v2.0
123 stars 22 forks source link

outdated: Add support for config file #24

Closed yo1dog closed 2 years ago

yo1dog commented 2 years ago

This is a big one. I split it into multiple small commits that are hopefully easier to follow than the massive final diff.

The INI config file allows the user to specify an action for each shortcut, including the default shortcut when no button is held. The action can be a path to a DOL, ONBAORD which reboots into onboard IPL, or USBGECKO. User can also specify CLI args and set the debug flag.

If a config file is found, iplboot will operate as configured. Otherwise, the "legacy" behavior will be used and a file matching the held button will be search for (or ipl.dol if no button is held).

Debug mode as replaced the holding of D-Down to delay exit. Now holding D-Down on boot will enable debug mode which both increases verbosity and prompts user at various points to allow reading of the diagnostic messages.

As discussed, USB gecko has been moved to lowest priority. This allows users with this device to leave them plugged in without it stalling iplboot. Instead, a config file can explicitly instruct their use via the USBGECKO action.

You can now build dolphin to create a DOL compatible with the Dolphin emulator (and Wii, presumably). This allows one to test using Dolphin and its Wii virtual SD card feature on PC. Much faster than swapping SD cards for those without proper dev hardware. Careful: make sure you clean before switching.

9ary commented 2 years ago

High level comment: I think with the config file it would make sense to deprecate the hardcoded filenames entirely (with the exception of ipl.dol as a fallback, only if a config file is not found). That ought to simplify the code a bit.

I haven't looked, but I would also expect that holding a configured shortcut would just halt with an error when failing to load the associated file.

Finally, I think booting the stock IPL could be its own action rather than a hardcoded button.

yo1dog commented 2 years ago

High level comment: I think with the config file it would make sense to deprecate the hardcoded filenames entirely (with the exception of ipl.dol as a fallback, only if a config file is not found). That ought to simplify the code a bit.

I did not want to break existing setups by removing hardcoded filename shortcuts. As far as simplifying, it would certainly simplify the documentation (although we could simply bury/remove legacy behaviors from documentation). As far as code, it would only remove ~10 lines or so if we kept support for ipl.dol. These lines:

https://github.com/yo1dog/iplboot/blob/3a59f1ce1041ed0a8230302dfdc7340aa24cfcd0/source/main.c#L280-L294

could be simplified to:

u8 *dol_file = NULL;
if (!read_dol_file(&dol_file, "ipl.dol"))
{
    return 1;
}

Either way, you are still looking for the config file first then some hardcoded file second. ipl.dol vs [button].dol is trivial.

I haven't looked, but I would also expect that holding a configured shortcut would just halt with an error when failing to load the associated file.

As currently programmed, if a config file is found, and a DOL shortcut is defined for the held button, and that DOL fails to load, an error is shown and the user is prompted to continue. However, holding a button for which there is no configured shortcut is not considered an error.

Finally, I think booting the stock IPL could be its own action rather than a hardcoded button.

Currently, it's both. You can use D-Left as a high-level skip which causes iplboot to not attempt to load anything. You can also configure a shortcut action to ONBOARD which reboots into onboard IPL. My arguments for keeping the former are: A) Can be a useful catch-all in edge cases. B) It is documented production behavior. But I could be easily convinced of axing it.

9ary commented 2 years ago

We can start by deprecating the hardcoded paths and removing the documentation. Actual support can be axed later on.

As currently programmed, if a config file is found, and a DOL shortcut is defined for the held button, and that DOL fails to load, an error is shown and the user is prompted to continue. However, holding a button for which there is no configured shortcut is not considered an error.

That's exactly how it should be. :+1:

Currently, it's both. You can use D-Left as a high-level skip which causes iplboot to not attempt to load anything. You can also configure a shortcut action to ONBOARD which reboots into onboard IPL. My arguments for keeping the former are: A) Can be a useful catch-all in edge cases. B) It is documented production behavior. But I could be easily convinced of axing it.

That's fine. I'm not sure I like the name ONBOARD, but it's not very important.

yo1dog commented 2 years ago

I have started breaking this out into several PRs. First one is here: #28

yo1dog commented 2 years ago

I'm not sure I like the name ONBOARD.

Neither am I. Need a succinct way to refer to the original IPL on the GC.

9ary commented 2 years ago

I'm closing this since it's been superseded by the split up pull requests.