mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 16:24:55 +00:00
initial MLVL and STRG trilogy integration
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
add_library(DNACommon
|
||||
STRG.hpp
|
||||
STRG.cpp
|
||||
DNACommon.hpp
|
||||
DNACommon.cpp)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "DNACommon.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
const HECL::FourCC ENGL("ENGL");
|
||||
const HECL::FourCC FREN("FREN");
|
||||
const HECL::FourCC GERM("GERM");
|
||||
const HECL::FourCC SPAN("SPAN");
|
||||
const HECL::FourCC ITAL("ITAL");
|
||||
const HECL::FourCC JAPN("JAPN");
|
||||
|
||||
const HECL::FourCC AFSM("AFSM");
|
||||
const HECL::FourCC AGSC("AGSC");
|
||||
const HECL::FourCC ANCS("ANCS");
|
||||
const HECL::FourCC ANIM("ANIM");
|
||||
const HECL::FourCC ATBL("ATBL");
|
||||
const HECL::FourCC CINF("CINF");
|
||||
const HECL::FourCC CMDL("CMDL");
|
||||
const HECL::FourCC CRSC("CRSC");
|
||||
const HECL::FourCC CSKR("CSKR");
|
||||
const HECL::FourCC CSMP("CSMP");
|
||||
const HECL::FourCC CSNG("CSNG");
|
||||
const HECL::FourCC CTWK("CTWK");
|
||||
const HECL::FourCC DGRP("DGRP");
|
||||
const HECL::FourCC DPSC("DPSC");
|
||||
const HECL::FourCC DUMB("DUMB");
|
||||
const HECL::FourCC ELSC("ELSC");
|
||||
const HECL::FourCC EVNT("EVNT");
|
||||
const HECL::FourCC FONT("FONT");
|
||||
const HECL::FourCC FRME("FRME");
|
||||
const HECL::FourCC HINT("HINT");
|
||||
const HECL::FourCC MAPA("MAPA");
|
||||
const HECL::FourCC MAPU("MAPU");
|
||||
const HECL::FourCC MAPW("MAPW");
|
||||
const HECL::FourCC MLVL("MLVL");
|
||||
const HECL::FourCC MREA("MREA");
|
||||
const HECL::FourCC PART("PART");
|
||||
const HECL::FourCC PATH("PATH");
|
||||
const HECL::FourCC RFRM("RFRM");
|
||||
const HECL::FourCC ROOM("ROOM");
|
||||
const HECL::FourCC SAVW("SAVW");
|
||||
const HECL::FourCC SCAN("SCAN");
|
||||
const HECL::FourCC STRG("STRG");
|
||||
const HECL::FourCC SWHC("SWHC");
|
||||
const HECL::FourCC TXTR("TXTR");
|
||||
const HECL::FourCC WPSC("WPSC");
|
||||
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@ namespace Retro
|
||||
/* This comes up a great deal */
|
||||
typedef Athena::io::DNA<Athena::BigEndian> BigDNA;
|
||||
|
||||
/* FourCC with DNA read/write */
|
||||
class FourCC final : public BigDNA, public HECL::FourCC
|
||||
{
|
||||
public:
|
||||
FourCC() : HECL::FourCC() {}
|
||||
FourCC(const HECL::FourCC& other)
|
||||
: HECL::FourCC() {num = other.toUint32();}
|
||||
FourCC(const char* name)
|
||||
: HECL::FourCC(name) {}
|
||||
|
||||
@@ -135,11 +138,63 @@ struct CaseInsensitiveCompare
|
||||
}
|
||||
};
|
||||
|
||||
/* Language-identifiers */
|
||||
extern const HECL::FourCC ENGL;
|
||||
extern const HECL::FourCC FREN;
|
||||
extern const HECL::FourCC GERM;
|
||||
extern const HECL::FourCC SPAN;
|
||||
extern const HECL::FourCC ITAL;
|
||||
extern const HECL::FourCC JAPN;
|
||||
|
||||
/* Resource types */
|
||||
extern const HECL::FourCC AFSM;
|
||||
extern const HECL::FourCC AGSC;
|
||||
extern const HECL::FourCC ANCS;
|
||||
extern const HECL::FourCC ANIM;
|
||||
extern const HECL::FourCC ATBL;
|
||||
extern const HECL::FourCC CINF;
|
||||
extern const HECL::FourCC CMDL;
|
||||
extern const HECL::FourCC CRSC;
|
||||
extern const HECL::FourCC CSKR;
|
||||
extern const HECL::FourCC CSMP;
|
||||
extern const HECL::FourCC CSNG;
|
||||
extern const HECL::FourCC CTWK;
|
||||
extern const HECL::FourCC DGRP;
|
||||
extern const HECL::FourCC DPSC;
|
||||
extern const HECL::FourCC DUMB;
|
||||
extern const HECL::FourCC ELSC;
|
||||
extern const HECL::FourCC EVNT;
|
||||
extern const HECL::FourCC FONT;
|
||||
extern const HECL::FourCC FRME;
|
||||
extern const HECL::FourCC HINT;
|
||||
extern const HECL::FourCC MAPA;
|
||||
extern const HECL::FourCC MAPU;
|
||||
extern const HECL::FourCC MAPW;
|
||||
extern const HECL::FourCC MLVL;
|
||||
extern const HECL::FourCC MREA;
|
||||
extern const HECL::FourCC PART;
|
||||
extern const HECL::FourCC PATH;
|
||||
extern const HECL::FourCC RFRM;
|
||||
extern const HECL::FourCC ROOM;
|
||||
extern const HECL::FourCC SAVW;
|
||||
extern const HECL::FourCC SCAN;
|
||||
extern const HECL::FourCC STRG;
|
||||
extern const HECL::FourCC SWHC;
|
||||
extern const HECL::FourCC TXTR;
|
||||
extern const HECL::FourCC WPSC;
|
||||
|
||||
}
|
||||
|
||||
/* Hash template-specializations for UniqueID types */
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<Retro::FourCC>
|
||||
{
|
||||
inline size_t operator()(const Retro::FourCC& fcc) const
|
||||
{return fcc.toUint32();}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<Retro::UniqueID32>
|
||||
{
|
||||
|
||||
42
DataSpec/DNACommon/STRG.cpp
Normal file
42
DataSpec/DNACommon/STRG.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "STRG.hpp"
|
||||
#include "../DNAMP1/STRG.hpp"
|
||||
#include "../DNAMP2/STRG.hpp"
|
||||
#include "../DNAMP3/STRG.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
std::unique_ptr<ISTRG> LoadSTRG(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
uint32_t magic = reader.readUint32();
|
||||
if (magic != 0x87654321)
|
||||
{
|
||||
LogModule.report(LogVisor::Error, "invalid STRG magic");
|
||||
return std::unique_ptr<ISTRG>();
|
||||
}
|
||||
|
||||
uint32_t version = reader.readUint32();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
DNAMP1::STRG* newStrg = new struct DNAMP1::STRG;
|
||||
newStrg->_read(reader);
|
||||
return std::unique_ptr<ISTRG>(newStrg);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
DNAMP2::STRG* newStrg = new struct DNAMP2::STRG;
|
||||
newStrg->_read(reader);
|
||||
return std::unique_ptr<ISTRG>(newStrg);
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
DNAMP3::STRG* newStrg = new struct DNAMP3::STRG;
|
||||
newStrg->_read(reader);
|
||||
return std::unique_ptr<ISTRG>(newStrg);
|
||||
}
|
||||
}
|
||||
return std::unique_ptr<ISTRG>();
|
||||
}
|
||||
}
|
||||
22
DataSpec/DNACommon/STRG.hpp
Normal file
22
DataSpec/DNACommon/STRG.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef __COMMON_STRG_HPP__
|
||||
#define __COMMON_STRG_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <HECL/HECL.hpp>
|
||||
#include "DNACommon.hpp"
|
||||
#include "../Logging.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
struct ISTRG
|
||||
{
|
||||
virtual size_t count() const=0;
|
||||
virtual std::string getUTF8(const FourCC& lang, size_t idx) const=0;
|
||||
virtual std::wstring getUTF16(const FourCC& lang, size_t idx) const=0;
|
||||
virtual HECL::SystemString getSystemString(const FourCC& lang, size_t idx) const=0;
|
||||
virtual int32_t lookupIdx(const std::string& name) const=0;
|
||||
};
|
||||
std::unique_ptr<ISTRG> LoadSTRG(Athena::io::IStreamReader& reader);
|
||||
}
|
||||
|
||||
#endif // __COMMON_STRG_HPP__
|
||||
Reference in New Issue
Block a user