Skip to content

Commit

Permalink
Fix remain shuffling always giving a remains regardless if shuffled o…
Browse files Browse the repository at this point in the history
…r not. (#73)

Fix the issue where masks wouldn't be removed during the giant's cutscenes.
  • Loading branch information
PhlexPlexico authored Jun 27, 2024
1 parent 3e4fa84 commit 95a3290
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions code/include/game/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ namespace game {

// Mask IDs are action IDs - 0x3b
enum class MaskId : u8 {
None = 0x00,
MaskOfTruth = 0x01,
BunnyHood = 0x04,
BlastMask = 0x12,
Expand Down
1 change: 1 addition & 0 deletions code/include/rnd/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace rnd::link {
void FixFreeCameraReset();
extern "C" void AssignSwordForHoneyDarling();
extern "C" void RemoveSwordFromHoneyDarling();
extern "C" void ResetPlayerForm();

} // namespace rnd::link

Expand Down
11 changes: 8 additions & 3 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ SECTIONS{
*(.patch_CheckDungeonSmallKeys)
}

.patch_OverrideRemainGetItem 0x2347F8 : {
*(.patch_OverrideRemainGetItem)
}

.patch_DisableMilkTimer 0x234BFC : {
*(.patch_DisableMilkTimer)
}
Expand Down Expand Up @@ -320,13 +324,14 @@ SECTIONS{
*(.patch_OverrideItemID)
}

.patch_TwinmoldConsistentDamage 0x28E544 : {
*(.patch_TwinmoldConsistentDamage)
}

.patch_EnteringLocation 0x23AA54 : {
*(.patch_EnteringLocation)
}

.patch_TwinmoldConsistentDamage 0x28E544 : {
*(.patch_TwinmoldConsistentDamage)
}

.patch_FasterBlockMovement 0x2AC634 : {
*(.patch_FasterBlockMovement)
Expand Down
16 changes: 16 additions & 0 deletions code/source/asm/item_override_hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ noOverrideItemIdIndex:
ldrsh r0, [r0, #-6]
bx lr

.global hook_OverrideRemainGetItem
hook_OverrideRemainGetItem:
push {r0-r12,lr}
bl ResetPlayerForm
pop {r0-r12,lr}
push {r2}
ldr r2,.rActiveItemRow_addr
ldr r2,[r2]
cmp r2,#0x0
pop {r2}
bne 0x23406C
cmp r2,#0x3
bhi 0x234878
bx lr


.global hook_OverrideDrawIndex
hook_OverrideDrawIndex:
ldr r0,.rActiveItemGraphicId_addr
Expand Down
5 changes: 5 additions & 0 deletions code/source/asm/item_override_patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ patch_OverrideItemIdIndex:
@TODO: Branch off to hook and load addr that is needed from text ID.
bl hook_OverrideItemIdIndex

.section .patch_OverrideRemainGetItem
.global patch_OverrideRemainGetItem
patch_OverrideRemainGetItem:
bl hook_OverrideRemainGetItem

.section .patch_ChangeDrawItemIndex
.global OverrideDrawIndex_patch
OverrideDrawIndex_patch:
Expand Down
3 changes: 0 additions & 3 deletions code/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ namespace rnd {

const u32 pressedButtons = gctx->pad_state.input.buttons.flags;
// const u32 newButtons = gctx->pad_state.input.new_buttons.flags;
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
// game::SaveData& saveData = game::GetCommonData().save;
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
if (pressedButtons == (u32)game::pad::Button::ZR) {
yPos += 10.00f;
Expand All @@ -121,7 +119,6 @@ namespace rnd {
} else if (pressedButtons == (u32)game::pad::Button::Down) {
zPos -= 10.00f;
}
#endif
#endif
if (gSettingsContext.customMaskButton != 0 && pressedButtons == gSettingsContext.customMaskButton) {
game::ui::OpenScreen(game::ui::ScreenType::Masks);
Expand Down
8 changes: 8 additions & 0 deletions code/source/rnd/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ namespace rnd::link {
hadSword = true;
}
}

void ResetPlayerForm() {
game::GlobalContext* gctx = GetContext().gctx;
game::SaveData& saveData = game::GetCommonData().save;
saveData.mask = game::MaskId::None;
saveData.player_form = game::act::Player::Form::Human;
// 0x3E0ADC
}
}

} // namespace rnd::link

0 comments on commit 95a3290

Please sign in to comment.