2013-04-17 22:43:11 -04:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2008-12-09 14:57:55 +00:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-07 20:06:58 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/Hash.h"
|
|
|
|
#include "Common/MathUtil.h"
|
|
|
|
#include "Common/StringUtil.h"
|
|
|
|
|
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/PatchEngine.h"
|
|
|
|
#include "Core/VolumeHandler.h"
|
|
|
|
#include "Core/Boot/Boot.h"
|
|
|
|
#include "Core/Boot/Boot_DOL.h"
|
|
|
|
#include "Core/Debugger/Debugger_SymbolMap.h"
|
|
|
|
#include "Core/HLE/HLE.h"
|
|
|
|
#include "Core/HW/DVDInterface.h"
|
|
|
|
#include "Core/HW/EXI_DeviceIPL.h"
|
|
|
|
#include "Core/HW/Memmap.h"
|
|
|
|
#include "Core/HW/ProcessorInterface.h"
|
|
|
|
#include "Core/HW/VideoInterface.h"
|
|
|
|
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
|
|
|
#include "Core/PowerPC/PPCAnalyst.h"
|
|
|
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
|
|
|
#include "Core/PowerPC/SignatureDB.h"
|
|
|
|
|
|
|
|
#include "DiscIO/NANDContentLoader.h"
|
2014-02-19 13:09:14 -05:00
|
|
|
#include "DiscIO/VolumeCreator.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
void CBoot::Load_FST(bool _bIsWii)
|
|
|
|
{
|
2013-04-16 23:14:36 -04:00
|
|
|
if (!VolumeHandler::IsValid())
|
|
|
|
return;
|
2010-04-08 16:59:35 +00:00
|
|
|
|
|
|
|
// copy first 20 bytes of disc to start of Mem 1
|
2013-10-29 01:23:17 -04:00
|
|
|
VolumeHandler::ReadToPtr(Memory::GetPointer(0x80000000), 0, 0x20);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
// copy of game id
|
|
|
|
Memory::Write_U32(Memory::Read_U32(0x80000000), 0x80003180);
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
u32 shift = 0;
|
|
|
|
if (_bIsWii)
|
|
|
|
shift = 2;
|
|
|
|
|
|
|
|
u32 fstOffset = VolumeHandler::Read32(0x0424) << shift;
|
|
|
|
u32 fstSize = VolumeHandler::Read32(0x0428) << shift;
|
|
|
|
u32 maxFstSize = VolumeHandler::Read32(0x042c) << shift;
|
|
|
|
|
2012-04-23 00:38:58 -07:00
|
|
|
u32 arenaHigh = ROUND_DOWN(0x817FFFFF - maxFstSize, 0x20);
|
2010-04-08 16:59:35 +00:00
|
|
|
Memory::Write_U32(arenaHigh, 0x00000034);
|
|
|
|
|
|
|
|
// load FST
|
|
|
|
VolumeHandler::ReadToPtr(Memory::GetPointer(arenaHigh), fstOffset, fstSize);
|
|
|
|
Memory::Write_U32(arenaHigh, 0x00000038);
|
2012-04-23 00:38:58 -07:00
|
|
|
Memory::Write_U32(maxFstSize, 0x0000003c);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-03-23 17:19:12 -04:00
|
|
|
void CBoot::UpdateDebugger_MapLoaded()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
Host_NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
bool CBoot::FindMapFile(std::string* existing_map_file,
|
|
|
|
std::string* writable_map_file)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2013-09-12 01:02:41 +02:00
|
|
|
std::string title_id_str;
|
2014-09-07 00:56:10 -04:00
|
|
|
size_t name_begin_index;
|
2013-09-12 01:02:41 +02:00
|
|
|
|
2009-02-22 23:36:13 +00:00
|
|
|
SCoreStartupParameter& _StartupPara = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
|
|
|
switch (_StartupPara.m_BootType)
|
|
|
|
{
|
2010-04-08 16:59:35 +00:00
|
|
|
case SCoreStartupParameter::BOOT_WII_NAND:
|
|
|
|
{
|
2013-09-12 01:02:41 +02:00
|
|
|
const DiscIO::INANDContentLoader& Loader =
|
|
|
|
DiscIO::CNANDContentManager::Access().GetNANDLoader(_StartupPara.m_strFilename);
|
2010-04-08 16:59:35 +00:00
|
|
|
if (Loader.IsValid())
|
|
|
|
{
|
|
|
|
u64 TitleID = Loader.GetTitleID();
|
2013-09-12 01:02:41 +02:00
|
|
|
title_id_str = StringFromFormat("%08X_%08X",
|
|
|
|
(u32)(TitleID >> 32) & 0xFFFFFFFF,
|
|
|
|
(u32)TitleID & 0xFFFFFFFF);
|
2010-04-08 16:59:35 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-03-04 19:13:51 +00:00
|
|
|
|
2009-02-22 23:36:13 +00:00
|
|
|
case SCoreStartupParameter::BOOT_ELF:
|
|
|
|
case SCoreStartupParameter::BOOT_DOL:
|
2014-09-07 00:56:10 -04:00
|
|
|
// Strip the .elf/.dol file extension and directories before the name
|
|
|
|
name_begin_index = _StartupPara.m_strFilename.find_last_of("/") + 1;
|
|
|
|
if ((_StartupPara.m_strFilename.find_last_of("\\") + 1) > name_begin_index)
|
|
|
|
{
|
|
|
|
name_begin_index = _StartupPara.m_strFilename.find_last_of("\\") + 1;
|
|
|
|
}
|
2013-09-12 01:02:41 +02:00
|
|
|
title_id_str = _StartupPara.m_strFilename.substr(
|
2014-09-07 00:56:10 -04:00
|
|
|
name_begin_index, _StartupPara.m_strFilename.size() - 4 - name_begin_index);
|
2013-09-12 01:02:41 +02:00
|
|
|
break;
|
|
|
|
|
2009-02-22 23:36:13 +00:00
|
|
|
default:
|
2013-09-12 01:02:41 +02:00
|
|
|
title_id_str = _StartupPara.GetUniqueID();
|
|
|
|
break;
|
2009-02-22 23:36:13 +00:00
|
|
|
}
|
2009-03-04 19:13:51 +00:00
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
if (writable_map_file)
|
|
|
|
*writable_map_file = File::GetUserPath(D_MAPS_IDX) + title_id_str + ".map";
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
bool found = false;
|
|
|
|
static const std::string maps_directories[] = {
|
|
|
|
File::GetUserPath(D_MAPS_IDX),
|
|
|
|
File::GetSysDirectory() + MAPS_DIR DIR_SEP
|
|
|
|
};
|
|
|
|
for (size_t i = 0; !found && i < ArraySize(maps_directories); ++i)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2013-09-12 01:02:41 +02:00
|
|
|
std::string path = maps_directories[i] + title_id_str + ".map";
|
|
|
|
if (File::Exists(path))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2013-09-12 01:02:41 +02:00
|
|
|
found = true;
|
|
|
|
if (existing_map_file)
|
|
|
|
*existing_map_file = path;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CBoot::LoadMapFromFilename()
|
|
|
|
{
|
|
|
|
std::string strMapFilename;
|
2014-03-09 21:14:26 +01:00
|
|
|
bool found = FindMapFile(&strMapFilename, nullptr);
|
2014-03-12 15:33:41 -04:00
|
|
|
if (found && g_symbolDB.LoadMap(strMapFilename))
|
2013-09-12 01:02:41 +02:00
|
|
|
{
|
2008-12-08 05:30:24 +00:00
|
|
|
UpdateDebugger_MapLoaded();
|
2013-09-12 01:02:41 +02:00
|
|
|
return true;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
return false;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 01:23:17 -04:00
|
|
|
// If ipl.bin is not found, this function does *some* of what BS1 does:
|
2010-08-20 14:57:26 +00:00
|
|
|
// loading IPL(BS2) and jumping to it.
|
|
|
|
// It does not initialize the hardware or anything else like BS1 does.
|
2009-10-11 16:16:18 +00:00
|
|
|
bool CBoot::Load_BS2(const std::string& _rBootROMFilename)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-08-22 20:49:21 -07:00
|
|
|
const u32 USA = 0x1FCE3FD6;
|
|
|
|
const u32 USA_v1_1 = 0x4D5935D1;
|
|
|
|
const u32 JAP = 0x87424396;
|
|
|
|
const u32 PAL = 0xA0EA7341;
|
|
|
|
//const u32 PanasonicQJ = 0xAEA8265C;
|
|
|
|
//const u32 PanasonicQU = 0x94015753;
|
|
|
|
|
2009-10-11 16:16:18 +00:00
|
|
|
// Load the whole ROM dump
|
2009-06-14 10:59:06 +00:00
|
|
|
std::string data;
|
2014-03-12 15:33:41 -04:00
|
|
|
if (!File::ReadFileToString(_rBootROMFilename, data))
|
2009-06-14 10:59:06 +00:00
|
|
|
return false;
|
|
|
|
|
2011-08-22 20:49:21 -07:00
|
|
|
u32 ipl_hash = HashAdler32((const u8*)data.data(), data.size());
|
|
|
|
std::string ipl_region;
|
|
|
|
switch (ipl_hash)
|
|
|
|
{
|
|
|
|
case USA:
|
|
|
|
case USA_v1_1:
|
|
|
|
ipl_region = USA_DIR;
|
|
|
|
break;
|
|
|
|
case JAP:
|
|
|
|
ipl_region = JAP_DIR;
|
|
|
|
break;
|
|
|
|
case PAL:
|
|
|
|
ipl_region = EUR_DIR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PanicAlert("IPL with unknown hash %x", ipl_hash);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string BootRegion = _rBootROMFilename.substr(_rBootROMFilename.find_last_of(DIR_SEP) - 3, 3);
|
|
|
|
if (BootRegion != ipl_region)
|
2013-03-31 19:10:21 -04:00
|
|
|
PanicAlert("%s IPL found in %s directory. The disc may not be recognized", ipl_region.c_str(), BootRegion.c_str());
|
2011-08-22 20:49:21 -07:00
|
|
|
|
2009-10-11 16:16:18 +00:00
|
|
|
// Run the descrambler over the encrypted section containing BS1/BS2
|
|
|
|
CEXIIPL::Descrambler((u8*)data.data()+0x100, 0x1AFE00);
|
|
|
|
|
2010-08-20 14:57:26 +00:00
|
|
|
Memory::WriteBigEData((const u8*)data.data() + 0x100, 0x81200000, 0x700);
|
2009-10-11 16:16:18 +00:00
|
|
|
Memory::WriteBigEData((const u8*)data.data() + 0x820, 0x81300000, 0x1AFE00);
|
2010-08-20 14:57:26 +00:00
|
|
|
PC = 0x81200000;
|
2013-04-16 23:14:36 -04:00
|
|
|
return true;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2009-01-07 02:59:19 +00:00
|
|
|
// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp
|
2009-01-18 01:45:53 +00:00
|
|
|
bool CBoot::BootUp()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2013-10-29 01:23:17 -04:00
|
|
|
SCoreStartupParameter& _StartupPara =
|
2009-01-18 01:45:53 +00:00
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-03-20 22:54:59 +00:00
|
|
|
NOTICE_LOG(BOOT, "Booting %s", _StartupPara.m_strFilename.c_str());
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
g_symbolDB.Clear();
|
2010-04-08 16:59:35 +00:00
|
|
|
VideoInterface::Preset(_StartupPara.bNTSC);
|
|
|
|
switch (_StartupPara.m_BootType)
|
|
|
|
{
|
|
|
|
// GCM and Wii
|
|
|
|
case SCoreStartupParameter::BOOT_ISO:
|
|
|
|
{
|
|
|
|
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_StartupPara.m_strFilename);
|
2014-03-09 21:14:26 +01:00
|
|
|
if (pVolume == nullptr)
|
2010-04-08 16:59:35 +00:00
|
|
|
break;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
bool isoWii = DiscIO::IsVolumeWiiDisc(pVolume);
|
|
|
|
if (isoWii != _StartupPara.bWii)
|
|
|
|
{
|
2011-01-13 02:05:58 +00:00
|
|
|
PanicAlertT("Warning - starting ISO in wrong console mode!");
|
2010-04-08 16:59:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// setup the map from ISOFile ID
|
|
|
|
VolumeHandler::SetVolumeName(_StartupPara.m_strFilename);
|
|
|
|
|
2012-03-19 11:12:40 -07:00
|
|
|
std::string unique_id = VolumeHandler::GetVolume()->GetUniqueID();
|
2012-03-19 12:07:47 -07:00
|
|
|
if (unique_id.size() >= 4)
|
2012-03-19 11:12:40 -07:00
|
|
|
VideoInterface::SetRegionReg(unique_id.at(3));
|
2011-06-03 00:55:58 +00:00
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
|
|
|
|
2010-09-08 00:20:19 +00:00
|
|
|
u32 _TMDsz = 0x208;
|
|
|
|
u8* _pTMD = new u8[_TMDsz];
|
|
|
|
pVolume->GetTMD(_pTMD, &_TMDsz);
|
|
|
|
if (_TMDsz)
|
|
|
|
{
|
|
|
|
WII_IPC_HLE_Interface::ES_DIVerify(_pTMD, _TMDsz);
|
|
|
|
}
|
|
|
|
delete []_pTMD;
|
|
|
|
|
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
_StartupPara.bWii = VolumeHandler::IsWii();
|
|
|
|
|
|
|
|
// HLE BS2 or not
|
|
|
|
if (_StartupPara.bHLE_BS2)
|
|
|
|
{
|
|
|
|
EmulatedBS2(_StartupPara.bWii);
|
|
|
|
}
|
|
|
|
else if (!Load_BS2(_StartupPara.m_strBootROM))
|
|
|
|
{
|
|
|
|
// If we can't load the bootrom file we HLE it instead
|
|
|
|
EmulatedBS2(_StartupPara.bWii);
|
|
|
|
}
|
2014-06-30 17:28:45 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Load patches if they weren't already
|
|
|
|
PatchEngine::LoadPatches();
|
|
|
|
}
|
2010-04-08 16:59:35 +00:00
|
|
|
|
2011-10-05 00:22:51 +11:00
|
|
|
// Scan for common HLE functions
|
2012-12-28 14:26:46 +11:00
|
|
|
if (_StartupPara.bSkipIdle && !_StartupPara.bEnableDebugging)
|
2011-10-05 00:22:51 +11:00
|
|
|
{
|
2012-05-05 18:38:00 +10:00
|
|
|
PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB);
|
2011-10-05 00:22:51 +11:00
|
|
|
SignatureDB db;
|
2014-03-12 15:33:41 -04:00
|
|
|
if (db.Load(File::GetSysDirectory() + TOTALDB))
|
2011-10-05 00:22:51 +11:00
|
|
|
{
|
|
|
|
db.Apply(&g_symbolDB);
|
2012-05-05 18:38:00 +10:00
|
|
|
HLE::PatchFunctions();
|
|
|
|
db.Clear();
|
2011-10-05 00:22:51 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
/* Try to load the symbol map if there is one, and then scan it for
|
|
|
|
and eventually replace code */
|
2013-09-12 01:02:41 +02:00
|
|
|
if (LoadMapFromFilename())
|
2010-04-08 16:59:35 +00:00
|
|
|
HLE::PatchFunctions();
|
|
|
|
|
|
|
|
// We don't need the volume any more
|
|
|
|
delete pVolume;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DOL
|
|
|
|
case SCoreStartupParameter::BOOT_DOL:
|
|
|
|
{
|
2014-03-12 15:33:41 -04:00
|
|
|
CDolLoader dolLoader(_StartupPara.m_strFilename);
|
2010-04-08 16:59:35 +00:00
|
|
|
// Check if we have gotten a Wii file or not
|
2011-01-24 21:54:19 +00:00
|
|
|
bool dolWii = dolLoader.IsWii();
|
2010-04-08 16:59:35 +00:00
|
|
|
if (dolWii != _StartupPara.bWii)
|
|
|
|
{
|
2011-01-13 02:05:58 +00:00
|
|
|
PanicAlertT("Warning - starting DOL in wrong console mode!");
|
2010-04-08 16:59:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BS2Success = false;
|
|
|
|
|
|
|
|
if (dolWii)
|
|
|
|
{
|
|
|
|
BS2Success = EmulatedBS2(dolWii);
|
|
|
|
}
|
|
|
|
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
|
|
|
|
{
|
2014-03-12 15:33:41 -04:00
|
|
|
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
|
2010-04-08 16:59:35 +00:00
|
|
|
BS2Success = EmulatedBS2(dolWii);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_StartupPara.m_strDVDRoot.empty())
|
|
|
|
{
|
|
|
|
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str());
|
|
|
|
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, dolWii, _StartupPara.m_strApploader, _StartupPara.m_strFilename);
|
|
|
|
BS2Success = EmulatedBS2(dolWii);
|
2013-10-29 01:23:17 -04:00
|
|
|
}
|
2010-04-08 16:59:35 +00:00
|
|
|
|
|
|
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
|
|
|
|
|
|
|
if (!BS2Success)
|
|
|
|
{
|
2011-01-24 21:54:19 +00:00
|
|
|
dolLoader.Load();
|
2010-04-08 16:59:35 +00:00
|
|
|
PC = dolLoader.GetEntryPoint();
|
|
|
|
}
|
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
if (LoadMapFromFilename())
|
2010-04-08 16:59:35 +00:00
|
|
|
HLE::PatchFunctions();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2013-04-16 23:14:36 -04:00
|
|
|
break;
|
2010-04-08 16:59:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ELF
|
|
|
|
case SCoreStartupParameter::BOOT_ELF:
|
|
|
|
{
|
2014-03-11 00:30:55 +13:00
|
|
|
if (!File::Exists(_StartupPara.m_strFilename))
|
2010-04-08 16:59:35 +00:00
|
|
|
{
|
2011-01-13 02:05:58 +00:00
|
|
|
PanicAlertT("The file you specified (%s) does not exist",
|
2010-04-08 16:59:35 +00:00
|
|
|
_StartupPara.m_strFilename.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we have gotten a Wii file or not
|
2014-03-12 15:33:41 -04:00
|
|
|
bool elfWii = IsElfWii(_StartupPara.m_strFilename);
|
2010-04-08 16:59:35 +00:00
|
|
|
if (elfWii != _StartupPara.bWii)
|
|
|
|
{
|
2011-01-13 02:05:58 +00:00
|
|
|
PanicAlertT("Warning - starting ELF in wrong console mode!");
|
2013-10-29 01:23:17 -04:00
|
|
|
}
|
2010-04-08 16:59:35 +00:00
|
|
|
|
|
|
|
bool BS2Success = false;
|
|
|
|
|
|
|
|
if (elfWii)
|
|
|
|
{
|
|
|
|
BS2Success = EmulatedBS2(elfWii);
|
|
|
|
}
|
|
|
|
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
|
|
|
|
{
|
2014-03-12 15:33:41 -04:00
|
|
|
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
|
2010-04-08 16:59:35 +00:00
|
|
|
BS2Success = EmulatedBS2(elfWii);
|
|
|
|
}
|
|
|
|
|
|
|
|
// load image or create virtual drive from directory
|
|
|
|
if (!_StartupPara.m_strDVDRoot.empty())
|
|
|
|
{
|
|
|
|
NOTICE_LOG(BOOT, "Setting DVDRoot %s", _StartupPara.m_strDVDRoot.c_str());
|
|
|
|
// TODO: auto-convert elf to dol, so we can load them :)
|
|
|
|
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, elfWii);
|
|
|
|
BS2Success = EmulatedBS2(elfWii);
|
2013-10-29 01:23:17 -04:00
|
|
|
}
|
2010-04-08 16:59:35 +00:00
|
|
|
else if (!_StartupPara.m_strDefaultGCM.empty())
|
|
|
|
{
|
|
|
|
NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultGCM.c_str());
|
|
|
|
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
|
|
|
|
}
|
|
|
|
else VolumeHandler::SetVolumeDirectory(_StartupPara.m_strFilename, elfWii);
|
|
|
|
|
|
|
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
|
|
|
|
|
|
|
if (BS2Success)
|
|
|
|
{
|
|
|
|
HLE::PatchFunctions();
|
|
|
|
}
|
|
|
|
else // Poor man's bootup
|
|
|
|
{
|
|
|
|
Load_FST(elfWii);
|
2014-03-12 15:33:41 -04:00
|
|
|
Boot_ELF(_StartupPara.m_strFilename);
|
2010-04-08 16:59:35 +00:00
|
|
|
}
|
|
|
|
UpdateDebugger_MapLoaded();
|
|
|
|
Dolphin_Debugger::AddAutoBreakpoints();
|
|
|
|
break;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-02-22 00:40:52 +00:00
|
|
|
// Wii WAD
|
2009-02-27 23:44:15 +00:00
|
|
|
case SCoreStartupParameter::BOOT_WII_NAND:
|
2014-03-12 15:33:41 -04:00
|
|
|
Boot_WiiWAD(_StartupPara.m_strFilename);
|
2009-03-02 21:10:46 +00:00
|
|
|
|
2013-09-12 01:02:41 +02:00
|
|
|
if (LoadMapFromFilename())
|
2010-04-08 16:59:35 +00:00
|
|
|
HLE::PatchFunctions();
|
2009-06-18 08:22:02 +00:00
|
|
|
|
|
|
|
// load default image or create virtual drive from directory
|
|
|
|
if (!_StartupPara.m_strDVDRoot.empty())
|
|
|
|
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, true);
|
|
|
|
else if (!_StartupPara.m_strDefaultGCM.empty())
|
|
|
|
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
|
|
|
|
|
|
|
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
2009-02-22 00:40:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
// Bootstrap 2 (AKA: Initial Program Loader, "BIOS")
|
|
|
|
case SCoreStartupParameter::BOOT_BS2:
|
|
|
|
{
|
|
|
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
|
|
|
if (Load_BS2(_StartupPara.m_strBootROM))
|
|
|
|
{
|
2013-09-12 01:02:41 +02:00
|
|
|
if (LoadMapFromFilename())
|
2010-04-08 16:59:35 +00:00
|
|
|
HLE::PatchFunctions();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
case SCoreStartupParameter::BOOT_DFF:
|
|
|
|
// do nothing
|
|
|
|
break;
|
|
|
|
|
2010-04-08 16:59:35 +00:00
|
|
|
default:
|
|
|
|
{
|
2011-01-13 02:05:58 +00:00
|
|
|
PanicAlertT("Tried to load an unknown file type.");
|
2010-04-08 16:59:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-09-12 00:03:37 -04:00
|
|
|
|
|
|
|
// HLE jump to loader (homebrew). Disabled when Gecko is active as it interferes with the code handler
|
|
|
|
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats)
|
|
|
|
{
|
|
|
|
HLE::Patch(0x80001800, "HBReload");
|
|
|
|
const u8 stubstr[] = { 'S', 'T', 'U', 'B', 'H', 'A', 'X', 'X' };
|
|
|
|
Memory::WriteBigEData(stubstr, 0x80001804, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not part of the binary itself, but either we or Gecko OS might insert
|
|
|
|
// this, and it doesn't clear the icache properly.
|
|
|
|
HLE::Patch(0x800018a8, "GeckoCodehandler");
|
2008-12-08 05:30:24 +00:00
|
|
|
return true;
|
|
|
|
}
|