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"
79 uint8_t
x()
const {
return x_; }
80 uint8_t
y()
const {
return y_; }
91 const std::vector<gfx::TileInfo>&
tiles()
const {
return tiles_; }
95 absl::StatusOr<std::span<const gfx::TileInfo>>
GetTiles()
const;
98 absl::StatusOr<const gfx::TileInfo*>
GetTile(
int index)
const;
169 mutable std::vector<gfx::TileInfo>
tiles_;
188constexpr static inline const char* Type1RoomObjectNames[] = {
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) ↔",
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) ↔",
244 "Drapes (west, odd) ↔",
247 "Wall decors (north) ↔",
248 "Wall decors (south) ↔",
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) ↔",
264 "Supports (south) ↔",
270 "Cannon hole A (north) ↔",
271 "Cannon hole A (south) ↔",
274 "Wall torches (north) ↔",
275 "Wall torches (south) ↔",
280 "Cannon hole B (north) ↔",
281 "Cannon hole B (south) ↔",
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) ↕",
297 "Rail wall (west) ↕",
298 "Rail wall (east) ↕",
307 "Wall decors (west) ↕",
308 "Wall decors (east) ↕",
310 "Water edge (west) ↕",
311 "Water edge (east) ↕",
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) ↕",
328 "Jump ledge (west) ↕",
329 "Jump ledge (east) ↕",
333 "Wall flair (west) ↕",
334 "Wall flair (east) ↕",
349 "Diagonal ceiling A ◤",
350 "Diagonal ceiling A ◣",
351 "Diagonal ceiling A ◥",
352 "Diagonal ceiling A ◢",
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 ◤",
359 "Diagonal layer 2 mask B ◣",
360 "Diagonal layer 2 mask B ◥",
361 "Diagonal layer 2 mask B ◢",
365 "Jump ledge (north) ↔",
366 "Jump ledge (south) ↔",
368 "Rug trim (north) ↔",
369 "Rug trim (south) ↔",
370 "Archery game curtains ↔",
371 "Wall flair (north) ↔",
372 "Wall flair (south) ↔",
376 "Fake pressure plates ↔",
382 "Chest platform (tall) ⇲",
383 "Layer 2 pit mask (large) ⇲",
384 "Layer 2 pit mask (medium) ⇲",
387 "Layer 2 mask (large) ⇲",
390 "Flood water (medium) ⇲ ",
394 "Moving wall (west) ⇲",
395 "Moving wall (east) ⇲",
404 "Layer 2 mask (medium) ⇲",
405 "Flood water (large) ⇲",
406 "Layer 2 swim mask ⇲",
407 "Flood water B (large) ⇲",
409 "Chest platform (short) ⇲",
416 "Conveyor upwards ⇲",
417 "Conveyor downwards ⇲",
418 "Conveyor leftwards ⇲",
419 "Conveyor rightwards ⇲",
420 "Heavy current water ⇲",
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) ▟",
470 "Star tile (disabled)",
471 "Star tile (enabled)",
485 "Interroom stairs (up)",
486 "Interroom stairs (down)",
487 "Interroom stairs B (down)",
488 "Intraroom stairs north B",
489 "Intraroom stairs north (separate layers)",
490 "Intraroom stairs north (merged layers)",
491 "Intraroom stairs north (swim layer)",
493 "Water ladder (north)",
494 "Water ladder (south)",
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)",
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 ┫",
521 "Somaria path 2-way endpoint",
522 "Somaria path crossover",
523 "Babasu hole (north)",
524 "Babasu hole (south)",
527 "Unused / Warp door",
528 "Kholdstare's shell",
534 "Intraroom stairs south",
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)",
551 "Liftable large block",
553 "Agahnim's boss room",
558 "Intraroom stairs south (swim layer)",
559 "Intraroom stairs south (long)",
573 "Pipe-rock intersection ⯊",
574 "Pipe-rock intersection ⯋",
575 "Pipe-rock intersection ◖",
576 "Pipe-rock intersection ◗",
579 "Fake bombable floor",
586 "Warp tile (disabled)",
591 "Fortune teller room",
603 "Arrow game hole (west)",
604 "Arrow game hole (east)",
606 "Fake pressure plate",
608 "4-way shooter block",
610 "Wall crack (north)",
611 "Wall crack (south)",
615 "Water grate (north)",
616 "Water grate (south)",
617 "Water grate (west)",
618 "Water grate (east)",
622 "Layer 2 mask (full)",
626 "Triforce wall ornament",
627 "Triforce floor tiles",
630 "Vitreous goo damage",
640 if (object_id < 0x100) {
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];
647 return absl::StrFormat(
"Unknown Type1 (0x%02X)", object_id);
648 }
else if (object_id >= 0x100 && object_id < 0x200) {
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];
656 return absl::StrFormat(
"Unknown Type2 (0x%03X)", object_id);
657 }
else if (object_id >= 0xF80) {
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];
665 return absl::StrFormat(
"Unknown Type3 (0x%03X)", object_id);
667 return absl::StrFormat(
"Unknown (0x%03X)", object_id);
672 if (object_id < 0x100)
return 1;
673 if (object_id < 0x200)
return 2;
674 if (object_id >= 0xF80)
return 3;
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
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