From cc05f1b4695a0176e61946de20b808e9e97325fe Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 14 Apr 2024 13:49:00 -0500 Subject: [PATCH] add zelda3::screen namespace --- src/app/editor/screen_editor.cc | 35 +++++++++++++++------------ src/app/editor/screen_editor.h | 4 +-- src/app/zelda3/screen/dungeon_map.h | 4 ++- src/app/zelda3/screen/inventory.cc | 2 ++ src/app/zelda3/screen/inventory.h | 8 +++--- src/app/zelda3/screen/title_screen.cc | 4 ++- src/app/zelda3/screen/title_screen.h | 4 ++- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/app/editor/screen_editor.cc b/src/app/editor/screen_editor.cc index 85d82bfc..e4cac7c2 100644 --- a/src/app/editor/screen_editor.cc +++ b/src/app/editor/screen_editor.cc @@ -117,25 +117,30 @@ absl::Status ScreenEditor::LoadDungeonMaps() { for (int d = 0; d < 14; d++) { current_floor_rooms_d.clear(); current_floor_gfx_d.clear(); - ASSIGN_OR_RETURN(int ptr, - rom()->ReadWord(zelda3::kDungeonMapRoomsPtr + (d * 2))); - ASSIGN_OR_RETURN(int ptrGFX, - rom()->ReadWord(zelda3::kDungeonMapRoomsPtr + (d * 2))); + ASSIGN_OR_RETURN( + int ptr, + rom()->ReadWord(zelda3::screen::kDungeonMapRoomsPtr + (d * 2))); + ASSIGN_OR_RETURN( + int ptrGFX, + rom()->ReadWord(zelda3::screen::kDungeonMapRoomsPtr + (d * 2))); ptr |= 0x0A0000; // Add bank to the short ptr ptrGFX |= 0x0A0000; // Add bank to the short ptr int pcPtr = core::SnesToPc(ptr); // Contains data for the next 25 rooms int pcPtrGFX = core::SnesToPc(ptrGFX); // Contains data for the next 25 rooms - ASSIGN_OR_RETURN(ushort bossRoomD, - rom()->ReadWord(zelda3::kDungeonMapBossRooms + (d * 2))); + ASSIGN_OR_RETURN( + ushort bossRoomD, + rom()->ReadWord(zelda3::screen::kDungeonMapBossRooms + (d * 2))); - ASSIGN_OR_RETURN(nbr_basement_d, - rom()->ReadByte(zelda3::kDungeonMapFloors + (d * 2))); + ASSIGN_OR_RETURN( + nbr_basement_d, + rom()->ReadByte(zelda3::screen::kDungeonMapFloors + (d * 2))); nbr_basement_d &= 0x0F; - ASSIGN_OR_RETURN(nbr_floor_d, - rom()->ReadByte(zelda3::kDungeonMapFloors + (d * 2))); + ASSIGN_OR_RETURN( + nbr_floor_d, + rom()->ReadByte(zelda3::screen::kDungeonMapFloors + (d * 2))); nbr_floor_d &= 0xF0; nbr_floor_d = nbr_floor_d >> 4; @@ -179,8 +184,8 @@ absl::Status ScreenEditor::LoadDungeonMaps() { absl::Status ScreenEditor::SaveDungeonMaps() { for (int d = 0; d < 14; d++) { - int ptr = zelda3::kDungeonMapRoomsPtr + (d * 2); - int ptrGFX = zelda3::kDungeonMapGfxPtr + (d * 2); + int ptr = zelda3::screen::kDungeonMapRoomsPtr + (d * 2); + int ptrGFX = zelda3::screen::kDungeonMapGfxPtr + (d * 2); int pcPtr = core::SnesToPc(ptr); int pcPtrGFX = core::SnesToPc(ptrGFX); @@ -208,9 +213,9 @@ absl::Status ScreenEditor::LoadDungeonMapTile16() { tile16_sheet_.Init(256, 192, gfx::TileType::Tile16); for (int i = 0; i < 186; i++) { - int addr = zelda3::kDungeonMapTile16; - if (rom()->data()[zelda3::kDungeonMapExpCheck] != 0xB9) { - addr = zelda3::kDungeonMapTile16Expanded; + int addr = zelda3::screen::kDungeonMapTile16; + if (rom()->data()[zelda3::screen::kDungeonMapExpCheck] != 0xB9) { + addr = zelda3::screen::kDungeonMapTile16Expanded; } ASSIGN_OR_RETURN(auto tl, rom()->ReadWord(addr + (i * 8))); diff --git a/src/app/editor/screen_editor.h b/src/app/editor/screen_editor.h index 23dd92c9..8cecd330 100644 --- a/src/app/editor/screen_editor.h +++ b/src/app/editor/screen_editor.h @@ -57,7 +57,7 @@ class ScreenEditor : public SharedROM { void DrawDungeonMapsTabs(); void DrawDungeonMapsEditor(); - std::vector dungeon_maps_; + std::vector dungeon_maps_; std::vector>> dungeon_map_labels_; std::unordered_map tile16_individual_; @@ -74,7 +74,7 @@ class ScreenEditor : public SharedROM { bool paste_button_pressed = false; Bytes all_gfx_; - zelda3::Inventory inventory_; + zelda3::screen::Inventory inventory_; gfx::SnesPalette palette_; gui::Canvas screen_canvas_; gui::Canvas tilesheet_canvas_; diff --git a/src/app/zelda3/screen/dungeon_map.h b/src/app/zelda3/screen/dungeon_map.h index 6b9588ec..5977a947 100644 --- a/src/app/zelda3/screen/dungeon_map.h +++ b/src/app/zelda3/screen/dungeon_map.h @@ -7,6 +7,7 @@ namespace yaze { namespace app { namespace zelda3 { +namespace screen { constexpr int kDungeonMapRoomsPtr = 0x57605; // 14 pointers of map data constexpr int kDungeonMapFloors = 0x575D9; // 14 words values @@ -47,8 +48,9 @@ class DungeonMap { floor_gfx(floor_gfx) {} }; +} // namespace screen } // namespace zelda3 } // namespace app } // namespace yaze -#endif // YAZE_APP_ZELDA3_SCREEN_DUNGEON_MAP_H \ No newline at end of file +#endif // YAZE_APP_ZELDA3_SCREEN_DUNGEON_MAP_H diff --git a/src/app/zelda3/screen/inventory.cc b/src/app/zelda3/screen/inventory.cc index b32434dd..4cafb895 100644 --- a/src/app/zelda3/screen/inventory.cc +++ b/src/app/zelda3/screen/inventory.cc @@ -8,6 +8,7 @@ namespace yaze { namespace app { namespace zelda3 { +namespace screen { void Inventory::Create() { data_.reserve(256 * 256); @@ -86,6 +87,7 @@ absl::Status Inventory::BuildTileset() { return absl::OkStatus(); } +} // namespace screen } // namespace zelda3 } // namespace app } // namespace yaze \ No newline at end of file diff --git a/src/app/zelda3/screen/inventory.h b/src/app/zelda3/screen/inventory.h index e2bd27d1..c0b39435 100644 --- a/src/app/zelda3/screen/inventory.h +++ b/src/app/zelda3/screen/inventory.h @@ -2,14 +2,15 @@ #define YAZE_APP_ZELDA3_INVENTORY_H #include "app/gfx/bitmap.h" -#include "app/gfx/snes_tile.h" #include "app/gfx/snes_palette.h" -#include "app/rom.h" +#include "app/gfx/snes_tile.h" #include "app/gui/canvas.h" +#include "app/rom.h" namespace yaze { namespace app { namespace zelda3 { +namespace screen { constexpr int kInventoryStart = 0x6564A; constexpr int kBowItemPos = 0x6F631; @@ -37,8 +38,9 @@ class Inventory : public SharedROM { std::vector tiles_; }; +} // namespace screen } // namespace zelda3 } // namespace app } // namespace yaze -#endif \ No newline at end of file +#endif // YAZE_APP_ZELDA3_INVENTORY_H diff --git a/src/app/zelda3/screen/title_screen.cc b/src/app/zelda3/screen/title_screen.cc index cdb647b0..3ef63361 100644 --- a/src/app/zelda3/screen/title_screen.cc +++ b/src/app/zelda3/screen/title_screen.cc @@ -10,6 +10,7 @@ namespace yaze { namespace app { namespace zelda3 { +namespace screen { void TitleScreen::Create() { tiles8Bitmap.Create(128, 512, 8, 0x20000); @@ -124,6 +125,7 @@ void TitleScreen::LoadTitleScreen() { pal_selected_ = 2; } +} // namespace screen } // namespace zelda3 } // namespace app -} // namespace yaze \ No newline at end of file +} // namespace yaze diff --git a/src/app/zelda3/screen/title_screen.h b/src/app/zelda3/screen/title_screen.h index 9e9cd556..fb618fea 100644 --- a/src/app/zelda3/screen/title_screen.h +++ b/src/app/zelda3/screen/title_screen.h @@ -11,6 +11,7 @@ namespace yaze { namespace app { namespace zelda3 { +namespace screen { class TitleScreen { public: @@ -74,8 +75,9 @@ class TitleScreen { gfx::Bitmap tiles8Bitmap; // 0x20000 }; +} // namespace screen } // namespace zelda3 } // namespace app } // namespace yaze -#endif \ No newline at end of file +#endif // YAZE_APP_ZELDA3_SCREEN_H