2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 22:27:43 +00:00

Finish CPakFile and CResLoader

This commit is contained in:
Jack Andersen
2017-10-25 19:37:46 -10:00
parent e274cd12b9
commit 7c3fb4174f
20 changed files with 561 additions and 124 deletions

View File

@@ -6,6 +6,7 @@
#include "CStringExtras.hpp"
#include "CDvdFile.hpp"
#include "CDvdRequest.hpp"
#include "CFactoryMgr.hpp"
namespace urde
{
@@ -16,10 +17,24 @@ class CPakFile : public CDvdFile
public:
struct SResInfo
{
FourCC x0_type;
u32 x4_offset;
u32 x8_size;
bool xb_compressed;
CAssetId x0_id;
bool x4_compressed : 1;
CFactoryMgr::ETypeTable x4_typeIdx : 7;
u32 x5_offsetDiv32 : 27;
u32 x7_sizeDiv32 : 27;
SResInfo(CAssetId id, FourCC fcc, u32 offset, u32 size, u32 flags)
: x0_id(id)
{
x4_compressed = flags != 0;
x4_typeIdx = CFactoryMgr::FourCCToTypeIdx(fcc);
x5_offsetDiv32 = offset / 32;
x7_sizeDiv32 = size / 32;
}
u32 GetOffset() const { return x5_offsetDiv32 * 32; }
u32 GetSize() const { return x7_sizeDiv32 * 32; }
FourCC GetType() const { return CFactoryMgr::TypeIdxToFourCC(x4_typeIdx); }
bool IsCompressed() const { return x4_compressed; }
CAssetId GetId() const { return x0_id; }
};
private:
union
@@ -39,25 +54,28 @@ private:
InitialHeader = 1,
DataLoad = 2,
Loaded = 3
} x2c_asyncLoadPhase;
} x2c_asyncLoadPhase = EAsyncPhase::Warmup;
std::shared_ptr<IDvdRequest> x30_dvdReq; // Used to be auto_ptr
std::vector<u8> x38_headerData;
u32 x48_resTableOffset = 0;
u32 x4c_resTableCount = 0;
int x50_ = -1;
int x50_aramBase = -1;
std::vector<std::pair<std::string, SObjectTag>> x54_nameList;
std::vector<CAssetId> x64_depList;
std::vector<std::pair<CAssetId, SResInfo>> x74_resList;
std::vector<SResInfo> x74_resList;
mutable s32 x84_currentSeek = -1;
void LoadResourceTable(athena::io::MemoryReader& r);
void DataLoad();
void InitialHeaderLoad();
void Warmup();
public:
CPakFile(const std::string& filename, bool buildDepList, bool worldPak);
const std::vector<CAssetId>& GetDepList() const { return x64_depList; }
const SObjectTag* GetResIdByName(const char* name) const;
const SResInfo* GetResInfoForLoad(CAssetId id) { return nullptr; }
const SResInfo* GetResInfo(CAssetId id) const { return nullptr; }
const SResInfo* GetResInfoForLoadPreferForward(CAssetId id) const;
const SResInfo* GetResInfoForLoadDirectionless(CAssetId id) const;
const SResInfo* GetResInfo(CAssetId id) const;
u32 GetFakeStaticSize() const { return 0; }
void DataLoad() {}
void InitialHeaderLoad() {}
void Warmup() {}
void AsyncIdle();
};