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