2022-09-04 23:21:59 -04:00
|
|
|
//
|
|
|
|
// EuropaTools
|
|
|
|
//
|
2025-01-07 14:13:22 -05:00
|
|
|
// (C) 2021-2025 modeco80 <lily.modeco80@protonmail.ch>
|
2022-09-04 23:21:59 -04:00
|
|
|
//
|
2025-01-07 18:02:27 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-09-04 23:21:59 -04:00
|
|
|
//
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
#pragma endian little
|
2022-09-07 05:07:40 -04:00
|
|
|
// Big archives need a big pattern limit
|
2022-09-21 03:49:57 -04:00
|
|
|
#pragma pattern_limit 0x40000
|
|
|
|
#pragma array_limit 0x40000
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
namespace europa {
|
|
|
|
|
|
|
|
struct PakHeader {
|
|
|
|
char magic[16]; // "Europa Packfile\0"
|
|
|
|
|
|
|
|
// Doesn't include magic
|
2025-01-12 16:05:58 -05:00
|
|
|
u8 revision;
|
|
|
|
|
|
|
|
// This seems to be the start of the actual header
|
|
|
|
u8 pad;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
2025-01-07 14:13:22 -05:00
|
|
|
// 0x3 - PMDL
|
2022-09-04 17:11:14 -04:00
|
|
|
// 0x4 - Starfighter
|
2025-01-07 14:13:22 -05:00
|
|
|
// 0x5 - Jedi Starfighter
|
2022-09-04 17:11:14 -04:00
|
|
|
u16 Version;
|
2025-01-12 16:05:58 -05:00
|
|
|
u8 pad2;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
u32 tocOffset;
|
|
|
|
|
2025-01-07 14:13:22 -05:00
|
|
|
u32 tocSize;
|
2022-09-04 17:11:14 -04:00
|
|
|
|
|
|
|
u32 fileCount;
|
|
|
|
|
2025-01-07 14:13:22 -05:00
|
|
|
// Unix epoch timestamp (libc time()) of when the archive was created
|
2022-09-04 17:11:14 -04:00
|
|
|
u32 archiveCreationTime;
|
|
|
|
|
2025-01-07 14:13:22 -05:00
|
|
|
// Set to 0 in basically every file
|
|
|
|
u32 reserved;
|
2025-01-12 16:05:58 -05:00
|
|
|
|
|
|
|
// Version 5 has additional fields to support sector-alignment
|
|
|
|
if(Version == 5) {
|
|
|
|
u32 sectorSize;
|
|
|
|
u8 sectorAligned;
|
|
|
|
u8 pad3;
|
|
|
|
}
|
2022-09-04 17:11:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// "Pascal" string used
|
|
|
|
// in the TOC.
|
|
|
|
struct PakTocPString {
|
|
|
|
u8 len;
|
|
|
|
|
|
|
|
if(len != 0)
|
|
|
|
char string[len];
|
|
|
|
};
|
|
|
|
|
|
|
|
// A Toc entry
|
|
|
|
struct PakTocEntry {
|
|
|
|
PakTocPString fileName;
|
|
|
|
|
|
|
|
u32 offset;
|
|
|
|
u32 size;
|
|
|
|
|
2025-01-12 16:05:58 -05:00
|
|
|
if(parent.header.Version == 5) {
|
|
|
|
if(parent.header.sectorAligned == 0x1) {
|
|
|
|
// Start LBA of the file
|
|
|
|
u32 startLBA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-04 17:11:14 -04:00
|
|
|
// Seems to be the same as he header.
|
|
|
|
u32 creationTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PakFile {
|
|
|
|
PakHeader header;
|
2022-09-07 05:07:40 -04:00
|
|
|
PakTocEntry toc[header.fileCount] @ header.tocOffset;
|
2022-09-04 17:11:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace europa
|
|
|
|
|
|
|
|
europa::PakFile pak @ 0x0;
|