blob: 80f8f856a966266a2e7ae323ea06a7d72947a182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// This file is part of the 64k demo project.
// It implements the generic asset retrieval logic.
// Uses an array lookup for O(1) access to embedded data.
#include "util/asset_manager.h"
#include "assets.h"
// These are defined in the generated assets_data.cc
extern const AssetRecord g_assets[];
extern const size_t g_assets_count;
const uint8_t *GetAsset(AssetId asset_id, size_t *out_size) {
uint16_t index = static_cast<uint16_t>(asset_id);
if (index >= g_assets_count) {
if (out_size)
*out_size = 0;
return nullptr;
}
const AssetRecord &record = g_assets[index];
if (out_size)
*out_size = record.size;
return record.data;
}
void DropAsset(AssetId asset_id, const uint8_t *asset) {
(void)asset_id;
(void)asset;
// Implementation for lazy decompression will go here
}
|