diff options
| author | Leonid Kapitonov <Feacur@gmail.com> | 2024-12-07 20:27:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-07 12:27:42 -0700 |
| commit | 8e5451997741a70edf39d7840074f262005b0988 (patch) | |
| tree | 4c6aaf584d484897d91777e2be7d1e07a19dc540 /src | |
| parent | 7c055329a7a71f8652587cb7dc779ac3eb69f5d4 (diff) | |
`ac_house_goki` OK (#229)
* prepare unknown size
* move `.data` to the C side
* remove redundant headers
* aHG_actor_ct OK
* func_80A83770_jp OK (rename to `aHG_actor_dt`)
* aHG_actor_move OK
- fix `mCoBG_CheckResult` description and comments
- extend `MyRoomClip` and fix offsets in comments
* func_80A83780_jp OK
* func_80A83930_jp OK
* func_80A83994_jp OK
* func_80A83A00_jp OK
* func_80A8401C_jp OK
* func_80A8409C_jp OK (rename to `aHG_setup_action`)
* aHG_actor_draw OK
* func_80A83D4C_jp OK
* func_80A83A24_jp OK
* name HG models
* put static HG data into the functions
* func_80A837C4_jp OK
* add notes and clean up a bit
* apply a suggestion by @hensldm
* remove ASM pragmas
* extract assets
Diffstat (limited to 'src')
| -rw-r--r-- | src/objects/act_house_goki/act_house_goki.c | 10 | ||||
| -rw-r--r-- | src/objects/act_house_goki/act_house_goki.h | 13 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_House_Goki/ac_house_goki.c | 357 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_House_Goki/ac_house_goki.h | 14 | ||||
| -rw-r--r-- | src/overlays/actors/player_actor/m_player.c | 2 |
5 files changed, 375 insertions, 21 deletions
diff --git a/src/objects/act_house_goki/act_house_goki.c b/src/objects/act_house_goki/act_house_goki.c new file mode 100644 index 0000000..028ab05 --- /dev/null +++ b/src/objects/act_house_goki/act_house_goki.c @@ -0,0 +1,10 @@ +#include "act_house_goki.h" + +#include "assets/jp/objects/act_house_goki/act_house_goki_vtx_1.vtx.inc.c" +#include "assets/jp/objects/act_house_goki/act_house_goki_vtx_2.vtx.inc.c" +#include "assets/jp/objects/act_house_goki/act_house_goki_model_1.gfx.inc.c" +#include "assets/jp/objects/act_house_goki/act_house_goki_model_2.gfx.inc.c" +#include "assets/jp/objects/act_house_goki/act_house_goki_pal.palette.inc.c" +u8 act_house_goki_tex[] = { +#include "assets/jp/objects/act_house_goki/act_house_goki_tex.ci4.inc.c" +}; diff --git a/src/objects/act_house_goki/act_house_goki.h b/src/objects/act_house_goki/act_house_goki.h new file mode 100644 index 0000000..f04e01b --- /dev/null +++ b/src/objects/act_house_goki/act_house_goki.h @@ -0,0 +1,13 @@ +#ifndef OBJECT_ACT_HOUSE_GOKI_H +#define OBJECT_ACT_HOUSE_GOKI_H + +#include "gbi.h" + +extern Vtx act_house_goki_vtx_1[]; +extern Vtx act_house_goki_vtx_2[]; +extern Gfx act_house_goki_model_1[]; +extern Gfx act_house_goki_model_2[]; +extern u16 act_house_goki_pal[]; +extern u8 act_house_goki_tex[]; + +#endif diff --git a/src/overlays/actors/ovl_House_Goki/ac_house_goki.c b/src/overlays/actors/ovl_House_Goki/ac_house_goki.c index ecd688b..cea1227 100644 --- a/src/overlays/actors/ovl_House_Goki/ac_house_goki.c +++ b/src/overlays/actors/ovl_House_Goki/ac_house_goki.c @@ -2,50 +2,371 @@ #include "m_actor_dlftbls.h" #include "m_object.h" #include "overlays/gamestates/ovl_play/m_play.h" +#include "m_actor_shadow.h" +#include "src/overlays/actors/player_actor/m_player.h" +#include "m_player_lib.h" +#include "audio.h" +#include "m_cockroach.h" +#include "m_collision_bg.h" +#include "m_rcp.h" +#include "m_field_info.h" +#include "macros.h" + +#include "objects/act_house_goki/act_house_goki.h" void aHG_actor_ct(Actor* thisx, Game_Play* game_play); -void func_80A83770_jp(Actor* thisx, Game_Play* game_play); +void aHG_actor_dt(Actor* thisx, Game_Play* game_play); void aHG_actor_move(Actor* thisx, Game_Play* game_play); void aHG_actor_draw(Actor* thisx, Game_Play* game_play); -#if 0 +void func_80A83930_jp(House_Goki* this, Game_Play* game_play); +void func_80A83994_jp(House_Goki* this, Game_Play* game_play); +void func_80A83A00_jp(House_Goki* this, Game_Play* game_play); + +void func_80A83A24_jp(House_Goki* this, Game_Play* game_play); +void func_80A83D4C_jp(House_Goki* this, Game_Play* game_play); +void func_80A8401C_jp(House_Goki* this, Game_Play* game_play); + +void aHG_setup_action(House_Goki* this, s32 processIndex, Game_Play* game_play); + ActorProfile House_Goki_Profile = { /* */ ACTOR_HOUSE_GOKI, /* */ ACTOR_PART_4, /* */ ACTOR_FLAG_10, /* */ 0x0000, - /* */ OBJECT_369, + /* */ OBJECT_ACT_HOUSE_GOKI, /* */ sizeof(House_Goki), /* */ aHG_actor_ct, - /* */ func_80A83770_jp, + /* */ aHG_actor_dt, /* */ aHG_actor_move, /* */ aHG_actor_draw, /* */ NULL, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/aHG_actor_ct.s") +void aHG_actor_ct(Actor* thisx, Game_Play* game_play) { + House_Goki* this = (House_Goki*)thisx; + this->unk_190 = 0x1E; + if (this->actor.params <= 0) { + this->actor.params = 0; + this->unk_190 = 0xFF; + } + this->actor.scale.x = 0.01f; + this->actor.scale.y = 0.01f; + this->actor.scale.z = 0.01f; + Shape_Info_init(&this->actor, 0, mAc_ActorShadowCircle, 6.0f, 6.0f); + xyz_t_move(&this->actor.home.pos, &this->actor.world.pos); + this->actor.update = aHG_actor_move; + this->actor.gravity = -2.0f; + aHG_setup_action(this, 1, game_play); +} + +void aHG_actor_dt(Actor* thisx UNUSED, Game_Play* game_play UNUSED) { +} + +void func_80A83780_jp(House_Goki* this) { + this->unk_198 += 1.0f; + if (this->unk_198 >= 2.0f) { + this->unk_198 -= 2.0f; + } +} + +s16 func_80A837C4_jp(House_Goki* this) { + Actor* thisx = &this->actor; + s16 result = 777; + s16 angles[2]; + s16 index; + + this->unk_184 = 0; + + if (thisx->xzDistToPlayer > 20.0f) { + angles[0] = 777; + angles[1] = 777; + if (thisx->colCheck.colResult.hitWall & 2) { + angles[0] = DEG_TO_BINANG(-90); + angles[1] = DEG_TO_BINANG(90); + } + + if ((thisx->colCheck.colResult.hitWall & 4) || (thisx->colCheck.colResult.hitWall & 8)) { + if (angles[0] == 777) { + angles[0] = 0x8000 - thisx->world.rot.y; + if (angles[0] > 0) { + angles[0] = 0x10000 - thisx->world.rot.y; + } + } else { + angles[0] = thisx->colCheck.colResult.hitWall & 4 ? DEG_TO_BINANG(90) : DEG_TO_BINANG(-90); + } + return angles[0]; + } + + index = 0; + if (angles[0] != 777) { + result = (s16)ABS((s16)(angles[0] - thisx->yawTowardsPlayer)); + } + if (angles[1] != 777) { + if (result < (s16)ABS((s16)(angles[1] - thisx->yawTowardsPlayer))) { + index = 1; + } + } + result = angles[index]; + } + + return result; +} + +void func_80A83930_jp(House_Goki* this, Game_Play* game_play UNUSED) { + this->unk_180 = (s32)fqrand() * 20 + 20; + this->unk_184 = 0; + this->unk_188 = 0; + this->unk_195 = 0; + this->unk_198 = 0.0f; + this->actor.speed = 8.0f; +} + +void func_80A83994_jp(House_Goki* this, Game_Play* game_play UNUSED) { + this->actor.speed = 0.0f; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->unk_198 = 0.0f; + this->unk_188 = 0; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_180 = (s32)fqrand() * 20 + 20; +} + +void func_80A83A00_jp(House_Goki* this, Game_Play* game_play UNUSED) { + this->unk_188 = 0xFF; + this->unk_180 = 40; + this->actor.speed = 0.0f; +} + +void func_80A83A24_jp(House_Goki* this, Game_Play* game_play) { + Player* player = get_player_actor_withoutCheck(game_play); + UNUSED void* pad = &this->actor.world.pos; + u16* unitFG; + s16 rotY; + s32 chance; + + if (this->actor.world.pos.y == this->actor.home.pos.y) { + if (this->unk_195 == 1) { + this->unk_195 = 0; + this->actor.speed = 8.0f; + this->unk_198 = 0.0f; + } + if (this->unk_180 > 0) { + this->unk_180 -= 1; + } + if ((this->unk_180 == 0) && (this->unk_18C == 0) && + ((player->actor.speed == 0.0f) || (this->actor.xzDistToPlayer > 60.0f))) { + aHG_setup_action(this, 1, game_play); + return; + } + } + + if (this->unk_184 > 0) { + this->unk_184 -= 1; + } + + if (this->unk_195 == 1) { + func_80A83780_jp(this); + if (this->actor.velocity.y < 0.0f) { + this->actor.gravity = -7.0f; + } + } + + unitFG = mFI_GetUnitFG(this->actor.world.pos); + if ((unitFG != NULL) && (*unitFG == 0x1F3F)) { + this->unk_18C = 1; + this->actor.shape.rot.y = -0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_184 = (s32)(fqrand() * 4.0f) + 4; + } else { + this->unk_18C = 0; + if ((this->unk_184 == 0) && (this->actor.colCheck.colResult.hitWall != 0)) { + rotY = func_80A837C4_jp(this); + chance = 20; + if (rotY != 777) { + this->actor.world.rot.y += rotY; + this->actor.world.rot.y &= 0xC000; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_184 = (s32)(fqrand() * 5.0f) + 5; + } else { + chance = 50; + } + + if (this->unk_195 == 0 && (s32)(fqrand() * 100.0f) < chance) { + rotY = (s32)fqrand(); + rotY = 0x1000 - (rotY << 0xD); + this->actor.shape.rot.y = rotY + this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_195 = 1; + this->actor.velocity.y = 17.0f; + this->actor.gravity = -2.0f; + this->actor.speed = 5.0f; + sAdo_OngenTrgStart(0x132, &this->actor.world.pos); + } + } else if ((this->unk_195 == 0) && (this->unk_184 == 0)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } + sAdo_OngenPos((uintptr_t)this, 0x28, &this->actor.world.pos); +} + +void func_80A83D4C_jp(House_Goki* this, Game_Play* game_play) { + Player* player = get_player_actor_withoutCheck(game_play); + u16* unitFG; + UNUSED s32 pad[2]; + xyz_t pos; + + if (this->unk_194 == 0 || (player->actor.speed != 0.0f && this->actor.xzDistToPlayer < 60.0f)) { + this->unk_194 = 1; + aHG_setup_action(this, 0, game_play); + return; + } + + if (this->actor.speed != 0.0f) { + sAdo_OngenPos((uintptr_t)this, 0x28, &this->actor.world.pos); + if ((this->actor.colCheck.colResult.hitWall & 2) || (this->actor.colCheck.colResult.unk1 & 2) || + (this->actor.colCheck.colResult.hitWall & 4) || (this->actor.colCheck.colResult.unk1 & 4) || + (this->actor.colCheck.colResult.hitWall & 8) || (this->actor.colCheck.colResult.unk1 & 8)) { + if (this->unk_188 == 0) { + this->actor.shape.rot.y += 0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->unk_188 = 1; + } + } else { + unitFG = mFI_GetUnitFG(this->actor.world.pos); + if ((unitFG != NULL) && (*unitFG == 0x1F3F)) { + this->unk_188 = 0; + this->unk_180 = (s32)(fqrand() * 5.0f) + 5; + this->actor.shape.rot.y = -0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + } else { + this->unk_188 = 0; + } + } + } + + if (this->unk_180 > 0) { + this->unk_180 -= 1; + return; + } + + this->unk_180 = (s32)(fqrand() * 5.0f) + 5; + this->actor.speed = 0; + if (((game_play->unk_1EA0 % 100) < 0x15) && !(fqrand() < 0.5f)) { + if (!(this->actor.xzDistToPlayer < 60.0f)) { + xyz_t_move(&pos, &this->actor.world.pos); + pos.x += 80.0f - (fqrand() * 160.0f); + pos.z += 80.0f - (fqrand() * 160.0f); + this->actor.shape.rot.y = search_position_angleY(&this->actor.world.pos, &pos); + this->unk_195 = 0; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.speed = 4; + } + } +} + +void func_80A8401C_jp(House_Goki* this, Game_Play* game_play UNUSED) { + this->unk_190 = this->unk_188; + + this->unk_180 -= 1; + if ((this->unk_180 & 2) == 0) { + this->unk_190 = 0; + } + + this->unk_188 -= 5; + if (this->unk_188 < 0) { + this->unk_188 = 0; + } + + this->actor.shape.shadowAlphaRate = (f32)this->unk_188 * 0.0015f; + if (this->unk_180 <= 0) { + Actor_delete(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83770_jp.s") +void aHG_setup_action(House_Goki* this, s32 processIndex, Game_Play* game_play) { + static House_GokiActionFunc init_process[] = { func_80A83930_jp, func_80A83994_jp, func_80A83A00_jp }; + static House_GokiActionFunc process[] = { func_80A83A24_jp, func_80A83D4C_jp, func_80A8401C_jp }; + this->processIndex = processIndex; + this->process = process[processIndex]; + init_process[processIndex](this, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83780_jp.s") +void aHG_actor_move(Actor* thisx, Game_Play* game_play) { + House_Goki* this = (House_Goki*)thisx; + Player* player = get_player_actor_withoutCheck(game_play); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A837C4_jp.s") + if (this->processIndex != 2 && this->unk_190 != 0xFF) { + this->unk_190 += 7; + if (this->unk_190 >= 0x100) { + this->unk_190 = 0xFF; + } + } else if (common_data.clip.myRoomClip != NULL) { + if (this->processIndex != 2 && this->unk_190 == 0xFF) { + if (common_data.clip.myRoomClip->unk_68(&this->actor.world.pos)) { + common_data.clip.unk_090->unk_00(0x5F, this->actor.world.pos, 1, 0, game_play, 0, 0, 0); + mCkRh_CalcCanLookGokiCount(-1); + sAdo_OngenTrgStart(0x5B, &this->actor.world.pos); + aHG_setup_action(this, 2, game_play); + return; + } + } + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83930_jp.s") + this->actor.velocity.x = sin_s(this->actor.world.rot.y) * this->actor.speed; + this->actor.velocity.z = cos_s(this->actor.world.rot.y) * this->actor.speed; + this->actor.velocity.y += this->actor.gravity; + Actor_position_move(&this->actor); + func_80076778_jp(0, &this->actor, 15.0f, 0.0f, 0, 0); + if (this->actor.world.pos.y < this->actor.home.pos.y) { + this->actor.world.pos.y = this->actor.home.pos.y; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83994_jp.s") + if (this->unk_190 == 0xFF && this->processIndex != 2) { + if (this->actor.colCheck.colResult.unk9 || this->actor.colCheck.colResult.unk10) { + common_data.clip.unk_090->unk_00(0x5F, this->actor.world.pos, 1, 0, game_play, 0, 0, 0); + mCkRh_CalcCanLookGokiCount(-1); + sAdo_OngenTrgStart(0x5B, &this->actor.world.pos); + aHG_setup_action(this, 2, game_play); + return; + } + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83A00_jp.s") + if (this->unk_190 != 0xFF && this->actor.params == 2) { + this->actor.params = 1; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83A24_jp.s") + if (this->processIndex != 2) { + if (this->actor.params == 2 || + (this->unk_190 == 0xFF && player->actor.speed != 0.0f && this->actor.xzDistToPlayer < 9.0f && + this->actor.world.pos.y == this->actor.home.pos.y)) { + common_data.clip.unk_090->unk_00(0x5F, this->actor.world.pos, 1, 0, game_play, 0, 0, 0); + mCkRh_CalcCanLookGokiCount(-1); + sAdo_OngenTrgStart(0x5B, &this->actor.world.pos); + aHG_setup_action(this, 2, game_play); + } + } + this->process(this, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A83D4C_jp.s") +void aHG_actor_draw(Actor* thisx, Game_Play* game_play) { + static Gfx* aHG_models[] = { act_house_goki_model_1, act_house_goki_model_2 }; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A8401C_jp.s") + GraphicsContext* gfxCtx = game_play->state.gfxCtx; + House_Goki* this = (House_Goki*)thisx; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/func_80A8409C_jp.s") + Matrix_push(); + _texture_z_light_fog_prim_xlu(gfxCtx); + Matrix_translate(this->actor.world.pos.x, this->actor.world.pos.y + 2.0f, this->actor.world.pos.z, 0U); + Matrix_scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1U); + Matrix_RotateX(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/aHG_actor_move.s") + OPEN_POLY_XLU_DISP(gfxCtx); + gSPMatrix(__polyXlu++, _Matrix_to_Mtx_new(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(__polyXlu++, 0xFF, 0xFF, 0xFF, this->unk_190); + gSPDisplayList(__polyXlu++, aHG_models[(s32)this->unk_198]); + CLOSE_POLY_XLU_DISP(sp3C); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_House_Goki/ac_house_goki/aHG_actor_draw.s") + Matrix_pull(); +} diff --git a/src/overlays/actors/ovl_House_Goki/ac_house_goki.h b/src/overlays/actors/ovl_House_Goki/ac_house_goki.h index 81ef9ab..f68c5b2 100644 --- a/src/overlays/actors/ovl_House_Goki/ac_house_goki.h +++ b/src/overlays/actors/ovl_House_Goki/ac_house_goki.h @@ -1,7 +1,6 @@ #ifndef AC_HOUSE_GOKI_H #define AC_HOUSE_GOKI_H -#include "ultra64.h" #include "m_actor.h" #include "unk.h" @@ -12,7 +11,18 @@ typedef void (*House_GokiActionFunc)(struct House_Goki*, struct Game_Play*); typedef struct House_Goki { /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x28]; + /* 0x174 */ House_GokiActionFunc process; + /* 0x178 */ UNK_TYPE1 unk_178[4]; + /* 0x17C */ s32 processIndex; + /* 0x180 */ s32 unk_180; + /* 0x184 */ s32 unk_184; + /* 0x188 */ s32 unk_188; + /* 0x18C */ s32 unk_18C; + /* 0x190 */ u32 unk_190; + /* 0x194 */ u8 unk_194; + /* 0x195 */ u8 unk_195; + /* 0x196 */ UNK_TYPE1 unk_196[2]; + /* 0x198 */ f32 unk_198; } House_Goki; // size = 0x19C #endif diff --git a/src/overlays/actors/player_actor/m_player.c b/src/overlays/actors/player_actor/m_player.c index 77c348e..b1a7b98 100644 --- a/src/overlays/actors/player_actor/m_player.c +++ b/src/overlays/actors/player_actor/m_player.c @@ -1015,7 +1015,7 @@ void Player_actor_main_Wade_other_func1(UNUSED Actor* actor, UNUSED Game* game) void Player_actor_main_Sitdown_wait_other_func2(Actor* actor, UNUSED Game* game) { if (common_data.clip.myRoomClip != NULL) { - common_data.clip.myRoomClip->unk_54(&actor->world.pos); + common_data.clip.myRoomClip->unk_5C(&actor->world.pos); } } |
