Skip to content

Commit 4c705f0

Browse files
author
djevangelia
committed
Prevent softlock when Hookshot cannot spawn on equip
Hook into Player_InitHookshotIA Asm check if Hookshot actor is NULL If so, Player_UseItem item none
1 parent 2900fed commit 4c705f0

14 files changed

Lines changed: 38644 additions & 38654 deletions

ASM/build/asm_symbols.txt

Lines changed: 760 additions & 757 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/build/bundle.o

2.43 KB
Binary file not shown.

ASM/build/c_symbols.txt

Lines changed: 724 additions & 722 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/c/debug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "objects.h"
33
#include "item_effects.h"
44
#include "actor.h"
5+
#include "player.h"
56

67
extern uint16_t current_textbox_id;
78

@@ -480,7 +481,7 @@ void draw_debug_menu(z64_disp_buf_t* db) {
480481
if (input_local_copy.pad_pressed.a) {
481482
z64_GiveItem(&z64_game, Z64_ITEM_BUNNY_HOOD);
482483
if (z64_game.pause_ctxt.state == PAUSE_STATE_OFF) {
483-
z64_usebutton(&z64_game, &z64_link, Z64_ITEM_BUNNY_HOOD, 2);
484+
Player_UseItem(&z64_game, &z64_link, Z64_ITEM_BUNNY_HOOD);
484485
}
485486
}
486487
}

ASM/c/dpad.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "gfx.h"
22
#include "dpad.h"
33
#include "trade_quests.h"
4+
#include "player.h"
45

56
extern uint8_t CFG_DISPLAY_DPAD;
67

@@ -10,10 +11,8 @@ extern uint8_t CFG_DISPLAY_DPAD;
1011
//unknown 03 is always a3 in my testing
1112
//unknown 04 is always a3 + 0x08 in my testing (801043A8)
1213
typedef void(*playsfx_t)(uint16_t sfx, z64_xyzf_t* unk_00_, int8_t unk_01_ , float* unk_02_, float* unk_03_, float* unk_04_);
13-
typedef void(*usebutton_t)(z64_game_t* game, z64_link_t* link, uint8_t item, uint8_t button);
1414

1515
#define z64_playsfx ((playsfx_t) 0x800C806C)
16-
#define z64_usebutton ((usebutton_t) 0x8038C9A0)
1716

1817
void handle_dpad() {
1918

@@ -57,12 +56,12 @@ void handle_dpad() {
5756

5857
if (z64_file.link_age == 1) {
5958
if (pad_pressed.dr && CAN_USE_CHILD_TRADE) {
60-
z64_usebutton(&z64_game,&z64_link,z64_file.items[Z64_SLOT_CHILD_TRADE], 2);
59+
Player_UseItem(&z64_game,&z64_link,z64_file.items[Z64_SLOT_CHILD_TRADE]);
6160
}
6261
}
6362

6463
if (pad_pressed.dd && CAN_USE_OCARINA) {
65-
z64_usebutton(&z64_game,&z64_link,z64_file.items[Z64_SLOT_OCARINA], 2);
64+
Player_UseItem(&z64_game,&z64_link,z64_file.items[Z64_SLOT_OCARINA]);
6665
}
6766
}
6867
}

ASM/c/player.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef PLAYER_H
2+
#define PLAYER_H
3+
4+
extern void Player_UseItem(z64_game_t* game, z64_link_t* player, int32_t item);
5+
6+
#endif

ASM/ootSymbols.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ z64_sEquipMoveTimer = 0x8039EAB8;
4141
gActorOverlayTable = 0x800E8530;
4242
Message_CloseTextbox = 0x800d6218;
4343
sSetupDL = 0x800f7d50;
44+
Player_UseItem = 0x8038c9a0; /* 0x80834000 */
4445
OVL_EnOkarinaTag_Action2 = 0x80a872d0;
4546
OVL_EnOkarinaTag_Action1 = 0x80a87088;

ASM/src/build.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ RANDO_CONTEXT:
134134
.include "bg_gate_shutter.asm"
135135
.include "big_poe.asm"
136136
.include "player_ladder_cutscene.asm"
137+
.include "player_hookshotcheckspawn.asm"
137138

138139
.align 0x10
139140
.importobj "../build/bundle.o"

ASM/src/hacks/z_player.asm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,15 @@
66
; Replaces lw t8,1644(s0)
77
; lui at,0xffdf
88
.org 0x8084a6c4 ; in Player_Action_DismountLadder (0x803a3064)
9-
jal player_ladder_cutscene
9+
jal Player_LadderCutsceneFix
1010
nop
11+
12+
;================================================================================
13+
; Prevent softlock if Hookshot actor cannot spawn when equipping
14+
; (memory shortage due to Hyrule Field glitch, child equip etc)
15+
;================================================================================
16+
; Replaces lw a1,60(sp)
17+
; sw v0,924(a1)
18+
.org 0x808319d4 ; in Player_InitHookshotIA (0x8038a374)
19+
jal Player_HookshotCheckActorSpawn
20+
lw a1,60(sp) ; displaced (loads player)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Player_HookshotCheckActorSpawn:
2+
bnez v0,@@Return ; If Hookshot actor spawned,
3+
sw v0,924(a1) ; set it as heldActor and continue
4+
5+
addiu sp,sp,-24
6+
sw ra,16(sp)
7+
move a0,s1 ; Otherwise, use item none to avoid softlock
8+
jal Player_UseItem ; a0 play a1 player a2 item
9+
li a2,255
10+
lw ra,16(sp)
11+
addiu sp,sp,24
12+
@@Return:
13+
jr ra
14+
nop

0 commit comments

Comments
 (0)