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 kDownwardsBar2x3_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)
99constexpr int kRightwardsBar4x3_1to16 = 52;
100constexpr int kRightwardsShelf4x4_1to16 = 53;
104constexpr int kRightwardsPots2x2_1to16 = 73;
106
107// SuperSquare routines (56-64)
108constexpr int k4x4BlocksIn4x4SuperSquare = 56;
109constexpr int k3x3FloorIn4x4SuperSquare = 57;
110constexpr int k4x4FloorIn4x4SuperSquare = 58;
113constexpr int kBigHole4x4_1to16 = 61;
114constexpr int kSpike2x2In4x4SuperSquare = 62;
115constexpr int kTableRock4x4_1to16 = 63;
116constexpr int kWaterOverlay8x8_1to16 = 64;
117
118// Chest platform and moving wall routines (79-82)
119constexpr int kClosedChestPlatform = 79;
120constexpr int kMovingWallWest = 80;
121constexpr int kMovingWallEast = 81;
122constexpr int kOpenChestPlatform = 82;
123
124// Stair routines (83-91)
125constexpr int kInterRoomFatStairsUp = 83;
126constexpr int kInterRoomFatStairsDownA = 84;
127constexpr int kInterRoomFatStairsDownB = 85;
128constexpr int kAutoStairs = 86;
129constexpr int kStraightInterRoomStairs = 87;
130constexpr int kSpiralStairsGoingUpUpper = 88;
132constexpr int kSpiralStairsGoingUpLower = 90;
134
135// Interactive object routines (92-96)
136constexpr int kBigKeyLock = 92;
137constexpr int kBombableFloor = 93;
138constexpr int kEmptyWaterFace = 94;
139constexpr int kSpittingWaterFace = 95;
140constexpr int kDrenchingWaterFace = 96;
141
142// Additional Type 2/3 routines (97-115)
143constexpr int kWaterfall = 97;
144constexpr int kFloorTile4x2 = 98;
145constexpr int kCannonHole4x3 = 99;
146constexpr int kBed4x5 = 100;
147constexpr int kRightwards3x6 = 101;
148constexpr int kVerticalTurtleRockPipe = 102;
149constexpr int kHorizontalTurtleRockPipe = 103;
150constexpr int kLightBeam = 104;
151constexpr int kBigLightBeam = 105;
152constexpr int kBossShell4x4 = 106;
153constexpr int kSolidWallDecor3x4 = 107;
154constexpr int kArcheryGameTargetDoor = 108;
155constexpr int kGanonTriforceFloorDecor = 109;
156constexpr int kLargeCanvasObject = 110;
157constexpr int kUtility6x3 = 111;
158constexpr int kUtility3x5 = 112;
159constexpr int kSingle4x4 = 113;
160constexpr int kSingle4x3 = 114;
161constexpr int kRupeeFloor = 115;
162
163// Custom object routines (130+)
164constexpr int kCustomObject = 130;
165
166} // namespace DrawRoutineIds
167
176 public:
177 static DrawRoutineRegistry& Get();
178
179 // Initialize the registry - must be called once at startup
180 void Initialize();
181
182 // Rebuild object->routine mapping after runtime feature-flag changes.
184
185 // Look up routine info by ID
186 const DrawRoutineInfo* GetRoutineInfo(int routine_id) const;
187
188 // Get all registered routines
189 const std::vector<DrawRoutineInfo>& GetAllRoutines() const { return routines_; }
190
191 // Check if a routine draws to both BG layers
192 bool RoutineDrawsToBothBGs(int routine_id) const;
193
194 // Get routine metadata for dimension calculation
195 bool GetRoutineDimensions(int routine_id, int* base_width, int* base_height) const;
196
197 // Look up draw routine ID for an object ID. Returns -1 if unmapped.
198 int GetRoutineIdForObject(int16_t object_id) const;
199
200 private:
202 void BuildRegistry();
203 void BuildObjectMapping();
204
205 std::vector<DrawRoutineInfo> routines_;
206 std::unordered_map<int, const DrawRoutineInfo*> routine_map_;
207 std::unordered_map<int16_t, int> object_to_routine_map_;
208 bool initialized_ = false;
209};
210
211} // namespace zelda3
212} // namespace yaze
213
214#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.