mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of https://github.com/RetroView/RetroCommon
This commit is contained in:
commit
fb0abb652a
|
@ -8,7 +8,6 @@ set(NOD_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/NODLib/include)
|
|||
add_subdirectory(DataSpec)
|
||||
add_subdirectory(Runtime)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
include_directories(include)
|
||||
add_library(RetroCommon
|
||||
src/RetroCommon.cpp include/RetroCommon.hpp
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
include_directories(${HECL_INCLUDE_DIR} ${NOD_LIB_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR}
|
||||
${SQUISH_INCLUDE_DIR})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-multichar")
|
||||
|
||||
# Magic ingredient
|
||||
find_package(atdna REQUIRED)
|
||||
|
@ -13,6 +12,8 @@ macro(make_dnalist outlist)
|
|||
endforeach()
|
||||
endmacro()
|
||||
|
||||
include_directories(${ZLIB_INCLUDE_DIR} ${LZO_INCLUDE_DIR})
|
||||
|
||||
# Each game's DNA library
|
||||
add_subdirectory(DNACommon)
|
||||
add_subdirectory(DNAMP1)
|
||||
|
|
|
@ -133,13 +133,22 @@ struct CaseInsensitiveCompare
|
|||
inline bool operator()(const std::string& lhs, const std::string& rhs) const
|
||||
{
|
||||
#if _WIN32
|
||||
if (stricmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||
if (_stricmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||
#else
|
||||
if (strcasecmp(lhs.c_str(), rhs.c_str()) < 0)
|
||||
#endif
|
||||
return true;
|
||||
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 */
|
||||
|
|
|
@ -23,29 +23,6 @@ struct ISTRG
|
|||
|
||||
virtual bool readAngelScript(const AngelScript::asIScriptModule& in)=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);
|
||||
|
||||
|
|
|
@ -537,11 +537,13 @@ bool TXTR::Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
|||
png_write_flush(png);
|
||||
png_destroy_write_struct(&png, &info);
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TXTR::Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry)
|
|||
switch (entry.type.toUint32())
|
||||
{
|
||||
case SBIG('STRG'):
|
||||
return {STRG::Extract<STRG>, ".as"};
|
||||
return {STRG::Extract, ".as"};
|
||||
case SBIG('TXTR'):
|
||||
return {TXTR::Extract, ".png"};
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
writer.writeUint32(0x00030005);
|
||||
writer.writeUint32(0);
|
||||
|
||||
writer.writeUint32(m_nameEntries.size());
|
||||
writer.writeUint32((atUint32)m_nameEntries.size());
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
{
|
||||
((NameEntry&)entry).nameLen = entry.name.size();
|
||||
|
|
|
@ -53,12 +53,33 @@ struct STRG : ISTRG, BigDNA
|
|||
#else
|
||||
return HECL::WideToUTF8(search->second->at(idx));
|
||||
#endif
|
||||
return std::string();
|
||||
return HECL::SystemString();
|
||||
}
|
||||
|
||||
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ ResExtractor PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& entry)
|
|||
switch (entry.type.toUint32())
|
||||
{
|
||||
case SBIG('STRG'):
|
||||
return {STRG::Extract<STRG>, ".as"};
|
||||
return {STRG::Extract, ".as"};
|
||||
case SBIG('TXTR'):
|
||||
return {TXTR::Extract, ".png"};
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
|
||||
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void STRG::writeAngelScript(std::ofstream& out) const
|
||||
|
|
|
@ -60,11 +60,32 @@ struct STRG : ISTRG, BigDNA
|
|||
#else
|
||||
return HECL::WideToUTF8(search->second->at(idx));
|
||||
#endif
|
||||
return std::string();
|
||||
return HECL::SystemString();
|
||||
}
|
||||
|
||||
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
FourCC("STRG").write(writer);
|
||||
atUint32 strgSz = 4;
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
strgSz += entry.name.size() + 13;
|
||||
strgSz += (atUint32)entry.name.size() + 13;
|
||||
atUint32 strgPad = ((strgSz + 63) & ~63) - strgSz;
|
||||
strgSz += strgPad;
|
||||
writer.writeUint32(strgSz);
|
||||
|
@ -88,12 +88,12 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
writer.writeUint32(dataSz);
|
||||
writer.seek(36, Athena::Current);
|
||||
|
||||
writer.writeUint32(m_nameEntries.size());
|
||||
writer.writeUint32((atUint32)m_nameEntries.size());
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
entry.write(writer);
|
||||
writer.seek(strgPad, Athena::Current);
|
||||
|
||||
writer.writeUint32(m_entries.size());
|
||||
writer.writeUint32((atUint32)m_entries.size());
|
||||
for (const Entry& entry : m_entries)
|
||||
{
|
||||
Entry copy = entry;
|
||||
|
@ -125,8 +125,9 @@ std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const NOD::DiscBase::IPartition
|
|||
{
|
||||
atUint32 compSz;
|
||||
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 totalDecompSz = 0;
|
||||
|
|
|
@ -149,6 +149,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
|
||||
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void STRG::writeAngelScript(std::ofstream& out) const
|
||||
|
|
|
@ -60,7 +60,7 @@ struct STRG : ISTRG, BigDNA
|
|||
#else
|
||||
return search->second->at(idx);
|
||||
#endif
|
||||
return std::string();
|
||||
return HECL::SystemString();
|
||||
}
|
||||
|
||||
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
||||
|
@ -73,6 +73,18 @@ struct STRG : ISTRG, BigDNA
|
|||
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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ void SpecBase::doExtract(HECL::Database::Project& project, const ExtractPassInfo
|
|||
|
||||
bool SpecBase::canCook(const HECL::Database::Project& project, const CookTaskInfo& info)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SpecBase::gatherDependencies(const HECL::Database::Project& project, const PackagePassInfo& info,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <utility>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SpecBase.hpp"
|
||||
#include "DNAMP1/DNAMP1.hpp"
|
||||
|
@ -100,7 +101,8 @@ struct SpecMP1 : SpecBase
|
|||
{
|
||||
rep.childOpts.emplace_back();
|
||||
ExtractReport& childRep = rep.childOpts.back();
|
||||
childRep.name = item.first;
|
||||
HECL::SystemStringView nameView(item.first);
|
||||
childRep.name = nameView;
|
||||
childRep.desc = item.second->getLevelString();
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ struct SpecMP1 : SpecBase
|
|||
{
|
||||
HECL::SystemString lowerArg = arg;
|
||||
HECL::ToLower(lowerArg);
|
||||
if (!lowerArg.compare(0, 3, "mp1"))
|
||||
if (!lowerArg.compare(0, 3, _S("mp1")))
|
||||
{
|
||||
doMP1 = true;
|
||||
size_t slashPos = arg.find(_S('/'));
|
||||
|
@ -247,31 +249,38 @@ struct SpecMP1 : SpecBase
|
|||
|
||||
bool checkFromProject(HECL::Database::Project& proj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool readFromProject(HECL::Database::Project& proj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct LevelSpec : public ILevelSpec
|
||||
{
|
||||
bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct AreaSpec : public IAreaSpec
|
||||
{
|
||||
bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bool visitAreas(std::function<bool(const IAreaSpec&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bool visitLevels(std::function<bool(const ILevelSpec&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -98,7 +98,8 @@ struct SpecMP2 : SpecBase
|
|||
{
|
||||
rep.childOpts.emplace_back();
|
||||
ExtractReport& childRep = rep.childOpts.back();
|
||||
childRep.name = item.first;
|
||||
HECL::SystemStringView nameView(item.first);
|
||||
childRep.name = nameView;
|
||||
childRep.desc = item.second->getLevelString();
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ struct SpecMP2 : SpecBase
|
|||
{
|
||||
HECL::SystemString lowerArg = arg;
|
||||
HECL::ToLower(lowerArg);
|
||||
if (!lowerArg.compare(0, 3, "mp2"))
|
||||
if (!lowerArg.compare(0, 3, _S("mp2")))
|
||||
{
|
||||
doMP2 = true;
|
||||
size_t slashPos = arg.find(_S('/'));
|
||||
|
@ -245,31 +246,38 @@ struct SpecMP2 : SpecBase
|
|||
|
||||
bool checkFromProject(HECL::Database::Project& proj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool readFromProject(HECL::Database::Project& proj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct LevelSpec : public ILevelSpec
|
||||
{
|
||||
bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct AreaSpec : public IAreaSpec
|
||||
{
|
||||
bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bool visitAreas(std::function<bool(const IAreaSpec&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bool visitLevels(std::function<bool(const ILevelSpec&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ struct SpecMP3 : SpecBase
|
|||
{
|
||||
rep.childOpts.emplace_back();
|
||||
ExtractReport& childRep = rep.childOpts.back();
|
||||
childRep.name = item.first;
|
||||
HECL::SystemStringView nameView(item.first);
|
||||
childRep.name = nameView;
|
||||
if (!item.first.compare("Worlds.pak"))
|
||||
continue;
|
||||
else if (!item.first.compare("Metroid6.pak"))
|
||||
|
@ -191,7 +192,7 @@ struct SpecMP3 : SpecBase
|
|||
{
|
||||
HECL::SystemString lowerArg = arg;
|
||||
HECL::ToLower(lowerArg);
|
||||
if (!lowerArg.compare(0, 3, "mp3"))
|
||||
if (!lowerArg.compare(0, 3, _S("mp3")))
|
||||
{
|
||||
doMP3 = true;
|
||||
size_t slashPos = arg.find(_S('/'));
|
||||
|
@ -206,7 +207,7 @@ struct SpecMP3 : SpecBase
|
|||
{
|
||||
HECL::SystemString lowerArg = arg;
|
||||
HECL::ToLower(lowerArg);
|
||||
if (!lowerArg.compare(0, 2, "fe"))
|
||||
if (!lowerArg.compare(0, 2, _S("fe")))
|
||||
{
|
||||
doMPTFE = true;
|
||||
size_t slashPos = arg.find(_S('/'));
|
||||
|
@ -381,31 +382,38 @@ struct SpecMP3 : SpecBase
|
|||
|
||||
bool checkFromProject(HECL::Database::Project& proj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool readFromProject(HECL::Database::Project& proj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool visitGameObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct LevelSpec : public ILevelSpec
|
||||
{
|
||||
bool visitLevelObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
struct AreaSpec : public IAreaSpec
|
||||
{
|
||||
bool visitAreaObjects(std::function<bool(const HECL::Database::ObjectBase&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bool visitAreas(std::function<bool(const IAreaSpec&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
bool visitLevels(std::function<bool(const ILevelSpec&)>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
2
NODLib
2
NODLib
|
@ -1 +1 @@
|
|||
Subproject commit edb84685750cdf6d5d6ed5bd3801b2c31202468f
|
||||
Subproject commit 9e7e0979bd3fcdcd1930a477c96838f9d8418f70
|
Loading…
Reference in New Issue