Arms_Hook OK (#33)

* All but 2 functions matched

* More work on hookshot

* hookshot work

* 2 functions left (and one is almost done)

* sp issues with draw, but matching otherwise

* hookshot matching

* Changed rodata inclusion for armshook

* Hookshot OK

* Resolve script conflicts

* Rename unk variables to match MM standard

* Made requested changes
This commit is contained in:
fullgrowngaming
2020-10-11 16:30:22 -07:00
committed by GitHub
parent 1c4a3047de
commit f927730418
17 changed files with 404 additions and 62 deletions
-2
View File
@@ -1,7 +1,5 @@
#include <ultra64.h>
#include <global.h>
extern float fabsf(float);
#pragma intrinsic (fabsf)
void EffFootmark_Init(GlobalContext* ctxt) {
EffFootmark* footmark;
-4
View File
@@ -1,10 +1,6 @@
#include <ultra64.h>
#include <global.h>
#pragma intrinsic (sqrtf)
extern float fabsf(float);
#pragma intrinsic (fabsf)
void* Lib_bcopy(void* dest, void* src, size_t n) {
_bcopy(src, dest, n);
-4
View File
@@ -1,10 +1,6 @@
#include <ultra64.h>
#include <global.h>
#pragma intrinsic (sqrtf)
extern float fabsf(float);
#pragma intrinsic (fabsf)
void Lights_InitPositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue, s16 radius, u32 type) {
info->type = type;
info->params.posX = posX;
+289 -14
View File
@@ -9,7 +9,9 @@ void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx);
void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx);
void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx);
const ActorInit Arms_Hook_InitVars = {
ACTOR_ARMS_HOOK,
ACTORTYPE_ITEMACTION,
@@ -21,28 +23,301 @@ const ActorInit Arms_Hook_InitVars = {
(ActorFunc)ArmsHook_Update,
(ActorFunc)ArmsHook_Draw
};
*/
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C1030.asm")
ColQuadInit D_808C1BC0 = {
{ 10, 0x09, 0x00, 0x00, 0x08, 3 },
{ 0x02, { 0x00000080, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, 0x05, 0x00, 0x00 },
{ 0 },
};
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/ArmsHook_Init.asm")
Vec3f D_808C1C10 = { 0.0f, 0.0f, 0.0f };
Vec3f D_808C1C1C = { 0.0f, 0.0f, 900.0f };
Vec3f D_808C1C28 = { 0.0f, 500.0f, -3000.0f };
Vec3f D_808C1C34 = { 0.0f, -500.0f, -3000.0f };
Vec3f D_808C1C40 = { 0.0f, 500.0f, 0.0f };
Vec3f D_808C1C4C = { 0.0f, -500.0f, 0.0f };
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/ArmsHook_Destroy.asm")
extern Gfx D_0601D960[];
extern Gfx D_040008D0[];
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C10F8.asm")
void ArmsHook_SetupAction(ArmsHook* this, ArmsHookActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C1154.asm")
void ArmsHook_Init(Actor* thisx, GlobalContext* globalCtx) {
ArmsHook* this = THIS;
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C1168.asm")
Collision_InitQuadDefault(globalCtx, &this->collider);
Collision_InitQuadWithData(globalCtx, &this->collider, &this->actor, &D_808C1BC0);
ArmsHook_SetupAction(this, ArmsHook_Wait);
this->unk1E0 = this->actor.currPosRot.pos;
}
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C1198.asm")
void ArmsHook_Destroy(Actor* thisx, GlobalContext* globalCtx) {
ArmsHook* this = THIS;
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C11C0.asm")
if (this->grabbed != NULL) {
this->grabbed->flags &= ~0x2000;
}
Collision_FiniQuad(globalCtx, &this->collider);
}
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C125C.asm")
void ArmsHook_Wait(ArmsHook* this, GlobalContext* globalCtx) {
if (this->actor.parent == NULL) {
ArmsHook_SetupAction(this, ArmsHook_Shoot);
func_800B6C04(&this->actor, 20.0f);
this->actor.parent = &PLAYER->base;
this->timer = 26;
}
}
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/func_808C12A4.asm")
void func_808C1154(ArmsHook* this) {
this->actor.child = this->actor.parent;
this->actor.parent->parent = &this->actor;
}
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/ArmsHook_Update.asm")
s32 ArmsHook_AttachToPlayer(ArmsHook* this, ActorPlayer* player) {
player->base.child = &this->actor;
player->heldActor = &this->actor;
if (this->actor.child != NULL) {
player->base.parent = this->actor.child = NULL;
return 1;
}
return 0;
}
GLOBAL_ASM("asm/non_matchings/ovl_Arms_Hook_0x808C1030/ArmsHook_Draw.asm")
void ArmsHook_DetachHookFromActor(ArmsHook* this) {
if (this->grabbed != NULL) {
this->grabbed->flags &= ~0x2000;
this->grabbed = NULL;
}
}
s32 ArmsHook_CheckForCancel(ArmsHook* this) {
ActorPlayer* player = (ActorPlayer*)this->actor.parent;
if (func_801240C8(player)) {
if ((player->heldItemActionParam != player->itemActionParam) || ((player->base.flags & 0x100)) ||
((player->stateFlags1 & 0x4000080))) {
this->timer = 0;
ArmsHook_DetachHookFromActor(this);
Math_Vec3f_Copy(&this->actor.currPosRot.pos, &player->unk368);
return 1;
}
}
return 0;
}
void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) {
actor->flags |= 0x2000;
this->grabbed = actor;
Math_Vec3f_Diff(&actor->currPosRot.pos, &this->actor.currPosRot.pos, &this->unk1FC);
}
void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) {
ActorPlayer* player = PLAYER;
if ((this->actor.parent == NULL) || (!func_801240C8(player))) {
ArmsHook_DetachHookFromActor(this);
Actor_MarkForDeath(&this->actor);
return;
}
func_800B8F98(&player->base, 0x100B);
ArmsHook_CheckForCancel(this);
if (this->timer != 0 && (this->collider.base.flagsAT & 2) && (this->collider.body.unk20->unk14 != 4)) {
Actor* touchedActor = this->collider.base.collisionAT;
if ((touchedActor->update != NULL) && (touchedActor->flags & 0x600)) {
if (this->collider.body.unk20->unk16 & 4) {
ArmsHook_AttachHookToActor(this, touchedActor);
if ((touchedActor->flags & 0x400) == 0x400) {
func_808C1154(this);
}
}
}
this->timer = 0;
func_8019F1C0(&this->actor.projectedPos, 0x1814);
return;
}
if (DECR(this->timer) == 0) {
Actor* grabbed;
Vec3f bodyDistDiffVec;
Vec3f newPos;
f32 bodyDistDiff;
f32 phi_f16;
s32 pad;
grabbed = this->grabbed;
if (grabbed != NULL) {
if ((grabbed->update == NULL) || (grabbed->flags & 0x2000) != 0x2000) {
grabbed = NULL;
this->grabbed = NULL;
} else {
if (this->actor.child != NULL) {
f32 sp94 = Actor_DistanceBetweenActors(this, grabbed);
f32 sp90 = sqrtf(SQ(this->unk1FC.x) + SQ(this->unk1FC.y) + SQ(this->unk1FC.z));
Math_Vec3f_Diff(&grabbed->currPosRot.pos, &this->unk1FC, &this->actor.currPosRot.pos);
if (50.0f < (sp94 - sp90)) {
ArmsHook_DetachHookFromActor(this);
grabbed = NULL;
}
}
}
}
{
f32 velocity;
bodyDistDiff =
Math_Vec3f_DistXYZAndStoreDiff(&player->unk368, &this->actor.currPosRot.pos, &bodyDistDiffVec);
if (bodyDistDiff < 30.0f) {
velocity = 0.0f;
phi_f16 = 0.0f;
} else {
if (this->actor.child != NULL) {
velocity = 30.0f;
} else {
if (grabbed != NULL) {
velocity = 50.0f;
} else {
velocity = 200.0f;
}
}
phi_f16 = bodyDistDiff - velocity;
if (bodyDistDiff <= velocity) {
phi_f16 = 0.0f;
}
velocity = phi_f16 / bodyDistDiff;
}
newPos.x = bodyDistDiffVec.x * velocity;
newPos.y = bodyDistDiffVec.y * velocity;
newPos.z = bodyDistDiffVec.z * velocity;
}
if (this->actor.child == NULL) {
Math_Vec3f_Sum(&player->unk368, &newPos, &this->actor.currPosRot.pos);
if (grabbed != NULL) {
Math_Vec3f_Sum(&this->actor.currPosRot.pos, &this->unk1FC, &grabbed->currPosRot.pos);
}
} else {
Math_Vec3f_Diff(&bodyDistDiffVec, &newPos, &player->base.velocity);
player->base.currPosRot.rot.x =
atans_flip(sqrtf(SQ(bodyDistDiffVec.x) + SQ(bodyDistDiffVec.z)), -bodyDistDiffVec.y);
}
if (phi_f16 < 50.0f) {
ArmsHook_DetachHookFromActor(this);
if (phi_f16 == 0.0f) {
ArmsHook_SetupAction(this, ArmsHook_Wait);
if (ArmsHook_AttachToPlayer(this, player)) {
Math_Vec3f_Diff(&this->actor.currPosRot.pos, &player->base.currPosRot.pos, &player->base.velocity);
player->base.velocity.y -= 20.0f;
}
}
}
} else {
BgPolygon* poly;
u32 dynaPolyID;
Vec3f sp78;
Vec3f prevFrameDiff;
Vec3f sp60;
Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor);
Math_Vec3f_Diff(&this->actor.currPosRot.pos, &this->actor.lastPos, &prevFrameDiff);
Math_Vec3f_Sum(&this->unk1E0, &prevFrameDiff, &this->unk1E0);
this->actor.shape.rot.x = atans_flip(this->actor.speedXZ, -this->actor.velocity.y);
sp60.x = this->unk1EC.x - (this->unk1E0.x - this->unk1EC.x);
sp60.y = this->unk1EC.y - (this->unk1E0.y - this->unk1EC.y);
sp60.z = this->unk1EC.z - (this->unk1E0.z - this->unk1EC.z);
if (func_800C55C4(&globalCtx->colCtx, &sp60, &this->unk1E0, &sp78, &poly, 1, 1, 1, 1, &dynaPolyID) != 0 &&
(func_800B90AC(globalCtx, &this->actor, poly, dynaPolyID, &sp78) == 0 ||
func_800C576C(&globalCtx->colCtx, &sp60, &this->unk1E0, &sp78, &poly, 1, 1, 1, 1, &dynaPolyID) != 0)) {
f32 sp5C = poly->normal.x * (1 / SHT_MAX);
f32 sp58 = poly->normal.z * (1 / SHT_MAX);
Math_Vec3f_Copy(&this->actor.currPosRot.pos, &sp78);
this->actor.currPosRot.pos.x += 10.0f * sp5C;
this->actor.currPosRot.pos.z += 10.0f * sp58;
this->timer = 1;
if (func_800C9CEC(&globalCtx->colCtx, poly, dynaPolyID)) {
{
DynaPolyActor* dynaPolyActor;
if (dynaPolyID != 0x32 &&
(dynaPolyActor = BgCheck_GetActorOfMesh(&globalCtx->colCtx, dynaPolyID)) != NULL) {
ArmsHook_AttachHookToActor(this, &dynaPolyActor->actor);
}
}
func_808C1154(this);
func_8019F1C0(&this->actor.projectedPos, 0x1829);
} else {
func_800E8668(globalCtx, &this->actor.currPosRot.pos);
func_8019F1C0(&this->actor.projectedPos, 0x1813);
}
} else {
if ((globalCtx->state.input[0].pressEdge.buttons &
(A_BUTTON | B_BUTTON | R_TRIG | U_CBUTTONS | L_CBUTTONS | R_CBUTTONS | D_CBUTTONS))) {
s32 pad;
this->timer = 1;
}
}
}
}
void ArmsHook_Update(Actor* thisx, GlobalContext* globalCtx) {
ArmsHook* this = THIS;
this->actionFunc(this, globalCtx);
this->unk1EC = this->unk1E0;
}
void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) {
ArmsHook* this = THIS;
s32 pad;
ActorPlayer* player = PLAYER;
Vec3f sp68;
Vec3f sp5C;
Vec3f sp50;
f32 sp4C;
f32 sp48;
if (player->base.draw != NULL && player->unk151 == 0xB) {
// OPEN_DISP macro
{
GraphicsContext* sp44 = globalCtx->state.gfxCtx;
f32 f0;
if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) {
SysMatrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0);
SysMatrix_MultiplyVector3fByState(&D_808C1C28, &sp5C);
SysMatrix_MultiplyVector3fByState(&D_808C1C34, &sp50);
this->unk1C4 = 0;
} else {
SysMatrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0);
SysMatrix_MultiplyVector3fByState(&D_808C1C40, &sp5C);
SysMatrix_MultiplyVector3fByState(&D_808C1C4C, &sp50);
}
func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50);
func_8012C28C(globalCtx->state.gfxCtx);
func_80122868(globalCtx, player);
gSPMatrix(sp44->polyOpa.p++, SysMatrix_AppendStateToPolyOpaDisp(globalCtx->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(sp44->polyOpa.p++, D_0601D960);
SysMatrix_InsertTranslation(this->actor.currPosRot.pos.x, this->actor.currPosRot.pos.y,
this->actor.currPosRot.pos.z, MTXMODE_NEW);
Math_Vec3f_Diff(&player->unk368, &this->actor.currPosRot.pos, &sp68);
sp48 = SQ(sp68.x) + SQ(sp68.z);
sp4C = sqrtf(sp48);
SysMatrix_InsertYRotation_s(atans(sp68.x, sp68.z), MTXMODE_APPLY);
SysMatrix_InsertXRotation_s(atans(-sp68.y, sp4C), MTXMODE_APPLY);
f0 = sqrtf(SQ(sp68.y) + sp48);
SysMatrix_InsertScale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY);
gSPMatrix(sp44->polyOpa.p++, SysMatrix_AppendStateToPolyOpaDisp(globalCtx->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(sp44->polyOpa.p++, D_040008D0);
func_801229A0(globalCtx, player);
}
}
}
@@ -5,9 +5,20 @@
struct ArmsHook;
typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*);
typedef struct ArmsHook {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0xCC];
/* 0x144 */ ColQuad collider;
/* 0x1C4 */ s32 unk1C4;
/* 0x1C8 */ char unk1C8[0x18];
/* 0x1E0 */ Vec3f unk1E0;
/* 0x1EC */ Vec3f unk1EC;
/* 0x1F8 */ Actor* grabbed;
/* 0x1FC */ Vec3f unk1FC;
/* 0x208 */ char unk208[0x2];
/* 0x20A */ s16 timer;
/* 0x20C */ ArmsHookActionFunc actionFunc;
} ArmsHook; // size = 0x210
extern const ActorInit Arms_Hook_InitVars;
@@ -47,7 +47,7 @@ void BgFuKaiten_UpdateRotation(BgFuKaiten* this) {
if (this->rotationSpeed > 0)
{
f0 = this->rotationSpeed * .002f;
func_8019FAD8(&this->bg.actor.unkEC, 8310, f0);
func_8019FAD8(&this->bg.actor.projectedPos, 8310, f0);
}
}