diff --git a/src/app/core/constants.h b/src/app/core/constants.h index 4388ecc4..e77af32f 100644 --- a/src/app/core/constants.h +++ b/src/app/core/constants.h @@ -28,6 +28,7 @@ namespace constants { //=========================================================================================== // 65816 LanguageDefinition //=========================================================================================== + static const char *const kKeywords[] = { "ADC", "AND", "ASL", "BCC", "BCS", "BEQ", "BIT", "BMI", "BNE", "BPL", "BRA", "BRL", "BVC", "BVS", "CLC", "CLD", "CLI", "CLV", diff --git a/src/app/core/controller.cc b/src/app/core/controller.cc index 35776ba7..eaa7feb9 100644 --- a/src/app/core/controller.cc +++ b/src/app/core/controller.cc @@ -71,7 +71,6 @@ void Controller::onInput() { case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_CLOSE: - editor_.Shutdown(); quit(); break; case SDL_WINDOWEVENT_SIZE_CHANGED: diff --git a/src/app/core/controller.h b/src/app/core/controller.h index e1b45220..515d56fd 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -45,7 +45,7 @@ class Controller { }; bool active_; - gui::editor::Editor editor_; + app::editor::Editor editor_; std::shared_ptr sdl_window_; std::shared_ptr sdl_renderer_; }; diff --git a/src/app/editor/editor.cc b/src/app/editor/editor.cc index 0a45109c..cc093a15 100644 --- a/src/app/editor/editor.cc +++ b/src/app/editor/editor.cc @@ -15,7 +15,7 @@ #include "gui/input.h" namespace yaze { -namespace gui { +namespace app { namespace editor { Editor::Editor() { @@ -125,8 +125,6 @@ void Editor::UpdateScreen() { ImGui::End(); } -void Editor::Shutdown() {} - void Editor::DrawYazeMenu() { MENU_BAR() DrawFileMenu(); @@ -276,6 +274,7 @@ void Editor::DrawViewMenu() { void Editor::DrawHelpMenu() const { if (ImGui::BeginMenu("Help")) { if (ImGui::MenuItem("About")) { + // insert the about window here } ImGui::EndMenu(); } @@ -297,10 +296,10 @@ void Editor::DrawGraphicsSheet(int offset) { unsigned int snesAddr = 0; unsigned int pcAddr = 0; - snesAddr = (unsigned int)((((uchar)(rom_.data()[0x4F80 + offset]) << 16) | - ((uchar)(rom_.data()[0x505F + offset]) << 8) | - ((uchar)(rom_.data()[0x513E + offset])))); - pcAddr = rom_.SnesToPc(snesAddr); + snesAddr = (unsigned int)((((rom_.data()[0x4F80 + offset]) << 16) | + ((rom_.data()[0x505F + offset]) << 8) | + ((rom_.data()[0x513E + offset])))); + pcAddr = core::SnesToPc(snesAddr); std::cout << "Decompressing..." << std::endl; char *decomp = rom_.Decompress(pcAddr); std::cout << "Converting to 8bpp sheet..." << std::endl; @@ -338,7 +337,7 @@ void Editor::DrawProjectEditor() { for (int i = 0; i < 8; i++) { std::string id = "##PaletteColor" + std::to_string(i); ImGui::SameLine(); - ImGui::ColorEdit4(id.c_str(), (float *)¤t_palette_[i].x, + ImGui::ColorEdit4(id.c_str(), ¤t_palette_[i].x, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHex); @@ -521,5 +520,5 @@ void Editor::DrawHUDEditor() { } } // namespace editor -} // namespace gui +} // namespace app } // namespace yaze \ No newline at end of file diff --git a/src/app/editor/editor.h b/src/app/editor/editor.h index 52c2c693..a352bb29 100644 --- a/src/app/editor/editor.h +++ b/src/app/editor/editor.h @@ -15,7 +15,7 @@ #include "gui/input.h" namespace yaze { -namespace gui { +namespace app { namespace editor { class Editor { @@ -24,7 +24,6 @@ class Editor { ~Editor(); void SetupScreen(std::shared_ptr renderer); void UpdateScreen(); - void Shutdown(); private: void DrawYazeMenu(); diff --git a/src/app/editor/overworld_editor.cc b/src/app/editor/overworld_editor.cc index 7286d9ff..3f782c24 100644 --- a/src/app/editor/overworld_editor.cc +++ b/src/app/editor/overworld_editor.cc @@ -29,7 +29,7 @@ // have an overworld map viewer, in less than few hours if are able to // understand the data quickly namespace yaze { -namespace gui { +namespace app { namespace editor { void OverworldEditor::SetupROM(app::rom::ROM &rom) { rom_ = rom; } diff --git a/src/app/editor/overworld_editor.h b/src/app/editor/overworld_editor.h index 2de07c81..bb513596 100644 --- a/src/app/editor/overworld_editor.h +++ b/src/app/editor/overworld_editor.h @@ -10,7 +10,7 @@ #include "gui/icons.h" namespace yaze { -namespace gui { +namespace app { namespace editor { static constexpr unsigned int k4BPP = 4; diff --git a/src/app/gfx/snes_palette.cc b/src/app/gfx/snes_palette.cc index de8daf19..53e72506 100644 --- a/src/app/gfx/snes_palette.cc +++ b/src/app/gfx/snes_palette.cc @@ -12,7 +12,6 @@ #include #include - namespace yaze { namespace app { namespace gfx { @@ -49,9 +48,8 @@ SNESPalette::SNESPalette(uint8_t mSize) : size_(mSize) { } } -SNESPalette::SNESPalette(char* data) { +SNESPalette::SNESPalette(char* data) : size_(sizeof(data) / 2) { assert((sizeof(data) % 4 == 0) && (sizeof(data) <= 32)); - size_ = sizeof(data) / 2; for (unsigned i = 0; i < sizeof(data); i += 2) { SNESColor col; col.snes = static_cast(data[i + 1]) << 8; @@ -62,9 +60,8 @@ SNESPalette::SNESPalette(char* data) { } } -SNESPalette::SNESPalette(const unsigned char* snes_pal) { +SNESPalette::SNESPalette(const unsigned char* snes_pal) : size_(sizeof(snes_pal) / 2) { assert((sizeof(snes_pal) % 4 == 0) && (sizeof(snes_pal) <= 32)); - 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; @@ -75,7 +72,7 @@ SNESPalette::SNESPalette(const unsigned char* snes_pal) { } } -SNESPalette::SNESPalette(std::vector cols) { +SNESPalette::SNESPalette(const std::vector & cols) { for (const auto& each : cols) { SNESColor scol; scol.setRgb(each); @@ -85,10 +82,9 @@ SNESPalette::SNESPalette(std::vector cols) { } char* SNESPalette::encode() { - // char* data(size * 2, 0); char* data = new char[size_ * 2]; for (unsigned int i = 0; i < size_; i++) { - // std::cout << QString::number(colors[i].snes, 16); + std::cout << colors[i].snes << std::endl; data[i * 2] = (char)(colors[i].snes & 0xFF); data[i * 2 + 1] = (char)(colors[i].snes >> 8); } @@ -100,20 +96,20 @@ SDL_Palette* SNESPalette::GetSDL_Palette() { auto sdl_palette = std::make_shared(); sdl_palette->ncolors = size_; - auto* sdl_colors = new SDL_Color[size_]; + auto color = std::vector(size_); for (int i = 0; i < size_; i++) { - sdl_colors[i].r = (uint8_t)colors[i].rgb.x * 100; - sdl_colors[i].g = (uint8_t)colors[i].rgb.y * 100; - sdl_colors[i].b = (uint8_t)colors[i].rgb.z * 100; - std::cout << "Color " << i << " added (R:" << sdl_colors[i].r - << " G:" << sdl_colors[i].g << " B:" << sdl_colors[i].b << ")" + color[i].r = (uint8_t)colors[i].rgb.x * 100; + color[i].g = (uint8_t)colors[i].rgb.y * 100; + color[i].b = (uint8_t)colors[i].rgb.z * 100; + std::cout << "Color " << i << " added (R:" << color[i].r + << " G:" << color[i].g << " B:" << color[i].b << ")" << std::endl; } - sdl_palette->colors = sdl_colors; + sdl_palette->colors = color.data(); // store the pointers to free them later sdl_palettes_.push_back(sdl_palette); - colors_arrays_.push_back(sdl_colors); + colors_.push_back(color); return sdl_palette.get(); } diff --git a/src/app/gfx/snes_palette.h b/src/app/gfx/snes_palette.h index 3c8759f1..7d945936 100644 --- a/src/app/gfx/snes_palette.h +++ b/src/app/gfx/snes_palette.h @@ -34,7 +34,7 @@ class SNESPalette { explicit SNESPalette(uint8_t mSize); explicit SNESPalette(char* snesPal); explicit SNESPalette(const unsigned char* snes_pal); - explicit SNESPalette(std::vector); + explicit SNESPalette(const std::vector&); char* encode(); SDL_Palette* GetSDL_Palette(); @@ -43,6 +43,7 @@ class SNESPalette { std::vector colors; std::vector> sdl_palettes_; std::vector colors_arrays_; + std::vector> colors_; }; } // namespace gfx diff --git a/src/app/gfx/tile.h b/src/app/gfx/tile.h index 5c048b74..cbca3e7f 100644 --- a/src/app/gfx/tile.h +++ b/src/app/gfx/tile.h @@ -2,7 +2,6 @@ #define YAZE_APP_GFX_TILE_H #include -#include #include #include @@ -22,6 +21,12 @@ namespace yaze { namespace app { namespace gfx { +typedef struct { + unsigned int id; + char data[64]; + unsigned int palette_id; +} tile8; + using ushort = unsigned short; using uchar = unsigned char; using ulong = unsigned long; diff --git a/src/app/zelda3/overworld.cc b/src/app/zelda3/overworld.cc index 93fccf19..cde00ef2 100644 --- a/src/app/zelda3/overworld.cc +++ b/src/app/zelda3/overworld.cc @@ -29,9 +29,9 @@ void Overworld::Load(app::rom::ROM& rom, uchar* allGfxPtr) { rom_ = rom; allGfx16Ptr = allGfxPtr; - overworldMapPointer = std::make_shared(0x40000); - mapblockset16 = std::make_shared(1048576); - currentOWgfx16Ptr = std::make_shared((128 * 512) / 2); + overworldMapPointer = std::make_shared(0x40000); + mapblockset16 = std::make_shared(1048576); + currentOWgfx16Ptr = std::make_shared((128 * 512) / 2); AssembleMap32Tiles(); AssembleMap16Tiles(); diff --git a/src/app/zelda3/overworld_map.h b/src/app/zelda3/overworld_map.h index 1f8b4c84..86a52595 100644 --- a/src/app/zelda3/overworld_map.h +++ b/src/app/zelda3/overworld_map.h @@ -15,13 +15,13 @@ using ushort = unsigned short; class OverworldMap { public: - int parent_ = 0; - int index_ = 0; - int message_id_ = 0; - int gfx_ = 0; - int palette_ = 0; - bool initialized_ = false; - bool large_map_ = false; + int parent_ = 0; + int index_ = 0; + int message_id_ = 0; + int gfx_ = 0; + int palette_ = 0; + bool initialized_ = false; + bool large_map_ = false; uchar sprite_graphics_[3]; uchar sprite_palette_[3]; uchar musics[4];