Skip to content

Commit

Permalink
Merge 'Kak gate fix' (OoTRandomizer#2250)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
fenhl committed Jun 25, 2024
2 parents b192e39 + 0ea5672 commit 4e00862
Show file tree
Hide file tree
Showing 15 changed files with 32,463 additions and 32,385 deletions.
1,323 changes: 662 additions & 661 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
886 changes: 443 additions & 443 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions ASM/c/bg_gate_shutter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "z64.h"

typedef struct BgGateShutter {
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0154 */ void* actionFunc;
/* 0x0158 */ int16_t openingState; // 1 if gate is opening
/* 0x015C */ z64_xyzf_t somePos;
/* 0x0168 */ int16_t unk_168;
} BgGateShutter; // size = 0x016C
18 changes: 17 additions & 1 deletion ASM/c/item_effects.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "item_effects.h"
#include "dungeon_info.h"
#include "trade_quests.h"
#include "bg_gate_shutter.h"
#include "save.h"

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

uint8_t OPEN_KAKARIKO = 0;
uint8_t COMPLETE_MASK_QUEST = 0;
void open_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2) {
void open_gate_and_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2) {
// Check OPEN_KAKARIKO setting and open the gate
if (OPEN_KAKARIKO) {
save->inf_table[7] = save->inf_table[7] | 0x40; // "Spoke to Gate Guard About Mask Shop"
if (!COMPLETE_MASK_QUEST) {
save->item_get_inf[2] = save->item_get_inf[2] & 0xFB87; // Unset "Obtained Mask" flags just in case of savewarp before Impa.
}
// Check if we're in kak and actually open the gate
if (z64_game.scene_index == 82) {
// Loop through the actors looking for the gate
z64_actor_t* curr = z64_game.actor_list[7].first;
while (curr != NULL) {
if (curr->actor_id == 0x100) { // Check for BG_GATE_SHUTTER
// Set the openingState so it starts to open
BgGateShutter* gate = (BgGateShutter*)curr;
gate->openingState = 2;
return;
}
curr = curr->next;
}
}
}
if (COMPLETE_MASK_QUEST) {
save->inf_table[7] = save->inf_table[7] | 0x80; // "Soldier Wears Keaton Mask"
Expand Down
2 changes: 1 addition & 1 deletion ASM/c/item_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void ice_trap_effect(z64_file_t* save, int16_t arg1, int16_t arg2);
void give_bean_pack(z64_file_t* save, int16_t arg1, int16_t arg2);
void fill_wallet_upgrade(z64_file_t* save, int16_t arg1, int16_t arg2);
void clear_excess_hearts(z64_file_t* save, int16_t arg1, int16_t arg2);
void open_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2);
void open_gate_and_mask_shop(z64_file_t* save, int16_t arg1, int16_t arg2);
void give_bombchus(z64_file_t* save, int16_t arg1, int16_t arg2);
void trade_quest_upgrade(z64_file_t* save, int16_t item_id, int16_t arg2);
extern uint8_t KEYRING_BOSSKEY_CONDITION;
Expand Down
2 changes: 1 addition & 1 deletion ASM/c/item_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ item_row_t item_table[] = {
[0x0008] = ITEM_ROW(0x53, GILDED_CHEST, 0x0A, -1, 0x0036, 0x00DD, 0x2D, no_upgrade, no_effect, -1, -1, NULL), // Hookshot
[0x0009] = ITEM_ROW(0x53, GILDED_CHEST, 0x0B, -1, 0x004F, 0x00DD, 0x2E, no_upgrade, no_effect, -1, -1, NULL), // Longshot
[0x000A] = ITEM_ROW(0x53, GILDED_CHEST, 0x0F, -1, 0x0039, 0x00EA, 0x36, no_upgrade, no_effect, -1, -1, NULL), // Lens of Truth
[0x000B] = ITEM_ROW(0x53, GILDED_CHEST, 0x23, -1, 0x0069, 0x00EF, 0x3B, no_upgrade, open_mask_shop, 0x23, -1, NULL), // Zelda's Letter
[0x000B] = ITEM_ROW(0x53, GILDED_CHEST, 0x23, -1, 0x0069, 0x00EF, 0x3B, no_upgrade, open_gate_and_mask_shop, 0x23, -1, NULL), // Zelda's Letter
[0x000C] = ITEM_ROW(0x53, GILDED_CHEST, 0x08, -1, 0x003A, 0x00DE, 0x2F, no_upgrade, no_effect, -1, -1, NULL), // Ocarina of Time
[0x000D] = ITEM_ROW(0x53, GILDED_CHEST, 0x11, -1, 0x0038, 0x00F6, 0x41, no_upgrade, no_effect, -1, -1, NULL), // Megaton Hammer
[0x000E] = ITEM_ROW(0x53, GILDED_CHEST, 0x2F, -1, 0x0002, 0x0109, 0x5E, no_upgrade, trade_quest_upgrade, 0x2F, -1, NULL), // Cojiro
Expand Down
9 changes: 9 additions & 0 deletions ASM/src/bg_gate_shutter.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Check the new gate open flag instead of the master sword check
; This happens after the zelda's letter check so it should only effect it when the setting is set to open
; Put the flag into t9 because it will be checked against 0 when we return
; we can use t8
bg_gate_shutter_open_hack:
li t8, OPEN_KAKARIKO
lb t8, 0x00(t8) ; read the value of the OPEN_KAKARIKO setting. If we set it to 2 then it's always open
jr ra
andi t9, t8, 0x02
1 change: 1 addition & 0 deletions ASM/src/build.asm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ RANDO_CONTEXT:
.include "ocarina_buttons.asm"
.include "fairy_ocarina.asm"
.include "en_dns.asm"
.include "bg_gate_shutter.asm"

.align 0x10
.importobj "../build/bundle.o"
Expand Down
50 changes: 6 additions & 44 deletions ASM/src/hacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3280,45 +3280,6 @@ courtyard_guards_kill:
jal fountain_set_posrot
or a0, s0, r0

;==================================================================================================
; Speed Up Gate in Kakariko
;==================================================================================================
; gate opening x
; Replaces: lui at, 0x4000 ;2.0f
.orga 0xDD366C
lui at, 0x40D0 ;6.5f

; gate opening z
; Replaces: lui a2, 0x3F4C
; sub.s f8, f4, f6
; lui a3, 0x3E99
; ori a3, a3, 0x999A
; ori a2, a2, 0xCCCD
.orga 0xDD367C
lui a2, 0x4000
sub.s f8, f4, f6
lui a3, 0x4000
nop
nop

; gate closing x
; Replaces: lui at, 0x4000 ;2.0f
.orga 0xDD3744
lui at, 0x40D0 ;6.5f

; gate closing z
; Replaces: lui a2, 0x3F4C
; add.s f8, f4, f6
; lui a3, 0x3E99
; ori a3, a3, 0x999A
; ori a2, a2, 0xCCCD
.orga 0xDD3754
lui a2, 0x4000
add.s f8, f4, f6
lui a3, 0x4000
nop
nop

;==================================================================================================
; Prevent Carpenter Boss Softlock
;==================================================================================================
Expand Down Expand Up @@ -4170,10 +4131,11 @@ DemoEffect_DrawJewel_AfterHook:
jal volvagia_flying_hitbox
nop

.include "hacks/z_parameter.asm"
.include "hacks/ovl_en_kz.asm"
.include "hacks/ovl_en_dns.asm"
.include "hacks/en_item00.asm"
.include "hacks/ovl_bg_gate_shutter.asm"
.include "hacks/ovl_bg_haka_tubo.asm"
.include "hacks/ovl_bg_spot18_basket.asm"
.include "hacks/ovl_en_dns.asm"
.include "hacks/ovl_en_kz.asm"
.include "hacks/ovl_obj_mure3.asm"
.include "hacks/ovl_bg_haka_tubo.asm"
.include "hacks/en_item00.asm"
.include "hacks/z_parameter.asm"
52 changes: 52 additions & 0 deletions ASM/src/hacks/ovl_bg_gate_shutter.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
; Hacks in bg_gate_shutter (Kakariko Village Gate)

.headersize(0x80A50A70 - 0xDD34B0)

; Make the Kak gate open based on the setting. Removes the master sword check
; In BgGateShutter_Init where it checks the master sword EVENTINF flag
.org 0x80A50AF4
; Replaces
; lhu t8, 0xedc(v1)
; andi t9, t8, 0x20
jal bg_gate_shutter_open_hack
nop


;==================================================================================================
; Speed Up Gate in Kakariko
;==================================================================================================
; gate opening x
; Replaces: lui at, 0x4000 ;2.0f
.orga 0x80A50C2C
lui at, 0x40D0 ;6.5f

; gate opening z
; Replaces: lui a2, 0x3F4C
; sub.s f8, f4, f6
; lui a3, 0x3E99
; ori a3, a3, 0x999A
; ori a2, a2, 0xCCCD
.orga 0x80A50C3C
lui a2, 0x4000
sub.s f8, f4, f6
lui a3, 0x4000
nop
nop

; gate closing x
; Replaces: lui at, 0x4000 ;2.0f
.orga 0x80A50D04
lui at, 0x40D0 ;6.5f

; gate closing z
; Replaces: lui a2, 0x3F4C
; add.s f8, f4, f6
; lui a3, 0x3E99
; ori a3, a3, 0x999A
; ori a2, a2, 0xCCCD
.orga 0x80A50D14
lui a2, 0x4000
add.s f8, f4, f6
lui a3, 0x4000
nop
nop
7 changes: 3 additions & 4 deletions Patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,10 +1006,9 @@ def set_entrance_updates(entrances: Iterable[Entrance]) -> None:
rom.write_int16(0x00E1F3CA, 0x5036)
rom.write_int16(0x00E1F3CC, 0x5036)

# Make the Kakariko Gate not open with the MS
if world.settings.open_kakariko != 'open':
rom.write_int32(0xDD3538, 0x34190000) # li t9, 0
if world.settings.open_kakariko != 'closed':
if world.settings.open_kakariko == 'open':
rom.write_byte(rom.sym('OPEN_KAKARIKO'), 2)
elif world.settings.open_kakariko != 'closed':
rom.write_byte(rom.sym('OPEN_KAKARIKO'), 1)

# Mark starting trade items as owned
Expand Down
Loading

0 comments on commit 4e00862

Please sign in to comment.