Improve Script and added ApplyPatchToROM with Asar
This commit is contained in:
@@ -1,19 +1,28 @@
|
|||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
#include <asar.h>
|
#include <interface-lib.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace snes_asm {
|
namespace snes_asm {
|
||||||
|
|
||||||
|
absl::Status Script::ApplyPatchToROM(ROM& rom) {
|
||||||
|
if (!asar_patch(patch_filename_, rom_.data(), patch_size_, rom_.size())) {
|
||||||
|
return absl::InternalError("Unable to apply patch");
|
||||||
|
}
|
||||||
|
return absl::OkStatus();
|
||||||
|
}
|
||||||
|
|
||||||
absl::StatusOr<absl::string_view> Script::GenerateMosaicChangeAssembly(
|
absl::StatusOr<absl::string_view> Script::GenerateMosaicChangeAssembly(
|
||||||
std::array<int, core::kNumOverworldMaps> mosaic_tiles) {
|
std::array<int, core::kNumOverworldMaps> mosaic_tiles) {
|
||||||
std::fstream file("assets/asm/mosaic_change.asm",
|
std::fstream file("assets/asm/mosaic_change.asm",
|
||||||
@@ -23,8 +32,8 @@ absl::StatusOr<absl::string_view> Script::GenerateMosaicChangeAssembly(
|
|||||||
"Couldn't open mosaic change template file");
|
"Couldn't open mosaic change template file");
|
||||||
}
|
}
|
||||||
std::stringstream assembly;
|
std::stringstream assembly;
|
||||||
|
assembly << "org ";
|
||||||
assembly << absl::StrCat("org ", kDefaultMosaicHook);
|
assembly << kDefaultMosaicHook;
|
||||||
assembly << file.rdbuf();
|
assembly << file.rdbuf();
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
#ifndef YAZE_APP_ASM_SCRIPT_H
|
#ifndef YAZE_APP_ASM_SCRIPT_H
|
||||||
#define YAZE_APP_ASM_SCRIPT_H
|
#define YAZE_APP_ASM_SCRIPT_H
|
||||||
|
|
||||||
#include <asar.h>
|
#include <interface-lib.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -19,8 +21,17 @@ constexpr char kDefaultMosaicHook[] = "$02AADB";
|
|||||||
|
|
||||||
class Script {
|
class Script {
|
||||||
public:
|
public:
|
||||||
|
Script() = default;
|
||||||
|
|
||||||
|
absl::Status ApplyPatchToROM(ROM& rom);
|
||||||
|
|
||||||
absl::StatusOr<absl::string_view> GenerateMosaicChangeAssembly(
|
absl::StatusOr<absl::string_view> GenerateMosaicChangeAssembly(
|
||||||
std::array<int, core::kNumOverworldMaps> mosaic_tiles);
|
std::array<int, core::kNumOverworldMaps> mosaic_tiles);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int64_t patch_size_;
|
||||||
|
std::string patch_filename_;
|
||||||
|
std::string patch_contents_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace snes_asm
|
} // namespace snes_asm
|
||||||
|
|||||||
Reference in New Issue
Block a user