This commit is contained in:
Jack Andersen 2015-07-24 14:26:15 -10:00
commit fb0abb652a
19 changed files with 118 additions and 46 deletions

View File

@ -8,7 +8,6 @@ set(NOD_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NODLib/include)
add_subdirectory(DataSpec) add_subdirectory(DataSpec)
add_subdirectory(Runtime) add_subdirectory(Runtime)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(include) include_directories(include)
add_library(RetroCommon add_library(RetroCommon
src/RetroCommon.cpp include/RetroCommon.hpp src/RetroCommon.cpp include/RetroCommon.hpp

View File

@ -1,6 +1,5 @@
include_directories(${HECL_INCLUDE_DIR} ${NOD_LIB_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR} include_directories(${HECL_INCLUDE_DIR} ${NOD_LIB_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR}
${SQUISH_INCLUDE_DIR}) ${SQUISH_INCLUDE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-multichar")
# Magic ingredient # Magic ingredient
find_package(atdna REQUIRED) find_package(atdna REQUIRED)
@ -13,6 +12,8 @@ macro(make_dnalist outlist)
endforeach() endforeach()
endmacro() endmacro()
include_directories(${ZLIB_INCLUDE_DIR} ${LZO_INCLUDE_DIR})
# Each game's DNA library # Each game's DNA library
add_subdirectory(DNACommon) add_subdirectory(DNACommon)
add_subdirectory(DNAMP1) add_subdirectory(DNAMP1)

View File

@ -133,13 +133,22 @@ struct CaseInsensitiveCompare
inline bool operator()(const std::string& lhs, const std::string& rhs) const inline bool operator()(const std::string& lhs, const std::string& rhs) const
{ {
#if _WIN32 #if _WIN32
if (stricmp(lhs.c_str(), rhs.c_str()) < 0) if (_stricmp(lhs.c_str(), rhs.c_str()) < 0)
#else #else
if (strcasecmp(lhs.c_str(), rhs.c_str()) < 0) if (strcasecmp(lhs.c_str(), rhs.c_str()) < 0)
#endif #endif
return true; return true;
return false; return false;
} }
#if _WIN32
inline bool operator()(const std::wstring& lhs, const std::wstring& rhs) const
{
if (_wcsicmp(lhs.c_str(), rhs.c_str()) < 0)
return true;
return false;
}
#endif
}; };
/* PAK entry stream reader */ /* PAK entry stream reader */

View File

@ -23,29 +23,6 @@ struct ISTRG
virtual bool readAngelScript(const AngelScript::asIScriptModule& in)=0; virtual bool readAngelScript(const AngelScript::asIScriptModule& in)=0;
virtual void writeAngelScript(std::ofstream& out) const=0; virtual void writeAngelScript(std::ofstream& out) const=0;
template <class SUBCLS>
static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
{
SUBCLS strg;
strg.read(rs);
std::ofstream strgOut(outPath.getAbsolutePath());
strg.writeAngelScript(strgOut);
return true;
}
template <class SUBCLS>
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
{
SUBCLS strg;
HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath);
if (!mod)
return false;
strg.readAngelScript(mod);
Athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}
}; };
std::unique_ptr<ISTRG> LoadSTRG(Athena::io::IStreamReader& reader); std::unique_ptr<ISTRG> LoadSTRG(Athena::io::IStreamReader& reader);

View File

@ -537,11 +537,13 @@ bool TXTR::Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
png_write_flush(png); png_write_flush(png);
png_destroy_write_struct(&png, &info); png_destroy_write_struct(&png, &info);
fclose(fp); fclose(fp);
return true;
} }
bool TXTR::Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath) bool TXTR::Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
{ {
return false;
} }
} }

View File

@ -49,7 +49,7 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry)
switch (entry.type.toUint32()) switch (entry.type.toUint32())
{ {
case SBIG('STRG'): case SBIG('STRG'):
return {STRG::Extract<STRG>, ".as"}; return {STRG::Extract, ".as"};
case SBIG('TXTR'): case SBIG('TXTR'):
return {TXTR::Extract, ".png"}; return {TXTR::Extract, ".png"};
} }

View File

