IOS: Implement MIOS functionality

This implements MIOS's PPC bootstrapping functionality, which enables
users to start a GameCube game from the Wii System Menu.

Because we aren't doing Starlet LLE (and don't have a boot1), we can
just jump to MIOS when the emulated software does an ES_LAUNCH or uses
ioctlv 0x25 to launch BC.

Note that the process is more complex on a real Wii and goes through
several more steps before getting to MIOS:

* The System Menu detects a GameCube disc and launches BC (1-100)
  instead of the game. [Dolphin does this too.]

* BC, which is reportedly very similar to boot1, lowers the Hollywood
  clock speed to the Flipper's and then launches boot2.

* boot2 sees the lowered clock speed and launches MIOS (1-101) instead
  of the System Menu.

MIOS runs instead of IOS in GC mode and has an embedded GC IPL (which
is the code actually responsible for loading the disc game) and a PPC
bootstrap code. To get things working properly, we simply need to load
both to memory, then jump to the bootstrap code at 0x3400.

Obviously, because of the way this works, a real MIOS is required.
This commit is contained in:
Léo Lam 2017-01-28 18:12:05 +01:00
parent 4662e25cbb
commit fdfe57a49b
25 changed files with 362 additions and 67 deletions

View file

@ -156,6 +156,19 @@ static std::string DoState(PointerWrap& p)
return version_created_by;
}
bool is_wii =
SConfig::GetInstance().bWii || SConfig::GetInstance().m_BootType == SConfig::BOOT_MIOS;
const bool is_wii_currently = is_wii;
p.Do(is_wii);
if (is_wii != is_wii_currently)
{
OSD::AddMessage(StringFromFormat("Cannot load a savestate created under %s mode in %s mode",
is_wii ? "Wii" : "GC", is_wii_currently ? "Wii" : "GC"),
OSD::Duration::NORMAL, OSD::Color::RED);
p.SetMode(PointerWrap::MODE_MEASURE);
return version_created_by;
}
// Begin with video backend, so that it gets a chance to clear its caches and writeback modified
// things to RAM
g_video_backend->DoState(p);