yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
object_layer_semantics.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_DUNGEON_OBJECT_LAYER_SEMANTICS_H_
2#define YAZE_ZELDA3_DUNGEON_OBJECT_LAYER_SEMANTICS_H_
3
4#include <cstdint>
5
6#include "core/features.h"
11
12namespace yaze {
13namespace zelda3 {
14
15enum class EffectiveBgLayer {
16 kBg1,
17 kBg2,
19};
20
22 int routine_id = -1;
24 // Compatibility field for the legacy all_bgs_/routine-metadata decision.
25 // Object-ID-specific routing (for example auto and straight stairs) is
26 // represented by render_routing instead.
27 bool draws_to_both_bgs = false;
30};
31
32inline bool UsesRoomObjectStream(const RoomObject& object) {
33 const auto options = object.options();
34 return (options & ObjectOption::Torch) == ObjectOption::Nothing &&
36}
37
38inline bool UsesSpecialLayerSelector(const RoomObject& object) {
39 return !UsesRoomObjectStream(object);
40}
41
42inline bool HasActiveCustomObjectOverride(const RoomObject& object) {
43 if (!core::FeatureFlags::get().kEnableCustomObjects) {
44 return false;
45 }
46
47 const int subtype = object.size_ & 0x1F;
48 return CustomObjectManager::Get().GetObjectInternal(object.id_, subtype).ok();
49}
50
51// Reports built-in routine routing. A project custom-object override can
52// preempt the built-in routine and use stored placement instead.
55
57 const bool routine_both =
58 (out.routine_id >= 0) &&
60 out.draws_to_both_bgs = object.all_bgs_ || routine_both;
61
62 if (out.draws_to_both_bgs) {
65 return out;
66 }
67
72 return out;
73 }
74
79 return out;
80 }
81
86 return out;
87 }
88
91 return out;
92 }
93
95 // The facade is fixed BG1; only its four-column center uses the stream.
96 const bool mixed = object.layer_ == RoomObject::LayerType::BG2;
101 return out;
102 }
103
104 out.effective_bg_layer = (object.layer_ == RoomObject::LayerType::BG2)
107 return out;
108}
109
110// Reports the route actually used by ObjectDrawer after custom overrides have
111// had their chance to preempt the built-in routine.
113 const RoomObject& object) {
114 if (!HasActiveCustomObjectOverride(object)) {
115 return GetObjectLayerSemantics(object);
116 }
117
119 out.custom_override_active = true;
120 out.draws_to_both_bgs = object.all_bgs_;
121 if (object.all_bgs_) {
124 } else {
129 }
130 return out;
131}
132
133inline const char* EffectiveBgLayerLabel(EffectiveBgLayer layer) {
134 switch (layer) {
136 return "BG1";
138 return "BG2";
140 return "Both BGs";
141 }
142 return "Unknown";
143}
144
146 switch (routing) {
148 return "Stored placement";
150 return "BG1 (fixed)";
152 return "BG2 (fixed)";
154 return "Both BGs (full)";
156 return "Mixed BG1/BG2";
157 }
158 return "Unknown";
159}
160
162 const ObjectLayerSemantics& semantics) {
165 }
167 ? "BG2 (stored placement)"
168 : "BG1 (stored placement)";
169}
170
172 switch (routing) {
174 return "stored";
176 return "fixed_bg1";
178 return "fixed_bg2";
180 return "full_both";
182 return "mixed";
183 }
184 return "unknown";
185}
186
187} // namespace zelda3
188} // namespace yaze
189
190#endif // YAZE_ZELDA3_DUNGEON_OBJECT_LAYER_SEMANTICS_H_
static Flags & get()
Definition features.h:119
static CustomObjectManager & Get()
absl::StatusOr< std::shared_ptr< CustomObject > > GetObjectInternal(int object_id, int subtype)
bool RoutineDrawsToBothBGs(int routine_id) const
int GetRoutineIdForObject(int16_t object_id) const
static DrawRoutineRegistry & Get()
constexpr bool IsFullBothAutoStairsObject(int object_id)
constexpr bool IsMixedStraightInterroomObject(int object_id)
ObjectLayerSemantics GetObjectLayerSemantics(const RoomObject &object)
const char * ObjectRenderRoutingLabel(ObjectRenderRouting routing)
const char * ObjectRenderRoutingToken(ObjectRenderRouting routing)
ObjectLayerSemantics GetEffectiveObjectLayerSemantics(const RoomObject &object)
const char * ObjectRenderRoutingDisplayLabel(const ObjectLayerSemantics &semantics)
bool UsesRoomObjectStream(const RoomObject &object)
bool UsesSpecialLayerSelector(const RoomObject &object)
bool HasActiveCustomObjectOverride(const RoomObject &object)
const char * EffectiveBgLayerLabel(EffectiveBgLayer layer)