From 09cf394d988e80a75ca24a23103c8f976a9dc396 Mon Sep 17 00:00:00 2001 From: TrulyNaN <52424023+TrulyNaN@users.noreply.github.com> Date: Sun, 9 Oct 2022 21:34:17 -0400 Subject: [PATCH] ovl_Bg_Kin2_Picture OK and documented, object_kin2_obj documented (#1070) * test commit * undoing test commit * making sure this is the right repo * removing test file * init for OSH bombable wall started. put back Actor* in function declarations. * BgKin2Bombwall_Init is matching. * started z_bg_kin2_bombwall destroy function. One mismatch right now. * BgKin2Bombwall_Destroy matches. * BgKin2Bombwall_Draw matches. * Fixed BgKin2Bombwall_Init * BgKin2Bombwall_Init and BgKin2Bombwall_Destroy both match. Fixed s32 array in struct. * BgKin2Bombwall_Draw and BgKin2Bombwall_Update match. * Only func_80B6E020 and func_80B6E090 left to match in ovl_Bg_Kin2_Bombwall. * func_80B6E020 from ovl_Bg_Kin2_Bombwall matches. * Went from 8925 to about 5-6k diff score for func_80B6E090 in ovl_Bg_Kin2_Bombwall * Took func_80B6E090 from about 5300 diff score to about 4300 diff score in ovl_Bg_Kin2_Bombwall. * Diff score for ovl_Bg_Kin2_Bombwall func_80B6E090 went from 4k ish to 3277 * Diff score for ovl_Bg_Kin2_Bombwall func_80B6E090 went from 3277 to 2262. * Diff score for ovl_Bg_Kin2_Bombwall func_80B6E090 went from 2262 to 1589. * only slight progress on ovl_Bg_Kinw_Bombwall's func_80B6E090 * Got to 1473 diff score on ovl_Bg_Kinw_Bombwall's func_80B6E090 * Put in the changes made by EllipticEllipsis and hensldm for ovl_Bg_Kin2_Bombwall's func_8066E090. * renamed some symbols. Fake symbol removal makes nonzero diff, but rom OK's after make. * moving declarations around, ordering. * One.word.away. from importing data in ovl_Bg_Kin2_Bombwall. * ovl_Bg_Kin2_Bombwall data imported. Matching. * Edited spec for reloc of ovl_Bg_Kin2_Bombwall. * Removed extra comments for ovl_Bg_Kin2_Bombwall. * unpushed stuff. dunno. * forgot to save z_bg_kin2_bombwall.c * need to commit before make-ing in master. * Ported z_bg_kin2_bombwall's code. Data next. * Imported data for merging z_bg_kin2_bombwall. Yes, I yelled when it OK'd. * Added comments to remember what does what in z_bg_kin2_bombwall. * Some comments in z_bg_kin2_bombwall.c and function names ideas. * Added comments for function name ideas. Cleaned up temps in z_bg_kin2_bombwall except in func_80B6E090. * Renamed most functions and some variables in z_bg_kin2_bombwall. * Made a name suggestion for func_80B6E020 after testing in game. * Ran format.sh. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c 1 and 0 replaced by true and false in func_80B6E020. Co-authored-by: Isghj <42048411+isghj5@users.noreply.github.com> * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Bending to the x-- supremacy. Co-authored-by: Isghj <42048411+isghj5@users.noreply.github.com> * PR fixes (not done yet) including more consistent use of THIS, removing arg0 and arg1 variable names, standardizing params for z_bg_kin2_bombwall, turning some if-return to if-else, removing unnecessary casts. * Applied isghj5's and EllipticEllipsis' suggestions except for the object file in z_bg_kin2_bombwall. Object file next. * Screwd up formatting. * Thinking of playing with object_kin2_obj. * Documented most of object_kin2_obj based on bombwall, fence and shelf actors. * Had forgotten an arg1 in z_bg_kin2_bombwall.c * First commit for ovl_Bg_Ikana_Mirror branch. * Started decompiling ovl_Bg_Ikana_Mirror. Setup functions and _Update done matching. * Replaced a float by its fractional representation. I need to learn float magic. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Co-authored-by: EllipticEllipsis * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h Co-authored-by: EllipticEllipsis * Applied more formatting and naming remarks from PR about the C file. Assets and object stuff next. * Display lists and collision header in z_bg_kin2_bombwall.c renamed after their descriptive names in the object's XML file. Name for Ocean Spider House drawers chests left to change. * Working on BgIkanaMirror_Destroy. Stack and registers left essentially. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Co-authored-by: Derek Hensley * One extra line in an if, collision naming convention applied and renamed Ocean Spider House nightstands to drawers chests. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Co-authored-by: Derek Hensley * Changed drawers chest to chest of drawers in object_kin2_obj and z_bg_kin2_shelf. * Removed some unnecessary comment. * almost done with BgIkanaMirror_Destroy function. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Co-authored-by: EllipticEllipsis * BgIkanaMirror_Destroy OK. * Almost done with BgIkanaMirror_Init. Mostly stack stuff left. * Registers and stack left to fix for BgIkanaMirror_Init. * BgIkanaMirror_Init matching. * Ran permuter to improve BgIkanaMirror_Draw's score. * Actually not mad at permuter for BgIkanaMirror_Draw headstart. * Matched func_80B7F730 in ovl_Bg_Ikana_Mirror. Progress on its _Init done too. * func_80B7FA9C in ovl_Bg_Ikana_Mirror is matching. _Init left then documentation. * Mistake in last commit message: actually, _Draw is left for ovl_Bg_Ikana_Mirror. * Going to do some groceries, so pushing. About 2/3 across func_80B7FBA4 in ovl_Bg_Ikana_Mirror. * func_80B7FBA4 in ovl_Bg_Ikana_Mirror is matching. _Draw then data left. * Need to switch branch. * Fixed BgKin2Bombwall_SpawnEffects after the Rand_Next() type update. * Switching branch. * Learning to decomp draw functions with BgIkanaMirror_Draw. YEP * Switching branch. * Went through the first wave of graphics macros attempts for BgIkanaMirror_Draw. * Removed some temps in BgIkanaMirror_Draw. * Second pass of macro attempts for BgIkanaMirror_Draw. * Diff score for BgIkanaMirror_Draw at 1873. Getting there. * BgIkanaMirror_Draw diff score down to 854. 4 instructions off and registers to fix. * Instructions are matching for BgIkanaMirror_Draw. Registers left. * BgIkanaMirror_Draw matches. Data next. Adding some co-authors * BgIkanaMirror_Draw matches. Data next. Adding some co-authors Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Tom-Overton Co-authored-by: Isghj5 Co-authored-by: mzxrules Co-authored-by: Derek-Hensley * Data imported and OK. Co-authored-by: Maide Co-authored-by: mzxrules Co-authored-by: Derek-Hensley * Removed commented lines of unused code and useless externs. Documenting C file and object next. * Renamed fields in actor and variables in 3 functions for ovl_bg_ikana_mirror. Some conventions applied. * Renamed more variables in the struct and C file for ovl_bg_ikana_mirror. * More cleanups and naming in ovl_Bg_Ikana_Mirror. * Renamed some functions in ovl_Bg_Ikana_Mirror. More cleanups. Object documentation next once function names confirmed. * Renamed collision header, animated textures and display lists for ovl_Bg_Ikana_Mirror in ovl_Bg_Ikana_Mirror and object_ikana_obj. Some textures left to rename. * Renamed textures only used by ovl_Bg_Ikana_Mirror. Must go back through docs for conventions and styles plus an extra cleanup before PR. * Went through merging and review docs for extra cleanups. Adding co-authors for documentation. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Derek-Hensley * Creating branch to merge ovl_Bg_Ikana_Mirror. * Fixed the merge from zeldaret/mm. ovl_Bg_Ikana_Mirror OK and documented. PR-ready. * Started ovl_Bg_Kin2_Picture. _Draw, _Destroy and _Update matching. Started _Init. * Switching branch. * Applied first batch of fixes from PR comments. Adding co-authors for documentation and a function rewrite. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Derek-Hensley Co-authored-by: Kelebek1 * Renamed the colliders in ovl_Bg_Ikana_Mirror's struct and fixed naming in object file plus spacing cleanups. * About 8 extra functions matching for ovl_Bg_Kin2_Picture. _Init and 3 other functions to match. * Only two functions left to match in ovl_Bg_Kin2_Picture. * func_80B6F098 in ovl_Bg_Kin2_Picture is matching. Adding co-authors. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Derek-Hensley * ovl_Bg_Kin2_Picture OK. Documentation for the overlay and the associated object next. * Fixed reloc file in spec for ovl_Bg_Kin2_Picture. * Fixed reloc file in spec for ovl_Bg_Kin2_Picture. * Started ovl_Bg_Kin2_Picture clean up. Named extra assets in object_kin2_obj. Rewrote func_80B6EFEC. Adding documentation co-authors. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Isghj5 * Removed some temps from functions, renamed some functions and some variables in ovl_Bg_Kin2_Picture. * More cleanups. Starting to make sense of what is happening in ovl_Bg_Kin2_Picture. * Renamed the spawn function for Gold Skulltulas and a timer variable in ovl_Bg_Kin2_Picture. * Renamed fall and shiver functions plus their respective setup functions for ovl_Bg_Kin2_Picture. Renamed some variables in the same actor. * Renamed all functions in ovl_Bg_Kin2_Picture. Need to confirm name for painting timer used for two distinct reasons. * Renamed a struct variable and rewrote some comments for ovl_Bg_Kin2_Picture. * Renamed all struct variables in ovl_Bg_Kin2_Picture except padding. * Renamed static variable, dust spawn function and a variable in the dust spawn function for ovl_Bg_Kin2_Picture. * Finished decompiling object_kin2_obj. Adding extra co-authors. Co-authored-by: Derek-Hensley Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Ready to make PR branch. * Fixed merge conflicts. OK. * Fixed object_kin2_obj.xml error. * Applied first batch of fixes from PR review to z_bg_kin2_picture.c and its corresponding header. * Fixed unused TLUT naming in object_kin2_obj.xml and added a description to the object. * Removed extra parentheses in z_bg_kin2_picture.c and renamed a macro. * First batch of fixes suggested by EllipticEllipsis for ovl_Bg_Kin2_Picture. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Second batch of fixes suggested by EllipticEllipsis for ovl_Bg_Kin2_Picture. Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c Co-authored-by: EllipticEllipsis * Rewrote 0xCCC as 0x10000/20. * Renamed angle and offset variables in BgKin2Picture_SpawnDust. Co-authored-by: Isghj <42048411+isghj5@users.noreply.github.com> Co-authored-by: EllipticEllipsis Co-authored-by: Derek Hensley Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Isghj5 Co-authored-by: mzxrules Co-authored-by: Maide --- assets/xml/objects/object_kin2_obj.xml | 38 +- spec | 3 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 2 +- .../ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c | 333 +++++++++++++++--- .../ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h | 20 +- tools/disasm/functions.txt | 26 +- 6 files changed, 344 insertions(+), 78 deletions(-) diff --git a/assets/xml/objects/object_kin2_obj.xml b/assets/xml/objects/object_kin2_obj.xml index e0ae09106c..d36766ee43 100644 --- a/assets/xml/objects/object_kin2_obj.xml +++ b/assets/xml/objects/object_kin2_obj.xml @@ -1,33 +1,51 @@  + - + + - - - - + + + + + + + + - - + + + + - + + + - + + - + + + + + diff --git a/spec b/spec index a59e3f0f44..428de2321e 100644 --- a/spec +++ b/spec @@ -3945,8 +3945,7 @@ beginseg name "ovl_Bg_Kin2_Picture" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.o" - include "build/data/ovl_Bg_Kin2_Picture/ovl_Bg_Kin2_Picture.data.o" - include "build/data/ovl_Bg_Kin2_Picture/ovl_Bg_Kin2_Picture.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Picture/ovl_Bg_Kin2_Picture_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 09f71c4ff2..34aba7769f 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -150,7 +150,7 @@ void BgKin2Fence_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_kin2_obj_Colheader_000908); + DynaPolyActor_LoadMesh(play, &this->dyna, &gOceanSpiderHouseFireplaceGrateCol); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c index 2f50ca820c..39c72a108d 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.c @@ -5,6 +5,7 @@ */ #include "z_bg_kin2_picture.h" +#include "assets/objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS 0x00000000 @@ -15,13 +16,17 @@ void BgKin2Picture_Destroy(Actor* thisx, PlayState* play); void BgKin2Picture_Update(Actor* thisx, PlayState* play); void BgKin2Picture_Draw(Actor* thisx, PlayState* play); -void func_80B6F4D4(BgKin2Picture* this, PlayState* play); -void func_80B6F5B8(BgKin2Picture* this, PlayState* play); -void func_80B6F640(BgKin2Picture* this, PlayState* play); -void func_80B6F72C(BgKin2Picture* this, PlayState* play); -void func_80B6F90C(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupWait(BgKin2Picture* this); +void BgKin2Picture_Wait(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupPlayCutscene(BgKin2Picture* this); +void BgKin2Picture_PlayCutscene(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupShiver(BgKin2Picture* this); +void BgKin2Picture_Shiver(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupFall(BgKin2Picture* this); +void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupDoNothing(BgKin2Picture* this); +void BgKin2Picture_DoNothing(BgKin2Picture* this, PlayState* play); -#if 0 const ActorInit Bg_Kin2_Picture_InitVars = { ACTOR_BG_KIN2_PICTURE, ACTORCAT_PROP, @@ -34,73 +39,307 @@ const ActorInit Bg_Kin2_Picture_InitVars = { (ActorFunc)BgKin2Picture_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80B6F990[2] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x000138B0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -20.0f, 53.29999923706055f, 9.0f }, { -20.0f, 3.0f, 9.0f }, { 20.0f, 3.0f, 9.0f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x000138B0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -20.0f, 53.3f, 9.0f }, { -20.0f, 3.0f, 9.0f }, { 20.0f, 3.0f, 9.0f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x000138B0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -20.0f, 53.29999923706055f, 9.0f }, { 20.0f, 3.0f, 9.0f }, { 20.0f, 53.29999923706055f, 9.0f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x000138B0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -20.0f, 53.3f, 9.0f }, { 20.0f, 3.0f, 9.0f }, { 20.0f, 53.3f, 9.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B6FA08 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - ARRAY_COUNT(sTrisElementsInit), D_80B6F990, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sTrisElementsInit), + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B6FA24[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +static Vec3f sDustBasePos = { 0.0f, 23.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 BgKin2Picture_IsSkulltulaCollected(PlayState* play, s32 skulltulaParams) { + s32 flag = -1; -extern ColliderTrisElementInit D_80B6F990[2]; -extern ColliderTrisInit D_80B6FA08; -extern InitChainEntry D_80B6FA24[]; + if ((u8)skulltulaParams & 3) { + flag = BG_KIN2_PICTURE_GET_3FC(skulltulaParams); + } -extern UNK_TYPE D_06000658; -extern UNK_TYPE D_06000798; + return (flag >= 0) && Flags_GetTreasure(play, flag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6EFA0.s") +void BgKin2Picture_SpawnSkulltula(BgKin2Picture* this, PlayState* play2) { + PlayState* play = play2; + s32 skulltulaSpawnParams; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6EFEC.s") + if (!BG_KIN2_PICTURE_SKULLTULA_COLLECTED(&this->dyna.actor)) { // Gold Skulltula is still here. + skulltulaSpawnParams = BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); + if (!BgKin2Picture_IsSkulltulaCollected(play, skulltulaSpawnParams) && + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, this->dyna.actor.home.pos.x, + this->dyna.actor.home.pos.y + 23.0f, this->dyna.actor.home.pos.z, 0, + this->dyna.actor.home.rot.y, 0, skulltulaSpawnParams)) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F098.s") +#define DUST_COUNT 20 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Init.s") +void BgKin2Picture_SpawnDust(BgKin2Picture* this, PlayState* play) { + f32 offset; + Vec3f basePos; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + s32 angle; + s32 scale; + s16 scaleStep; + s32 baseAngle; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Destroy.s") + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultVec3f(&sDustBasePos, &basePos); + pos.y = basePos.y - 7.0f; + velocity.y = 0.0f; + accel.y = 0.2f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F4C0.s") + for (i = 0, baseAngle = 0; i < DUST_COUNT; i++, baseAngle += (0x10000 / DUST_COUNT)) { + angle = (s32)(Rand_ZeroOne() * (0x10000 / DUST_COUNT)) + baseAngle; + offset = (Rand_ZeroOne() * 14.0f) + 4.0f; + pos.x = Math_SinS(angle) * offset; + pos.z = Math_CosS(angle) * offset; + velocity.x = (Rand_ZeroOne() - 0.5f) + (pos.x * (1.0f / 6.0f)); + velocity.z = (Rand_ZeroOne() - 0.5f) + (pos.z * (1.0f / 6.0f)); + pos.x += basePos.x; + pos.z += basePos.z; + accel.x = velocity.x * -0.09f; + accel.z = velocity.z * -0.09f; + scale = (s32)(Rand_ZeroOne() * 10.0f) + 10; + scaleStep = (s32)(Rand_ZeroOne() * 10.0f) + 15; + func_800B1210(play, &pos, &velocity, &accel, scale, scaleStep); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F4D4.s") +void BgKin2Picture_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgKin2Picture* this = THIS; + s32 skulltulaParams; + Vec3f vertices[3]; + s32 i; + s32 j; + ColliderTrisElementInit* element; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F5A4.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gOceanSpiderHouseSkullkidPaintingCol); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_InitTris(play, &this->colliderTris); + Collider_SetTris(play, &this->colliderTris, &this->dyna.actor, &sTrisInit, this->colliderElement); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F5B8.s") + for (i = 0; i < ARRAY_COUNT(sTrisElementsInit); i++) { + for (j = 0; j < ARRAY_COUNT(vertices); j++) { + element = &sTrisInit.elements[i]; + Matrix_MultVec3f(&element->dim.vtx[j], &vertices[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vertices[0], &vertices[1], &vertices[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F61C.s") + Actor_SetFocus(&this->dyna.actor, 23.0f); + skulltulaParams = BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F640.s") + if (BG_KIN2_PICTURE_SKULLTULA_COLLECTED(&this->dyna.actor) || + BgKin2Picture_IsSkulltulaCollected(play, skulltulaParams)) { + this->skulltulaNoiseTimer = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F708.s") + BgKin2Picture_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F72C.s") +void BgKin2Picture_Destroy(Actor* thisx, PlayState* play) { + BgKin2Picture* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F8F8.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F90C.s") +void BgKin2Picture_SetupWait(BgKin2Picture* this) { + this->actionFunc = BgKin2Picture_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Update.s") +void BgKin2Picture_Wait(BgKin2Picture* this, PlayState* play) { + // hit by projectile + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + BgKin2Picture_SetupPlayCutscene(this); + } else { // Gold Skulltula can be heard behind Skullkid's painting. + if (this->skulltulaNoiseTimer >= 0) { + if (this->skulltulaNoiseTimer == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Draw.s") + if (Rand_ZeroOne() < 0.1f) { + this->skulltulaNoiseTimer = Rand_S16Offset(40, 80); + } else { + this->skulltulaNoiseTimer = 8; + } + } else { + this->skulltulaNoiseTimer--; + } + } + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + } +} + +void BgKin2Picture_SetupPlayCutscene(BgKin2Picture* this) { + this->actionFunc = BgKin2Picture_PlayCutscene; +} + +void BgKin2Picture_PlayCutscene(BgKin2Picture* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->cutsceneStarted = true; + BgKin2Picture_SetupShiver(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void BgKin2Picture_SetupShiver(BgKin2Picture* this) { + this->paintingTimer = 13; + this->xOffsetAngle = 0; + this->yOffsetAngle = 0; + this->actionFunc = BgKin2Picture_Shiver; +} + +void BgKin2Picture_Shiver(BgKin2Picture* this, PlayState* play) { + s32 pad; + Vec3f basePosOffset; + Vec3f posOffset; + + this->paintingTimer--; + if (this->paintingTimer <= 0) { + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + BgKin2Picture_SetupFall(this); + } else { + this->xOffsetAngle += 0x7BAC; + this->yOffsetAngle += 0x4E20; + basePosOffset.x = Math_CosS(this->xOffsetAngle); + basePosOffset.y = Math_CosS(this->yOffsetAngle) * 0.2f; + basePosOffset.z = 0.0f; + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&basePosOffset, &posOffset); + Math_Vec3f_Sum(&this->dyna.actor.home.pos, &posOffset, &this->dyna.actor.world.pos); + } +} + +void BgKin2Picture_SetupFall(BgKin2Picture* this) { + this->landTimer = 0; + this->step = 0; + this->paintingTimer = 4; + this->actionFunc = BgKin2Picture_Fall; +} + +void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play) { + if (this->paintingTimer > 0) { + this->paintingTimer--; + + if (this->paintingTimer == 0) { + BgKin2Picture_SpawnSkulltula(this, play); + } + } + + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->dyna.actor.bgCheckFlags & 1) { + Math_StepToS(&this->step, 0x7D0, 0x78); + + if (this->landTimer < 3) { + this->landTimer++; + + if (this->dyna.actor.velocity.y <= 0.01f) { + this->dyna.actor.velocity.y *= -0.7f; + + if (this->dyna.actor.velocity.y > 6.0f) { + this->dyna.actor.velocity.y = 6.0f; + } + + if (this->landTimer < 3) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SMALL_WOODPLATE_BOUND_0); + } + } + } + } + + Actor_SetFocus(&this->dyna.actor, 23.0f); + + if (!this->hasSpawnedDust && (this->dyna.actor.shape.rot.x > 0x3300)) { + BgKin2Picture_SpawnDust(this, play); + this->hasSpawnedDust = true; + } + + if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, 0x4000, this->step)) { // facing the floor + this->dyna.actor.shape.yOffset = 40.0f; + + if (this->cutsceneStarted) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + BgKin2Picture_SetupDoNothing(this); + } else { + this->dyna.actor.shape.yOffset = Math_SinS(this->dyna.actor.shape.rot.x) * 40.0f; + } +} + +void BgKin2Picture_SetupDoNothing(BgKin2Picture* this) { + this->actionFunc = BgKin2Picture_DoNothing; +} + +void BgKin2Picture_DoNothing(BgKin2Picture* this, PlayState* play) { +} + +void BgKin2Picture_Update(Actor* thisx, PlayState* play) { + BgKin2Picture* this = THIS; + + this->actionFunc(this, play); +} + +void BgKin2Picture_Draw(Actor* thisx, PlayState* play) { + BgKin2Picture* this = THIS; + + Gfx_DrawDListOpa(play, gOceanSpiderHouseSkullkidPaintingDL); +} diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h index 19651ef575..ce7cf95fb3 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.h @@ -3,17 +3,27 @@ #include "global.h" +#define BG_KIN2_PICTURE_SKULLTULA_COLLECTED(thisx) (((thisx)->params >> 5) & 1) +#define BG_KIN2_PICTURE_GET_3FC(thisx) ((u8)(((thisx & 0x3FC)) >> 2)) +#define BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(thisx) ((((thisx)->params & 0x1F) << 2) | 0xFF03) + struct BgKin2Picture; typedef void (*BgKin2PictureActionFunc)(struct BgKin2Picture*, PlayState*); typedef struct BgKin2Picture { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xF0]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris colliderTris; + /* 0x17C */ ColliderTrisElement colliderElement[2]; /* 0x234 */ BgKin2PictureActionFunc actionFunc; - /* 0x238 */ char unk_238[0xC]; + /* 0x238 */ s16 step; + /* 0x23A */ s8 paintingTimer; // Used for when painting is shaking and for timing Gold Skulltula spawn. + /* 0x23B */ s8 landTimer; + /* 0x23C */ s16 xOffsetAngle; + /* 0x23E */ s16 yOffsetAngle; + /* 0x240 */ s8 cutsceneStarted; + /* 0x241 */ s8 hasSpawnedDust; + /* 0x242 */ s8 skulltulaNoiseTimer; } BgKin2Picture; // size = 0x244 -extern const ActorInit Bg_Kin2_Picture_InitVars; - #endif // Z_BG_KIN2_PICTURE_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5746355b33..4165363f84 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14322,21 +14322,21 @@ 0x80B6ED58:("BgKin2Fence_DoNothing",), 0x80B6ED68:("BgKin2Fence_Update",), 0x80B6ED8C:("BgKin2Fence_Draw",), - 0x80B6EFA0:("func_80B6EFA0",), - 0x80B6EFEC:("func_80B6EFEC",), - 0x80B6F098:("func_80B6F098",), + 0x80B6EFA0:("BgKin2Picture_IsSkulltulaCollected",), + 0x80B6EFEC:("BgKin2Picture_SpawnSkulltula",), + 0x80B6F098:("BgKin2Picture_SpawnDust",), 0x80B6F2DC:("BgKin2Picture_Init",), 0x80B6F478:("BgKin2Picture_Destroy",), - 0x80B6F4C0:("func_80B6F4C0",), - 0x80B6F4D4:("func_80B6F4D4",), - 0x80B6F5A4:("func_80B6F5A4",), - 0x80B6F5B8:("func_80B6F5B8",), - 0x80B6F61C:("func_80B6F61C",), - 0x80B6F640:("func_80B6F640",), - 0x80B6F708:("func_80B6F708",), - 0x80B6F72C:("func_80B6F72C",), - 0x80B6F8F8:("func_80B6F8F8",), - 0x80B6F90C:("func_80B6F90C",), + 0x80B6F4C0:("BgKin2Picture_SetupWait",), + 0x80B6F4D4:("BgKin2Picture_Wait",), + 0x80B6F5A4:("BgKin2Picture_SetupPlayCutscene",), + 0x80B6F5B8:("BgKin2Picture_PlayCutscene",), + 0x80B6F61C:("BgKin2Picture_SetupShiver",), + 0x80B6F640:("BgKin2Picture_Shiver",), + 0x80B6F708:("BgKin2Picture_SetupFall",), + 0x80B6F72C:("BgKin2Picture_Fall",), + 0x80B6F8F8:("BgKin2Picture_SetupDoNothing",), + 0x80B6F90C:("BgKin2Picture_DoNothing",), 0x80B6F91C:("BgKin2Picture_Update",), 0x80B6F940:("BgKin2Picture_Draw",), 0x80B6FB30:("func_80B6FB30",),