Loader for ZSPR (ALttP Randomizer) sprite files. More...
#include <zspr_loader.h>
Static Public Member Functions | |
| static absl::StatusOr< ZsprData > | LoadFromFile (const std::string &path) |
| Load ZSPR data from a file path. | |
| static absl::StatusOr< ZsprData > | LoadFromData (const std::vector< uint8_t > &data) |
| Load ZSPR data from a byte buffer. | |
| static absl::Status | ApplyToRom (Rom &rom, const ZsprData &zspr) |
| Apply loaded ZSPR sprite data to ROM's Link graphics. | |
| static absl::Status | ApplyPaletteToRom (Rom &rom, const ZsprData &zspr) |
| Apply ZSPR palette data to ROM. | |
Static Public Attributes | |
| static constexpr uint32_t | kZsprMagic = 0x5250535A |
| static constexpr size_t | kExpectedSpriteDataSize = 28672 |
| static constexpr size_t | kExpectedPaletteDataSize = 120 |
| static constexpr size_t | kTilesPerSheet = 64 |
| static constexpr size_t | kBytesPerTile = 32 |
| static constexpr size_t | kLinkSheetCount = 14 |
Static Private Member Functions | |
| static bool | ValidateChecksum (const std::vector< uint8_t > &data, uint32_t expected_checksum) |
| Validate ZSPR checksum (Adler-32) | |
| static uint32_t | CalculateAdler32 (const uint8_t *data, size_t length) |
| Calculate Adler-32 checksum. | |
| static std::string | ReadNullTerminatedString (const uint8_t *data, size_t max_length, size_t &bytes_read) |
| Read null-terminated string from buffer. | |
| static uint16_t | ReadU16LE (const uint8_t *data) |
| Read 16-bit little-endian value. | |
| static uint32_t | ReadU32LE (const uint8_t *data) |
| Read 32-bit little-endian value. | |
Loader for ZSPR (ALttP Randomizer) sprite files.
ZSPR Format (v1):
Definition at line 72 of file zspr_loader.h.
|
static |
Load ZSPR data from a file path.
| path | Path to the .zspr file |
Definition at line 14 of file zspr_loader.cc.
References LoadFromData().
Referenced by yaze::editor::LinkSpritePanel::ImportZspr().

|
static |
Load ZSPR data from a byte buffer.
| data | Raw file contents |
Definition at line 35 of file zspr_loader.cc.
References yaze::gfx::ZsprMetadata::author, yaze::gfx::ZsprMetadata::author_rom_name, yaze::gfx::ZsprMetadata::display_name, yaze::gfx::ZsprData::glove_colors, yaze::gfx::ZsprData::is_link_sprite(), kExpectedSpriteDataSize, LOG_INFO, LOG_WARN, yaze::gfx::ZsprData::metadata, yaze::gfx::ZsprData::palette_data, ReadNullTerminatedString(), ReadU16LE(), ReadU32LE(), yaze::gfx::ZsprData::sprite_data, yaze::gfx::ZsprMetadata::sprite_type, ValidateChecksum(), and yaze::gfx::ZsprMetadata::version.
Referenced by LoadFromFile().
Apply loaded ZSPR sprite data to ROM's Link graphics.
Writes the sprite data to the ROM at Link's graphics sheet locations. The ZSPR 4BPP data is converted to the ROM's expected format.
| rom | ROM to modify |
| zspr | ZSPR data to apply |
Definition at line 147 of file zspr_loader.cc.
References yaze::gfx::ZsprMetadata::display_name, yaze::gfx::ZsprData::is_link_sprite(), yaze::Rom::is_loaded(), kExpectedSpriteDataSize, kLinkSheetCount, LOG_INFO, LOG_WARN, yaze::gfx::ZsprData::metadata, yaze::gfx::ZsprData::sprite_data, and yaze::Rom::WriteByte().
Referenced by yaze::editor::LinkSpritePanel::ImportZspr().

Apply ZSPR palette data to ROM.
Writes the sprite palette data to the appropriate ROM locations.
| rom | ROM to modify |
| zspr | ZSPR data containing palette |
Definition at line 206 of file zspr_loader.cc.
References yaze::Rom::is_loaded(), kExpectedPaletteDataSize, yaze::gfx::kNumPalettes, LOG_INFO, yaze::gfx::ZsprData::palette_data, and yaze::Rom::WriteByte().
Referenced by yaze::editor::LinkSpritePanel::ImportZspr().

|
staticprivate |
Validate ZSPR checksum (Adler-32)
Definition at line 257 of file zspr_loader.cc.
References CalculateAdler32().
Referenced by LoadFromData().

|
staticprivate |
Calculate Adler-32 checksum.
Definition at line 263 of file zspr_loader.cc.
Referenced by ValidateChecksum().
|
staticprivate |
Read null-terminated string from buffer.
Definition at line 275 of file zspr_loader.cc.
Referenced by LoadFromData().
|
staticprivate |
Read 16-bit little-endian value.
Definition at line 292 of file zspr_loader.cc.
Referenced by LoadFromData().
|
staticprivate |
Read 32-bit little-endian value.
Definition at line 297 of file zspr_loader.cc.
Referenced by LoadFromData().
|
staticconstexpr |
Definition at line 74 of file zspr_loader.h.
|
staticconstexpr |
Definition at line 75 of file zspr_loader.h.
Referenced by ApplyToRom(), and LoadFromData().
|
staticconstexpr |
Definition at line 76 of file zspr_loader.h.
Referenced by ApplyPaletteToRom().
|
staticconstexpr |
Definition at line 77 of file zspr_loader.h.
|
staticconstexpr |
Definition at line 78 of file zspr_loader.h.
|
staticconstexpr |
Definition at line 79 of file zspr_loader.h.
Referenced by ApplyToRom().