diff --git a/include/z64.h b/include/z64.h index 3d711dd7e7..e4a1dbd62d 100644 --- a/include/z64.h +++ b/include/z64.h @@ -341,7 +341,9 @@ typedef struct { /* 0x000 */ UNK_TYPE1 pad0[0xC]; /* 0x00C */ s32 sceneSetupIndex; /* 0x010 */ s32 unk10; - /* 0x014 */ UNK_TYPE1 pad14[0x2E]; + /* 0x014 */ UNK_TYPE1 pad14[0x10]; + /* 0x024 */ s16 unk24; + /* 0x040 */ UNK_TYPE1 pad22[0x1C]; /* 0x042 */ s16 unk42; /* 0x044 */ UNK_TYPE1 pad44[0x34]; /* 0x078 */ f32 unk78; @@ -379,7 +381,8 @@ typedef struct { /* 0x0002 */ u8 unk2; /* 0x0003 */ UNK_TYPE1 pad3[0x2]; /* 0x0005 */ u8 unk5; - /* 0x0006 */ UNK_TYPE1 pad6[0x2C8E]; + /* 0x0006 */ UNK_TYPE1 pad6[0x2C8C]; + /* 0x0006 */ s16 unk_A00; } SaveContextOwl; // size = 0x2C94 typedef struct { diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index a8f4aedcfe..6fd927e0dc 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -4969,9 +4969,9 @@ SECTIONS ovl_En_Warp_Uzu : AT(RomLocation) { build/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.o(.text) - build/asm/overlays/ovl_En_Warp_Uzu_data.o(.data) + build/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.o(.data) build/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.o(.rodata) - build/asm/overlays/ovl_En_Warp_Uzu_rodata.o(.rodata) + build/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index cc49cfee0c..b5d90bd6e7 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -191,6 +191,9 @@ D_06000140 = 0x06000140; D_06000A20 = 0x06000A20; D_06000040 = 0x06000040; +/* z_en_warp_uzu */ +D_06000EC0 = 0x06000EC0; + /* en_cha */ D_06000710 = 0x06000710; D_06000958 = 0x06000958; diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 8188b90bf1..b014b20a5b 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -1,3 +1,9 @@ +/* + * File: z_en_warp_uzu.c + * Overlay: ovl_En_Warp_Uzu + * Description: Pirates Fortress Telescope + */ + #include "z_en_warp_uzu.h" #define FLAGS 0x00000019 @@ -9,7 +15,11 @@ void EnWarpUzu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWarpUzu_Update(Actor* thisx, GlobalContext* globalCtx); void EnWarpUzu_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx); +void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx); +void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx); +void EnWarpUzu_DoNothing(EnWarpUzu* this, GlobalContext* globalCtx); + const ActorInit En_Warp_Uzu_InitVars = { ACTOR_EN_WARP_UZU, ACTORCAT_PROP, @@ -19,22 +29,109 @@ const ActorInit En_Warp_Uzu_InitVars = { (ActorFunc)EnWarpUzu_Init, (ActorFunc)EnWarpUzu_Destroy, (ActorFunc)EnWarpUzu_Update, - (ActorFunc)EnWarpUzu_Draw + (ActorFunc)EnWarpUzu_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/EnWarpUzu_Init.asm") +static ColliderCylinderInit D_80A664C0 = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 25, 43, -20, { 0, 0, 0 } }, +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/EnWarpUzu_Destroy.asm") +static InitChainEntry D_80A664EC[] = { + ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/func_80A66208.asm") +extern UNK_TYPE D_06000EC0; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/func_80A66278.asm") +void EnWarpUzu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWarpUzu* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/func_80A66384.asm") + Actor_ProcessInitChain(&this->actor, &D_80A664EC); + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &D_80A664C0); + thisx->targetMode = 0; + func_80A66208(thisx, globalCtx); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/func_80A663E8.asm") +void EnWarpUzu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWarpUzu* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/EnWarpUzu_Update.asm") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Warp_Uzu_0x80A66180/EnWarpUzu_Draw.asm") +static Vec3f D_80A664FC = { 0.0f, 53.0f, -29.0f }; +void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { + Vec3f sp24; + + this->actor.textId = 0; + Matrix_RotateY(this->actor.shape.rot.y, 0); + SysMatrix_MultiplyVector3fByState(&D_80A664FC, &sp24); + Math_Vec3f_Sum(&this->actor.world, &sp24, &this->actor.focus); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.shape); + this->actionFunc = func_80A66278; +} + +void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { + Actor* sp24; + s16 temp_v0; + s16 phi_a0; + s16 phi_v1; + + do { + sp24 = globalCtx->actorCtx.actorList[2].first; + if (func_800B84D0(&this->actor, globalCtx)) { + func_80A66384(this, globalCtx); + } else { + phi_a0 = ABS((s16)(Actor_YawBetweenActors(&this->actor, sp24) - this->actor.shape.rot.y)); + temp_v0 = sp24->shape.rot.y - this->actor.shape.rot.y; + phi_v1 = ABS(temp_v0); + if (phi_a0 >= 0x2AAB) { + if (phi_v1 < 0x238E) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } + } + } + } while (0); +} + +void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x22A0; + gSaveContext.extra.unk24 = globalCtx->nextEntranceIndex; + func_80169EFC(globalCtx); + gSaveContext.extra.unk10 = -2; + this->actionFunc = EnWarpUzu_DoNothing; +} + +void EnWarpUzu_DoNothing(EnWarpUzu* this, GlobalContext* globalCtx) { +} + +void EnWarpUzu_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWarpUzu* this = THIS; + s32 pad; + + this->actor.uncullZoneForward = 1000.0f; + this->actionFunc(this, globalCtx); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->collider); +} + +void EnWarpUzu_Draw(Actor* thisx, GlobalContext* globalCtx) { + func_800BDFC0(globalCtx, &D_06000EC0); +} diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h index 2ea4c8d305..f6b74b2a2c 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.h @@ -5,9 +5,12 @@ struct EnWarpUzu; +typedef void (*EnWarpUzuActionFunc)(struct EnWarpUzu*, GlobalContext*); + typedef struct EnWarpUzu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x50]; + /* 0x144 */ EnWarpUzuActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; } EnWarpUzu; // size = 0x194 extern const ActorInit En_Warp_Uzu_InitVars; diff --git a/tables/functions.txt b/tables/functions.txt index 5f2865253f..a00c110504 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -10834,7 +10834,7 @@ 0x80A66208:("func_80A66208",), 0x80A66278:("func_80A66278",), 0x80A66384:("func_80A66384",), - 0x80A663E8:("func_80A663E8",), + 0x80A663E8:("EnWarpUzu_DoNothing",), 0x80A663F8:("EnWarpUzu_Update",), 0x80A66468:("EnWarpUzu_Draw",), 0x80A66570:("func_80A66570",),