mirror of https://github.com/AxioDL/metaforce.git
bug fixes with MP1's spec
This commit is contained in:
parent
c1f4f31e6f
commit
975429f3c6
|
@ -31,7 +31,7 @@ class UniqueID32 : public BigDNA
|
|||
public:
|
||||
Delete expl;
|
||||
inline void read(Athena::io::IStreamReader& reader)
|
||||
{reader.readUint32();}
|
||||
{m_id = reader.readUint32();}
|
||||
inline void write(Athena::io::IStreamWriter& writer) const
|
||||
{writer.writeUint32(m_id);}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class UniqueID64 : public BigDNA
|
|||
public:
|
||||
Delete expl;
|
||||
inline void read(Athena::io::IStreamReader& reader)
|
||||
{reader.readUint64();}
|
||||
{m_id = reader.readUint64();}
|
||||
inline void write(Athena::io::IStreamWriter& writer) const
|
||||
{writer.writeUint64(m_id);}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ struct MLVL : BigDNA
|
|||
{
|
||||
DECL_DNA
|
||||
UniqueID32 id;
|
||||
HECL::FourCC type;
|
||||
FourCC type;
|
||||
};
|
||||
Vector<Dependency, DNA_COUNT(depCount)> deps;
|
||||
|
||||
|
@ -63,7 +63,6 @@ struct MLVL : BigDNA
|
|||
Value<atUint32> areaIdx;
|
||||
Value<atUint32> dockIdx;
|
||||
};
|
||||
HECL::FourCC type;
|
||||
Vector<Endpoint, DNA_COUNT(endpointCount)> endpoints;
|
||||
|
||||
Value<atUint32> planeVertCount;
|
||||
|
@ -71,6 +70,7 @@ struct MLVL : BigDNA
|
|||
};
|
||||
Vector<Dock, DNA_COUNT(dockCount)> docks;
|
||||
};
|
||||
Vector<Area, DNA_COUNT(areaCount)> areas;
|
||||
|
||||
UniqueID32 worldMap;
|
||||
Value<atUint8> unknown2;
|
||||
|
|
|
@ -34,6 +34,12 @@ void PAK::read(Athena::io::IStreamReader& reader)
|
|||
m_idMap[m_entries.back().id] = &m_entries.back();
|
||||
}
|
||||
|
||||
atUint32 realCount = 0;
|
||||
for (Entry& entry : m_entries)
|
||||
{
|
||||
++realCount;
|
||||
}
|
||||
|
||||
m_nameMap.clear();
|
||||
m_nameMap.reserve(nameCount);
|
||||
for (NameEntry& entry : m_nameEntries)
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace DNAMP1
|
|||
class PAK : public BigDNA
|
||||
{
|
||||
public:
|
||||
DECL_EXPLICIT_DNA
|
||||
|
||||
struct NameEntry : public BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
|
@ -33,15 +35,11 @@ public:
|
|||
Value<atUint32> offset;
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<NameEntry> m_nameEntries;
|
||||
std::vector<Entry> m_entries;
|
||||
std::unordered_map<UniqueID32, Entry*> m_idMap;
|
||||
std::unordered_map<std::string, Entry*> m_nameMap;
|
||||
|
||||
public:
|
||||
DECL_EXPLICIT_DNA
|
||||
|
||||
inline const Entry* lookupEntry(const UniqueID32& id) const
|
||||
{
|
||||
std::unordered_map<UniqueID32, Entry*>::const_iterator result = m_idMap.find(id);
|
||||
|
@ -57,9 +55,6 @@ public:
|
|||
return result->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline std::vector<Entry>::iterator begin() {return m_entries.begin();}
|
||||
inline std::vector<Entry>::iterator end() {return m_entries.end();}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ const HECL::FourCC JAPNfcc("JAPN");
|
|||
|
||||
void STRG::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
uint32_t magic = reader.readUint32();
|
||||
if (magic != 0x87654321)
|
||||
LogModule.report(LogVisor::FatalError, "invalid STRG magic");
|
||||
|
@ -46,6 +47,7 @@ void STRG::read(Athena::io::IStreamReader& reader)
|
|||
|
||||
void STRG::write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.setEndian(Athena::BigEndian);
|
||||
writer.writeUint32(0x87654321);
|
||||
writer.writeUint32(version);
|
||||
writer.writeUint32(langs.size());
|
||||
|
|
|
@ -11,7 +11,13 @@ namespace Retro
|
|||
|
||||
struct SpecMP1 : SpecBase
|
||||
{
|
||||
std::vector<std::pair<std::string, DNAMP1::PAK>> m_paks;
|
||||
struct DiscPAK
|
||||
{
|
||||
const NOD::DiscBase::IPartition::Node& node;
|
||||
DNAMP1::PAK pak;
|
||||
DiscPAK(const NOD::DiscBase::IPartition::Node& n) : node(n) {}
|
||||
};
|
||||
std::vector<DiscPAK> m_paks;
|
||||
|
||||
bool checkFromGCNDisc(NOD::DiscGCN& disc,
|
||||
const std::vector<const HECL::SystemString*>& args,
|
||||
|
@ -40,7 +46,7 @@ struct SpecMP1 : SpecBase
|
|||
|
||||
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) + 16;
|
||||
const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19;
|
||||
|
||||
reps.emplace_back();
|
||||
ExtractReport& rep = reps.back();
|
||||
|
@ -50,8 +56,6 @@ struct SpecMP1 : SpecBase
|
|||
rep.desc += " (" + std::string(buildInfo) + ")";
|
||||
|
||||
/* Iterate PAKs and build level options */
|
||||
std::map<std::string, std::pair<const NOD::DiscBase::IPartition::Node*, DNAMP1::PAK*>,
|
||||
CaseInsensitiveCompare> orderedPaks;
|
||||
NOD::DiscBase::IPartition::Node& root = disc.getDataPartition()->getFSTRoot();
|
||||
for (const NOD::DiscBase::IPartition::Node& child : root)
|
||||
{
|
||||
|
@ -100,35 +104,39 @@ struct SpecMP1 : SpecBase
|
|||
|
||||
if (good)
|
||||
{
|
||||
m_paks.emplace_back(std::make_pair(name, DNAMP1::PAK()));
|
||||
std::pair<std::string, DNAMP1::PAK>& res = m_paks.back();
|
||||
m_paks.emplace_back(child);
|
||||
NOD::AthenaPartReadStream rs(child.beginReadStream());
|
||||
res.second.read(rs);
|
||||
orderedPaks[name] = std::make_pair(&child, &res.second);
|
||||
m_paks.back().pak.read(rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (std::pair<std::string, std::pair<const NOD::DiscBase::IPartition::Node*, DNAMP1::PAK*>> item : orderedPaks)
|
||||
/* Sort PAKs alphabetically */
|
||||
std::map<std::string, DiscPAK*, CaseInsensitiveCompare> orderedPaks;
|
||||
for (DiscPAK& dpak : m_paks)
|
||||
orderedPaks[dpak.node.getName()] = &dpak;
|
||||
|
||||
for (std::pair<std::string, DiscPAK*> item : orderedPaks)
|
||||
{
|
||||
rep.childOpts.emplace_back();
|
||||
ExtractReport& childRep = rep.childOpts.back();
|
||||
childRep.name = item.first;
|
||||
|
||||
for (DNAMP1::PAK::Entry& entry : *item.second.second)
|
||||
DNAMP1::PAK& pak = item.second->pak;
|
||||
for (DNAMP1::PAK::Entry& entry : pak.m_entries)
|
||||
{
|
||||
static const HECL::FourCC MLVLfourcc("MLVL");
|
||||
if (entry.type == MLVLfourcc)
|
||||
{
|
||||
NOD::AthenaPartReadStream rs(item.second.first->beginReadStream(entry.offset));
|
||||
NOD::AthenaPartReadStream rs(item.second->node.beginReadStream(entry.offset));
|
||||
DNAMP1::MLVL mlvl;
|
||||
mlvl.read(rs);
|
||||
const DNAMP1::PAK::Entry* nameEnt = item.second.second->lookupEntry(mlvl.worldNameId);
|
||||
const DNAMP1::PAK::Entry* nameEnt = pak.lookupEntry(mlvl.worldNameId);
|
||||
if (nameEnt)
|
||||
{
|
||||
DNAMP1::STRG mlvlName;
|
||||
rs.seek(nameEnt->offset, Athena::Begin);
|
||||
NOD::AthenaPartReadStream rs(item.second->node.beginReadStream(nameEnt->offset));
|
||||
mlvlName.read(rs);
|
||||
if (childRep.desc.size())
|
||||
childRep.desc += _S(", ");
|
||||
|
|
|
@ -4,5 +4,5 @@ static HECL::Database::DataSpecEntry SpecMP2
|
|||
(
|
||||
_S("MP2"),
|
||||
_S("Data specification for original Metroid Prime 2 engine"),
|
||||
[](HECL::Database::DataSpecTool tool) -> HECL::Database::IDataSpec* {}
|
||||
[](HECL::Database::DataSpecTool tool) -> HECL::Database::IDataSpec* {return nullptr;}
|
||||
);
|
||||
|
|
|
@ -4,6 +4,6 @@ static HECL::Database::DataSpecEntry SpecMP3
|
|||
(
|
||||
_S("MP3"),
|
||||
_S("Data specification for original Metroid Prime 3 engine"),
|
||||
[](HECL::Database::DataSpecTool tool) -> HECL::Database::IDataSpec* {}
|
||||
[](HECL::Database::DataSpecTool tool) -> HECL::Database::IDataSpec* {return nullptr;}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue