Add zelda3::overworld namespace

This commit is contained in:
scawful
2024-04-14 14:37:53 -05:00
parent cc05f1b469
commit b06e22dc0d
14 changed files with 54 additions and 36 deletions

View File

@@ -34,8 +34,8 @@ set(
set( set(
YAZE_APP_ZELDA3_SRC YAZE_APP_ZELDA3_SRC
app/zelda3/overworld_map.cc app/zelda3/overworld/overworld_map.cc
app/zelda3/overworld.cc app/zelda3/overworld/overworld.cc
app/zelda3/screen/inventory.cc app/zelda3/screen/inventory.cc
app/zelda3/screen/title_screen.cc app/zelda3/screen/title_screen.cc
app/zelda3/sprite/sprite.cc app/zelda3/sprite/sprite.cc

View File

@@ -15,7 +15,7 @@
#include "app/gui/input.h" #include "app/gui/input.h"
#include "app/gui/pipeline.h" #include "app/gui/pipeline.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
@@ -167,7 +167,7 @@ class GraphicsEditor : public SharedROM {
ROM temp_rom_; ROM temp_rom_;
ROM tilemap_rom_; ROM tilemap_rom_;
zelda3::Overworld overworld_; zelda3::overworld::Overworld overworld_;
MemoryEditor cgx_memory_editor_; MemoryEditor cgx_memory_editor_;
MemoryEditor col_memory_editor_; MemoryEditor col_memory_editor_;
PaletteEditor palette_editor_; PaletteEditor palette_editor_;

View File

@@ -18,7 +18,7 @@
#include "app/gui/pipeline.h" #include "app/gui/pipeline.h"
#include "app/gui/widgets.h" #include "app/gui/widgets.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {

View File

@@ -17,7 +17,7 @@
#include "app/gui/pipeline.h" #include "app/gui/pipeline.h"
#include "app/gui/widgets.h" #include "app/gui/widgets.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
@@ -65,7 +65,7 @@ class GfxGroupEditor : public SharedROM {
std::vector<gfx::Bitmap> tile16_individual_; std::vector<gfx::Bitmap> tile16_individual_;
gui::BitmapViewer gfx_group_viewer_; gui::BitmapViewer gfx_group_viewer_;
zelda3::Overworld overworld_; zelda3::overworld::Overworld overworld_;
}; };
} // namespace editor } // namespace editor

View File

@@ -19,7 +19,7 @@
#include "app/gui/style.h" #include "app/gui/style.h"
#include "app/gui/widgets.h" #include "app/gui/widgets.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {

View File

@@ -18,7 +18,7 @@
#include "app/gui/icons.h" #include "app/gui/icons.h"
#include "app/gui/pipeline.h" #include "app/gui/pipeline.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
@@ -128,7 +128,7 @@ class Tile16Editor : public context::GfxContext, public SharedROM {
PaletteEditor palette_editor_; PaletteEditor palette_editor_;
gfx::SnesPalette palette_; gfx::SnesPalette palette_;
zelda3::Overworld transfer_overworld_; zelda3::overworld::Overworld transfer_overworld_;
gfx::BitmapTable graphics_bin_; gfx::BitmapTable graphics_bin_;

View File

@@ -23,7 +23,7 @@
#include "app/gui/style.h" #include "app/gui/style.h"
#include "app/gui/widgets.h" #include "app/gui/widgets.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
@@ -863,8 +863,9 @@ bool IsMouseHoveringOverEntity(const zelda3::OverworldEntity &entity,
return false; return false;
} }
void MoveEntityOnGrid(zelda3::OverworldEntity *entity, ImVec2 canvas_p0, void MoveEntityOnGrid(zelda3::OverworldEntity *entity,
ImVec2 scrolling, bool free_movement = false) { ImVec2 canvas_p0, ImVec2 scrolling,
bool free_movement = false) {
// Get the mouse position relative to the canvas // Get the mouse position relative to the canvas
const ImGuiIO &io = ImGui::GetIO(); const ImGuiIO &io = ImGui::GetIO();
const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y); const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y);
@@ -883,8 +884,9 @@ void MoveEntityOnGrid(zelda3::OverworldEntity *entity, ImVec2 canvas_p0,
entity->set_y(new_y); entity->set_y(new_y);
} }
void HandleEntityDragging(zelda3::OverworldEntity *entity, ImVec2 canvas_p0, void HandleEntityDragging(zelda3::OverworldEntity *entity,
ImVec2 scrolling, bool &is_dragging_entity, ImVec2 canvas_p0, ImVec2 scrolling,
bool &is_dragging_entity,
zelda3::OverworldEntity *&dragged_entity, zelda3::OverworldEntity *&dragged_entity,
zelda3::OverworldEntity *&current_entity, zelda3::OverworldEntity *&current_entity,
bool free_movement = false) { bool free_movement = false) {
@@ -960,7 +962,8 @@ bool DrawEntranceInserterPopup() {
} }
// TODO: Implement deleting OverworldEntrance objects, currently only hides them // TODO: Implement deleting OverworldEntrance objects, currently only hides them
bool DrawOverworldEntrancePopup(zelda3::OverworldEntrance &entrance) { bool DrawOverworldEntrancePopup(
zelda3::overworld::OverworldEntrance &entrance) {
static bool set_done = false; static bool set_done = false;
if (set_done) { if (set_done) {
set_done = false; set_done = false;
@@ -1084,7 +1087,7 @@ void DrawExitInserterPopup() {
} }
} }
bool DrawExitEditorPopup(zelda3::OverworldExit &exit) { bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit) {
static bool set_done = false; static bool set_done = false;
if (set_done) { if (set_done) {
set_done = false; set_done = false;
@@ -1280,8 +1283,8 @@ void DrawItemInsertPopup() {
ImGui::Text("Add Item"); ImGui::Text("Add Item");
ImGui::BeginChild("ScrollRegion", ImVec2(150, 150), true, ImGui::BeginChild("ScrollRegion", ImVec2(150, 150), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
for (int i = 0; i < zelda3::kSecretItemNames.size(); i++) { for (int i = 0; i < zelda3::overworld::kSecretItemNames.size(); i++) {
if (ImGui::Selectable(zelda3::kSecretItemNames[i].c_str(), if (ImGui::Selectable(zelda3::overworld::kSecretItemNames[i].c_str(),
i == new_item_id)) { i == new_item_id)) {
new_item_id = i; new_item_id = i;
} }
@@ -1304,7 +1307,7 @@ void DrawItemInsertPopup() {
} }
// TODO: Implement deleting OverworldItem objects, currently only hides them // TODO: Implement deleting OverworldItem objects, currently only hides them
bool DrawItemEditorPopup(zelda3::OverworldItem &item) { bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item) {
static bool set_done = false; static bool set_done = false;
if (set_done) { if (set_done) {
set_done = false; set_done = false;
@@ -1314,8 +1317,8 @@ bool DrawItemEditorPopup(zelda3::OverworldItem &item) {
ImGui::BeginChild("ScrollRegion", ImVec2(150, 150), true, ImGui::BeginChild("ScrollRegion", ImVec2(150, 150), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar); ImGuiWindowFlags_AlwaysVerticalScrollbar);
ImGui::BeginGroup(); ImGui::BeginGroup();
for (int i = 0; i < zelda3::kSecretItemNames.size(); i++) { for (int i = 0; i < zelda3::overworld::kSecretItemNames.size(); i++) {
if (ImGui::Selectable(zelda3::kSecretItemNames[i].c_str(), if (ImGui::Selectable(zelda3::overworld::kSecretItemNames[i].c_str(),
item.id == i)) { item.id == i)) {
item.id = i; item.id = i;
} }
@@ -1348,7 +1351,7 @@ void OverworldEditor::DrawOverworldItems() {
// Get the item's bitmap and real X and Y positions // Get the item's bitmap and real X and Y positions
if (item.room_map_id < 0x40 + (current_world_ * 0x40) && if (item.room_map_id < 0x40 + (current_world_ * 0x40) &&
item.room_map_id >= (current_world_ * 0x40) && !item.deleted) { item.room_map_id >= (current_world_ * 0x40) && !item.deleted) {
std::string item_name = zelda3::kSecretItemNames[item.id]; std::string item_name = zelda3::overworld::kSecretItemNames[item.id];
ow_map_canvas_.DrawRect(item.x_, item.y_, 16, 16, ImVec4(255, 0, 0, 150)); ow_map_canvas_.DrawRect(item.x_, item.y_, 16, 16, ImVec4(255, 0, 0, 150));
@@ -1647,7 +1650,7 @@ absl::Status OverworldEditor::LoadGraphics() {
} }
// Render the overworld maps loaded from the ROM. // Render the overworld maps loaded from the ROM.
for (int i = 0; i < zelda3::kNumOverworldMaps; ++i) { for (int i = 0; i < zelda3::overworld::kNumOverworldMaps; ++i) {
overworld_.set_current_map(i); overworld_.set_current_map(i);
auto palette = overworld_.AreaPalette(); auto palette = overworld_.AreaPalette();
gui::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200, gui::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,

View File

@@ -25,7 +25,7 @@
#include "app/gui/icons.h" #include "app/gui/icons.h"
#include "app/gui/pipeline.h" #include "app/gui/pipeline.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
@@ -235,11 +235,11 @@ class OverworldEditor : public Editor,
zelda3::OverworldEntity* current_entity_; zelda3::OverworldEntity* current_entity_;
int current_entrance_id_ = 0; int current_entrance_id_ = 0;
zelda3::OverworldEntrance current_entrance_; zelda3::overworld::OverworldEntrance current_entrance_;
int current_exit_id_ = 0; int current_exit_id_ = 0;
zelda3::OverworldExit current_exit_; zelda3::overworld::OverworldExit current_exit_;
int current_item_id_ = 0; int current_item_id_ = 0;
zelda3::OverworldItem current_item_; zelda3::overworld::OverworldItem current_item_;
int current_sprite_id_ = 0; int current_sprite_id_ = 0;
zelda3::Sprite current_sprite_; zelda3::Sprite current_sprite_;
@@ -257,7 +257,7 @@ class OverworldEditor : public Editor,
Tile16Editor tile16_editor_; Tile16Editor tile16_editor_;
GfxGroupEditor gfx_group_editor_; GfxGroupEditor gfx_group_editor_;
PaletteEditor palette_editor_; PaletteEditor palette_editor_;
zelda3::Overworld overworld_; zelda3::overworld::Overworld overworld_;
gui::Canvas ow_map_canvas_{ImVec2(0x200 * 8, 0x200 * 8), gui::Canvas ow_map_canvas_{ImVec2(0x200 * 8, 0x200 * 8),
gui::CanvasGridSize::k64x64}; gui::CanvasGridSize::k64x64};

View File

@@ -17,12 +17,13 @@
#include "app/gfx/compression.h" #include "app/gfx/compression.h"
#include "app/gfx/snes_tile.h" #include "app/gfx/snes_tile.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld_map.h" #include "app/zelda3/overworld/overworld_map.h"
#include "app/zelda3/sprite/sprite.h" #include "app/zelda3/sprite/sprite.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace zelda3 { namespace zelda3 {
namespace overworld {
namespace { namespace {
@@ -427,7 +428,7 @@ absl::Status Overworld::LoadExits() {
absl::Status Overworld::LoadItems() { absl::Status Overworld::LoadItems() {
ASSIGN_OR_RETURN(uint32_t pointer, ASSIGN_OR_RETURN(uint32_t pointer,
rom()->ReadLong(zelda3::overworldItemsAddress)); rom()->ReadLong(zelda3::overworld::kOverworldItemsAddress));
uint32_t pointer_pc = core::SnesToPc(pointer); // 1BC2F9 -> 0DC2F9 uint32_t pointer_pc = core::SnesToPc(pointer); // 1BC2F9 -> 0DC2F9
for (int i = 0; i < 128; i++) { for (int i = 0; i < 128; i++) {
ASSIGN_OR_RETURN(uint16_t word_address, ASSIGN_OR_RETURN(uint16_t word_address,
@@ -1568,6 +1569,7 @@ OWBlockset &Overworld::GetMapTiles(int world_type) {
} }
} }
} // namespace overworld
} // namespace zelda3 } // namespace zelda3
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -15,13 +15,19 @@
#include "app/gfx/snes_tile.h" #include "app/gfx/snes_tile.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/common.h" #include "app/zelda3/common.h"
#include "app/zelda3/overworld_map.h" #include "app/zelda3/overworld/overworld_map.h"
#include "app/zelda3/sprite/sprite.h" #include "app/zelda3/sprite/sprite.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace zelda3 { namespace zelda3 {
/**
* @namespace yaze::app::zelda3::overworld
* @brief Represents the Overworld data.
*/
namespace overworld {
// List of secret item names // List of secret item names
const std::vector<std::string> kSecretItemNames = { const std::vector<std::string> kSecretItemNames = {
"Nothing", // 0 "Nothing", // 0
@@ -55,7 +61,7 @@ const std::vector<std::string> kSecretItemNames = {
}; };
constexpr int overworldItemsPointers = 0xDC2F9; constexpr int overworldItemsPointers = 0xDC2F9;
constexpr int overworldItemsAddress = 0xDC8B9; // 1BC2F9 constexpr int kOverworldItemsAddress = 0xDC8B9; // 1BC2F9
constexpr int overworldItemsBank = 0xDC8BF; constexpr int overworldItemsBank = 0xDC8BF;
constexpr int overworldItemsEndData = 0xDC89C; // 0DC89E constexpr int overworldItemsEndData = 0xDC89C; // 0DC89E
@@ -624,6 +630,7 @@ class Overworld : public SharedROM, public core::ExperimentFlags {
absl::flat_hash_map<int, MapData> proto_map_data_; absl::flat_hash_map<int, MapData> proto_map_data_;
}; };
} // namespace overworld
} // namespace zelda3 } // namespace zelda3
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -13,11 +13,12 @@
#include "app/gfx/bitmap.h" #include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h" #include "app/gfx/snes_tile.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace zelda3 { namespace zelda3 {
namespace overworld {
OverworldMap::OverworldMap(int index, ROM& rom, OverworldMap::OverworldMap(int index, ROM& rom,
std::vector<gfx::Tile16>& tiles16) std::vector<gfx::Tile16>& tiles16)
@@ -557,6 +558,7 @@ absl::Status OverworldMap::BuildBitmap(OWBlockset& world_blockset) {
return absl::OkStatus(); return absl::OkStatus();
} }
} // namespace overworld
} // namespace zelda3 } // namespace zelda3
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -20,6 +20,7 @@
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace zelda3 { namespace zelda3 {
namespace overworld {
static constexpr int kTileOffsets[] = {0, 8, 4096, 4104}; static constexpr int kTileOffsets[] = {0, 8, 4096, 4104};
@@ -144,6 +145,7 @@ class OverworldMap : public editor::context::GfxContext {
std::vector<gfx::Tile16> tiles16_; std::vector<gfx::Tile16> tiles16_;
}; };
} // namespace overworld
} // namespace zelda3 } // namespace zelda3
} // namespace app } // namespace app
} // namespace yaze } // namespace yaze

View File

@@ -1,5 +1,7 @@
#include "sprite.h" #include "sprite.h"
#include "app/zelda3/overworld/overworld.h"
namespace yaze { namespace yaze {
namespace app { namespace app {
namespace zelda3 { namespace zelda3 {

View File

@@ -22,7 +22,7 @@
#include "app/gui/canvas.h" #include "app/gui/canvas.h"
#include "app/gui/pipeline.h" #include "app/gui/pipeline.h"
#include "app/rom.h" // for ROM #include "app/rom.h" // for ROM
#include "app/zelda3/overworld.h" #include "app/zelda3/overworld/overworld.h"
#include "cli/patch.h" // for ApplyBpsPatch, CreateBpsPatch #include "cli/patch.h" // for ApplyBpsPatch, CreateBpsPatch
namespace yaze { namespace yaze {