2024-08-17 09:52:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
struct Version {
|
|
|
|
u32 major;
|
|
|
|
u32 minor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FileHeader {
|
|
|
|
u32 toc_offset;
|
|
|
|
Version version;
|
|
|
|
padding[256];
|
|
|
|
u32 deadbeef;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TOCEntry {
|
|
|
|
char name[12];
|
|
|
|
u32 offset;
|
|
|
|
u32 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TableOfContents {
|
|
|
|
u32 item_count;
|
|
|
|
TOCEntry items[item_count];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ChunkHeader {
|
|
|
|
char name[12];
|
|
|
|
Version version;
|
|
|
|
padding[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Chunk<T> {
|
|
|
|
ChunkHeader header;
|
|
|
|
T data;
|
|
|
|
};
|
|
|
|
|
|
|
|
fn get_toc_entry(TableOfContents toc, str entry_name) {
|
|
|
|
for (u32 i = 0, i < toc.item_count, i = i + 1) {
|
|
|
|
if (std::string::starts_with(toc.items[i].name, entry_name)) {
|
|
|
|
return toc.items[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
fn get_offset(TableOfContents toc, str entry_name) {
|
|
|
|
TOCEntry entry = get_toc_entry(toc, entry_name);
|
|
|
|
return entry.offset;
|
2024-08-23 11:07:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
fn get_size(TableOfContents toc, str entry_name) {
|
|
|
|
TOCEntry entry = get_toc_entry(toc, entry_name);
|
|
|
|
return entry.size;
|
|
|
|
};
|
|
|
|
|
|
|
|
fn get_end(TableOfContents toc, str entry_name) {
|
|
|
|
TOCEntry entry = get_toc_entry(toc, entry_name);
|
|
|
|
return entry.offset + entry.size + 24;
|
2024-08-17 09:52:09 +00:00
|
|
|
};
|