Skip to content

Commit 9c31190

Browse files
committed
Merge 'Prevent softlock when Hookshot cannot spawn on equip' (#2571)
# Conflicts: # ASM/build/asm_symbols.txt # ASM/build/bundle.o # ASM/build/c_symbols.txt # ASM/src/build.asm # ASM/src/hacks/z_player.asm # ASM/src/player_ladder_cutscene.asm # data/generated/patch_symbols.json # data/generated/rom_patch.txt # data/generated/symbols.json
2 parents 8842469 + 5e10dfe commit 9c31190

15 files changed

Lines changed: 38387 additions & 38347 deletions

ASM/build/asm_symbols.txt

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

ASM/build/bundle.o

24 Bytes
Binary file not shown.

ASM/build/c_symbols.txt

Lines changed: 685 additions & 684 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
@@ -43,5 +43,6 @@ z64_sEquipMoveTimer = 0x8039EAB8;
4343
gActorOverlayTable = 0x800E8530;
4444
Message_CloseTextbox = 0x800d6218;
4545
sSetupDL = 0x800f7d50;
46+
Player_UseItem = 0x8038c9a0; /* 0x80834000 */
4647
OVL_EnOkarinaTag_Action2 = 0x80a872d0;
4748
OVL_EnOkarinaTag_Action1 = 0x80a87088;

ASM/src/build.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ RANDO_CONTEXT:
135135
.include "big_poe.asm"
136136
.include "player_laddercutscenefix.asm"
137137
.include "player_bunny_hover_matrix.asm"
138+
.include "player_hookshotcheckspawn.asm"
138139

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

ASM/src/hacks/z_player.asm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@
3939
.org 0x80848578
4040
jal Player_HoverMatrixPop
4141
sw v0,4(s0)
42+
43+
;================================================================================
44+
; Prevent softlock if Hookshot actor cannot spawn when equipping
45+
; (memory shortage due to Hyrule Field glitch, child equip etc)
46+
;================================================================================
47+
; Replaces lw a1,60(sp)
48+
; sw v0,924(a1)
49+
.org 0x808319d4 ; in Player_InitHookshotIA (0x8038a374)
50+
jal Player_HookshotCheckActorSpawn
51+
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)