#pragma once

// ::Assets::Macros::Header::

#define FILE_VERSION 0

#define CreateMagicValue(a, b, c, d) ((u32)(d << 24) | (u32)(c << 16) | (u32)(b << 8) | (u32)(a))

// ::Assets::Types::Header::

typedef enum AssetType_e
{
	SHADER_ASSET,
	TEXTURE_ASSET,
	SOUND_ASSET,
	MODEL_ASSET,
	ASSET_TYPE_MAX,
} AssetType;

typedef enum ShaderAsset_e
{
	QUAD_FRAG_SPIRV_SHADER,
	QUAD_VERT_SPIRV_SHADER,
	GUI_FRAG_SPIRV_SHADER,
	GUI_VERT_SPIRV_SHADER,
	
	SHADER_ASSET_MAX,
} ShaderAsset;

typedef enum TextureAsset_e
{
	PATTERMON_OBESE,
	PATTERMON_PURPLOID,
	PATTERMON_ORIENTAL,

	TEXTURE_ASSET_MAX
} TextureAsset;

typedef enum TextureAssetTag_e
{
	TEXTURE_ASSET_TAG_MAX,
} TextureAssetTag;

typedef enum SoundAsset_e
{
	SOUND_ASSET_MAX,
} SoundAsset;

typedef enum SoundAssetTag_e
{
	SOUND_ASSET_TAG_MAX,
} SoundAssetTag;

typedef enum ModelAsset_e
{
	MODEL_ASSET_MAX,
} ModelAsset;

typedef enum ModelAssetTag_e
{
	MODEL_ASSET_TAG_MAX,
} ModelAssetTag;

typedef struct TextureAssetMeta
{
	u32 w;
	u32 h;
} TextureAssetMeta;

typedef struct Asset
{
	u8  *bytes;
	u64	len;
	union 
	{
		TextureAssetMeta texture_meta;
	};
} Asset;

typedef struct AssetTag
{
	u32 tag_id;
	f32 value;
} AssetTag;

typedef struct AssetFile
{
	u64 data_offset;
	u64 len;
} AssetFile;

typedef struct FileHeader
{
	u32 magic_num;
	u32 version;

	u32 tag_counts[ASSET_TYPE_MAX];
	u32 asset_counts[ASSET_TYPE_MAX];

	u64 tag_offsets[ASSET_TYPE_MAX];
	u64 asset_offsets[ASSET_TYPE_MAX];
} FileHeader;

// ::Assets::Init::Functions::Header::

static void AssetPackLoadHeader();

// ::Assets::Loading::Functions::Header::

static Asset AssetPackLoadTexture(TextureAsset asset_id);
static Asset AssetPackLoadShader(ShaderAsset asset_id);
static void AssetPackUnloadTexture(Asset asset);
static void AssetPackUnloadShader(Asset asset);

// ::Assets::Util::Functions::Header::

// TODO(MA): Implement async asset handling
static inline b32 AssetPackMarkUnloaded(AssetType type, u32 index);
static inline void AssetPackMarkLoaded(AssetType type, u32 index);
