diff --git a/lib/bolt/Reader.cpp b/lib/bolt/Reader.cpp
index e68e6b8..154b3c5 100644
--- a/lib/bolt/Reader.cpp
+++ b/lib/bolt/Reader.cpp
@@ -2,12 +2,12 @@
#include
#include
-
#include
namespace lightningbolt {
struct BoltReader::Impl {
+ Impl(Game game) : game(game) {}
ErrorOr OpenBolt(const fs::path& path) {
// Load the BOLT file
@@ -19,36 +19,40 @@ namespace lightningbolt {
if(!lib->Validate())
return std::make_error_code(BoltErrc::InvalidMagic);
- auto p = path;
- p.replace_filename("SLUS_201.14");
+ if(game == Game::SimpsonsSkateboarding) {
+ auto p = path;
+ p.replace_filename("SLUS_201.14");
- if(auto error = elfFile.Open(p); error.HasError())
- return error;
+ if(auto error = elfFile.Open(p); error.HasError())
+ return error;
- // Load table entries.
- GetTableEntries();
+ // Load table entries.
+ GetTableEntries();
+ }
return {};
}
const std::vector& GetTableEntries() {
- if(entryTable.empty()) {
- auto* base = elfFile.GetMapping();
- auto* table = std::bit_cast(base + elf::BoltTableOffsets.usTable);
- while(table->filenamePtr != 0x0) {
- auto string_offset = elf::AddressToElfFileOffset(table->filenamePtr);
+ if(game == Game::SimpsonsSkateboarding) {
+ if(entryTable.empty()) {
+ auto* base = elfFile.GetMapping();
+ auto* table = std::bit_cast(base + elf::BoltTableOffsets.usTable);
+ while(table->filenamePtr != 0x0) {
+ auto string_offset = elf::AddressToElfFileOffset(table->filenamePtr);
- BoltReader::File te;
- te.filename = { std::bit_cast(base + string_offset) };
- te.index = table->entryId;
- te.gid = table->groupId;
+ BoltReader::File te;
+ te.filename = { std::bit_cast(base + string_offset) };
+ te.index = table->entryId;
+ te.gid = table->groupId;
- if(te.filename == "")
- break;
+ if(te.filename == "")
+ break;
- entryTable.emplace_back(te);
+ entryTable.emplace_back(te);
- table++;
+ table++;
+ }
}
}
return entryTable;
@@ -75,6 +79,7 @@ namespace lightningbolt {
}
private:
+ Game game;
std::vector entryTable;
MmapFile elfFile;
MmapFile boltFile;
@@ -82,8 +87,8 @@ namespace lightningbolt {
BoltLibraryHeader* lib;
};
- BoltReader::BoltReader():
- impl(std::make_unique()) {}
+ BoltReader::BoltReader(Game game) : impl(std::make_unique(game)) {
+ }
BoltReader::~BoltReader() = default;
@@ -92,9 +97,7 @@ namespace lightningbolt {
}
void BoltReader::ForEachFile(std::function f) {
- impl->ForEachFile([&f](auto& file) {
- return f(file);
- });
+ impl->ForEachFile([&f](auto& file) { return f(file); });
}
} // namespace lightningbolt
diff --git a/lib/bolt/Reader.hpp b/lib/bolt/Reader.hpp
index 033e446..df9dc85 100644
--- a/lib/bolt/Reader.hpp
+++ b/lib/bolt/Reader.hpp
@@ -6,6 +6,12 @@
namespace lightningbolt {
struct BoltReader {
+ enum class Game {
+ LooseBolt, ///< Use this for games with no bolt entry
+ SimpsonsSkateboarding,
+ NamcoMuseumGCN = LooseBolt
+ };
+
struct File {
std::string_view filename;
u16 index;
@@ -15,10 +21,9 @@ namespace lightningbolt {
u8* uncompressedData { nullptr };
usize uncompressedSize;
-
};
- BoltReader();
+ BoltReader(Game game = Game::SimpsonsSkateboarding);
~BoltReader();
ErrorOr OpenBolt(const fs::path& path);
diff --git a/lib/structs/BoltStructs.hpp b/lib/structs/BoltStructs.hpp
index 8c2c958..508e4a1 100644
--- a/lib/structs/BoltStructs.hpp
+++ b/lib/structs/BoltStructs.hpp
@@ -7,6 +7,7 @@
namespace lightningbolt {
+ /// Elf structures, only applicable to Simpsons Skateboarding
namespace elf {
/// Table entry in the ELF. We use this to create file names.