mirror of https://github.com/AxioDL/metaforce.git
various implementation
This commit is contained in:
parent
6577d4ca13
commit
f3b5b9f49a
|
@ -18,15 +18,15 @@ typedef Athena::io::DNA<Athena::BigEndian> BigDNA;
|
|||
typedef Athena::io::DNAYaml<Athena::BigEndian> BigYAML;
|
||||
|
||||
/* FourCC with DNA read/write */
|
||||
class FourCC final : public BigYAML, public HECL::FourCC
|
||||
class DNAFourCC final : public BigYAML, public HECL::FourCC
|
||||
{
|
||||
public:
|
||||
FourCC() : HECL::FourCC() {}
|
||||
FourCC(const HECL::FourCC& other)
|
||||
DNAFourCC() : HECL::FourCC() {}
|
||||
DNAFourCC(const HECL::FourCC& other)
|
||||
: HECL::FourCC() {num = other.toUint32();}
|
||||
FourCC(const char* name)
|
||||
DNAFourCC(const char* name)
|
||||
: HECL::FourCC(name) {}
|
||||
FourCC(uint32_t n)
|
||||
DNAFourCC(uint32_t n)
|
||||
: HECL::FourCC(n) {}
|
||||
|
||||
Delete expl;
|
||||
|
@ -40,6 +40,8 @@ public:
|
|||
{writer.writeString(nullptr, std::string(fcc, 4));}
|
||||
};
|
||||
|
||||
using FourCC = HECL::FourCC;
|
||||
|
||||
/* PAK 32-bit Unique ID */
|
||||
class UniqueID32 : public BigYAML
|
||||
{
|
||||
|
@ -243,9 +245,9 @@ typedef std::function<bool(const HECL::ProjectPath&, const HECL::ProjectPath&)>
|
|||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<Retro::FourCC>
|
||||
struct hash<Retro::DNAFourCC>
|
||||
{
|
||||
inline size_t operator()(const Retro::FourCC& fcc) const
|
||||
inline size_t operator()(const Retro::DNAFourCC& fcc) const
|
||||
{return fcc.toUint32();}
|
||||
};
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ struct ANCS : BigYAML
|
|||
{
|
||||
DECL_YAML
|
||||
String<-1> name;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
UniqueID32 id;
|
||||
String<-1> name2;
|
||||
Value<float> unk1;
|
||||
|
|
|
@ -23,7 +23,7 @@ PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPar
|
|||
/* Append Level String */
|
||||
for (const PAK::Entry& entry : m_pak.m_entries)
|
||||
{
|
||||
if (entry.type == SBIG('MLVL'))
|
||||
if (entry.type == FOURCC('MLVL'))
|
||||
{
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
MLVL mlvl;
|
||||
|
@ -119,7 +119,7 @@ void PAKBridge::build()
|
|||
/* First pass: build per-area/per-layer dependency map */
|
||||
for (const PAK::Entry& entry : m_pak.m_entries)
|
||||
{
|
||||
if (entry.type == SBIG('MLVL'))
|
||||
if (entry.type == FOURCC('MLVL'))
|
||||
{
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
MLVL mlvl;
|
||||
|
|
|
@ -48,7 +48,7 @@ struct EVNT : BigYAML
|
|||
{
|
||||
DECL_YAML
|
||||
Value<atUint32> frameCount;
|
||||
FourCC effectType;
|
||||
DNAFourCC effectType;
|
||||
UniqueID32 effectId;
|
||||
String<-1> boneName;
|
||||
Value<float> scale;
|
||||
|
|
|
@ -48,7 +48,7 @@ struct MLVL : BigYAML
|
|||
{
|
||||
DECL_YAML
|
||||
UniqueID32 id;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
};
|
||||
Vector<Dependency, DNA_COUNT(depCount)> deps;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ struct PAK : BigDNA
|
|||
struct NameEntry : BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
UniqueID32 id;
|
||||
Value<atUint32> nameLen;
|
||||
String<DNA_COUNT(nameLen)> name;
|
||||
|
@ -30,7 +30,7 @@ struct PAK : BigDNA
|
|||
{
|
||||
DECL_DNA
|
||||
Value<atUint32> compressed;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
UniqueID32 id;
|
||||
Value<atUint32> size;
|
||||
Value<atUint32> offset;
|
||||
|
|
|
@ -15,7 +15,7 @@ void STRG::_read(Athena::io::IStreamReader& reader)
|
|||
readLangs.reserve(langCount);
|
||||
for (atUint32 l=0 ; l<langCount ; ++l)
|
||||
{
|
||||
FourCC lang;
|
||||
DNAFourCC lang;
|
||||
lang.read(reader);
|
||||
readLangs.emplace_back(lang);
|
||||
reader.seek(4);
|
||||
|
@ -62,7 +62,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
atUint32 offset = 0;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
lang.first.write(writer);
|
||||
DNAFourCC(lang.first).write(writer);
|
||||
writer.writeUint32Big(offset);
|
||||
offset += strCount * 4 + 4;
|
||||
atUint32 langStrCount = lang.second.size();
|
||||
|
|
|
@ -74,7 +74,7 @@ struct ANCS : BigYAML
|
|||
{
|
||||
DECL_YAML
|
||||
String<-1> name;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
UniqueID32 id;
|
||||
Value<atUint32> unkMP2;
|
||||
Value<float> unk1;
|
||||
|
@ -162,7 +162,7 @@ struct ANCS : BigYAML
|
|||
{
|
||||
DECL_YAML
|
||||
Value<atUint32> frameCount;
|
||||
FourCC effectType;
|
||||
DNAFourCC effectType;
|
||||
UniqueID32 effectId;
|
||||
Value<atUint32> boneId;
|
||||
Value<float> scale;
|
||||
|
|
|
@ -22,7 +22,7 @@ PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPar
|
|||
/* Append Level String */
|
||||
for (const DNAMP1::PAK::Entry& entry : m_pak.m_entries)
|
||||
{
|
||||
if (entry.type == SBIG('MLVL'))
|
||||
if (entry.type == FOURCC('MLVL'))
|
||||
{
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
MLVL mlvl;
|
||||
|
@ -118,7 +118,7 @@ void PAKBridge::build()
|
|||
/* First pass: build per-area/per-layer dependency map */
|
||||
for (const DNAMP1::PAK::Entry& entry : m_pak.m_entries)
|
||||
{
|
||||
if (entry.type == SBIG('MLVL'))
|
||||
if (entry.type == FOURCC('MLVL'))
|
||||
{
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
MLVL mlvl;
|
||||
|
|
|
@ -38,7 +38,7 @@ struct MLVL : BigDNA
|
|||
{
|
||||
DECL_DNA
|
||||
UniqueID32 id;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
};
|
||||
Vector<Dependency, DNA_COUNT(depCount)> deps;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ void STRG::_read(Athena::io::IStreamReader& reader)
|
|||
readLangs.reserve(langCount);
|
||||
for (atUint32 l=0 ; l<langCount ; ++l)
|
||||
{
|
||||
FourCC lang;
|
||||
DNAFourCC lang;
|
||||
lang.read(reader);
|
||||
readLangs.emplace_back(lang);
|
||||
reader.seek(8);
|
||||
|
@ -75,7 +75,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
writer.writeUint32Big(strCount);
|
||||
|
||||
atUint32 offset = 0;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
for (const std::pair<DNAFourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
lang.first.write(writer);
|
||||
writer.writeUint32Big(offset);
|
||||
|
@ -114,7 +114,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
for (const std::pair<std::string, int32_t>& name : names)
|
||||
writer.writeString(name.first);
|
||||
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
for (const std::pair<DNAFourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
offset = strCount * 4;
|
||||
atUint32 langStrCount = lang.second.size();
|
||||
|
|
|
@ -79,7 +79,7 @@ struct MaterialSet : BigDNA
|
|||
XRAY = SBIG('XRAY'),
|
||||
TOON = SBIG('TOON')
|
||||
};
|
||||
FourCC subtype;
|
||||
DNAFourCC subtype;
|
||||
struct Flags : BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
|
@ -106,7 +106,7 @@ struct MaterialSet : BigDNA
|
|||
CLR = SBIG('CLR '),
|
||||
DIFB = SBIG('DIFB')
|
||||
};
|
||||
FourCC subtype;
|
||||
DNAFourCC subtype;
|
||||
GX::Color color;
|
||||
};
|
||||
struct SectionINT : ISection
|
||||
|
@ -121,7 +121,7 @@ struct MaterialSet : BigDNA
|
|||
BNIF = SBIG('BNIF'),
|
||||
XRBR = SBIG('XRBR')
|
||||
};
|
||||
FourCC subtype;
|
||||
DNAFourCC subtype;
|
||||
Value<atUint32> value;
|
||||
};
|
||||
struct SectionFactory : BigDNA
|
||||
|
@ -130,7 +130,7 @@ struct MaterialSet : BigDNA
|
|||
std::unique_ptr<ISection> section;
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
type.read(reader);
|
||||
switch (type)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPar
|
|||
std::set<HECL::SystemString, CaseInsensitiveCompare> uniq;
|
||||
for (const PAK::Entry& entry : m_pak.m_entries)
|
||||
{
|
||||
if (entry.type == SBIG('MLVL'))
|
||||
if (entry.type == FOURCC('MLVL'))
|
||||
{
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
MLVL mlvl;
|
||||
|
|
|
@ -62,7 +62,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
{
|
||||
m_header.write(writer);
|
||||
|
||||
FourCC("STRG").write(writer);
|
||||
DNAFourCC("STRG").write(writer);
|
||||
atUint32 strgSz = 4;
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
strgSz += (atUint32)entry.name.size() + 13;
|
||||
|
@ -70,14 +70,14 @@ void PAK::write(Athena::io::IStreamWriter& writer) const
|
|||
strgSz += strgPad;
|
||||
writer.writeUint32Big(strgSz);
|
||||
|
||||
FourCC("RSHD").write(writer);
|
||||
DNAFourCC("RSHD").write(writer);
|
||||
atUint32 rshdSz = 4 + 24 * m_entries.size();
|
||||
atUint32 rshdPad = ((rshdSz + 63) & ~63) - rshdSz;
|
||||
rshdSz += rshdPad;
|
||||
writer.writeUint32Big(rshdSz);
|
||||
atUint32 dataOffset = 128 + strgSz + rshdSz;
|
||||
|
||||
FourCC("DATA").write(writer);
|
||||
DNAFourCC("DATA").write(writer);
|
||||
atUint32 dataSz = 0;
|
||||
for (const Entry& entry : m_entries)
|
||||
dataSz += (entry.size + 63) & ~63;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct PAK : BigDNA
|
|||
{
|
||||
DECL_DNA
|
||||
String<-1> name;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
UniqueID64 id;
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ struct PAK : BigDNA
|
|||
{
|
||||
DECL_DNA
|
||||
Value<atUint32> compressed;
|
||||
FourCC type;
|
||||
DNAFourCC type;
|
||||
UniqueID64 id;
|
||||
Value<atUint32> size;
|
||||
Value<atUint32> offset;
|
||||
|
|
|
@ -29,11 +29,11 @@ void STRG::_read(Athena::io::IStreamReader& reader)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<FourCC> readLangs;
|
||||
std::vector<DNAFourCC> readLangs;
|
||||
readLangs.reserve(langCount);
|
||||
for (atUint32 l=0 ; l<langCount ; ++l)
|
||||
{
|
||||
FourCC lang;
|
||||
DNAFourCC lang;
|
||||
lang.read(reader);
|
||||
readLangs.emplace_back(lang);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void STRG::_read(Athena::io::IStreamReader& reader)
|
|||
|
||||
langMap.clear();
|
||||
langMap.reserve(langCount);
|
||||
for (std::pair<FourCC, std::vector<std::string>>& item : langs)
|
||||
for (std::pair<DNAFourCC, std::vector<std::string>>& item : langs)
|
||||
langMap.emplace(item.first, &item.second);
|
||||
}
|
||||
|
||||
|
@ -142,12 +142,12 @@ void STRG::fromYAML(Athena::io::YAMLDocReader& reader)
|
|||
for (const auto& node : item.second->m_seqChildren)
|
||||
if (node->m_type == YAML_SCALAR_NODE)
|
||||
strs.emplace_back(node->m_scalarString);
|
||||
langs.emplace_back(std::make_pair(FourCC(item.first.c_str()), std::move(strs)));
|
||||
langs.emplace_back(std::make_pair(DNAFourCC(item.first.c_str()), std::move(strs)));
|
||||
}
|
||||
|
||||
langMap.clear();
|
||||
langMap.reserve(langs.size());
|
||||
for (std::pair<FourCC, std::vector<std::string>>& item : langs)
|
||||
for (std::pair<DNAFourCC, std::vector<std::string>>& item : langs)
|
||||
langMap.emplace(item.first, &item.second);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ struct STRG : ISTRG
|
|||
DECL_YAML
|
||||
Delete expl;
|
||||
void _read(Athena::io::IStreamReader& reader);
|
||||
std::vector<std::pair<FourCC, std::vector<std::string>>> langs;
|
||||
std::unordered_map<FourCC, std::vector<std::string>*> langMap;
|
||||
std::vector<std::pair<DNAFourCC, std::vector<std::string>>> langs;
|
||||
std::unordered_map<DNAFourCC, std::vector<std::string>*> langMap;
|
||||
std::map<std::string, int32_t> names;
|
||||
|
||||
inline int32_t lookupIdx(const std::string& name) const
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef __RETRO_CDVDFILE_HPP__
|
||||
#define __RETRO_CDVDFILE_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
const char* DecodeARAMFile(const char* name);
|
||||
|
||||
enum ESeekOrigin
|
||||
{
|
||||
OriginBegin = 0,
|
||||
OriginCur = 1,
|
||||
OriginEnd = 2
|
||||
};
|
||||
|
||||
struct DVDFileInfo;
|
||||
class CDvdRequest;
|
||||
|
||||
class CDvdFile
|
||||
{
|
||||
public:
|
||||
CDvdFile(const char*);
|
||||
void UpdateFilePos(int);
|
||||
void CalcFileOffset(int, ESeekOrigin);
|
||||
static void internalCallback(s32, DVDFileInfo*);
|
||||
bool FileExists(const char*);
|
||||
void CloseFile();
|
||||
CDvdRequest* AsyncSeekRead(void*, u32, ESeekOrigin, int);
|
||||
void SyncSeekRead(void*, u32, ESeekOrigin, int);
|
||||
CDvdRequest* AsyncRead(void*, u32);
|
||||
void SyncRead(void*, u32);
|
||||
void StallForARAMFile();
|
||||
void StartARAMFileLoad();
|
||||
void PopARAMFileLoad();
|
||||
void PushARAMFileLoad();
|
||||
void TryARAMFile();
|
||||
void PingARAMTransfer();
|
||||
void HandleDVDInterrupt();
|
||||
void HandleARAMInterrupt();
|
||||
static void ARAMARAMXferCallback(u32);
|
||||
static void DVDARAMXferCallback(s32, DVDFileInfo*);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CDVDFILE_HPP__
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef __RETRO_CDVDREQUEST_HPP__
|
||||
#define __RETRO_CDVDREQUEST_HPP__
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
class CDvdRequest
|
||||
{
|
||||
public:
|
||||
virtual void WaitUntilComplete()=0;
|
||||
virtual bool IsComplete()=0;
|
||||
virtual void PostCancelRequest()=0;
|
||||
|
||||
enum EMediaType
|
||||
{
|
||||
MediaARAM = 0,
|
||||
MediaReal = 1,
|
||||
MediaNOD = 2
|
||||
};
|
||||
virtual EMediaType GetMediaType() const=0;
|
||||
};
|
||||
|
||||
class CNODDvdRequest : public CDvdRequest
|
||||
{
|
||||
public:
|
||||
void WaitUntilComplete();
|
||||
bool IsComplete();
|
||||
void PostCancelRequest();
|
||||
EMediaType GetMediaType() const {return MediaNOD;}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CDVDREQUEST_HPP__
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef __RETRO_CFACTORYMGR_HPP__
|
||||
#define __RETRO_CFACTORYMGR_HPP__
|
||||
|
||||
#include <unordered_map>
|
||||
#include "RetroTypes.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
class SObjectTag;
|
||||
class CVParamTransfer;
|
||||
class CInputStream;
|
||||
|
||||
typedef void(*CFactoryFnReturn)(const SObjectTag&, CInputStream&, const CVParamTransfer&);
|
||||
|
||||
class CFactoryMgr
|
||||
{
|
||||
std::unordered_map<u32, CFactoryFnReturn> m_factories;
|
||||
public:
|
||||
MakeObjectFromMemory(const SObjectTag&, void*, int, bool, const CVParamTransfer&);
|
||||
void AddFactory(FourCC key, CFactoryFnReturn func)
|
||||
{
|
||||
m_factories[key] = func;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CFACTORYMGR_HPP__
|
|
@ -7,11 +7,19 @@ add_subdirectory(GuiSys)
|
|||
add_subdirectory(Input)
|
||||
add_subdirectory(Particle)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND PLAT_SRCS CMemoryCardSysWin.cpp)
|
||||
elseif(APPLE)
|
||||
list(APPEND PLAT_SRCS CMemoryCardSysMac.cpp)
|
||||
else()
|
||||
list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp)
|
||||
endif()
|
||||
|
||||
add_library(RuntimeCommon
|
||||
COsContext.hpp COsContextBoo.cpp
|
||||
CMainFlow.hpp CMainFlow.cpp
|
||||
CMemory.hpp CMemory.cpp
|
||||
CMemoryCardSys.hpp CMemoryCardSysPC.cpp
|
||||
CMemoryCardSys.hpp
|
||||
IAllocator.hpp IAllocator.cpp
|
||||
CGameAllocator.hpp CGameAllocator.cpp
|
||||
CBasics.hpp CBasicsPC.cpp
|
||||
|
@ -25,6 +33,9 @@ add_library(RuntimeCommon
|
|||
CWorldTransManager.hpp CWorldTransManager.cpp
|
||||
CRandom16.hpp CRandom16.cpp
|
||||
CResFactory.hpp CResFactory.cpp
|
||||
CResLoader.hpp CResLoader.cpp
|
||||
CDvdRequest.hpp CNODDvdRequest.cpp
|
||||
CDvdFile.hpp CNODDvdFile.cpp
|
||||
IObjectStore.hpp
|
||||
CSimplePool.hpp CSimplePool.cpp
|
||||
CAi.hpp CAi.cpp
|
||||
|
@ -45,10 +56,14 @@ add_library(RuntimeCommon
|
|||
CAreaOctTree.hpp CAreaOctTree.cpp
|
||||
CActor.hpp CActor.cpp
|
||||
CPhysicsActor.hpp CPhysicsActor.cpp
|
||||
CFactoryMgr.hpp CFactoryMgr.cpp
|
||||
CPakFile.hpp CPakFile.cpp
|
||||
CStringExtras.hpp
|
||||
rstl.hpp rstl.cpp
|
||||
GameGlobalObjects.hpp
|
||||
RetroTypes.hpp
|
||||
GCNTypes.hpp)
|
||||
GCNTypes.hpp
|
||||
${PLAT_SRCS})
|
||||
|
||||
add_subdirectory(MP1)
|
||||
add_subdirectory(MP2)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "CDvdRequest.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
void CNODDvdRequest::WaitUntilComplete()
|
||||
{
|
||||
}
|
||||
bool CNODDvdRequest::IsComplete()
|
||||
{
|
||||
}
|
||||
void CNODDvdRequest::PostCancelRequest()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
#ifndef __RETRO_CPAKFILE_HPP__
|
||||
#define __RETRO_CPAKFILE_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CStringExtras.hpp"
|
||||
#include "CDvdFile.hpp"
|
||||
#include "CDvdRequest.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
class CPakFile : public CDvdFile
|
||||
{
|
||||
friend class CResLoader;
|
||||
public:
|
||||
struct SResInfo
|
||||
{
|
||||
u32 compressed;
|
||||
SObjectTag tag;
|
||||
u32 size;
|
||||
u32 offset;
|
||||
};
|
||||
private:
|
||||
enum EAsyncPhase
|
||||
{
|
||||
PakAsyncWarmup = 0,
|
||||
PakAsyncInitialHeader = 1,
|
||||
PakAsyncDataLoad = 2,
|
||||
PakAsyncLoaded = 3
|
||||
} x2c_asyncLoadPhase;
|
||||
CDvdRequest* x34_dvdReq;
|
||||
std::vector<std::pair<std::string, SObjectTag>> x4c_nameList;
|
||||
std::vector<u32> x5c_depList;
|
||||
std::vector<std::pair<u32, SResInfo>> x6c_resList;
|
||||
public:
|
||||
CPakFile(const std::string& filename);
|
||||
const std::vector<u32>& GetDepList() const {return x5c_depList;}
|
||||
u32 GetResIdByName(const char* name) const
|
||||
{
|
||||
for (const std::pair<std::string, SObjectTag>& p : x4c_nameList)
|
||||
if (!CStringExtras::CompareCaseInsensitive(p.first.c_str(), name))
|
||||
return p.second.id;
|
||||
return 0;
|
||||
}
|
||||
const SResInfo* GetResInfoForLoad(u32 id);
|
||||
const SResInfo* GetResInfo(u32 id) const;
|
||||
u32 GetFakeStaticSize() const;
|
||||
void DataLoad();
|
||||
void InitialHeaderLoad();
|
||||
void Warmup();
|
||||
void AsyncIdle()
|
||||
{
|
||||
if (x2c_asyncLoadPhase == PakAsyncLoaded)
|
||||
return;
|
||||
if (x34_dvdReq && x34_dvdReq->IsComplete())
|
||||
return;
|
||||
switch (x2c_asyncLoadPhase)
|
||||
{
|
||||
case PakAsyncWarmup:
|
||||
Warmup();
|
||||
break;
|
||||
case PakAsyncInitialHeader:
|
||||
InitialHeaderLoad();
|
||||
break;
|
||||
case PakAsyncDataLoad:
|
||||
DataLoad();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CPAKFILE_HPP__
|
|
@ -3,7 +3,7 @@
|
|||
namespace Retro
|
||||
{
|
||||
|
||||
void CResFactory::Build(const SObjectTag&, const CVParamTransfer&)
|
||||
std::unique_ptr<IObj> CResFactory::Build(const SObjectTag&, const CVParamTransfer&)
|
||||
{
|
||||
}
|
||||
void CResFactory::BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**)
|
||||
|
@ -12,11 +12,5 @@ void CResFactory::BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**)
|
|||
void CResFactory::CancelBuild(const SObjectTag&)
|
||||
{
|
||||
}
|
||||
bool CResFactory::CanBuild(const SObjectTag&)
|
||||
{
|
||||
}
|
||||
const SObjectTag& CResFactory::GetResourceIdByName(const char*) const
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,41 @@
|
|||
#ifndef __RETRO_CRESFACTORY_HPP__
|
||||
#define __RETRO_CRESFACTORY_HPP__
|
||||
|
||||
#include <unordered_map>
|
||||
#include "IFactory.hpp"
|
||||
#include "CResLoader.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
class CDvdRequest;
|
||||
|
||||
class CResFactory : public IFactory
|
||||
{
|
||||
CResLoader x4_loader;
|
||||
public:
|
||||
void Build(const SObjectTag&, const CVParamTransfer&);
|
||||
struct SLoadingData
|
||||
{
|
||||
SObjectTag tag;
|
||||
CDvdRequest* dvdReq;
|
||||
IObj** targetPtr;
|
||||
void* loadBuffer;
|
||||
u32 resSize;
|
||||
};
|
||||
private:
|
||||
std::unordered_map<SObjectTag, SLoadingData> m_loadList;
|
||||
void AddToLoadList(const SLoadingData& data) {m_loadList[data.tag] = data;}
|
||||
public:
|
||||
std::unique_ptr<IObj> Build(const SObjectTag&, const CVParamTransfer&);
|
||||
void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**);
|
||||
void CancelBuild(const SObjectTag&);
|
||||
bool CanBuild(const SObjectTag&);
|
||||
const SObjectTag& GetResourceIdByName(const char*) const;
|
||||
bool CanBuild(const SObjectTag& tag) {return x4_loader.ResourceExists(tag);}
|
||||
u32 GetResourceIdByName(const char* name) const {return x4_loader.GetResourceIdByName(name);}
|
||||
|
||||
std::vector<std::pair<std::string, SObjectTag>> GetResourceIdToNameList() const
|
||||
{
|
||||
std::vector<std::pair<std::string, SObjectTag>> retval;
|
||||
return retval;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
#ifndef __RETRO_CRESLOADER_HPP__
|
||||
#define __RETRO_CRESLOADER_HPP__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CPakFile.hpp"
|
||||
#include "CBasics.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
class SObjectTag;
|
||||
class CDvdRequest;
|
||||
|
||||
class CResLoader
|
||||
{
|
||||
//std::list<std::unique_ptr<CPakFile>> x4_unusedList;
|
||||
std::list<std::unique_ptr<CPakFile>> x1c_pakLoadedList;
|
||||
std::list<std::unique_ptr<CPakFile>> x34_pakLoadingList;
|
||||
u32 x44_pakLoadingCount = 0;
|
||||
u32 x4c_cachedResId = -1;
|
||||
const CPakFile::SResInfo* x50_cachedResInfo = nullptr;
|
||||
public:
|
||||
const std::vector<u32>& GetTagListForFile(const std::string&) const;
|
||||
void AddPakFileAsync(const std::string&, bool);
|
||||
void AddPakFile(const std::string&, bool);
|
||||
CInputStream* LoadNewResourcePartSync(const SObjectTag&, int, int, char*);
|
||||
void LoadMemResourceSync(const SObjectTag&, char*, int*);
|
||||
CInputStream* LoadResourceFromMemorySync(const SObjectTag&, const void*);
|
||||
CInputStream* LoadNewResourceSync(const SObjectTag&, char*);
|
||||
|
||||
CDvdRequest* LoadResourcePartAsync(const SObjectTag& tag, int offset, int length, void* buf)
|
||||
{
|
||||
return FindResourceForLoad(tag.id)->AsyncSeekRead(buf, length,
|
||||
OriginBegin, x50_cachedResInfo->offset + offset);
|
||||
}
|
||||
|
||||
CDvdRequest* LoadResourceAsync(const SObjectTag& tag, void* buf)
|
||||
{
|
||||
return FindResourceForLoad(tag.id)->AsyncSeekRead(buf, ROUND_UP_32(x50_cachedResInfo->size),
|
||||
OriginBegin, x50_cachedResInfo->offset);
|
||||
}
|
||||
|
||||
bool GetResourceCompression(const SObjectTag& tag)
|
||||
{
|
||||
if (FindResource(tag.id))
|
||||
return x50_cachedResInfo->compressed;
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 ResourceSize(const SObjectTag& tag)
|
||||
{
|
||||
if (FindResource(tag.id))
|
||||
return x50_cachedResInfo->size;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ResourceExists(const SObjectTag& tag)
|
||||
{
|
||||
return FindResource(tag.id);
|
||||
}
|
||||
|
||||
FourCC GetResourceTypeById(u32 id)
|
||||
{
|
||||
if (FindResource(id))
|
||||
return x50_cachedResInfo->tag.type;
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 GetResourceIdByName(const char* name) const
|
||||
{
|
||||
for (const std::unique_ptr<CPakFile>& file : x1c_pakLoadedList)
|
||||
{
|
||||
u32 id = file->GetResIdByName(name);
|
||||
if (id)
|
||||
return id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AreAllPaksLoaded() const
|
||||
{
|
||||
return x44_pakLoadingCount == 0;
|
||||
}
|
||||
|
||||
void AsyncIdlePakLoading()
|
||||
{
|
||||
for (auto it=x34_pakLoadingList.begin();
|
||||
it != x34_pakLoadingList.end();
|
||||
++it)
|
||||
{
|
||||
(*it)->AsyncIdle();
|
||||
if ((*it)->x2c_asyncLoadPhase == CPakFile::PakAsyncLoaded)
|
||||
{
|
||||
MoveToCorrectLoadedList(std::move(*it));
|
||||
it = x34_pakLoadingList.erase(it);
|
||||
--x44_pakLoadingCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FindResource(u32 id)
|
||||
{
|
||||
for (const std::unique_ptr<CPakFile>& file : x1c_pakLoadedList)
|
||||
if (CacheFromPak(*file, id))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
CPakFile* FindResourceForLoad(u32 id)
|
||||
{
|
||||
for (std::unique_ptr<CPakFile>& file : x1c_pakLoadedList)
|
||||
if (CacheFromPakForLoad(*file, id))
|
||||
return file.get();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPakFile* FindResourceForLoad(const SObjectTag& tag)
|
||||
{
|
||||
return FindResourceForLoad(tag.id);
|
||||
}
|
||||
|
||||
bool CacheFromPakForLoad(CPakFile& file, u32 id)
|
||||
{
|
||||
const CPakFile::SResInfo* info = file.GetResInfoForLoad(id);
|
||||
if (info)
|
||||
{
|
||||
x4c_cachedResId = id;
|
||||
x50_cachedResInfo = info;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CacheFromPak(const CPakFile& file, u32 id)
|
||||
{
|
||||
const CPakFile::SResInfo* info = file.GetResInfo(id);
|
||||
if (info)
|
||||
{
|
||||
x4c_cachedResId = id;
|
||||
x50_cachedResInfo = info;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MoveToCorrectLoadedList(std::unique_ptr<CPakFile>&& file)
|
||||
{
|
||||
x1c_pakLoadedList.push_back(std::move(file));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CRESLOADER_HPP__
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef __RETRO_CSTRINGEXTRAS_HPP__
|
||||
#define __RETRO_CSTRINGEXTRAS_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
class CStringExtras
|
||||
{
|
||||
public:
|
||||
static int CompareCaseInsensitive(const char* a, const char* b)
|
||||
{
|
||||
#if _WIN32
|
||||
return _stricmp(a, b);
|
||||
#else
|
||||
return strcasecmp(a, b);
|
||||
#endif
|
||||
}
|
||||
static int CompareCaseInsensitive(const std::string& a, const std::string& b)
|
||||
{
|
||||
return CompareCaseInsensitive(a.c_str(), b.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CSTRINGEXTRAS_HPP__
|
|
@ -2,9 +2,11 @@
|
|||
#define __RETRO_CTOKEN_HPP__
|
||||
|
||||
#include <memory>
|
||||
#include "IObj.hpp"
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CVParamTransfer.hpp"
|
||||
#include "IVParamObj.hpp"
|
||||
#include "IObjectStore.hpp"
|
||||
#include "IFactory.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
@ -28,23 +30,72 @@ public:
|
|||
|
||||
bool IsLoading() const {return x3_loading;}
|
||||
void Unlock() {}
|
||||
void RemoveReference() {}
|
||||
void Lock() {}
|
||||
u32 RemoveReference()
|
||||
{
|
||||
--x0_refCount;
|
||||
if (x0_refCount == 0)
|
||||
{
|
||||
if (x10_object)
|
||||
Unload();
|
||||
if (IsLoading())
|
||||
CancelLoad();
|
||||
xC_objectStore->ObjectUnreferenced(x4_objTag);
|
||||
}
|
||||
}
|
||||
void CancelLoad() {}
|
||||
void Unload() {}
|
||||
void GetObject() {}
|
||||
void Unload()
|
||||
{
|
||||
x10_object.reset(nullptr);
|
||||
x3_loading = false;
|
||||
}
|
||||
IObj& GetObject()
|
||||
{
|
||||
IFactory& factory = xC_objectStore->GetFactory();
|
||||
factory.Build(x4_objTag, x14_params);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CToken
|
||||
{
|
||||
CObjectReference* x0_objRef;
|
||||
CObjectReference& x0_objRef;
|
||||
bool x4_lockHeld = false;
|
||||
public:
|
||||
~CToken()
|
||||
void Unlock()
|
||||
{
|
||||
if (x4_lockHeld)
|
||||
{
|
||||
x0_objRef.Unlock();
|
||||
x4_lockHeld = false;
|
||||
}
|
||||
}
|
||||
void Lock()
|
||||
{
|
||||
if (!x4_lockHeld)
|
||||
{
|
||||
x0_objRef.Lock();
|
||||
x4_lockHeld = true;
|
||||
}
|
||||
}
|
||||
void RemoveRef()
|
||||
{
|
||||
|
||||
}
|
||||
IObj& GetObj()
|
||||
{
|
||||
Lock();
|
||||
return x0_objRef.GetObject();
|
||||
}
|
||||
CToken& operator=(CToken&& other)
|
||||
{
|
||||
|
||||
}
|
||||
~CToken()
|
||||
{
|
||||
if (x0_objRef && x4_lockHeld)
|
||||
x0_objRef->Unlock();
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -5,16 +5,9 @@
|
|||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
class CCharacterFactoryBuilder
|
||||
class CCharacterFactoryBuilder : public IFactory
|
||||
{
|
||||
public:
|
||||
CCharacterFactoryBuilder();
|
||||
class CDummyFactory : public IFactory
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CASSETFACTORY_HPP__
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef __RETRO_CHIERARCHYPOSEBUILDER_HPP__
|
||||
#define __RETRO_CHIERARCHYPOSEBUILDER_HPP__
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
||||
class CHierarchyPoseBuilder
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RETRO_CHIERARCHYPOSEBUILDER_HPP__
|
|
@ -8,4 +8,5 @@ add_library(RuntimeCommonCharacter
|
|||
CAnimationDatabase.hpp
|
||||
CAnimationDatabaseGame.hpp
|
||||
CTransitionDatabase.hpp
|
||||
CTransitionDatabaseGame.hpp)
|
||||
CTransitionDatabaseGame.hpp
|
||||
CHierarchyPoseBuilder.hpp CHierarchyPoseBuilder.cpp)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef __RETRO_IFACTORY_HPP__
|
||||
#define __RETRO_IFACTORY_HPP__
|
||||
|
||||
#include <memory>
|
||||
#include "RetroTypes.hpp"
|
||||
|
||||
namespace Retro
|
||||
|
@ -12,11 +13,11 @@ class IFactory
|
|||
{
|
||||
public:
|
||||
virtual ~IFactory() {}
|
||||
virtual void Build(const SObjectTag&, const CVParamTransfer&)=0;
|
||||
virtual std::unique_ptr<IObj> Build(const SObjectTag&, const CVParamTransfer&)=0;
|
||||
virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**)=0;
|
||||
virtual void CancelBuild(const SObjectTag&)=0;
|
||||
virtual bool CanBuild(const SObjectTag&)=0;
|
||||
virtual const SObjectTag& GetResourceIdByName(const char*) const=0;
|
||||
virtual u32 GetResourceIdByName(const char*) const=0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -8,13 +8,15 @@ namespace Retro
|
|||
|
||||
class IObj
|
||||
{
|
||||
public:
|
||||
virtual ~IObj() {}
|
||||
};
|
||||
|
||||
class TObjOwnerDerivedFromIObjUntyped : public IObj
|
||||
{
|
||||
protected:
|
||||
void* m_objPtr;
|
||||
TObjOwnerDerivedFromIObjUntyped(void* objPtr) : m_objPtr(objPtr) {}
|
||||
IObj* m_objPtr;
|
||||
TObjOwnerDerivedFromIObjUntyped(IObj* objPtr) : m_objPtr(objPtr) {}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -3,21 +3,23 @@
|
|||
|
||||
namespace Retro
|
||||
{
|
||||
class SObjectTag;
|
||||
class CVParamTransfer;
|
||||
class IFactory;
|
||||
class IObj;
|
||||
|
||||
class IObjectStore
|
||||
{
|
||||
public:
|
||||
/*
|
||||
GetObj((SObjectTag const &,CVParamTransfer const &))
|
||||
GetObj((SObjectTag const &))
|
||||
GetObj((char const *))
|
||||
GetObj((char const *,CVParamTransfer const &))
|
||||
HasObject(const(SObjectTag const &))
|
||||
.data6:80352C6C .long CSimplePool::ObjectIsLive(const(SObjectTag const &))
|
||||
.data6:80352C70 .long CSimplePool::GetFactory(const(void))
|
||||
.data6:80352C74 .long CSimplePool::Flush((void))
|
||||
.data6:80352C78 .long CSimplePool::ObjectUnreferenced((SObjectTag const &))
|
||||
*/
|
||||
virtual IObj& GetObj(const SObjectTag&, const CVParamTransfer&)=0;
|
||||
virtual IObj& GetObj(const SObjectTag&)=0;
|
||||
virtual IObj& GetObj(char const*)=0;
|
||||
virtual IObj& GetObj(char const*, const CVParamTransfer&)=0;
|
||||
virtual void HasObject(const SObjectTag&) const=0;
|
||||
virtual void ObjectIsLive(const SObjectTag&) const=0;
|
||||
virtual IFactory& GetFactory() const=0;
|
||||
virtual void Flush()=0;
|
||||
virtual void ObjectUnreferenced(const SObjectTag&)=0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -11,10 +11,14 @@
|
|||
namespace Retro
|
||||
{
|
||||
|
||||
using FourCC = HECL::FourCC;
|
||||
|
||||
struct SObjectTag
|
||||
{
|
||||
FourCC type;
|
||||
UniqueID32 id;
|
||||
u32 id;
|
||||
bool operator!=(const SObjectTag& other) const {return id != other.id;}
|
||||
bool operator==(const SObjectTag& other) const {return id == other.id;}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -62,4 +66,14 @@ using TAreaId = u32;
|
|||
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<Retro::SObjectTag>
|
||||
{
|
||||
inline size_t operator()(const Retro::SObjectTag& tag) const
|
||||
{return tag.id;}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __RETRO_TYPES_HPP__
|
||||
|
|
Loading…
Reference in New Issue