VolumeDirectory: allow loading of arbitrary apploader and dol. Code cleaning around the bootup logic.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4668 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
d4e35a1a97
commit
805bd8ec28
|
@ -160,7 +160,6 @@ bool CBoot::Load_BS2(const std::string& _rBootROMFilename)
|
||||||
// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp
|
// Third boot step after BootManager and Core. See Call schedule in BootManager.cpp
|
||||||
bool CBoot::BootUp()
|
bool CBoot::BootUp()
|
||||||
{
|
{
|
||||||
const bool bDebugIsoBootup = false;
|
|
||||||
SCoreStartupParameter& _StartupPara =
|
SCoreStartupParameter& _StartupPara =
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter;
|
SConfig::GetInstance().m_LocalCoreStartupParameter;
|
||||||
|
|
||||||
|
@ -195,30 +194,17 @@ bool CBoot::BootUp()
|
||||||
|
|
||||||
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
||||||
|
|
||||||
|
_StartupPara.bWii = VolumeHandler::IsWii();
|
||||||
|
|
||||||
// HLE BS2 or not
|
// HLE BS2 or not
|
||||||
if (_StartupPara.bHLE_BS2)
|
if (_StartupPara.bHLE_BS2)
|
||||||
{
|
{
|
||||||
if (!VolumeHandler::IsWii())
|
EmulatedBS2(_StartupPara.bWii);
|
||||||
EmulatedBS2(bDebugIsoBootup);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_StartupPara.bWii = true;
|
|
||||||
EmulatedBS2_Wii(bDebugIsoBootup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (!Load_BS2(_StartupPara.m_strBootROM))
|
||||||
{
|
{
|
||||||
// If we can't load the bootrom file we HLE it instead
|
// If we can't load the bootrom file we HLE it instead
|
||||||
if (!Load_BS2(_StartupPara.m_strBootROM))
|
EmulatedBS2(_StartupPara.bWii);
|
||||||
{
|
|
||||||
if (!VolumeHandler::IsWii())
|
|
||||||
EmulatedBS2(bDebugIsoBootup);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_StartupPara.bWii = true;
|
|
||||||
EmulatedBS2_Wii(bDebugIsoBootup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to load the symbol map if there is one, and then scan it for
|
/* Try to load the symbol map if there is one, and then scan it for
|
||||||
|
@ -240,32 +226,37 @@ bool CBoot::BootUp()
|
||||||
if (dolWii != _StartupPara.bWii)
|
if (dolWii != _StartupPara.bWii)
|
||||||
{
|
{
|
||||||
PanicAlert("Warning - starting DOL in wrong console mode!");
|
PanicAlert("Warning - starting DOL in wrong console mode!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop apploader from running when the BS2 HLE funcs run
|
bool BS2Success = false;
|
||||||
VolumeHandler::SetVolumeName("");
|
|
||||||
|
|
||||||
if (dolWii)
|
if (dolWii)
|
||||||
{
|
{
|
||||||
EmulatedBS2_Wii(false);
|
BS2Success = EmulatedBS2(dolWii);
|
||||||
}
|
}
|
||||||
else
|
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
|
||||||
{
|
{
|
||||||
if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
|
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
|
||||||
{
|
BS2Success = EmulatedBS2(dolWii);
|
||||||
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
|
|
||||||
EmulatedBS2(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
||||||
|
|
||||||
CDolLoader dolLoader(_StartupPara.m_strFilename.c_str());
|
if (!BS2Success)
|
||||||
PC = dolLoader.GetEntryPoint();
|
{
|
||||||
#ifdef _DEBUG
|
CDolLoader dolLoader(_StartupPara.m_strFilename.c_str());
|
||||||
|
PC = dolLoader.GetEntryPoint();
|
||||||
|
}
|
||||||
|
|
||||||
if (LoadMapFromFilename(_StartupPara.m_strFilename))
|
if (LoadMapFromFilename(_StartupPara.m_strFilename))
|
||||||
HLE::PatchFunctions();
|
HLE::PatchFunctions();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -285,28 +276,26 @@ bool CBoot::BootUp()
|
||||||
if (elfWii != _StartupPara.bWii)
|
if (elfWii != _StartupPara.bWii)
|
||||||
{
|
{
|
||||||
PanicAlert("Warning - starting ELF in wrong console mode!");
|
PanicAlert("Warning - starting ELF in wrong console mode!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop apploader from running when the BS2 HLE funcs run
|
bool BS2Success = false;
|
||||||
VolumeHandler::SetVolumeName("");
|
|
||||||
|
|
||||||
if (elfWii)
|
if (elfWii)
|
||||||
{
|
{
|
||||||
EmulatedBS2_Wii(false);
|
BS2Success = EmulatedBS2(elfWii);
|
||||||
}
|
}
|
||||||
else
|
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
|
||||||
{
|
{
|
||||||
if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
|
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
|
||||||
{
|
BS2Success = EmulatedBS2(elfWii);
|
||||||
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
|
|
||||||
EmulatedBS2(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load image or create virtual drive from directory
|
// load image or create virtual drive from directory
|
||||||
if (!_StartupPara.m_strDVDRoot.empty()) {
|
if (!_StartupPara.m_strDVDRoot.empty()) {
|
||||||
NOTICE_LOG(BOOT, "Setting DVDroot %s", _StartupPara.m_strDefaultGCM.c_str());
|
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);
|
VolumeHandler::SetVolumeDirectory(_StartupPara.m_strDVDRoot, elfWii);
|
||||||
|
BS2Success = EmulatedBS2(elfWii);
|
||||||
}
|
}
|
||||||
else if (!_StartupPara.m_strDefaultGCM.empty()) {
|
else if (!_StartupPara.m_strDefaultGCM.empty()) {
|
||||||
NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultGCM.c_str());
|
NOTICE_LOG(BOOT, "Loading default ISO %s", _StartupPara.m_strDefaultGCM.c_str());
|
||||||
|
@ -317,14 +306,17 @@ bool CBoot::BootUp()
|
||||||
|
|
||||||
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
DVDInterface::SetDiscInside(VolumeHandler::IsValid());
|
||||||
|
|
||||||
Load_FST(elfWii);
|
if (BS2Success)
|
||||||
|
{
|
||||||
Boot_ELF(_StartupPara.m_strFilename.c_str());
|
HLE::PatchFunctions();
|
||||||
|
}
|
||||||
|
else // Poor man's bootup
|
||||||
|
{
|
||||||
|
Load_FST(elfWii);
|
||||||
|
Boot_ELF(_StartupPara.m_strFilename.c_str());
|
||||||
|
}
|
||||||
UpdateDebugger_MapLoaded();
|
UpdateDebugger_MapLoaded();
|
||||||
Dolphin_Debugger::AddAutoBreakpoints();
|
Dolphin_Debugger::AddAutoBreakpoints();
|
||||||
|
|
||||||
|
|
||||||
HLE::PatchFunctions();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,9 @@ private:
|
||||||
static bool Boot_ELF(const char *filename);
|
static bool Boot_ELF(const char *filename);
|
||||||
static bool Boot_WiiWAD(const char *filename);
|
static bool Boot_WiiWAD(const char *filename);
|
||||||
|
|
||||||
static void EmulatedBS2(bool _bDebug);
|
static bool EmulatedBS2_GC();
|
||||||
static bool EmulatedBS2_Wii(bool _bDebug);
|
static bool EmulatedBS2_Wii();
|
||||||
|
static bool EmulatedBS2(bool _bIsWii);
|
||||||
static bool Load_BS2(const std::string& _rBootROMFilename);
|
static bool Load_BS2(const std::string& _rBootROMFilename);
|
||||||
static void Load_FST(bool _bIsWii);
|
static void Load_FST(bool _bIsWii);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void CBoot::RunFunction(u32 _iAddr)
|
||||||
// GameCube Bootstrap 2 HLE:
|
// GameCube Bootstrap 2 HLE:
|
||||||
// copy the apploader to 0x81200000
|
// copy the apploader to 0x81200000
|
||||||
// execute the apploader, function by function, using the above utility.
|
// execute the apploader, function by function, using the above utility.
|
||||||
void CBoot::EmulatedBS2(bool _bDebug)
|
bool CBoot::EmulatedBS2_GC()
|
||||||
{
|
{
|
||||||
INFO_LOG(BOOT, "Faking GC BS2...");
|
INFO_LOG(BOOT, "Faking GC BS2...");
|
||||||
|
|
||||||
|
@ -87,10 +87,13 @@ void CBoot::EmulatedBS2(bool _bDebug)
|
||||||
// Load Apploader to Memory - The apploader is hardcoded to begin at 0x2440 on the disc,
|
// Load Apploader to Memory - The apploader is hardcoded to begin at 0x2440 on the disc,
|
||||||
// but the size can differ between discs. Compare with yagcd chap 13.
|
// but the size can differ between discs. Compare with yagcd chap 13.
|
||||||
u32 iAppLoaderOffset = 0x2440;
|
u32 iAppLoaderOffset = 0x2440;
|
||||||
u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10);
|
u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10);
|
||||||
u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14);
|
u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14) + VolumeHandler::Read32(iAppLoaderOffset + 0x18);
|
||||||
if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1))
|
if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1))
|
||||||
return;
|
{
|
||||||
|
INFO_LOG(BOOT, "GC BS2: Not running apploader!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize);
|
VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize);
|
||||||
|
|
||||||
// Setup pointers like real BS2 does
|
// Setup pointers like real BS2 does
|
||||||
|
@ -161,6 +164,8 @@ void CBoot::EmulatedBS2(bool _bDebug)
|
||||||
|
|
||||||
// If we have any patches that need to be applied very early, here's a good place
|
// If we have any patches that need to be applied very early, here's a good place
|
||||||
PatchEngine::ApplyFramePatches();
|
PatchEngine::ApplyFramePatches();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,7 +292,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
|
||||||
// Wii Bootstrap 2 HLE:
|
// Wii Bootstrap 2 HLE:
|
||||||
// copy the apploader to 0x81200000
|
// copy the apploader to 0x81200000
|
||||||
// execute the apploader
|
// execute the apploader
|
||||||
bool CBoot::EmulatedBS2_Wii(bool _bDebug)
|
bool CBoot::EmulatedBS2_Wii()
|
||||||
{
|
{
|
||||||
INFO_LOG(BOOT, "Faking Wii BS2...");
|
INFO_LOG(BOOT, "Faking Wii BS2...");
|
||||||
|
|
||||||
|
@ -391,3 +396,8 @@ bool CBoot::EmulatedBS2_Wii(bool _bDebug)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CBoot::EmulatedBS2(bool _bIsWii)
|
||||||
|
{
|
||||||
|
return _bIsWii ? EmulatedBS2_Wii() : EmulatedBS2_GC();
|
||||||
|
}
|
|
@ -102,6 +102,7 @@ void SConfig::SaveSettings()
|
||||||
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
|
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
|
||||||
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
|
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
|
||||||
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
|
ini.Set("Core", "DVDRoot", m_LocalCoreStartupParameter.m_strDVDRoot);
|
||||||
|
ini.Set("Core", "Apploader", m_LocalCoreStartupParameter.m_strApploader);
|
||||||
ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers);
|
ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers);
|
||||||
ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats);
|
ini.Set("Core", "EnableCheats", m_LocalCoreStartupParameter.bEnableCheats);
|
||||||
ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage);
|
ini.Set("Core", "SelectedLanguage", m_LocalCoreStartupParameter.SelectedLanguage);
|
||||||
|
@ -213,6 +214,7 @@ void SConfig::LoadSettings()
|
||||||
ini.Get("Core", "LockThreads", &m_LocalCoreStartupParameter.bLockThreads, false);
|
ini.Get("Core", "LockThreads", &m_LocalCoreStartupParameter.bLockThreads, false);
|
||||||
ini.Get("Core", "DefaultGCM", &m_LocalCoreStartupParameter.m_strDefaultGCM);
|
ini.Get("Core", "DefaultGCM", &m_LocalCoreStartupParameter.m_strDefaultGCM);
|
||||||
ini.Get("Core", "DVDRoot", &m_LocalCoreStartupParameter.m_strDVDRoot);
|
ini.Get("Core", "DVDRoot", &m_LocalCoreStartupParameter.m_strDVDRoot);
|
||||||
|
ini.Get("Core", "Apploader", &m_LocalCoreStartupParameter.m_strApploader);
|
||||||
ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true);
|
ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true);
|
||||||
ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false);
|
ini.Get("Core", "EnableCheats", &m_LocalCoreStartupParameter.bEnableCheats, false);
|
||||||
ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0);
|
ini.Get("Core", "SelectedLanguage", &m_LocalCoreStartupParameter.SelectedLanguage, 0);
|
||||||
|
|
|
@ -110,6 +110,7 @@ struct SCoreStartupParameter
|
||||||
std::string m_strSRAM;
|
std::string m_strSRAM;
|
||||||
std::string m_strDefaultGCM;
|
std::string m_strDefaultGCM;
|
||||||
std::string m_strDVDRoot;
|
std::string m_strDVDRoot;
|
||||||
|
std::string m_strApploader;
|
||||||
std::string m_strUniqueID;
|
std::string m_strUniqueID;
|
||||||
std::string m_strName;
|
std::string m_strName;
|
||||||
std::string m_strGameIni;
|
std::string m_strGameIni;
|
||||||
|
|
|
@ -53,7 +53,7 @@ bool SetVolumeName(const std::string& _rFullPath)
|
||||||
return g_pVolume != NULL;
|
return g_pVolume != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii)
|
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL)
|
||||||
{
|
{
|
||||||
if (g_pVolume)
|
if (g_pVolume)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii)
|
||||||
g_pVolume = NULL;
|
g_pVolume = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pVolume = DiscIO::CreateVolumeFromDirectory(_rFullPath, _bIsWii);
|
g_pVolume = DiscIO::CreateVolumeFromDirectory(_rFullPath, _bIsWii, _rApploader, _rDOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Read32(u64 _Offset)
|
u32 Read32(u64 _Offset)
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace VolumeHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
bool SetVolumeName(const std::string& _rFullPath);
|
bool SetVolumeName(const std::string& _rFullPath);
|
||||||
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii);
|
void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii, const std::string& _rApploader = "", const std::string& _rDOL = "");
|
||||||
|
|
||||||
u32 Read32(u64 _Offset);
|
u32 Read32(u64 _Offset);
|
||||||
bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength);
|
bool ReadToPtr(u8* ptr, u64 _dwOffset, u64 _dwLength);
|
||||||
|
|
|
@ -111,10 +111,10 @@ IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionG
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii)
|
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL)
|
||||||
{
|
{
|
||||||
if (CVolumeDirectory::IsValidDirectory(_rDirectory))
|
if (CVolumeDirectory::IsValidDirectory(_rDirectory))
|
||||||
return new CVolumeDirectory(_rDirectory, _bIsWii);
|
return new CVolumeDirectory(_rDirectory, _bIsWii, _rApploader, _rDOL);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionGroup = 0, u32 _VolumeNum = -1);
|
IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionGroup = 0, u32 _VolumeNum = -1);
|
||||||
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii);
|
IVolume* CreateVolumeFromDirectory(const std::string& _rDirectory, bool _bIsWii, const std::string& _rApploader = "", const std::string& _rDOL = "");
|
||||||
bool IsVolumeWiiDisc(const IVolume *_rVolume);
|
bool IsVolumeWiiDisc(const IVolume *_rVolume);
|
||||||
bool IsVolumeWadFile(const IVolume *_rVolume);
|
bool IsVolumeWadFile(const IVolume *_rVolume);
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -25,11 +25,20 @@ namespace DiscIO
|
||||||
static const u8 ENTRY_SIZE = 0x0c;
|
static const u8 ENTRY_SIZE = 0x0c;
|
||||||
static const u8 FILE_ENTRY = 0;
|
static const u8 FILE_ENTRY = 0;
|
||||||
static const u8 DIRECTORY_ENTRY = 1;
|
static const u8 DIRECTORY_ENTRY = 1;
|
||||||
static const u64 FST_ADDRESS = 0x440;
|
static const u64 DISKHEADER_ADDRESS = 0;
|
||||||
|
static const u64 DISKHEADERINFO_ADDRESS = 0x440;
|
||||||
|
static const u64 APPLOADER_ADDRESS = 0x2440;
|
||||||
static const u32 MAX_NAME_LENGTH = 0x3df;
|
static const u32 MAX_NAME_LENGTH = 0x3df;
|
||||||
|
// relocatable
|
||||||
|
static u64 FST_ADDRESS = 0x440;
|
||||||
|
static u64 DOL_ADDRESS = 0;
|
||||||
|
|
||||||
CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii)
|
CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii, const std::string& _rApploader, const std::string& _rDOL)
|
||||||
: m_totalNameSize(0)
|
: m_apploaderSize(0)
|
||||||
|
, m_apploader(NULL)
|
||||||
|
, m_DOLSize(0)
|
||||||
|
, m_DOL(NULL)
|
||||||
|
, m_totalNameSize(0)
|
||||||
, m_dataStartAddress(-1)
|
, m_dataStartAddress(-1)
|
||||||
, m_fstSize(0)
|
, m_fstSize(0)
|
||||||
, m_FSTData(NULL)
|
, m_FSTData(NULL)
|
||||||
|
@ -51,16 +60,31 @@ CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii)
|
||||||
SetDiskTypeGC();
|
SetDiskTypeGC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_diskHeaderInfo = new SDiskHeaderInfo();
|
||||||
|
|
||||||
|
// Don't load the dol if we've no apploader...
|
||||||
|
if (SetApploader(_rApploader))
|
||||||
|
SetDOL(_rDOL);
|
||||||
|
|
||||||
BuildFST();
|
BuildFST();
|
||||||
}
|
}
|
||||||
|
|
||||||
CVolumeDirectory::~CVolumeDirectory()
|
CVolumeDirectory::~CVolumeDirectory()
|
||||||
{
|
{
|
||||||
delete m_FSTData;
|
delete[] m_FSTData;
|
||||||
m_FSTData = NULL;
|
m_FSTData = NULL;
|
||||||
|
|
||||||
delete m_diskHeader;
|
delete[] m_diskHeader;
|
||||||
m_diskHeader = NULL;
|
m_diskHeader = NULL;
|
||||||
|
|
||||||
|
delete m_diskHeaderInfo;
|
||||||
|
m_diskHeaderInfo = NULL;
|
||||||
|
|
||||||
|
delete[] m_DOL;
|
||||||
|
m_DOL = NULL;
|
||||||
|
|
||||||
|
delete[] m_apploader;
|
||||||
|
m_apploader = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
bool CVolumeDirectory::IsValidDirectory(const std::string& _rDirectory)
|
||||||
|
@ -76,14 +100,35 @@ bool CVolumeDirectory::RAWRead( u64 _Offset, u64 _Length, u8* _pBuffer ) const
|
||||||
|
|
||||||
bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
|
bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
|
||||||
{
|
{
|
||||||
if(_Offset < FST_ADDRESS)
|
// header
|
||||||
|
if(_Offset < DISKHEADERINFO_ADDRESS)
|
||||||
{
|
{
|
||||||
WriteToBuffer(0, FST_ADDRESS, m_diskHeader, _Offset, _Length, _pBuffer);
|
WriteToBuffer(DISKHEADER_ADDRESS, DISKHEADERINFO_ADDRESS, m_diskHeader, _Offset, _Length, _pBuffer);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
// header info
|
||||||
|
if(_Offset < APPLOADER_ADDRESS)
|
||||||
|
{
|
||||||
|
WriteToBuffer(DISKHEADERINFO_ADDRESS, sizeof(m_diskHeaderInfo), (u8*)m_diskHeaderInfo, _Offset, _Length, _pBuffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// apploader
|
||||||
|
if(_Offset >= APPLOADER_ADDRESS && _Offset <= APPLOADER_ADDRESS + m_apploaderSize)
|
||||||
|
{
|
||||||
|
WriteToBuffer(APPLOADER_ADDRESS, m_apploaderSize, m_apploader, _Offset, _Length, _pBuffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// dol
|
||||||
|
if(_Offset >= DOL_ADDRESS && _Offset <= DOL_ADDRESS + m_DOLSize)
|
||||||
|
{
|
||||||
|
WriteToBuffer(DOL_ADDRESS, m_DOLSize, m_DOL, _Offset, _Length, _pBuffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// fst
|
||||||
if(_Offset < m_dataStartAddress)
|
if(_Offset < m_dataStartAddress)
|
||||||
{
|
{
|
||||||
WriteToBuffer(FST_ADDRESS, m_fstSize, m_FSTData, _Offset, _Length, _pBuffer);
|
WriteToBuffer(FST_ADDRESS, m_fstSize, m_FSTData, _Offset, _Length, _pBuffer);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_virtualDisk.size() == 0)
|
if(m_virtualDisk.size() == 0)
|
||||||
|
@ -257,6 +302,52 @@ void CVolumeDirectory::SetDiskTypeGC()
|
||||||
m_addressShift = 0;
|
m_addressShift = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CVolumeDirectory::SetApploader(const std::string& _rApploader)
|
||||||
|
{
|
||||||
|
if (!_rApploader.empty())
|
||||||
|
{
|
||||||
|
std::string data;
|
||||||
|
File::ReadFileToString(false, _rApploader.c_str(), data);
|
||||||
|
m_apploaderSize = 0x20 + Common::swap32(*(u32*)&data.data()[0x14]) + Common::swap32(*(u32*)&data.data()[0x18]);
|
||||||
|
if (m_apploaderSize != data.size())
|
||||||
|
{
|
||||||
|
PanicAlert("Apploader is the wrong size...is it really an apploader?");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_apploader = new u8[m_apploaderSize];
|
||||||
|
copy(data.begin(), data.end(), m_apploader);
|
||||||
|
|
||||||
|
// 32byte aligned (plus 0x20 padding)
|
||||||
|
DOL_ADDRESS = (APPLOADER_ADDRESS + m_apploaderSize + 0x20 + 31) & ~31ULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_apploaderSize = 0x20;
|
||||||
|
m_apploader = new u8[m_apploaderSize];
|
||||||
|
// Make sure BS2 HLE doesn't try to run the apploader
|
||||||
|
*(u32*)&m_apploader[0x10] = (u32)-1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CVolumeDirectory::SetDOL(const std::string& _rDOL)
|
||||||
|
{
|
||||||
|
if (!_rDOL.empty())
|
||||||
|
{
|
||||||
|
std::string data;
|
||||||
|
File::ReadFileToString(false, _rDOL.c_str(), data);
|
||||||
|
m_DOLSize = data.size();
|
||||||
|
m_DOL = new u8[m_DOLSize];
|
||||||
|
copy(data.begin(), data.end(), m_DOL);
|
||||||
|
|
||||||
|
Write32((u32)(DOL_ADDRESS >> m_addressShift), 0x0420, m_diskHeader);
|
||||||
|
|
||||||
|
// 32byte aligned (plus 0x20 padding)
|
||||||
|
FST_ADDRESS = (DOL_ADDRESS + m_DOLSize + 0x20 + 31) & ~31ULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CVolumeDirectory::BuildFST()
|
void CVolumeDirectory::BuildFST()
|
||||||
{
|
{
|
||||||
if(m_FSTData)
|
if(m_FSTData)
|
||||||
|
|
|
@ -33,75 +33,114 @@ namespace DiscIO
|
||||||
|
|
||||||
class CVolumeDirectory : public IVolume
|
class CVolumeDirectory : public IVolume
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii);
|
CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii,
|
||||||
|
const std::string& _rApploader = "", const std::string& _rDOL = "");
|
||||||
|
|
||||||
~CVolumeDirectory();
|
~CVolumeDirectory();
|
||||||
|
|
||||||
static bool IsValidDirectory(const std::string& _rDirectory);
|
static bool IsValidDirectory(const std::string& _rDirectory);
|
||||||
|
|
||||||
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const;
|
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer) const;
|
||||||
bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const;
|
bool RAWRead(u64 _Offset, u64 _Length, u8* _pBuffer) const;
|
||||||
|
|
||||||
std::string GetUniqueID() const;
|
std::string GetUniqueID() const;
|
||||||
void SetUniqueID(std::string _ID);
|
void SetUniqueID(std::string _ID);
|
||||||
|
|
||||||
std::string GetMakerID() const;
|
std::string GetMakerID() const;
|
||||||
|
|
||||||
std::string GetName() const;
|
std::string GetName() const;
|
||||||
void SetName(std::string);
|
void SetName(std::string);
|
||||||
|
|
||||||
u32 GetFSTSize() const;
|
u32 GetFSTSize() const;
|
||||||
|
|
||||||
std::string GetApploaderDate() const;
|
std::string GetApploaderDate() const;
|
||||||
|
|
||||||
ECountry GetCountry() const;
|
ECountry GetCountry() const;
|
||||||
|
|
||||||
u64 GetSize() const;
|
u64 GetSize() const;
|
||||||
|
|
||||||
void BuildFST();
|
void BuildFST();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string ExtractDirectoryName(const std::string& _rDirectory);
|
static std::string ExtractDirectoryName(const std::string& _rDirectory);
|
||||||
|
|
||||||
void SetDiskTypeWii();
|
void SetDiskTypeWii();
|
||||||
void SetDiskTypeGC();
|
void SetDiskTypeGC();
|
||||||
|
|
||||||
// writing to read buffer
|
bool SetApploader(const std::string& _rApploader);
|
||||||
void WriteToBuffer(u64 _SrcStartAddress, u64 _SrcLength, u8* _Src,
|
|
||||||
u64& _Address, u64& _Length, u8*& _pBuffer) const;
|
|
||||||
|
|
||||||
void PadToAddress(u64 _StartAddress, u64& _Address, u64& _Length, u8*& _pBuffer) const;
|
void SetDOL(const std::string& _rDOL);
|
||||||
|
|
||||||
void Write32(u32 data, u32 offset, u8* buffer);
|
// writing to read buffer
|
||||||
|
void WriteToBuffer(u64 _SrcStartAddress, u64 _SrcLength, u8* _Src,
|
||||||
|
u64& _Address, u64& _Length, u8*& _pBuffer) const;
|
||||||
|
|
||||||
// FST creation
|
void PadToAddress(u64 _StartAddress, u64& _Address, u64& _Length, u8*& _pBuffer) const;
|
||||||
void WriteEntryData(u32& entryOffset, u8 type, u32 nameOffset, u64 dataOffset, u32 length);
|
|
||||||
void WriteEntryName(u32& nameOffset, const std::string& name);
|
|
||||||
void WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u32& nameOffset, u64& dataOffset, u32 parentEntryNum);
|
|
||||||
|
|
||||||
// returns number of entries found in _Directory
|
void Write32(u32 data, u32 offset, u8* buffer);
|
||||||
u32 AddDirectoryEntries(const std::string& _Directory, File::FSTEntry& parentEntry);
|
|
||||||
|
|
||||||
std::string m_rootDirectory;
|
// FST creation
|
||||||
|
void WriteEntryData(u32& entryOffset, u8 type, u32 nameOffset, u64 dataOffset, u32 length);
|
||||||
|
void WriteEntryName(u32& nameOffset, const std::string& name);
|
||||||
|
void WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u32& nameOffset, u64& dataOffset, u32 parentEntryNum);
|
||||||
|
|
||||||
std::map<u64, std::string> m_virtualDisk;
|
// returns number of entries found in _Directory
|
||||||
|
u32 AddDirectoryEntries(const std::string& _Directory, File::FSTEntry& parentEntry);
|
||||||
|
|
||||||
u32 m_totalNameSize;
|
std::string m_rootDirectory;
|
||||||
|
|
||||||
// gc has no shift, wii has 2 bit shift
|
std::map<u64, std::string> m_virtualDisk;
|
||||||
u32 m_addressShift;
|
|
||||||
|
|
||||||
// first address on disk containing file data
|
u32 m_totalNameSize;
|
||||||
u64 m_dataStartAddress;
|
|
||||||
|
|
||||||
u64 m_fstNameOffset;
|
// gc has no shift, wii has 2 bit shift
|
||||||
|
u32 m_addressShift;
|
||||||
|
|
||||||
u64 m_fstSize;
|
// first address on disk containing file data
|
||||||
|
u64 m_dataStartAddress;
|
||||||
|
|
||||||
u8* m_FSTData;
|
u64 m_fstNameOffset;
|
||||||
u8* m_diskHeader;
|
u64 m_fstSize;
|
||||||
|
u8* m_FSTData;
|
||||||
|
|
||||||
|
u8* m_diskHeader;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct SDiskHeaderInfo
|
||||||
|
{
|
||||||
|
u32 debug_mntr_size;
|
||||||
|
u32 simulated_mem_size;
|
||||||
|
u32 arg_offset;
|
||||||
|
u32 debug_flag;
|
||||||
|
u32 track_location;
|
||||||
|
u32 track_size;
|
||||||
|
u32 countrycode;
|
||||||
|
u32 unknown;
|
||||||
|
u32 unknown2;
|
||||||
|
|
||||||
|
// All the data is byteswapped
|
||||||
|
SDiskHeaderInfo() {
|
||||||
|
debug_mntr_size = 0;
|
||||||
|
simulated_mem_size = 0;
|
||||||
|
arg_offset = 0;
|
||||||
|
debug_flag = 0;
|
||||||
|
track_location = 0;
|
||||||
|
track_size = 0;
|
||||||
|
countrycode = 0;
|
||||||
|
unknown = 0;
|
||||||
|
unknown2 = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
SDiskHeaderInfo* m_diskHeaderInfo;
|
||||||
|
|
||||||
|
u64 m_apploaderSize;
|
||||||
|
u8* m_apploader;
|
||||||
|
|
||||||
|
u64 m_DOLSize;
|
||||||
|
u8* m_DOL;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -95,6 +95,7 @@ EVT_BUTTON(ID_REMOVEISOPATH, CConfigMain::AddRemoveISOPaths)
|
||||||
EVT_CHECKBOX(ID_RECERSIVEISOPATH, CConfigMain::RecursiveDirectoryChanged)
|
EVT_CHECKBOX(ID_RECERSIVEISOPATH, CConfigMain::RecursiveDirectoryChanged)
|
||||||
EVT_FILEPICKER_CHANGED(ID_DEFAULTISO, CConfigMain::DefaultISOChanged)
|
EVT_FILEPICKER_CHANGED(ID_DEFAULTISO, CConfigMain::DefaultISOChanged)
|
||||||
EVT_DIRPICKER_CHANGED(ID_DVDROOT, CConfigMain::DVDRootChanged)
|
EVT_DIRPICKER_CHANGED(ID_DVDROOT, CConfigMain::DVDRootChanged)
|
||||||
|
EVT_FILEPICKER_CHANGED(ID_APPLOADERPATH, CConfigMain::ApploaderPathChanged)
|
||||||
|
|
||||||
EVT_CHOICE(ID_GRAPHIC_CB, CConfigMain::OnSelectionChanged)
|
EVT_CHOICE(ID_GRAPHIC_CB, CConfigMain::OnSelectionChanged)
|
||||||
EVT_BUTTON(ID_GRAPHIC_CONFIG, CConfigMain::OnConfig)
|
EVT_BUTTON(ID_GRAPHIC_CONFIG, CConfigMain::OnConfig)
|
||||||
|
@ -525,6 +526,11 @@ void CConfigMain::CreateGUIControls()
|
||||||
DVDRootText = new wxStaticText(PathsPage, ID_DVDROOT_TEXT, wxT("DVD Root:"), wxDefaultPosition, wxDefaultSize);
|
DVDRootText = new wxStaticText(PathsPage, ID_DVDROOT_TEXT, wxT("DVD Root:"), wxDefaultPosition, wxDefaultSize);
|
||||||
DVDRoot = new wxDirPickerCtrl(PathsPage, ID_DVDROOT, wxEmptyString, wxT("Choose a DVD root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL);
|
DVDRoot = new wxDirPickerCtrl(PathsPage, ID_DVDROOT, wxEmptyString, wxT("Choose a DVD root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL);
|
||||||
DVDRoot->SetPath(wxString::FromAscii(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot.c_str()));
|
DVDRoot->SetPath(wxString::FromAscii(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot.c_str()));
|
||||||
|
ApploaderPathText = new wxStaticText(PathsPage, ID_APPLOADERPATH_TEXT, wxT("Apploader:"), wxDefaultPosition, wxDefaultSize);
|
||||||
|
ApploaderPath = new wxFilePickerCtrl(PathsPage, ID_APPLOADERPATH, wxEmptyString, wxT("Choose file to use as apploader: (applies to discs constructed from directories only)"),
|
||||||
|
wxString::Format(wxT("apploader (.img)|*.img|All files (%s)|%s"), wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr),
|
||||||
|
wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);
|
||||||
|
ApploaderPath->SetPath(wxString::FromAscii(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strApploader.c_str()));
|
||||||
|
|
||||||
sPaths = new wxBoxSizer(wxVERTICAL);
|
sPaths = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
@ -544,6 +550,8 @@ void CConfigMain::CreateGUIControls()
|
||||||
sOtherPaths->Add(DefaultISO, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
sOtherPaths->Add(DefaultISO, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
||||||
sOtherPaths->Add(DVDRootText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
sOtherPaths->Add(DVDRootText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||||
sOtherPaths->Add(DVDRoot, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
sOtherPaths->Add(DVDRoot, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
||||||
|
sOtherPaths->Add(ApploaderPathText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||||
|
sOtherPaths->Add(ApploaderPath, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
||||||
sPaths->Add(sOtherPaths, 0, wxEXPAND|wxALL, 5);
|
sPaths->Add(sOtherPaths, 0, wxEXPAND|wxALL, 5);
|
||||||
PathsPage->SetSizer(sPaths);
|
PathsPage->SetSizer(sPaths);
|
||||||
sPaths->Layout();
|
sPaths->Layout();
|
||||||
|
@ -931,6 +939,11 @@ void CConfigMain::DVDRootChanged(wxFileDirPickerEvent& WXUNUSED (event))
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot = DVDRoot->GetPath().mb_str();
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDVDRoot = DVDRoot->GetPath().mb_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CConfigMain::ApploaderPathChanged(wxFileDirPickerEvent& WXUNUSED (event))
|
||||||
|
{
|
||||||
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strApploader = ApploaderPath->GetPath().mb_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Plugin settings
|
// Plugin settings
|
||||||
void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event))
|
void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event))
|
||||||
|
|
|
@ -131,6 +131,8 @@ private:
|
||||||
wxFilePickerCtrl* DefaultISO;
|
wxFilePickerCtrl* DefaultISO;
|
||||||
wxStaticText* DVDRootText;
|
wxStaticText* DVDRootText;
|
||||||
wxDirPickerCtrl* DVDRoot;
|
wxDirPickerCtrl* DVDRoot;
|
||||||
|
wxStaticText* ApploaderPathText;
|
||||||
|
wxFilePickerCtrl* ApploaderPath;
|
||||||
|
|
||||||
wxStaticText* PADText;
|
wxStaticText* PADText;
|
||||||
wxButton* PADConfig;
|
wxButton* PADConfig;
|
||||||
|
@ -206,6 +208,8 @@ private:
|
||||||
ID_DEFAULTISO,
|
ID_DEFAULTISO,
|
||||||
ID_DVDROOT_TEXT,
|
ID_DVDROOT_TEXT,
|
||||||
ID_DVDROOT,
|
ID_DVDROOT,
|
||||||
|
ID_APPLOADERPATH_TEXT,
|
||||||
|
ID_APPLOADERPATH,
|
||||||
|
|
||||||
ID_WIIMOTE_ABOUT,
|
ID_WIIMOTE_ABOUT,
|
||||||
ID_WIIMOTE_CONFIG,
|
ID_WIIMOTE_CONFIG,
|
||||||
|
@ -239,6 +243,7 @@ private:
|
||||||
void AddRemoveISOPaths(wxCommandEvent& event);
|
void AddRemoveISOPaths(wxCommandEvent& event);
|
||||||
void DefaultISOChanged(wxFileDirPickerEvent& event);
|
void DefaultISOChanged(wxFileDirPickerEvent& event);
|
||||||
void DVDRootChanged(wxFileDirPickerEvent& event);
|
void DVDRootChanged(wxFileDirPickerEvent& event);
|
||||||
|
void ApploaderPathChanged(wxFileDirPickerEvent& WXUNUSED (event));
|
||||||
|
|
||||||
void FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename);
|
void FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename);
|
||||||
void CallConfig(wxChoice* _pChoice);
|
void CallConfig(wxChoice* _pChoice);
|
||||||
|
|
Loading…
Reference in New Issue