From fae853d5e1a6ddad1568b45421c87248c4a77862 Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 12 Apr 2024 15:48:11 -0400 Subject: [PATCH] Add EntranceContext for managing custom entrance tile types --- src/app/editor/context/entrance_context.h | 40 +++++++++++++++++++++++ src/app/editor/overworld_editor.cc | 1 + src/app/editor/overworld_editor.h | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 src/app/editor/context/entrance_context.h diff --git a/src/app/editor/context/entrance_context.h b/src/app/editor/context/entrance_context.h new file mode 100644 index 00000000..5870cbb1 --- /dev/null +++ b/src/app/editor/context/entrance_context.h @@ -0,0 +1,40 @@ +#ifndef YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_ +#define YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_ + +#include +#include + +#include "absl/status/status.h" +#include "app/rom.h" + +namespace yaze { +namespace app { +namespace editor { + +class EntranceContext { + public: + absl::Status LoadEntranceTileTypes(ROM& rom) { + int offset_low = 0xDB8BF; + int offset_high = 0xDB917; + + for (int i = 0; i < 0x2C; i++) { + // Load entrance tile types + ASSIGN_OR_RETURN(auto value_low, rom.ReadWord(offset_low + i)); + entrance_tile_types_low_.push_back(value_low); + ASSIGN_OR_RETURN(auto value_high, rom.ReadWord(offset_high + i)); + entrance_tile_types_low_.push_back(value_high); + } + + return absl::OkStatus(); + } + + private: + std::vector entrance_tile_types_low_; + std::vector entrance_tile_types_high_; +}; + +} // namespace editor +} // namespace app +} // namespace yaze + +#endif // YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_ \ No newline at end of file diff --git a/src/app/editor/overworld_editor.cc b/src/app/editor/overworld_editor.cc index 1e3a70e2..917ca588 100644 --- a/src/app/editor/overworld_editor.cc +++ b/src/app/editor/overworld_editor.cc @@ -48,6 +48,7 @@ absl::Status OverworldEditor::Update() { tile16_individual_, *overworld_.mutable_all_tiles_types()); gfx_group_editor_.InitBlockset(tile16_blockset_bmp_); + RETURN_IF_ERROR(LoadEntranceTileTypes(*rom())); all_gfx_loaded_ = true; } else if (!rom()->is_loaded() && all_gfx_loaded_) { Shutdown(); diff --git a/src/app/editor/overworld_editor.h b/src/app/editor/overworld_editor.h index 60e2bd32..6fcb9873 100644 --- a/src/app/editor/overworld_editor.h +++ b/src/app/editor/overworld_editor.h @@ -13,6 +13,7 @@ #include "absl/strings/str_format.h" #include "app/core/common.h" #include "app/core/editor.h" +#include "app/editor/context/entrance_context.h" #include "app/editor/context/gfx_context.h" #include "app/editor/modules/gfx_group_editor.h" #include "app/editor/modules/palette_editor.h" @@ -64,6 +65,7 @@ constexpr absl::string_view kOWMapTable = "#MapSettingsTable"; class OverworldEditor : public Editor, public SharedROM, public GfxContext, + public EntranceContext, public core::ExperimentFlags { public: absl::Status Update() final;