mirror of https://github.com/zeldaret/mm.git
Boyo (#1341)
* updated variables.txt * continue investigation * format to style * matching more asm * still more asm matching * finally matching * matching even more * add rodata * match more asm for Update * matching 99.58% of ObjBoyo_Update * matched ObjBoyo_Update * some cleanup * formatted * review: remove ACTOR_COLLISION_HANDLING_CASES define * review: fix main functions parameters * review: fix collision function signatures * review: fix ObjBoyo_FindCollidedActor parameters * review: better formatting for InitVars * review: fix ObjBoyoCollisionHandler typedef * review: fix segmented AnimatedMaterial * review: fix static ColliderCylinderInit * review: disassembled initchain * review: fix collision functions * review: fix functions.txt * review: fix variables.txt * review: clean z_obj_boyo.h * review: fix ObjBoyo_Destroy * remove fake variable from ObjBoyo_Init * review: rematch FindCollidedActor * review: make asm match again * review: update spec file * review: fix spec file * review: remove static D_*** * review: fix bad logic to find collided actor * review: fix ObjBoyo size (local make is now OK) * review: rename collision handlers array * review: use constant * review: clean PushPlayer function * review: fix LSP bad renaming * review: use GET_PLAYER macro * review: remove ugly pointer deref * review: replace += 1 with ++ * review: return NULL to emphasize it is a pointer * review: check against NULL instead of 0 * review: remove unnecessary casts * review: use constants * review: remove unnecessary include * review: rename variables + fix assembly matching * review: change ++i to i++ * review: fix inline comments * review: replace != with < in for loop
This commit is contained in:
parent
2c182bf7e3
commit
2e344b8d15
3
spec
3
spec
|
@ -2108,8 +2108,7 @@ beginseg
|
|||
name "ovl_Obj_Boyo"
|
||||
compress
|
||||
include "build/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.o"
|
||||
include "build/data/ovl_Obj_Boyo/ovl_Obj_Boyo.data.o"
|
||||
include "build/data/ovl_Obj_Boyo/ovl_Obj_Boyo.reloc.o"
|
||||
include "build/src/overlays/actors/ovl_Obj_Boyo/ovl_Obj_Boyo_reloc.o"
|
||||
endseg
|
||||
|
||||
beginseg
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include "z_obj_boyo.h"
|
||||
#include "overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h"
|
||||
#include "overlays/actors/ovl_En_Bom/z_en_bom.h"
|
||||
#include "objects/object_boyo/object_boyo.h"
|
||||
|
||||
#define FLAGS (ACTOR_FLAG_10)
|
||||
|
||||
|
@ -9,7 +12,11 @@ void ObjBoyo_Destroy(Actor* thisx, PlayState* play2);
|
|||
void ObjBoyo_Update(Actor* thisx, PlayState* play2);
|
||||
void ObjBoyo_Draw(Actor* thisx, PlayState* play);
|
||||
|
||||
/*
|
||||
void ObjBoyo_PushPlayer(ObjBoyo* this, Actor* actor);
|
||||
void ObjBoyo_PushPirate(ObjBoyo* this, Actor* actor);
|
||||
void ObjBoyo_ExplodeBomb(ObjBoyo* this, Actor* actor);
|
||||
Actor* ObjBoyo_FindCollidedActor(ObjBoyo* this, PlayState* play, s32* index);
|
||||
|
||||
const ActorInit Obj_Boyo_InitVars = {
|
||||
ACTOR_OBJ_BOYO,
|
||||
ACTORCAT_PROP,
|
||||
|
@ -19,22 +26,184 @@ const ActorInit Obj_Boyo_InitVars = {
|
|||
(ActorFunc)ObjBoyo_Init,
|
||||
(ActorFunc)ObjBoyo_Destroy,
|
||||
(ActorFunc)ObjBoyo_Update,
|
||||
(ActorFunc)ObjBoyo_Draw
|
||||
(ActorFunc)ObjBoyo_Draw,
|
||||
};
|
||||
*/
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Init.s")
|
||||
typedef void (*ObjBoyoCollisionHandler)(ObjBoyo* this, Actor* actor);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Destroy.s")
|
||||
typedef struct ObjBoyoUnkStruct {
|
||||
/* 0x0 */ s16 id;
|
||||
/* 0x4 */ ObjBoyoCollisionHandler colHandler;
|
||||
} ObjBoyoUnkStruct; // size = 0x8
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5DC0.s")
|
||||
static ColliderCylinderInit sCylinderInit = {
|
||||
{
|
||||
COLTYPE_NONE,
|
||||
AT_NONE,
|
||||
AC_TYPE_PLAYER | AC_HARD | AC_ON,
|
||||
OC1_TYPE_2 | OC1_TYPE_1 | OC1_TYPE_PLAYER | OC1_ON,
|
||||
OC2_TYPE_2,
|
||||
COLSHAPE_CYLINDER,
|
||||
},
|
||||
{
|
||||
ELEMTYPE_UNK0,
|
||||
{ 0x00000000, 0x00, 0x00 },
|
||||
{ 0x01CBFFBE, 0x00, 0x00 },
|
||||
TOUCH_NONE,
|
||||
BUMP_ON,
|
||||
OCELEM_ON,
|
||||
},
|
||||
{
|
||||
60,
|
||||
140,
|
||||
0,
|
||||
{ 0, 0, 0 },
|
||||
},
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5DE0.s")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE),
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5E14.s")
|
||||
static ObjBoyoUnkStruct sCollisionHandlers[] = {
|
||||
{ ACTOR_PLAYER, ObjBoyo_PushPlayer },
|
||||
{ ACTOR_EN_KAIZOKU, ObjBoyo_PushPirate },
|
||||
{ ACTOR_EN_BOM, ObjBoyo_ExplodeBomb },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/func_809A5E24.s")
|
||||
void ObjBoyo_Init(Actor* thisx, PlayState* play) {
|
||||
ObjBoyo* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Update.s")
|
||||
Actor_ProcessInitChain(&this->actor, sInitChain);
|
||||
Collider_InitCylinder(play, &this->collider);
|
||||
Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
|
||||
Collider_UpdateCylinder(&this->actor, &this->collider);
|
||||
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
|
||||
this->animatedMaterial = Lib_SegmentedToVirtual(&object_boyo_Matanimheader_000E88);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boyo/ObjBoyo_Draw.s")
|
||||
void ObjBoyo_Destroy(Actor* thisx, PlayState* play2) {
|
||||
PlayState* play = play2;
|
||||
ObjBoyo* this = THIS;
|
||||
|
||||
Collider_DestroyCylinder(play, &this->collider);
|
||||
}
|
||||
|
||||
void ObjBoyo_PushPlayer(ObjBoyo* this, Actor* actor) {
|
||||
Player* player = (Player*)actor;
|
||||
|
||||
player->pushedSpeed = 30.0f;
|
||||
player->pushedYaw = this->actor.yawTowardsPlayer;
|
||||
}
|
||||
|
||||
void ObjBoyo_PushPirate(ObjBoyo* this, Actor* actor) {
|
||||
EnKaizoku* kaizoku = (EnKaizoku*)actor;
|
||||
|
||||
kaizoku->unk_2F0 = 30.0f;
|
||||
kaizoku->unk_2F4 = Actor_WorldYawTowardActor(&this->actor, &kaizoku->picto.actor);
|
||||
}
|
||||
|
||||
void ObjBoyo_ExplodeBomb(ObjBoyo* this, Actor* actor) {
|
||||
EnBom* bom = (EnBom*)actor;
|
||||
|
||||
bom->timer = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the Actor we collided with.
|
||||
*/
|
||||
Actor* ObjBoyo_FindCollidedActor(ObjBoyo* this, PlayState* play, s32* index) {
|
||||
Actor* collidedActor;
|
||||
ObjBoyoUnkStruct* iter;
|
||||
s32 i;
|
||||
|
||||
if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) {
|
||||
*index = 0;
|
||||
return &GET_PLAYER(play)->actor;
|
||||
}
|
||||
iter = sCollisionHandlers + 1;
|
||||
if (this->collider.base.ocFlags1 & OC1_HIT) {
|
||||
collidedActor = this->collider.base.oc;
|
||||
for (i = 1; i < 3; i++) {
|
||||
if (iter->id == collidedActor->id) {
|
||||
*index = i;
|
||||
return collidedActor;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjBoyo_Update(Actor* thisx, PlayState* play2) {
|
||||
PlayState* play = play2;
|
||||
ObjBoyo* this = THIS;
|
||||
Actor* collidedActor;
|
||||
s32 index;
|
||||
|
||||
collidedActor = ObjBoyo_FindCollidedActor(this, play, &index);
|
||||
|
||||
if (collidedActor != NULL) {
|
||||
sCollisionHandlers[index].colHandler(this, collidedActor);
|
||||
// TODO: find out what all of these are.
|
||||
|
||||
this->unk194 = 0x64;
|
||||
this->unk196 = 3;
|
||||
this->unk198 = 0.01f;
|
||||
this->unk19C = 0.03f;
|
||||
this->unk1A4 = 0x3F40;
|
||||
this->unk1A6 = 0x7D0;
|
||||
this->unk1A8 = 0;
|
||||
this->unk1A0 = 0.03f;
|
||||
this->unk1AA = 0x2DF7;
|
||||
this->unk1AC = 0x258;
|
||||
}
|
||||
|
||||
if (this->unk194 > 0) {
|
||||
// compute new scaling
|
||||
// this computation might help finding what those values are.
|
||||
|
||||
this->unk194 -= this->unk196;
|
||||
this->unk1AA += this->unk1AC;
|
||||
this->unk1A8 += this->unk1AA;
|
||||
|
||||
this->actor.scale.x = this->actor.scale.z =
|
||||
(Math_CosS(this->unk1A8 + this->unk1A4) * (f32)this->unk194 * this->unk19C * this->unk198) + 0.1f;
|
||||
|
||||
this->actor.scale.y =
|
||||
(Math_CosS(this->unk1A8 + this->unk1A6) * (f32)this->unk194 * this->unk1A0 * this->unk198) + 0.1f;
|
||||
} else {
|
||||
Actor_SetScale(&this->actor, 0.1f);
|
||||
if (this->collider.base.acFlags & AC_HIT) {
|
||||
// TODO: find out what all of these are.
|
||||
|
||||
this->unk194 = 0x1E;
|
||||
this->unk196 = 2;
|
||||
this->unk198 = 0.033333335f;
|
||||
this->unk19C = 0.012f;
|
||||
this->unk1A0 = 0.006f;
|
||||
this->unk1A4 = 0x3F40;
|
||||
this->unk1A6 = 0x7D0;
|
||||
this->unk1A8 = 0;
|
||||
this->unk1AA = 0x3A98;
|
||||
this->unk1AC = 0x640;
|
||||
}
|
||||
}
|
||||
this->collider.base.acFlags &= ~AC_HIT;
|
||||
this->collider.base.ocFlags1 &= ~OC1_HIT;
|
||||
this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER;
|
||||
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
|
||||
if (this->actor.xzDistToPlayer < 2000.0f) {
|
||||
CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjBoyo_Draw(Actor* thisx, PlayState* play) {
|
||||
ObjBoyo* this = THIS;
|
||||
|
||||
AnimatedMat_Draw(play, this->animatedMaterial);
|
||||
Gfx_DrawDListOpa(play, object_boyo_DL_000300);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,21 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
struct ObjBoyo;
|
||||
|
||||
typedef struct ObjBoyo {
|
||||
/* 0x000 */ Actor actor;
|
||||
/* 0x144 */ char unk_144[0x6C];
|
||||
/* 0x144 */ ColliderCylinder collider;
|
||||
/* 0x190 */ AnimatedMaterial* animatedMaterial;
|
||||
/* 0x194 */ s16 unk194;
|
||||
/* 0x196 */ s16 unk196;
|
||||
/* 0x198 */ f32 unk198;
|
||||
/* 0x19C */ f32 unk19C;
|
||||
/* 0x1A0 */ f32 unk1A0;
|
||||
/* 0x1A4 */ s16 unk1A4;
|
||||
/* 0x1A6 */ s16 unk1A6;
|
||||
/* 0x1A8 */ s16 unk1A8;
|
||||
/* 0x1AA */ s16 unk1AA;
|
||||
/* 0x1AC */ s16 unk1AC;
|
||||
/* 0x1AE */ s16 unk1AE;
|
||||
} ObjBoyo; // size = 0x1B0
|
||||
|
||||
#endif // Z_OBJ_BOYO_H
|
||||
|
|
|
@ -8743,10 +8743,10 @@
|
|||
0x809A5B50:("ObjArmos_Draw",),
|
||||
0x809A5D10:("ObjBoyo_Init",),
|
||||
0x809A5D94:("ObjBoyo_Destroy",),
|
||||
0x809A5DC0:("func_809A5DC0",),
|
||||
0x809A5DE0:("func_809A5DE0",),
|
||||
0x809A5E14:("func_809A5E14",),
|
||||
0x809A5E24:("func_809A5E24",),
|
||||
0x809A5DC0:("ObjBoyo_PushPlayer",),
|
||||
0x809A5DE0:("ObjBoyo_PushPirate",),
|
||||
0x809A5E14:("ObjBoyo_ExplodeBomb",),
|
||||
0x809A5E24:("ObjBoyo_FindCollidedActor",),
|
||||
0x809A5E98:("ObjBoyo_Update",),
|
||||
0x809A610C:("ObjBoyo_Draw",),
|
||||
0x809A6280:("EnGrasshopper_Init",),
|
||||
|
|
|
@ -9366,10 +9366,9 @@
|
|||
0x809A5BF0:("D_809A5BF0","f32","",0x4),
|
||||
0x809A5BF4:("D_809A5BF4","f32","",0x4),
|
||||
0x809A6150:("Obj_Boyo_InitVars","UNK_TYPE1","",0x1),
|
||||
0x809A6170:("D_809A6170","UNK_TYPE1","",0x1),
|
||||
0x809A619C:("D_809A619C","UNK_TYPE1","",0x1),
|
||||
0x809A61B0:("D_809A61B0","UNK_TYPE1","",0x1),
|
||||
0x809A61B4:("D_809A61B4","UNK_TYPE2","",0x2),
|
||||
0x809A6170:("sCylinderInit","ColliderCylinderInit","",0x1),
|
||||
0x809A619C:("sInitChain","InitChainEntry","[]",0x4),
|
||||
0x809A61AC:("gCollisionHandling","ObjBoyoUnkStruct","[]",0x20),
|
||||
0x809A61D0:("D_809A61D0","f32","",0x4),
|
||||
0x809A61D4:("D_809A61D4","f32","",0x4),
|
||||
0x809A61D8:("D_809A61D8","f32","",0x4),
|
||||
|
|
Loading…
Reference in New Issue