metaforce/Runtime/CPakFile.hpp

86 lines
2.6 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_CPAKFILE_HPP__
#define __URDE_CPAKFILE_HPP__
2015-08-23 06:42:29 +00:00
#include <vector>
#include "RetroTypes.hpp"
#include "CStringExtras.hpp"
#include "CDvdFile.hpp"
#include "CDvdRequest.hpp"
2017-10-26 05:37:46 +00:00
#include "CFactoryMgr.hpp"
2015-08-23 06:42:29 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
2015-08-23 06:42:29 +00:00
{
class CPakFile : public CDvdFile
{
friend class CResLoader;
public:
struct SResInfo
{
2017-10-26 05:37:46 +00:00
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; }
2015-08-23 06:42:29 +00:00
};
private:
2017-02-08 06:48:43 +00:00
union
{
struct
{
2017-04-15 05:32:25 +00:00
bool x28_24_buildDepList;
2017-02-08 06:48:43 +00:00
bool x28_25_aramFile;
bool x28_26_worldPak;
2017-10-27 10:10:32 +00:00
bool x28_27_stashedInARAM;
2017-02-08 06:48:43 +00:00
};
u32 _dummy = 0;
};
2015-11-21 01:16:07 +00:00
enum class EAsyncPhase
2015-08-23 06:42:29 +00:00
{
2015-11-21 01:16:07 +00:00
Warmup = 0,
InitialHeader = 1,
DataLoad = 2,
Loaded = 3
2017-10-26 05:37:46 +00:00
} x2c_asyncLoadPhase = EAsyncPhase::Warmup;
2017-04-15 05:32:25 +00:00
std::shared_ptr<IDvdRequest> x30_dvdReq; // Used to be auto_ptr
std::vector<u8> x38_headerData;
u32 x48_resTableOffset = 0;
u32 x4c_resTableCount = 0;
2017-10-26 05:37:46 +00:00
int x50_aramBase = -1;
2017-04-15 05:32:25 +00:00
std::vector<std::pair<std::string, SObjectTag>> x54_nameList;
2017-08-13 05:26:14 +00:00
std::vector<CAssetId> x64_depList;
2017-10-26 05:37:46 +00:00
std::vector<SResInfo> x74_resList;
mutable s32 x84_currentSeek = -1;
void LoadResourceTable(athena::io::MemoryReader& r);
void DataLoad();
void InitialHeaderLoad();
void Warmup();
2015-08-23 06:42:29 +00:00
public:
2017-04-15 05:32:25 +00:00
CPakFile(const std::string& filename, bool buildDepList, bool worldPak);
const std::vector<std::pair<std::string, SObjectTag>>& GetNameList() const { return x54_nameList; }
2017-08-13 05:26:14 +00:00
const std::vector<CAssetId>& GetDepList() const { return x64_depList; }
2017-02-08 06:48:43 +00:00
const SObjectTag* GetResIdByName(const char* name) const;
2017-10-26 05:37:46 +00:00
const SResInfo* GetResInfoForLoadPreferForward(CAssetId id) const;
const SResInfo* GetResInfoForLoadDirectionless(CAssetId id) const;
const SResInfo* GetResInfo(CAssetId id) const;
2017-02-08 06:48:43 +00:00
u32 GetFakeStaticSize() const { return 0; }
void AsyncIdle();
2015-08-23 06:42:29 +00:00
};
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CPAKFILE_HPP__