summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPheenoh <pheenoh@gmail.com>2021-06-06 17:12:23 -0400
committerPheenoh <pheenoh@gmail.com>2021-06-06 17:34:11 -0400
commit0b1268d8cc298b401f8469183393fc46c5b9afaf (patch)
tree75bed8e5039ed4614c1281b9f995e9cd35a3cea7
parentf0d805228dd32d0f55b3049b8260e1c59c56cab6 (diff)
add macros
-rw-r--r--src/lib.cpp1
-rw-r--r--src/save_manager.cpp28
2 files changed, 23 insertions, 6 deletions
diff --git a/src/lib.cpp b/src/lib.cpp
index 9695b72..89816ad 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -36,6 +36,7 @@ extern "C" {
#if (GCN_NTSCU)
#define main_tampoline ((void (*)(void))0x803737b4)
+#define SET_WATER_DROP_COLOR ((uint32_t*)0x800CCE08)
#endif
#if (GCN_PAL)
#define main_tampoline ((void (*)(void))0x803745e4)
diff --git a/src/save_manager.cpp b/src/save_manager.cpp
index 9123394..bb9fc67 100644
--- a/src/save_manager.cpp
+++ b/src/save_manager.cpp
@@ -143,13 +143,29 @@ void SaveManager::load_save_file(const char* fileName) {
SaveManager::inject_save((void*)sTmpBuf);
}
+#if (GCN_NTSCU)
+#define SET_WATER_DROP_COLOR_BL ((uint32_t*)0x800CCE08)
+#endif
+#if (GCN_PAL)
+#define SET_WATER_DROP_COLOR_BL ((uint32_t*)0x800CD014)
+#endif
+#if (GCN_NTSCJ)
+#define SET_WATER_DROP_COLOR_BL ((uint32_t*)0x800CCE40)
+#endif
+#if (WII_NTSCU_10)
+#define SET_WATER_DROP_COLOR_BL ((uint32_t*)0x800C38BC)
+#endif
+#if (WII_PAL)
+#define SET_WATER_DROP_COLOR_BL ((uint32_t*)0x800C3DD4)
+#endif
+
void SaveManager::trigger_load() {
// Loading hasn't started yet, run the before load function and initiate loading
if (!tp_fopScnRq.isLoading && !gSaveManager.loading_initiated) {
// Patch out setWaterDropColor call temporarily (prevents a crash in some scenarios)
- *reinterpret_cast<uint32_t*>(0x800CCE08) = 0x60000000; // nop
- DCFlushRange((void*)(0x800CCE08), sizeof(uint32_t));
- ICInvalidateRange((void*)(0x800CCE08), sizeof(uint32_t));
+ *reinterpret_cast<uint32_t*>(SET_WATER_DROP_COLOR_BL) = 0x60000000; // nop
+ DCFlushRange((void*)(SET_WATER_DROP_COLOR_BL), sizeof(uint32_t));
+ ICInvalidateRange((void*)(SET_WATER_DROP_COLOR_BL), sizeof(uint32_t));
// Trigger loading
g_dComIfG_gameInfo.play.mNextStage.enabled = true;
@@ -168,10 +184,10 @@ void SaveManager::trigger_load() {
// Loading has completed, run the after load function
if (!tp_fopScnRq.isLoading) {
// Patch back in setWaterDropColor call
- *reinterpret_cast<uint32_t*>(0x800CCE08) =
+ *reinterpret_cast<uint32_t*>(SET_WATER_DROP_COLOR_BL) =
0x4BFFF55D; // bl daAlink_c::setWaterDropColor
- DCFlushRange((void*)(0x800CCE08), sizeof(uint32_t));
- ICInvalidateRange((void*)(0x800CCE08), sizeof(uint32_t));
+ DCFlushRange((void*)(SET_WATER_DROP_COLOR_BL), sizeof(uint32_t));
+ ICInvalidateRange((void*)(SET_WATER_DROP_COLOR_BL), sizeof(uint32_t));
if (gSaveManager.mPracticeFileOpts.inject_options_after_load) {
gSaveManager.mPracticeFileOpts.inject_options_after_load();