jbo cleanup, almost matching for demo

This commit is contained in:
LagoLunatic 2025-09-17 16:56:25 -04:00
parent 4558c9e6af
commit a13640e949
3 changed files with 83 additions and 81 deletions

View File

@ -6,34 +6,29 @@
class mDoExt_McaMorf;
/**
* Baba bulb
* Only the lowest byte of fopAc_ac_c::base::mParameters is used,
* It is expected to be:
* - 0 - silently appears
* - 1 - plays a popup sound and animation on spawn
* - 2 - sets otherwise locally unused m2BA=1
* - 3 - waits until an event bit is set, does nothing until then, after converts to 0
* - 0xFF - converts to 0
*/
class jbo_class : public fopAc_ac_c {
public:
enum daJbo_Type {
daJbo_Type_NORMAL_e = 0,
daJbo_Type_POPS_UP_e = 1,
daJbo_Type_UNK_2_e = 2,
daJbo_Type_APPEAR_AFTER_DEKU_TREE_e = 3,
};
struct jbo_class {
/* 0x000 */ fopAc_ac_c actor;
/* 0x290 */ u8 m290[0x2AC - 0x290];
/* 0x2AC */ request_of_phase_process_class mPhs;
/* 0x2B4 */ mDoExt_McaMorf* mpMorf;
/* 0x2B8 */ u8 mParam;
/* 0x2B8 */ u8 mType;
/* 0x2B9 */ u8 m2B9[0x2B9 - 0x2B8];
// FIXME: give following two fields names if external use is spotted
/* 0x2BA */ u8 m2BA;
/* 0x2BB */ u8 m2BB;
/* 0x2BC */ u8 mState;
/* 0x2BC */ u8 mMode;
/* 0x2BE */ s16 mFramesUntilJump;
/* 0x2C0 */ s16 mAnimRotation;
/* 0x2C2 */ s16 mAnimationSpeed;
/* 0x2C4 */ cXyz mParticlePos;
/* 0x2D0 */ dCcD_Stts mStts;
/* 0x30C */ dCcD_Sph mSph;
/* 0x30C */ dCcD_Sph mCoSph;
};
STATIC_ASSERT(sizeof(jbo_class) == 0x438);

View File

@ -14,6 +14,14 @@
#include "f_op/f_op_actor_mng.h"
#include "d/d_priority.h"
#define JUMP_ANIMATION_TIME 70
enum daJbo_Mode {
daJbo_Mode_IDLE_e = 0,
daJbo_Mode_WAIT_JUMP_e = 1,
daJbo_Mode_SPAWN_e = 2,
};
/* 00000078-00000108 .text nodeCallBack__FP7J3DNodei */
static BOOL nodeCallBack(J3DNode* i_node, int i_calcTiming) {
if (i_calcTiming == J3DNodeCBCalcTiming_In) {
@ -34,17 +42,16 @@ static BOOL nodeCallBack(J3DNode *i_node, int i_calcTiming) {
/* 00000108-00000240 .text jbo_draw_SUB__FP9jbo_class */
void jbo_draw_SUB(jbo_class* i_this) {
fopAc_ac_c* actor = &i_this->actor;
J3DModel *model = i_this->mpMorf->getModel();
model->setBaseScale(i_this->scale);
mDoMtx_stack_c::transS(i_this->current.pos.x, i_this->current.pos.y, i_this->current.pos.z);
mDoMtx_stack_c::YrotM(i_this->shape_angle.y);
mDoMtx_stack_c::XrotM(i_this->shape_angle.x);
mDoMtx_stack_c::ZrotM(i_this->shape_angle.z);
model->setBaseScale(actor->scale);
mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z);
mDoMtx_stack_c::YrotM(actor->shape_angle.y);
mDoMtx_stack_c::XrotM(actor->shape_angle.x);
mDoMtx_stack_c::ZrotM(actor->shape_angle.z);
if (i_this->mAnimationSpeed) {
cXyz scale;
scale.x = REG8_F(1) + 1.1F;
scale.y = REG8_F(2) + 1.0F;
scale.z = REG8_F(3) + 0.9F;
scale.set(REG8_F(1) + 1.1F, REG8_F(2) + 1.0F, REG8_F(3) + 0.9F);
i_this->mAnimRotation += i_this->mAnimationSpeed;
mDoMtx_stack_c::YrotM(i_this->mAnimRotation);
mDoMtx_stack_c::scaleM(scale);
@ -55,65 +62,58 @@ void jbo_draw_SUB(jbo_class *i_this) {
/* 00000240-000002C4 .text daJBO_Draw__FP9jbo_class */
static BOOL daJBO_Draw(jbo_class* i_this) {
fopAc_ac_c* actor = &i_this->actor;
J3DModel *model = i_this->mpMorf->getModel();
if (i_this->mParam == 3)
if (i_this->mType == daJbo_Type_APPEAR_AFTER_DEKU_TREE_e)
return TRUE;
g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->current.pos, &i_this->tevStr);
g_env_light.setLightTevColorType(model, &i_this->tevStr);
g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &actor->current.pos, &actor->tevStr);
g_env_light.setLightTevColorType(model, &actor->tevStr);
i_this->mpMorf->updateDL();
return TRUE;
}
// time from link entering blub to being vomited out
#define JUMP_ANIMATION_TIME 70
enum daJbo_State {
daJbo_State_IDLE = 0,
daJbo_State_WAIT_JUMP = 1,
daJbo_State_SPAWN = 2,
};
/* 000002C4-00000584 .text jbo_move__FP9jbo_class */
void jbo_move(jbo_class* i_this) {
u8 state = i_this->mState;
switch (state) {
case daJbo_State_IDLE: {
if (dComIfGp_checkPlayerStatus0(0, daPyStts0_UNK80_e) && i_this->mSph.ChkCoHit()) {
fopAc_ac_c* actor = &i_this->actor;
switch (i_this->mMode) {
case daJbo_Mode_IDLE_e: {
if (dComIfGp_checkPlayerStatus0(0, daPyStts0_UNK80_e) && i_this->mCoSph.ChkCoHit()) {
J3DAnmTransform* anm = (J3DAnmTransform*)dComIfG_getObjectRes("JBO", JBO_BCK_IN1);
i_this->mpMorf->setAnm(anm, J3DFrameCtrl::EMode_NONE, 0.0, 1.0, 0.0, -1.0, NULL);
fopAcM_seStart(i_this, JA_SE_OBJ_JFLOWER_IN, 0);
fopAcM_seStart(actor, JA_SE_OBJ_JFLOWER_IN, 0);
dComIfGp_setItemMagicCount(4);
i_this->mFramesUntilJump = JUMP_ANIMATION_TIME;
i_this->mState += 1;
i_this->mMode += 1;
}
break;
}
case daJbo_State_WAIT_JUMP: {
case daJbo_Mode_WAIT_JUMP_e: {
i_this->mAnimationSpeed = JUMP_ANIMATION_TIME - i_this->mFramesUntilJump;
i_this->mAnimationSpeed *= 200;
if (i_this->mFramesUntilJump == 1) {
((daPy_py_c *)dComIfGp_getPlayer(0))->onForceVomitJump();
daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0);
player->onForceVomitJump();
}
if (dComIfGp_checkPlayerStatus0(0, daPyStts0_UNK80000000_e)) {
J3DAnmTransform* anm = (J3DAnmTransform*)dComIfG_getObjectRes("JBO", JBO_BCK_OUT1);
i_this->mpMorf->setAnm(anm, J3DFrameCtrl::EMode_NONE, 0.0, 1.0, 0.0, -1.0, NULL);
fopAcM_seStart(i_this, JA_SE_OBJ_JFLOWER_OUT, 0);
fopAcM_seStart(actor, JA_SE_OBJ_JFLOWER_OUT, 0);
i_this->mAnimationSpeed = 0;
i_this->mAnimRotation = 0;
JPABaseEmitter* emitter = dComIfGp_particle_setToon(0xa110, &i_this->mParticlePos);
if (emitter != NULL) {
emitter->setGlobalAlpha(100);
}
if (i_this->mParam == 2) {
if (i_this->mType == daJbo_Type_UNK_2_e) {
i_this->m2BA = 1;
}
i_this->mState = daJbo_State_IDLE;
i_this->mMode = daJbo_Mode_IDLE_e;
}
break;
}
case daJbo_State_SPAWN: {
case daJbo_Mode_SPAWN_e: {
if (i_this->mpMorf->isStop()) {
i_this->mState = daJbo_State_IDLE;
i_this->mMode = daJbo_Mode_IDLE_e;
}
break;
}
@ -122,10 +122,11 @@ void jbo_move(jbo_class *i_this) {
/* 00000584-00000698 .text daJBO_Execute__FP9jbo_class */
static BOOL daJBO_Execute(jbo_class* i_this) {
if (i_this->mParam == 3) {
fopAc_ac_c* actor = &i_this->actor;
if (i_this->mType == daJbo_Type_APPEAR_AFTER_DEKU_TREE_e) {
if (dComIfGs_isEventBit(0x1801)) {
i_this->mParam = 0;
i_this->mSph.OnCoSPrmBit(cCcD_CoSPrm_Set_e);
i_this->mType = daJbo_Type_NORMAL_e;
i_this->mCoSph.OnCoSetBit();
}
return TRUE;
}
@ -138,11 +139,11 @@ static BOOL daJBO_Execute(jbo_class* i_this) {
break;
}
i_this->mpMorf->play(NULL, 0, 0);
cXyz pos(i_this->current.pos);
cXyz pos(actor->current.pos);
pos.y += 30.0;
i_this->mSph.SetC(pos);
i_this->mSph.SetR(55.0);
dComIfG_Ccsp()->Set(&i_this->mSph);
i_this->mCoSph.SetC(pos);
i_this->mCoSph.SetR(55.0);
dComIfG_Ccsp()->Set(&i_this->mCoSph);
jbo_draw_SUB(i_this);
return TRUE;
}
@ -154,7 +155,7 @@ static BOOL daJBO_IsDelete(jbo_class*) {
/* 000006A0-000006D0 .text daJBO_Delete__FP9jbo_class */
static BOOL daJBO_Delete(jbo_class* i_this) {
dComIfG_resDelete(&i_this->mPhs, "JBO");
dComIfG_resDeleteDemo(&i_this->mPhs, "JBO");
return TRUE;
}
@ -188,24 +189,29 @@ static BOOL useHeapInit(fopAc_ac_c* i_this) {
/* 0000081C-00000A90 .text daJBO_Create__FP10fopAc_ac_c */
static cPhs_State daJBO_Create(fopAc_ac_c* i_this) {
#if VERSION > VERSION_DEMO
fopAcM_SetupActor(i_this, jbo_class);
#endif
jbo_class* a_this = (jbo_class*)i_this;
cPhs_State state = dComIfG_resLoad(&a_this->mPhs, "JBO");
if (state == cPhs_COMPLEATE_e) {
#if VERSION == VERSION_DEMO
fopAcM_SetupActor(i_this, jbo_class);
#endif
if (!fopAcM_entrySolidHeap(i_this, &useHeapInit, 0x1c20)) {
return cPhs_ERROR_e;
} else {
a_this->mParam = fopAcM_GetParam(a_this);
if (a_this->mParam == 0xFF) {
a_this->mParam = 0;
a_this->mType = fopAcM_GetParam(a_this);
if (a_this->mType == 0xFF) {
a_this->mType = daJbo_Type_NORMAL_e;
}
if (REG8_S(9) != 0) {
a_this->mParam = REG8_S(9);
a_this->mType = REG8_S(9);
}
fopAcM_SetMtx(a_this, a_this->mpMorf->getModel()->getBaseTRMtx());
a_this->attention_info.flags = 0;
a_this->mStts.Init(0xff, 0xff, a_this);
fopAcM_SetMtx(i_this, a_this->mpMorf->getModel()->getBaseTRMtx());
i_this->attention_info.flags = 0;
a_this->mStts.Init(0xff, 0xff, i_this);
static dCcD_SrcSph co_sph_src = {
// dCcD_SrcGObjInf
{
@ -215,7 +221,7 @@ static cPhs_State daJBO_Create(fopAc_ac_c* i_this) {
/* SrcObjAt SPrm */ 0,
/* SrcObjTg Type */ 0,
/* SrcObjTg SPrm */ 0,
/* SrcObjCo SPrm */ cCcD_CoSPrm_VsEnemy_e|cCcD_CoSPrm_IsOther_e|cCcD_CoSPrm_Set_e,
/* SrcObjCo SPrm */ cCcD_CoSPrm_Set_e | cCcD_CoSPrm_IsOther_e | cCcD_CoSPrm_VsEnemy_e,
/* SrcGObjAt Se */ 0,
/* SrcGObjAt HitMark */ 0,
/* SrcGObjAt Spl */ 0,
@ -234,19 +240,19 @@ static cPhs_State daJBO_Create(fopAc_ac_c* i_this) {
/* Radius */ 15.0f,
}},
};
a_this->mSph.Set(co_sph_src);
a_this->mSph.SetStts(&a_this->mStts);
if (a_this->mParam == 3) {
fopAcM_OffStatus(a_this, fopAcStts_SHOWMAP_e);
a_this->mSph.ClrCoSet();
a_this->mCoSph.Set(co_sph_src);
a_this->mCoSph.SetStts(&a_this->mStts);
if (a_this->mType == daJbo_Type_APPEAR_AFTER_DEKU_TREE_e) {
fopAcM_OffStatus(i_this, fopAcStts_SHOWMAP_e);
a_this->mCoSph.ClrCoSet();
}
if (a_this->mParam == 1) {
if (a_this->mType == daJbo_Type_POPS_UP_e) {
J3DAnmTransform* pAnimRes = (J3DAnmTransform*) dComIfG_getObjectRes("JBO", JBO_BCK_UMARERU1);
a_this->mpMorf->setAnm(pAnimRes, J3DFrameCtrl::EMode_NONE, 0.0, 1.0, 0.0, -1.0, NULL);
fopAcM_seStart(a_this, JA_SE_CM_BV_BASE_POPUP, 0);
a_this->mState = daJbo_State_SPAWN;
fopAcM_seStart(i_this, JA_SE_CM_BV_BASE_POPUP, 0);
a_this->mMode = daJbo_Mode_SPAWN_e;
}
a_this->gbaName = 0x21;
i_this->gbaName = 0x21;
jbo_draw_SUB(a_this);
}
}

View File

@ -5,6 +5,7 @@
#include "d/dolzel_rel.h" // IWYU pragma: keep
#include "d/res/res_ojtree.h"
#include "d/actor/d_a_jbo.h"
#include "d/actor/d_a_obj_ojtree.h"
#include "d/d_com_inf_game.h"
#include "m_Do/m_Do_mtx.h"
@ -31,7 +32,7 @@ BOOL daObjOjtree::Act_c::Create() {
fopAcM_setCullSizeBox(this, -500.0f, -1.0f, -300.0f, 251.0f, 5001.0f, 251.0f);
pos.set(current.pos);
pos.y += 5000.0f;
fopAcM_create(PROC_JBO, 0, &pos, home.roomNo, &shape_angle, NULL, 0xff, NULL);
fopAcM_create(PROC_JBO, daJbo_Type_NORMAL_e, &pos, home.roomNo, &shape_angle, NULL, 0xff, NULL);
mLockTimer = 2;
return TRUE;
}