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;
178 mutable std::vector<gfx::TileInfo>
tiles_;
205 uint8_t list_index) {
206 if (list_index > 2) {
209 if (list_index == 1) {
220constexpr static inline const char* Type1RoomObjectNames[] = {
222 "Wall (top, north) ↔",
223 "Wall (top, south) ↔",
224 "Wall (bottom, north) ↔",
225 "Wall (bottom, south) ↔",
226 "Wall columns (north) ↔",
227 "Wall columns (south) ↔",
228 "Deep wall (north) ↔",
229 "Deep wall (south) ↔",
230 "Diagonal wall A ◤ (top) ↔",
231 "Diagonal wall A ◣ (top) ↔",
232 "Diagonal wall A ◥ (top) ↔",
233 "Diagonal wall A ◢ (top) ↔",
234 "Diagonal wall B ◤ (top) ↔",
235 "Diagonal wall B ◣ (top) ↔",
236 "Diagonal wall B ◥ (top) ↔",
237 "Diagonal wall B ◢ (top) ↔",
238 "Diagonal wall C ◤ (top) ↔",
239 "Diagonal wall C ◣ (top) ↔",
240 "Diagonal wall C ◥ (top) ↔",
241 "Diagonal wall C ◢ (top) ↔",
242 "Diagonal wall A ◤ (bottom) ↔",
243 "Diagonal wall A ◣ (bottom) ↔",
244 "Diagonal wall A ◥ (bottom) ↔",
245 "Diagonal wall A ◢ (bottom) ↔",
246 "Diagonal wall B ◤ (bottom) ↔",
247 "Diagonal wall B ◣ (bottom) ↔",
248 "Diagonal wall B ◥ (bottom) ↔",
249 "Diagonal wall B ◢ (bottom) ↔",
250 "Diagonal wall C ◤ (bottom) ↔",
251 "Diagonal wall C ◣ (bottom) ↔",
252 "Diagonal wall C ◥ (bottom) ↔",
253 "Diagonal wall C ◢ (bottom) ↔",
256 "Pit edge ┏━┓ A (north) ↔",
257 "Pit edge ┏━┓ B (north) ↔",
258 "Pit edge ┏━┓ C (north) ↔",
259 "Pit edge ┏━┓ D (north) ↔",
260 "Pit edge ┏━┓ E (north) ↔",
261 "Pit edge ┗━┛ (south) ↔",
262 "Pit edge ━━━ (south) ↔",
263 "Pit edge ━━━ (north) ↔",
264 "Pit edge ━━┛ (south) ↔",
265 "Pit edge ┗━━ (south) ↔",
266 "Pit edge ━━┓ (north) ↔",
267 "Pit edge ┏━━ (north) ↔",
268 "Rail wall (north) ↔",
269 "Rail wall (south) ↔",
276 "Drapes (west, odd) ↔",
279 "Wall decors (north) ↔",
280 "Wall decors (south) ↔",
283 "Supports (north) ↔",
284 "Water edge ┏━┓ (concave) ↔",
285 "Water edge ┗━┛ (concave) ↔",
286 "Water edge ┏━┓ (convex) ↔",
287 "Water edge ┗━┛ (convex) ↔",
288 "Water edge ┏━┛ (concave) ↔",
289 "Water edge ┗━┓ (concave) ↔",
290 "Water edge ┗━┓ (convex) ↔",
291 "Water edge ┏━┛ (convex) ↔",
296 "Supports (south) ↔",
302 "Cannon hole A (north) ↔",
303 "Cannon hole A (south) ↔",
306 "Wall torches (north) ↔",
307 "Wall torches (south) ↔",
312 "Cannon hole B (north) ↔",
313 "Cannon hole B (south) ↔",
318 "Wall (top, west) ↕",
319 "Wall (top, east) ↕",
320 "Wall (bottom, west) ↕",
321 "Wall (bottom, east) ↕",
322 "Wall columns (west) ↕",
323 "Wall columns (east) ↕",
324 "Deep wall (west) ↕",
325 "Deep wall (east) ↕",
329 "Rail wall (west) ↕",
330 "Rail wall (east) ↕",
339 "Wall decors (west) ↕",
340 "Wall decors (east) ↕",
342 "Water edge (west) ↕",
343 "Water edge (east) ↕",
348 "Wall torches (west) ↕",
349 "Wall torches (east) ↕",
350 "Wall decors tight A (west) ↕",
351 "Wall decors tight A (east) ↕",
352 "Wall decors tight B (west) ↕",
353 "Wall decors tight B (east) ↕",
354 "Cannon hole (west) ↕",
355 "Cannon hole (east) ↕",
360 "Jump ledge (west) ↕",
361 "Jump ledge (east) ↕",
365 "Wall flair (west) ↕",
366 "Wall flair (east) ↕",
381 "Diagonal ceiling A ◤",
382 "Diagonal ceiling A ◣",
383 "Diagonal ceiling A ◥",
384 "Diagonal ceiling A ◢",
386 "Diagonal layer 2 mask A ◤",
387 "Diagonal layer 2 mask A ◣",
388 "Diagonal layer 2 mask A ◥",
389 "Diagonal layer 2 mask A ◢",
390 "Diagonal layer 2 mask B ◤",
391 "Diagonal layer 2 mask B ◣",
392 "Diagonal layer 2 mask B ◥",
393 "Diagonal layer 2 mask B ◢",
397 "Jump ledge (north) ↔",
398 "Jump ledge (south) ↔",
400 "Rug trim (north) ↔",
401 "Rug trim (south) ↔",
402 "Archery game curtains ↔",
403 "Wall flair (north) ↔",
404 "Wall flair (south) ↔",
408 "Fake pressure plates ↔",
414 "Chest platform (tall) ⇲",
415 "Layer 2 pit mask (large) ⇲",
416 "Layer 2 pit mask (medium) ⇲",
419 "Layer 2 mask (large) ⇲",
422 "Flood water (medium) ⇲ ",
426 "Moving wall (west) ⇲",
427 "Moving wall (east) ⇲",
436 "Layer 2 mask (medium) ⇲",
437 "Flood water (large) ⇲",
438 "Layer 2 swim mask ⇲",
439 "Flood water B (large) ⇲",
441 "Chest platform (short) ⇲",
448 "Conveyor upwards ⇲",
449 "Conveyor downwards ⇲",
450 "Conveyor leftwards ⇲",
451 "Conveyor rightwards ⇲",
452 "Heavy current water ⇲",
471constexpr static inline const char* Type2RoomObjectNames[] = {
472 "Corner (top, concave) ▛",
473 "Corner (top, concave) ▙",
474 "Corner (top, concave) ▜",
475 "Corner (top, concave) ▟",
476 "Corner (top, convex) ▟",
477 "Corner (top, convex) ▜",
478 "Corner (top, convex) ▙",
479 "Corner (top, convex) ▛",
480 "Corner (bottom, concave) ▛",
481 "Corner (bottom, concave) ▙",
482 "Corner (bottom, concave) ▜",
483 "Corner (bottom, concave) ▟",
484 "Corner (bottom, convex) ▟",
485 "Corner (bottom, convex) ▜",
486 "Corner (bottom, convex) ▙",
487 "Corner (bottom, convex) ▛",
488 "Kinked corner north (bottom) ▜",
489 "Kinked corner south (bottom) ▟",
490 "Kinked corner north (bottom) ▛",
491 "Kinked corner south (bottom) ▙",
492 "Kinked corner west (bottom) ▙",
493 "Kinked corner west (bottom) ▛",
494 "Kinked corner east (bottom) ▟",
495 "Kinked corner east (bottom) ▜",
496 "Deep corner (concave) ▛",
497 "Deep corner (concave) ▙",
498 "Deep corner (concave) ▜",
499 "Deep corner (concave) ▟",
502 "Star tile (disabled)",
503 "Star tile (enabled)",
517 "Interroom stairs (up)",
518 "Interroom stairs (down)",
519 "Interroom stairs B (down)",
520 "Intraroom stairs north B",
521 "Intraroom stairs north (separate layers)",
522 "Intraroom stairs north (merged layers)",
523 "Intraroom stairs north (swim layer)",
525 "Water ladder (north)",
526 "Water ladder (south)",
528 "Interroom spiral stairs up (top)",
529 "Interroom spiral stairs down (top)",
530 "Interroom spiral stairs up (bottom)",
531 "Interroom spiral stairs down (bottom)",
532 "Sanctuary wall (north)",
533 "Sanctuary pew (right end)",
538constexpr static inline const char* Type3RoomObjectNames[] = {
539 "Waterfall face (empty)",
540 "Waterfall face (short)",
541 "Waterfall face (long)",
542 "Somaria path endpoint",
543 "Somaria path intersection ╋",
544 "Somaria path corner ┏",
545 "Somaria path corner ┗",
546 "Somaria path corner ┓",
547 "Somaria path corner ┛",
548 "Somaria path intersection ┳",
549 "Somaria path intersection ┻",
550 "Somaria path intersection ┣",
551 "Somaria path intersection ┫",
553 "Somaria path 2-way endpoint",
554 "Somaria path crossover",
555 "Babasu hole (north)",
556 "Babasu hole (south)",
559 "Unused / Warp door",
560 "Kholdstare's shell",
566 "Intraroom stairs south",
567 "Intraroom stairs south (separate layers)",
568 "Intraroom stairs south (merged layers)",
569 "Interroom straight stairs up (north, top)",
570 "Interroom straight stairs down (north, top)",
571 "Interroom straight stairs up (south, top)",
572 "Interroom straight stairs down (south, top)",
573 "Deep corner (convex) ▟",
574 "Deep corner (convex) ▜",
575 "Deep corner (convex) ▙",
576 "Deep corner (convex) ▛",
577 "Interroom straight stairs up (north, bottom)",
578 "Interroom straight stairs down (north, bottom)",
579 "Interroom straight stairs up (south, bottom)",
580 "Interroom straight stairs down (south, bottom)",
583 "Liftable large block",
585 "Agahnim's boss room",
590 "Intraroom stairs south (swim layer)",
591 "Intraroom stairs south (long)",
605 "Pipe-rock intersection ⯊",
606 "Pipe-rock intersection ⯋",
607 "Pipe-rock intersection ◖",
608 "Pipe-rock intersection ◗",
611 "Fake bombable floor",
618 "Warp tile (disabled)",
623 "Fortune teller room",
635 "Arrow game hole (west)",
636 "Arrow game hole (east)",
638 "Fake pressure plate",
640 "4-way shooter block",
642 "Wall crack (north)",
643 "Wall crack (south)",
647 "Water grate (north)",
648 "Water grate (south)",
649 "Water grate (west)",
650 "Water grate (east)",
654 "Layer 2 mask (full)",
658 "Triforce wall ornament",
659 "Triforce floor tiles",
662 "Vitreous goo damage",
672 if (object_id < 0x100) {
674 constexpr size_t kType1Count =
675 sizeof(Type1RoomObjectNames) /
sizeof(Type1RoomObjectNames[0]);
676 if (object_id >= 0 && object_id <
static_cast<int>(kType1Count)) {
677 return Type1RoomObjectNames[object_id];
679 return absl::StrFormat(
"Unknown Type1 (0x%02X)", object_id);
680 }
else if (object_id >= 0x100 && object_id < 0x200) {
682 int idx = object_id - 0x100;
683 constexpr size_t kType2Count =
684 sizeof(Type2RoomObjectNames) /
sizeof(Type2RoomObjectNames[0]);
685 if (idx >= 0 && idx <
static_cast<int>(kType2Count)) {
686 return Type2RoomObjectNames[idx];
688 return absl::StrFormat(
"Unknown Type2 (0x%03X)", object_id);
689 }
else if (object_id >= 0xF80) {
691 int idx = object_id - 0xF80;
692 constexpr size_t kType3Count =
693 sizeof(Type3RoomObjectNames) /
sizeof(Type3RoomObjectNames[0]);
694 if (idx >= 0 && idx <
static_cast<int>(kType3Count)) {
695 return Type3RoomObjectNames[idx];
697 return absl::StrFormat(
"Unknown Type3 (0x%03X)", object_id);
699 return absl::StrFormat(
"Unknown (0x%03X)", object_id);
704 if (object_id < 0x100)
706 if (object_id < 0x200)
708 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_
void set_size(uint8_t size)
std::vector< gfx::TileInfo > & mutable_tiles()
ObjectBytes EncodeObjectToBytes() const
const std::vector< gfx::TileInfo > & tiles() const
void RefreshDerivedFlagsFromId()
static int DetermineObjectType(uint8_t b1, uint8_t b3)
absl::Status LoadTilesWithParser()
absl::StatusOr< std::span< const gfx::TileInfo > > GetTiles() 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_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