mp1 dataspec adjustments

This commit is contained in:
Jack Andersen 2015-07-12 08:07:58 -10:00
parent 6aa69f2775
commit abb9d4c000
5 changed files with 74 additions and 64 deletions

View File

@ -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)

View File

@ -17,10 +17,14 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
const char* gameID = disc->getHeader().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::vector<ExtractReport
return false;
}
if (isWii)
return checkFromWiiDisc(*(NOD::DiscWii*)disc.get(), info.extractArgs, reps);
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 = &regNONE;
switch (region)
{
case 'E':
regstr = &regE;
break;
case 'J':
regstr = &regJ;
break;
case 'P':
regstr = &regP;
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)

View File

@ -24,13 +24,15 @@ struct SpecBase : HECL::Database::IDataSpec
std::unordered_set<HECL::ProjectPath>& implicitsOut);
void doPackage(const HECL::Database::Project& project, const PackagePassInfo& info);
virtual bool checkFromGCNDisc(NOD::DiscGCN& disc, const std::vector<const HECL::SystemString*>& args,
virtual bool checkFromStandaloneDisc(NOD::DiscBase& disc,
const std::string& regstr,
const std::vector<const HECL::SystemString*>& args,
std::vector<ExtractReport>& reps)=0;
virtual bool readFromGCNDisc(NOD::DiscGCN& disc, const std::vector<const HECL::SystemString*>& args)=0;
virtual bool checkFromWiiDisc(NOD::DiscWii& disc, const std::vector<const HECL::SystemString*>& args,
virtual bool checkFromTrilogyDisc(NOD::DiscBase& disc,
const std::string& regstr,
const std::vector<const HECL::SystemString*>& args,
std::vector<ExtractReport>& reps)=0;
virtual bool readFromWiiDisc(NOD::DiscWii& disc, const std::vector<const HECL::SystemString*>& args)=0;
virtual bool extractFromDisc()=0;
virtual bool checkFromProject(HECL::Database::Project& proj)=0;
virtual bool readFromProject(HECL::Database::Project& proj)=0;

View File

@ -18,45 +18,13 @@ struct SpecMP1 : SpecBase
DiscPAK(const NOD::DiscBase::IPartition::Node& n) : node(n) {}
};
std::vector<DiscPAK> m_paks;
std::map<std::string, DiscPAK*, CaseInsensitiveCompare> m_orderedPaks;
bool checkFromGCNDisc(NOD::DiscGCN& disc,
void buildPaks(NOD::DiscBase::IPartition::Node& root,
const std::vector<const HECL::SystemString*>& args,
std::vector<ExtractReport>& reps)
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 = &regNONE;
switch (region)
{
case 'E':
regstr = &regE;
break;
case 'J':
regstr = &regJ;
break;
case 'P':
regstr = &regP;
break;
}
NOD::DiscGCN::IPartition* partition = disc.getDataPartition();
std::unique_ptr<uint8_t[]> 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<std::string, DiscPAK*, CaseInsensitiveCompare> orderedPaks;
m_orderedPaks.clear();
for (DiscPAK& dpak : m_paks)
orderedPaks[dpak.node.getName()] = &dpak;
m_orderedPaks[dpak.node.getName()] = &dpak;
for (std::pair<std::string, DiscPAK*> item : orderedPaks)
/* Assemble extract report */
for (std::pair<std::string, DiscPAK*> item : m_orderedPaks)
{
rep.childOpts.emplace_back();
ExtractReport& childRep = rep.childOpts.back();
@ -149,25 +120,39 @@ struct SpecMP1 : SpecBase
}
}
}
return true;
}
bool readFromGCNDisc(NOD::DiscGCN& disc,
const std::vector<const HECL::SystemString*>& args)
{
}
bool checkFromWiiDisc(NOD::DiscWii& disc,
bool checkFromStandaloneDisc(NOD::DiscBase& disc,
const std::string& regstr,
const std::vector<const HECL::SystemString*>& args,
std::vector<ExtractReport>& reps)
{
if (memcmp(disc.getHeader().gameID, "R3M", 3))
return false;
NOD::DiscGCN::IPartition* partition = disc.getDataPartition();
std::unique_ptr<uint8_t[]> 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 readFromWiiDisc(NOD::DiscWii& disc,
const std::vector<const HECL::SystemString*>& args)
bool checkFromTrilogyDisc(NOD::DiscBase& disc,
const std::string& regstr,
const std::vector<const HECL::SystemString*>& args,
std::vector<ExtractReport>& reps)
{
return true;
}
bool extractFromDisc()
{
}

2
NODLib

@ -1 +1 @@
Subproject commit 1c2ade8d5225aa9f6e9526d1adf377776b009a32
Subproject commit f30a9302b6bad6811efd8125b424c70069514658