From 4f79743da0821645001a37046b98357c1c3acde9 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 6 Jul 2015 17:22:44 -1000 Subject: [PATCH] Added CMakeLists.txt --- CMakeLists.txt | 7 ++++ DataSpec/CMakeLists.txt | 16 +++++++++ DataSpec/DNACommon/CMakeLists.txt | 0 DataSpec/DNAMP1/CMakeLists.txt | 2 ++ DataSpec/DNAMP1/DNAMP1.pri | 4 +-- DataSpec/DNAMP1/MLVL.hpp | 16 ++++----- DataSpec/DNAMP1/PAK.hpp | 8 ++--- DataSpec/DNAMP2/CMakeLists.txt | 1 + DataSpec/DNAMP3/CMakeLists.txt | 2 ++ DataSpec/DNAMP3/PAK.hpp | 16 ++++----- DataSpec/SpecBase.hpp | 14 ++++---- DataSpec/SpecMP1.cpp | 59 ++++++++++++++++++++++++------- NODLib | 2 +- 13 files changed, 105 insertions(+), 42 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 DataSpec/CMakeLists.txt create mode 100644 DataSpec/DNACommon/CMakeLists.txt create mode 100644 DataSpec/DNAMP1/CMakeLists.txt create mode 100644 DataSpec/DNAMP2/CMakeLists.txt create mode 100644 DataSpec/DNAMP3/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..0c5693eb8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.0) +project(RetroCommon) +if (NOT TARGET NOD) + add_subdirectory(NODLib) +endif() +include_directories(${ATHENA_INCLUDE_DIR} ${LOG_VISOR_INCLUDE_DIR}) +add_subdirectory(DataSpec) diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt new file mode 100644 index 000000000..9394449b6 --- /dev/null +++ b/DataSpec/CMakeLists.txt @@ -0,0 +1,16 @@ +include_directories(${HECL_INCLUDE_DIR} ${NOD_LIB_INCLUDE_DIR}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +add_subdirectory(DNACommon) +add_subdirectory(DNAMP1) +add_subdirectory(DNAMP2) +add_subdirectory(DNAMP3) + +add_library(RetroDataSpec + SpecBase.cpp + SpecMP1.cpp + SpecMP2.cpp + SpecMP3.cpp) +target_link_libraries(RetroDataSpec + DNAMP1 + DNAMP3) diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb diff --git a/DataSpec/DNAMP1/CMakeLists.txt b/DataSpec/DNAMP1/CMakeLists.txt new file mode 100644 index 000000000..9302569b1 --- /dev/null +++ b/DataSpec/DNAMP1/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(DNAMP1 + PAK.cpp) diff --git a/DataSpec/DNAMP1/DNAMP1.pri b/DataSpec/DNAMP1/DNAMP1.pri index 6e2e47528..7134590f9 100644 --- a/DataSpec/DNAMP1/DNAMP1.pri +++ b/DataSpec/DNAMP1/DNAMP1.pri @@ -1,6 +1,6 @@ HEADERS += \ - $$PWD/PAK.hpp \ - $$PWD/MLVL.hpp + $$PWD/MLVL.hpp \ + $$PWD/PAK.hpp SOURCES += \ $$PWD/PAK.cpp diff --git a/DataSpec/DNAMP1/MLVL.hpp b/DataSpec/DNAMP1/MLVL.hpp index 5bf717ddc..62ea60812 100644 --- a/DataSpec/DNAMP1/MLVL.hpp +++ b/DataSpec/DNAMP1/MLVL.hpp @@ -5,7 +5,7 @@ namespace Retro namespace DNAMP1 { -struct MLVL : public BigDNA +struct MLVL : BigDNA { DECL_DNA DNAFourCC magic; @@ -15,7 +15,7 @@ struct MLVL : public BigDNA DNAUniqueID32 worldSkyboxId; Value memRelayLinkCount; - struct MemRelayLink : public BigDNA + struct MemRelayLink : BigDNA { DECL_DNA Value memRelayId; @@ -27,7 +27,7 @@ struct MLVL : public BigDNA Value areaCount; Value unknown1; - struct Area : public BigDNA + struct Area : BigDNA { DECL_DNA DNAUniqueID32 areaNameId; @@ -41,7 +41,7 @@ struct MLVL : public BigDNA Value padding; Value depCount; - struct Dependency : public BigDNA + struct Dependency : BigDNA { DECL_DNA DNAUniqueID32 id; @@ -53,11 +53,11 @@ struct MLVL : public BigDNA Vector depLayers; Value dockCount; - struct Dock : public BigDNA + struct Dock : BigDNA { DECL_DNA Value endpointCount; - struct Endpoint : public BigDNA + struct Endpoint : BigDNA { DECL_DNA Value areaIdx; @@ -77,7 +77,7 @@ struct MLVL : public BigDNA Value unknown3; Value audioGroupCount; - struct AudioGroup : public BigDNA + struct AudioGroup : BigDNA { DECL_DNA Value unknown; @@ -87,7 +87,7 @@ struct MLVL : public BigDNA String<-1> unkString; Value layerFlagCount; - struct LayerFlags : public BigDNA + struct LayerFlags : BigDNA { DECL_DNA Value layerCount; diff --git a/DataSpec/DNAMP1/PAK.hpp b/DataSpec/DNAMP1/PAK.hpp index c20325952..e911d2346 100644 --- a/DataSpec/DNAMP1/PAK.hpp +++ b/DataSpec/DNAMP1/PAK.hpp @@ -23,7 +23,7 @@ public: String name; }; - struct Entry : public BigDNA + struct Entry : BigDNA { DECL_DNA Value compressed; @@ -79,16 +79,16 @@ public: m_nameMap[entry.name] = found->second; } } - void write(Athena::io::IStreamWriter& writer) + void write(Athena::io::IStreamWriter& writer) const { writer.setEndian(Athena::BigEndian); writer.writeUint32(0x00030005); writer.writeUint32(0); writer.writeUint32(m_nameEntries.size()); - for (NameEntry& entry : m_nameEntries) + for (const NameEntry& entry : m_nameEntries) { - entry.nameLen = entry.name.size(); + ((NameEntry&)entry).nameLen = entry.name.size(); entry.write(writer); } diff --git a/DataSpec/DNAMP2/CMakeLists.txt b/DataSpec/DNAMP2/CMakeLists.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/DataSpec/DNAMP2/CMakeLists.txt @@ -0,0 +1 @@ + diff --git a/DataSpec/DNAMP3/CMakeLists.txt b/DataSpec/DNAMP3/CMakeLists.txt new file mode 100644 index 000000000..95cf91618 --- /dev/null +++ b/DataSpec/DNAMP3/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(DNAMP3 + PAK.cpp) diff --git a/DataSpec/DNAMP3/PAK.hpp b/DataSpec/DNAMP3/PAK.hpp index 4a987aa70..bf354e06d 100644 --- a/DataSpec/DNAMP3/PAK.hpp +++ b/DataSpec/DNAMP3/PAK.hpp @@ -14,7 +14,7 @@ namespace DNAMP3 class PAK : public BigDNA { public: - struct Header : public BigDNA + struct Header : BigDNA { DECL_DNA Value version; @@ -23,7 +23,7 @@ public: Seek<40, Athena::Current> seek; } m_header; - struct NameEntry : public BigDNA + struct NameEntry : BigDNA { DECL_DNA String<-1> name; @@ -31,7 +31,7 @@ public: UniqueID64 id; }; - struct Entry : public BigDNA + struct Entry : BigDNA { DECL_DNA Value compressed; @@ -95,14 +95,14 @@ public: m_nameMap[entry.name] = found->second; } } - void write(Athena::io::IStreamWriter& writer) + void write(Athena::io::IStreamWriter& writer) const { writer.setEndian(Athena::BigEndian); m_header.write(writer); HECL::FourCC("STRG").write(writer); atUint32 strgSz = 4; - for (NameEntry& entry : m_nameEntries) + for (const NameEntry& entry : m_nameEntries) strgSz += entry.name.size() + 13; atUint32 strgPad = ((strgSz + 63) & ~63) - strgSz; strgSz += strgPad; @@ -116,7 +116,7 @@ public: HECL::FourCC("DATA").write(writer); atUint32 dataSz = 0; - for (Entry& entry : m_entries) + for (const Entry& entry : m_entries) dataSz += (entry.size + 63) & ~63; atUint32 dataPad = ((dataSz + 63) & ~63) - dataSz; dataSz += dataPad; @@ -124,12 +124,12 @@ public: writer.seek(36, Athena::Current); writer.writeUint32(m_nameEntries.size()); - for (NameEntry& entry : m_nameEntries) + for (const NameEntry& entry : m_nameEntries) entry.write(writer); writer.seek(strgPad, Athena::Current); writer.writeUint32(m_entries.size()); - for (Entry& entry : m_entries) + for (const Entry& entry : m_entries) entry.write(writer); writer.seek(rshdPad, Athena::Current); } diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index 954b75f72..bb5e64bd6 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -11,7 +11,7 @@ namespace Retro extern LogVisor::LogModule LogModule; -struct SpecBase : public HECL::Database::IDataSpec +struct SpecBase : HECL::Database::IDataSpec { bool canExtract(const ExtractPassInfo& info); void doExtract(const HECL::Database::Project& project, const ExtractPassInfo& info); @@ -24,14 +24,14 @@ struct SpecBase : public HECL::Database::IDataSpec std::unordered_set& implicitsOut); void doPackage(const HECL::Database::Project& project, const PackagePassInfo& info); - virtual bool checkFromGCNDisc(const NOD::DiscGCN& disc)=0; - virtual bool readFromGCNDisc(const NOD::DiscGCN& disc)=0; + virtual bool checkFromGCNDisc(NOD::DiscGCN& disc, ExtractOption& opts)=0; + virtual bool readFromGCNDisc(NOD::DiscGCN& disc)=0; - virtual bool checkFromWiiDisc(const NOD::DiscWii& disc)=0; - virtual bool readFromWiiDisc(const NOD::DiscWii& disc)=0; + virtual bool checkFromWiiDisc(NOD::DiscWii& disc, ExtractOption& opts)=0; + virtual bool readFromWiiDisc(NOD::DiscWii& disc)=0; - virtual bool checkFromProject(const HECL::Database::Project& proj)=0; - virtual bool readFromProject(const HECL::Database::Project& proj)=0; + virtual bool checkFromProject(HECL::Database::Project& proj)=0; + virtual bool readFromProject(HECL::Database::Project& proj)=0; virtual bool visitGameObjects(std::function)=0; struct ILevelSpec diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index afd4b1002..5512a9ba3 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -1,28 +1,63 @@ +#include + +#define NOD_ATHENA 1 #include "SpecBase.hpp" +#include "DNAMP1/PAK.hpp" namespace Retro { -struct SpecMP1 : public SpecBase +struct SpecMP1 : SpecBase { - bool checkFromGCNDisc(const NOD::DiscGCN& disc) + std::map> m_worldPaks; + + bool checkFromGCNDisc(NOD::DiscGCN& disc, ExtractOption& opts) { + if (memcmp(disc.getHeader().gameID, "GM8", 3)) + return false; + + /* Iterate PAKs and build level options */ + m_worldPaks.clear(); + NOD::DiscBase::IPartition::Node& root = disc.getDataPartition()->getFSTRoot(); + for (const NOD::DiscBase::IPartition::Node& child : root) + { + std::string name = child.getName(); + std::transform(name.begin(), name.end(), name.begin(), tolower); + if (!name.compare(0, 7, "metroid") && !name.compare(8, 4, ".pak")) + { + /* This is a world pak */ + std::pair>::iterator,bool> res = + m_worldPaks.emplace(std::make_pair(name, std::make_pair(child.getName(), DNAMP1::PAK()))); + if (res.second) + { + NOD::AthenaPartReadStream rs(child.beginReadStream()); + res.first->second.second.read(rs); + } + } + + } + + return true; } - bool readFromGCNDisc(const NOD::DiscGCN& disc) + bool readFromGCNDisc(NOD::DiscGCN& disc) + { + + } + + bool checkFromWiiDisc(NOD::DiscWii& disc, ExtractOption& opts) + { + if (memcmp(disc.getHeader().gameID, "R3M", 3)) + return false; + return true; + } + bool readFromWiiDisc(NOD::DiscWii& disc) { } - bool checkFromWiiDisc(const NOD::DiscWii& disc) + bool checkFromProject(HECL::Database::Project& proj) { } - bool readFromWiiDisc(const NOD::DiscWii& disc) - { - } - - bool checkFromProject(const HECL::Database::Project& proj) - { - } - bool readFromProject(const HECL::Database::Project& proj) + bool readFromProject(HECL::Database::Project& proj) { } diff --git a/NODLib b/NODLib index 179013df1..dea4eda76 160000 --- a/NODLib +++ b/NODLib @@ -1 +1 @@ -Subproject commit 179013df157f9434f72b0dbdecec481874847100 +Subproject commit dea4eda76dfd07772335d518870420e358ae426b