diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b73268a..d8bad67c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,9 +38,9 @@ add_executable( application/Data/rom.cc application/Data/OW/overworld.cc application/Data/OW/overworld_map.cc - application/Graphics/bitmap.cc - application/Graphics/tile.cc - application/Graphics/palette.cc + application/gfx/bitmap.cc + application/gfx/tile.cc + application/gfx/palette.cc application/Editor/editor.cc application/Editor/overworld_editor.cc # GUI libraries diff --git a/src/application/Data/OW/overworld.cc b/src/application/Data/OW/overworld.cc index cc7bec82..0c047463 100644 --- a/src/application/Data/OW/overworld.cc +++ b/src/application/Data/OW/overworld.cc @@ -1,13 +1,13 @@ #include "overworld.h" -#include "Graphics/tile.h" +#include "gfx/tile.h" namespace yaze { namespace application { namespace Data { using namespace core; -using namespace Graphics; +using namespace gfx; Overworld::~Overworld() { if (isLoaded) { diff --git a/src/application/Data/OW/overworld.h b/src/application/Data/OW/overworld.h index 83ef55fb..8185e549 100644 --- a/src/application/Data/OW/overworld.h +++ b/src/application/Data/OW/overworld.h @@ -8,8 +8,8 @@ #include "Core/constants.h" #include "Data/rom.h" -#include "Graphics/bitmap.h" -#include "Graphics/tile.h" +#include "gfx/bitmap.h" +#include "gfx/tile.h" #include "overworld_map.h" namespace yaze { @@ -24,10 +24,10 @@ class Overworld { void Load(Data::ROM & rom); char* overworldMapPointer = new char[0x40000]; - Graphics::Bitmap* overworldMapBitmap; + gfx::Bitmap* overworldMapBitmap; char* owactualMapPointer = new char[0x40000]; - Graphics::Bitmap* owactualMapBitmap; + gfx::Bitmap* owactualMapBitmap; private: Data::ROM rom_; @@ -39,9 +39,9 @@ class Overworld { ushort** allmapsTilesDW; // 64 maps * (32*32 tiles) ushort** allmapsTilesSP; // 32 maps * (32*32 tiles) - std::vector tiles16; - std::vector tiles32; - std::vector map16tiles; + std::vector tiles16; + std::vector tiles32; + std::vector map16tiles; std::vector allmaps; diff --git a/src/application/Data/OW/overworld_map.cc b/src/application/Data/OW/overworld_map.cc index e37e463f..4aa1ebd9 100644 --- a/src/application/Data/OW/overworld_map.cc +++ b/src/application/Data/OW/overworld_map.cc @@ -1,17 +1,17 @@ #include "overworld_map.h" #include "Data/rom.h" -#include "Graphics/tile.h" +#include "gfx/tile.h" namespace yaze { namespace application { namespace Data { -using namespace Core; -using namespace Graphics; +using namespace core; +using namespace gfx; OverworldMap::OverworldMap(Data::ROM & rom, - const std::vector tiles16, + const std::vector tiles16, uchar index) : rom_(rom), index(index), tiles16_(tiles16), parent(index) { if (index != 0x80) { diff --git a/src/application/Data/OW/overworld_map.h b/src/application/Data/OW/overworld_map.h index 6e7c5699..5fe27f52 100644 --- a/src/application/Data/OW/overworld_map.h +++ b/src/application/Data/OW/overworld_map.h @@ -4,8 +4,8 @@ #include #include "Data/rom.h" -#include "Graphics/bitmap.h" -#include "Graphics/tile.h" +#include "gfx/bitmap.h" +#include "gfx/tile.h" namespace yaze { namespace application { @@ -29,8 +29,8 @@ class OverworldMap { int* gfxPtr = new int[512 * 512]; int* mapblockset16 = new int[1048576]; - Graphics::Bitmap mapblockset16Bitmap; - Graphics::Bitmap gfxBitmap; + gfx::Bitmap mapblockset16Bitmap; + gfx::Bitmap gfxBitmap; uchar* staticgfx = new uchar[16]; // Need to be used to display map and not pre render it! @@ -40,9 +40,9 @@ class OverworldMap { Data::ROM rom_; uchar* currentOWgfx16Ptr = new uchar[(128 * 512) / 2]; - std::vector tiles16_; + std::vector tiles16_; - OverworldMap(Data::ROM & rom, const std::vector tiles16, + OverworldMap(Data::ROM & rom, const std::vector tiles16, uchar index); void BuildMap(uchar* mapParent, int count, int gameState, ushort** allmapsTilesLW, ushort** allmapsTilesDW, @@ -57,10 +57,10 @@ class OverworldMap { // void ReloadPalettes() { LoadPalette(); } void CopyTile(int x, int y, int xx, int yy, int offset, - Graphics::TileInfo tile, uchar* gfx16Pointer, + gfx::TileInfo tile, uchar* gfx16Pointer, uchar* gfx8Pointer); void CopyTileToMap(int x, int y, int xx, int yy, int offset, - Graphics::TileInfo tile, uchar* gfx16Pointer, + gfx::TileInfo tile, uchar* gfx16Pointer, uchar* gfx8Pointer); void LoadPalette(); diff --git a/src/application/Data/rom.cc b/src/application/Data/rom.cc index 868854de..2fb2d8d3 100644 --- a/src/application/Data/rom.cc +++ b/src/application/Data/rom.cc @@ -44,7 +44,7 @@ void ROM::LoadFromFile(const std::string &path) { loaded = true; } -std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { +std::vector ROM::ExtractTiles(gfx::TilePreset &preset) { std::cout << "Extracting tiles..." << std::endl; uint filePos = 0; uint size_out = 0; @@ -55,7 +55,7 @@ std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { std::cout << "ROM Position: " << filePos << " from " << preset.SNESTilesLocation << std::endl; - // decompress the graphics + // decompress the gfx auto data = (char *)malloc(sizeof(char) * size); memcpy(data, (current_rom_ + filePos), size); data = alttp_decompress_gfx(data, 0, size, &size_out, &compressed_size_); @@ -82,7 +82,7 @@ std::vector ROM::ExtractTiles(Graphics::TilePreset &preset) { return rawTiles; } -Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) { +gfx::SNESPalette ROM::ExtractPalette(gfx::TilePreset &preset) { uint filePos = GetRomPosition(preset.pc_palette_location_, preset.SNESPaletteLocation); std::cout << "Palette pos : " << filePos << std::endl; // TODO: make this hex @@ -100,9 +100,9 @@ Graphics::SNESPalette ROM::ExtractPalette(Graphics::TilePreset &preset) { std::cout << std::endl; const unsigned char *data = palette_data.get(); - Graphics::SNESPalette pal(data); + gfx::SNESPalette pal(data); if (preset.no_zero_color_) { - Graphics::SNESColor col; + gfx::SNESColor col; col.setRgb(ImVec4(153, 153, 153, 255)); pal.colors.push_back(col); @@ -255,7 +255,7 @@ uchar *ROM::SNES3bppTo8bppSheet(uchar *buffer_in, return sheet_buffer_out; } -SDL_Texture *ROM::DrawGraphicsSheet(int offset) { +SDL_Texture *ROM::DrawgfxSheet(int offset) { SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, 128, 32, 8, SDL_PIXELFORMAT_INDEX8); std::cout << "Drawing surface #" << offset << std::endl; diff --git a/src/application/Data/rom.h b/src/application/Data/rom.h index ce0981d6..bdf705f0 100644 --- a/src/application/Data/rom.h +++ b/src/application/Data/rom.h @@ -14,7 +14,7 @@ #include #include "Core/constants.h" -#include "Graphics/tile.h" +#include "gfx/tile.h" namespace yaze { namespace application { @@ -28,12 +28,12 @@ class ROM { void SetupRenderer(std::shared_ptr renderer); void LoadFromFile(const std::string& path); - std::vector ExtractTiles(Graphics::TilePreset& preset); - Graphics::SNESPalette ExtractPalette(Graphics::TilePreset& preset); + std::vector ExtractTiles(gfx::TilePreset& preset); + gfx::SNESPalette ExtractPalette(gfx::TilePreset& preset); uint32_t GetRomPosition(int direct_addr, uint snes_addr) const; char* Decompress(int pos, int size = 0x800, bool reversed = false); uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0); - SDL_Texture* DrawGraphicsSheet(int offset); + SDL_Texture* DrawgfxSheet(int offset); inline uchar* GetRawData() { return current_rom_; } const uchar* getTitle() const { return title; } diff --git a/src/application/Editor/editor.cc b/src/application/Editor/editor.cc index 38d1777d..4ba9e27b 100644 --- a/src/application/Editor/editor.cc +++ b/src/application/Editor/editor.cc @@ -9,8 +9,8 @@ #include "Core/constants.h" #include "Data/rom.h" #include "Editor/overworld_editor.h" -#include "Graphics/palette.h" -#include "Graphics/tile.h" +#include "gfx/palette.h" +#include "gfx/tile.h" #include "gui/icons.h" #include "gui/input.h" @@ -117,7 +117,7 @@ void Editor::UpdateScreen() { DrawProjectEditor(); DrawOverworldEditor(); DrawDungeonEditor(); - DrawGraphicsEditor(); + DrawgfxEditor(); DrawSpriteEditor(); DrawScreenEditor(); DrawHUDEditor(); @@ -280,7 +280,7 @@ void Editor::DrawHelpMenu() const { } } -void Editor::DrawGraphicsSheet(int offset) { +void Editor::DrawgfxSheet(int offset) { SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, 128, 32, 8, SDL_PIXELFORMAT_INDEX8); std::cout << "Drawing surface" << std::endl; @@ -345,9 +345,9 @@ void Editor::DrawProjectEditor() { } ImGui::SetNextItemWidth(100.f); ImGui::InputInt("Tilesheet Offset", &tilesheet_offset); - BASIC_BUTTON("Retrieve Graphics") { + BASIC_BUTTON("Retrieve gfx") { if (rom_.isLoaded()) { - DrawGraphicsSheet(tilesheet_offset); + DrawgfxSheet(tilesheet_offset); loaded_image = true; } } @@ -496,8 +496,8 @@ void Editor::DrawDungeonEditor() { } } -void Editor::DrawGraphicsEditor() { - if (ImGui::BeginTabItem("Graphics")) { +void Editor::DrawgfxEditor() { + if (ImGui::BeginTabItem("gfx")) { ImGui::EndTabItem(); } } diff --git a/src/application/Editor/editor.h b/src/application/Editor/editor.h index db09edc3..5c1e2349 100644 --- a/src/application/Editor/editor.h +++ b/src/application/Editor/editor.h @@ -10,7 +10,7 @@ #include "Core/constants.h" #include "Data/rom.h" #include "Editor/overworld_editor.h" -#include "Graphics/tile.h" +#include "gfx/tile.h" #include "gui/icons.h" #include "gui/input.h" @@ -32,12 +32,12 @@ class Editor { void DrawViewMenu(); void DrawHelpMenu() const; - void DrawGraphicsSheet(int offset = 0); + void DrawgfxSheet(int offset = 0); void DrawProjectEditor(); void DrawOverworldEditor(); void DrawDungeonEditor(); - void DrawGraphicsEditor(); + void DrawgfxEditor(); void DrawSpriteEditor(); void DrawScreenEditor(); void DrawHUDEditor(); @@ -58,7 +58,7 @@ class Editor { OverworldEditor overworld_editor_; ImVec4 current_palette_[8]; - Graphics::TilePreset current_set_; + gfx::TilePreset current_set_; ImGuiWindowFlags main_editor_flags_ = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | diff --git a/src/application/Editor/overworld_editor.cc b/src/application/Editor/overworld_editor.cc index e00bc5a7..57c417de 100644 --- a/src/application/Editor/overworld_editor.cc +++ b/src/application/Editor/overworld_editor.cc @@ -4,11 +4,12 @@ #include -#include "Graphics/bitmap.h" -#include "Graphics/icons.h" -#include "Graphics/tile.h" +#include "gfx/bitmap.h" +#include "gfx/tile.h" +#include "gui/icons.h" -// first step would be to decompress all graphics data from the game + +// 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 // vice-versa @@ -34,10 +35,10 @@ void OverworldEditor::SetupROM(Data::ROM &rom) { rom_ = rom; } void OverworldEditor::Update() { if (rom_.isLoaded()) { - if (!all_graphics_loaded_) { - LoadGraphics(); - //overworld_.Load(rom_); - all_graphics_loaded_ = true; + if (!all_gfx_loaded_) { + Loadgfx(); + // overworld_.Load(rom_); + all_gfx_loaded_ = true; } } @@ -275,8 +276,9 @@ void OverworldEditor::DrawTileSelector() { if (ImGui::BeginTabItem("Tile8")) { ImGuiStyle &style = ImGui::GetStyle(); ImGuiID child_id = ImGui::GetID((void *)(intptr_t)1); - bool child_is_visible = ImGui::BeginChild( - child_id, ImGui::GetContentRegionAvail(), true, ImGuiWindowFlags_AlwaysVerticalScrollbar); + bool child_is_visible = + ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, + ImGuiWindowFlags_AlwaysVerticalScrollbar); if (child_is_visible) // Avoid calling SetScrollHereY when running with // culled items { @@ -328,7 +330,7 @@ void OverworldEditor::DrawTile8Selector() { ImGui::EndPopup(); } - if (all_graphics_loaded_) { + if (all_gfx_loaded_) { for (const auto &[key, value] : all_texture_sheet_) { int offset = 64 * (key + 1); int top_left_y = canvas_p0.y + 2; @@ -369,9 +371,9 @@ void OverworldEditor::DrawChangelist() { ImGui::End(); } -void OverworldEditor::LoadGraphics() { +void OverworldEditor::Loadgfx() { for (int i = 0; i < kNumSheetsToLoad; i++) { - all_texture_sheet_[i] = rom_.DrawGraphicsSheet(i); + all_texture_sheet_[i] = rom_.DrawgfxSheet(i); } } diff --git a/src/application/Editor/overworld_editor.h b/src/application/Editor/overworld_editor.h index d387f6cc..73864f56 100644 --- a/src/application/Editor/overworld_editor.h +++ b/src/application/Editor/overworld_editor.h @@ -4,8 +4,8 @@ #include #include "Data/OW/overworld.h" -#include "Graphics/palette.h" -#include "Graphics/tile.h" +#include "gfx/palette.h" +#include "gfx/tile.h" #include "gui/icons.h" @@ -28,13 +28,13 @@ class OverworldEditor { void DrawTile8Selector(); void DrawChangelist(); - void LoadGraphics(); + void Loadgfx(); Data::ROM rom_; Data::Overworld overworld_; - Graphics::Bitmap allgfxBitmap; - Graphics::SNESPalette palette_; - Graphics::TilePreset current_set_; + gfx::Bitmap allgfxBitmap; + gfx::SNESPalette palette_; + gfx::TilePreset current_set_; std::unordered_map all_texture_sheet_; SDL_Texture *gfx_texture = nullptr; @@ -58,7 +58,7 @@ class OverworldEditor { bool doneLoaded = false; bool opt_enable_grid = true; bool show_changelist_ = false; - bool all_graphics_loaded_ = false; + bool all_gfx_loaded_ = false; constexpr static int kByteSize = 3; constexpr static int kMessageIdSize = 5; diff --git a/src/application/core/constants.h b/src/application/core/constants.h index 6daac46e..27f32ea3 100644 --- a/src/application/core/constants.h +++ b/src/application/core/constants.h @@ -82,7 +82,7 @@ constexpr int NumberOfOWSprites = 352; constexpr int NumberOfColors = 3143; // =========================================================================================== -// Graphics +// gfx // =========================================================================================== constexpr int tile_address = 0x1B52; // JP = Same @@ -934,7 +934,7 @@ static const std::string Type3RoomObjectNames[] = { "Bar bottles", "Arrow game hole (west)", "Arrow game hole (east)", - "Vitreous goo graphics", + "Vitreous goo gfx", "Fake pressure plate", "Medusa head", "4-way shooter block", diff --git a/src/application/Graphics/bitmap.cc b/src/application/gfx/bitmap.cc similarity index 96% rename from src/application/Graphics/bitmap.cc rename to src/application/gfx/bitmap.cc index 5ff37dc5..3cdb6196 100644 --- a/src/application/Graphics/bitmap.cc +++ b/src/application/gfx/bitmap.cc @@ -6,7 +6,7 @@ namespace yaze { namespace application { -namespace Graphics { +namespace gfx { int GetPCGfxAddress(char *romData, char id) { char **info1 = new char *[255]; @@ -173,6 +173,6 @@ void CreateAllGfxData(char *romData, char *allgfx16Ptr) { } } -} // namespace Graphics +} // namespace gfx } // namespace application } // namespace yaze diff --git a/src/application/Graphics/bitmap.h b/src/application/gfx/bitmap.h similarity index 89% rename from src/application/Graphics/bitmap.h rename to src/application/gfx/bitmap.h index 88a3c355..b7132580 100644 --- a/src/application/Graphics/bitmap.h +++ b/src/application/gfx/bitmap.h @@ -7,7 +7,7 @@ namespace yaze { namespace application { -namespace Graphics { +namespace gfx { class Bitmap { public: @@ -30,7 +30,7 @@ int GetPCGfxAddress(char *romData, char id); char *CreateAllGfxDataRaw(char *romData); void CreateAllGfxData(char *romData, char *allgfx16Ptr); -} // namespace Graphics +} // namespace gfx } // namespace application } // namespace yaze diff --git a/src/application/Graphics/palette.cc b/src/application/gfx/palette.cc similarity index 95% rename from src/application/Graphics/palette.cc rename to src/application/gfx/palette.cc index 299f78ef..ce5ad82c 100644 --- a/src/application/Graphics/palette.cc +++ b/src/application/gfx/palette.cc @@ -5,7 +5,7 @@ namespace yaze { namespace application { -namespace Graphics { +namespace gfx { SNESColor::SNESColor() : rgb(ImVec4(0.f, 0.f, 0.f, 0.f)) {} @@ -108,6 +108,6 @@ SDL_Palette* SNESPalette::GetSDL_Palette() { return sdl_palette.get(); } -} // namespace Graphics +} // namespace gfx } // namespace application } // namespace yaze \ No newline at end of file diff --git a/src/application/Graphics/palette.h b/src/application/gfx/palette.h similarity index 79% rename from src/application/Graphics/palette.h rename to src/application/gfx/palette.h index 789a34cb..16a40a6e 100644 --- a/src/application/Graphics/palette.h +++ b/src/application/gfx/palette.h @@ -1,5 +1,5 @@ -#ifndef YAZE_APPLICATION_GRAPHICS_PALETTE_H -#define YAZE_APPLICATION_GRAPHICS_PALETTE_H +#ifndef YAZE_APPLICATION_gfx_PALETTE_H +#define YAZE_APPLICATION_gfx_PALETTE_H #include #include @@ -13,7 +13,7 @@ namespace yaze { namespace application { -namespace Graphics { +namespace gfx { struct SNESColor { SNESColor(); @@ -43,8 +43,8 @@ class SNESPalette { std::vector colors_arrays_; }; -} // namespace Graphics +} // namespace gfx } // namespace application } // namespace yaze -#endif // YAZE_APPLICATION_GRAPHICS_PALETTE_H \ No newline at end of file +#endif // YAZE_APPLICATION_gfx_PALETTE_H \ No newline at end of file diff --git a/src/application/Graphics/tile.cc b/src/application/gfx/tile.cc similarity index 95% rename from src/application/Graphics/tile.cc rename to src/application/gfx/tile.cc index 9c8b56e3..038e68eb 100644 --- a/src/application/Graphics/tile.cc +++ b/src/application/gfx/tile.cc @@ -10,7 +10,7 @@ namespace yaze { namespace application { -namespace Graphics { +namespace gfx { TilesPattern::TilesPattern() { tiles_per_row_ = 16; @@ -108,6 +108,6 @@ std::vector > TilesPattern::transform( return pattern.transform(tiles); } -} // namespace Graphics +} // namespace gfx } // namespace application } // namespace yaze diff --git a/src/application/Graphics/tile.h b/src/application/gfx/tile.h similarity index 92% rename from src/application/Graphics/tile.h rename to src/application/gfx/tile.h index b7a225af..e1734cca 100644 --- a/src/application/Graphics/tile.h +++ b/src/application/gfx/tile.h @@ -9,11 +9,11 @@ #include #include "Core/constants.h" -#include "Graphics/palette.h" +#include "gfx/palette.h" namespace yaze { namespace application { -namespace Graphics { +namespace gfx { // vhopppcc cccccccc // [0, 1] @@ -96,7 +96,7 @@ class TilePreset { int SNESPaletteLocation = 0; }; -} // namespace Graphics +} // namespace gfx } // namespace application } // namespace yaze diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3b2dc674..e0061b74 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,9 +17,9 @@ add_executable( yaze_test yaze_test.cc ../src/application/Data/rom.cc - ../src/application/Graphics/tile.cc - ../src/application/Graphics/tile.cc - ../src/application/Graphics/palette.cc + ../src/application/gfx/tile.cc + ../src/application/gfx/tile.cc + ../src/application/gfx/palette.cc ${SNESHACKING_PATH}/compressions/alttpcompression.c ${SNESHACKING_PATH}/compressions/stdnintendo.c ${SNESHACKING_PATH}/tile.c