@ -57,7 +57,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
writer.writeUint32(0x00030005); writer.writeUint32(0x00030005);
writer.writeUint32(0); writer.writeUint32(0);
writer.writeUint32(m_nameEntries.size()); writer.writeUint32((atUint32)m_nameEntries.size());
for (const NameEntry& entry : m_nameEntries) for (const NameEntry& entry : m_nameEntries)
{ {
((NameEntry&)entry).nameLen = entry.name.size(); ((NameEntry&)entry).nameLen = entry.name.size();

View File

@ -53,12 +53,33 @@ struct STRG : ISTRG, BigDNA
#else #else
return HECL::WideToUTF8(search->second->at(idx)); return HECL::WideToUTF8(search->second->at(idx));
#endif #endif
return std::string(); return HECL::SystemString();
} }
bool readAngelScript(const AngelScript::asIScriptModule& in); bool readAngelScript(const AngelScript::asIScriptModule& in);
void writeAngelScript(std::ofstream& out) const; void writeAngelScript(std::ofstream& out) const;
static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
{
STRG strg;
strg.read(rs);
std::ofstream strgOut(outPath.getAbsolutePath());
strg.writeAngelScript(strgOut);
return true;
}
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
{
STRG strg;
HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath);
if (!mod)
return false;
strg.readAngelScript(mod);
Athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}
}; };
} }

View File

@ -48,7 +48,7 @@ ResExtractor PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& entry)
switch (entry.type.toUint32()) switch (entry.type.toUint32())
{ {
case SBIG('STRG'): case SBIG('STRG'):
return {STRG::Extract<STRG>, ".as"}; return {STRG::Extract, ".as"};
case SBIG('TXTR'): case SBIG('TXTR'):
return {TXTR::Extract, ".png"}; return {TXTR::Extract, ".png"};
} }

View File

@ -141,6 +141,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in) bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
{ {
return false;
} }
void STRG::writeAngelScript(std::ofstream& out) const void STRG::writeAngelScript(std::ofstream& out) const

View File

@ -60,11 +60,32 @@ struct STRG : ISTRG, BigDNA
#else #else
return HECL::WideToUTF8(search->second->at(idx)); return HECL::WideToUTF8(search->second->at(idx));
#endif #endif
return std::string(); return HECL::SystemString();
} }
bool readAngelScript(const AngelScript::asIScriptModule& in); bool readAngelScript(const AngelScript::asIScriptModule& in);
void writeAngelScript(std::ofstream& out) const; void writeAngelScript(std::ofstream& out) const;
static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
{
STRG strg;
strg.read(rs);
std::ofstream strgOut(outPath.getAbsolutePath());
strg.writeAngelScript(strgOut);
return true;
}
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
{
STRG strg;
HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath);
if (!mod)
return false;
strg.readAngelScript(mod);
Athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}
}; };
} }

View File

@ -67,7 +67,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
FourCC("STRG").write(writer); FourCC("STRG").write(writer);
atUint32 strgSz = 4; atUint32 strgSz = 4;
for (const NameEntry& entry : m_nameEntries) for (const NameEntry& entry : m_nameEntries)
strgSz += entry.name.size() + 13; strgSz += (atUint32)entry.name.size() + 13;
atUint32 strgPad = ((strgSz + 63) & ~63) - strgSz; atUint32 strgPad = ((strgSz + 63) & ~63) - strgSz;
strgSz += strgPad; strgSz += strgPad;
writer.writeUint32(strgSz); writer.writeUint32(strgSz);
@ -88,12 +88,12 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
writer.writeUint32(dataSz); writer.writeUint32(dataSz);
writer.seek(36, Athena::Current); writer.seek(36, Athena::Current);
writer.writeUint32(m_nameEntries.size()); writer.writeUint32((atUint32)m_nameEntries.size());
for (const NameEntry& entry : m_nameEntries) for (const NameEntry& entry : m_nameEntries)
entry.write(writer); entry.write(writer);
writer.seek(strgPad, Athena::Current); writer.seek(strgPad, Athena::Current);
writer.writeUint32(m_entries.size()); writer.writeUint32((atUint32)m_entries.size());
for (const Entry& entry : m_entries) for (const Entry& entry : m_entries)
{ {
Entry copy = entry; Entry copy = entry;
@ -125,8 +125,9 @@ std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const NOD::DiscBase::IPartition
{ {
atUint32 compSz; atUint32 compSz;
atUint32 decompSz; atUint32 decompSz;
} blocks[head.blockCount]; };
strm->read(blocks, 8 * head.blockCount); std::unique_ptr<Block[]> blocks(new Block[head.blockCount]);
strm->read(blocks.get(), 8 * head.blockCount);
atUint64 maxBlockSz = 0; atUint64 maxBlockSz = 0;
atUint64 totalDecompSz = 0; atUint64 totalDecompSz = 0;

View File

@ -149,6 +149,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in) bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
{ {
return false;
} }
void STRG::writeAngelScript(std::ofstream& out) const void STRG::writeAngelScript(std::ofstream& out) const

View File

@ -60,7 +60,7 @@ struct STRG : ISTRG, BigDNA
#else #else
return search->second->at(idx); return search->second->at(idx);
#endif #endif
return std::string(); return HECL::SystemString();
} }
bool readAngelScript(const AngelScript::asIScriptModule& in); bool readAngelScript(const AngelScript::asIScriptModule& in);
@ -73,6 +73,18 @@ struct STRG : ISTRG, BigDNA
strg->writeAngelScript(strgOut); strg->writeAngelScript(strgOut);
return true; return true;
} }
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
{
STRG strg;
HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath);
if (!mod)
return false;
strg.readAngelScript(mod);
Athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}
}; };
} }

