Added CMakeLists.txt

This commit is contained in:
Jack Andersen 2015-07-06 17:22:44 -10:00
parent 8cc3c014e6
commit 4f79743da0
13 changed files with 105 additions and 42 deletions

7
CMakeLists.txt Normal file
View File

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

16
DataSpec/CMakeLists.txt Normal file
View File

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

View File

View File

@ -0,0 +1,2 @@
add_library(DNAMP1
PAK.cpp)

View File

@ -1,6 +1,6 @@
HEADERS += \
$$PWD/PAK.hpp \
$$PWD/MLVL.hpp
$$PWD/MLVL.hpp \
$$PWD/PAK.hpp
SOURCES += \
$$PWD/PAK.cpp

View File

@ -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<atUint32> memRelayLinkCount;
struct MemRelayLink : public BigDNA
struct MemRelayLink : BigDNA
{
DECL_DNA
Value<atUint32> memRelayId;
@ -27,7 +27,7 @@ struct MLVL : public BigDNA
Value<atUint32> areaCount;
Value<atUint32> unknown1;
struct Area : public BigDNA
struct Area : BigDNA
{
DECL_DNA
DNAUniqueID32 areaNameId;
@ -41,7 +41,7 @@ struct MLVL : public BigDNA
Value<atUint32> padding;
Value<atUint32> depCount;
struct Dependency : public BigDNA
struct Dependency : BigDNA
{
DECL_DNA
DNAUniqueID32 id;
@ -53,11 +53,11 @@ struct MLVL : public BigDNA
Vector<atUint32, DNA_COUNT(depLayerCount)> depLayers;
Value<atUint32> dockCount;
struct Dock : public BigDNA
struct Dock : BigDNA
{
DECL_DNA
Value<atUint32> endpointCount;
struct Endpoint : public BigDNA
struct Endpoint : BigDNA
{
DECL_DNA
Value<atUint32> areaIdx;
@ -77,7 +77,7 @@ struct MLVL : public BigDNA
Value<atUint32> unknown3;
Value<atUint32> audioGroupCount;
struct AudioGroup : public BigDNA
struct AudioGroup : BigDNA
{
DECL_DNA
Value<atUint32> unknown;
@ -87,7 +87,7 @@ struct MLVL : public BigDNA
String<-1> unkString;
Value<atUint32> layerFlagCount;
struct LayerFlags : public BigDNA
struct LayerFlags : BigDNA
{
DECL_DNA
Value<atUint32> layerCount;

View File

@ -23,7 +23,7 @@ public:
String<DNA_COUNT(nameLen)> name;
};
struct Entry : public BigDNA
struct Entry : BigDNA
{
DECL_DNA
Value<atUint32> 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);
}

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,2 @@
add_library(DNAMP3
PAK.cpp)

View File

@ -14,7 +14,7 @@ namespace DNAMP3
class PAK : public BigDNA
{
public:
struct Header : public BigDNA
struct Header : BigDNA
{
DECL_DNA
Value<atUint32> 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<atUint32> 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);
}

View File

@ -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<HECL::ProjectPath>& 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<bool(const HECL::Database::ObjectBase&)>)=0;
struct ILevelSpec

View File

@ -1,28 +1,63 @@
#include <utility>
#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<std::string, std::pair<std::string, DNAMP1::PAK>> 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<std::map<std::string, std::pair<std::string, DNAMP1::PAK>>::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)
{
}

2
NODLib

@ -1 +1 @@
Subproject commit 179013df157f9434f72b0dbdecec481874847100
Subproject commit dea4eda76dfd07772335d518870420e358ae426b