Add LayerMergeType and list of constant types

This commit is contained in:
scawful
2025-01-02 08:37:34 -05:00
parent 72b51376d9
commit df67e6aaf7
2 changed files with 45 additions and 17 deletions

View File

@@ -7,20 +7,15 @@
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "app/core/constants.h" #include "app/core/constants.h"
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_palette.h"
#include "app/gfx/snes_tile.h"
#include "app/gui/canvas.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/dungeon/room_object.h" #include "app/zelda3/dungeon/room_object.h"
#include "app/zelda3/dungeon/room_tag.h"
#include "app/zelda3/sprite/sprite.h" #include "app/zelda3/sprite/sprite.h"
namespace yaze { namespace yaze {
namespace zelda3 { namespace zelda3 {
void Room::LoadHeader() { void Room::LoadHeader() {
// Address of the room header
int header_pointer = (rom()->data()[kRoomHeaderPointer + 2] << 16) + int header_pointer = (rom()->data()[kRoomHeaderPointer + 2] << 16) +
(rom()->data()[kRoomHeaderPointer + 1] << 8) + (rom()->data()[kRoomHeaderPointer + 1] << 8) +
(rom()->data()[kRoomHeaderPointer]); (rom()->data()[kRoomHeaderPointer]);
@@ -33,7 +28,7 @@ void Room::LoadHeader() {
auto header_location = core::SnesToPc(address); auto header_location = core::SnesToPc(address);
bg2_ = (z3_dungeon_background2)((rom()->data()[header_location] >> 5) & 0x07); bg2_ = (z3_dungeon_background2)((rom()->data()[header_location] >> 5) & 0x07);
// collision = (CollisionKey)((rom()->data()[header_location] >> 2) & 0x07); collision_ = (CollisionKey)((rom()->data()[header_location] >> 2) & 0x07);
is_light_ = ((rom()->data()[header_location]) & 0x01) == 1; is_light_ = ((rom()->data()[header_location]) & 0x01) == 1;
if (is_light_) { if (is_light_) {
@@ -43,9 +38,9 @@ void Room::LoadHeader() {
palette = ((rom()->data()[header_location + 1] & 0x3F)); palette = ((rom()->data()[header_location + 1] & 0x3F));
blockset = (rom()->data()[header_location + 2]); blockset = (rom()->data()[header_location + 2]);
spriteset = (rom()->data()[header_location + 3]); spriteset = (rom()->data()[header_location + 3]);
// effect = (EffectKey)((rom()->data()[header_location + 4])); effect_ = (EffectKey)((rom()->data()[header_location + 4]));
// tag1 = (TagKey)((rom()->data()[header_location + 5])); tag1_ = (TagKey)((rom()->data()[header_location + 5]));
// tag2 = (TagKey)((rom()->data()[header_location + 6])); tag2_ = (TagKey)((rom()->data()[header_location + 6]));
staircase_plane_[0] = ((rom()->data()[header_location + 7] >> 2) & 0x03); staircase_plane_[0] = ((rom()->data()[header_location + 7] >> 2) & 0x03);
staircase_plane_[1] = ((rom()->data()[header_location + 7] >> 4) & 0x03); staircase_plane_[1] = ((rom()->data()[header_location + 7] >> 4) & 0x03);
@@ -139,8 +134,7 @@ void Room::LoadRoomFromROM() {
uint8_t b = rom_data[hpos]; uint8_t b = rom_data[hpos];
layer2_mode_ = (b >> 5); layer2_mode_ = (b >> 5);
// TODO(@scawful): Make LayerMerging object. layer_merging_ = kLayerMergeTypeList[(b & 0x0C) >> 2];
// LayerMerging = LayerMergeType.ListOf[(b & 0x0C) >> 2];
is_dark_ = (b & 0x01) == 0x01; is_dark_ = (b & 0x01) == 0x01;
hpos++; hpos++;
@@ -157,10 +151,10 @@ void Room::LoadRoomFromROM() {
layer2_behavior_ = rom_data[hpos]; layer2_behavior_ = rom_data[hpos];
hpos++; hpos++;
tag1_ = rom_data[hpos]; tag1_ = (TagKey)rom_data[hpos];
hpos++; hpos++;
tag2_ = rom_data[hpos]; tag2_ = (TagKey)rom_data[hpos];
hpos++; hpos++;
b = rom_data[hpos]; b = rom_data[hpos];
@@ -485,8 +479,5 @@ void Room::LoadChests() {
} }
} }
} // namespace zelda3 } // namespace zelda3
} // namespace yaze } // namespace yaze

View File

@@ -11,6 +11,7 @@
#include "app/gfx/bitmap.h" #include "app/gfx/bitmap.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/dungeon/room_object.h" #include "app/zelda3/dungeon/room_object.h"
#include "app/zelda3/dungeon/room_tag.h"
#include "app/zelda3/sprite/sprite.h" #include "app/zelda3/sprite/sprite.h"
namespace yaze { namespace yaze {
@@ -80,6 +81,36 @@ constexpr int NumberOfRooms = 296;
constexpr ushort stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D}; constexpr ushort stairsObjects[] = {0x139, 0x138, 0x13B, 0x12E, 0x12D};
struct LayerMergeType {
uint8_t ID;
std::string Name;
bool Layer2OnTop;
bool Layer2Translucent;
bool Layer2Visible;
LayerMergeType() = default;
LayerMergeType(uint8_t id, std::string name, bool see, bool top, bool trans) {
ID = id;
Name = name;
Layer2OnTop = top;
Layer2Translucent = trans;
Layer2Visible = see;
}
};
const static LayerMergeType LayerMerge00{0x00, "Off", true, false, false};
const static LayerMergeType LayerMerge01{0x01, "Parallax", true, false, false};
const static LayerMergeType LayerMerge02{0x02, "Dark", true, true, true};
const static LayerMergeType LayerMerge03{0x03, "On top", true, true, false};
const static LayerMergeType LayerMerge04{0x04, "Translucent", true, true, true};
const static LayerMergeType LayerMerge05{0x05, "Addition", true, true, true};
const static LayerMergeType LayerMerge06{0x06, "Normal", true, false, false};
const static LayerMergeType LayerMerge07{0x07, "Transparent", true, true, true};
const static LayerMergeType LayerMerge08{0x08, "Dark room", true, true, true};
const static LayerMergeType kLayerMergeTypeList[] = {
LayerMerge00, LayerMerge01, LayerMerge02, LayerMerge03, LayerMerge04,
LayerMerge05, LayerMerge06, LayerMerge07, LayerMerge08};
class Room : public SharedRom { class Room : public SharedRom {
public: public:
Room() = default; Room() = default;
@@ -156,6 +187,12 @@ class Room : public SharedRom {
std::vector<z3_staircase> z3_staircases_; std::vector<z3_staircase> z3_staircases_;
std::vector<z3_chest_data> chests_in_room_; std::vector<z3_chest_data> chests_in_room_;
LayerMergeType layer_merging_;
CollisionKey collision_;
EffectKey effect_;
TagKey tag1_;
TagKey tag2_;
z3_dungeon_background2 bg2_; z3_dungeon_background2 bg2_;
z3_dungeon_destination pits_; z3_dungeon_destination pits_;
z3_dungeon_destination stair1_; z3_dungeon_destination stair1_;