diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c91b5cfb..f0386e23 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,11 +38,11 @@ add_executable( gui/editor/overworld_editor.cc app/rom.cc app/core/controller.cc - app/zelda3/overworld.cc - app/zelda3/overworld_map.cc app/gfx/bitmap.cc app/gfx/tile.cc app/gfx/palette.cc + app/zelda3/overworld.cc + app/zelda3/overworld_map.cc # GUI libraries ${IMGUI_PATH}/imgui.cpp ${IMGUI_PATH}/imgui_demo.cpp @@ -67,6 +67,7 @@ target_include_directories( / Library/ app/ + gui/ "C:/msys64/mingw64/include/libpng16" "C:/msys64/mingw64/include/SDL2" "C:/msys64/mingw64/include" diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 73a9b31b..790f68f5 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -43,7 +43,7 @@ class Controller { }; bool active_; - Editor::Editor editor_; + gui::editor::Editor editor_; std::shared_ptr sdl_window_; std::shared_ptr sdl_renderer_; }; diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index c0ec4434..46894dd5 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -28,7 +28,7 @@ int GetPCGfxAddress(char *romData, char id) { char gfxGamePointer3 = romData[gfxPointer3 + id]; return lorom_snes_to_pc( - Data::AddressFromBytes(gfxGamePointer1, gfxGamePointer2, gfxGamePointer3), + AddressFromBytes(gfxGamePointer1, gfxGamePointer2, gfxGamePointer3), info1); } diff --git a/src/app/gfx/tile.cc b/src/app/gfx/tile.cc index a9619e2f..5008de14 100644 --- a/src/app/gfx/tile.cc +++ b/src/app/gfx/tile.cc @@ -1,5 +1,7 @@ #include "tile.h" +#include + #include #include #include @@ -7,6 +9,12 @@ #include #include #include +#include +#include +#include + +#include "app/core/constants.h" +#include "app/gfx/palette.h" namespace yaze { namespace app { diff --git a/src/app/gfx/tile.h b/src/app/gfx/tile.h index a82ee790..75477145 100644 --- a/src/app/gfx/tile.h +++ b/src/app/gfx/tile.h @@ -1,15 +1,21 @@ -#ifndef YAZE_APP_DATA_TILE_H -#define YAZE_APP_DATA_TILE_H +#ifndef YAZE_APP_GFX_TILE_H +#define YAZE_APP_GFX_TILE_H #include +#include #include +#include +#include +#include +#include +#include #include #include #include -#include "Core/constants.h" -#include "gfx/palette.h" +#include "app/core/constants.h" +#include "app/gfx/palette.h" namespace yaze { namespace app { @@ -100,4 +106,4 @@ class TilePreset { } // namespace app } // namespace yaze -#endif \ No newline at end of file +#endif // YAZE_APP_GFX_TILE_H \ No newline at end of file diff --git a/src/app/rom.cc b/src/app/rom.cc index f4ad9dd2..6949f650 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -1,12 +1,27 @@ #include "rom.h" -#include +#include +#include +#include -#include "Core/constants.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "app/core/constants.h" +#include "app/gfx/tile.h" namespace yaze { namespace app { -namespace Data { + +int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3) { + return (addr1 << 16) | (addr2 << 8) | addr3; +} ROM::~ROM() { if (loaded) { @@ -287,10 +302,5 @@ SDL_Texture *ROM::DrawgfxSheet(int offset) { return sheet_texture; } -int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3) { - return (addr1 << 16) | (addr2 << 8) | addr3; -} - -} // namespace Data } // namespace app } // namespace yaze \ No newline at end of file diff --git a/src/app/rom.h b/src/app/rom.h index cf0dda8e..d49575f7 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -7,18 +7,18 @@ #include #include +#include #include #include #include #include #include -#include "Core/constants.h" -#include "gfx/tile.h" +#include "app/core/constants.h" +#include "app/gfx/tile.h" namespace yaze { namespace app { -namespace Data { int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3); @@ -52,13 +52,13 @@ class ROM { private: bool loaded = false; bool has_header_ = false; - uchar* current_rom_; - uchar version_; - uchar title[21] = "ROM Not Loaded"; + long int size_; uint uncompressed_size_; uint compressed_size_; uint compress_size_; - long int size_; + uchar* current_rom_; + uchar version_; + uchar title[21] = "ROM Not Loaded"; enum rom_type type_ = LoROM; std::shared_ptr rom_ptr_; @@ -68,7 +68,6 @@ class ROM { std::shared_ptr sdl_renderer_; }; -} // namespace Data } // namespace app } // namespace yaze diff --git a/src/app/zelda3/overworld.cc b/src/app/zelda3/overworld.cc index 8a992e15..8c7d1da9 100644 --- a/src/app/zelda3/overworld.cc +++ b/src/app/zelda3/overworld.cc @@ -41,7 +41,7 @@ static TileInfo GetTilesInfo(ushort tile) { return TileInfo(tid, p, v, h, o); } -void Overworld::Load(Data::ROM& rom) { +void Overworld::Load(ROM& rom) { rom_ = rom; for (int i = 0; i < 0x2B; i++) { tileLeftEntrance.push_back(constants::overworldEntranceAllowedTilesLeft + diff --git a/src/app/zelda3/overworld.h b/src/app/zelda3/overworld.h index 2be8a410..a246806a 100644 --- a/src/app/zelda3/overworld.h +++ b/src/app/zelda3/overworld.h @@ -21,7 +21,7 @@ class Overworld { Overworld() = default; ~Overworld(); - void Load(Data::ROM& rom); + void Load(ROM& rom); char* overworldMapPointer = new char[0x40000]; gfx::Bitmap* overworldMapBitmap; @@ -30,7 +30,7 @@ class Overworld { gfx::Bitmap* owactualMapBitmap; private: - Data::ROM rom_; + ROM rom_; int gameState = 1; bool isLoaded = false; uchar mapParent[160]; diff --git a/src/app/zelda3/overworld_map.cc b/src/app/zelda3/overworld_map.cc index aa349736..2749c249 100644 --- a/src/app/zelda3/overworld_map.cc +++ b/src/app/zelda3/overworld_map.cc @@ -10,8 +10,8 @@ namespace zelda3 { using namespace core; using namespace gfx; -OverworldMap::OverworldMap(Data::ROM& rom, - const std::vector tiles16, uchar index) +OverworldMap::OverworldMap(ROM& rom, const std::vector tiles16, + uchar index) : rom_(rom), index(index), tiles16_(tiles16), parent(index) { if (index != 0x80) { if (index <= 150) { diff --git a/src/app/zelda3/overworld_map.h b/src/app/zelda3/overworld_map.h index ee9585fe..a91c6174 100644 --- a/src/app/zelda3/overworld_map.h +++ b/src/app/zelda3/overworld_map.h @@ -37,13 +37,12 @@ class OverworldMap { ushort** tilesUsed; bool needRefresh = false; - Data::ROM rom_; + ROM rom_; uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2]; std::vector tiles16_; - OverworldMap(Data::ROM& rom, const std::vector tiles16, - uchar index); + OverworldMap(ROM& rom, const std::vector tiles16, uchar index); void BuildMap(uchar* mapParent, int count, int gameState, ushort** allmapsTilesLW, ushort** allmapsTilesDW, ushort** allmapsTilesSP); diff --git a/src/gui/editor/editor.cc b/src/gui/editor/editor.cc index 857954aa..46247706 100644 --- a/src/gui/editor/editor.cc +++ b/src/gui/editor/editor.cc @@ -15,16 +15,14 @@ #include "rom.h" namespace yaze { -namespace app { -namespace Editor { - -using namespace core; +namespace gui { +namespace editor { Editor::Editor() { - for (auto &k : core::constants::kKeywords) + for (auto &k : app::core::constants::kKeywords) language_65816_.mKeywords.emplace(k); - for (auto &k : core::constants::kIdentifiers) { + for (auto &k : app::core::constants::kIdentifiers) { TextEditor::Identifier id; id.mDeclaration = "Built-in function"; language_65816_.mIdentifiers.insert(std::make_pair(std::string(k), id)); diff --git a/src/gui/editor/editor.h b/src/gui/editor/editor.h index ebcaeab0..9bb15ec7 100644 --- a/src/gui/editor/editor.h +++ b/src/gui/editor/editor.h @@ -15,8 +15,8 @@ #include "rom.h" namespace yaze { -namespace app { -namespace Editor { +namespace gui { +namespace editor { class Editor { public: @@ -45,20 +45,18 @@ class Editor { void *rom_data_; bool is_loaded_ = true; - std::vector tiles_; - std::vector> arranged_tiles_; - std::unordered_map> texture_cache_; - std::unordered_map imagesCache; - - std::shared_ptr sdl_renderer_; - - Data::ROM rom_; + app::ROM rom_; TextEditor asm_editor_; TextEditor::LanguageDefinition language_65816_; OverworldEditor overworld_editor_; + std::vector tiles_; + std::vector> arranged_tiles_; + std::unordered_map imagesCache; + std::shared_ptr sdl_renderer_; + ImVec4 current_palette_[8]; - gfx::TilePreset current_set_; + app::gfx::TilePreset current_set_; ImGuiWindowFlags main_editor_flags_ = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | @@ -67,7 +65,7 @@ class Editor { ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit; }; -} // namespace Editor +} // namespace editor } // namespace app } // namespace yaze diff --git a/src/gui/editor/overworld_editor.cc b/src/gui/editor/overworld_editor.cc index 5b58a35c..f339eaf6 100644 --- a/src/gui/editor/overworld_editor.cc +++ b/src/gui/editor/overworld_editor.cc @@ -28,10 +28,10 @@ // have an overworld map viewer, in less than few hours if are able to // understand the data quickly namespace yaze { -namespace app { -namespace Editor { +namespace gui { +namespace editor { -void OverworldEditor::SetupROM(Data::ROM &rom) { rom_ = rom; } +void OverworldEditor::SetupROM(app::ROM &rom) { rom_ = rom; } void OverworldEditor::Update() { if (rom_.isLoaded()) { diff --git a/src/gui/editor/overworld_editor.h b/src/gui/editor/overworld_editor.h index 38a357ee..0d3eb618 100644 --- a/src/gui/editor/overworld_editor.h +++ b/src/gui/editor/overworld_editor.h @@ -3,21 +3,20 @@ #include -#include "zelda3/overworld.h" #include "gfx/palette.h" #include "gfx/tile.h" #include "gui/icons.h" - +#include "zelda3/overworld.h" namespace yaze { -namespace app { -namespace Editor { +namespace gui { +namespace editor { static constexpr unsigned int k4BPP = 4; class OverworldEditor { public: - void SetupROM(Data::ROM &rom); + void SetupROM(app::ROM &rom); void Update(); private: @@ -30,11 +29,11 @@ class OverworldEditor { void Loadgfx(); - Data::ROM rom_; - Data::Overworld overworld_; - gfx::Bitmap allgfxBitmap; - gfx::SNESPalette palette_; - gfx::TilePreset current_set_; + app::ROM rom_; + app::zelda3::Overworld overworld_; + app::gfx::Bitmap allgfxBitmap; + app::gfx::SNESPalette palette_; + app::gfx::TilePreset current_set_; std::unordered_map all_texture_sheet_; SDL_Texture *gfx_texture = nullptr; @@ -72,8 +71,8 @@ class OverworldEditor { ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingStretchSame; }; -} // namespace Editor -} // namespace app +} // namespace editor +} // namespace gui } // namespace yaze #endif \ No newline at end of file