Create snes_asm namespace for MosaicEditor code
This commit is contained in:
36
src/app/asm/script.cc
Normal file
36
src/app/asm/script.cc
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include "script.h"
|
||||||
|
|
||||||
|
#include <asar.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#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<absl::string_view> 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
|
||||||
28
src/app/asm/script.h
Normal file
28
src/app/asm/script.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef YAZE_APP_ASM_SCRIPT_H
|
||||||
|
#define YAZE_APP_ASM_SCRIPT_H
|
||||||
|
|
||||||
|
#include <asar.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#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<int, core::kNumOverworldMaps>;
|
||||||
|
constexpr char kDefaultMosaicHook[] = "$02AADB";
|
||||||
|
|
||||||
|
absl::StatusOr<absl::string_view> GenerateMosaicChangeAssembly(
|
||||||
|
MosaicArray mosaic_tiles);
|
||||||
|
|
||||||
|
} // namespace snes_asm
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "app/asm/script.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
@@ -20,27 +21,6 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
absl::StatusOr<absl::string_view> 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)); }
|
ScreenEditor::ScreenEditor() { screen_canvas_.SetCanvasSize(ImVec2(512, 512)); }
|
||||||
|
|
||||||
void ScreenEditor::Update() {
|
void ScreenEditor::Update() {
|
||||||
@@ -58,7 +38,7 @@ void ScreenEditor::Update() {
|
|||||||
void ScreenEditor::DrawMosaicEditor() {
|
void ScreenEditor::DrawMosaicEditor() {
|
||||||
TAB_ITEM("Mosaic Transitions")
|
TAB_ITEM("Mosaic Transitions")
|
||||||
if (ImGui::Button("GenerateMosaicChangeAssembly")) {
|
if (ImGui::Button("GenerateMosaicChangeAssembly")) {
|
||||||
auto mosaic = GenerateMosaicChangeAssembly(mosaic_tiles_);
|
auto mosaic = snes_asm::GenerateMosaicChangeAssembly(mosaic_tiles_);
|
||||||
if (!mosaic.ok()) {
|
if (!mosaic.ok()) {
|
||||||
std::cout << "Failed to generate mosaic change assembly";
|
std::cout << "Failed to generate mosaic change assembly";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
#include "app/asm/script.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/zelda3/screen.h"
|
#include "app/zelda3/screen.h"
|
||||||
@@ -13,7 +14,6 @@ namespace app {
|
|||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
||||||
constexpr char kDefaultMosaicHook[] = "$02AADB";
|
|
||||||
|
|
||||||
class ScreenEditor {
|
class ScreenEditor {
|
||||||
public:
|
public:
|
||||||
@@ -32,7 +32,7 @@ class ScreenEditor {
|
|||||||
void DrawCanvas();
|
void DrawCanvas();
|
||||||
void DrawToolset();
|
void DrawToolset();
|
||||||
|
|
||||||
MosaicArray mosaic_tiles_;
|
snes_asm::MosaicArray mosaic_tiles_;
|
||||||
|
|
||||||
zelda3::Screen current_screen_;
|
zelda3::Screen current_screen_;
|
||||||
gui::Canvas screen_canvas_;
|
gui::Canvas screen_canvas_;
|
||||||
|
|||||||
Reference in New Issue
Block a user