Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,520 changes: 761 additions & 759 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
1,450 changes: 728 additions & 722 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions ASM/c/player.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PLAYER_H
#define PLAYER_H

extern int16_t R_EXITED_SCENE_RIDING_HORSE;

#endif
8 changes: 6 additions & 2 deletions ASM/c/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ typedef struct {
z64_col_water_t *water;
} z64_col_hdr_t;

typedef struct {
/* 0x00 */ z64_col_hdr_t* colHeader; // scene's static collision
/* 0x04 */ char colCtxData[0x1460];
} CollisionContext;

typedef enum {
Z64_ITEM_NULL = -1,
Z64_ITEM_STICK,
Expand Down Expand Up @@ -1394,8 +1399,7 @@ typedef struct {
char unk_07_[0x0010]; /* 0x00798 */
z64_lighting_t lighting; /* 0x007A8 */
char unk_08_[0x0008]; /* 0x007B8 */
z64_col_hdr_t *col_hdr; /* 0x007C0 */
char unk_09_[0x1460]; /* 0x007C4 */
CollisionContext colCtx; /* 0x007C0 */
z64_actor_ctxt_t actor_ctxt; /* 0x01C24 */
uint8_t n_actors_loaded; /* 0x01C2C */
char unk_0A_[0x0003]; /* 0x01C2D */
Expand Down
47 changes: 47 additions & 0 deletions ASM/c/z_player.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "z64.h"
#include "actor.h"
#include "player.h"

#define SCENE_HYRULE_FIELD 0x51
#define SCENE_LAKE_HYLIA 0x57
#define SCENE_GERUDO_VALLEY 0x5A
#define SCENE_GERUDOS_FORTRESS 0x5D
#define SCENE_LON_LON_RANCH 0x63

extern int32_t BgCheck_AnyLineTest1(CollisionContext* colCtx, z64_xyzf_t* posA, z64_xyzf_t* posB,
z64_xyzf_t* posResult, z64_col_poly_t** outPoly, int32_t chkOneFace);

/**
* Do a line intersect test between player position and waterbox surface Y position
* If resulting Y position is less than or equal to waterbox surface, player is either
* in water (eg. Zora's River water- > Hyrule Field) or directly above water surface
* (Gerudo Valley -> Lake Hylia), so should not spawn Epona.
* float ySurface is $f12 = (waterbox Y surface - player Y position)
*/
void Player_CheckEponaWater(volatile float ySurface) {
// Exited riding into an Epona allowed scene
if(R_EXITED_SCENE_RIDING_HORSE == true &&
(z64_game.scene_index == SCENE_HYRULE_FIELD || z64_game.scene_index == SCENE_LAKE_HYLIA ||
z64_game.scene_index == SCENE_GERUDO_VALLEY || z64_game.scene_index == SCENE_GERUDOS_FORTRESS ||
z64_game.scene_index == SCENE_LON_LON_RANCH)) {

z64_col_poly_t* floorPoly;
z64_xyzf_t pos = (z64_xyzf_t){z64_link.common.pos_world.x, ySurface, z64_link.common.pos_world.z};
z64_xyzf_t posResult;

// Check line intersection: player position vs player-waterbox Y position "pos"
// Intersect position is stored in "posResult"
BgCheck_AnyLineTest1(&z64_game.colCtx, &z64_link.common.pos_world, &pos, &posResult, &floorPoly, false);

// If the water surface is either higher than resulting Y position (= is above floor),
// or same height (= is waterbox itself), water is higher than the floor
if((posResult.y <= ySurface)) {
// Dismount in all areas, except Lake Hylia warp entrance (X pos -1045).
// (That waterbox has Y surface -90 for one frame, so special X-based fix is needed)
if((z64_game.scene_index != SCENE_LAKE_HYLIA) || (z64_game.scene_index == SCENE_LAKE_HYLIA &&
!(z64_link.common.pos_world.x > -1050.0f && z64_link.common.pos_world.x < -1040.0f))) {
R_EXITED_SCENE_RIDING_HORSE = false;
}
}
}
}
2 changes: 2 additions & 0 deletions ASM/ootSymbols.ld
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Flags_UnsetTempClear = 0x800206C8;
Flags_GetCollectible = 0x800206E8;
Flags_SetCollectible = 0x8002071C;
Actor_SetColorFilter = 0x80027090;
BgCheck_AnyLineTest1 = 0x80030ae8;
CutsceneFlags_Get = 0x8005991C;
z64_Gfx_SetupDL_42Opa = 0x8007E868;
Audio_StopCurrentMusic = 0x800C7684;
Expand All @@ -27,6 +28,7 @@ z64_ItemIcons = 0x800F8D2C;
z64_SfxDefaultPos = 0x80104394;
z64_SfxDefaultFreqAndVolScale = 0x801043A0;
z64_SfxDefaultReverb = 0x801043A8;
R_EXITED_SCENE_RIDING_HORSE = 0x801c7cf0;
KaleidoScope_DrawAmmoCount = 0x8038EA10;
KaleidoScope_SetCursorVtx = 0x8038EF94;
KaleidoScope_QuadTextureIA8 = 0x80394200;
Expand Down
1 change: 1 addition & 0 deletions ASM/src/build.asm
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ RANDO_CONTEXT:
.include "en_dns.asm"
.include "bg_gate_shutter.asm"
.include "big_poe.asm"
.include "player_callcheckeponawater.asm"

.align 0x10
.importobj "../build/bundle.o"
Expand Down
1 change: 1 addition & 0 deletions ASM/src/hacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4161,3 +4161,4 @@ DemoEffect_DrawJewel_AfterHook:
.include "hacks/ovl_en_ssh.asm"
.include "hacks/ovl_en_okarina_tag.asm"
.include "hacks/sound.asm"
.include "hacks/z_player.asm"
14 changes: 14 additions & 0 deletions ASM/src/hacks/z_player.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.headersize(0x808301c0 - 0xbcdb70)

;================================================================================
; Fixes Epona spawning on water when exiting into a water entrance while riding.
;================================================================================
; Replaces sub.s $f10,$f6,$f8
; move a0,s1
; move a1,s0
; swc1 $f10,40(sp)
.org 0x8083aa1c ; in Player_SetStartingMovement (start at 0x80393360)
sub.s $f12,$f6,$f8 ; (waterbox Y surface - player Y) = ySurface
move s7,a2 ; store Player_Action_StartModeWater address
jal Player_CallCheckEponaWater
swc1 $f12,40(sp) ; store new ySurface (restored in end of jal to $f10)
12 changes: 12 additions & 0 deletions ASM/src/player_callcheckeponawater.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Player_CallCheckEponaWater:
addiu sp,sp,-24
sw ra,16(sp)
jal Player_CheckEponaWater
nop
lw ra,16(sp)
addiu sp,sp,24
move a0,s1
move a1,s0 ; Restore displaced a0 and a1 (z64_game and z64_link),
move a2,s7 ; address to Player_Action_StartModeWater to a2,
jr ra
lwc1 $f10,40(sp) ; and ySurface as $f10 (for c.le.s after return)
2 changes: 1 addition & 1 deletion data/generated/patch_symbols.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading