@@ -110,55 +110,6 @@ void preventTextboxOptionSelection(char *currentText, void *storeAddress, int32_
110
110
reinterpret_cast <uint32_t >(storeAddress) + 0x9C ) = NewOption;
111
111
}
112
112
113
- uint32_t fixRoomProblems ()
114
- {
115
- uint32_t SequencePosition = getSequencePosition ();
116
-
117
- if (compareStringToNextMap (" nok_00" ))
118
- {
119
- // Prevent the game from crashing if the player enters the intro cutscene after interacting with an NPC that is past slot 10
120
- // Check if the cutscene is going to play
121
- if (SequencePosition < 26 )
122
- {
123
- // Clear the pointer used to check which animation Mario should use when greeting the Koopa
124
- uint32_t fbatPointer = reinterpret_cast <uint32_t >(ttyd::npcdrv::fbatGetPointer ());
125
- *reinterpret_cast <uint32_t *>(fbatPointer + 0x4 ) = 0 ; // Mario will do no animation when the pointer is not set
126
- }
127
- }
128
- else if (compareStringToNextMap (" rsh_05_a" ))
129
- {
130
- // Prevent the game from crashing if the player enters rsh_05_a with the Sequence past 338
131
- if (SequencePosition > 338 )
132
- {
133
- // Set the Sequence to 338 to prevent the crash
134
- setSequencePosition (338 );
135
- }
136
- }
137
- else if (compareStringToNextMap (" aji_13" ))
138
- {
139
- // Prevent the game from crashing if the conveyor belt has not been activated
140
- // Set GW(11) to 0 upon entering the room to prevent the crash
141
- setGW (11 , 0 );
142
- }
143
- else if (compareStringToNextMap (" las_08" ))
144
- {
145
- // Prevent the game from crashing if the player entered las_08 with the Sequence as 385 and GSW(1121) at 7
146
- if (SequencePosition == 385 )
147
- {
148
- // Check if GSW(1121) is currently at 7
149
- uint32_t GSW_1121 = ttyd::swdrv::swByteGet (1121 );
150
- if (GSW_1121 == 7 )
151
- {
152
- // Lower the value to 6 to prevent the game from crashing
153
- ttyd::swdrv::swByteSet (1121 , 6 );
154
- }
155
- }
156
- }
157
-
158
- // The overwritten instruction sets r3 to 512, so return 512
159
- return 512 ;
160
- }
161
-
162
113
void *fixEvtMapBlendSetFlagPartnerCrash (void *partnerPtr)
163
114
{
164
115
// Bring out a partner if no partner is currently out
@@ -420,8 +371,57 @@ int32_t Mod::fixMarioKeyOn()
420
371
return mPFN_marioKeyOn_trampoline ();
421
372
}
422
373
423
- bool Mod::performRelPatches (gc::OSModule::OSModuleInfo *newModule, void *bss )
374
+ void fixRoomProblems ( )
424
375
{
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
425
// Call the original function immediately, as the REL file should be linked before applying patches
426
426
const bool Result = mPFN_OSLink_trampoline (newModule, bss);
427
427
@@ -618,7 +618,6 @@ void initAddressOverwrites()
618
618
void *FixBlooperCrash1Address = reinterpret_cast <void *>(0x8010F810 );
619
619
void *FixBlooperCrash2Address = reinterpret_cast <void *>(0x8010F888 );
620
620
void *PreventTextboxSelectionAddress = reinterpret_cast <void *>(0x800D214C );
621
- void *FixRoomProblemsAddress = reinterpret_cast <void *>(0x800087C8 );
622
621
void *DisableDPadOptionsDisplayAddress = reinterpret_cast <void *>(0x8013D148 );
623
622
void *FixEvtMapBlendSetFlagPartnerCrashAddress = reinterpret_cast <void *>(0x800389C4 );
624
623
void *FixEvtMapBlendSetFlagFollowerCrashAddress = reinterpret_cast <void *>(0x80038A0C );
@@ -642,7 +641,6 @@ void initAddressOverwrites()
642
641
void *FixBlooperCrash1Address = reinterpret_cast <void *>(0x8010A724 );
643
642
void *FixBlooperCrash2Address = reinterpret_cast <void *>(0x8010A79C );
644
643
void *PreventTextboxSelectionAddress = reinterpret_cast <void *>(0x800CE01C );
645
- void *FixRoomProblemsAddress = reinterpret_cast <void *>(0x800086F0 );
646
644
void *DisableDPadOptionsDisplayAddress = reinterpret_cast <void *>(0x80137C1C );
647
645
void *FixEvtMapBlendSetFlagPartnerCrashAddress = reinterpret_cast <void *>(0x80038328 );
648
646
void *FixEvtMapBlendSetFlagFollowerCrashAddress = reinterpret_cast <void *>(0x80038370 );
@@ -666,7 +664,6 @@ void initAddressOverwrites()
666
664
void *FixBlooperCrash1Address = reinterpret_cast <void *>(0x801106E8 );
667
665
void *FixBlooperCrash2Address = reinterpret_cast <void *>(0x80110760 );
668
666
void *PreventTextboxSelectionAddress = reinterpret_cast <void *>(0x800D2F44 );
669
- void *FixRoomProblemsAddress = reinterpret_cast <void *>(0x80008994 );
670
667
void *DisableDPadOptionsDisplayAddress = reinterpret_cast <void *>(0x8013EC30 );
671
668
void *FixEvtMapBlendSetFlagPartnerCrashAddress = reinterpret_cast <void *>(0x80038AAC );
672
669
void *FixEvtMapBlendSetFlagFollowerCrashAddress = reinterpret_cast <void *>(0x80038AF4 );
@@ -693,8 +690,6 @@ void initAddressOverwrites()
693
690
694
691
patch::writeBranchBL (PreventTextboxSelectionAddress, reinterpret_cast <void *>(StartPreventTextboxSelection));
695
692
696
- patch::writeBranchBL (FixRoomProblemsAddress, reinterpret_cast <void *>(fixRoomProblems));
697
-
698
693
patch::writeBranchBL (DisableDPadOptionsDisplayAddress, reinterpret_cast <void *>(StartDisableDPadOptionsDisplay));
699
694
700
695
patch::writeBranchBL (FixEvtMapBlendSetFlagPartnerCrashAddress, reinterpret_cast <void *>(StartFixEvtMapBlendSetFlagPartnerCrash));
0 commit comments