yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
draw_routine_registry.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_DUNGEON_DRAW_ROUTINES_DRAW_ROUTINE_REGISTRY_H
2#define YAZE_ZELDA3_DUNGEON_DRAW_ROUTINES_DRAW_ROUTINE_REGISTRY_H
3
4#include <cstdint>
5#include <unordered_map>
6#include <vector>
7
9
10namespace yaze {
11namespace zelda3 {
12
22namespace DrawRoutineIds {
23
24// Rightwards routines (0-4, 16, 20-32)
25constexpr int kRightwards2x2_1to15or32 = 0;
26constexpr int kRightwards2x4_1to15or26 = 1;
27constexpr int kRightwards2x4_1to16 = 2;
29constexpr int kRightwards2x2_1to16 = 4;
30constexpr int kRightwards4x4_1to16 = 16;
31constexpr int kRightwards1x2_1to16_plus2 = 20;
44
45// Diagonal routines (5-6, 17-18)
46constexpr int kDiagonalAcute_1to16 = 5;
47constexpr int kDiagonalGrave_1to16 = 6;
48constexpr int kDiagonalAcute_1to16_BothBG = 17;
49constexpr int kDiagonalGrave_1to16_BothBG = 18;
50
51// Downwards routines (7-15, 43-50, 65-71)
52constexpr int kDownwards2x2_1to15or32 = 7;
53constexpr int kDownwards4x2_1to15or26 = 8;
56constexpr int kDownwards2x2_1to16 = 11;
58constexpr int kDownwardsEdge1x1_1to16 = 13;
61constexpr int kDownwardsFloor4x4_1to16 = 43;
73constexpr int kDownwardsBar2x5_1to16 = 69;
74constexpr int kDownwardsPots2x2_1to16 = 70;
76
77// Vertical rail routine with CORNER+MIDDLE+END pattern (for 0x8A-0x8C)
79
80// Corner routines (19, 35-37, 75-78)
81constexpr int kCorner4x4 = 19;
82constexpr int kCorner4x4_BothBG = 35;
83constexpr int kWeirdCornerBottom_BothBG = 36;
84constexpr int kWeirdCornerTop_BothBG = 37;
85constexpr int kDiagonalCeilingTopLeft = 75;
86constexpr int kDiagonalCeilingBottomLeft = 76;
87constexpr int kDiagonalCeilingTopRight = 77;
88constexpr int kDiagonalCeilingBottomRight = 78;
89
90// Special routines (26, 33-34, 38-39)
91constexpr int kDoorSwitcherer = 26;
92constexpr int kSomariaLine = 33;
93constexpr int kWaterFace = 34;
94constexpr int kNothing = 38;
95constexpr int kChest = 39;
96
97// Additional rightwards (51-55, 72-74)
98constexpr int kRightwards4x2_1to16 = 40;
102constexpr int kRightwardsBar4x3_1to16 = 52;
103constexpr int kRightwardsShelf4x4_1to16 = 53;
107constexpr int kRightwardsPots2x2_1to16 = 73;
109
110// SuperSquare routines (56-64)
111constexpr int k4x4BlocksIn4x4SuperSquare = 56;
112constexpr int k3x3FloorIn4x4SuperSquare = 57;
113constexpr int k4x4FloorIn4x4SuperSquare = 58;
116constexpr int kBigHole4x4_1to16 = 61;
117constexpr int kSpike2x2In4x4SuperSquare = 62;
118constexpr int kTableRock4x4_1to16 = 63;
119constexpr int kWaterOverlay8x8_1to16 = 64;
120
121// Chest platform and moving wall routines (79-82)
122constexpr int kClosedChestPlatform = 79;
123constexpr int kMovingWallWest = 80;
124constexpr int kMovingWallEast = 81;
125constexpr int kOpenChestPlatform = 82;
126
127// Stair routines (83-91)
128constexpr int kInterRoomFatStairsUp = 83;
129constexpr int kInterRoomFatStairsDownA = 84;
130constexpr int kInterRoomFatStairsDownB = 85;
131constexpr int kAutoStairs = 86;
132constexpr int kStraightInterRoomStairs = 87;
133constexpr int kSpiralStairsGoingUpUpper = 88;
135constexpr int kSpiralStairsGoingUpLower = 90;
137
138// Interactive object routines (92-96)
139constexpr int kBigKeyLock = 92;
140constexpr int kBombableFloor = 93;
141constexpr int kEmptyWaterFace = 94;
142constexpr int kSpittingWaterFace = 95;
143constexpr int kDrenchingWaterFace = 96;
144
145// Additional Type 2/3 routines (97-116)
146constexpr int kPrisonCell = 97;
147constexpr int kBed4x5 = 98;
148constexpr int kRightwards3x6 = 99;
149constexpr int kUtility6x3 = 100;
150constexpr int kUtility3x5 = 101;
151constexpr int kVerticalTurtleRockPipe = 102;
152constexpr int kHorizontalTurtleRockPipe = 103;
153constexpr int kLightBeam = 104;
154constexpr int kBigLightBeam = 105;
155constexpr int kBossShell4x4 = 106;
156constexpr int kSolidWallDecor3x4 = 107;
157constexpr int kArcheryGameTargetDoor = 108;
158constexpr int kGanonTriforceFloorDecor = 109;
159constexpr int kSingle2x2 = 110;
160constexpr int kWaterfall47 = 111;
161constexpr int kWaterfall48 = 112;
162constexpr int kSingle4x4 = 113;
163constexpr int kSingle4x3 = 114;
164constexpr int kRupeeFloor = 115;
165constexpr int kActual4x4 = 116;
166
167// Custom object routines (130+)
168constexpr int kCustomObject = 130;
169
170} // namespace DrawRoutineIds
171
180 public:
181 static DrawRoutineRegistry& Get();
182
183 // Initialize the registry - must be called once at startup
184 void Initialize();
185
186 // Rebuild object->routine mapping after runtime feature-flag changes.
188
189 // Look up routine info by ID
190 const DrawRoutineInfo* GetRoutineInfo(int routine_id) const;
191
192 // Get all registered routines
193 const std::vector<DrawRoutineInfo>& GetAllRoutines() const {
194 return routines_;
195 }
196
197 // Check if a routine draws to both BG layers
198 bool RoutineDrawsToBothBGs(int routine_id) const;
199
200 // Get routine metadata for dimension calculation
201 bool GetRoutineDimensions(int routine_id, int* base_width,
202 int* base_height) const;
203
204 // Look up draw routine ID for an object ID. Returns -1 if unmapped.
205 int GetRoutineIdForObject(int16_t object_id) const;
206
207 private:
209 void BuildRegistry();
210 void BuildObjectMapping();
211
212 std::vector<DrawRoutineInfo> routines_;
213 std::unordered_map<int, const DrawRoutineInfo*> routine_map_;
214 std::unordered_map<int16_t, int> object_to_routine_map_;
215 bool initialized_ = false;
216};
217
218} // namespace zelda3
219} // namespace yaze
220
221#endif // YAZE_ZELDA3_DUNGEON_DRAW_ROUTINES_DRAW_ROUTINE_REGISTRY_H
Unified draw routine registry.
const DrawRoutineInfo * GetRoutineInfo(int routine_id) const
const std::vector< DrawRoutineInfo > & GetAllRoutines() const
bool GetRoutineDimensions(int routine_id, int *base_width, int *base_height) const
std::unordered_map< int16_t, int > object_to_routine_map_
bool RoutineDrawsToBothBGs(int routine_id) const
std::unordered_map< int, const DrawRoutineInfo * > routine_map_
int GetRoutineIdForObject(int16_t object_id) const
std::vector< DrawRoutineInfo > routines_
static DrawRoutineRegistry & Get()
constexpr int kDownwardsLeftCorners2x1_1to16_plus12
constexpr int kRightwardsBottomCorners1x2_1to16_plus13
constexpr int kDownwardsRightCorners2x1_1to16_plus12
constexpr int kRightwardsTopCorners1x2_1to16_plus13
Metadata about a draw routine.