1#ifndef YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_H
2#define YAZE_APP_ZELDA3_DUNGEON_ROOM_OBJECT_H
8#include "absl/status/status.h"
9#include "absl/strings/str_format.h"
89 uint8_t
x()
const {
return x_; }
90 uint8_t
y()
const {
return y_; }
101 const std::vector<gfx::TileInfo>&
tiles()
const {
return tiles_; }
105 absl::StatusOr<std::span<const gfx::TileInfo>>
GetTiles()
const;
108 absl::StatusOr<const gfx::TileInfo*>
GetTile(
int index)
const;
215 mutable std::vector<gfx::TileInfo>
tiles_;
254 return object_id == 0xF99 || object_id == 0xFB1;
271 uint8_t list_index) {
272 if (list_index > 2) {
275 if (list_index == 1) {
286constexpr static inline const char* Type1RoomObjectNames[] = {
288 "Wall (top, north) ↔",
289 "Wall (top, south) ↔",
290 "Wall (bottom, north) ↔",
291 "Wall (bottom, south) ↔",
292 "Wall columns (north) ↔",
293 "Wall columns (south) ↔",
294 "Deep wall (north) ↔",
295 "Deep wall (south) ↔",
296 "Diagonal wall A ◤ (top) ↔",
297 "Diagonal wall A ◣ (top) ↔",
298 "Diagonal wall A ◥ (top) ↔",
299 "Diagonal wall A ◢ (top) ↔",
300 "Diagonal wall B ◤ (top) ↔",
301 "Diagonal wall B ◣ (top) ↔",
302 "Diagonal wall B ◥ (top) ↔",
303 "Diagonal wall B ◢ (top) ↔",
304 "Diagonal wall C ◤ (top) ↔",
305 "Diagonal wall C ◣ (top) ↔",
306 "Diagonal wall C ◥ (top) ↔",
307 "Diagonal wall C ◢ (top) ↔",
308 "Diagonal wall A ◤ (bottom) ↔",
309 "Diagonal wall A ◣ (bottom) ↔",
310 "Diagonal wall A ◥ (bottom) ↔",
311 "Diagonal wall A ◢ (bottom) ↔",
312 "Diagonal wall B ◤ (bottom) ↔",
313 "Diagonal wall B ◣ (bottom) ↔",
314 "Diagonal wall B ◥ (bottom) ↔",
315 "Diagonal wall B ◢ (bottom) ↔",
316 "Diagonal wall C ◤ (bottom) ↔",
317 "Diagonal wall C ◣ (bottom) ↔",
318 "Diagonal wall C ◥ (bottom) ↔",
319 "Diagonal wall C ◢ (bottom) ↔",
322 "Pit edge ┏━┓ A (north) ↔",
323 "Pit edge ┏━┓ B (north) ↔",
324 "Pit edge ┏━┓ C (north) ↔",
325 "Pit edge ┏━┓ D (north) ↔",
326 "Pit edge ┏━┓ E (north) ↔",
327 "Pit edge ┗━┛ (south) ↔",
328 "Pit edge ━━━ (south) ↔",
329 "Pit edge ━━━ (north) ↔",
330 "Pit edge ━━┛ (south) ↔",
331 "Pit edge ┗━━ (south) ↔",
332 "Pit edge ━━┓ (north) ↔",
333 "Pit edge ┏━━ (north) ↔",
334 "Rail wall (north) ↔",
335 "Rail wall (south) ↔",
342 "Drapes (west, odd) ↔",
345 "Wall decors (north) ↔",
346 "Wall decors (south) ↔",
349 "Supports (north) ↔",
350 "Water edge ┏━┓ (concave) ↔",
351 "Water edge ┗━┛ (concave) ↔",
352 "Water edge ┏━┓ (convex) ↔",
353 "Water edge ┗━┛ (convex) ↔",
354 "Water edge ┏━┛ (concave) ↔",
355 "Water edge ┗━┓ (concave) ↔",
356 "Water edge ┗━┓ (convex) ↔",
357 "Water edge ┏━┛ (convex) ↔",
360 "Floor tiles 4x2 A ↔",
361 "Floor tiles 4x2 B ↔",
362 "Supports (south) ↔",
368 "Cannon hole A (north) ↔",
369 "Cannon hole A (south) ↔",
372 "Wall torches (north) ↔",
373 "Wall torches (south) ↔",
378 "Cannon hole B (north) ↔",
379 "Cannon hole B (south) ↔",
384 "Wall (top, west) ↕",
385 "Wall (top, east) ↕",
386 "Wall (bottom, west) ↕",
387 "Wall (bottom, east) ↕",
388 "Wall columns (west) ↕",
389 "Wall columns (east) ↕",
390 "Deep wall (west) ↕",
391 "Deep wall (east) ↕",
395 "Rail wall (west) ↕",
396 "Rail wall (east) ↕",
405 "Wall decors (west) ↕",
406 "Wall decors (east) ↕",
408 "Water edge (west) ↕",
409 "Water edge (east) ↕",
414 "Wall torches (west) ↕",
415 "Wall torches (east) ↕",
416 "Wall decors tight A (west) ↕",
417 "Wall decors tight A (east) ↕",
418 "Wall decors tight B (west) ↕",
419 "Wall decors tight B (east) ↕",
420 "Cannon hole (west) ↕",
421 "Cannon hole (east) ↕",
426 "Jump ledge (west) ↕",
427 "Jump ledge (east) ↕",
431 "Wall flair (west) ↕",
432 "Wall flair (east) ↕",
447 "Diagonal ceiling A ◤",
448 "Diagonal ceiling A ◣",
449 "Diagonal ceiling A ◥",
450 "Diagonal ceiling A ◢",
452 "Diagonal layer 2 mask A ◤",
453 "Diagonal layer 2 mask A ◣",
454 "Diagonal layer 2 mask A ◥",
455 "Diagonal layer 2 mask A ◢",
456 "Diagonal layer 2 mask B ◤",
457 "Diagonal layer 2 mask B ◣",
458 "Diagonal layer 2 mask B ◥",
459 "Diagonal layer 2 mask B ◢",
463 "Jump ledge (north) ↔",
464 "Jump ledge (south) ↔",
466 "Rug trim (north) ↔",
467 "Rug trim (south) ↔",
468 "Archery game curtains ↔",
469 "Wall flair (north) ↔",
470 "Wall flair (south) ↔",
474 "Fake pressure plates ↔",
480 "Chest platform (tall) ⇲",
481 "Layer 2 pit mask (large) ⇲",
482 "Layer 2 pit mask (medium) ⇲",
485 "Layer 2 mask (large) ⇲",
488 "Flood water (medium) ⇲ ",
492 "Moving wall (west) ⇲",
493 "Moving wall (east) ⇲",
498 "Wall moved check A (logic)",
499 "Wall moved check B (logic)",
500 "Wall moved check C (logic)",
501 "Wall moved check D (logic)",
502 "Layer 2 mask (medium) ⇲",
503 "Flood water (large) ⇲",
504 "Layer 2 swim mask ⇲",
505 "Flood water B (large) ⇲",
507 "Chest platform (short) ⇲",
514 "Conveyor upwards ⇲",
515 "Conveyor downwards ⇲",
516 "Conveyor leftwards ⇲",
517 "Conveyor rightwards ⇲",
518 "Heavy current water ⇲",
537constexpr static inline const char* Type2RoomObjectNames[] = {
538 "Corner (top, concave) ▛",
539 "Corner (top, concave) ▙",
540 "Corner (top, concave) ▜",
541 "Corner (top, concave) ▟",
542 "Corner (top, convex) ▟",
543 "Corner (top, convex) ▜",
544 "Corner (top, convex) ▙",
545 "Corner (top, convex) ▛",
546 "Corner (bottom, concave) ▛",
547 "Corner (bottom, concave) ▙",
548 "Corner (bottom, concave) ▜",
549 "Corner (bottom, concave) ▟",
550 "Corner (bottom, convex) ▟",
551 "Corner (bottom, convex) ▜",
552 "Corner (bottom, convex) ▙",
553 "Corner (bottom, convex) ▛",
554 "Kinked corner north (bottom) ▜",
555 "Kinked corner south (bottom) ▟",
556 "Kinked corner north (bottom) ▛",
557 "Kinked corner south (bottom) ▙",
558 "Kinked corner west (bottom) ▙",
559 "Kinked corner west (bottom) ▛",
560 "Kinked corner east (bottom) ▟",
561 "Kinked corner east (bottom) ▜",
562 "Deep corner (concave) ▛",
563 "Deep corner (concave) ▙",
564 "Deep corner (concave) ▜",
565 "Deep corner (concave) ▟",
568 "Star tile (disabled)",
569 "Star tile (enabled)",
581 "Rightwards 2x2 decor",
582 "Rightwards 6x3 decor",
583 "Interroom stairs (up)",
584 "Interroom stairs (down)",
585 "Interroom stairs B (down)",
586 "Intraroom stairs north B",
587 "Intraroom stairs north (separate layers)",
588 "Intraroom stairs north (merged layers)",
589 "Intraroom stairs north (swim layer)",
591 "Water-hop stairs A",
592 "Water-hop stairs B",
594 "Interroom spiral stairs up (top)",
595 "Interroom spiral stairs down (top)",
596 "Interroom spiral stairs up (bottom)",
597 "Interroom spiral stairs down (bottom)",
598 "Sanctuary wall (north)",
599 "Sanctuary pew (right end)",
604constexpr static inline const char* Type3RoomObjectNames[] = {
605 "Waterfall face (empty)",
606 "Waterfall face (short)",
607 "Waterfall face (long)",
608 "Somaria path endpoint",
609 "Somaria path intersection ╋",
610 "Somaria path corner ┏",
611 "Somaria path corner ┗",
612 "Somaria path corner ┓",
613 "Somaria path corner ┛",
614 "Somaria path intersection ┳",
615 "Somaria path intersection ┻",
616 "Somaria path intersection ┣",
617 "Somaria path intersection ┫",
618 "Prison cell bars (alt)",
619 "Somaria path 2-way endpoint",
620 "Somaria path crossover",
621 "Babasu hole (north)",
622 "Babasu hole (south)",
625 "Unused / Warp door",
626 "Kholdstare's shell",
632 "Intraroom stairs south",
633 "Intraroom stairs south (separate layers)",
634 "Intraroom stairs south (merged layers)",
635 "Interroom straight stairs up (north, top)",
636 "Interroom straight stairs down (north, top)",
637 "Interroom straight stairs up (south, top)",
638 "Interroom straight stairs down (south, top)",
639 "Deep corner (convex) ▟",
640 "Deep corner (convex) ▜",
641 "Deep corner (convex) ▙",
642 "Deep corner (convex) ▛",
643 "Interroom straight stairs up (north, bottom)",
644 "Interroom straight stairs down (north, bottom)",
645 "Interroom straight stairs up (south, bottom)",
646 "Interroom straight stairs down (south, bottom)",
648 "Single 2x2 decor A",
649 "Liftable large block",
651 "Agahnim's boss room",
653 "Single 2x2 decor B",
656 "Intraroom stairs south (swim layer)",
657 "Intraroom stairs south (long)",
671 "Pipe-rock intersection ⯊",
672 "Pipe-rock intersection ⯋",
673 "Pipe-rock intersection ◖",
674 "Pipe-rock intersection ◗",
677 "Fake bombable floor",
678 "Single 2x2 decor C",
684 "Warp tile (disabled)",
686 "Single 2x2 decor D",
689 "Fortune teller room",
701 "Arrow game hole (west)",
702 "Arrow game hole (east)",
704 "Fake pressure plate",
706 "4-way shooter block",
708 "Wall crack (north)",
709 "Wall crack (south)",
713 "Water grate (north)",
714 "Water grate (south)",
715 "Water grate (west)",
716 "Water grate (east)",
720 "Layer 2 mask (full)",
724 "Triforce wall ornament",
725 "Triforce floor tiles",
728 "Vitreous goo damage",
738 if (object_id < 0x100) {
740 constexpr size_t kType1Count =
741 sizeof(Type1RoomObjectNames) /
sizeof(Type1RoomObjectNames[0]);
742 if (object_id >= 0 && object_id <
static_cast<int>(kType1Count)) {
743 return Type1RoomObjectNames[object_id];
745 return absl::StrFormat(
"Unknown Type1 (0x%02X)", object_id);
746 }
else if (object_id >= 0x100 && object_id < 0x200) {
748 int idx = object_id - 0x100;
749 constexpr size_t kType2Count =
750 sizeof(Type2RoomObjectNames) /
sizeof(Type2RoomObjectNames[0]);
751 if (idx >= 0 && idx <
static_cast<int>(kType2Count)) {
752 return Type2RoomObjectNames[idx];
754 return absl::StrFormat(
"Unknown Type2 (0x%03X)", object_id);
755 }
else if (object_id >= 0xF80) {
757 int idx = object_id - 0xF80;
758 constexpr size_t kType3Count =
759 sizeof(Type3RoomObjectNames) /
sizeof(Type3RoomObjectNames[0]);
760 if (idx >= 0 && idx <
static_cast<int>(kType3Count)) {
761 return Type3RoomObjectNames[idx];
763 return absl::StrFormat(
"Unknown Type3 (0x%03X)", object_id);
765 return absl::StrFormat(
"Unknown (0x%03X)", object_id);
770 if (object_id < 0x100)
772 if (object_id < 0x200)
774 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)
uint8_t DefaultRoomObjectSizeForPlacement(int object_id)
bool IsRoomObjectSizeEditable(int object_id)
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)
uint8_t CanonicalRoomObjectSize(int object_id, uint8_t requested_size)
constexpr int kRoomObjectSubtype1
constexpr int kRoomObjectSubtype2
constexpr int kRoomObjectTileAddress
ObjectOption operator~(ObjectOption option)
std::string GetObjectName(int object_id)
constexpr bool IsStatefulChestObjectId(int object_id)
ObjectOption operator&(ObjectOption lhs, ObjectOption rhs)
absl::Status ValidateRoomObjectStreamEntryForSave(const RoomObject &object)
constexpr int kRoomObjectTileAddressFloor