yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_atlas.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_ATLAS_DUNGEON_ATLAS_H_
2#define YAZE_ZELDA3_ATLAS_DUNGEON_ATLAS_H_
3
4// Dungeon Atlas model: every underworld room ($000-$127) with its owner area,
5// status, doors, links and chest/key badges, plus door edges, areas, plans and
6// the per-area key table. No ImGui; the CLI (`z3ed atlas-render --json`), the
7// renderer (P3) and the editor windows (P4) read this model.
8//
9// The room census (room_census.h) stays the single source of status, owners
10// and reachability. CollectDungeonAtlasInput runs the census collection once
11// and reads the extra per-room facts (door types, chest items, pot items, key
12// drops) from the same room loads. BuildDungeonAtlas is a pure function of the
13// input and the annotations.
14//
15// Every derived field records where it came from (Origin): "rom", "registry",
16// "annotation:<file>", "symbol:<label>" or "default".
17
18#include <cstdint>
19#include <map>
20#include <set>
21#include <string>
22#include <vector>
23
24#include "absl/status/statusor.h"
28
29namespace yaze {
30class Rom;
31namespace core {
32struct ProjectRegistry;
33class HackManifest;
34} // namespace core
35
36namespace zelda3::atlas {
37
38enum class RoomStatus : uint8_t {
39 kInUse,
40 kFree,
42 kOrphan, // Census: in use, but nothing reaches it.
43 kReserved, // Free or reclaimable, but an ASM (annotation or symbol) link
44 // lands in it, or an annotation marks it reserved.
45};
46const char* RoomStatusName(RoomStatus status);
47
48enum class LinkKind : uint8_t {
49 kEntrance, // Overworld entrance into the room (links_in).
50 kHole, // Overworld hole into the room (links_in).
51 kSpawn, // Spawn point (links_in).
52 kStair, // Stair object -> header slot destination.
53 kPit, // Pits using the header holewarp.
54 kWarpTiles, // Warp tiles using the header holewarp.
55 kWarpTag, // Project warp tag through header stair slots.
56 kPitDamage, // Pits in a RoomsWithPitDamage room: no warp.
57 kTagPit, // Tag-driven holes (weak).
58 kAnnotation, // Annotation `links[]` (runtime-only links).
59 kSymbol, // `symbol_links[]` read from the ROM at a .sym label.
60};
61const char* LinkKindName(LinkKind kind);
62
63struct AtlasLink {
65 int from = -1; // Source room (-1 for entrances, holes, spawns).
66 int to = -1; // Target room (-1 = label only).
67 int entrance = -1; // Entrance or hole ID.
68 int ow_map = -1; // Overworld map of an entrance or hole.
69 int index = -1; // Spawn point, header slot (1-4) or symbol entry (1-n).
70 bool cross_area = false; // Lands in another area.
71 std::string style; // Annotation/symbol kind: pit, warp, dream, ...
72 std::string label; // Pill text for annotation and symbol links.
73 std::string note;
75};
76
78 int k_chest = 0; // Small key chests.
79 int c = 0; // Compass chests.
80 int m = 0; // Map chests.
81 int bk_chest = 0; // Big key chests.
82 int big_chest = 0; // Big chests (any item).
83 int other = 0; // Other small chests.
84 int k_pot = 0; // Small keys under pots.
85 int k_drop = 0; // Small keys dropped by enemies.
86 int bk_drop = 0; // Big keys dropped by enemies.
87};
88
90 int room_id = 0;
91 std::string area; // Area key: dungeon code, annotation area, INT, OTHER,
92 // NONE.
94 std::string owner; // Census owner ID, empty = none.
95 std::string owner_name;
98 bool reached = false;
99 bool empty = false;
100 bool interior = false;
101 int objects = 0;
102 int sprites = 0;
103 float vanilla_similarity = -1.0f;
104 uint8_t tag1 = 0;
105 uint8_t tag2 = 0;
106 int blockset = 0;
107 std::string name;
109 std::string note; // Annotation rooms.<id>.note
110 std::vector<std::string> reasons; // Census reasons.
111 std::vector<std::string> plans; // Plan keys.
112 std::vector<AtlasDoor> doors; // Outer-wall doors.
113 std::vector<AtlasLink> links_out; // Pills drawn in this room.
114 std::vector<AtlasLink> links_in; // Entrances, holes, spawns, symbol
115 // links landing here.
117 bool pit_damage = false; // Listed in RoomsWithPitDamage.
118};
119
120struct AtlasArea {
121 std::string key;
122 std::string code;
123 std::string name;
125 std::string kind; // dungeon, area, interior, other, none
126 std::string owner; // Census owner ID for dungeon areas.
127 Origin origin; // Where code/name come from.
129 int rooms = 0;
130};
131
132struct AtlasPlan {
133 std::string key;
134 std::string label;
135 std::string name;
136 std::string status;
137 bool has_color = false;
139 std::vector<int> rooms;
140 std::string note;
142};
143
145 std::string area;
146 int k_chest = 0;
147 int k_pot = 0;
148 int k_drop = 0;
149 int bk = 0; // Big key chests + big key drops.
150 int bc = 0; // Big chests.
151 int c = 0;
152 int m = 0;
153};
154
156 std::string name; // File name.
157 std::string sha1;
158 size_t size = 0;
159};
160
162 int free = 0;
163 int reclaimable = 0;
164 int in_use = 0;
165 int orphan = 0;
166 int reserved = 0;
167 int interior = 0;
168};
169
172 std::string title;
176 std::string symbols; // .sym read for symbol links, empty = none.
177 std::vector<std::string> annotation_files;
178 std::vector<DungeonAtlasRoom> rooms; // kAtlasRoomCount entries.
179 std::vector<DoorEdge> edges;
180 std::vector<AtlasArea> areas;
181 std::vector<AtlasPlan> plans;
182 std::vector<AtlasKeyTableRow> key_table;
183 std::vector<std::string> legend_notes;
185 std::vector<std::string> warnings;
186};
187
188// Per-room facts the census does not keep.
190 std::vector<AtlasDoorFact> doors;
191 struct Chest {
192 int item = 0;
193 bool big = false;
194 };
195 std::vector<Chest> chests;
196 std::vector<int> pot_items;
199};
200
201// Values read at a symbol link's label (one entry per symbol_links[] item).
203 bool found = false;
204 std::vector<int> values;
205};
206
209 std::vector<DungeonAtlasRoomExtras> extras; // kAtlasRoomCount entries.
210 std::map<int, std::string> registry_room_names;
211 std::vector<AtlasSymbolRead> symbol_reads; // Parallel to symbol_links.
212 std::string symbols_path;
214};
215
218 const core::HackManifest* manifest = nullptr; // Warp tags.
219 Rom* vanilla_rom = nullptr;
220 // Symbol links to read (from the annotations) and the .sym to read them
221 // from; empty path = no symbol links.
222 std::vector<SymbolLinkAnnotation> symbol_links;
223 std::string symbols_path;
224};
225
226absl::StatusOr<DungeonAtlasInput> CollectDungeonAtlasInput(
227 Rom* rom, const DungeonAtlasCollectOptions& options);
228
230 const AtlasAnnotations& annotations);
231
232// WLA symbol file ("BB:AAAA Label" lines) -> label -> 24-bit SNES address.
233absl::StatusOr<std::map<std::string, uint32_t>> ReadWlaSymbols(
234 const std::string& path);
235
236} // namespace zelda3::atlas
237} // namespace yaze
238
239#endif // YAZE_ZELDA3_ATLAS_DUNGEON_ATLAS_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:49
Loads and queries the hack manifest JSON for yaze-ASM integration.
absl::StatusOr< DungeonAtlasInput > CollectDungeonAtlasInput(Rom *rom, const DungeonAtlasCollectOptions &options)
absl::StatusOr< std::map< std::string, uint32_t > > ReadWlaSymbols(const std::string &path)
const char * RoomStatusName(RoomStatus status)
DungeonAtlas BuildDungeonAtlas(const DungeonAtlasInput &input, const AtlasAnnotations &annotations)
const char * LinkKindName(LinkKind kind)
Project-level registry data loaded from the Oracle planning outputs.
std::vector< SymbolLinkAnnotation > symbol_links
std::map< int, std::string > registry_room_names
std::vector< AtlasSymbolRead > symbol_reads
std::vector< DungeonAtlasRoomExtras > extras
std::vector< std::string > reasons
std::vector< std::string > plans
std::vector< AtlasLink > links_out
std::vector< AtlasLink > links_in
std::vector< AtlasPlan > plans
std::vector< DoorEdge > edges
std::vector< AtlasKeyTableRow > key_table
std::vector< AtlasArea > areas
std::vector< std::string > annotation_files
std::vector< std::string > warnings
std::vector< DungeonAtlasRoom > rooms
std::vector< std::string > legend_notes