mirror of https://github.com/AxioDL/metaforce.git
moved retro-specific stuff out of hecl
This commit is contained in:
parent
be43fb19c0
commit
a8fbfcb361
|
@ -1,30 +0,0 @@
|
|||
#include "HECLDatabase.hpp"
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
|
||||
IDataSpec* NewDataSpec_little();
|
||||
IDataSpec* NewDataSpec_big();
|
||||
IDataSpec* NewDataSpec_revolution();
|
||||
IDataSpec* NewDataSpec_cafe();
|
||||
|
||||
IDataSpec* NewDataSpec_mp1();
|
||||
IDataSpec* NewDataSpec_mp2();
|
||||
IDataSpec* NewDataSpec_mp3();
|
||||
|
||||
const DataSpecEntry DATA_SPEC_REGISTRY[] =
|
||||
{
|
||||
{_S("hecl-little"), _S("Targets little-endian PC apps using the HECL runtime"), NewDataSpec_little},
|
||||
{_S("hecl-big"), _S("Targets big-endian PC apps using the HECL runtime"), NewDataSpec_big},
|
||||
{_S("hecl-revolution"), _S("Targets Wii apps using the HECL runtime"), NewDataSpec_revolution},
|
||||
{_S("hecl-cafe"), _S("Targets Wii U apps using the HECL runtime"), NewDataSpec_cafe},
|
||||
{_S("mp1"), _S("Targets original Metroid Prime engine"), NewDataSpec_mp1},
|
||||
{_S("mp2"), _S("Targets original Metroid Prime 2 engine"), NewDataSpec_mp2},
|
||||
{_S("mp3"), _S("Targets original Metroid Prime 3 engine"), NewDataSpec_mp3},
|
||||
{}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
TARGET = hecl-dataspec
|
||||
CONFIG -= Qt
|
||||
QT =
|
||||
unix:QMAKE_CXXFLAGS += -std=c++11
|
||||
unix:QMAKE_CFLAGS += -std=c99
|
||||
unix:LIBS += -std=c++11
|
||||
clang:QMAKE_CXXFLAGS += -stdlib=libc++
|
||||
clang:LIBS += -stdlib=libc++ -lc++abi
|
||||
|
||||
INCLUDEPATH += $$PWD ../include ../extern \
|
||||
../extern/Athena/include
|
||||
../extern/RetroCommon/include
|
||||
|
||||
include(../extern/RetroCommon/RetroCommon.pri)
|
||||
|
||||
include(hecl/hecl.pri)
|
||||
include(mp1/mp1.pri)
|
||||
include(mp2/mp2.pri)
|
||||
include(mp3/mp3.pri)
|
||||
|
||||
HEADERS += \
|
||||
helpers.hpp
|
||||
|
||||
SOURCES += \
|
||||
helpers.cpp \
|
||||
dataspec.cpp
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#ifndef DUMB_HPP
|
||||
#define DUMB_HPP
|
||||
|
||||
#include "HECLDatabase.hpp"
|
||||
#include "HECLRuntime.hpp"
|
||||
|
||||
class CDUMBProject : public HECL::Database::ObjectBase
|
||||
{
|
||||
using HECL::Database::ObjectBase::ObjectBase;
|
||||
|
||||
bool _cookObject(FDataAppender dataAppender,
|
||||
DataEndianness endianness, DataPlatform platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _gatherDeps(FDepAdder depAdder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CDUMBRuntime : public HECL::Runtime::ObjectBase
|
||||
{
|
||||
using HECL::Runtime::ObjectBase::ObjectBase;
|
||||
|
||||
bool _objectFinishedLoading(const void* data, size_t len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _objectWillUnload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // DUMB_HPP
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef HMDL_HPP
|
||||
#define HMDL_HPP
|
||||
|
||||
#include "HECLDatabase.hpp"
|
||||
#include "HECLRuntime.hpp"
|
||||
|
||||
class CHMDLProject : public HECL::Database::ObjectBase
|
||||
{
|
||||
using HECL::Database::ObjectBase::ObjectBase;
|
||||
|
||||
bool _cookObject(FDataAppender dataAppender,
|
||||
DataEndianness endianness, DataPlatform platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _gatherDeps(FDepAdder depAdder)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class CHMDLRuntime : public HECL::Runtime::ObjectBase
|
||||
{
|
||||
using HECL::Runtime::ObjectBase::ObjectBase;
|
||||
|
||||
bool _objectFinishedLoading(const void* data, size_t len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _objectWillUnload()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif // HMDL_HPP
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef MATR_HPP
|
||||
#define MATR_HPP
|
||||
|
||||
#include "HECLDatabase.hpp"
|
||||
#include "HECLRuntime.hpp"
|
||||
|
||||
class CMATRProject : public HECL::Database::ObjectBase
|
||||
{
|
||||
using HECL::Database::ObjectBase::ObjectBase;
|
||||
|
||||
bool _cookObject(FDataAppender dataAppender,
|
||||
DataEndianness endianness, DataPlatform platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _gatherDeps(FDepAdder depAdder)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class CMATRRuntime : public HECL::Runtime::ObjectBase
|
||||
{
|
||||
using HECL::Runtime::ObjectBase::ObjectBase;
|
||||
|
||||
bool _objectFinishedLoading(const void* data, size_t len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _objectWillUnload()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MATR_HPP
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef STRG_HPP
|
||||
#define STRG_HPP
|
||||
|
||||
#include "HECLDatabase.hpp"
|
||||
#include "HECLRuntime.hpp"
|
||||
|
||||
class CSTRGProject : public HECL::Database::ObjectBase
|
||||
{
|
||||
using HECL::Database::ObjectBase::ObjectBase;
|
||||
|
||||
bool _cookObject(FDataAppender dataAppender,
|
||||
DataEndianness endianness, DataPlatform platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _gatherDeps(FDepAdder depAdder)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class CSTRGRuntime : public HECL::Runtime::ObjectBase
|
||||
{
|
||||
using HECL::Runtime::ObjectBase::ObjectBase;
|
||||
|
||||
bool _objectFinishedLoading(const void* data, size_t len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _objectWillUnload()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif // STRG_HPP
|
|
@ -1,49 +0,0 @@
|
|||
#ifndef TXTR_HPP
|
||||
#define TXTR_HPP
|
||||
|
||||
#include "HECLDatabase.hpp"
|
||||
#include "HECLRuntime.hpp"
|
||||
#include "helpers.hpp"
|
||||
|
||||
class CTXTRProject : public HECL::Database::ObjectBase
|
||||
{
|
||||
using HECL::Database::ObjectBase::ObjectBase;
|
||||
|
||||
bool _cookObject(FDataAppender dataAppender,
|
||||
DataEndianness endianness, DataPlatform platform)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _gatherDeps(FDepAdder depAdder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
static bool ClaimPath(const std::string& path, const std::string&)
|
||||
{
|
||||
if (!HECLHelpers::IsRegularFile(path))
|
||||
return false;
|
||||
if (!HECLHelpers::ContainsMagic(path, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class CTXTRRuntime : public HECL::Runtime::ObjectBase
|
||||
{
|
||||
using HECL::Runtime::ObjectBase::ObjectBase;
|
||||
|
||||
bool _objectFinishedLoading(const void* data, size_t len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _objectWillUnload()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TXTR_HPP
|
|
@ -1,50 +0,0 @@
|
|||
#include "HECLDatabase.hpp"
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
|
||||
class HECLBaseDataSpec : public IDataSpec
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class HECLLittleDataSpec : public HECLBaseDataSpec
|
||||
{
|
||||
};
|
||||
|
||||
class HECLBigDataSpec : public HECLBaseDataSpec
|
||||
{
|
||||
};
|
||||
|
||||
class HECLRevolutionDataSpec : public HECLBaseDataSpec
|
||||
{
|
||||
};
|
||||
|
||||
class HECLCafeDataSpec : public HECLBaseDataSpec
|
||||
{
|
||||
};
|
||||
|
||||
IDataSpec* NewDataSpec_little()
|
||||
{
|
||||
return new HECLLittleDataSpec();
|
||||
}
|
||||
|
||||
IDataSpec* NewDataSpec_big()
|
||||
{
|
||||
return new HECLBigDataSpec();
|
||||
}
|
||||
|
||||
IDataSpec* NewDataSpec_revolution()
|
||||
{
|
||||
return new HECLRevolutionDataSpec();
|
||||
}
|
||||
|
||||
IDataSpec* NewDataSpec_cafe()
|
||||
{
|
||||
return new HECLCafeDataSpec();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
SOURCES += \
|
||||
$$PWD/hecl.cpp
|
|
@ -1,51 +0,0 @@
|
|||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "helpers.hpp"
|
||||
|
||||
namespace HECLHelpers
|
||||
{
|
||||
|
||||
bool IsRegularFile(const std::string& path)
|
||||
{
|
||||
struct stat theStat;
|
||||
if (stat(path.c_str(), &theStat))
|
||||
return false;
|
||||
if (!S_ISREG(theStat.st_mode))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsDirectoryFile(const std::string& path)
|
||||
{
|
||||
struct stat theStat;
|
||||
if (stat(path.c_str(), &theStat))
|
||||
return false;
|
||||
if (!S_ISDIR(theStat.st_mode))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContainsMagic(const std::string& path, const char* magicBuf,
|
||||
size_t magicLen, size_t magicOff)
|
||||
{
|
||||
if (!IsRegularFile(path))
|
||||
return false;
|
||||
|
||||
FILE* fp = fopen(path.c_str(), "rb");
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
char* readBuf[magicLen];
|
||||
fseek(fp, magicOff, SEEK_SET);
|
||||
size_t readLen = fread(readBuf, 1, magicLen, fp);
|
||||
fclose(fp);
|
||||
|
||||
if (readLen < magicLen)
|
||||
return false;
|
||||
if (memcmp(readBuf, magicBuf, magicLen))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef HELPERS_HPP
|
||||
#define HELPERS_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace HECLHelpers
|
||||
{
|
||||
bool IsRegularFile(const std::string& path);
|
||||
bool IsDirectoryFile(const std::string& path);
|
||||
bool ContainsMagic(const std::string& path, const char* magicBuf,
|
||||
size_t magicLen, size_t magicOff=0);
|
||||
|
||||
bool IsBlenderFile(const std::string& path);
|
||||
|
||||
}
|
||||
|
||||
#endif // HELPERS_HPP
|
|
@ -1,22 +0,0 @@
|
|||
#include "HECLDatabase.hpp"
|
||||
|
||||
#include "CMDL.hpp"
|
||||
#include "MREA.hpp"
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
|
||||
class MP1DataSpec : public IDataSpec
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
IDataSpec* NewDataSpec_mp1()
|
||||
{
|
||||
return new MP1DataSpec();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
SOURCES += \
|
||||
$$PWD/mp1.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/MREA.hpp \
|
||||
$$PWD/CMDL.hpp
|
|
@ -1,22 +0,0 @@
|
|||
#include "HECLDatabase.hpp"
|
||||
|
||||
#include "CMDL.hpp"
|
||||
#include "MREA.hpp"
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
|
||||
class MP2DataSpec : public IDataSpec
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
IDataSpec* NewDataSpec_mp2()
|
||||
{
|
||||
return new MP2DataSpec();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
SOURCES += \
|
||||
$$PWD/mp2.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/MREA.hpp \
|
||||
$$PWD/CMDL.hpp
|
|
@ -1,22 +0,0 @@
|
|||
#include "HECLDatabase.hpp"
|
||||
|
||||
#include "CMDL.hpp"
|
||||
#include "MREA.hpp"
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Database
|
||||
{
|
||||
|
||||
class MP3DataSpec : public IDataSpec
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
IDataSpec* NewDataSpec_mp3()
|
||||
{
|
||||
return new MP3DataSpec();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
SOURCES += \
|
||||
$$PWD/mp3.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/MREA.hpp \
|
||||
$$PWD/CMDL.hpp
|
|
@ -47,7 +47,7 @@ public:
|
|||
bool found = false;
|
||||
for (auto& spec : specs)
|
||||
{
|
||||
if (!spec.first.name.compare(*it))
|
||||
if (!spec.first.m_name.compare(*it))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
@ -90,15 +90,13 @@ public:
|
|||
{
|
||||
if (!m_info.project)
|
||||
{
|
||||
for (const HECL::Database::DataSpecEntry* spec = HECL::Database::DATA_SPEC_REGISTRY;
|
||||
spec->name.size();
|
||||
++spec)
|
||||
for (const HECL::Database::DataSpecEntry* spec : HECL::Database::DATA_SPEC_REGISTRY)
|
||||
{
|
||||
if (XTERM_COLOR)
|
||||
HECL::Printf(_S("" BOLD CYAN "%s" NORMAL "\n"), spec->name.c_str());
|
||||
HECL::Printf(_S("" BOLD CYAN "%s" NORMAL "\n"), spec->m_name.c_str());
|
||||
else
|
||||
HECL::Printf(_S("%s\n"), spec->name.c_str());
|
||||
HECL::Printf(_S(" %s\n"), spec->desc.c_str());
|
||||
HECL::Printf(_S("%s\n"), spec->m_name.c_str());
|
||||
HECL::Printf(_S(" %s\n"), spec->m_desc.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -109,9 +107,9 @@ public:
|
|||
for (auto& spec : specs)
|
||||
{
|
||||
if (XTERM_COLOR)
|
||||
HECL::Printf(_S("" BOLD CYAN "%s" NORMAL ""), spec.first.name.c_str());
|
||||
HECL::Printf(_S("" BOLD CYAN "%s" NORMAL ""), spec.first.m_name.c_str());
|
||||
else
|
||||
HECL::Printf(_S("%s"), spec.first.name.c_str());
|
||||
HECL::Printf(_S("%s"), spec.first.m_name.c_str());
|
||||
if (spec.second)
|
||||
{
|
||||
if (XTERM_COLOR)
|
||||
|
@ -119,7 +117,7 @@ public:
|
|||
else
|
||||
HECL::Printf(_S(" [ENABLED]"));
|
||||
}
|
||||
HECL::Printf(_S("\n %s\n"), spec.first.desc.c_str());
|
||||
HECL::Printf(_S("\n %s\n"), spec.first.m_desc.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,9 +131,9 @@ public:
|
|||
HECL::ToLower(itName);
|
||||
for (auto& spec : specs)
|
||||
{
|
||||
if (!spec.first.name.compare(itName))
|
||||
if (!spec.first.m_name.compare(itName))
|
||||
{
|
||||
opSpecs.push_back(spec.first.name);
|
||||
opSpecs.push_back(spec.first.m_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit af64e55395e2e262d2d25715e15c2518024d21f2
|
||||
Subproject commit 1e7f39e4c540b675f472fe0d60a2ed8dc8073634
|
|
@ -1 +1 @@
|
|||
Subproject commit 7c67895430d88d4971e3197f9a4eeba3ba0f6d35
|
||||
Subproject commit 1d3ed2763636ef7d049644c7ddc7fb905e52e254
|
|
@ -20,13 +20,15 @@ HEADERS += \
|
|||
SUBDIRS += \
|
||||
extern/blowfish \
|
||||
extern/libpng \
|
||||
extern/libSquish \
|
||||
extern/RetroCommon \
|
||||
blender \
|
||||
lib \
|
||||
dataspec \
|
||||
driver
|
||||
|
||||
driver.depends = extern/blowfish
|
||||
driver.depends = extern/libpng
|
||||
driver.depends = extern/libSquish
|
||||
driver.depends = extern/RetroCommon
|
||||
driver.depends = blender
|
||||
driver.depends = lib
|
||||
driver.depends = dataspec
|
||||
|
|
|
@ -10,6 +10,7 @@ char* win_realpath(const char* name, char* restrict resolved);
|
|||
#include <sys/file.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
|
|
@ -117,16 +117,34 @@ public:
|
|||
{(void)project;(void)info;}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Pre-emptive indication of what the constructed DataSpec is used for
|
||||
*/
|
||||
enum DataSpecTool
|
||||
{
|
||||
TOOL_EXTRACT,
|
||||
TOOL_COOK,
|
||||
TOOL_PACKAGE
|
||||
};
|
||||
|
||||
extern std::vector<const struct DataSpecEntry*> DATA_SPEC_REGISTRY;
|
||||
|
||||
/**
|
||||
* @brief IDataSpec registry entry
|
||||
*
|
||||
* Auto-registers with data spec registry
|
||||
*/
|
||||
struct DataSpecEntry
|
||||
{
|
||||
SystemString name;
|
||||
SystemString desc;
|
||||
std::function<IDataSpec*(void)> factory;
|
||||
SystemString m_name;
|
||||
SystemString m_desc;
|
||||
std::function<IDataSpec*(DataSpecTool)> m_factory;
|
||||
|
||||
DataSpecEntry(SystemString&& name, SystemString&& desc,
|
||||
std::function<IDataSpec*(DataSpecTool)>&& factory)
|
||||
: m_name(std::move(name)), m_desc(std::move(desc)), m_factory(std::move(factory))
|
||||
{DATA_SPEC_REGISTRY.push_back(this);}
|
||||
};
|
||||
extern const HECL::Database::DataSpecEntry DATA_SPEC_REGISTRY[];
|
||||
|
||||
/**
|
||||
* @brief Base object to subclass for integrating with key project operations
|
||||
|
|
|
@ -271,11 +271,9 @@ void Project::rescanDataSpecs()
|
|||
{
|
||||
m_compiledSpecs.clear();
|
||||
m_specs.lockAndRead();
|
||||
for (const DataSpecEntry* spec = DATA_SPEC_REGISTRY;
|
||||
spec->name.size();
|
||||
++spec)
|
||||
for (const DataSpecEntry* spec : DATA_SPEC_REGISTRY)
|
||||
{
|
||||
SystemUTF8View specUTF8(spec->name);
|
||||
SystemUTF8View specUTF8(spec->m_name);
|
||||
m_compiledSpecs.push_back({*spec, m_specs.checkForLine(specUTF8.utf8_str()) ? true : false});
|
||||
}
|
||||
m_specs.unlockAndDiscard();
|
||||
|
|
Loading…
Reference in New Issue