1#ifndef YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_H
2#define YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_H
8#include "absl/strings/str_format.h"
88 uint8_t
x()
const {
return x_; }
89 uint8_t
y()
const {
return y_; }
100 const std::vector<gfx::TileInfo>&
tiles()
const {
return tiles_; }
104 absl::StatusOr<std::span<const gfx::TileInfo>>
GetTiles()
const;
107 absl::StatusOr<const gfx::TileInfo*>
GetTile(
int index)
const;
214 mutable std::vector<gfx::TileInfo>
tiles_;
251 uint8_t list_index) {
252 if (list_index > 2) {
255 if (list_index == 1) {
266constexpr static inline const char* Type1RoomObjectNames[] = {
268 "Wall (top, north) ↔",
269 "Wall (top, south) ↔",
270 "Wall (bottom, north) ↔",
271 "Wall (bottom, south) ↔",
272 "Wall columns (north) ↔",
273 "Wall columns (south) ↔",
274 "Deep wall (north) ↔",
275 "Deep wall (south) ↔",
276 "Diagonal wall A ◤ (top) ↔",
277 "Diagonal wall A ◣ (top) ↔",
278 "Diagonal wall A ◥ (top) ↔",
279 "Diagonal wall A ◢ (top) ↔",
280 "Diagonal wall B ◤ (top) ↔",
281 "Diagonal wall B ◣ (top) ↔",
282 "Diagonal wall B ◥ (top) ↔",
283 "Diagonal wall B ◢ (top) ↔",
284 "Diagonal wall C ◤ (top) ↔",
285 "Diagonal wall C ◣ (top) ↔",
286 "Diagonal wall C ◥ (top) ↔",
287 "Diagonal wall C ◢ (top) ↔",
288 "Diagonal wall A ◤ (bottom) ↔",
289 "Diagonal wall A ◣ (bottom) ↔",
290 "Diagonal wall A ◥ (bottom) ↔",
291 "Diagonal wall A ◢ (bottom) ↔",
292 "Diagonal wall B ◤ (bottom) ↔",
293 "Diagonal wall B ◣ (bottom) ↔",
294 "Diagonal wall B ◥ (bottom) ↔",
295 "Diagonal wall B ◢ (bottom) ↔",
296 "Diagonal wall C ◤ (bottom) ↔",
297 "Diagonal wall C ◣ (bottom) ↔",
298 "Diagonal wall C ◥ (bottom) ↔",
299 "Diagonal wall C ◢ (bottom) ↔",
302 "Pit edge ┏━┓ A (north) ↔",
303 "Pit edge ┏━┓ B (north) ↔",
304 "Pit edge ┏━┓ C (north) ↔",
305 "Pit edge ┏━┓ D (north) ↔",
306 "Pit edge ┏━┓ E (north) ↔",
307 "Pit edge ┗━┛ (south) ↔",
308 "Pit edge ━━━ (south) ↔",
309 "Pit edge ━━━ (north) ↔",
310 "Pit edge ━━┛ (south) ↔",
311 "Pit edge ┗━━ (south) ↔",
312 "Pit edge ━━┓ (north) ↔",
313 "Pit edge ┏━━ (north) ↔",
314 "Rail wall (north) ↔",
315 "Rail wall (south) ↔",
322 "Drapes (west, odd) ↔",
325 "Wall decors (north) ↔",
326 "Wall decors (south) ↔",
329 "Supports (north) ↔",
330 "Water edge ┏━┓ (concave) ↔",
331 "Water edge ┗━┛ (concave) ↔",
332 "Water edge ┏━┓ (convex) ↔",
333 "Water edge ┗━┛ (convex) ↔",
334 "Water edge ┏━┛ (concave) ↔",
335 "Water edge ┗━┓ (concave) ↔",
336 "Water edge ┗━┓ (convex) ↔",
337 "Water edge ┏━┛ (convex) ↔",
340 "Floor tiles 4x2 A ↔",
341 "Floor tiles 4x2 B ↔",
342 "Supports (south) ↔",
348 "Cannon hole A (north) ↔",
349 "Cannon hole A (south) ↔",
352 "Wall torches (north) ↔",
353 "Wall torches (south) ↔",
358 "Cannon hole B (north) ↔",
359 "Cannon hole B (south) ↔",
364 "Wall (top, west) ↕",
365 "Wall (top, east) ↕",
366 "Wall (bottom, west) ↕",
367 "Wall (bottom, east) ↕",
368 "Wall columns (west) ↕",
369 "Wall columns (east) ↕",
370 "Deep wall (west) ↕",
371 "Deep wall (east) ↕",
375 "Rail wall (west) ↕",
376 "Rail wall (east) ↕",
385 "Wall decors (west) ↕",
386 "Wall decors (east) ↕",
388 "Water edge (west) ↕",
389 "Water edge (east) ↕",
394 "Wall torches (west) ↕",
395 "Wall torches (east) ↕",
396 "Wall decors tight A (west) ↕",
397 "Wall decors tight A (east) ↕",
398 "Wall decors tight B (west) ↕",
399 "Wall decors tight B (east) ↕",
400 "Cannon hole (west) ↕",
401 "Cannon hole (east) ↕",
406 "Jump ledge (west) ↕",
407 "Jump ledge (east) ↕",
411 "Wall flair (west) ↕",
412 "Wall flair (east) ↕",
427 "Diagonal ceiling A ◤",
428 "Diagonal ceiling A ◣",
429 "Diagonal ceiling A ◥",
430 "Diagonal ceiling A ◢",
432 "Diagonal layer 2 mask A ◤",
433 "Diagonal layer 2 mask A ◣",
434 "Diagonal layer 2 mask A ◥",
435 "Diagonal layer 2 mask A ◢",
436 "Diagonal layer 2 mask B ◤",
437 "Diagonal layer 2 mask B ◣",
438 "Diagonal layer 2 mask B ◥",
439 "Diagonal layer 2 mask B ◢",
443 "Jump ledge (north) ↔",
444 "Jump ledge (south) ↔",
446 "Rug trim (north) ↔",
447 "Rug trim (south) ↔",
448 "Archery game curtains ↔",
449 "Wall flair (north) ↔",
450 "Wall flair (south) ↔",
454 "Fake pressure plates ↔",
460 "Chest platform (tall) ⇲",
461 "Layer 2 pit mask (large) ⇲",
462 "Layer 2 pit mask (medium) ⇲",
465 "Layer 2 mask (large) ⇲",
468 "Flood water (medium) ⇲ ",
472 "Moving wall (west) ⇲",
473 "Moving wall (east) ⇲",
478 "Wall moved check A (logic)",
479 "Wall moved check B (logic)",
480 "Wall moved check C (logic)",
481 "Wall moved check D (logic)",
482 "Layer 2 mask (medium) ⇲",
483 "Flood water (large) ⇲",
484 "Layer 2 swim mask ⇲",
485 "Flood water B (large) ⇲",
487 "Chest platform (short) ⇲",
494 "Conveyor upwards ⇲",
495 "Conveyor downwards ⇲",
496 "Conveyor leftwards ⇲",
497 "Conveyor rightwards ⇲",
498 "Heavy current water ⇲",
517constexpr static inline const char* Type2RoomObjectNames[] = {
518 "Corner (top, concave) ▛",
519 "Corner (top, concave) ▙",
520 "Corner (top, concave) ▜",
521 "Corner (top, concave) ▟",
522 "Corner (top, convex) ▟",
523 "Corner (top, convex) ▜",
524 "Corner (top, convex) ▙",
525 "Corner (top, convex) ▛",
526 "Corner (bottom, concave) ▛",
527 "Corner (bottom, concave) ▙",
528 "Corner (bottom, concave) ▜",
529 "Corner (bottom, concave) ▟",
530 "Corner (bottom, convex) ▟",
531 "Corner (bottom, convex) ▜",
532 "Corner (bottom, convex) ▙",
533 "Corner (bottom, convex) ▛",
534 "Kinked corner north (bottom) ▜",
535 "Kinked corner south (bottom) ▟",
536 "Kinked corner north (bottom) ▛",
537 "Kinked corner south (bottom) ▙",
538 "Kinked corner west (bottom) ▙",
539 "Kinked corner west (bottom) ▛",
540 "Kinked corner east (bottom) ▟",
541 "Kinked corner east (bottom) ▜",
542 "Deep corner (concave) ▛",
543 "Deep corner (concave) ▙",
544 "Deep corner (concave) ▜",
545 "Deep corner (concave) ▟",
548 "Star tile (disabled)",
549 "Star tile (enabled)",
561 "Rightwards 2x2 decor",
562 "Rightwards 6x3 decor",
563 "Interroom stairs (up)",
564 "Interroom stairs (down)",
565 "Interroom stairs B (down)",
566 "Intraroom stairs north B",
567 "Intraroom stairs north (separate layers)",
568 "Intraroom stairs north (merged layers)",
569 "Intraroom stairs north (swim layer)",
571 "Water-hop stairs A",
572 "Water-hop stairs B",
574 "Interroom spiral stairs up (top)",
575 "Interroom spiral stairs down (top)",
576 "Interroom spiral stairs up (bottom)",
577 "Interroom spiral stairs down (bottom)",
578 "Sanctuary wall (north)",
579 "Sanctuary pew (right end)",
584constexpr static inline const char* Type3RoomObjectNames[] = {
585 "Waterfall face (empty)",
586 "Waterfall face (short)",
587 "Waterfall face (long)",
588 "Somaria path endpoint",
589 "Somaria path intersection ╋",
590 "Somaria path corner ┏",
591 "Somaria path corner ┗",
592 "Somaria path corner ┓",
593 "Somaria path corner ┛",
594 "Somaria path intersection ┳",
595 "Somaria path intersection ┻",
596 "Somaria path intersection ┣",
597 "Somaria path intersection ┫",
598 "Prison cell bars (alt)",
599 "Somaria path 2-way endpoint",
600 "Somaria path crossover",
601 "Babasu hole (north)",
602 "Babasu hole (south)",
605 "Unused / Warp door",
606 "Kholdstare's shell",
612 "Intraroom stairs south",
613 "Intraroom stairs south (separate layers)",
614 "Intraroom stairs south (merged layers)",
615 "Interroom straight stairs up (north, top)",
616 "Interroom straight stairs down (north, top)",
617 "Interroom straight stairs up (south, top)",
618 "Interroom straight stairs down (south, top)",
619 "Deep corner (convex) ▟",
620 "Deep corner (convex) ▜",
621 "Deep corner (convex) ▙",
622 "Deep corner (convex) ▛",
623 "Interroom straight stairs up (north, bottom)",
624 "Interroom straight stairs down (north, bottom)",
625 "Interroom straight stairs up (south, bottom)",
626 "Interroom straight stairs down (south, bottom)",
628 "Single 2x2 decor A",
629 "Liftable large block",
631 "Agahnim's boss room",
633 "Single 2x2 decor B",
636 "Intraroom stairs south (swim layer)",
637 "Intraroom stairs south (long)",
651 "Pipe-rock intersection ⯊",
652 "Pipe-rock intersection ⯋",
653 "Pipe-rock intersection ◖",
654 "Pipe-rock intersection ◗",
657 "Fake bombable floor",
658 "Single 2x2 decor C",
664 "Warp tile (disabled)",
666 "Single 2x2 decor D",
669 "Fortune teller room",
681 "Arrow game hole (west)",
682 "Arrow game hole (east)",
684 "Fake pressure plate",
686 "4-way shooter block",
688 "Wall crack (north)",
689 "Wall crack (south)",
693 "Water grate (north)",
694 "Water grate (south)",
695 "Water grate (west)",
696 "Water grate (east)",
700 "Layer 2 mask (full)",
704 "Triforce wall ornament",
705 "Triforce floor tiles",
708 "Vitreous goo damage",
718 if (object_id < 0x100) {
720 constexpr size_t kType1Count =
721 sizeof(Type1RoomObjectNames) /
sizeof(Type1RoomObjectNames[0]);
722 if (object_id >= 0 && object_id <
static_cast<int>(kType1Count)) {
723 return Type1RoomObjectNames[object_id];
725 return absl::StrFormat(
"Unknown Type1 (0x%02X)", object_id);
726 }
else if (object_id >= 0x100 && object_id < 0x200) {
728 int idx = object_id - 0x100;
729 constexpr size_t kType2Count =
730 sizeof(Type2RoomObjectNames) /
sizeof(Type2RoomObjectNames[0]);
731 if (idx >= 0 && idx <
static_cast<int>(kType2Count)) {
732 return Type2RoomObjectNames[idx];
734 return absl::StrFormat(
"Unknown Type2 (0x%03X)", object_id);
735 }
else if (object_id >= 0xF80) {
737 int idx = object_id - 0xF80;
738 constexpr size_t kType3Count =
739 sizeof(Type3RoomObjectNames) /
sizeof(Type3RoomObjectNames[0]);
740 if (idx >= 0 && idx <
static_cast<int>(kType3Count)) {
741 return Type3RoomObjectNames[idx];
743 return absl::StrFormat(
"Unknown Type3 (0x%03X)", object_id);
745 return absl::StrFormat(
"Unknown (0x%03X)", object_id);
750 if (object_id < 0x100)
752 if (object_id < 0x200)
754 if (object_id >= 0xF80)
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
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_
uint8_t torch_reserved_bit_
void set_size(uint8_t size)
std::vector< gfx::TileInfo > & mutable_tiles()
uint8_t block_behavior_layer_
ObjectBytes EncodeObjectToBytes() const
const std::vector< gfx::TileInfo > & tiles() const
void RefreshDerivedFlagsFromId()
static int DetermineObjectType(uint8_t b1, uint8_t b3)
absl::Status LoadTilesWithParser()
void set_block_behavior_layer(uint8_t layer)
int block_load_order() const
static constexpr int kBlockLoadOrderNew
void set_torch_reserved_bit(uint8_t reserved)
absl::StatusOr< std::span< const gfx::TileInfo > > GetTiles() const
uint8_t block_behavior_layer() const
void InvalidateTileCache()
RoomObject(int16_t id, uint8_t x, uint8_t y, uint8_t size, uint8_t layer=0)
uint8_t GetLayerValue() const
void set_block_load_order(int order)
uint8_t torch_reserved_bit() const
RoomObject CopyForNewPlacement() const
void set_options(ObjectOption options)
constexpr int kRoomObjectSubtype3
RoomObject::LayerType MapRoomObjectListIndexToDrawLayer(uint8_t list_index)
ObjectOption operator|(ObjectOption lhs, ObjectOption rhs)
int GetObjectSubtype(int object_id)
ObjectOption operator^(ObjectOption lhs, ObjectOption rhs)
constexpr int kRoomObjectSubtype1
constexpr int kRoomObjectSubtype2
constexpr int kRoomObjectTileAddress
ObjectOption operator~(ObjectOption option)
std::string GetObjectName(int object_id)
ObjectOption operator&(ObjectOption lhs, ObjectOption rhs)
constexpr int kRoomObjectTileAddressFloor