Skip to content

Commit

Permalink
Implement blast mask cooldown. (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhlexPlexico authored Feb 22, 2024
1 parent c7fde8c commit 1cf9682
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
15 changes: 15 additions & 0 deletions code/include/rnd/blastmask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _RND_CHEST_H_
#define _RND_CHEST_H_

#include "common/advanced_context.h"
#include "rnd/settings.h"
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
#include "common/debug.h"
extern "C" {
#include <3ds/svc.h>
}
#endif
namespace rnd {
extern "C" u8 checkBlastMaskCooldown();
} // namespace rnd
#endif
3 changes: 3 additions & 0 deletions code/include/rnd/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ namespace rnd {
u32 customMaskButton = 0;
u32 customNotebookButton = 0;
u32 customIngameSpoilerButton = 0;

// Extra MM Settings
u8 blastMaskCooldown;
} SettingsContext;

extern "C" SettingsContext gSettingsContext;
Expand Down
4 changes: 4 additions & 0 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ SECTIONS{
*(.patch_CheckMagicForZoraFastSwim)
}

.patch_BlastMaskCooldown 0x2047FC : {
*(.patch_BlastMaskCooldown)
}

.patch_ZoraBarrierCheckMagicAcquired 0x207230 : {
*(.patch_ZoraBarrierCheckMagicAcquired)
}
Expand Down
33 changes: 33 additions & 0 deletions code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,39 @@ hook_SaveFile_Init:
mov r3,#0x0
b 0x5b8b28

.global hook_BlastMaskCooldown
hook_BlastMaskCooldown:
push {r0-r12, lr}
bl checkBlastMaskCooldown
cmp r0,#0x0
beq defaultBlastCd
cmp r0,#0x1
beq shortBlastCd
cmp r0,#0x2
beq veryShortBlastCd
cmp r0,#0x3
beq instBlastCd
defaultBlastCd:
pop {r0-r12, lr}
cmp r0,#0x0
subne r0,r0,#0x1
bx lr
shortBlastCd:
pop {r0-r12, lr}
cmp r0,#0x0
subne r0,r0,#0x2
bx lr
veryShortBlastCd:
pop {r0-r12, lr}
cmp r0,#0x0
subne r0,r0,#0x5
bx lr
instBlastCd:
pop {r0-r12, lr}
cmp r0,#0x0
subne r0,r0,r0
bx lr

.global hook_OverrideItemIdIndex
hook_OverrideItemIdIndex:
push {r0}
Expand Down
5 changes: 5 additions & 0 deletions code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ patch_ISGCrouchStabTwo:
nop
nop

.section .patch_BlastMaskCooldown
.global patch_BlastMaskCooldown
patch_BlastMaskCooldown:
bl hook_BlastMaskCooldown

.section .patch_RemoveRazordSwordHealth
.global patch_RemoveRazordSwordHealth
patch_RemoveRazordSwordHealth:
Expand Down
9 changes: 9 additions & 0 deletions code/source/rnd/blastmask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "rnd/blastmask.h"

namespace rnd {
extern "C" {
u8 checkBlastMaskCooldown() {
return gSettingsContext.blastMaskCooldown;
}
}
} // namespace rnd

0 comments on commit 1cf9682

Please sign in to comment.