From b40699e81d84fe360c1fa7a6cf0ea5f515883372 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 10 Nov 2024 21:40:06 -0500 Subject: [PATCH] Refactor dungeon room structures and rename classes for consistency --- src/app/zelda3/dungeon/room.cc | 27 +++++++++--------- src/app/zelda3/dungeon/room.h | 51 +++++----------------------------- src/incl/dungeon.h | 41 ++++++++++++++++++++------- 3 files changed, 51 insertions(+), 68 deletions(-) diff --git a/src/app/zelda3/dungeon/room.cc b/src/app/zelda3/dungeon/room.cc index 44ae129a..aa5fd1c2 100644 --- a/src/app/zelda3/dungeon/room.cc +++ b/src/app/zelda3/dungeon/room.cc @@ -164,23 +164,23 @@ void Room::LoadRoomFromROM() { b = rom_data[hpos]; - pits_.TargetLayer = (uchar)(b & 0x03); - stair1_.TargetLayer = (uchar)((b >> 2) & 0x03); - stair2_.TargetLayer = (uchar)((b >> 4) & 0x03); - stair3_.TargetLayer = (uchar)((b >> 6) & 0x03); + pits_.target_layer = (uchar)(b & 0x03); + stair1_.target_layer = (uchar)((b >> 2) & 0x03); + stair2_.target_layer = (uchar)((b >> 4) & 0x03); + stair3_.target_layer = (uchar)((b >> 6) & 0x03); hpos++; - stair4_.TargetLayer = (uchar)(rom_data[hpos] & 0x03); + stair4_.target_layer = (uchar)(rom_data[hpos] & 0x03); hpos++; - pits_.Target = rom_data[hpos]; + pits_.target = rom_data[hpos]; hpos++; - stair1_.Target = rom_data[hpos]; + stair1_.target = rom_data[hpos]; hpos++; - stair2_.Target = rom_data[hpos]; + stair2_.target = rom_data[hpos]; hpos++; - stair3_.Target = rom_data[hpos]; + stair3_.target = rom_data[hpos]; hpos++; - stair4_.Target = rom_data[hpos]; + stair4_.target = rom_data[hpos]; hpos++; // Load room objects @@ -375,7 +375,7 @@ void Room::LoadObjects() { if (nbr_of_staircase < 4) { tile_objects_.back().set_options(ObjectOption::Stairs | tile_objects_.back().options()); - staircase_rooms_vec_.push_back(StaircaseRooms( + staircase_rooms_vec_.push_back(z3_staircase( posX, posY, absl::StrCat("To ", staircase_rooms_[nbr_of_staircase]) .data())); @@ -383,8 +383,7 @@ void Room::LoadObjects() { } else { tile_objects_.back().set_options(ObjectOption::Stairs | tile_objects_.back().options()); - staircase_rooms_vec_.push_back( - StaircaseRooms(posX, posY, "To ???")); + staircase_rooms_vec_.push_back(z3_staircase(posX, posY, "To ???")); } } } @@ -480,7 +479,7 @@ void Room::LoadChests() { } chests_in_room_.emplace_back( - ChestData(rom_data[cpos + (i * 3) + 2], big)); + z3_chest_data(rom_data[cpos + (i * 3) + 2], big)); } } } diff --git a/src/app/zelda3/dungeon/room.h b/src/app/zelda3/dungeon/room.h index 269ed49a..388b3a75 100644 --- a/src/app/zelda3/dungeon/room.h +++ b/src/app/zelda3/dungeon/room.h @@ -86,43 +86,6 @@ constexpr int NumberOfRooms = 296; constexpr ushort stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D}; -class DungeonDestination { - public: - DungeonDestination() = default; - ~DungeonDestination() = default; - DungeonDestination(uint8_t i) : Index(i) {} - - uint8_t Index; - uint8_t Target = 0; - uint8_t TargetLayer = 0; -}; - -struct Chest { - uint8_t x = 0; - uint8_t y = 0; - uint8_t item = 0; - bool picker = false; - bool big_chest = false; -}; - -struct ChestData { - ChestData() = default; - ChestData(uchar i, bool s) : id_(i), size_(s) {}; - - uchar id_; - bool size_; -}; - -struct StaircaseRooms { - StaircaseRooms() = default; - StaircaseRooms(uchar i, uchar r, const char *label) - : id_(i), room_(r), label_(label) {}; - - uchar id_; - uchar room_; - const char *label_; -}; - class Room : public SharedRom { public: Room() = default; @@ -200,16 +163,16 @@ class Room : public SharedRom { std::array background_bmps_; std::vector sprites_; - std::vector staircase_rooms_vec_; + std::vector staircase_rooms_vec_; Background2 bg2_; - DungeonDestination pits_; - DungeonDestination stair1_; - DungeonDestination stair2_; - DungeonDestination stair3_; - DungeonDestination stair4_; + z3_dungeon_destination pits_; + z3_dungeon_destination stair1_; + z3_dungeon_destination stair2_; + z3_dungeon_destination stair3_; + z3_dungeon_destination stair4_; - std::vector chests_in_room_; + std::vector chests_in_room_; std::vector tile_objects_; std::vector room_addresses_; diff --git a/src/incl/dungeon.h b/src/incl/dungeon.h index 325be811..c40e712d 100644 --- a/src/incl/dungeon.h +++ b/src/incl/dungeon.h @@ -7,17 +7,38 @@ extern "C" { #include -struct object_door { - object_door() = default; - object_door(short id, uint8_t x, uint8_t y, uint8_t size, uint8_t layer) - : id_(id), x_(x), y_(y), size_(size), layer_(layer) {} +struct z3_object_door { + short id; + uint8_t x; + uint8_t y; + uint8_t size; + uint8_t type; + uint8_t layer; +}; - short id_; - uint8_t x_; - uint8_t y_; - uint8_t size_; - uint8_t type_; - uint8_t layer_; +struct z3_dungeon_destination { + uint8_t index; + uint8_t target = 0; + uint8_t target_layer = 0; +}; + +struct z3_staircase { + uint8_t id; + uint8_t room; + const char *label; +}; + +struct z3_chest { + uint8_t x = 0; + uint8_t y = 0; + uint8_t item = 0; + bool picker = false; + bool big_chest = false; +}; + +struct z3_chest_data { + uchar id; + bool size; }; #ifdef __cplusplus