diff --git a/src/app/asm/script.cc b/src/app/asm/script.cc new file mode 100644 index 00000000..1533d54c --- /dev/null +++ b/src/app/asm/script.cc @@ -0,0 +1,36 @@ +#include "script.h" + +#include + +#include +#include +#include + +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "app/core/constants.h" + +namespace yaze { +namespace app { +namespace snes_asm { + +absl::StatusOr GenerateMosaicChangeAssembly( + MosaicArray mosaic_tiles) { + std::fstream file("assets/asm/mosaic_change.asm", + std::ios::out | std::ios::in); + if (!file.is_open()) { + return absl::InvalidArgumentError( + "Couldn't open mosaic change template file"); + } + std::stringstream assembly; + + assembly << absl::StrCat("org ", kDefaultMosaicHook); + assembly << file.rdbuf(); + + file.close(); + return assembly.str(); +} + +} // namespace snes_asm +} // namespace app +} // namespace yaze \ No newline at end of file diff --git a/src/app/asm/script.h b/src/app/asm/script.h new file mode 100644 index 00000000..ccf66655 --- /dev/null +++ b/src/app/asm/script.h @@ -0,0 +1,28 @@ +#ifndef YAZE_APP_ASM_SCRIPT_H +#define YAZE_APP_ASM_SCRIPT_H + +#include + +#include +#include +#include + +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "app/core/constants.h" + +namespace yaze { +namespace app { +namespace snes_asm { + +using MosaicArray = std::array; +constexpr char kDefaultMosaicHook[] = "$02AADB"; + +absl::StatusOr GenerateMosaicChangeAssembly( + MosaicArray mosaic_tiles); + +} // namespace snes_asm +} // namespace app +} // namespace yaze + +#endif \ No newline at end of file diff --git a/src/app/editor/screen_editor.cc b/src/app/editor/screen_editor.cc index f60428f6..92096ed7 100644 --- a/src/app/editor/screen_editor.cc +++ b/src/app/editor/screen_editor.cc @@ -10,6 +10,7 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include "app/asm/script.h" #include "app/core/common.h" #include "app/core/constants.h" #include "app/gfx/bitmap.h" @@ -20,27 +21,6 @@ namespace yaze { namespace app { namespace editor { -namespace { - -absl::StatusOr GenerateMosaicChangeAssembly( - MosaicArray mosaic_tiles) { - std::fstream file("assets/asm/mosaic_change.asm", - std::ios::out | std::ios::in); - if (!file.is_open()) { - return absl::InvalidArgumentError( - "Couldn't open mosaic change template file"); - } - std::stringstream assembly; - - assembly << absl::StrCat("org ", kDefaultMosaicHook); - assembly << file.rdbuf(); - - file.close(); - return assembly.str(); -} - -} // namespace - ScreenEditor::ScreenEditor() { screen_canvas_.SetCanvasSize(ImVec2(512, 512)); } void ScreenEditor::Update() { @@ -58,7 +38,7 @@ void ScreenEditor::Update() { void ScreenEditor::DrawMosaicEditor() { TAB_ITEM("Mosaic Transitions") if (ImGui::Button("GenerateMosaicChangeAssembly")) { - auto mosaic = GenerateMosaicChangeAssembly(mosaic_tiles_); + auto mosaic = snes_asm::GenerateMosaicChangeAssembly(mosaic_tiles_); if (!mosaic.ok()) { std::cout << "Failed to generate mosaic change assembly"; } else { diff --git a/src/app/editor/screen_editor.h b/src/app/editor/screen_editor.h index c4f17545..be92104a 100644 --- a/src/app/editor/screen_editor.h +++ b/src/app/editor/screen_editor.h @@ -3,6 +3,7 @@ #include +#include "app/asm/script.h" #include "app/gfx/bitmap.h" #include "app/gfx/snes_tile.h" #include "app/zelda3/screen.h" @@ -13,7 +14,6 @@ namespace app { namespace editor { using MosaicArray = std::array; -constexpr char kDefaultMosaicHook[] = "$02AADB"; class ScreenEditor { public: @@ -32,7 +32,7 @@ class ScreenEditor { void DrawCanvas(); void DrawToolset(); - MosaicArray mosaic_tiles_; + snes_asm::MosaicArray mosaic_tiles_; zelda3::Screen current_screen_; gui::Canvas screen_canvas_;