Skip to content

Commit 4e00862

Browse files
committed
Merge 'Kak gate fix' (#2250)
# Conflicts: # ASM/build/asm_symbols.txt # ASM/build/bundle.o # ASM/build/c_symbols.txt # ASM/src/hacks.asm # data/generated/rom_patch.txt # data/generated/symbols.json
2 parents b192e39 + 0ea5672 commit 4e00862

15 files changed

Lines changed: 32463 additions & 32385 deletions

ASM/build/asm_symbols.txt

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

ASM/build/bundle.o

148 Bytes
Binary file not shown.

ASM/build/c_symbols.txt

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

ASM/c/bg_gate_shutter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "z64.h"
2+
3+
typedef struct BgGateShutter {
4+
/* 0x0000 */ DynaPolyActor dyna;
5+
/* 0x0154 */ void* actionFunc;
6+
/* 0x0158 */ int16_t openingState; // 1 if gate is opening
7+
/* 0x015C */ z64_xyzf_t somePos;
8+
/* 0x0168 */ int16_t unk_168;
9+
} BgGateShutter; // size = 0x016C

ASM/c/item_effects.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "item_effects.h"
22
#include "dungeon_info.h"
33
#include "trade_quests.h"
4+
#include "bg_gate_shutter.h"
45
#include "save.h"
56

67
#define rupee_cap ((uint16_t*)0x800F8CEC)
@@ -223,12 +224,27 @@ void clear_excess_hearts(z64_file_t* save, int16_t arg1, int16_t arg2) {
223224

224225
uint8_t OPEN_KAKARIKO = 0;
225226
uint8_t COMPLETE_MASK_QUEST = 0;
226-
void open_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2) {
227+
void open_gate_and_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2) {
228+
// Check OPEN_KAKARIKO setting and open the gate
227229
if (OPEN_KAKARIKO) {
228230
save->inf_table[7] = save->inf_table[7] | 0x40; // "Spoke to Gate Guard About Mask Shop"
229231
if (!COMPLETE_MASK_QUEST) {
230232
save->item_get_inf[2] = save->item_get_inf[2] & 0xFB87; // Unset "Obtained Mask" flags just in case of savewarp before Impa.
231233
}
234+
// Check if we're in kak and actually open the gate
235+
if (z64_game.scene_index == 82) {
236+
// Loop through the actors looking for the gate
237+
z64_actor_t* curr = z64_game.actor_list[7].first;
238+
while (curr != NULL) {
239+
if (curr->actor_id == 0x100) { // Check for BG_GATE_SHUTTER
240+
// Set the openingState so it starts to open
241+
BgGateShutter* gate = (BgGateShutter*)curr;
242+
gate->openingState = 2;
243+
return;
244+
}
245+
curr = curr->next;
246+
}
247+
}
232248
}
233249
if (COMPLETE_MASK_QUEST) {
234250
save->inf_table[7] = save->inf_table[7] | 0x80; // "Soldier Wears Keaton Mask"

ASM/c/item_effects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void ice_trap_effect(z64_file_t* save, int16_t arg1, int16_t arg2);
2626
void give_bean_pack(z64_file_t* save, int16_t arg1, int16_t arg2);
2727
void fill_wallet_upgrade(z64_file_t* save, int16_t arg1, int16_t arg2);
2828
void clear_excess_hearts(z64_file_t* save, int16_t arg1, int16_t arg2);
29-
void open_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2);
29+
void open_gate_and_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2);
3030
void give_bombchus(z64_file_t* save, int16_t arg1, int16_t arg2);
3131
void trade_quest_upgrade(z64_file_t* save, int16_t item_id, int16_t arg2);
3232
extern uint8_t KEYRING_BOSSKEY_CONDITION;

ASM/c/item_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ item_row_t item_table[] = {
3737
[0x0008] = ITEM_ROW(0x53, GILDED_CHEST, 0x0A, -1, 0x0036, 0x00DD, 0x2D, no_upgrade, no_effect, -1, -1, NULL), // Hookshot
3838
[0x0009] = ITEM_ROW(0x53, GILDED_CHEST, 0x0B, -1, 0x004F, 0x00DD, 0x2E, no_upgrade, no_effect, -1, -1, NULL), // Longshot
3939
[0x000A] = ITEM_ROW(0x53, GILDED_CHEST, 0x0F, -1, 0x0039, 0x00EA, 0x36, no_upgrade, no_effect, -1, -1, NULL), // Lens of Truth
40-
[0x000B] = ITEM_ROW(0x53, GILDED_CHEST, 0x23, -1, 0x0069, 0x00EF, 0x3B, no_upgrade, open_mask_shop, 0x23, -1, NULL), // Zelda's Letter
40+
[0x000B] = ITEM_ROW(0x53, GILDED_CHEST, 0x23, -1, 0x0069, 0x00EF, 0x3B, no_upgrade, open_gate_and_mask_shop, 0x23, -1, NULL), // Zelda's Letter
4141
[0x000C] = ITEM_ROW(0x53, GILDED_CHEST, 0x08, -1, 0x003A, 0x00DE, 0x2F, no_upgrade, no_effect, -1, -1, NULL), // Ocarina of Time
4242
[0x000D] = ITEM_ROW(0x53, GILDED_CHEST, 0x11, -1, 0x0038, 0x00F6, 0x41, no_upgrade, no_effect, -1, -1, NULL), // Megaton Hammer
4343
[0x000E] = ITEM_ROW(0x53, GILDED_CHEST, 0x2F, -1, 0x0002, 0x0109, 0x5E, no_upgrade, trade_quest_upgrade, 0x2F, -1, NULL), // Cojiro

ASM/src/bg_gate_shutter.asm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; Check the new gate open flag instead of the master sword check
2+
; This happens after the zelda's letter check so it should only effect it when the setting is set to open
3+
; Put the flag into t9 because it will be checked against 0 when we return
4+
; we can use t8
5+
bg_gate_shutter_open_hack:
6+
li t8, OPEN_KAKARIKO
7+
lb t8, 0x00(t8) ; read the value of the OPEN_KAKARIKO setting. If we set it to 2 then it's always open
8+
jr ra
9+
andi t9, t8, 0x02

ASM/src/build.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ RANDO_CONTEXT:
131131
.include "ocarina_buttons.asm"
132132
.include "fairy_ocarina.asm"
133133
.include "en_dns.asm"
134+
.include "bg_gate_shutter.asm"
134135

135136
.align 0x10
136137
.importobj "../build/bundle.o"

ASM/src/hacks.asm

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,45 +3280,6 @@ courtyard_guards_kill:
32803280
jal fountain_set_posrot
32813281
or a0, s0, r0
32823282

3283-
;==================================================================================================
3284-
; Speed Up Gate in Kakariko
3285-
;==================================================================================================
3286-
; gate opening x
3287-
; Replaces: lui at, 0x4000 ;2.0f
3288-
.orga 0xDD366C
3289-
lui at, 0x40D0 ;6.5f
3290-
3291-
; gate opening z
3292-
; Replaces: lui a2, 0x3F4C
3293-
; sub.s f8, f4, f6
3294-
; lui a3, 0x3E99
3295-
; ori a3, a3, 0x999A
3296-
; ori a2, a2, 0xCCCD
3297-
.orga 0xDD367C
3298-
lui a2, 0x4000
3299-
sub.s f8, f4, f6
3300-
lui a3, 0x4000
3301-
nop
3302-
nop
3303-
3304-
; gate closing x
3305-
; Replaces: lui at, 0x4000 ;2.0f
3306-
.orga 0xDD3744
3307-
lui at, 0x40D0 ;6.5f
3308-
3309-
; gate closing z
3310-
; Replaces: lui a2, 0x3F4C
3311-
; add.s f8, f4, f6
3312-
; lui a3, 0x3E99
3313-
; ori a3, a3, 0x999A
3314-
; ori a2, a2, 0xCCCD
3315-
.orga 0xDD3754
3316-
lui a2, 0x4000
3317-
add.s f8, f4, f6
3318-
lui a3, 0x4000
3319-
nop
3320-
nop
3321-
33223283
;==================================================================================================
33233284
; Prevent Carpenter Boss Softlock
33243285
;==================================================================================================
@@ -4170,10 +4131,11 @@ DemoEffect_DrawJewel_AfterHook:
41704131
jal volvagia_flying_hitbox
41714132
nop
41724133

4173-
.include "hacks/z_parameter.asm"
4174-
.include "hacks/ovl_en_kz.asm"
4175-
.include "hacks/ovl_en_dns.asm"
4134+
.include "hacks/en_item00.asm"
4135+
.include "hacks/ovl_bg_gate_shutter.asm"
4136+
.include "hacks/ovl_bg_haka_tubo.asm"
41764137
.include "hacks/ovl_bg_spot18_basket.asm"
4138+
.include "hacks/ovl_en_dns.asm"
4139+
.include "hacks/ovl_en_kz.asm"
41774140
.include "hacks/ovl_obj_mure3.asm"
4178-
.include "hacks/ovl_bg_haka_tubo.asm"
4179-
.include "hacks/en_item00.asm"
4141+
.include "hacks/z_parameter.asm"

0 commit comments

Comments
 (0)