View File

@ -74,6 +74,7 @@ void SpecBase::doExtract(HECL::Database::Project& project, const ExtractPassInfo
bool SpecBase::canCook(const HECL::Database::Project& project, const CookTaskInfo& info) bool SpecBase::canCook(const HECL::Database::Project& project, const CookTaskInfo& info)
{ {
return false;
} }
void SpecBase::doCook(const HECL::Database::Project& project, const CookTaskInfo& info) void SpecBase::doCook(const HECL::Database::Project& project, const CookTaskInfo& info)
@ -82,6 +83,7 @@ void SpecBase::doCook(const HECL::Database::Project& project, const CookTaskInfo
bool SpecBase::canPackage(const HECL::Database::Project& project, const PackagePassInfo& info) bool SpecBase::canPackage(const HECL::Database::Project& project, const PackagePassInfo& info)
{ {
return false;
} }
void SpecBase::gatherDependencies(const HECL::Database::Project& project, const PackagePassInfo& info, void SpecBase::gatherDependencies(const HECL::Database::Project& project, const PackagePassInfo& info,

View File

@ -1,5 +1,6 @@
#include <utility> #include <utility>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "SpecBase.hpp" #include "SpecBase.hpp"
#include "DNAMP1/DNAMP1.hpp" #include "DNAMP1/DNAMP1.hpp"
@ -100,7 +101,8 @@ struct SpecMP1 : SpecBase
{ {
rep.childOpts.emplace_back(); rep.childOpts.emplace_back();
ExtractReport& childRep = rep.childOpts.back(); ExtractReport& childRep = rep.childOpts.back();
childRep.name = item.first; HECL::SystemStringView nameView(item.first);
childRep.name = nameView;
childRep.desc = item.second->getLevelString(); childRep.desc = item.second->getLevelString();
} }
} }
@ -149,7 +151,7 @@ struct SpecMP1 : SpecBase
{ {
HECL::SystemString lowerArg = arg; HECL::SystemString lowerArg = arg;
HECL::ToLower(lowerArg); HECL::ToLower(lowerArg);
if (!lowerArg.compare(0, 3, "mp1")) if (!lowerArg.compare(0, 3, _S("mp1")))
{ {
doMP1 = true; doMP1 = true;
size_t slashPos = arg.find(_S('/')); size_t slashPos = arg.find(_S('/'));
@ -247,31 +249,38 @@ struct SpecMP1 : SpecBase
bool checkFromProject(HECL::Database::Project& proj) bool checkFromProject(HECL::Database::Project& proj)
{ {
return false;
} }
bool readFromProject(HECL::Database::Project& proj) bool readFromProject(HECL::Database::Project& proj)
{ {
return false;
} }
bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
struct LevelSpec : public ILevelSpec struct LevelSpec : public ILevelSpec
{ {
bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
struct AreaSpec : public IAreaSpec struct AreaSpec : public IAreaSpec
{ {
bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
}; };
bool visitAreas(std::function<bool(const IAreaSpec&)>) bool visitAreas(std::function<bool(const IAreaSpec&)>)
{ {
return false;
} }
}; };
bool visitLevels(std::function<bool(const ILevelSpec&)>) bool visitLevels(std::function<bool(const ILevelSpec&)>)
{ {
return false;
} }
}; };

View File

@ -98,7 +98,8 @@ struct SpecMP2 : SpecBase
{ {
rep.childOpts.emplace_back(); rep.childOpts.emplace_back();
ExtractReport& childRep = rep.childOpts.back(); ExtractReport& childRep = rep.childOpts.back();
childRep.name = item.first; HECL::SystemStringView nameView(item.first);
childRep.name = nameView;
childRep.desc = item.second->getLevelString(); childRep.desc = item.second->getLevelString();
} }
} }
@ -147,7 +148,7 @@ struct SpecMP2 : SpecBase
{ {
HECL::SystemString lowerArg = arg; HECL::SystemString lowerArg = arg;
HECL::ToLower(lowerArg); HECL::ToLower(lowerArg);
if (!lowerArg.compare(0, 3, "mp2")) if (!lowerArg.compare(0, 3, _S("mp2")))
{ {
doMP2 = true; doMP2 = true;
size_t slashPos = arg.find(_S('/')); size_t slashPos = arg.find(_S('/'));
@ -245,31 +246,38 @@ struct SpecMP2 : SpecBase
bool checkFromProject(HECL::Database::Project& proj) bool checkFromProject(HECL::Database::Project& proj)
{ {
return false;
} }
bool readFromProject(HECL::Database::Project& proj) bool readFromProject(HECL::Database::Project& proj)
{ {
return false;
} }
bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
struct LevelSpec : public ILevelSpec struct LevelSpec : public ILevelSpec
{ {
bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
struct AreaSpec : public IAreaSpec struct AreaSpec : public IAreaSpec
{ {
bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
}; };
bool visitAreas(std::function<bool(const IAreaSpec&)>) bool visitAreas(std::function<bool(const IAreaSpec&)>)
{ {
return false;
} }
}; };
bool visitLevels(std::function<bool(const ILevelSpec&)>) bool visitLevels(std::function<bool(const ILevelSpec&)>)
{ {
return false;
} }
}; };

View File

@ -133,7 +133,8 @@ struct SpecMP3 : SpecBase
{ {
rep.childOpts.emplace_back(); rep.childOpts.emplace_back();
ExtractReport& childRep = rep.childOpts.back(); ExtractReport& childRep = rep.childOpts.back();
childRep.name = item.first; HECL::SystemStringView nameView(item.first);
childRep.name = nameView;
if (!item.first.compare("Worlds.pak")) if (!item.first.compare("Worlds.pak"))
continue; continue;
else if (!item.first.compare("Metroid6.pak")) else if (!item.first.compare("Metroid6.pak"))
@ -191,7 +192,7 @@ struct SpecMP3 : SpecBase
{ {
HECL::SystemString lowerArg = arg; HECL::SystemString lowerArg = arg;
HECL::ToLower(lowerArg); HECL::ToLower(lowerArg);
if (!lowerArg.compare(0, 3, "mp3")) if (!lowerArg.compare(0, 3, _S("mp3")))
{ {
doMP3 = true; doMP3 = true;
size_t slashPos = arg.find(_S('/')); size_t slashPos = arg.find(_S('/'));
@ -206,7 +207,7 @@ struct SpecMP3 : SpecBase
{ {
HECL::SystemString lowerArg = arg; HECL::SystemString lowerArg = arg;
HECL::ToLower(lowerArg); HECL::ToLower(lowerArg);
if (!lowerArg.compare(0, 2, "fe")) if (!lowerArg.compare(0, 2, _S("fe")))
{ {
doMPTFE = true; doMPTFE = true;
size_t slashPos = arg.find(_S('/')); size_t slashPos = arg.find(_S('/'));
@ -381,31 +382,38 @@ struct SpecMP3 : SpecBase
bool checkFromProject(HECL::Database::Project& proj) bool checkFromProject(HECL::Database::Project& proj)
{ {
return false;
} }
bool readFromProject(HECL::Database::Project& proj) bool readFromProject(HECL::Database::Project& proj)
{ {
return false;
} }
bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
struct LevelSpec : public ILevelSpec struct LevelSpec : public ILevelSpec
{ {
bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
struct AreaSpec : public IAreaSpec struct AreaSpec : public IAreaSpec
{ {
bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>) bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
{ {
return false;
} }
}; };
bool visitAreas(std::function<bool(const IAreaSpec&)>) bool visitAreas(std::function<bool(const IAreaSpec&)>)
{ {
return false;
} }
}; };
bool visitLevels(std::function<bool(const ILevelSpec&)>) bool visitLevels(std::function<bool(const ILevelSpec&)>)
{ {
return false;
} }
}; };

2
NODLib

@ -1 +1 @@
Subproject commit edb84685750cdf6d5d6ed5bd3801b2c31202468f Subproject commit 9e7e0979bd3fcdcd1930a477c96838f9d8418f70