From abb9d4c0004daa0c892b7d81eb189549089f8cf2 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 12 Jul 2015 08:07:58 -1000 Subject: [PATCH] mp1 dataspec adjustments --- DataSpec/CMakeLists.txt | 2 +- DataSpec/SpecBase.cpp | 29 ++++++++++++-- DataSpec/SpecBase.hpp | 16 ++++---- DataSpec/SpecMP1.cpp | 89 +++++++++++++++++------------------------ NODLib | 2 +- 5 files changed, 74 insertions(+), 64 deletions(-) diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt index 9d64ec357..f6c61ee60 100644 --- a/DataSpec/CMakeLists.txt +++ b/DataSpec/CMakeLists.txt @@ -1,5 +1,5 @@ include_directories(${HECL_INCLUDE_DIR} ${NOD_LIB_INCLUDE_DIR}) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Magic ingredient find_package(atdna REQUIRED) diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index ea2698eac..8c991a540 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -17,10 +17,14 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vectorgetHeader().gameID; bool valid = false; + bool standalone = true; if (isWii) { if (!memcmp(gameID, "R3M", 3)) + { valid = true; + standalone = false; + } else if (!memcmp(gameID, "R3IJ01", 6)) valid = true; } @@ -36,10 +40,29 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vectorgetHeader().gameID[3]; + static const std::string regNONE = ""; + static const std::string regE = "NTSC"; + static const std::string regJ = "NTSC-J"; + static const std::string regP = "PAL"; + const std::string* regstr = ®NONE; + switch (region) + { + case 'E': + regstr = ®E; + break; + case 'J': + regstr = ®J; + break; + case 'P': + regstr = ®P; + break; + } + + if (standalone) + return checkFromStandaloneDisc(*disc.get(), *regstr, info.extractArgs, reps); else - return checkFromGCNDisc(*(NOD::DiscGCN*)disc.get(), info.extractArgs, reps); + return checkFromTrilogyDisc(*disc.get(), *regstr, info.extractArgs, reps); } void SpecBase::doExtract(const HECL::Database::Project& project, const ExtractPassInfo& info) diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index 5a39ce4c3..62aec499c 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -24,13 +24,15 @@ struct SpecBase : HECL::Database::IDataSpec std::unordered_set& implicitsOut); void doPackage(const HECL::Database::Project& project, const PackagePassInfo& info); - virtual bool checkFromGCNDisc(NOD::DiscGCN& disc, const std::vector& args, - std::vector& reps)=0; - virtual bool readFromGCNDisc(NOD::DiscGCN& disc, const std::vector& args)=0; - - virtual bool checkFromWiiDisc(NOD::DiscWii& disc, const std::vector& args, - std::vector& reps)=0; - virtual bool readFromWiiDisc(NOD::DiscWii& disc, const std::vector& args)=0; + virtual bool checkFromStandaloneDisc(NOD::DiscBase& disc, + const std::string& regstr, + const std::vector& args, + std::vector& reps)=0; + virtual bool checkFromTrilogyDisc(NOD::DiscBase& disc, + const std::string& regstr, + const std::vector& args, + std::vector& reps)=0; + virtual bool extractFromDisc()=0; virtual bool checkFromProject(HECL::Database::Project& proj)=0; virtual bool readFromProject(HECL::Database::Project& proj)=0; diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 3538c1577..9274b0eb2 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -18,45 +18,13 @@ struct SpecMP1 : SpecBase DiscPAK(const NOD::DiscBase::IPartition::Node& n) : node(n) {} }; std::vector m_paks; + std::map m_orderedPaks; - bool checkFromGCNDisc(NOD::DiscGCN& disc, - const std::vector& args, - std::vector& reps) + void buildPaks(NOD::DiscBase::IPartition::Node& root, + const std::vector& args, + ExtractReport& rep) { - if (memcmp(disc.getHeader().gameID, "GM8", 3)) - return false; - char region = disc.getHeader().gameID[3]; - static const std::string regNONE = ""; - static const std::string regE = "NTSC"; - static const std::string regJ = "NTSC-J"; - static const std::string regP = "PAL"; - const std::string* regstr = ®NONE; - switch (region) - { - case 'E': - regstr = ®E; - break; - case 'J': - regstr = ®J; - break; - case 'P': - regstr = ®P; - break; - } - - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); - std::unique_ptr dolBuf = partition->getDOLBuf(); - const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19; - - reps.emplace_back(); - ExtractReport& rep = reps.back(); - rep.name = "MP1"; - rep.desc = "Metroid Prime " + *regstr; - if (buildInfo) - rep.desc += " (" + std::string(buildInfo) + ")"; - - /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node& root = disc.getDataPartition()->getFSTRoot(); + m_paks.clear(); for (const NOD::DiscBase::IPartition::Node& child : root) { const std::string& name = child.getName(); @@ -85,6 +53,8 @@ struct SpecMP1 : SpecBase good = true; } } + else + good = true; if (!good) { @@ -113,11 +83,12 @@ struct SpecMP1 : SpecBase } /* Sort PAKs alphabetically */ - std::map orderedPaks; + m_orderedPaks.clear(); for (DiscPAK& dpak : m_paks) - orderedPaks[dpak.node.getName()] = &dpak; + m_orderedPaks[dpak.node.getName()] = &dpak; - for (std::pair item : orderedPaks) + /* Assemble extract report */ + for (std::pair item : m_orderedPaks) { rep.childOpts.emplace_back(); ExtractReport& childRep = rep.childOpts.back(); @@ -149,25 +120,39 @@ struct SpecMP1 : SpecBase } } } + } + + bool checkFromStandaloneDisc(NOD::DiscBase& disc, + const std::string& regstr, + const std::vector& args, + std::vector& reps) + { + NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); + std::unique_ptr dolBuf = partition->getDOLBuf(); + const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19; + + reps.emplace_back(); + ExtractReport& rep = reps.back(); + rep.name = "MP1"; + rep.desc = "Metroid Prime " + regstr; + if (buildInfo) + rep.desc += " (" + std::string(buildInfo) + ")"; + + /* Iterate PAKs and build level options */ + NOD::DiscBase::IPartition::Node& root = disc.getDataPartition()->getFSTRoot(); + buildPaks(root, args, rep); return true; } - bool readFromGCNDisc(NOD::DiscGCN& disc, - const std::vector& args) - { - } - - bool checkFromWiiDisc(NOD::DiscWii& disc, - const std::vector& args, - std::vector& reps) + bool checkFromTrilogyDisc(NOD::DiscBase& disc, + const std::string& regstr, + const std::vector& args, + std::vector& reps) { - if (memcmp(disc.getHeader().gameID, "R3M", 3)) - return false; return true; } - bool readFromWiiDisc(NOD::DiscWii& disc, - const std::vector& args) + bool extractFromDisc() { } diff --git a/NODLib b/NODLib index 1c2ade8d5..f30a9302b 160000 --- a/NODLib +++ b/NODLib @@ -1 +1 @@ -Subproject commit 1c2ade8d5225aa9f6e9526d1adf377776b009a32 +Subproject commit f30a9302b6bad6811efd8125b424c70069514658