From b510ad3fc662b300fd7a0c5ccd3d451163c15ba3 Mon Sep 17 00:00:00 2001 From: Justin Scofield <47263509+scawful@users.noreply.github.com> Date: Sun, 7 Aug 2022 13:25:34 -0400 Subject: [PATCH] feat: add initial hook parameter with default val * untested --- src/app/asm/script.cc | 19 +++++++++++++++---- src/app/asm/script.h | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/app/asm/script.cc b/src/app/asm/script.cc index 6203353f..e65c94c6 100644 --- a/src/app/asm/script.cc +++ b/src/app/asm/script.cc @@ -76,7 +76,8 @@ absl::Status Script::ApplyPatchToROM(ROM &rom) { } absl::Status Script::GenerateMosaicChangeAssembly( - ROM &rom, char mosaic_tiles[core::kNumOverworldMaps], int routine_offset) { + ROM &rom, char mosaic_tiles[core::kNumOverworldMaps], int routine_offset, + int hook_offset) { std::fstream file("assets/asm/mosaic_change.asm", std::ios::out | std::ios::in); if (!file.is_open()) { @@ -89,9 +90,19 @@ absl::Status Script::GenerateMosaicChangeAssembly( file.close(); auto assembly_string = assembly.str(); - if (!string_replace(assembly_string, "", kMosaicChangeOffset)) { - return absl::InternalError( - "Mosaic template did not have proper `` to replace."); + + if (!hook_offset) { + // TODO: TESTME + if (!string_replace(assembly_string, "", + absl::StrFormat("$%06x", hook_offset))) { + return absl::InternalError( + "Mosaic template did not have proper `` to replace."); + } + } else { + if (!string_replace(assembly_string, "", kMosaicChangeOffset)) { + return absl::InternalError( + "Mosaic template did not have proper `` to replace."); + } } if (!string_replace( diff --git a/src/app/asm/script.h b/src/app/asm/script.h index e5edcfe9..c0eb30ac 100644 --- a/src/app/asm/script.h +++ b/src/app/asm/script.h @@ -28,7 +28,8 @@ class Script { Script() { asar_init_with_dll_path("assets/libasar.dll"); } absl::Status GenerateMosaicChangeAssembly( - ROM& rom, char mosaic_tiles[core::kNumOverworldMaps], int routine_offset); + ROM& rom, char mosaic_tiles[core::kNumOverworldMaps], int routine_offset, + int hook_offset = 0); private: absl::Status ApplyPatchToROM(ROM& rom);