Skip to content

Commit

Permalink
Reset *Mario & Luigi: Bowser's Inside Story* on each crash
Browse files Browse the repository at this point in the history
Does not apply to B4DS mode due to limited code space
  • Loading branch information
RocketRobz committed Jan 28, 2025
1 parent 7e4e476 commit 38ff9e6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions retail/bootloaderi/source/arm7/hook_arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define b_fntFatCached BIT(17)
#define b_waitForPreloadToFinish BIT(18)
#define b_resetOnFirstException BIT(19)
#define b_resetOnEveryException BIT(20)


static const int MAX_HANDLER_LEN = 50;
Expand Down Expand Up @@ -378,6 +379,8 @@ int hookNdsRetailArm9(
}
if (!dataToPreloadFound(ndsHeader) && (strncmp(romTid, "YPT", 3) == 0)) { // Puppy Palace
ce9->valueBits |= b_resetOnFirstException;
} else if (strncmp(romTid, "CLJ", 3) == 0) { // Mario & Luigi: Bowser's Inside Story
ce9->valueBits |= b_resetOnEveryException;
}

if (ndsHeader->unitCode == 0 || !dsiMode) {
Expand Down
3 changes: 2 additions & 1 deletion retail/cardenginei/arm9/source/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define dsiBios BIT(11)
#define bypassExceptionHandler BIT(16)
#define resetOnFirstException BIT(19)
#define resetOnEveryException BIT(20)

#define EXCEPTION_VECTOR_SDK1 (*(VoidFn *)(0x27FFD9C))

Expand All @@ -23,7 +24,7 @@ void userException() {
sharedAddr[0] = 0x524F5245; // 'EROR'

#ifndef TWLSDK
if (ce9->valueBits & resetOnFirstException) {
if ((ce9->valueBits & resetOnFirstException) || (ce9->valueBits & resetOnEveryException)) {
ce9->valueBits &= ~resetOnFirstException;

extern void reset(u32 param, u32 tid2);
Expand Down
1 change: 1 addition & 0 deletions retail/common/include/cardengine_header_arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ typedef struct cardengineArm9 {
17: fntFatCached
18: waitForPreloadToFinish
19: resetOnFirstException
20: resetOnEveryException
*/
s32 mainScreen;
u32 consoleModel;
Expand Down

0 comments on commit 38ff9e6

Please sign in to comment.