obj_boat decompiled (#842)

* obj_boat decompiled

* PR review fixes

* pr review fixes

* PR Review fixes

* PR review fixes

* final cleanup

Co-authored-by: SonicDcer <noreply@github.com>
This commit is contained in:
Alejandro Asenjo 2022-06-19 19:45:00 -03:00 committed by GitHub
parent ab7625db65
commit 3997776e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 161 additions and 24 deletions

3
spec
View File

@ -4284,8 +4284,7 @@ beginseg
name "ovl_Obj_Boat"
compress
include "build/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.o"
include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.data.o"
include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.reloc.o"
include "build/src/overlays/actors/ovl_Obj_Boat/ovl_Obj_Boat_reloc.o"
endseg
beginseg

View File

@ -5,6 +5,7 @@
*/
#include "z_obj_boat.h"
#include "objects/object_kaizoku_obj/object_kaizoku_obj.h"
#define FLAGS (ACTOR_FLAG_10)
@ -15,7 +16,8 @@ void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx);
void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx);
#if 0
void func_80B9B428(Actor* thisx, GlobalContext* globalCtx);
const ActorInit Obj_Boat_InitVars = {
ACTOR_OBJ_BOAT,
ACTORCAT_BG,
@ -28,31 +30,162 @@ const ActorInit Obj_Boat_InitVars = {
(ActorFunc)ObjBoat_Draw,
};
// static InitChainEntry sInitChain[] = {
static InitChainEntry D_80B9B680[] = {
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP),
};
#endif
s16 func_80B9AF50(ObjBoat* this, Vec3f* arg0) {
s16 yaw;
Vec3s* temp = &this->unk_164[(s32)this->unk_15C];
extern InitChainEntry D_80B9B680[];
Math_Vec3s_ToVec3f(arg0, &temp[this->unk_15D]);
yaw = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg0);
extern UNK_TYPE D_06007630;
extern UNK_TYPE D_06009A88;
return ((this->unk_15D > 0) ? yaw : (yaw + 0x8000));
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9AF50.s")
void ObjBoat_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad[2];
Path* path;
ObjBoat* this = THIS;
Vec3f sp24;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Init.s")
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, 3);
DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kaizoku_obj_Colheader_009A88);
if (thisx->params < 0) {
this->dyna.actor.update = func_80B9B428;
} else {
path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(thisx)];
this->unk_163 = path->count - 1;
this->unk_164 = Lib_SegmentedToVirtual(path->points);
this->unk_15D = 1;
this->dyna.actor.world.pos.x = this->unk_164[this->unk_15C].x;
this->dyna.actor.world.pos.z = this->unk_164[this->unk_15C].z;
this->dyna.actor.shape.rot.y = func_80B9AF50(this, &sp24);
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y;
this->unk_15D = -this->unk_15D;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Destroy.s")
void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx) {
ObjBoat* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B124.s")
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Update.s")
void func_80B9B124(ObjBoat* this) {
this->unk_160 += 1000;
this->dyna.actor.world.pos.y = Math_SinS(this->unk_160) + this->dyna.actor.home.pos.y;
this->dyna.actor.shape.rot.x = Math_SinS(this->unk_160) * 100.0f;
this->dyna.actor.shape.rot.z = Math_SinS(this->unk_160 * 2) * 50.0f;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B428.s")
void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
ObjBoat* this = THIS;
Player* player = GET_PLAYER(globalCtx);
s32 temp = DynaPolyActor_IsInRidingMovingState(&this->dyna);
f32 sp3C = 0.0f;
s16 sp3A = this->dyna.actor.shape.rot.y;
Vec3f sp2C;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Draw.s")
if ((temp != 0) || ((DynaPolyActor_IsInRidingFallingState(&this->dyna)))) {
if ((this->unk_15F == 0) && (OBJBOAT_GET_4000(thisx) || ((temp != 0) && (this->unk_15C == this->unk_15E)))) {
this->unk_15D = -this->unk_15D;
if (this->unk_15D > 0) {
this->unk_15E = this->unk_163;
} else {
this->unk_15E = 0;
}
this->unk_15F = 60;
}
} else if (this->dyna.actor.speedXZ == 0.0f) {
if (this->unk_15F != 0) {
this->unk_15F--;
}
}
if (this->unk_15C != this->unk_15E) {
sp3A = func_80B9AF50(this, &sp2C);
if (Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp2C) < 200.0f) {
this->unk_15C += this->unk_15D;
if (this->unk_15C == this->unk_15E) {
if (OBJBOAT_GET_4000(thisx)) {
this->unk_15C = 0;
} else if (this->dyna.actor.speedXZ == 0.0f) {
this->unk_15C = 0;
this->unk_15D = -1;
}
}
} else {
sp3C = this->unk_15D * (OBJBOAT_GET_4000(thisx) ? 5.0f : 3.0f);
}
}
if (player->csMode != 0x1A) {
Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, sp3A, (s16)(s32)(fabsf(this->dyna.actor.speedXZ) * 40.0f));
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y;
Math_StepToF(&this->dyna.actor.speedXZ, sp3C, 0.05f);
Actor_MoveWithGravity(&this->dyna.actor);
if (this->dyna.actor.speedXZ != 0.0f) {
func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG);
}
}
func_80B9B124(this);
}
void func_80B9B428(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
ObjBoat* this = THIS;
if (Cutscene_CheckActorAction(globalCtx, 511)) {
CsCmdActorAction* actionIndex = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 511)];
if (this->unk_15F != actionIndex->action) {
this->dyna.actor.shape.rot.x = actionIndex->urot.x;
if (actionIndex->action != 1) {
Path* path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(&this->dyna.actor)];
if (actionIndex->action == 3) {
path = &globalCtx->setupPathList[path->unk1];
}
this->unk_163 = path->count;
this->unk_164 = Lib_SegmentedToVirtual(path->points);
Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->unk_164);
this->dyna.actor.speedXZ = actionIndex->urot.z * (45.0f / 0x2000);
this->unk_164++;
this->unk_15C = 1;
}
this->unk_15F = actionIndex->action;
} else {
if (actionIndex->action != 1) {
Vec3f vec;
f32 step;
Math_Vec3s_ToVec3f(&vec, this->unk_164);
step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &vec, this->dyna.actor.speedXZ);
if ((this->unk_15C < this->unk_163) && (step < this->dyna.actor.speedXZ)) {
this->unk_164++;
this->unk_15C++;
}
}
if (actionIndex->action != 3) {
func_80B9B124(this);
if (actionIndex->action == 2) {
func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG);
}
} else {
this->dyna.actor.shape.rot.y += 0x7D0;
this->dyna.actor.shape.rot.x += 0x3E8;
this->dyna.actor.shape.rot.z += 0x1F4;
}
}
}
}
void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx) {
ObjBoat* this = THIS;
Gfx_DrawDListOpa(globalCtx, object_kaizoku_obj_DL_007630);
}

View File

@ -3,12 +3,22 @@
#include "global.h"
#define OBJBOAT_GET_PATH(thisx) (((thisx)->params >> 7) & 0x1F)
#define OBJBOAT_GET_4000(thisx) ((thisx)->params & 0x4000)
struct ObjBoat;
typedef struct ObjBoat {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x24];
} ObjBoat; // size = 0x168
/* 0x000 */ DynaPolyActor dyna;
/* 0x15C */ u8 unk_15C;
/* 0x15D */ s8 unk_15D;
/* 0x15E */ u8 unk_15E;
/* 0x15F */ u8 unk_15F;
/* 0x160 */ s16 unk_160;
/* 0x162 */ UNK_TYPE1 pad_162;
/* 0x163 */ u8 unk_163;
/* 0x164 */ Vec3s* unk_164;
} ObjBoat;
extern const ActorInit Obj_Boat_InitVars;

View File

@ -1552,11 +1552,6 @@ D_06000168 = 0x06000168;
D_060003F8 = 0x060003F8;
D_060004B0 = 0x060004B0;
// ovl_Obj_Boat
D_06007630 = 0x06007630;
D_06009A88 = 0x06009A88;
// ovl_Obj_Chikuwa
D_06000D10 = 0x06000D10;