|
| 1 | +#include "main.h" |
1 | 2 | #include "global.h"
|
2 | 3 | #include "commonfunctions.h"
|
3 | 4 | #include "menufunctions.h"
|
@@ -110,6 +111,52 @@ void preventTextboxOptionSelection(char *currentText, void *storeAddress, int32_
|
110 | 111 | reinterpret_cast<uint32_t>(storeAddress) + 0x9C) = NewOption;
|
111 | 112 | }
|
112 | 113 |
|
| 114 | +void fixRoomProblems() // Gets called in initStageEvents |
| 115 | +{ |
| 116 | + uint32_t SequencePosition = getSequencePosition(); |
| 117 | + |
| 118 | + if (compareStringToNextMap("nok_00")) |
| 119 | + { |
| 120 | + // Prevent the game from crashing if the player enters the intro cutscene after interacting with an NPC that is past slot 10 |
| 121 | + // Check if the cutscene is going to play |
| 122 | + if (SequencePosition < 26) |
| 123 | + { |
| 124 | + // Clear the pointer used to check which animation Mario should use when greeting the Koopa |
| 125 | + uint32_t fbatPointer = reinterpret_cast<uint32_t>(ttyd::npcdrv::fbatGetPointer()); |
| 126 | + *reinterpret_cast<uint32_t *>(fbatPointer + 0x4) = 0; // Mario will do no animation when the pointer is not set |
| 127 | + } |
| 128 | + } |
| 129 | + else if (compareStringToNextMap("rsh_05_a")) |
| 130 | + { |
| 131 | + // Prevent the game from crashing if the player enters rsh_05_a with the Sequence past 338 |
| 132 | + if (SequencePosition > 338) |
| 133 | + { |
| 134 | + // Set the Sequence to 338 to prevent the crash |
| 135 | + setSequencePosition(338); |
| 136 | + } |
| 137 | + } |
| 138 | + else if (compareStringToNextMap("aji_13")) |
| 139 | + { |
| 140 | + // Prevent the game from crashing if the conveyor belt has not been activated |
| 141 | + // Set GW(11) to 0 upon entering the room to prevent the crash |
| 142 | + setGW(11, 0); |
| 143 | + } |
| 144 | + else if (compareStringToNextMap("las_08")) |
| 145 | + { |
| 146 | + // Prevent the game from crashing if the player entered las_08 with the Sequence as 385 and GSW(1121) at 7 |
| 147 | + if (SequencePosition == 385) |
| 148 | + { |
| 149 | + // Check if GSW(1121) is currently at 7 |
| 150 | + uint32_t GSW_1121 = ttyd::swdrv::swByteGet(1121); |
| 151 | + if (GSW_1121 == 7) |
| 152 | + { |
| 153 | + // Lower the value to 6 to prevent the game from crashing |
| 154 | + ttyd::swdrv::swByteSet(1121, 6); |
| 155 | + } |
| 156 | + } |
| 157 | + } |
| 158 | +} |
| 159 | + |
113 | 160 | void *fixEvtMapBlendSetFlagPartnerCrash(void *partnerPtr)
|
114 | 161 | {
|
115 | 162 | // Bring out a partner if no partner is currently out
|
@@ -371,57 +418,8 @@ int32_t Mod::fixMarioKeyOn()
|
371 | 418 | return mPFN_marioKeyOn_trampoline();
|
372 | 419 | }
|
373 | 420 |
|
374 |
| -void fixRoomProblems() |
| 421 | +bool Mod::performRelPatches(gc::OSModule::OSModuleInfo *newModule, void *bss) |
375 | 422 | {
|
376 |
| - uint32_t SequencePosition = getSequencePosition(); |
377 |
| - |
378 |
| - if (compareStringToNextMap("nok_00")) |
379 |
| - { |
380 |
| - // Prevent the game from crashing if the player enters the intro cutscene after interacting with an NPC that is past slot 10 |
381 |
| - // Check if the cutscene is going to play |
382 |
| - if (SequencePosition < 26) |
383 |
| - { |
384 |
| - // Clear the pointer used to check which animation Mario should use when greeting the Koopa |
385 |
| - uint32_t fbatPointer = reinterpret_cast<uint32_t>(ttyd::npcdrv::fbatGetPointer()); |
386 |
| - *reinterpret_cast<uint32_t *>(fbatPointer + 0x4) = 0; // Mario will do no animation when the pointer is not set |
387 |
| - } |
388 |
| - } |
389 |
| - else if (compareStringToNextMap("rsh_05_a")) |
390 |
| - { |
391 |
| - // Prevent the game from crashing if the player enters rsh_05_a with the Sequence past 338 |
392 |
| - if (SequencePosition > 338) |
393 |
| - { |
394 |
| - // Set the Sequence to 338 to prevent the crash |
395 |
| - setSequencePosition(338); |
396 |
| - } |
397 |
| - } |
398 |
| - else if (compareStringToNextMap("aji_13")) |
399 |
| - { |
400 |
| - // Prevent the game from crashing if the conveyor belt has not been activated |
401 |
| - // Set GW(11) to 0 upon entering the room to prevent the crash |
402 |
| - setGW(11, 0); |
403 |
| - } |
404 |
| - else if (compareStringToNextMap("las_08")) |
405 |
| - { |
406 |
| - // Prevent the game from crashing if the player entered las_08 with the Sequence as 385 and GSW(1121) at 7 |
407 |
| - if (SequencePosition == 385) |
408 |
| - { |
409 |
| - // Check if GSW(1121) is currently at 7 |
410 |
| - uint32_t GSW_1121 = ttyd::swdrv::swByteGet(1121); |
411 |
| - if (GSW_1121 == 7) |
412 |
| - { |
413 |
| - // Lower the value to 6 to prevent the game from crashing |
414 |
| - ttyd::swdrv::swByteSet(1121, 6); |
415 |
| - } |
416 |
| - } |
417 |
| - } |
418 |
| -} |
419 |
| - |
420 |
| -bool Mod::performRelAndMapPatches(gc::OSModule::OSModuleInfo *newModule, void *bss) |
421 |
| -{ |
422 |
| - // Check to see if any fixes need to be applied to specific maps |
423 |
| - fixRoomProblems(); |
424 |
| - |
425 | 423 | // Call the original function immediately, as the REL file should be linked before applying patches
|
426 | 424 | const bool Result = mPFN_OSLink_trampoline(newModule, bss);
|
427 | 425 |
|
@@ -716,7 +714,7 @@ void initAddressOverwrites()
|
716 | 714 |
|
717 | 715 | *reinterpret_cast<uint32_t *>(msgWindowMrAddress) = 0x38830001; // addi r4,r3,1
|
718 | 716 |
|
719 |
| - // Set the initial value for the debug mode variable, to allow backtrace screens before the title sequence begins |
| 717 | + // Set the initial value for the debug mode variable |
720 | 718 | *reinterpret_cast<int32_t *>(
|
721 | 719 | reinterpret_cast<uint32_t>(
|
722 | 720 | ttyd::seq_title::seqTitleWorkPointer2) + 0x30) = -1;
|
|
0 commit comments