yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
lyra_layout_descriptor.h
Go to the documentation of this file.
1#ifndef YAZE_ROM_LYRA_LAYOUT_DESCRIPTOR_H_
2#define YAZE_ROM_LYRA_LAYOUT_DESCRIPTOR_H_
3
4#include <array>
5#include <cstddef>
6#include <cstdint>
7#include <optional>
8#include <span>
9#include <string>
10#include <vector>
11
12#include "absl/status/statusor.h"
13
14namespace yaze::rom {
15
16// This is the proposed overworld ROM format, not the separate SRAM event format.
17// A valid revision-1 image is readable for inspection but has no Yaze writer.
19
21 uint16_t id = 0;
22 uint16_t kind = 0;
23 uint32_t snes_address = 0;
24 uint32_t pc_address = 0;
25 uint16_t count = 0;
26 uint16_t stride = 0;
27 uint32_t crc32 = 0;
28};
29
32 uint16_t revision = 0;
33 uint16_t capacity = 0;
34 uint16_t active_count = 0;
35 bool write_supported = true;
36 // A revision-2 capability permits only the dedicated A0 terrain Save As.
37 // Generic ROM writes remain refused for every Lyra revision.
39 bool offline_only = true;
40 std::string error;
41 std::vector<LyraLayoutEntry> entries;
42};
43
44// The input is a headerless ROM image. The caller owns session attribution:
45// an attributed image remains protected even if a later in-memory edit removes
46// its magic bytes. Unrelated ROM data at the locator is not attribution.
47LyraLayoutInspection InspectLyraLayout(const uint8_t* image, size_t size);
48
49// Checked, session-local reads from an already validated descriptor. The
50// descriptor owns table addresses; ordinary ROM settings are not consulted.
51std::optional<std::span<const uint8_t>> LyraLayoutRecord(
52 const LyraLayoutInspection& layout, const uint8_t* image, size_t size,
53 uint16_t table_id, size_t index);
54
55// Reuses the descriptor validator's stream decoder and allocation fences.
56std::optional<std::array<uint16_t, 256>> LyraMapTile32(
57 const LyraLayoutInspection& layout, const uint8_t* image, size_t size,
58 size_t map_index);
59
60inline constexpr uint32_t kLyraA0HighStreamPc = 0x132000;
61inline constexpr uint32_t kLyraA0LowStreamPc = 0x132200;
62inline constexpr size_t kLyraA0StreamSlotSize = 512;
63
64// Stages a complete image without mutating the caller. Revision 1, malformed
65// descriptors and every unowned byte remain protected. No checksum is changed.
66absl::StatusOr<std::vector<uint8_t>> SerializeLyraA0Terrain(
67 const std::vector<uint8_t>& baseline,
68 const std::array<uint16_t, 256>& tiles);
69
70} // namespace yaze::rom
71
72#endif // YAZE_ROM_LYRA_LAYOUT_DESCRIPTOR_H_
std::optional< std::span< const uint8_t > > LyraLayoutRecord(const LyraLayoutInspection &layout, const uint8_t *image, size_t size, uint16_t table_id, size_t index)
constexpr uint32_t kLyraA0LowStreamPc
constexpr uint32_t kLyraA0HighStreamPc
LyraLayoutInspection InspectLyraLayout(const uint8_t *image, size_t size)
std::optional< std::array< uint16_t, 256 > > LyraMapTile32(const LyraLayoutInspection &layout, const uint8_t *image, size_t size, size_t map_index)
absl::StatusOr< std::vector< uint8_t > > SerializeLyraA0Terrain(const std::vector< uint8_t > &baseline, const std::array< uint16_t, 256 > &tiles)
constexpr size_t kLyraA0StreamSlotSize
std::vector< LyraLayoutEntry > entries