Add core functionality for loading and processing game assets
- Implemented palette loading from binary files in `palette.cpp`. - Added runtime utilities for reading text and JSON files in `runtime.cpp`. - Created shape archive handling in `shape_archive.cpp`, including frame parsing and pixel decoding. - Introduced type flag loading functionality in `type_flags.cpp`. - Developed tests for combat tactics, entity dispatch entries, file system operations, fixed maps, flex archives, glob archives, map rendering, palette loading, shape archives, and type flags. - Added a Python script for importing Ghidra-exported function slices with reporting capabilities.
This commit is contained in:
parent
6ca3b18c3e
commit
8907604b84
41 changed files with 2889 additions and 0 deletions
56
rebuild/remorse/src/glob_archive.cpp
Normal file
56
rebuild/remorse/src/glob_archive.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "remorse/glob_archive.h"
|
||||
|
||||
#include "remorse/flex_archive.h"
|
||||
|
||||
namespace remorse {
|
||||
namespace {
|
||||
|
||||
constexpr u32 globCountSize = 2;
|
||||
constexpr u32 globEntrySize = 6;
|
||||
|
||||
u16 readU16Le(const std::vector<u8>& bytes, u32 offset)
|
||||
{
|
||||
return static_cast<u16>(bytes[offset] | (static_cast<u16>(bytes[offset + 1]) << 8));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<std::vector<GlobObject>> loadGlobObjects(const std::filesystem::path& path)
|
||||
{
|
||||
const auto archive = loadFlexArchive(path);
|
||||
if (!archive) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<GlobObject> objects;
|
||||
for (const FlexEntry& flexEntry : archive->populatedEntries) {
|
||||
const auto bytes = readFlexEntry(*archive, flexEntry.index);
|
||||
if (!bytes || bytes->size() < globCountSize) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const u16 entryCount = readU16Le(*bytes, 0);
|
||||
const u32 expectedSize = globCountSize + static_cast<u32>(entryCount) * globEntrySize;
|
||||
if (expectedSize > bytes->size()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
GlobObject object;
|
||||
object.index = flexEntry.index;
|
||||
for (u32 index = 0; index < entryCount; ++index) {
|
||||
const u32 offset = globCountSize + index * globEntrySize;
|
||||
GlobObjectEntry entry;
|
||||
entry.x = (*bytes)[offset];
|
||||
entry.y = (*bytes)[offset + 1];
|
||||
entry.z = (*bytes)[offset + 2];
|
||||
entry.shape = readU16Le(*bytes, offset + 3);
|
||||
entry.frame = (*bytes)[offset + 5];
|
||||
object.entries.push_back(entry);
|
||||
}
|
||||
objects.push_back(object);
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
} // namespace remorse
|
||||
Loading…
Add table
Add a link
Reference in a new issue