mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Core/Boot: Pass System instance to BootUp() and related.
This commit is contained in:
parent
7552deeff4
commit
a164c47caf
@ -413,7 +413,7 @@ bool CBoot::LoadMapFromFilename()
|
||||
// If ipl.bin is not found, this function does *some* of what BS1 does:
|
||||
// loading IPL(BS2) and jumping to it.
|
||||
// It does not initialize the hardware or anything else like BS1 does.
|
||||
bool CBoot::Load_BS2(const std::string& boot_rom_filename)
|
||||
bool CBoot::Load_BS2(Core::System& system, const std::string& boot_rom_filename)
|
||||
{
|
||||
// CRC32 hashes of the IPL file, obtained from Redump
|
||||
constexpr u32 NTSC_v1_0 = 0x6DAC1F2A;
|
||||
@ -463,7 +463,6 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename)
|
||||
// copying the initial boot code to 0x81200000 is a hack.
|
||||
// For now, HLE the first few instructions and start at 0x81200150
|
||||
// to work around this.
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
memory.CopyToEmu(0x01200000, data.data() + 0x100, 0x700);
|
||||
memory.CopyToEmu(0x01300000, data.data() + 0x820, 0x1AFE00);
|
||||
@ -494,14 +493,13 @@ static void SetDefaultDisc()
|
||||
SetDisc(DiscIO::CreateDisc(default_iso));
|
||||
}
|
||||
|
||||
static void CopyDefaultExceptionHandlers()
|
||||
static void CopyDefaultExceptionHandlers(Core::System& system)
|
||||
{
|
||||
constexpr u32 EXCEPTION_HANDLER_ADDRESSES[] = {0x00000100, 0x00000200, 0x00000300, 0x00000400,
|
||||
0x00000500, 0x00000600, 0x00000700, 0x00000800,
|
||||
0x00000900, 0x00000C00, 0x00000D00, 0x00000F00,
|
||||
0x00001300, 0x00001400, 0x00001700};
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
constexpr u32 RFI_INSTRUCTION = 0x4C000064;
|
||||
for (const u32 address : EXCEPTION_HANDLER_ADDRESSES)
|
||||
@ -509,7 +507,7 @@ static void CopyDefaultExceptionHandlers()
|
||||
}
|
||||
|
||||
// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp
|
||||
bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
bool CBoot::BootUp(Core::System& system, std::unique_ptr<BootParameters> boot)
|
||||
{
|
||||
SConfig& config = SConfig::GetInstance();
|
||||
|
||||
@ -525,8 +523,8 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
|
||||
struct BootTitle
|
||||
{
|
||||
BootTitle(const std::vector<DiscIO::Riivolution::Patch>& patches)
|
||||
: config(SConfig::GetInstance()), riivolution_patches(patches)
|
||||
BootTitle(Core::System& system, const std::vector<DiscIO::Riivolution::Patch>& patches)
|
||||
: system(system), config(SConfig::GetInstance()), riivolution_patches(patches)
|
||||
{
|
||||
}
|
||||
bool operator()(BootParameters::Disc& disc) const
|
||||
@ -538,7 +536,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
if (!volume)
|
||||
return false;
|
||||
|
||||
if (!EmulatedBS2(config.bWii, *volume, riivolution_patches))
|
||||
if (!EmulatedBS2(system, config.bWii, *volume, riivolution_patches))
|
||||
return false;
|
||||
|
||||
SConfig::OnNewTitleLoad();
|
||||
@ -557,7 +555,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
SetupMSR();
|
||||
SetupHID(config.bWii);
|
||||
SetupBAT(config.bWii);
|
||||
CopyDefaultExceptionHandlers();
|
||||
CopyDefaultExceptionHandlers(system);
|
||||
|
||||
if (config.bWii)
|
||||
{
|
||||
@ -567,12 +565,12 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
|
||||
// Because there is no TMD to get the requested system (IOS) version from,
|
||||
// we default to IOS58, which is the version used by the Homebrew Channel.
|
||||
SetupWiiMemory(IOS::HLE::IOSC::ConsoleType::Retail);
|
||||
SetupWiiMemory(system, IOS::HLE::IOSC::ConsoleType::Retail);
|
||||
IOS::HLE::GetIOS()->BootIOS(Titles::IOS(58));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupGCMemory();
|
||||
SetupGCMemory(system);
|
||||
}
|
||||
|
||||
if (!executable.reader->LoadIntoMemory())
|
||||
@ -596,7 +594,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
bool operator()(const DiscIO::VolumeWAD& wad) const
|
||||
{
|
||||
SetDefaultDisc();
|
||||
if (!Boot_WiiWAD(wad))
|
||||
if (!Boot_WiiWAD(system, wad))
|
||||
return false;
|
||||
|
||||
SConfig::OnNewTitleLoad();
|
||||
@ -606,7 +604,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
bool operator()(const BootParameters::NANDTitle& nand_title) const
|
||||
{
|
||||
SetDefaultDisc();
|
||||
if (!BootNANDTitle(nand_title.id))
|
||||
if (!BootNANDTitle(system, nand_title.id))
|
||||
return false;
|
||||
|
||||
SConfig::OnNewTitleLoad();
|
||||
@ -625,7 +623,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Load_BS2(ipl.path))
|
||||
if (!Load_BS2(system, ipl.path))
|
||||
return false;
|
||||
|
||||
if (ipl.disc)
|
||||
@ -645,11 +643,12 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
|
||||
}
|
||||
|
||||
private:
|
||||
Core::System& system;
|
||||
const SConfig& config;
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches;
|
||||
};
|
||||
|
||||
if (!std::visit(BootTitle(boot->riivolution_patches), boot->parameters))
|
||||
if (!std::visit(BootTitle(system, boot->riivolution_patches), boot->parameters))
|
||||
return false;
|
||||
|
||||
DiscIO::Riivolution::ApplyGeneralMemoryPatches(boot->riivolution_patches);
|
||||
|
@ -19,6 +19,11 @@
|
||||
#include "DiscIO/VolumeDisc.h"
|
||||
#include "DiscIO/VolumeWad.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace File
|
||||
{
|
||||
class IOFile;
|
||||
@ -143,7 +148,7 @@ struct BootParameters
|
||||
class CBoot
|
||||
{
|
||||
public:
|
||||
static bool BootUp(std::unique_ptr<BootParameters> boot);
|
||||
static bool BootUp(Core::System& system, std::unique_ptr<BootParameters> boot);
|
||||
|
||||
// Tries to find a map file for the current game by looking first in the
|
||||
// local user directory, then in the shared user directory.
|
||||
@ -166,24 +171,24 @@ private:
|
||||
|
||||
static void UpdateDebugger_MapLoaded();
|
||||
|
||||
static bool Boot_WiiWAD(const DiscIO::VolumeWAD& wad);
|
||||
static bool BootNANDTitle(u64 title_id);
|
||||
static bool Boot_WiiWAD(Core::System& system, const DiscIO::VolumeWAD& wad);
|
||||
static bool BootNANDTitle(Core::System& system, u64 title_id);
|
||||
|
||||
static void SetupMSR();
|
||||
static void SetupHID(bool is_wii);
|
||||
static void SetupBAT(bool is_wii);
|
||||
static bool RunApploader(bool is_wii, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches);
|
||||
static bool EmulatedBS2_GC(const DiscIO::VolumeDisc& volume,
|
||||
static bool EmulatedBS2_GC(Core::System& system, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches);
|
||||
static bool EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume,
|
||||
static bool EmulatedBS2_Wii(Core::System& system, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches);
|
||||
static bool EmulatedBS2(bool is_wii, const DiscIO::VolumeDisc& volume,
|
||||
static bool EmulatedBS2(Core::System& system, bool is_wii, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches);
|
||||
static bool Load_BS2(const std::string& boot_rom_filename);
|
||||
static bool Load_BS2(Core::System& system, const std::string& boot_rom_filename);
|
||||
|
||||
static void SetupGCMemory();
|
||||
static bool SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type);
|
||||
static void SetupGCMemory(Core::System& system);
|
||||
static bool SetupWiiMemory(Core::System& system, IOS::HLE::IOSC::ConsoleType console_type);
|
||||
};
|
||||
|
||||
class BootExecutableReader
|
||||
|
@ -211,9 +211,8 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::VolumeDisc& volume,
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBoot::SetupGCMemory()
|
||||
void CBoot::SetupGCMemory(Core::System& system)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// Booted from bootrom. 0xE5207C22 = booted from jtag
|
||||
@ -251,18 +250,16 @@ void CBoot::SetupGCMemory()
|
||||
// GameCube Bootstrap 2 HLE:
|
||||
// copy the apploader to 0x81200000
|
||||
// execute the apploader, function by function, using the above utility.
|
||||
bool CBoot::EmulatedBS2_GC(const DiscIO::VolumeDisc& volume,
|
||||
bool CBoot::EmulatedBS2_GC(Core::System& system, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches)
|
||||
{
|
||||
INFO_LOG_FMT(BOOT, "Faking GC BS2...");
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
|
||||
SetupMSR();
|
||||
SetupHID(/*is_wii*/ false);
|
||||
SetupBAT(/*is_wii*/ false);
|
||||
|
||||
SetupGCMemory();
|
||||
SetupGCMemory(system);
|
||||
|
||||
// Datel titles don't initialize the postMatrices, but they have dual-texture coordinate
|
||||
// transformation enabled. We initialize all of xfmem to 0, which results in everything using
|
||||
@ -332,7 +329,7 @@ static DiscIO::Region CodeRegion(char c)
|
||||
}
|
||||
}
|
||||
|
||||
bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
|
||||
bool CBoot::SetupWiiMemory(Core::System& system, IOS::HLE::IOSC::ConsoleType console_type)
|
||||
{
|
||||
static const std::map<DiscIO::Region, const RegionSetting> region_settings = {
|
||||
{DiscIO::Region::NTSC_J, {"JPN", "NTSC", "JP", "LJH"}},
|
||||
@ -420,7 +417,6 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// Write the 256 byte setting.txt to memory.
|
||||
@ -504,7 +500,7 @@ static void WriteEmptyPlayRecord()
|
||||
// Wii Bootstrap 2 HLE:
|
||||
// copy the apploader to 0x81200000
|
||||
// execute the apploader
|
||||
bool CBoot::EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume,
|
||||
bool CBoot::EmulatedBS2_Wii(Core::System& system, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches)
|
||||
{
|
||||
INFO_LOG_FMT(BOOT, "Faking Wii BS2...");
|
||||
@ -524,7 +520,6 @@ bool CBoot::EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume,
|
||||
state->discstate = 0x01;
|
||||
});
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
|
||||
// The system menu clears the RTC flags.
|
||||
@ -547,7 +542,7 @@ bool CBoot::EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume,
|
||||
const u64 ios = ios_override >= 0 ? Titles::IOS(static_cast<u32>(ios_override)) : tmd.GetIOSId();
|
||||
|
||||
const auto console_type = volume.GetTicket(data_partition).GetConsoleType();
|
||||
if (!SetupWiiMemory(console_type) || !IOS::HLE::GetIOS()->BootIOS(ios))
|
||||
if (!SetupWiiMemory(system, console_type) || !IOS::HLE::GetIOS()->BootIOS(ios))
|
||||
return false;
|
||||
|
||||
auto di =
|
||||
@ -589,9 +584,9 @@ bool CBoot::EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume,
|
||||
|
||||
// Returns true if apploader has run successfully. If is_wii is true, the disc
|
||||
// that volume refers to must currently be inserted into the emulated disc drive.
|
||||
bool CBoot::EmulatedBS2(bool is_wii, const DiscIO::VolumeDisc& volume,
|
||||
bool CBoot::EmulatedBS2(Core::System& system, bool is_wii, const DiscIO::VolumeDisc& volume,
|
||||
const std::vector<DiscIO::Riivolution::Patch>& riivolution_patches)
|
||||
{
|
||||
return is_wii ? EmulatedBS2_Wii(volume, riivolution_patches) :
|
||||
EmulatedBS2_GC(volume, riivolution_patches);
|
||||
return is_wii ? EmulatedBS2_Wii(system, volume, riivolution_patches) :
|
||||
EmulatedBS2_GC(system, volume, riivolution_patches);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "Core/WiiUtils.h"
|
||||
#include "DiscIO/VolumeWad.h"
|
||||
|
||||
bool CBoot::BootNANDTitle(const u64 title_id)
|
||||
bool CBoot::BootNANDTitle(Core::System& system, const u64 title_id)
|
||||
{
|
||||
UpdateStateFlags([](StateFlags* state) {
|
||||
state->type = 0x04; // TYPE_NANDBOOT
|
||||
@ -28,16 +28,16 @@ bool CBoot::BootNANDTitle(const u64 title_id)
|
||||
console_type = ticket.GetConsoleType();
|
||||
else
|
||||
ERROR_LOG_FMT(BOOT, "No ticket was found for {:016x}", title_id);
|
||||
SetupWiiMemory(console_type);
|
||||
SetupWiiMemory(system, console_type);
|
||||
return es->LaunchTitle(title_id);
|
||||
}
|
||||
|
||||
bool CBoot::Boot_WiiWAD(const DiscIO::VolumeWAD& wad)
|
||||
bool CBoot::Boot_WiiWAD(Core::System& system, const DiscIO::VolumeWAD& wad)
|
||||
{
|
||||
if (!WiiUtils::InstallWAD(*IOS::HLE::GetIOS(), wad, WiiUtils::InstallType::Temporary))
|
||||
{
|
||||
PanicAlertFmtT("Cannot boot this WAD because it could not be installed to the NAND.");
|
||||
return false;
|
||||
}
|
||||
return BootNANDTitle(wad.GetTMD().GetTitleId());
|
||||
return BootNANDTitle(system, wad.GetTMD().GetTitleId());
|
||||
}
|
||||
|
@ -585,7 +585,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||
if (SConfig::GetInstance().bWii)
|
||||
savegame_redirect = DiscIO::Riivolution::ExtractSavegameRedirect(boot->riivolution_patches);
|
||||
|
||||
if (!CBoot::BootUp(std::move(boot)))
|
||||
if (!CBoot::BootUp(system, std::move(boot)))
|
||||
return;
|
||||
|
||||
// Initialise Wii filesystem contents.
|
||||
|
Loading…
Reference in New Issue
Block a user