diff options
| author | Tom Overton <tom-overton@users.noreply.github.com> | 2024-02-23 14:31:45 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-23 15:31:45 -0700 |
| commit | 84cb26a6b03cd5b886b2da4a5bc9eb881a05dda3 (patch) | |
| tree | 1091a541441805719c3f1193658161e08fd2b074 /src | |
| parent | a187e97a8a499437bc818356a1d62670772ab8b4 (diff) | |
ac_t_keitai OK (#148)
* ac_t_keitai OK
* Pascal case the invented struct name
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_T_Keitai/ac_t_keitai.c | 181 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_T_Keitai/ac_t_keitai.h | 14 |
2 files changed, 180 insertions, 15 deletions
diff --git a/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.c b/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.c index 291661d..abf5c73 100644 --- a/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.c +++ b/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.c @@ -2,19 +2,38 @@ #include "m_lib.h" #include "m_actor_dlftbls.h" #include "m_object.h" +#include "m_rcp.h" +#include "objects/tol_keitai_1/tol_keitai_1.h" #include "overlays/gamestates/ovl_play/m_play.h" +#define THIS ((T_Keitai*)thisx) + void aTKT_actor_ct(Actor* thisx, Game_Play* game_play); void aTKT_actor_move(Actor* thisx, Game_Play* game_play); void aTKT_actor_draw(Actor* thisx, Game_Play* game_play); -#if 0 +void aTKT_setupAction(T_Keitai* this, s32 processIndex); + +typedef struct TKeitaiAnimationData { + /* 0x0 */ BaseAnimationR* animation; + /* 0x4 */ f32 startFrame; + /* 0x8 */ f32 endFrame; +} TKeitaiAnimationData; // size = 0xC + +TKeitaiAnimationData aTKT_anm_dt[] = { + { &cKF_ba_r_tol_keitai_1_keitai_on1, 1.0f, 68.0f }, + { &cKF_ba_r_tol_keitai_1_keitai_off1, 1.0f, 61.0f }, + { &cKF_ba_r_tol_keitai_1_keitai_off1, 1.0f, 61.0f }, + { &cKF_ba_r_tol_keitai_1_keitai_on1, 1.0f, 68.0f }, + { NULL, 0.0f, 0.0f }, +}; + ActorProfile T_Keitai_Profile = { /* */ ACTOR_T_KEITAI, /* */ ACTOR_PART_4, /* */ ACTOR_FLAG_10 | ACTOR_FLAG_20, /* */ 0x0000, - /* */ OBJECT_45, + /* */ OBJECT_TOL_KEITAI_1, /* */ sizeof(T_Keitai), /* */ aTKT_actor_ct, /* */ (void*)none_proc1, @@ -22,22 +41,160 @@ ActorProfile T_Keitai_Profile = { /* */ aTKT_actor_draw, /* */ NULL, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/aTKT_actor_ct.s") +void aTKT_actor_ct(Actor* thisx, Game_Play* game_play) { + T_Keitai* this = THIS; + + cKF_SkeletonInfo_R_ct(&this->skeletonInfo, &cKF_bs_r_tol_keitai_1, NULL, this->jointTable, this->morphTable); + this->segment = game_play->objectExchangeBank.status[this->toolActor.actor.unk_026].segment; + aTKT_setupAction(this, 0); +} + +void func_80A1F58C_jp(T_Keitai* this, Game_Play* game_play) { + UNUSED s32 pad; + void* segment = game_play->objectExchangeBank.status[this->toolActor.actor.unk_026].segment; + SkeletonInfoR* skeletonInfo; + TKeitaiAnimationData* animData; + + if (this->segment != segment) { + animData = &aTKT_anm_dt[this->processIndex]; + skeletonInfo = &this->skeletonInfo; + skeletonInfo->skeleton = Lib_SegmentedToVirtual(&cKF_bs_r_tol_keitai_1); + skeletonInfo->animation = Lib_SegmentedToVirtual(animData->animation); + this->segment = segment; + } +} + +void aTKT_calc_scale(T_Keitai* this, s32 index) { + static f32 start_scale[] = { 0.0f, 1.0f }; + static f32 end_scale[] = { 1.0f, 0.0f }; + static f32 start_chno[] = { 10.0f, 33.0f }; + static f32 end_chno[] = { 20.0f, 41.0f }; + f32 currentFrame = this->skeletonInfo.frameControl.currentFrame; + f32 startingChno = start_chno[index]; + f32 endingChno = end_chno[index]; + f32 startingScale = start_scale[index]; + f32 endingScale = end_scale[index]; + f32 scale; + + if (currentFrame < startingChno) { + scale = startingScale; + } else if (endingChno < currentFrame) { + scale = endingScale; + } else { + scale = (((currentFrame - startingChno) / (endingChno - startingChno)) * (endingScale - startingScale)) + + startingScale; + } + + this->toolActor.actor.scale.x = scale; + this->toolActor.actor.scale.y = scale; + this->toolActor.actor.scale.z = scale; +} + +void aTKT_takeout(T_Keitai* this) { + aTKT_calc_scale(this, 0); +} + +void aTKT_putaway(T_Keitai* this) { + aTKT_calc_scale(this, 1); +} + +void aTKT_destruct(T_Keitai* this) { + Actor_delete(&this->toolActor.actor); +} + +void aTKT_setupAction(T_Keitai* this, s32 processIndex) { + static T_KeitaiActionFunc process[] = { + aTKT_takeout, aTKT_putaway, aTKT_destruct, (T_KeitaiActionFunc)(void*)none_proc1, NULL, + }; + this->process = process[processIndex]; + this->processIndex = processIndex; + + { + TKeitaiAnimationData* animData = &aTKT_anm_dt[processIndex]; + + cKF_SkeletonInfo_R_init(&this->skeletonInfo, this->skeletonInfo.skeleton, animData->animation, + animData->startFrame, animData->endFrame, animData->startFrame, 1.0f, 0.0f, + ANIMATION_STOP, NULL); + } +} + +void aTKT_actor_move(Actor* thisx, Game_Play* game_play) { + T_Keitai* this = THIS; + + func_80A1F58C_jp(this, game_play); + + if (this->toolActor.unk1BC != this->processIndex) { + aTKT_setupAction(this, this->toolActor.unk1BC); + } + + cKF_SkeletonInfo_R_play(&this->skeletonInfo); + this->process(this); +} + +#define AC_GCN_OPEN_DISP(gfxCtx) \ + { \ + GraphicsContext* __gfxCtx = gfxCtx; \ + int __gfx_opened = 0; \ + do { \ + } while (0) + +#define AC_GCN_CLOSE_DISP(gfxCtx) \ + (void)__gfx_opened; \ + } \ + do { \ + } while (0) + +#define OPEN_POLY_OPA_DISPS() \ + { \ + Gfx* __polyOpa = __gfxCtx->polyOpa.p; \ + int __opa_opened = 0; \ + do { \ + } while (0) + +#define CLOSE_POLY_OPA_DISPS() \ + __gfxCtx->polyOpa.p = __polyOpa; \ + (void)__opa_opened; \ + } \ + do { \ + } while (0) + +void aTKT_actor_draw(Actor* thisx, Game_Play* game_play) { + static xyz_t D_80A1F9F4_jp = { 0.0f, 0.0f, 0.0f }; + T_Keitai* this = THIS; + SkeletonInfoR* skeletonInfo = &this->skeletonInfo; + GraphicsContext* gfxCtx = game_play->state.gfxCtx; + Mtx* mtx; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/func_80A1F58C_jp.s") + func_80A1F58C_jp(this, game_play); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/func_80A1F634_jp.s") + mtx = GRAPH_ALLOC_NO_ALIGN(gfxCtx, sizeof(Mtx) * skeletonInfo->skeleton->unk01); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/func_80A1F6C0_jp.s") + if (mtx != NULL) { + if (this->toolActor.unk1B8 == 1) { + Matrix_put(&this->toolActor.unk178); + Matrix_Position(&D_80A1F9F4_jp, &this->toolActor.actor.world.pos); + this->toolActor.unk1B8 = 0; + } else { + Matrix_translate(this->toolActor.actor.world.pos.x, this->toolActor.actor.world.pos.y, + this->toolActor.actor.world.pos.z, MTXMODE_NEW); + Matrix_scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/func_80A1F6E0_jp.s") + _texture_z_light_fog_prim_npc(gfxCtx); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/func_80A1F700_jp.s") + if (1) {} + AC_GCN_OPEN_DISP(gfxCtx); + OPEN_POLY_OPA_DISPS(); + if (1) {} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/func_80A1F720_jp.s") + Matrix_scale(this->toolActor.actor.scale.x, this->toolActor.actor.scale.y, this->toolActor.actor.scale.z, + MTXMODE_APPLY); + gSPMatrix(__polyOpa++, _Matrix_to_Mtx_new(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/aTKT_actor_move.s") + CLOSE_POLY_OPA_DISPS(); + AC_GCN_CLOSE_DISP(gfxCtx); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_T_Keitai/ac_t_keitai/aTKT_actor_draw.s") + cKF_Si3_draw_R_SV(game_play, skeletonInfo, mtx, NULL, NULL, NULL); + } +} diff --git a/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.h b/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.h index 434b9a8..9bc1105 100644 --- a/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.h +++ b/src/overlays/actors/ovl_T_Keitai/ac_t_keitai.h @@ -2,17 +2,25 @@ #define AC_T_KEITAI_H #include "ultra64.h" +#include "c_keyframe.h" #include "m_actor.h" +#include "overlays/actors/ovl_Tools/ac_tools.h" #include "unk.h" struct Game_Play; struct T_Keitai; -typedef void (*T_KeitaiActionFunc)(struct T_Keitai*, struct Game_Play*); +typedef void (*T_KeitaiActionFunc)(struct T_Keitai*); typedef struct T_Keitai { - /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x100]; + /* 0x000 */ ToolActor toolActor; + /* 0x1C0 */ UNK_TYPE1 unk_1C0[0x8]; + /* 0x1C8 */ T_KeitaiActionFunc process; + /* 0x1CC */ s32 processIndex; + /* 0x1D0 */ SkeletonInfoR skeletonInfo; + /* 0x240 */ s_xyz jointTable[4]; + /* 0x258 */ s_xyz morphTable[4]; + /* 0x270 */ void* segment; } T_Keitai; // size = 0x274 #endif |
