yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
room_object.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_H
2#define YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_H
3
4#include <cstdint>
5#include <string>
6#include <vector>
7
8#include "absl/strings/str_format.h"
10#include "rom/rom.h"
12
13namespace yaze {
14namespace zelda3 {
15
17
18enum Sorting {
19 All = 0,
20 Wall = 1,
25 Floors = 32,
26 SortStairs = 64
27};
28
29enum class ObjectOption {
30 Nothing = 0,
31 Door = 1,
32 Chest = 2,
33 Block = 4,
34 Torch = 8,
35 Bgr = 16,
36 Stairs = 32
37};
38
43
44constexpr int kRoomObjectSubtype1 = 0x8000; // JP = Same
45constexpr int kRoomObjectSubtype2 = 0x83F0; // JP = Same
46constexpr int kRoomObjectSubtype3 = 0x84F0; // JP = Same
47constexpr int kRoomObjectTileAddress = 0x1B52; // JP = Same
48constexpr int kRoomObjectTileAddressFloor = 0x1B5A; // JP = Same
49
51 public:
52 enum LayerType { BG1 = 0, BG2 = 1, BG3 = 2 };
53
54 RoomObject(int16_t id, uint8_t x, uint8_t y, uint8_t size, uint8_t layer = 0)
55 : id_(id),
56 x_(x),
57 y_(y),
58 size_(size),
59 layer_(static_cast<LayerType>(layer)),
60 nx_(x),
61 ny_(y),
62 ox_(x),
63 oy_(y),
64 width_(16),
65 height_(16),
66 rom_(nullptr) {}
67
68 void SetRom(Rom* rom) { rom_ = rom; }
69 Rom* rom() const { return rom_; }
70 auto mutable_rom() { return rom_; }
71
72 // Position setters and getters
73 void set_x(uint8_t x) { x_ = x; }
74 void set_y(uint8_t y) { y_ = y; }
75 void set_size(uint8_t size) { size_ = size; }
76 uint8_t x() const { return x_; }
77 uint8_t y() const { return y_; }
78 uint8_t size() const { return size_; }
79
80 // Ensures tiles_ is populated with a basic set based on ROM tables so we can
81 // preview/draw objects without needing full emulator execution.
82 void EnsureTilesLoaded();
83
84 // Load tiles using the new ObjectParser
85 absl::Status LoadTilesWithParser();
86
87 // Getter for tiles
88 const std::vector<gfx::TileInfo>& tiles() const { return tiles_; }
89 std::vector<gfx::TileInfo>& mutable_tiles() { return tiles_; }
90
91 // Get tile data through Arena system - returns references, not copies
92 absl::StatusOr<std::span<const gfx::TileInfo>> GetTiles() const;
93
94 // Get individual tile by index - uses Arena lookup
95 absl::StatusOr<const gfx::TileInfo*> GetTile(int index) const;
96
97 // Get tile count without loading all tiles
98 int GetTileCount() const;
99
100 // ============================================================================
101 // Object Encoding/Decoding (Phase 1, Task 1.1)
102 // ============================================================================
103
104 // 3-byte object encoding structure
105 struct ObjectBytes {
106 uint8_t b1;
107 uint8_t b2;
108 uint8_t b3;
109 };
110
111 // Decode object from 3-byte ROM format
112 // Type1: xxxxxxss yyyyyyss iiiiiiii (ID 0x00-0xFF)
113 // Type2: 111111xx xxxxyyyy yyiiiiii (ID 0x100-0x1FF)
114 // Type3: xxxxxxii yyyyyyii 11111iii (ID 0xF00-0xFFF)
115 static RoomObject DecodeObjectFromBytes(uint8_t b1, uint8_t b2, uint8_t b3,
116 uint8_t layer);
117
118 // Encode object to 3-byte ROM format
120
121 // Determine object type from bytes (1, 2, or 3)
122 static int DetermineObjectType(uint8_t b1, uint8_t b3);
123
124 // Get layer from LayerType enum
125 uint8_t GetLayerValue() const { return static_cast<uint8_t>(layer_); }
126
127 // ============================================================================
128
129 // NOTE: Legacy ZScream methods removed. Modern rendering uses:
130 // - ObjectParser for loading tiles from ROM
131 // - ObjectDrawer for rendering tiles to BackgroundBuffer
132
133 auto options() const { return options_; }
135
136 bool all_bgs_ = false;
137 bool lit_ = false;
138
139 int16_t id_;
140 uint8_t x_;
141 uint8_t y_;
142 uint8_t size_;
143 uint8_t nx_;
144 uint8_t ny_;
145 uint8_t ox_;
146 uint8_t oy_;
147 uint8_t z_ = 0;
148 uint8_t previous_size_ = 0;
149 // Size nibble bits captured from object encoding (0..3 each) for heuristic
150 // orientation and sizing decisions.
151 uint8_t size_x_bits_ = 0;
152 uint8_t size_y_bits_ = 0;
153
156 int offset_x_ = 0;
157 int offset_y_ = 0;
158
159 std::string name_;
160
161 std::vector<uint8_t> preview_object_data_;
162
163 // Tile data storage - using Arena system for efficient memory management
164 // Instead of copying Tile16 vectors, we store references to Arena-managed
165 // data
166 mutable std::vector<gfx::TileInfo> tiles_; // Individual tiles like ZScream
167 mutable bool tiles_loaded_ = false;
168 mutable int tile_count_ = 0;
169 mutable int tile_data_ptr_ = -1; // Pointer to tile data in ROM
170
173
175};
176
177// NOTE: Legacy Subtype1, Subtype2, Subtype3 classes removed.
178// These were ported from ZScream but are no longer used.
179// Modern code uses: ObjectParser + ObjectDrawer + ObjectRenderer
180
181constexpr static inline const char* Type1RoomObjectNames[] = {
182 "Ceiling ↔",
183 "Wall (top, north) ↔",
184 "Wall (top, south) ↔",
185 "Wall (bottom, north) ↔",
186 "Wall (bottom, south) ↔",
187 "Wall columns (north) ↔",
188 "Wall columns (south) ↔",
189 "Deep wall (north) ↔",
190 "Deep wall (south) ↔",
191 "Diagonal wall A ◤ (top) ↔",
192 "Diagonal wall A ◣ (top) ↔",
193 "Diagonal wall A ◥ (top) ↔",
194 "Diagonal wall A ◢ (top) ↔",
195 "Diagonal wall B ◤ (top) ↔",
196 "Diagonal wall B ◣ (top) ↔",
197 "Diagonal wall B ◥ (top) ↔",
198 "Diagonal wall B ◢ (top) ↔",
199 "Diagonal wall C ◤ (top) ↔",
200 "Diagonal wall C ◣ (top) ↔",
201 "Diagonal wall C ◥ (top) ↔",
202 "Diagonal wall C ◢ (top) ↔",
203 "Diagonal wall A ◤ (bottom) ↔",
204 "Diagonal wall A ◣ (bottom) ↔",
205 "Diagonal wall A ◥ (bottom) ↔",
206 "Diagonal wall A ◢ (bottom) ↔",
207 "Diagonal wall B ◤ (bottom) ↔",
208 "Diagonal wall B ◣ (bottom) ↔",
209 "Diagonal wall B ◥ (bottom) ↔",
210 "Diagonal wall B ◢ (bottom) ↔",
211 "Diagonal wall C ◤ (bottom) ↔",
212 "Diagonal wall C ◣ (bottom) ↔",
213 "Diagonal wall C ◥ (bottom) ↔",
214 "Diagonal wall C ◢ (bottom) ↔",
215 "Platform stairs ↔",
216 "Rail ↔",
217 "Pit edge ┏━┓ A (north) ↔",
218 "Pit edge ┏━┓ B (north) ↔",
219 "Pit edge ┏━┓ C (north) ↔",
220 "Pit edge ┏━┓ D (north) ↔",
221 "Pit edge ┏━┓ E (north) ↔",
222 "Pit edge ┗━┛ (south) ↔",
223 "Pit edge ━━━ (south) ↔",
224 "Pit edge ━━━ (north) ↔",
225 "Pit edge ━━┛ (south) ↔",
226 "Pit edge ┗━━ (south) ↔",
227 "Pit edge ━━┓ (north) ↔",
228 "Pit edge ┏━━ (north) ↔",
229 "Rail wall (north) ↔",
230 "Rail wall (south) ↔",
231 "Nothing",
232 "Nothing",
233 "Carpet ↔",
234 "Carpet trim ↔",
235 "Weird door", // TODO: WEIRD DOOR OBJECT NEEDS INVESTIGATION
236 "Drapes (north) ↔",
237 "Drapes (west, odd) ↔",
238 "Statues ↔",
239 "Columns ↔",
240 "Wall decors (north) ↔",
241 "Wall decors (south) ↔",
242 "Chairs in pairs ↔",
243 "Tall torches ↔",
244 "Supports (north) ↔",
245 "Water edge ┏━┓ (concave) ↔",
246 "Water edge ┗━┛ (concave) ↔",
247 "Water edge ┏━┓ (convex) ↔",
248 "Water edge ┗━┛ (convex) ↔",
249 "Water edge ┏━┛ (concave) ↔",
250 "Water edge ┗━┓ (concave) ↔",
251 "Water edge ┗━┓ (convex) ↔",
252 "Water edge ┏━┛ (convex) ↔",
253 "Unknown", // TODO: NEEDS IN GAME CHECKING
254 "Unknown", // TODO: NEEDS IN GAME CHECKING
255 "Unknown", // TODO: NEEDS IN GAME CHECKING
256 "Unknown", // TODO: NEEDS IN GAME CHECKING
257 "Supports (south) ↔",
258 "Bar ↔",
259 "Shelf A ↔",
260 "Shelf B ↔",
261 "Shelf C ↔",
262 "Somaria path ↔",
263 "Cannon hole A (north) ↔",
264 "Cannon hole A (south) ↔",
265 "Pipe path ↔",
266 "Nothing",
267 "Wall torches (north) ↔",
268 "Wall torches (south) ↔",
269 "Nothing",
270 "Nothing",
271 "Nothing",
272 "Nothing",
273 "Cannon hole B (north) ↔",
274 "Cannon hole B (south) ↔",
275 "Thick rail ↔",
276 "Blocks ↔",
277 "Long rail ↔",
278 "Ceiling ↕",
279 "Wall (top, west) ↕",
280 "Wall (top, east) ↕",
281 "Wall (bottom, west) ↕",
282 "Wall (bottom, east) ↕",
283 "Wall columns (west) ↕",
284 "Wall columns (east) ↕",
285 "Deep wall (west) ↕",
286 "Deep wall (east) ↕",
287 "Rail ↕",
288 "Pit edge (west) ↕",
289 "Pit edge (east) ↕",
290 "Rail wall (west) ↕",
291 "Rail wall (east) ↕",
292 "Nothing",
293 "Nothing",
294 "Carpet ↕",
295 "Carpet trim ↕",
296 "Nothing",
297 "Drapes (west) ↕",
298 "Drapes (east) ↕",
299 "Columns ↕",
300 "Wall decors (west) ↕",
301 "Wall decors (east) ↕",
302 "Supports (west) ↕",
303 "Water edge (west) ↕",
304 "Water edge (east) ↕",
305 "Supports (east) ↕",
306 "Somaria path ↕",
307 "Pipe path ↕",
308 "Nothing",
309 "Wall torches (west) ↕",
310 "Wall torches (east) ↕",
311 "Wall decors tight A (west) ↕",
312 "Wall decors tight A (east) ↕",
313 "Wall decors tight B (west) ↕",
314 "Wall decors tight B (east) ↕",
315 "Cannon hole (west) ↕",
316 "Cannon hole (east) ↕",
317 "Tall torches ↕",
318 "Thick rail ↕",
319 "Blocks ↕",
320 "Long rail ↕",
321 "Jump ledge (west) ↕",
322 "Jump ledge (east) ↕",
323 "Rug trim (west) ↕",
324 "Rug trim (east) ↕",
325 "Bar ↕",
326 "Wall flair (west) ↕",
327 "Wall flair (east) ↕",
328 "Blue pegs ↕",
329 "Orange pegs ↕",
330 "Invisible floor ↕",
331 "Fake pots ↕",
332 "Hammer pegs ↕",
333 "Nothing",
334 "Nothing",
335 "Nothing",
336 "Nothing",
337 "Nothing",
338 "Nothing",
339 "Nothing",
340 "Nothing",
341 "Nothing",
342 "Diagonal ceiling A ◤",
343 "Diagonal ceiling A ◣",
344 "Diagonal ceiling A ◥",
345 "Diagonal ceiling A ◢",
346 "Pit ⇲",
347 "Diagonal layer 2 mask A ◤",
348 "Diagonal layer 2 mask A ◣",
349 "Diagonal layer 2 mask A ◥",
350 "Diagonal layer 2 mask A ◢",
351 "Diagonal layer 2 mask B ◤", // TODO: VERIFY
352 "Diagonal layer 2 mask B ◣", // TODO: VERIFY
353 "Diagonal layer 2 mask B ◥", // TODO: VERIFY
354 "Diagonal layer 2 mask B ◢", // TODO: VERIFY
355 "Nothing",
356 "Nothing",
357 "Nothing",
358 "Jump ledge (north) ↔",
359 "Jump ledge (south) ↔",
360 "Rug ↔",
361 "Rug trim (north) ↔",
362 "Rug trim (south) ↔",
363 "Archery game curtains ↔",
364 "Wall flair (north) ↔",
365 "Wall flair (south) ↔",
366 "Blue pegs ↔",
367 "Orange pegs ↔",
368 "Invisible floor ↔",
369 "Fake pressure plates ↔",
370 "Fake pots ↔",
371 "Hammer pegs ↔",
372 "Nothing",
373 "Nothing",
374 "Ceiling (large) ⇲",
375 "Chest platform (tall) ⇲",
376 "Layer 2 pit mask (large) ⇲",
377 "Layer 2 pit mask (medium) ⇲",
378 "Floor 1 ⇲",
379 "Floor 3 ⇲",
380 "Layer 2 mask (large) ⇲",
381 "Floor 4 ⇲",
382 "Water floor ⇲ ",
383 "Flood water (medium) ⇲ ",
384 "Conveyor floor ⇲ ",
385 "Nothing",
386 "Nothing",
387 "Moving wall (west) ⇲",
388 "Moving wall (east) ⇲",
389 "Nothing",
390 "Nothing",
391 "Icy floor A ⇲",
392 "Icy floor B ⇲",
393 "Moving wall flag", // TODO: WTF IS THIS?
394 "Moving wall flag", // TODO: WTF IS THIS?
395 "Moving wall flag", // TODO: WTF IS THIS?
396 "Moving wall flag", // TODO: WTF IS THIS?
397 "Layer 2 mask (medium) ⇲",
398 "Flood water (large) ⇲",
399 "Layer 2 swim mask ⇲",
400 "Flood water B (large) ⇲",
401 "Floor 2 ⇲",
402 "Chest platform (short) ⇲",
403 "Table / rock ⇲",
404 "Spike blocks ⇲",
405 "Spiked floor ⇲",
406 "Floor 7 ⇲",
407 "Tiled floor ⇲",
408 "Rupee floor ⇲",
409 "Conveyor upwards ⇲",
410 "Conveyor downwards ⇲",
411 "Conveyor leftwards ⇲",
412 "Conveyor rightwards ⇲",
413 "Heavy current water ⇲",
414 "Floor 10 ⇲",
415 "Nothing",
416 "Nothing",
417 "Nothing",
418 "Nothing",
419 "Nothing",
420 "Nothing",
421 "Nothing",
422 "Nothing",
423 "Nothing",
424 "Nothing",
425 "Nothing",
426 "Nothing",
427 "Nothing",
428 "Nothing",
429 "Nothing",
430};
431
432constexpr static inline const char* Type2RoomObjectNames[] = {
433 "Corner (top, concave) ▛",
434 "Corner (top, concave) ▙",
435 "Corner (top, concave) ▜",
436 "Corner (top, concave) ▟",
437 "Corner (top, convex) ▟",
438 "Corner (top, convex) ▜",
439 "Corner (top, convex) ▙",
440 "Corner (top, convex) ▛",
441 "Corner (bottom, concave) ▛",
442 "Corner (bottom, concave) ▙",
443 "Corner (bottom, concave) ▜",
444 "Corner (bottom, concave) ▟",
445 "Corner (bottom, convex) ▟",
446 "Corner (bottom, convex) ▜",
447 "Corner (bottom, convex) ▙",
448 "Corner (bottom, convex) ▛",
449 "Kinked corner north (bottom) ▜",
450 "Kinked corner south (bottom) ▟",
451 "Kinked corner north (bottom) ▛",
452 "Kinked corner south (bottom) ▙",
453 "Kinked corner west (bottom) ▙",
454 "Kinked corner west (bottom) ▛",
455 "Kinked corner east (bottom) ▟",
456 "Kinked corner east (bottom) ▜",
457 "Deep corner (concave) ▛",
458 "Deep corner (concave) ▙",
459 "Deep corner (concave) ▜",
460 "Deep corner (concave) ▟",
461 "Large brazier",
462 "Statue",
463 "Star tile (disabled)",
464 "Star tile (enabled)",
465 "Small torch (lit)",
466 "Barrel",
467 "Unknown", // TODO: NEEDS IN GAME CHECKING
468 "Table",
469 "Fairy statue",
470 "Unknown", // TODO: NEEDS IN GAME CHECKING
471 "Unknown", // TODO: NEEDS IN GAME CHECKING
472 "Chair",
473 "Bed",
474 "Fireplace",
475 "Mario portrait",
476 "Unknown", // TODO: NEEDS IN GAME CHECKING
477 "Unknown", // TODO: NEEDS IN GAME CHECKING
478 "Interroom stairs (up)",
479 "Interroom stairs (down)",
480 "Interroom stairs B (down)",
481 "Intraroom stairs north B", // TODO: VERIFY LAYER HANDLING
482 "Intraroom stairs north (separate layers)",
483 "Intraroom stairs north (merged layers)",
484 "Intraroom stairs north (swim layer)",
485 "Block",
486 "Water ladder (north)",
487 "Water ladder (south)", // TODO: NEEDS IN GAME VERIFICATION
488 "Dam floodgate",
489 "Interroom spiral stairs up (top)",
490 "Interroom spiral stairs down (top)",
491 "Interroom spiral stairs up (bottom)",
492 "Interroom spiral stairs down (bottom)",
493 "Sanctuary wall (north)",
494 "Unknown", // TODO: NEEDS IN GAME CHECKING
495 "Pew",
496 "Magic bat altar",
497};
498
499constexpr static inline const char* Type3RoomObjectNames[] = {
500 "Waterfall face (empty)",
501 "Waterfall face (short)",
502 "Waterfall face (long)",
503 "Somaria path endpoint",
504 "Somaria path intersection ╋",
505 "Somaria path corner ┏",
506 "Somaria path corner ┗",
507 "Somaria path corner ┓",
508 "Somaria path corner ┛",
509 "Somaria path intersection ┳",
510 "Somaria path intersection ┻",
511 "Somaria path intersection ┣",
512 "Somaria path intersection ┫",
513 "Unknown", // TODO: NEEDS IN GAME CHECKING
514 "Somaria path 2-way endpoint",
515 "Somaria path crossover",
516 "Babasu hole (north)",
517 "Babasu hole (south)",
518 "9 blue rupees",
519 "Telepathy tile",
520 "Warp door", // TODO: NEEDS IN GAME VERIFICATION THAT THIS IS USELESS
521 "Kholdstare's shell",
522 "Hammer peg",
523 "Prison cell",
524 "Big key lock",
525 "Chest",
526 "Chest (open)",
527 "Intraroom stairs south", // TODO: VERIFY LAYER HANDLING
528 "Intraroom stairs south (separate layers)",
529 "Intraroom stairs south (merged layers)",
530 "Interroom straight stairs up (north, top)",
531 "Interroom straight stairs down (north, top)",
532 "Interroom straight stairs up (south, top)",
533 "Interroom straight stairs down (south, top)",
534 "Deep corner (convex) ▟",
535 "Deep corner (convex) ▜",
536 "Deep corner (convex) ▙",
537 "Deep corner (convex) ▛",
538 "Interroom straight stairs up (north, bottom)",
539 "Interroom straight stairs down (north, bottom)",
540 "Interroom straight stairs up (south, bottom)",
541 "Interroom straight stairs down (south, bottom)",
542 "Lamp cones",
543 "Unknown", // TODO: NEEDS IN GAME CHECKING
544 "Liftable large block",
545 "Agahnim's altar",
546 "Agahnim's boss room",
547 "Pot",
548 "Unknown", // TODO: NEEDS IN GAME CHECKING
549 "Big chest",
550 "Big chest (open)",
551 "Intraroom stairs south (swim layer)",
552 "Unknown", // TODO: NEEDS IN GAME CHECKING
553 "Unknown", // TODO: NEEDS IN GAME CHECKING
554 "Unknown", // TODO: NEEDS IN GAME CHECKING
555 "Unknown", // TODO: NEEDS IN GAME CHECKING
556 "Unknown", // TODO: NEEDS IN GAME CHECKING
557 "Unknown", // TODO: NEEDS IN GAME CHECKING
558 "Pipe end (south)",
559 "Pipe end (north)",
560 "Pipe end (east)",
561 "Pipe end (west)",
562 "Pipe corner ▛",
563 "Pipe corner ▙",
564 "Pipe corner ▜",
565 "Pipe corner ▟",
566 "Pipe-rock intersection ⯊",
567 "Pipe-rock intersection ⯋",
568 "Pipe-rock intersection ◖",
569 "Pipe-rock intersection ◗",
570 "Pipe crossover",
571 "Bombable floor",
572 "Fake bombable floor",
573 "Unknown", // TODO: NEEDS IN GAME CHECKING
574 "Warp tile",
575 "Tool rack",
576 "Furnace",
577 "Tub (wide)",
578 "Anvil",
579 "Warp tile (disabled)",
580 "Pressure plate",
581 "Unknown", // TODO: NEEDS IN GAME CHECKING
582 "Blue peg",
583 "Orange peg",
584 "Fortune teller room",
585 "Unknown", // TODO: NEEDS IN GAME CHECKING
586 "Bar corner ▛",
587 "Bar corner ▙",
588 "Bar corner ▜",
589 "Bar corner ▟",
590 "Decorative bowl",
591 "Tub (tall)",
592 "Bookcase",
593 "Range",
594 "Suitcase",
595 "Bar bottles",
596 "Arrow game hole (west)",
597 "Arrow game hole (east)",
598 "Vitreous goo gfx",
599 "Fake pressure plate",
600 "Medusa head",
601 "4-way shooter block",
602 "Pit",
603 "Wall crack (north)",
604 "Wall crack (south)",
605 "Wall crack (west)",
606 "Wall crack (east)",
607 "Large decor",
608 "Water grate (north)",
609 "Water grate (south)",
610 "Water grate (west)",
611 "Water grate (east)",
612 "Window sunlight",
613 "Floor sunlight",
614 "Trinexx's shell",
615 "Layer 2 mask (full)",
616 "Boss entrance",
617 "Minigame chest",
618 "Ganon door",
619 "Triforce wall ornament",
620 "Triforce floor tiles",
621 "Freezor hole",
622 "Pile of bones",
623 "Vitreous goo damage",
624 "Arrow tile ↑",
625 "Arrow tile ↓",
626 "Arrow tile →",
627 "Nothing",
628};
629
630// Helper function to get object name from ID
631// Works across all three object subtypes
632inline std::string GetObjectName(int object_id) {
633 if (object_id < 0x100) {
634 // Type 1: Subtype 1 objects (0x00-0xFF)
635 constexpr size_t kType1Count =
636 sizeof(Type1RoomObjectNames) / sizeof(Type1RoomObjectNames[0]);
637 if (object_id >= 0 && object_id < static_cast<int>(kType1Count)) {
638 return Type1RoomObjectNames[object_id];
639 }
640 return absl::StrFormat("Unknown Type1 (0x%02X)", object_id);
641 } else if (object_id >= 0x100 && object_id < 0x200) {
642 // Type 2: Subtype 2 objects (0x100-0x1FF)
643 int idx = object_id - 0x100;
644 constexpr size_t kType2Count =
645 sizeof(Type2RoomObjectNames) / sizeof(Type2RoomObjectNames[0]);
646 if (idx >= 0 && idx < static_cast<int>(kType2Count)) {
647 return Type2RoomObjectNames[idx];
648 }
649 return absl::StrFormat("Unknown Type2 (0x%03X)", object_id);
650 } else if (object_id >= 0xF80) {
651 // Type 3: Special objects (0xF80-0xFFF, decoded from ASM 0x200-0x27F)
652 int idx = object_id - 0xF80;
653 constexpr size_t kType3Count =
654 sizeof(Type3RoomObjectNames) / sizeof(Type3RoomObjectNames[0]);
655 if (idx >= 0 && idx < static_cast<int>(kType3Count)) {
656 return Type3RoomObjectNames[idx];
657 }
658 return absl::StrFormat("Unknown Type3 (0x%03X)", object_id);
659 }
660 return absl::StrFormat("Unknown (0x%03X)", object_id);
661}
662
663// Helper to get object type/subtype from ID
664inline int GetObjectSubtype(int object_id) {
665 if (object_id < 0x100) return 1;
666 if (object_id < 0x200) return 2;
667 if (object_id >= 0xF80) return 3;
668 return 0; // Unknown
669}
670
671} // namespace zelda3
672} // namespace yaze
673
674#endif // YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_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:24
absl::StatusOr< const gfx::TileInfo * > GetTile(int index) const
static RoomObject DecodeObjectFromBytes(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t layer)
std::vector< uint8_t > preview_object_data_
std::vector< gfx::TileInfo > tiles_
void set_size(uint8_t size)
Definition room_object.h:75
std::vector< gfx::TileInfo > & mutable_tiles()
Definition room_object.h:89
ObjectBytes EncodeObjectToBytes() const
const std::vector< gfx::TileInfo > & tiles() const
Definition room_object.h:88
void set_x(uint8_t x)
Definition room_object.h:73
static int DetermineObjectType(uint8_t b1, uint8_t b3)
absl::Status LoadTilesWithParser()
void SetRom(Rom *rom)
Definition room_object.h:68
uint8_t size() const
Definition room_object.h:78
absl::StatusOr< std::span< const gfx::TileInfo > > GetTiles() const
RoomObject(int16_t id, uint8_t x, uint8_t y, uint8_t size, uint8_t layer=0)
Definition room_object.h:54
uint8_t GetLayerValue() const
void set_y(uint8_t y)
Definition room_object.h:74
void set_options(ObjectOption options)
constexpr int kRoomObjectSubtype3
Definition room_object.h:46
ObjectOption operator|(ObjectOption lhs, ObjectOption rhs)
int GetObjectSubtype(int object_id)
ObjectOption operator^(ObjectOption lhs, ObjectOption rhs)
constexpr int kRoomObjectSubtype1
Definition room_object.h:44
constexpr int kRoomObjectSubtype2
Definition room_object.h:45
constexpr int kRoomObjectTileAddress
Definition room_object.h:47
ObjectOption operator~(ObjectOption option)
std::string GetObjectName(int object_id)
ObjectOption operator&(ObjectOption lhs, ObjectOption rhs)
constexpr int kRoomObjectTileAddressFloor
Definition room_object.h:48