diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f0386e23..3dc3a29f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,10 +37,11 @@ add_executable( gui/editor/editor.cc gui/editor/overworld_editor.cc app/rom.cc + app/core/constants.cc app/core/controller.cc app/gfx/bitmap.cc app/gfx/tile.cc - app/gfx/palette.cc + app/gfx/snes_palette.cc app/zelda3/overworld.cc app/zelda3/overworld_map.cc # GUI libraries @@ -67,7 +68,6 @@ 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/constants.cc b/src/app/core/constants.cc new file mode 100644 index 00000000..2568033d --- /dev/null +++ b/src/app/core/constants.cc @@ -0,0 +1 @@ +#include "app/core/constants.h" \ No newline at end of file diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index 46894dd5..6c2ad91a 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -1,8 +1,10 @@ #include "bitmap.h" +#include #include -#include "rom.h" +#include "app/core/constants.h" +#include "app/rom.h" namespace yaze { namespace app { @@ -28,7 +30,7 @@ int GetPCGfxAddress(char *romData, char id) { char gfxGamePointer3 = romData[gfxPointer3 + id]; return lorom_snes_to_pc( - AddressFromBytes(gfxGamePointer1, gfxGamePointer2, gfxGamePointer3), + yaze::app::rom::AddressFromBytes(gfxGamePointer1, gfxGamePointer2, gfxGamePointer3), info1); } diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index 2700cbfb..62e2dbd7 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -2,8 +2,10 @@ #define YAZE_APP_UTILS_BITMAP_H #include +#include -#include "Core/constants.h" +#include "app/core/constants.h" +#include "app/rom.h" namespace yaze { namespace app { diff --git a/src/app/gfx/palette.cc b/src/app/gfx/snes_palette.cc similarity index 89% rename from src/app/gfx/palette.cc rename to src/app/gfx/snes_palette.cc index d3196479..de8daf19 100644 --- a/src/app/gfx/palette.cc +++ b/src/app/gfx/snes_palette.cc @@ -1,7 +1,17 @@ -#include "palette.h" +#include "snes_palette.h" +#include +#include +#include +#include + +#include #include #include +#include +#include +#include + namespace yaze { namespace app { @@ -57,7 +67,7 @@ SNESPalette::SNESPalette(const unsigned char* snes_pal) { size_ = sizeof(snes_pal) / 2; for (unsigned i = 0; i < sizeof(snes_pal); i += 2) { SNESColor col; - col.snes = snes_pal[i + 1] << (uint16_t) 8; + col.snes = snes_pal[i + 1] << (uint16_t)8; col.snes = col.snes | snes_pal[i]; m_color mColor = convertcolor_snes_to_rgb(col.snes); col.rgb = ImVec4(mColor.red, mColor.green, mColor.blue, 1.f); diff --git a/src/app/gfx/palette.h b/src/app/gfx/snes_palette.h similarity index 91% rename from src/app/gfx/palette.h rename to src/app/gfx/snes_palette.h index 4b077e13..3c8759f1 100644 --- a/src/app/gfx/palette.h +++ b/src/app/gfx/snes_palette.h @@ -7,6 +7,8 @@ #include #include +#include +#include #include #include #include diff --git a/src/app/gfx/tile.cc b/src/app/gfx/tile.cc index 5008de14..0212e62b 100644 --- a/src/app/gfx/tile.cc +++ b/src/app/gfx/tile.cc @@ -13,8 +13,8 @@ #include #include -#include "app/core/constants.h" -#include "app/gfx/palette.h" +#include "app/gfx/snes_palette.h" + namespace yaze { namespace app { diff --git a/src/app/gfx/tile.h b/src/app/gfx/tile.h index 75477145..dcf5769e 100644 --- a/src/app/gfx/tile.h +++ b/src/app/gfx/tile.h @@ -14,13 +14,17 @@ #include #include -#include "app/core/constants.h" -#include "app/gfx/palette.h" +#include "app/gfx/snes_palette.h" namespace yaze { namespace app { namespace gfx { +using ushort = unsigned short; +using uchar = unsigned char; +using ulong = unsigned long; +using uint = unsigned int; + // vhopppcc cccccccc // [0, 1] // [2, 3] diff --git a/src/app/rom.cc b/src/app/rom.cc index 6949f650..81ed031c 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -18,7 +18,7 @@ namespace yaze { namespace app { - +namespace rom { int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3) { return (addr1 << 16) | (addr2 << 8) | addr3; } @@ -301,6 +301,6 @@ SDL_Texture *ROM::DrawgfxSheet(int offset) { } return sheet_texture; } - +} // namespace rom } // namespace app } // namespace yaze \ No newline at end of file diff --git a/src/app/rom.h b/src/app/rom.h index d49575f7..f7b444f6 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -19,7 +19,7 @@ namespace yaze { namespace app { - +namespace rom { int AddressFromBytes(uchar addr1, uchar addr2, uchar addr3); class ROM { @@ -68,6 +68,7 @@ class ROM { std::shared_ptr sdl_renderer_; }; +} // namespace rom } // namespace app } // namespace yaze diff --git a/src/app/zelda3/overworld.cc b/src/app/zelda3/overworld.cc index 8c7d1da9..8e989bab 100644 --- a/src/app/zelda3/overworld.cc +++ b/src/app/zelda3/overworld.cc @@ -1,7 +1,7 @@ #include "overworld.h" -#include "gfx/tile.h" -#include "rom.h" +#include "app/gfx/tile.h" +#include "app/rom.h" namespace yaze { namespace app { @@ -41,7 +41,7 @@ static TileInfo GetTilesInfo(ushort tile) { return TileInfo(tid, p, v, h, o); } -void Overworld::Load(ROM& rom) { +void Overworld::Load(app::rom::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 a246806a..ca2a9d02 100644 --- a/src/app/zelda3/overworld.h +++ b/src/app/zelda3/overworld.h @@ -6,11 +6,11 @@ #include #include -#include "Core/constants.h" -#include "gfx/bitmap.h" -#include "gfx/tile.h" -#include "overworld_map.h" -#include "rom.h" +#include "app/core/constants.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/tile.h" +#include "app/rom.h" +#include "app/zelda3/overworld_map.h" namespace yaze { namespace app { @@ -21,7 +21,7 @@ class Overworld { Overworld() = default; ~Overworld(); - void Load(ROM& rom); + void Load(app::rom::ROM& rom); char* overworldMapPointer = new char[0x40000]; gfx::Bitmap* overworldMapBitmap; @@ -30,7 +30,7 @@ class Overworld { gfx::Bitmap* owactualMapBitmap; private: - ROM rom_; + app::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 2749c249..56937540 100644 --- a/src/app/zelda3/overworld_map.cc +++ b/src/app/zelda3/overworld_map.cc @@ -1,7 +1,11 @@ #include "overworld_map.h" -#include "gfx/tile.h" -#include "rom.h" +#include +#include + +#include "app/gfx/bitmap.h" +#include "app/gfx/tile.h" +#include "app/rom.h" namespace yaze { namespace app { @@ -10,7 +14,7 @@ namespace zelda3 { using namespace core; using namespace gfx; -OverworldMap::OverworldMap(ROM& rom, const std::vector tiles16, +OverworldMap::OverworldMap(app::rom::ROM& rom, const std::vector tiles16, uchar index) : rom_(rom), index(index), tiles16_(tiles16), parent(index) { if (index != 0x80) { diff --git a/src/app/zelda3/overworld_map.h b/src/app/zelda3/overworld_map.h index a91c6174..799b4576 100644 --- a/src/app/zelda3/overworld_map.h +++ b/src/app/zelda3/overworld_map.h @@ -3,9 +3,9 @@ #include #include -#include "gfx/bitmap.h" -#include "gfx/tile.h" -#include "rom.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/tile.h" +#include "app/rom.h" namespace yaze { namespace app { @@ -37,12 +37,12 @@ class OverworldMap { ushort** tilesUsed; bool needRefresh = false; - ROM rom_; + app::rom::ROM rom_; uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2]; std::vector tiles16_; - OverworldMap(ROM& rom, const std::vector tiles16, uchar index); + OverworldMap(app::rom::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 46247706..d396c39c 100644 --- a/src/gui/editor/editor.cc +++ b/src/gui/editor/editor.cc @@ -6,13 +6,13 @@ #include #include -#include "core/constants.h" -#include "gfx/palette.h" -#include "gfx/tile.h" +#include "app/core/constants.h" +#include "app/gfx/snes_palette.h" +#include "app/gfx/tile.h" +#include "app/rom.h" #include "gui/editor/overworld_editor.h" #include "gui/icons.h" #include "gui/input.h" -#include "rom.h" namespace yaze { namespace gui { @@ -518,6 +518,6 @@ void Editor::DrawHUDEditor() { } } -} // namespace Editor -} // namespace app +} // namespace editor +} // namespace gui } // namespace yaze \ No newline at end of file diff --git a/src/gui/editor/editor.h b/src/gui/editor/editor.h index 9bb15ec7..982c3786 100644 --- a/src/gui/editor/editor.h +++ b/src/gui/editor/editor.h @@ -7,12 +7,12 @@ #include #include -#include "core/constants.h" -#include "gfx/tile.h" +#include "app/core/constants.h" +#include "app/gfx/tile.h" +#include "app/rom.h" #include "gui/editor/overworld_editor.h" #include "gui/icons.h" #include "gui/input.h" -#include "rom.h" namespace yaze { namespace gui { @@ -45,7 +45,7 @@ class Editor { void *rom_data_; bool is_loaded_ = true; - app::ROM rom_; + app::rom::ROM rom_; TextEditor asm_editor_; TextEditor::LanguageDefinition language_65816_; OverworldEditor overworld_editor_; @@ -66,7 +66,7 @@ class Editor { }; } // namespace editor -} // namespace app +} // namespace gui } // namespace yaze #endif // YAZE_APP_VIEW_EDITOR_H \ No newline at end of file diff --git a/src/gui/editor/overworld_editor.cc b/src/gui/editor/overworld_editor.cc index f339eaf6..217ff901 100644 --- a/src/gui/editor/overworld_editor.cc +++ b/src/gui/editor/overworld_editor.cc @@ -4,11 +4,12 @@ #include -#include "gfx/bitmap.h" -#include "gfx/tile.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/snes_palette.h" +#include "app/gfx/tile.h" +#include "app/zelda3/overworld.h" #include "gui/icons.h" - // first step would be to decompress all gfx data from the game // (in alttp that's easy they're all located in the same location all the // same sheet size 128x32) have a code that convert PC address to SNES and @@ -31,7 +32,7 @@ namespace yaze { namespace gui { namespace editor { -void OverworldEditor::SetupROM(app::ROM &rom) { rom_ = rom; } +void OverworldEditor::SetupROM(app::rom::ROM &rom) { rom_ = rom; } void OverworldEditor::Update() { if (rom_.isLoaded()) { @@ -377,6 +378,6 @@ void OverworldEditor::Loadgfx() { } } -} // namespace Editor -} // namespace app +} // namespace editor +} // namespace gui } // namespace yaze \ No newline at end of file diff --git a/src/gui/editor/overworld_editor.h b/src/gui/editor/overworld_editor.h index 0d3eb618..b8dbcbe2 100644 --- a/src/gui/editor/overworld_editor.h +++ b/src/gui/editor/overworld_editor.h @@ -1,12 +1,13 @@ #ifndef YAZE_APP_EDITOR_OVERWORLDEDITOR_H #define YAZE_APP_EDITOR_OVERWORLDEDITOR_H -#include +#include -#include "gfx/palette.h" -#include "gfx/tile.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/snes_palette.h" +#include "app/gfx/tile.h" +#include "app/zelda3/overworld.h" #include "gui/icons.h" -#include "zelda3/overworld.h" namespace yaze { namespace gui { @@ -16,7 +17,7 @@ static constexpr unsigned int k4BPP = 4; class OverworldEditor { public: - void SetupROM(app::ROM &rom); + void SetupROM(app::rom::ROM &rom); void Update(); private: @@ -29,7 +30,7 @@ class OverworldEditor { void Loadgfx(); - app::ROM rom_; + app::rom::ROM rom_; app::zelda3::Overworld overworld_; app::gfx::Bitmap allgfxBitmap; app::gfx::SNESPalette palette_; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 03e946c8..f62fbadd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -19,7 +19,7 @@ add_executable( ../src/app/rom.cc ../src/app/gfx/tile.cc ../src/app/gfx/tile.cc - ../src/app/gfx/palette.cc + ../src/app/gfx/snes_palette.cc ${SNESHACKING_PATH}/compressions/alttpcompression.c ${SNESHACKING_PATH}/compressions/stdnintendo.c ${SNESHACKING_PATH}/tile.c