yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
draw_routine_symbology.cc
Go to the documentation of this file.
2
3#include <string>
4
7
8namespace yaze {
9namespace zelda3 {
10namespace {
11
13 switch (category) {
15 return "Rightwards";
17 return "Downwards";
19 return "Diagonal";
21 return "Corner";
23 return "Special";
24 }
25 return "Unknown";
26}
27
29 switch (category) {
31 return '>';
33 return 'v';
35 return '/';
37 return 'L';
39 return 'S';
40 }
41 return '?';
42}
43
44// Object semantics, not geometry: these four are recognisable things rather
45// than a direction of extension, so they earn their own glyph.
47 const char* name;
48 const char* badge;
49 const char* family;
50};
51
53 {"Chest", "C", "Chest"},
54 {"BigKeyLock", "K", "Big key lock"},
55 {"BombableFloor", "B", "Bombable floor"},
56 {"PrisonCell", "P", "Prison cell"},
57};
58
59} // namespace
60
62 DrawRoutineSymbology symbology;
63 if (info == nullptr) {
64 symbology.badge = "?";
65 symbology.family = "Unknown";
66 return symbology;
67 }
68
69 symbology.dual_layer = info->draws_to_both_bgs;
70 symbology.base_width = info->base_width;
71 symbology.base_height = info->base_height;
72
73 bool named = false;
74 for (const auto& entry : kNamedRoutines) {
75 if (info->name == entry.name) {
76 symbology.badge = entry.badge;
77 symbology.family = entry.family;
78 named = true;
79 break;
80 }
81 }
82 if (!named) {
83 symbology.badge = std::string(1, CategoryGlyph(info->category));
84 symbology.family = CategoryFamilyLabel(info->category);
85 }
86
87 // The base pattern size is real registry metadata, so it goes in the label
88 // rather than being folded into the badge. An earlier version overrode the
89 // category with a "large fixed" badge inferred from the routine's name,
90 // which cost Corner4x4 its Corner identity while wrongly claiming
91 // BigHole4x4_1to16 was fixed — that routine repeats.
92 if (!named && symbology.base_width > 0 && symbology.base_height > 0) {
93 symbology.family += " " + std::to_string(symbology.base_width) + "x" +
94 std::to_string(symbology.base_height);
95 }
96
97 if (symbology.dual_layer) {
98 symbology.badge += '2';
99 symbology.family += " (BothBG)";
100 }
101
102 return symbology;
103}
104
106 const int routine_id =
108 if (routine_id < 0) {
109 DrawRoutineSymbology symbology;
110 symbology.badge = "?";
111 symbology.family = "Unmapped";
112 return symbology;
113 }
115 DrawRoutineRegistry::Get().GetRoutineInfo(routine_id));
116}
117
118} // namespace zelda3
119} // namespace yaze
int GetRoutineIdForObject(int16_t object_id) const
static DrawRoutineRegistry & Get()
const char * CategoryFamilyLabel(DrawRoutineInfo::Category category)
DrawRoutineSymbology GetSymbologyForRoutine(const DrawRoutineInfo *info)
DrawRoutineSymbology GetSymbologyForObject(int16_t object_id)
Metadata about a draw routine.
Compact, human-readable identity for an object's draw routine.