mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-15 02:31:20 +00:00
Add CDvdFile::SetRootDirectory; load proper DOL for Wii versions
This commit is contained in:
parent
acb137c790
commit
049a7764b8
@ -94,6 +94,7 @@ std::condition_variable CDvdFile::m_WorkerCV;
|
|||||||
std::mutex CDvdFile::m_WaitMutex;
|
std::mutex CDvdFile::m_WaitMutex;
|
||||||
std::atomic_bool CDvdFile::m_WorkerRun = {false};
|
std::atomic_bool CDvdFile::m_WorkerRun = {false};
|
||||||
std::vector<std::shared_ptr<IDvdRequest>> CDvdFile::m_RequestQueue;
|
std::vector<std::shared_ptr<IDvdRequest>> CDvdFile::m_RequestQueue;
|
||||||
|
std::string CDvdFile::m_rootDirectory;
|
||||||
|
|
||||||
CDvdFile::CDvdFile(std::string_view path) : x18_path(path) {
|
CDvdFile::CDvdFile(std::string_view path) : x18_path(path) {
|
||||||
auto* node = ResolvePath(path);
|
auto* node = ResolvePath(path);
|
||||||
@ -169,6 +170,13 @@ nod::Node* CDvdFile::ResolvePath(std::string_view path) {
|
|||||||
if (path.starts_with('/')) {
|
if (path.starts_with('/')) {
|
||||||
path.remove_prefix(1);
|
path.remove_prefix(1);
|
||||||
}
|
}
|
||||||
|
std::string prefixedPath;
|
||||||
|
if (!m_rootDirectory.empty()) {
|
||||||
|
prefixedPath = m_rootDirectory;
|
||||||
|
prefixedPath += '/';
|
||||||
|
prefixedPath += path;
|
||||||
|
path = prefixedPath;
|
||||||
|
}
|
||||||
auto* node = &m_DvdRoot->getDataPartition()->getFSTRoot();
|
auto* node = &m_DvdRoot->getDataPartition()->getFSTRoot();
|
||||||
while (node != nullptr && !path.empty()) {
|
while (node != nullptr && !path.empty()) {
|
||||||
std::string component;
|
std::string component;
|
||||||
@ -232,4 +240,6 @@ SDiscInfo CDvdFile::DiscInfo() {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDvdFile::SetRootDirectory(const std::string_view& rootDir) { m_rootDirectory = rootDir; }
|
||||||
|
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
@ -39,6 +39,7 @@ class CDvdFile {
|
|||||||
static std::mutex m_WaitMutex;
|
static std::mutex m_WaitMutex;
|
||||||
static std::atomic_bool m_WorkerRun;
|
static std::atomic_bool m_WorkerRun;
|
||||||
static std::vector<std::shared_ptr<IDvdRequest>> m_RequestQueue;
|
static std::vector<std::shared_ptr<IDvdRequest>> m_RequestQueue;
|
||||||
|
static std::string m_rootDirectory;
|
||||||
static void WorkerProc();
|
static void WorkerProc();
|
||||||
|
|
||||||
std::string x18_path;
|
std::string x18_path;
|
||||||
@ -52,6 +53,7 @@ class CDvdFile {
|
|||||||
public:
|
public:
|
||||||
static bool Initialize(const std::string_view& path);
|
static bool Initialize(const std::string_view& path);
|
||||||
static SDiscInfo DiscInfo();
|
static SDiscInfo DiscInfo();
|
||||||
|
static void SetRootDirectory(const std::string_view& rootDir);
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
CDvdFile(std::string_view path);
|
CDvdFile(std::string_view path);
|
||||||
|
@ -18,11 +18,16 @@ enum class EGame {
|
|||||||
MetroidPrime3,
|
MetroidPrime3,
|
||||||
MetroidPrimeTrilogy,
|
MetroidPrimeTrilogy,
|
||||||
};
|
};
|
||||||
|
enum class EPlatform {
|
||||||
|
GameCube,
|
||||||
|
Wii,
|
||||||
|
};
|
||||||
|
|
||||||
struct MetaforceVersionInfo {
|
struct MetaforceVersionInfo {
|
||||||
std::string version;
|
std::string version;
|
||||||
ERegion region;
|
ERegion region;
|
||||||
EGame game;
|
EGame game;
|
||||||
|
EPlatform platform;
|
||||||
std::string gameTitle;
|
std::string gameTitle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -589,14 +589,24 @@ void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IA
|
|||||||
if (discInfo.gameId[4] != '0' || discInfo.gameId[5] != '1') {
|
if (discInfo.gameId[4] != '0' || discInfo.gameId[5] != '1') {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Unknown game ID {}"), std::string_view{discInfo.gameId.data(), 6});
|
Log.report(logvisor::Fatal, FMT_STRING("Unknown game ID {}"), std::string_view{discInfo.gameId.data(), 6});
|
||||||
}
|
}
|
||||||
if (strncmp(discInfo.gameId.data(), "GM8", 3) == 0 || strncmp(discInfo.gameId.data(), "R3I", 3) == 0) {
|
if (strncmp(discInfo.gameId.data(), "GM8", 3) == 0) {
|
||||||
m_version.game = EGame::MetroidPrime1;
|
m_version.game = EGame::MetroidPrime1;
|
||||||
} else if (strncmp(discInfo.gameId.data(), "G2M", 3) == 0 || strncmp(discInfo.gameId.data(), "R32", 3) == 0) {
|
m_version.platform = EPlatform::GameCube;
|
||||||
|
} else if (strncmp(discInfo.gameId.data(), "R3I", 3) == 0) {
|
||||||
|
m_version.game = EGame::MetroidPrime1;
|
||||||
|
m_version.platform = EPlatform::Wii;
|
||||||
|
} else if (strncmp(discInfo.gameId.data(), "G2M", 3) == 0) {
|
||||||
m_version.game = EGame::MetroidPrime2;
|
m_version.game = EGame::MetroidPrime2;
|
||||||
} else if (strncmp(discInfo.gameId.data(), "R3M", 3) == 0) {
|
m_version.platform = EPlatform::GameCube;
|
||||||
m_version.game = EGame::MetroidPrime3;
|
} else if (strncmp(discInfo.gameId.data(), "R32", 3) == 0) {
|
||||||
|
m_version.game = EGame::MetroidPrime2;
|
||||||
|
m_version.platform = EPlatform::Wii;
|
||||||
} else if (strncmp(discInfo.gameId.data(), "RM3", 3) == 0) {
|
} else if (strncmp(discInfo.gameId.data(), "RM3", 3) == 0) {
|
||||||
|
m_version.game = EGame::MetroidPrime3;
|
||||||
|
m_version.platform = EPlatform::Wii;
|
||||||
|
} else if (strncmp(discInfo.gameId.data(), "R3M", 3) == 0) {
|
||||||
m_version.game = EGame::MetroidPrimeTrilogy;
|
m_version.game = EGame::MetroidPrimeTrilogy;
|
||||||
|
m_version.platform = EPlatform::Wii;
|
||||||
} else {
|
} else {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Unknown game ID {}"), std::string_view{discInfo.gameId.data(), 6});
|
Log.report(logvisor::Fatal, FMT_STRING("Unknown game ID {}"), std::string_view{discInfo.gameId.data(), 6});
|
||||||
}
|
}
|
||||||
@ -625,9 +635,15 @@ void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IA
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CDvdFile file("default.dol");
|
std::string_view dolFile = "default.dol"sv;
|
||||||
|
if (m_version.game == EGame::MetroidPrimeTrilogy) {
|
||||||
|
dolFile = "rs5mp1_p.dol";
|
||||||
|
} else if (m_version.platform == EPlatform::Wii) {
|
||||||
|
dolFile = "rs5mp1jpn_p.dol";
|
||||||
|
}
|
||||||
|
CDvdFile file(dolFile);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Failed to open default.dol"));
|
Log.report(logvisor::Fatal, FMT_STRING("Failed to open {}"), dolFile);
|
||||||
}
|
}
|
||||||
std::unique_ptr<u8[]> buf = std::make_unique<u8[]>(file.Length());
|
std::unique_ptr<u8[]> buf = std::make_unique<u8[]>(file.Length());
|
||||||
u32 readLen = file.SyncRead(buf.get(), file.Length());
|
u32 readLen = file.SyncRead(buf.get(), file.Length());
|
||||||
@ -638,6 +654,14 @@ void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IA
|
|||||||
m_version.version = buildInfo;
|
m_version.version = buildInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainLog.report(logvisor::Level::Info, FMT_STRING("Loading data from {} {} ({})"), GetGameTitle(),
|
||||||
|
magic_enum::enum_name(GetRegion()), GetVersionString());
|
||||||
|
|
||||||
|
if (m_version.game == EGame::MetroidPrimeTrilogy) {
|
||||||
|
CDvdFile::SetRootDirectory("MP1");
|
||||||
|
} else if (m_version.platform == EPlatform::Wii) {
|
||||||
|
CDvdFile::SetRootDirectory("MP1JPN");
|
||||||
|
}
|
||||||
InitializeSubsystems();
|
InitializeSubsystems();
|
||||||
AddOverridePaks();
|
AddOverridePaks();
|
||||||
x128_globalObjects->PostInitialize();
|
x128_globalObjects->PostInitialize();
|
||||||
@ -645,9 +669,6 @@ void CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IA
|
|||||||
x70_tweaks.RegisterResourceTweaks(m_cvarMgr);
|
x70_tweaks.RegisterResourceTweaks(m_cvarMgr);
|
||||||
AddWorldPaks();
|
AddWorldPaks();
|
||||||
|
|
||||||
MainLog.report(logvisor::Level::Info, FMT_STRING("Loading data from {} {} ({})"),
|
|
||||||
GetGameTitle(), magic_enum::enum_name(GetRegion()), GetVersionString());
|
|
||||||
|
|
||||||
auto args = aurora::get_args();
|
auto args = aurora::get_args();
|
||||||
for (auto it = args.begin(); it != args.end(); ++it) {
|
for (auto it = args.begin(); it != args.end(); ++it) {
|
||||||
if (*it == "--warp" && args.end() - it >= 3) {
|
if (*it == "--warp" && args.end() - it >= 3) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user