From 8ba8780bb55d8e9eb4ce216612cf3347f8e303cd Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Wed, 25 May 2022 16:59:36 -0700 Subject: [PATCH 01/53] En_Snowman (Eeno and snowballs) OK and documented. object_snowman documented (#818) * EnSnowman_Init OK * EnSnowman_Destroy OK * func_80B173D0 OK and better match for EnSnowman_Init * EnSnowman_Draw OK * func_80B19948 OK * func_80B19998 OK * func_80B19718 OK * func_80B1746C and func_80B177EC OK * Match a ton of functions * func_80B18B30 OK * func_80B180A4 OK * func_80B18C7C OK * func_80B18124 OK * EnSnowman_Update OK * func_80B17144 OK * func_80B19474 OK * func_80B18F50 OK * All functions OK * Import data to C * Use object symbols * Misc cleanup * Fully document object_snowman * Low hanging fruit * Document snowman types * Some more minor stuff * Some more minor cleanup and naming * Name some more functions * More names * Even more names * Turns out, they're called Eeno! * limbPos -> bodyPartsPos as per Fig's suggestion * Update some more names * Committing so I can push up stuff for the snowballPos naming * More names + use generated reloc * First pass name on every function * First pass names on all struct vars * Document the mega eeno glitch * Get rid of garbage "split dead" naming * First pass documentation on combine state * Better names and some documentation * Last doc pass before PR * Respond to Elliptic's review * / 100.0f -> * 0.01f --- assets/xml/objects/object_snowman.xml | 118 +- spec | 3 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 1225 +++++++++++++++-- .../actors/ovl_En_Snowman/z_en_snowman.h | 48 +- tools/disasm/functions.txt | 70 +- tools/disasm/variables.txt | 6 +- undefined_syms.txt | 13 - 7 files changed, 1268 insertions(+), 215 deletions(-) diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index 91b650a75..fde2d911f 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -1,49 +1,77 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index a2d9a9ef3..f6b19ee8a 100644 --- a/spec +++ b/spec @@ -3820,8 +3820,7 @@ beginseg name "ovl_En_Snowman" compress include "build/src/overlays/actors/ovl_En_Snowman/z_en_snowman.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.data.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.reloc.o" + include "build/src/overlays/actors/ovl_En_Snowman/ovl_En_Snowman_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 32d38ecb9..683685889 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1,7 +1,7 @@ /* * File: z_en_snowman.c * Overlay: ovl_En_Snowman - * Description: Enos + * Description: Eeno */ #include "z_en_snowman.h" @@ -15,21 +15,52 @@ void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B1746C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B178B8(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17A58(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17D78(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17EFC(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17FE0(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18124(EnSnowman* this, GlobalContext* globalCtx); -void func_80B183A4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1848C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1861C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B189C4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18A04(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18C7C(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMoveSnowPile(EnSnowman* this); +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupReadySnowball(EnSnowman* this); +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupThrowSnowball(EnSnowman* this); +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupIdle(EnSnowman* this); +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupDead(EnSnowman* this); +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSplitDoNothing(EnSnowman* this); +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMarkForDeath(EnSnowman* this); +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot); +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos); +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + // Indicates that this split Eeno is not currently trying to combine into a large Eeno. + /* 0 */ EN_SNOWMAN_COMBINE_STATE_NONE, + + // Indicates that this split Eeno is actively trying to combine into a large Eeno again. + // Eenos in this state can both absorb other Eenos and start being absorbed themselves. + /* 1 */ EN_SNOWMAN_COMBINE_STATE_ACTIVE, + + // Indicates that this Eeno cannot absorb other Eenos to combine into a large Eeno. + // It can still be absorbed by Eenos in the EN_SNOWMAN_COMBINE_STATE_ACTIVE state. + /* 2 */ EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION, + + // Indicates that either this Eeno is shrinking having been absorbed by another Eeno, or that + // this Eeno is a fully-combined large Eeno and is done trying to combine with other split + // Eenos. In both cases, this Eeno cannot be absorbed by any other Eeno. + /* 3 */ EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE, +} EnSnowmanCombineState; -#if 0 const ActorInit En_Snowman_InitVars = { ACTOR_EN_SNOWMAN, ACTORCAT_ENEMY, @@ -42,155 +73,1125 @@ const ActorInit En_Snowman_InitVars = { (ActorFunc)EnSnowman_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A00 = { - { COLTYPE_HIT4, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEenoCylinderInit = { + { + COLTYPE_HIT4, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0.0f, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A2C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sSnowballCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B19A58 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_SNOWMAN_DMGEFF_NONE, + /* 0x1 */ EN_SNOWMAN_DMGEFF_STUN, + /* 0x2 */ EN_SNOWMAN_DMGEFF_MELT, + /* 0x4 */ EN_SNOWMAN_DMGEFF_LIGHT_ORB = 0x4, + /* 0x5 */ EN_SNOWMAN_DMGEFF_ELECTRIC_STUN, + /* 0xF */ EN_SNOWMAN_DMGEFF_HOOKSHOT = 0xF, // Damages small Eenos, pulls the player towards large Eenos +} EnTalkGibudDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_MELT), + /* Ice arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B19A78 = { 2, 60, 80, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 60, 80, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B19AAC[] = { +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; + +static Color_RGBA8 sDustEnvColor = { 180, 180, 180, 255 }; + +static Vec3f sDustVelocity = { 0.0f, 1.5f, 0.0f }; + +static Gfx* sSnowballDLs[] = { + gEenoSmallSnowballDL, + gEenoLargeSnowballDL, + gEenoSmallSnowballDL, +}; + +static Gfx* sSnowballFragmentDLs[] = { + gEenoSnowballFragment1DL, + gEenoSnowballFragment2DL, + gEenoSnowballFragment3DL, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 20, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + s32 attackRange; -extern ColliderCylinderInit D_80B19A00; -extern ColliderCylinderInit D_80B19A2C; -extern DamageTable D_80B19A58; -extern CollisionCheckInfoInit D_80B19A78; -extern InitChainEntry D_80B19AAC[]; + Actor_ProcessInitChain(thisx, sInitChain); + attackRange = EN_SNOWMAN_GET_ATTACK_RANGE(thisx); + if (attackRange == 0xFF) { + attackRange = 0; + } -extern UNK_TYPE D_06000404; -extern UNK_TYPE D_06004628; -extern UNK_TYPE D_060046D8; -extern UNK_TYPE D_06004F14; -extern UNK_TYPE D_0600554C; -extern UNK_TYPE D_060058CC; + thisx->params &= 7; + if (EN_SNOWMAN_GET_TYPE(thisx) < EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEenoSkel, &gEenoEmergeAnim, this->jointTable, + this->morphTable, EENO_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->snowPileSkelAnime, &gEenoSnowPileSkel, &gEenoSnowPileMoveAnim, + this->snowPileJointTable, this->snowPileMorphTable, EENO_SNOW_PILE_LIMB_MAX); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sEenoCylinderInit); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_LARGE) { + thisx->flags |= ACTOR_FLAG_400; + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_SNOWMAN, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, EN_SNOWMAN_TYPE_SPLIT); + thisx->parent = Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, + thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, + 0, 0, EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + if ((thisx->child == NULL) || (thisx->parent == NULL)) { + if (thisx->child != NULL) { + Actor_MarkForDeath(thisx->child); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Init.s") + if (thisx->parent != NULL) { + Actor_MarkForDeath(thisx->parent); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Destroy.s") + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B16FC0.s") + // Makes each split Eeno the parent or child of other split Eenos + thisx->parent->child = thisx; + thisx->child->child = thisx->parent; + thisx->parent->parent = thisx->child; + if (1) {} + Actor_SetScale(thisx, 0.02f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17144.s") + this->eenoScale = thisx->scale.x * 100.0f; + this->attackRange = (240.0f * this->eenoScale) + (attackRange * 0.1f * 40.0f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B173D0.s") + thisx->flags &= ~ACTOR_FLAG_1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sSnowballCylinderInit); + thisx->world.rot.y = Actor_YawBetweenActors(thisx, &player->actor); + thisx->velocity.y = (Actor_XZDistanceBetweenActors(thisx, &player->actor) * 0.035f) + -5.0f; + thisx->velocity.y = CLAMP_MAX(thisx->velocity.y, 3.5f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + thisx->speedXZ = 15.0f; + } else { + thisx->speedXZ = 22.5f; + thisx->velocity.y *= 1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1746C.s") + thisx->world.pos.x += thisx->speedXZ * Math_SinS(thisx->world.rot.y); + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->speedXZ * Math_CosS(thisx->world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B177EC.s") + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + this->collider.dim.radius = 8; + this->collider.dim.height = 12; + this->collider.dim.yShift = -6; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + } else { + this->collider.dim.radius = 50; + this->collider.dim.height = 122; + this->collider.dim.yShift = -8; + this->collider.info.toucher.damage = 16; + thisx->world.pos.y -= 32.0f; + Actor_SetScale(thisx, 0.006f); + ActorShape_Init(&thisx->shape, 16000.0f / 3.0f, ActorShadow_DrawCircle, 170.0f); + thisx->gravity = -1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B178B8.s") + thisx->flags |= ACTOR_FLAG_10; + thisx->update = EnSnowman_UpdateSnowball; + thisx->draw = EnSnowman_DrawSnowball; + this->work.timer = 5; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B179D0.s") +void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17A58.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17CE8.s") +/** + * Spawns a circle of snow-colored dust around the actor. + */ +void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx) { + s16 angle = 0; + Vec3f pos; + f32 offset; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17D78.s") + pos.y = (Rand_ZeroFloat(10.0f) * this->eenoScale) + this->actor.world.pos.y; + for (i = 0; i < 16; i++) { + offset = (Rand_ZeroFloat(10.0f) + 20.0f) * this->eenoScale; + pos.x = (Math_SinS(angle) * offset) + this->actor.world.pos.x; + pos.z = (Math_CosS(angle) * offset) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + this->eenoScale * 400.0f, 10); + angle += 0x1000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EB4.s") +/** + * Spawns a batch of large snowball fragments and some snow-colored dust at snowballPos. + */ +void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -1.0f, 0.0f }; + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EFC.s") + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1800, 0x2800); + azimuth = ((u32)Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(3.0f) + 8.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(10.0f) * velocity.x) + this->snowballPos.x; + pos.y = (Rand_ZeroFloat(8.0f) * velocity.y) + this->snowballPos.y; + pos.z = (Rand_ZeroFloat(10.0f) * velocity.z) + this->snowballPos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17F4C.s") + func_800B0DE0(globalCtx, &this->snowballPos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17FE0.s") +void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { + Animation_PlayLoop(&this->snowPileSkelAnime, &gEenoSnowPileMoveAnim); + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 2.0f; + this->actor.draw = EnSnowman_DrawSnowPile; + this->work.timer = 40; + this->turningOnSteepSlope = false; + this->collider.dim.radius = this->eenoScale * 30.0f; + this->collider.dim.height = this->eenoScale * 10.0f; + this->actionFunc = EnSnowman_MoveSnowPile; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B180A4.s") +/** + * Moves around beneath the snow as a snow pile. + */ +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f combinePos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18124.s") + SkelAnime_Update(&this->snowPileSkelAnime); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MOVE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MINI_MOVE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18380.s") + if (this->work.timer > 0) { + this->work.timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183A4.s") + if (this->work.timer == 0) { + this->collider.base.acFlags |= AC_ON; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183C4.s") + if ((this->combineTimer == 0) && (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT)) { + // Sets the combinePos to be the average position of all living split Eenos. + if ((this->actor.parent->colChkInfo.health != 0) && (this->actor.child->colChkInfo.health != 0)) { + combinePos.x = + (this->actor.parent->world.pos.x + this->actor.child->world.pos.x + this->actor.world.pos.x) * + (1.0f / 3.0f); + combinePos.z = + (this->actor.parent->world.pos.z + this->actor.child->world.pos.z + this->actor.world.pos.z) * + (1.0f / 3.0f); + } else if (this->actor.parent->colChkInfo.health != 0) { + combinePos.x = (this->actor.parent->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.parent->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else if (this->actor.child->colChkInfo.health != 0) { + combinePos.x = (this->actor.child->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.child->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else { + combinePos.x = this->actor.world.pos.x; + combinePos.z = this->actor.world.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1848C.s") + combinePos.y = this->actor.world.pos.y; + EnSnowman_SetupCombine((EnSnowman*)this->actor.parent, globalCtx, &combinePos); + EnSnowman_SetupCombine((EnSnowman*)this->actor.child, globalCtx, &combinePos); + EnSnowman_SetupCombine(this, globalCtx, &combinePos); + } else if ((this->work.timer == 0) && (fabsf(this->actor.playerHeightRel) < 60.0f) && + (this->actor.xzDistToPlayer < this->attackRange) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->snowPileTargetRotY != this->actor.shape.rot.y) { + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->snowPileTargetRotY, 0x100)) { + this->turningOnSteepSlope = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18600.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (this->actor.bgCheckFlags & 8) { + this->snowPileTargetRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + } else if (Rand_ZeroOne() < 0.02f) { + this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1861C.s") +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_PlayOnce(&this->skelAnime, &gEenoEmergeAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SURFACE); + this->collider.dim.radius = this->eenoScale * 40.0f; + this->collider.dim.height = this->eenoScale * 25.0f; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x * 0.4f; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnSnowman_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18908.s") +/** + * Emerge from beneath the snow and face the player. + */ +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189C4.s") + Math_StepToF(&this->actor.scale.y, this->actor.scale.x, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189D4.s") + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + EnSnowman_SetupSubmerge(this, globalCtx); + } else if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + this->collider.base.acFlags |= AC_ON; + this->work.snowballsToThrowBeforeIdling = 3; + EnSnowman_SetupReadySnowball(this); + } else { + this->collider.base.acFlags |= AC_ON; + this->actor.scale.y = this->actor.scale.x; + EnSnowman_SetupIdle(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A04.s") +void EnSnowman_SetupReadySnowball(EnSnowman* this) { + this->actor.scale.y = this->actor.scale.x; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + this->fwork.frameToStartHoldingSnowball = 15.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballCreateAnim); + } else { + this->fwork.frameToStartHoldingSnowball = 6.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballCreateAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A28.s") + this->actionFunc = EnSnowman_ReadySnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18B30.s") +/** + * Plays the animation of the Eeno creating a snowball and spawns some snow-colored dust + * near the snowball at the appropriate part of their animation. + */ +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18BB4.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE) && this->isHoldingSnowball && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.x; + pos.y = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.y; + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, 30); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if ((this->skelAnime.curFrame > 3.0f) && (this->skelAnime.curFrame < 14.0f) && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = (this->actor.world.pos.x + (70.0f * Math_SinS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(20.0f); + pos.z = (this->actor.world.pos.z + (70.0f * Math_CosS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18C7C.s") + if (SkelAnime_Update(&this->skelAnime)) { + EnSnowman_SetupThrowSnowball(this); + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToStartHoldingSnowball)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HOLD_SNOW); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_HOLD); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18F50.s") + this->isHoldingSnowball = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Update.s") +void EnSnowman_SetupThrowSnowball(EnSnowman* this) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 17.0f; + } else { + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 15.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19474.s") + this->work.snowballsToThrowBeforeIdling--; + this->actionFunc = EnSnowman_ThrowSnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19718.s") +/** + * Throws the snowball the Eeno is holding at the player. If there are still more snowballs + * to throw before idling, this function is responsible for calling EnSnowman_SetupReadySnowball + * so it can eventually throw another one. Otherwise, this function will call EnSnowman_SetupIdle + * to transition the Eeno into an idle state. + */ +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Draw.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if (SkelAnime_Update(&this->skelAnime)) { + if ((this->work.snowballsToThrowBeforeIdling != 0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupReadySnowball(this); + } else { + this->work.snowballsToThrowBeforeIdling = 0; + EnSnowman_SetupIdle(this); + } + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToThrowSnowball)) { + this->isHoldingSnowball = false; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + params = EN_SNOWMAN_TYPE_LARGE_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_THROW); + } else { + params = EN_SNOWMAN_TYPE_SMALL_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19948.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, + this->snowballPos.z, 0, this->actor.yawTowardsPlayer, 0, params); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19998.s") +void EnSnowman_SetupIdle(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoIdleAnim); + this->work.timer = 60; + this->actionFunc = EnSnowman_Idle; +} + +/** + * Simply makes the Eeno wait around for a bit before submerging back into the snow. + */ +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->work.timer > 0) { + this->work.timer--; + } else { + EnSnowman_SetupSubmerge(this, globalCtx); + } +} + +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gEenoEmergeAnim, -1.0f, Animation_GetLastFrame(&gEenoEmergeAnim), 0.0f, + ANIMMODE_ONCE, -3.0f); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); + this->actionFunc = EnSnowman_Submerge; +} + +/** + * Submerge beneath the snow and become a snow pile. + */ +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.scale.y, this->actor.scale.x * 0.4f, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->actor.draw = EnSnowman_DrawSnowPile; + this->collider.base.acFlags |= AC_ON; + + // Calling EnSnowman_SetupCombine while EnSnowman_Submerge is our actionFunc will result + // in the broken target scale bug described in EnSnowman_SetupCombine. + EnSnowman_SetupCombine(this, globalCtx, &this->combinePos); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } +} + +void EnSnowman_SetupMelt(EnSnowman* this) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 50); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 50; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnSnowman_Melt; +} + +/** + * Spawns smoke and shrinks the Eeno down until the timer runs out, then kills the Eeno. + */ +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f smokeVelocity; + Vec3f smokePos; + + this->work.timer--; + if ((this->work.timer >= 38) && (!(this->work.timer & 1))) { + smokeVelocity.y = (this->work.timer - 38) * (1.0f / 12.0f); + smokeVelocity.x = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.z = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.y += 0.8f; + smokePos.x = ((smokeVelocity.x >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.x; + smokePos.z = ((smokeVelocity.z >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.z; + smokePos.y = this->actor.world.pos.y + 3.0f; + EffectSsIceSmoke_Spawn(globalCtx, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); + } + + if (this->work.timer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_MarkForDeath(this->actor.parent); + Actor_MarkForDeath(this->actor.child); + Actor_MarkForDeath(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } + } + + this->actor.scale.y = this->work.timer * 0.0002f * this->eenoScale; + this->actor.scale.x = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); + this->actor.scale.z = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); +} + +void EnSnowman_SetupStun(EnSnowman* this) { + if (this->actionFunc != EnSnowman_Stun) { + this->prevActionFunc = this->actionFunc; + } + + this->actionFunc = EnSnowman_Stun; +} + +/** + * Simply makes the Eeno do absolutely nothing until the stun is over. + * Once the stun is over, this swaps the actionFunc back to what it was before the stun. + */ +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx) { + if (this->actor.colorFilterTimer == 0) { + this->actionFunc = this->prevActionFunc; + } +} + +void EnSnowman_SetupDamaged(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoDamageAnim); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 20; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 10.0f; + func_800BE504(&this->actor, &this->collider); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_DAMAGE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_DAMAGE); + } + + this->actionFunc = EnSnowman_Damaged; +} + +/** + * Plays the damage animation and spins the Eeno around. + * Once it's done spinning, it will spawn three small split-off Eenos if the Eeno is a large one. + * Otherwise, it will either submerge underground (if it has health remaining) or die. + */ +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { + s32 rotationalVelocityScale; + + SkelAnime_Update(&this->skelAnime); + rotationalVelocityScale = CLAMP_MAX(this->work.timer, 10); + this->actor.shape.rot.y += rotationalVelocityScale * 0x300; + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Math_StepToF(&this->actor.scale.y, 1.3f * 0.01f, 0.7f * 0.001f); + this->actor.scale.x = this->actor.scale.y; + this->actor.scale.z = this->actor.scale.y; + } + + if (this->work.timer > 0) { + this->work.timer--; + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SPLIT); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->drawDmgEffAlpha = 0.0f; + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.parent, &this->actor.world.pos, + this->actor.shape.rot.y + 0x10000 / 3); + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.child, &this->actor.world.pos, + this->actor.shape.rot.y - 0x10000 / 3); + EnSnowman_CreateSplitEeno(this, &this->actor.world.pos, this->actor.shape.rot.y); + + // This is a hack to reuse EnSnowman_SpawnBigSnowballFragmentEffects, since it + // draws the fragments at snowballPos. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } else if (this->actor.colChkInfo.health != 0) { + this->collider.base.acFlags |= AC_ON; + EnSnowman_SetupSubmerge(this, globalCtx); + } else { + EnSnowman_SetupDead(this); + } +} + +void EnSnowman_SetupDead(EnSnowman* this) { + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = EnSnowman_Dead; +} + +/** + * Spawns snow-colored dust and snowball fragments and kills the Eeno. + */ +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; + Vec3f velocity; + Vec3f pos; + s16 altitude; + s16 azimuth; + f32 speed; + s32 i; + + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1000, 0x3000); + azimuth = ((u32)Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(2.0f) + 4.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(6.0f) * velocity.x) + this->actor.world.pos.x; + pos.y = (Rand_ZeroFloat(3.0f) * velocity.y) + this->actor.world.pos.y; + pos.z = (Rand_ZeroFloat(6.0f) * velocity.z) + this->actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, + 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_YMAJIN_DEAD_BREAK); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * There are some cases where a split Eeno shouldn't do anything, but we don't want to mark it for death. + * This is because we want to keep it around until *all* split Eenos are killed. + * + * This function is called whenever we want to put a split Eeno into this "do nothing" state. It disables + * collision and turns off drawing for the Eeno. If all three split Eenos are killed, this function is + * responsible for marking all of them for death. + */ +void EnSnowman_SetupSplitDoNothing(EnSnowman* this) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->actor.draw = NULL; + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } + + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); + if ((this->actor.parent != NULL) && (((EnSnowman*)this->actor.parent)->actionFunc == EnSnowman_SplitDoNothing)) { + if ((this->actor.child != NULL) && (((EnSnowman*)this->actor.child)->actionFunc == EnSnowman_SplitDoNothing)) { + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.parent); + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.child); + Actor_MarkForDeath(&this->actor); + } + } + + this->actionFunc = EnSnowman_SplitDoNothing; +} + +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx) { +} + +/** + * Turns off collision on the Eeno before calling Actor_MarkForDeath on it. + */ +void EnSnowman_SetupMarkForDeath(EnSnowman* this) { + this->collider.base.acFlags &= ~(AC_ON | AC_HIT); + this->collider.base.ocFlags1 &= ~(OC1_ON | OC1_HIT); + this->actionFunc = EnSnowman_MarkForDeath; +} + +/** + * Simply calls Actor_MarkForDeath on the Eeno. + */ +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} + +/** + * Creates a small split Eeno with a certain Y-rotation and at a certain offset from basePos. + */ +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot) { + this->actor.flags |= ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.y = yRot; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->combineState = EN_SNOWMAN_COMBINE_STATE_NONE; + this->actor.colChkInfo.health = 2; + this->eenoScale = 1.0f; + this->actor.world.pos.x = (Math_SinS(yRot) * 40.0f) + basePos->x; + this->actor.world.pos.y = basePos->y; + this->actor.world.pos.z = (Math_CosS(yRot) * 40.0f) + basePos->z; + this->combineTimer = 600; + this->actor.params = EN_SNOWMAN_TYPE_SPLIT; + this->actor.flags &= ~ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->collider.base.acFlags &= ~AC_ON; + EnSnowman_SetupMoveSnowPile(this); +} + +/** + * Absorbs the smaller Eeno into the larger one. The smaller Eeno's target scale is set to + * zero so it gradually disappears, and its collision is disabled, while the larger Eeno's + * target scale increases. + */ +void EnSnowman_AbsorbEeno(EnSnowman* smallerEeno, EnSnowman* largerEeno) { + Actor_PlaySfxAtPos(&largerEeno->actor, NA_SE_EN_YMAJIN_UNITE); + largerEeno->fwork.targetScaleDuringCombine += 0.005f; + smallerEeno->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + smallerEeno->collider.base.ocFlags1 &= ~OC1_HIT; + smallerEeno->collider.base.acFlags &= ~AC_HIT; + smallerEeno->collider.base.ocFlags1 &= ~OC1_ON; + smallerEeno->collider.base.acFlags &= ~AC_ON; + smallerEeno->fwork.targetScaleDuringCombine = 0.0f; +} + +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos) { + if (this->actor.colChkInfo.health == 0) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } else { + this->actor.flags |= ACTOR_FLAG_10; + Math_Vec3f_Copy(&this->combinePos, combinePos); + this->combineState = EN_SNOWMAN_COMBINE_STATE_ACTIVE; + + if (this->actionFunc != EnSnowman_Submerge) { + this->combineTimer = 400; + + //! @bug: Skipping this based the current actionFunc results in whatever is currently in fwork + //! being treated as the target scale when this function is called from EnSnowman_Submerge. + //! Since the only other things that get put in fwork are animation frame numbers, this results + //! in an enormous target scale, potentially creating the so-called "Mega Eeno" glitch. + //! It can still fail to become a Mega Eeno if it gets absorbed before it gets a chance to call + //! EnSnowman_Combine, though. + this->fwork.targetScaleDuringCombine = 0.01f; + } + + //! @bug: If an Eeno is in the middle of submerging, its draw function will still be EnSnowman_Draw. + //! It will call EnSnowman_SetupSubmerge again, resulting in the submerge animation playing twice. + if (this->actor.draw == EnSnowman_DrawSnowPile) { + this->actor.speedXZ = 3.0f; + this->actionFunc = EnSnowman_Combine; + } else { + this->isHoldingSnowball = false; + this->actor.speedXZ = 0.0f; + + // At this point, the combineState is EN_SNOWMAN_COMBINE_STATE_ACTIVE, and the actionFunc + // will be set to EnSnowman_Submerge. When the submerging animation is complete with this + // combineState, EnSnowman_Submerge will call EnSnowman_SetupCombine, causing the broken + // target scale bug described above. + EnSnowman_SetupSubmerge(this, globalCtx); + } + } +} + +/** + * Makes the small, split-off Eenos try to combine into a large Eeno by absorbing each other. + */ +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx) { + EnSnowman* parent; + EnSnowman* child; + + SkelAnime_Update(&this->snowPileSkelAnime); + parent = (EnSnowman*)this->actor.parent; + child = (EnSnowman*)this->actor.child; + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->combinePos), 0x1000); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + if ((this->collider.base.oc == this->actor.parent) && + (parent->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.parent->scale.x) { + EnSnowman_AbsorbEeno(this, parent); + } else { + EnSnowman_AbsorbEeno(parent, this); + } + } else if ((this->collider.base.oc == this->actor.child) && + (child->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.child->scale.x) { + EnSnowman_AbsorbEeno(this, child); + } else { + EnSnowman_AbsorbEeno(child, this); + } + } + } + + if (parent->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(parent, this); + } + + if (child->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(child, this); + } + } + + if ((this->combineTimer == 0) && (parent->fwork.targetScaleDuringCombine > 0.0f) && + (child->fwork.targetScaleDuringCombine > 0.0f) && (this->fwork.targetScaleDuringCombine < 0.011f) && + (this->combineState != EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE)) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + this->fwork.targetScaleDuringCombine = 0.0f; + } + + if (Actor_XZDistanceToPoint(&this->actor, &this->combinePos) < 20.0f) { + this->actor.speedXZ = 0.0f; + } + + if (Math_StepToF(&this->actor.scale.x, this->fwork.targetScaleDuringCombine, 0.0005f)) { + if (this->fwork.targetScaleDuringCombine < 0.01f) { + EnSnowman_SetupSplitDoNothing(this); + } else if (this->fwork.targetScaleDuringCombine > 0.018f) { + Actor_SetScale(&this->actor, 0.02f); + this->actor.params = EN_SNOWMAN_TYPE_LARGE; + this->actor.flags |= ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + this->eenoScale = 2.0f; + EnSnowman_SetupMoveSnowPile(this); + } + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; +} + +void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + if ((this->actor.colChkInfo.damageEffect != EN_SNOWMAN_DMGEFF_HOOKSHOT) || + (EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE)) { + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_MELT) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_ApplyDamage(&this->actor); + EnSnowman_SetupMelt(this); + } else { + if ((this->actionFunc == EnSnowman_MoveSnowPile) || (this->actionFunc == EnSnowman_Combine)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_ELECTRIC_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if (this->isHoldingSnowball == true) { + this->isHoldingSnowball = false; + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } + + EnSnowman_SetupDamaged(this); + } else { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + EnSnowman_SetupDamaged(this); + } + } + + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_LIGHT_ORB) { + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } + } +} + +void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + f32 wallCheckRadius; + + if (this->actionFunc != EnSnowman_SplitDoNothing) { + DECR(this->combineTimer); + + EnSnowman_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if (this->actionFunc != EnSnowman_MarkForDeath) { + Actor_MoveWithGravity(&this->actor); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) && + (this->actionFunc == EnSnowman_ReadySnowball)) { + wallCheckRadius = (this->skelAnime.curFrame * (1.0f / 60.0f)) + 1.0f; + wallCheckRadius = CLAMP_MAX(wallCheckRadius, 1.3f); + wallCheckRadius *= this->collider.dim.radius; + } else { + wallCheckRadius = this->collider.dim.radius; + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, wallCheckRadius, 0.0f, 0x1D); + if ((this->actor.floorPoly != NULL) && ((this->actor.floorPoly->normal.y * SHT_MINV) < 0.7f)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + if (!this->turningOnSteepSlope) { + this->snowPileTargetRotY = Math_FAtan2F(this->actor.floorPoly->normal.z * SHT_MINV, + this->actor.floorPoly->normal.x * SHT_MINV); + this->turningOnSteepSlope = true; + } + } else { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.draw == EnSnowman_Draw) { + Actor_SetFocus(&this->actor, this->actor.scale.y * 1800.0f); + } else { + Actor_SetFocus(&this->actor, this->actor.scale.y * 720.0f); + } + + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } + } + } +} + +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + s16 scale; + s32 i; + + if (this->work.timer > 0) { + this->work.timer--; + } else { + this->collider.base.ocFlags1 |= OC1_ON; + } + + if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 0x10) || + (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || + (this->collider.base.ocFlags1 & OC1_HIT)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + scale = 10; + for (i = 0; i < 3; i++) { + EffectSsHahen_SpawnBurst(globalCtx, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, 452, 20, + sSnowballFragmentDLs[i]); + scale *= 2; + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + 500, 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SMALL_SNOWBALL_BROKEN); + } else { + // EnSnowman_SpawnBigSnowballFragmentEffects only fworks with snowballPos, so we need + // to copy the snowball actor's current position into snowballPos to make this fwork. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_REFLECTION_WOOD); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.shape.rot.x += 0xF00; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius * 0.6f, + this->collider.dim.height - this->collider.dim.yShift, 0x1F); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos array. An index of -1 indicates that the limb is + * not part of the bodyPartsPos array. + */ +static s8 sLimbIndexToBodyPartsPosIndex[] = { + -1, -1, -1, -1, -1, -1, 0, 1, -1, 2, 3, 4, +}; + +/** + * The last five elements of the bodyPartsPos array are duplicates of the body + * bottom limb, each offset by a certain certain amount. + */ +static Vec3f sBodyBottomBodyPartOffsets[] = { + { 2000.0f, 3000.0f, 0.0f }, { 2000.0f, -2000.0f, 0.0f }, { 3000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 3000.0f }, { 1000.0f, 0.0f, -3000.0f }, +}; + +void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnSnowman* this = THIS; + Gfx* gfx; + s32 i; + + if (sLimbIndexToBodyPartsPosIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsPosIndex[limbIndex] == 4) { + for (i = 0; i < 5; i++) { + Matrix_MultiplyVector3fByState(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); + } + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); + } + } + + if ((limbIndex == EENO_LIMB_RIGHT_HAND) && (this->isHoldingSnowball == true)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + if (EN_SNOWMAN_GET_TYPE(thisx) != EN_SNOWMAN_TYPE_LARGE) { + Matrix_InsertTranslation(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + } + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], sSnowballDLs[EN_SNOWMAN_GET_TYPE(&this->actor)]); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_GetStateTranslation(&this->snowballPos); + } +} + +void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnSnowman_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale * this->eenoScale, 0.0f, this->drawDmgEffAlpha, this->drawDmgEffType); +} + +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->snowPileSkelAnime.skeleton, this->snowPileSkelAnime.jointTable, + this->snowPileSkelAnime.dListCount, NULL, NULL, &this->actor); +} + +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, sSnowballDLs[EN_SNOWMAN_GET_TYPE(thisx) - EN_SNOWMAN_TYPE_SMALL_SNOWBALL]); +} diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h index ceb711202..07d7f98c3 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h @@ -2,16 +2,56 @@ #define Z_EN_SNOWMAN_H #include "global.h" +#include "objects/object_snowman/object_snowman.h" + +#define EN_SNOWMAN_GET_TYPE(thisx) ((thisx)->params) +#define EN_SNOWMAN_GET_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_SNOWMAN_TYPE_SMALL, + /* 1 */ EN_SNOWMAN_TYPE_LARGE, + /* 2 */ EN_SNOWMAN_TYPE_SPLIT, + /* 3 */ EN_SNOWMAN_TYPE_SMALL_SNOWBALL, + /* 4 */ EN_SNOWMAN_TYPE_LARGE_SNOWBALL, +} EnSnowmanType; struct EnSnowman; typedef void (*EnSnowmanActionFunc)(struct EnSnowman*, GlobalContext*); typedef struct EnSnowman { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; - /* 0x0280 */ EnSnowmanActionFunc actionFunc; - /* 0x0284 */ char unk_284[0xF4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ SkelAnime snowPileSkelAnime; + /* 0x1CC */ Vec3s jointTable[EENO_LIMB_MAX]; + /* 0x214 */ Vec3s morphTable[EENO_LIMB_MAX]; + /* 0x25C */ Vec3s snowPileJointTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x26E */ Vec3s snowPileMorphTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x280 */ EnSnowmanActionFunc actionFunc; + /* 0x284 */ EnSnowmanActionFunc prevActionFunc; + /* 0x288 */ u8 isHoldingSnowball; + /* 0x289 */ u8 combineState; + /* 0x28A */ u8 turningOnSteepSlope; + /* 0x28B */ u8 drawDmgEffType; + /* 0x28C */ union { + s16 timer; + s16 snowballsToThrowBeforeIdling; + } work; + /* 0x28E */ s16 snowPileTargetRotY; + /* 0x290 */ s16 combineTimer; + /* 0x294 */ f32 eenoScale; + /* 0x298 */ union { + f32 frameToStartHoldingSnowball; + f32 frameToThrowSnowball; + f32 targetScaleDuringCombine; + } fwork; + /* 0x29C */ f32 attackRange; + /* 0x2A0 */ f32 drawDmgEffAlpha; + /* 0x2A4 */ f32 drawDmgEffScale; + /* 0x2A8 */ Vec3f combinePos; + /* 0x2B4 */ Vec3f snowballPos; + /* 0x2C0 */ Vec3f bodyPartsPos[9]; + /* 0x32C */ ColliderCylinder collider; } EnSnowman; // size = 0x378 extern const ActorInit En_Snowman_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fe4697ca9..4967ab0a2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13112,43 +13112,43 @@ 0x80B16808:("BgHakuginSwitch_Draw",), 0x80B16B00:("EnSnowman_Init",), 0x80B16F94:("EnSnowman_Destroy",), - 0x80B16FC0:("func_80B16FC0",), - 0x80B17144:("func_80B17144",), - 0x80B173D0:("func_80B173D0",), - 0x80B1746C:("func_80B1746C",), - 0x80B177EC:("func_80B177EC",), - 0x80B178B8:("func_80B178B8",), - 0x80B179D0:("func_80B179D0",), - 0x80B17A58:("func_80B17A58",), - 0x80B17CE8:("func_80B17CE8",), - 0x80B17D78:("func_80B17D78",), - 0x80B17EB4:("func_80B17EB4",), - 0x80B17EFC:("func_80B17EFC",), - 0x80B17F4C:("func_80B17F4C",), - 0x80B17FE0:("func_80B17FE0",), - 0x80B180A4:("func_80B180A4",), - 0x80B18124:("func_80B18124",), - 0x80B18380:("func_80B18380",), - 0x80B183A4:("func_80B183A4",), - 0x80B183C4:("func_80B183C4",), - 0x80B1848C:("func_80B1848C",), - 0x80B18600:("func_80B18600",), - 0x80B1861C:("func_80B1861C",), - 0x80B18908:("func_80B18908",), - 0x80B189C4:("func_80B189C4",), - 0x80B189D4:("func_80B189D4",), - 0x80B18A04:("func_80B18A04",), - 0x80B18A28:("func_80B18A28",), - 0x80B18B30:("func_80B18B30",), - 0x80B18BB4:("func_80B18BB4",), - 0x80B18C7C:("func_80B18C7C",), - 0x80B18F50:("func_80B18F50",), + 0x80B16FC0:("EnSnowman_SpawnCircularDustEffect",), + 0x80B17144:("EnSnowman_SpawnBigSnowballFragmentEffects",), + 0x80B173D0:("EnSnowman_SetupMoveSnowPile",), + 0x80B1746C:("EnSnowman_MoveSnowPile",), + 0x80B177EC:("EnSnowman_SetupEmerge",), + 0x80B178B8:("EnSnowman_Emerge",), + 0x80B179D0:("EnSnowman_SetupReadySnowball",), + 0x80B17A58:("EnSnowman_ReadySnowball",), + 0x80B17CE8:("EnSnowman_SetupThrowSnowball",), + 0x80B17D78:("EnSnowman_ThrowSnowball",), + 0x80B17EB4:("EnSnowman_SetupIdle",), + 0x80B17EFC:("EnSnowman_Idle",), + 0x80B17F4C:("EnSnowman_SetupSubmerge",), + 0x80B17FE0:("EnSnowman_Submerge",), + 0x80B180A4:("EnSnowman_SetupMelt",), + 0x80B18124:("EnSnowman_Melt",), + 0x80B18380:("EnSnowman_SetupStun",), + 0x80B183A4:("EnSnowman_Stun",), + 0x80B183C4:("EnSnowman_SetupDamaged",), + 0x80B1848C:("EnSnowman_Damaged",), + 0x80B18600:("EnSnowman_SetupDead",), + 0x80B1861C:("EnSnowman_Dead",), + 0x80B18908:("EnSnowman_SetupSplitDoNothing",), + 0x80B189C4:("EnSnowman_SplitDoNothing",), + 0x80B189D4:("EnSnowman_SetupMarkForDeath",), + 0x80B18A04:("EnSnowman_MarkForDeath",), + 0x80B18A28:("EnSnowman_CreateSplitEeno",), + 0x80B18B30:("EnSnowman_AbsorbEeno",), + 0x80B18BB4:("EnSnowman_SetupCombine",), + 0x80B18C7C:("EnSnowman_Combine",), + 0x80B18F50:("EnSnowman_UpdateDamage",), 0x80B1918C:("EnSnowman_Update",), - 0x80B19474:("func_80B19474",), - 0x80B19718:("func_80B19718",), + 0x80B19474:("EnSnowman_UpdateSnowball",), + 0x80B19718:("EnSnowman_PostLimbDraw",), 0x80B198B0:("EnSnowman_Draw",), - 0x80B19948:("func_80B19948",), - 0x80B19998:("func_80B19998",), + 0x80B19948:("EnSnowman_DrawSnowPile",), + 0x80B19998:("EnSnowman_DrawSnowball",), 0x80B19F60:("TGSw_ActionDecider",), 0x80B1A008:("TGSw_ActionExecuteOneShot",), 0x80B1A15C:("TGSw_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 6b1a7fcb7..5827c7261 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -13908,10 +13908,8 @@ 0x80B19AAC:("D_80B19AAC","UNK_TYPE1","",0x1), 0x80B19AB8:("D_80B19AB8","UNK_TYPE1","",0x1), 0x80B19AC4:("D_80B19AC4","UNK_TYPE1","",0x1), - 0x80B19AD0:("D_80B19AD0","UNK_TYPE1","",0x1), - 0x80B19ADA:("D_80B19ADA","UNK_TYPE1","",0x1), - 0x80B19ADC:("D_80B19ADC","UNK_TYPE1","",0x1), - 0x80B19B18:("D_80B19B18","UNK_TYPE1","",0x1), + 0x80B19AD0:("D_80B19AD0","s8","[12]",0xC), + 0x80B19ADC:("D_80B19ADC","Vec3f","[5]",0x3C), 0x80B19B20:("D_80B19B20","f32","",0x4), 0x80B19B24:("D_80B19B24","f32","",0x4), 0x80B19B28:("D_80B19B28","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 1ef7e6942..1567d0b70 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1458,19 +1458,6 @@ D_06000650 = 0x06000650; D_06000828 = 0x06000828; D_06000A10 = 0x06000A10; -// ovl_En_Snowman - -D_06000404 = 0x06000404; -D_060007B4 = 0x060007B4; -D_060045A0 = 0x060045A0; -D_06004628 = 0x06004628; -D_060046D8 = 0x060046D8; -D_06004A90 = 0x06004A90; -D_06004F14 = 0x06004F14; -D_0600544C = 0x0600544C; -D_0600554C = 0x0600554C; -D_060058CC = 0x060058CC; - // ovl_En_Snowwd D_06000198 = 0x06000198; From 3374f41d1ceeb46cb1c82e5b2529dfb5ffbe563c Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Wed, 25 May 2022 18:16:04 -0600 Subject: [PATCH 02/53] En_wiz_brock OK and documented (#817) * wiz brock OK * wiz_brok OK and documented * fixing text * fixing PR comments * addressing PR * fixing comma for format --- assets/xml/objects/object_wiz.xml | 6 +- spec | 3 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 119 ++++++++++++++++-- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h | 12 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 7 -- 6 files changed, 123 insertions(+), 28 deletions(-) diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index d9c8a1589..947cab3c7 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -8,7 +8,7 @@ - + @@ -40,11 +40,11 @@ - + - + diff --git a/spec b/spec index f6b19ee8a..e62c6ef3b 100644 --- a/spec +++ b/spec @@ -2837,8 +2837,7 @@ beginseg name "ovl_En_Wiz_Brock" compress include "build/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.data.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d6ae08331..d3fffb667 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -5,17 +5,29 @@ */ #include "z_en_wiz_brock.h" +#include "objects/object_wiz/object_wiz.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizBrock*)thisx) +typedef enum { + PLATFORM_TYPE_INACTIVE, + PLATFORM_TYPE_FIRE, + PLATFORM_TYPE_ICE, + PLATFORM_TYPE_MAX, +} PlatformType; + void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); + +s16 platformCount = 0; + const ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, ACTORCAT_PROP, @@ -28,19 +40,106 @@ const ActorInit En_Wiz_Brock_InitVars = { (ActorFunc)EnWizBrock_Draw, }; -#endif +void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_060010E8; -extern UNK_TYPE D_06001690; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + this->dyna.actor.colChkInfo.health = 3; + this->unk_1A6 = 0; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->platformNum = platformCount++; + this->actionFunc = EnWizBrock_SetupUpdateStatus; + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = 0.01f; + this->alpha = 255.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Init.s") +void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490E4.s") +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + this->actionFunc = EnWizBrock_UpdateStatus; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490FC.s") +/** + * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * count up to 30 at which point the platforms are despawned. + */ +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + if (this->platformType == PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { + this->platformType = this->dyna.actor.colChkInfo.health; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Update.s") + if (this->dyna.actor.colChkInfo.health == 0) { + this->timer++; + if (this->timer > (BREG(49) + 30)) { + Math_ApproachZeroF(&this->dyna.actor.scale.y, (BREG(50) / 10.0f) + 0.3f, (BREG(51) / 10000.0f) + 0.003f); + Math_ApproachZeroF(&this->alpha, (BREG(52) / 10.0f) + 1.0f, (BREG(53) / 10.0f) + 35.0f); + Math_ApproachF(&this->dyna.actor.scale.x, (BREG(54) / 100.0f) + 0.02f, (BREG(55) / 100.0f) + 0.2f, + (BREG(56) / 1000.0f) + 0.002f); + this->dyna.actor.scale.z = this->dyna.actor.scale.x; + if (this->dyna.actor.scale.y < 0.001f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Draw.s") +void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWizBrock* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + if (this->dyna.actor.colChkInfo.health != 0) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Gfx_DrawDListOpa(globalCtx, gWizzrobePlatform); + + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); + Gfx_DrawDListXlu(globalCtx, gWizzrobePlatform); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->platformType != PLATFORM_TYPE_INACTIVE) { + OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + if (this->platformType == PLATFORM_TYPE_FIRE) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 00, 100, (s16)this->alpha); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 00, 255, (s16)this->alpha); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h index 30932c5ac..ac900777e 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h @@ -8,10 +8,14 @@ struct EnWizBrock; typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, GlobalContext*); typedef struct EnWizBrock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnWizBrockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk_15C[0x44]; + /* 0x1A0 */ EnWizBrockActionFunc actionFunc; + /* 0x1A4 */ s16 timer; // Counter for despawing blocks (Max of 37) + /* 0x1A6 */ s16 unk_1A6; // TODO: set but not used maybe used in wizzrobe? + /* 0x1A8 */ s16 platformNum; // Numeric identifier for platform + /* 0x1AA */ s16 platformType; // Determines element type for platform (ice/fire) + /* 0x1AC */ f32 alpha; } EnWizBrock; // size = 0x1B0 extern const ActorInit En_Wiz_Brock_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4967ab0a2..eac58c3e6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10469,8 +10469,8 @@ 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), - 0x80A490E4:("func_80A490E4",), - 0x80A490FC:("func_80A490FC",), + 0x80A490E4:("EnWizBrock_SetupUpdateStatus",), + 0x80A490FC:("EnWizBrock_UpdateStatus",), 0x80A492E4:("EnWizBrock_Update",), 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 1567d0b70..1d5ea0bd3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1555,13 +1555,6 @@ D_060025F0 = 0x060025F0; D_060066C0 = 0x060066C0; D_0600B320 = 0x0600B320; -// ovl_En_Wiz_Brock - -D_060010E8 = 0x060010E8; -D_06001690 = 0x06001690; -D_06005870 = 0x06005870; -D_06005C64 = 0x06005C64; - // ovl_En_Zl4 D_06013328 = 0x06013328; From 6f2531cc66824ba7e09de5983bef71542c1b7dcb Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 17:55:04 -0700 Subject: [PATCH 03/53] Door_Warp1 OK (#816) * Match doorwarp1 * pad --- spec | 4 - .../actors/ovl_Door_Warp1/z_door_warp1.c | 89 +++++++------------ 2 files changed, 33 insertions(+), 60 deletions(-) diff --git a/spec b/spec index e62c6ef3b..83cc52b26 100644 --- a/spec +++ b/spec @@ -1026,11 +1026,7 @@ beginseg name "ovl_Door_Warp1" compress include "build/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Door_Warp1/ovl_Door_Warp1_reloc.o" -#else - include "build/data/ovl_Door_Warp1/ovl_Door_Warp1.reloc.o" -#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index dd41ac015..163619876 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1019,11 +1019,9 @@ void func_808BB4C4(DoorWarp1* this, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, object_warp1_DL_0076C0); } -#ifdef NON_MATCHING -// GraphicsContext should be compiler-managed? void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx; + s32 pad; Color_RGB8 sp64[] = { { 50, 150, 0 }, { 100, 150, 200 }, @@ -1065,7 +1063,10 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_004690); - gfxCtx = globalCtx->state.gfxCtx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, @@ -1073,10 +1074,6 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); - CLOSE_DISPS(globalCtx->state.gfxCtx); - - OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); @@ -1086,16 +1083,6 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -static Color_RGB8 D_808BBB50[] = { - { 50, 150, 0 }, - { 100, 150, 200 }, - { 0, 50, 200 }, - { 120, 150, 0 }, -}; -void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") -#endif void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { DoorWarp1* this = THIS; @@ -1123,54 +1110,44 @@ void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// casting/macro on temp_s1/s0 void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { - static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; - static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; - Vec3f sp9C; - Color_RGBA8 sp98; - Color_RGBA8 sp94; + static Vec3f sVelocity = { 0.0f, 0.05f, 0.0f }; + static Vec3f sAccel = { 0.0f, 0.25f, 0.0f }; + Vec3f pos; + Color_RGBA8 primColor; + Color_RGBA8 envColor; s32 i; - s16 temp_s0; - s32 temp_s1; - s32 phi_s2; + s32 rand; + s16 scale; + s32 life; for (i = 0; i < arg2; i++) { - temp_s1 = (Rand_ZeroOne() * 0x10000); - temp_s0 = temp_s1 - 0x8000; + rand = (Rand_ZeroOne() * 0x10000); - sp9C.x = (-Math_SinS(temp_s0) * 35.0f) + this->dyna.actor.world.pos.x; - sp9C.y = this->dyna.actor.world.pos.y; - temp_s0 = (s16)(temp_s1 - 0x8000); - sp9C.z = Math_CosS(temp_s0) * 35.0f + this->dyna.actor.world.pos.z; + pos.x = (-Math_SinS(rand - 0x8000) * 35.0f) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y; + pos.z = (Math_CosS(rand - 0x8000) * 35.0f) + this->dyna.actor.world.pos.z; - D_808BBB5C.x = 0.0f; - D_808BBB68.y = 0.25f; + primColor.r = 255; + primColor.g = 255; + primColor.b = 255; + envColor.r = 200; + envColor.g = 200; + envColor.b = 255; - sp98.r = 255; - sp98.g = 255; - sp98.b = 255; - sp94.r = 200; - sp94.g = 200; - sp94.b = 255; + sAccel.y = 0.25f; + sVelocity.x = 0.0f; + sVelocity.z = 0.0f; - D_808BBB5C.z = 0.0f; + scale = (Rand_ZeroOne() * 1000.0f) + 800.0f; - temp_s1 = (s16)((Rand_ZeroOne() * 1000.0f) + 800.0f); - - phi_s2 = 27; + life = 27; if (arg2 >= 2) { - phi_s2 = 8; - D_808BBB68.y = 1.8f; - D_808BBB5C.x = -Math_SinS(temp_s0) * 5.0f; - D_808BBB5C.z = Math_CosS(temp_s0) * 5.0f; + life = 8; + sAccel.y = 1.8f; + sVelocity.x = -Math_SinS(rand - 0x8000) * 5.0f; + sVelocity.z = Math_CosS(rand - 0x8000) * 5.0f; } - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp9C, &D_808BBB5C, &D_808BBB68, &sp98, &sp94, temp_s1, phi_s2); + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); } } -#else -static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; -static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB8D4.s") -#endif From e227684d9b35c8bb05bd0f1b9912487a6a4b0021 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 26 May 2022 02:04:10 +0100 Subject: [PATCH 04/53] En_Boom (#813) * En_Boom * Match (thanks Anon) * Update src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c Co-authored-by: Derek Hensley Co-authored-by: Anghelo Carvajal Co-authored-by: Derek Hensley --- include/functions.h | 2 +- include/z64actor.h | 3 + spec | 3 +- src/code/z_en_item00.c | 4 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 4 +- .../actors/ovl_Arms_Hook/z_arms_hook.h | 3 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 9 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.h | 8 +- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 319 ++++++++++++++++-- src/overlays/actors/ovl_En_Boom/z_en_boom.h | 10 +- tools/disasm/variables.txt | 24 +- 11 files changed, 331 insertions(+), 58 deletions(-) diff --git a/include/functions.h b/include/functions.h index 622dfcffb..0f3a2e671 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2051,7 +2051,7 @@ s32 func_801242B4(Player* player); // void func_80125D4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801262C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801263FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -s32 func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); +s32 func_80126440(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* arg3, Vec3f* arg4); // void func_801265C8(void); // void func_8012669C(void); // void func_80126808(void); diff --git a/include/z64actor.h b/include/z64actor.h index ee73ae8af..c7724bcd7 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -256,6 +256,9 @@ struct EnItem00; typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct GlobalContext*); +#define ENITEM00_GET_8000(thisx) ((thisx)->params & 0x8000) +#define ENITEM00_GET_7F00(thisx) (((thisx)->params & 0x7F00) >> 8) + typedef struct EnItem00 { /* 0x000 */ Actor actor; /* 0x144 */ EnItem00ActionFunc actionFunc; diff --git a/spec b/spec index 83cc52b26..46402feea 100644 --- a/spec +++ b/spec @@ -924,8 +924,7 @@ beginseg name "ovl_En_Boom" compress include "build/src/overlays/actors/ovl_En_Boom/z_en_boom.o" - include "build/data/ovl_En_Boom/ovl_En_Boom.data.o" - include "build/data/ovl_En_Boom/ovl_En_Boom.reloc.o" + include "build/src/overlays/actors/ovl_En_Boom/ovl_En_Boom_reloc.o" endseg beginseg diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index b8fa0f4f1..3bec8471b 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -68,9 +68,9 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { f32 shadowOffset = 980.0f; f32 shadowScale = 6.0f; s32 getItemId = GI_NONE; - s32 sp30 = (this->actor.params & 0x8000) ? 1 : 0; + s32 sp30 = ENITEM00_GET_8000(&this->actor) ? 1 : 0; - this->collectibleFlag = (this->actor.params & 0x7F00) >> 8; + this->collectibleFlag = ENITEM00_GET_7F00(&this->actor); thisx->params &= 0xFF; // Has to be thisx to match diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 009405238..b0a61382c 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -312,13 +312,13 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); Matrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); Matrix_MultiplyVector3fByState(&D_808C1C34, &sp50); - this->unk1C4 = 0; + this->unk1C4.active = false; } else { Matrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); Matrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); Matrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); } - func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50); + func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50); func_8012C28C(globalCtx->state.gfxCtx); func_80122868(globalCtx, player); diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h index ecccf5ff0..527d37b61 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -10,8 +10,7 @@ typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*); typedef struct ArmsHook { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ s32 unk1C4; - /* 0x1C8 */ char unk1C8[0x18]; + /* 0x1C4 */ WeaponInfo unk1C4; /* 0x1E0 */ Vec3f unk1E0; /* 0x1EC */ Vec3f unk1EC; /* 0x1F8 */ Actor* grabbed; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index f1dc5c6f6..45cc5bdae 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -581,7 +581,7 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); if (func_8088ACE0 == this->actionFunc) { - if (this->unk_244 == 0) { + if (!this->unk_244.active) { sp4C = arg2->unk_00; } else { sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; @@ -591,9 +591,10 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar if (this->actor.params < ENARROW_8) { sp30 = this->actor.params < ENARROW_6; if (this->unk_264 == 0) { - sp30 &= func_80126440(globalCtx, &this->collider.base, &this->unk_244, &sp40, &sp34); - } else if (sp30 && (sp40.x == this->unk_248) && (sp40.y == this->unk_24C) && (sp40.z == this->unk_250) && - (sp34.x == this->unk_254) && (sp34.y == this->unk_258) && (sp34.z == this->unk_25C)) { + sp30 &= func_80126440(globalCtx, &this->collider, &this->unk_244, &sp40, &sp34); + } else if (sp30 && (sp40.x == this->unk_244.tip.x) && (sp40.y == this->unk_244.tip.y) && + (sp40.z == this->unk_244.tip.z) && (sp34.x == this->unk_244.base.x) && + (sp34.y == this->unk_244.base.y) && (sp34.z == this->unk_244.base.z)) { sp30 = false; } if (sp30) { diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index f318cf152..654e8bea6 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -43,13 +43,7 @@ typedef struct EnArrow { /* 0x228 */ Vec3f unk_228; /* 0x234 */ Vec3f unk_234; /* 0x240 */ s32 unk_240; - /* 0x244 */ s32 unk_244; - /* 0x248 */ f32 unk_248; - /* 0x24C */ f32 unk_24C; - /* 0x250 */ f32 unk_250; - /* 0x254 */ f32 unk_254; - /* 0x258 */ f32 unk_258; - /* 0x25C */ f32 unk_25C; + /* 0x244 */ WeaponInfo unk_244; /* 0x260 */ u8 unk_260; // timer in OoT /* 0x261 */ u8 unk_261; // hitFlags in OoT /* 0x262 */ u8 unk_262; diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 930b1b597..15347d0ea 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -5,6 +5,7 @@ */ #include "z_en_boom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,11 +16,9 @@ void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); void func_808A2918(EnBoom* this, GlobalContext* globalCtx); -void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); - -#if 0 const ActorInit En_Boom_InitVars = { ACTOR_EN_BOOM, ACTORCAT_ITEMACTION, @@ -32,34 +31,316 @@ const ActorInit En_Boom_InitVars = { (ActorFunc)EnBoom_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_808A3010 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK2, { 0x00000010, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000010, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808A3060[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(targetMode, 5, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderQuadInit D_808A3010; -extern InitChainEntry D_808A3060[]; +void func_808A24DC(EnBoom* this, GlobalContext* globalCtx) { + WaterBox* sp54; + f32 sp50 = this->actor.world.pos.y; + u16 sp4E = this->actor.bgCheckFlags & 0x20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_SetupAction.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + Vec3f sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/func_808A24DC.s") + this->actor.bgCheckFlags |= 0x20; + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y - 20.0f; + sp40.z = this->actor.world.pos.z; + EffectSsBubble_Spawn(globalCtx, &sp40, 20.0f, 10.0f, 20.0f, 0.13f); + } else { + this->actor.bgCheckFlags &= ~0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Init.s") + if ((this->actor.bgCheckFlags & 0x40) && ((this->actor.bgCheckFlags & 0x20) != sp4E)) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Destroy.s") + Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &sp34); + if (sp34.y != 0.0f) { + f32 temp_fv0 = sqrtf(SQ(sp34.x) + SQ(sp34.z)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/func_808A2918.s") + if (temp_fv0 != 0.0f) { + temp_fv0 = (((sp50 - this->actor.prevPos.y) / sp34.y) * temp_fv0) / temp_fv0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Update.s") + sp34.x = this->actor.prevPos.x + (sp34.x * temp_fv0); + sp34.y = sp50; + sp34.z = this->actor.prevPos.z + (sp34.z * temp_fv0); + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 300); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Draw.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 8); + } + + this->actor.bgCheckFlags |= 0x40; +} + +void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx) { + static u8 D_808A3068[4] = { 255, 255, 100, 255 }; + static u8 D_808A306C[4] = { 255, 255, 100, 64 }; + static u8 D_808A3070[4] = { 255, 255, 100, 0 }; + static u8 D_808A3074[4] = { 255, 255, 100, 0 }; + s32 pad; + EnBoom* this = THIS; + EffectBlureInit1 sp30; + s32 i; + + this->actor.room = -1; + Actor_ProcessInitChain(&this->actor, sInitChain); + + for (i = 0; i < 4; i++) { + sp30.p1StartColor[i] = D_808A3068[i]; + sp30.p2StartColor[i] = D_808A306C[i]; + sp30.p1EndColor[i] = D_808A3070[i]; + sp30.p2EndColor[i] = D_808A3074[i]; + } + + sp30.elemDuration = 8; + sp30.unkFlag = 0; + sp30.calcMode = 0; + + Effect_Add(globalCtx, &this->effectIndex, 1, 0, 0, &sp30); + + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + EnBoom_SetupAction(this, func_808A2918); +} + +void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Actor* temp; + + if (player != NULL) { + Effect_Destroy(globalCtx, this->effectIndex); + Collider_DestroyQuad(globalCtx, &this->collider); + + temp = this->actor.child; + if (temp != NULL) { + temp->parent = NULL; + player->boomerangActor = temp; + } else { + temp = this->actor.parent; + if (temp != NULL) { + temp->child = NULL; + } else { + player->boomerangActor = NULL; + player->stateFlags1 &= ~0x2000000; + } + } + player->stateFlags3 |= 0x800000; + } +} + +void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { + Actor* sp7C; + Player* player = GET_PLAYER(globalCtx); + s32 sp74; + s16 sp72; + s16 sp70; + s16 sp6E; + s16 sp6C; + Actor* temp; + f32 sp64; + f32 distXYZ; + + sp7C = this->player; + + if (sp7C != NULL) { + sp72 = Actor_YawToPoint(&this->actor, &sp7C->focus.pos); + sp70 = this->actor.world.rot.y - sp72; + sp6E = Actor_PitchToPoint(&this->actor, &sp7C->focus.pos); + sp6C = this->actor.world.rot.x - sp6E; + + sp64 = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp7C->focus.pos)) * 0.005f; + if (sp64 < 0.12f) { + sp64 = 0.12f; + } + + if ((&player->actor != sp7C) && ((sp7C->update == NULL) || ((this->unk_1CF < 0) && (ABS_ALT(sp70) > 0x4000)))) { + this->player = NULL; + } else { + if (this->unk_1CE != 0) { + this->unk_1CE--; + this->actor.world.rot.y += (this->actor.params == 0) ? 0x190 : -0x190; + } else { + if (this->unk_1CF > 0) { + this->unk_1CF--; + } else { + this->unk_1CF = -1; + } + + Math_ScaledStepToS(&this->actor.world.rot.y, sp72, + (this->unk_1CF > 0) ? 1000 : (s16)(((sp70 < 0) ? -sp70 : sp70) * sp64)); + } + + Math_ScaledStepToS(&this->actor.world.rot.x, sp6E, ABS_ALT(sp6C) * sp64); + } + } + + Actor_SetSpeeds(&this->actor, 12.0f); + Actor_MoveWithGravity(&this->actor); + func_808A24DC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_IT_BOOMERANG_FLY - SFX_FLAG); + + if ((this->collider.base.atFlags & AT_HIT) && (((this->collider.base.at->id == ACTOR_EN_ITEM00) && + (this->collider.base.at->params != ITEM00_HEART_CONTAINER) && + (this->collider.base.at->params != ITEM00_HEART_PIECE)) || + (this->collider.base.at->id == ACTOR_EN_SI))) { + this->unk_1C8 = this->collider.base.at; + if (this->collider.base.at->id == ACTOR_EN_SI) { + this->collider.base.at->flags |= 0x2000; + } + } + + if (DECR(this->unk_1CC) != 0) { + s32 sp5C; + Vec3f sp50; + s32 pad; + + sp74 = BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, &sp50, + &this->actor.wallPoly, true, true, true, true, &sp5C); + if (sp74 != 0) { + if (func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, sp5C, &sp50)) { + sp74 = 0; + } else { + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp50); + } + } + + if (sp74 != 0) { + this->actor.world.rot.x = -this->actor.world.rot.x; + this->actor.world.rot.y += 0x8000; + this->player = &player->actor; + this->unk_1CC = 0; + } + } + + if (this->unk_1CC <= 16) { + distXYZ = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos); + + if (&player->actor != this->player) { + if (this->player == 0) { + this->unk_1CE = 8; + } + this->player = &player->actor; + } + + if (distXYZ < 40.0f) { + sp7C = this->unk_1C8; + if (sp7C != NULL) { + Math_Vec3f_Copy(&sp7C->world.pos, &player->actor.world.pos); + if (sp7C->id == ACTOR_EN_ITEM00) { + sp7C->gravity = -0.9f; + sp7C->bgCheckFlags &= ~3; + } else { + sp7C->flags &= -0x2001; + } + } + Actor_MarkForDeath(&this->actor); + } + } + + sp7C = this->unk_1C8; + if (sp7C != NULL) { + if (sp7C->update == NULL) { + this->unk_1C8 = NULL; + } else { + Math_Vec3f_Copy(&sp7C->world.pos, &this->actor.world.pos); + } + } +} + +void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + + if (!(player->stateFlags1 & 0x20000000)) { + this->actionFunc(this, globalCtx); + + if (((actor = this->actor.child) != NULL) || ((actor = this->actor.parent) != NULL)) { + this->actor.focus.pos.x = (this->actor.world.pos.x + actor->world.pos.x) * 0.5f; + this->actor.focus.pos.y = (this->actor.world.pos.y + actor->world.pos.y) * 0.5f; + this->actor.focus.pos.z = (this->actor.world.pos.z + actor->world.pos.z) * 0.5f; + } else { + Actor_SetFocus(&this->actor, 0.0f); + } + + if (this->actor.params != 0) { + this->unk_1CD--; + } else { + this->unk_1CD++; + } + } +} + +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; +} EnBoomStruct; + +EnBoomStruct D_808A3078[] = { + { gameplay_keep_DL_06FE20, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, + { gameplay_keep_DL_06FF68, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, +}; + +void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + EnBoomStruct* sp58 = &D_808A3078[this->actor.params]; + Vec3f sp4C; + Vec3f sp40; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + Matrix_InsertZRotation_s((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&sp58->unk_04, &sp4C); + Matrix_MultiplyVector3fByState(&sp58->unk_10, &sp40); + + if (func_80126440(globalCtx, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); + } + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_RotateY(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp58->unk_00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.h b/src/overlays/actors/ovl_En_Boom/z_en_boom.h index 906e592a5..0aa09f15b 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -9,7 +9,15 @@ typedef void (*EnBoomActionFunc)(struct EnBoom*, GlobalContext*); typedef struct EnBoom { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 0x0144 */ ColliderQuad collider; + /* 0x01C4 */ Actor* player; + /* 0x01C8 */ Actor* unk_1C8; + /* 0x01CC */ u8 unk_1CC; + /* 0x01CD */ u8 unk_1CD; + /* 0x01CE */ u8 unk_1CE; + /* 0x01CF */ s8 unk_1CF; + /* 0x01D0 */ s32 effectIndex; + /* 0x01D4 */ WeaponInfo weaponInfo; /* 0x01F0 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x1F4 diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 5827c7261..fd8ee4d45 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -6351,24 +6351,12 @@ 0x808A2300:("D_808A2300","f32","",0x4), 0x808A2304:("D_808A2304","f32","",0x4), 0x808A2FF0:("En_Boom_InitVars","UNK_TYPE1","",0x1), - 0x808A3010:("D_808A3010","UNK_TYPE1","",0x1), - 0x808A3060:("D_808A3060","UNK_TYPE1","",0x1), - 0x808A3068:("D_808A3068","UNK_TYPE1","",0x1), - 0x808A3069:("D_808A3069","UNK_TYPE1","",0x1), - 0x808A306A:("D_808A306A","UNK_TYPE1","",0x1), - 0x808A306B:("D_808A306B","UNK_TYPE1","",0x1), - 0x808A306C:("D_808A306C","UNK_TYPE1","",0x1), - 0x808A306D:("D_808A306D","UNK_TYPE1","",0x1), - 0x808A306E:("D_808A306E","UNK_TYPE1","",0x1), - 0x808A306F:("D_808A306F","UNK_TYPE1","",0x1), - 0x808A3070:("D_808A3070","UNK_TYPE1","",0x1), - 0x808A3071:("D_808A3071","UNK_TYPE1","",0x1), - 0x808A3072:("D_808A3072","UNK_TYPE1","",0x1), - 0x808A3073:("D_808A3073","UNK_TYPE1","",0x1), - 0x808A3074:("D_808A3074","UNK_TYPE1","",0x1), - 0x808A3075:("D_808A3075","UNK_TYPE1","",0x1), - 0x808A3076:("D_808A3076","UNK_TYPE1","",0x1), - 0x808A3077:("D_808A3077","UNK_TYPE1","",0x1), + 0x808A3010:("sQuadInit","UNK_TYPE1","",0x1), + 0x808A3060:("sInitChain","UNK_TYPE1","",0x1), + 0x808A3068:("D_808A3068","Color_RGBA8","",0x4), + 0x808A306C:("D_808A306C","Color_RGBA8","",0x4), + 0x808A3070:("D_808A3070","Color_RGBA8","",0x4), + 0x808A3074:("D_808A3074","Color_RGBA8","",0x4), 0x808A3078:("D_808A3078","UNK_TYPE4","",0x4), 0x808A30B0:("D_808A30B0","f32","",0x4), 0x808A30B4:("D_808A30B4","f32","",0x4), From 0fb3fb8634530301452e9fcb84f163e0aeeae3c1 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 26 May 2022 02:09:57 +0100 Subject: [PATCH 05/53] Bg_Ikana_Bombwall (#812) --- spec | 5 +- .../z_bg_ikana_bombwall.c | 343 ++++++++++++++++-- .../z_bg_ikana_bombwall.h | 9 +- undefined_syms.txt | 2 - 4 files changed, 321 insertions(+), 38 deletions(-) diff --git a/spec b/spec index 46402feea..c50c3cdd0 100644 --- a/spec +++ b/spec @@ -4627,8 +4627,11 @@ beginseg name "ovl_Bg_Ikana_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.o" - include "build/data/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall_reloc.o" +#else include "build/data/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index f183a7164..a5176bc64 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_bombwall.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10000000) @@ -15,7 +16,15 @@ void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BD4F18(BgIkanaBombwall* this); +void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4F88(BgIkanaBombwall* this); +void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4FF8(BgIkanaBombwall* this); +void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD5118(BgIkanaBombwall* this); +void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Bombwall_InitVars = { ACTOR_BG_IKANA_BOMBWALL, ACTORCAT_BG, @@ -28,65 +37,335 @@ const ActorInit Bg_Ikana_Bombwall_InitVars = { (ActorFunc)BgIkanaBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD5270 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD529C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 50, 20, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BD52D0[] = { +s16 D_80BD52C8[] = { + 32, + 21, + 15, + 8, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; +Gfx* D_80BD52E0[] = { + object_ikana_obj_DL_000378, + object_ikana_obj_DL_000048, +}; + +#ifdef NON_MATCHING +void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_fs0; + f32 phi_fs1; + s16 phi_s0; + s16 temp; + s16 phi_t0; + + Matrix_StatePush(); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + temp_fs0 = 0.0f; + phi_fs1 = 0.0f; + + for (i = 0; i < 30; i++) { + temp_fs0 += 60.0f + (Rand_ZeroOne() * 20.0f); + if (temp_fs0 > 75.0f) { + temp_fs0 -= 150.0f; + } + spC8.x = temp_fs0; + + phi_fs1 += 5; + spC8.y = phi_fs1; + + spC8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spBC.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (temp_fs0 * 0.053333335f); + spBC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spBC.z = (Rand_ZeroOne() * 4.0f) - 2.0f; + + Matrix_MultiplyVector3fByState(&spC8, &spE0); + Matrix_MultiplyVector3fByState(&spBC, &spD4); + + spE0.x += this->dyna.actor.world.pos.x; + spE0.y += this->dyna.actor.world.pos.y; + spE0.z += this->dyna.actor.world.pos.z; + + if ((i & 3) == 0) { + phi_s0 = 32; + func_800BBFB0(globalCtx, &spE0, 50.0f, 2, 100, 120, 1); + } else { + phi_s0 = 64; + } + + if (i & 1) { + phi_s0 |= 1; + phi_t0 = 1; + } else { + phi_t0 = 0; + } + + if (D_80BD52C8[i & 3] >= 16) { + temp = -550; + } else { + temp = -450; + } + + EffectSsKakera_Spawn(globalCtx, &spE0, &spD4, &spE0, temp, phi_s0, 30, 0, 0, D_80BD52C8[i & 3], phi_t0, 0, 50, + -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); + } + + Matrix_StatePop(); +} +#else +void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") #endif -extern ColliderCylinderInit D_80BD5270; -extern ColliderCylinderInit D_80BD529C; -extern InitChainEntry D_80BD52D0[]; +void func_80BD4A14(BgIkanaBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spD8; + Vec3f spCC; + f32 temp_fs0; + f32 temp_fs1; + f32 temp_fs3; + s16 temp_v1; + s16 phi_s2; + s32 phi_t0; + s16 phi_v0; + s32 phi_v1; -extern UNK_TYPE D_06000288; -extern UNK_TYPE D_06000488; + temp_fs3 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") + for (i = 0, phi_s2 = 0; i < 28; i++, phi_s2 += 0x924) { + temp_fs3 += 20.0f + (Rand_ZeroOne() * 10.0f); + if (temp_fs3 > 60.0f) { + temp_fs3 -= 60.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4A14.s") + temp_fs0 = Math_SinS(phi_s2); + temp_fs1 = Math_CosS(phi_s2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Init.s") + spD8.x = (temp_fs0 * temp_fs3) + this->dyna.actor.world.pos.x; + spD8.y = this->dyna.actor.world.pos.y; + spD8.z = (temp_fs1 * temp_fs3) + this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Destroy.s") + spCC.x = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs0) + ((temp_fs0 * temp_fs3) * 0.033333335f); + spCC.y = (Rand_ZeroOne() * 18.0f) + 4.0f; + spCC.z = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs1) + ((temp_fs1 * temp_fs3) * 0.033333335f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4E44.s") + temp_v1 = (Rand_Next() & 3) + (i >> 1) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4EAC.s") + if ((i & 3) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F18.s") + if (temp_v1 >= 15) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F2C.s") + EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_t0, phi_v0, 30, 0, 0, temp_v1, phi_v1, 0, 50, -1, + OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F88.s") + if ((i & 3) == 0) { + spD8.y += 30.0f; + func_800BBFB0(globalCtx, &spD8, 50.0f, 2, 70, 110, 1); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F9C.s") +void BgIkanaBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBombwall* this = THIS; + s32 sp2C = BGIKANABOMBWALL_GET_100(&this->dyna.actor); + s32 sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4FF8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD503C.s") + if (Flags_GetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD5118.s") + if (sp2C == 0) { + sp28 = &object_ikana_obj_Colheader_000488; + sp24 = &sCylinderInit1; + } else { + sp28 = &object_ikana_obj_Colheader_000128; + sp24 = &sCylinderInit2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD5134.s") + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp28); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, sp24); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Update.s") + if (sp2C == 0) { + func_80BD4F18(this); + } else { + func_80BD4F88(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Draw.s") +void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80BD4E44(BgIkanaBombwall* this) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < SQ(75.0f))) { + return true; + } + } + return false; +} + +s32 func_80BD4EAC(BgIkanaBombwall* this) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < SQ(80.0f))) { + return true; + } + } + return false; +} + +void func_80BD4F18(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F2C; +} + +void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (func_80BD4E44(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80BD4F88(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F9C; +} + +void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (func_80BD4EAC(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80BD4FF8(BgIkanaBombwall* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80BD503C; +} + +void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_80BD4720(this, globalCtx); + } else { + func_80BD4A14(this, globalCtx); + } + this->dyna.actor.draw = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + func_80BD5118(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80BD5118(BgIkanaBombwall* this) { + this->unk_1AC = 30; + this->actionFunc = func_80BD5134; +} + +void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (this->dyna.actor.cutscene >= 0) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80BD52E0[BGIKANABOMBWALL_GET_100(thisx)]); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h index 42b0596d8..37921ba53 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h @@ -7,11 +7,14 @@ struct BgIkanaBombwall; typedef void (*BgIkanaBombwallActionFunc)(struct BgIkanaBombwall*, GlobalContext*); +#define BGIKANABOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGIKANABOMBWALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgIkanaBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ BgIkanaBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x01AC */ s8 unk_1AC; } BgIkanaBombwall; // size = 0x1B0 extern const ActorInit Bg_Ikana_Bombwall_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 1d5ea0bd3..91ead11f3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -617,9 +617,7 @@ D_06000C90 = 0x06000C90; // ovl_Bg_Ikana_Bombwall -D_06000128 = 0x06000128; D_06000288 = 0x06000288; -D_06000488 = 0x06000488; // ovl_Bg_Ikana_Dharma From 9fcf1bd55b2732b494a22e0850988f86fc0db95a Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 26 May 2022 11:33:31 +1000 Subject: [PATCH 06/53] Match 9 Various NON_MATCHING functions (#811) * Match func_80A3C8D8 (obj_vspinyroll OK) * `EnHorse_Update` OK * Match EnHorse_Init & EnHorse_FleePlayer (en_horse OK) * Fake match func_80BF43FC (en_rg OK) * func_80A66930 + func_80A671E0 (obj_driftice OK) * Match func_80940588 (goroiwa OK) * Match func_80ABBFC0 (@anon) Co-authored-by: hensldm * PR Suggestions * PR suggestions --- spec | 24 -- .../z_bg_hakugin_bombwall.c | 13 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 14 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 284 ++++++++---------- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 2 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 14 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 2 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 2 +- .../actors/ovl_Obj_Driftice/z_obj_driftice.c | 24 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 8 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 3 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 35 +-- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.h | 10 +- 16 files changed, 175 insertions(+), 266 deletions(-) diff --git a/spec b/spec index c50c3cdd0..1a733af09 100644 --- a/spec +++ b/spec @@ -821,11 +821,7 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" -#else - include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" -#endif endseg beginseg @@ -1501,11 +1497,7 @@ beginseg name "ovl_En_Goroiwa" compress include "build/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Goroiwa/ovl_En_Goroiwa_reloc.o" -#else - include "build/data/ovl_En_Goroiwa/ovl_En_Goroiwa.reloc.o" -#endif endseg beginseg @@ -2765,11 +2757,7 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" -#else - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" -#endif endseg beginseg @@ -3001,11 +2989,7 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" -#else - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" -#endif endseg beginseg @@ -3287,11 +3271,7 @@ beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" -#else - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" -#endif endseg beginseg @@ -4878,11 +4858,7 @@ beginseg name "ovl_En_Rg" compress include "build/src/overlays/actors/ovl_En_Rg/z_en_rg.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Rg/ovl_En_Rg_reloc.o" -#else - include "build/data/ovl_En_Rg/ovl_En_Rg.reloc.o" -#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 1f0030d28..bf3e44154 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -121,10 +121,8 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#ifdef NON_MATCHING -// Breaks relocs void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { - s32 temp; + f32 temp; Vec3f spF0; Vec3f spE4; Vec3f spD8; @@ -138,13 +136,13 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < 6; i++) { - temp = i + 1; + temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); - spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + (temp * 26.666666f); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp; spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; - spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * 0.07777778f); + spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * (7.0f / 90.0f)); spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; spCC.z = spD8.z * 0.3f; @@ -176,9 +174,6 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") -#endif void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { s32 pad; diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 311d07a75..db1a954d0 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -512,7 +512,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { u16 pad; u8 spD3; u8 spD2; - s32 maxColor = 255; // Possible FAKE MATCH + s32 maxColor = 255; //! FAKE: f32 sp68; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index a69730bed..04d4100b1 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -603,7 +603,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index dd8d95c23..7f6db7264 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -739,24 +739,22 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// Stack void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { Gfx* phi_s7; Vec3f sp100; Vec3f spF4; Vec3f spE8; f32 temp_f20; - s32 phi_fp; + f32 spB0; s32 j; s32 i; s32 phi_s0; s32 spD0; s16 spCE; - s16 spC8; - f32 spB0; - f32 spAC; s16 spA8; + s16 phi_fp; + s16 spC8; + f32 spAC; spD0 = (s32)(arg5 * 35.0f) + 6; temp_f20 = (arg5 + 0.1f) * 0.5f; @@ -815,10 +813,6 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } } } -#else -void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940588.s") -#endif void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { s32 i; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index d71ac41af..54e388bc2 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -673,16 +673,16 @@ void func_8087C9F8(EnHorse* this) { void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { } -#ifdef NON_MATCHING void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnHorse* this = THIS; + Skin* skin = &this->skin; Actor_ProcessInitChain(&this->actor, sInitChain); EnHorse_ClearDustFlags(&this->dustFlags); D_801BDAA4 = 0; Skin_Setup(&this->skin); - this->riderPos = this->actor.world.pos; + this->riderPos = thisx->world.pos; this->unk_52C = 0; this->noInputTimer = 0; this->riderPos.y += 70.0f; @@ -702,19 +702,19 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } this->unk_1EC |= 1; - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } else if (ENHORSE_GET_4000(&this->actor)) { this->type = HORSE_2; this->unk_528 = 64.8f; this->boostSpeed = 15; if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { - this->actor.objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); + thisx->objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); Actor_SetObjectDependency(globalCtx, &this->actor); Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); this->unk_1EC |= 0x200; } else { - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } } else if (ENHORSE_GET_2000(&this->actor)) { this->type = HORSE_3; @@ -724,46 +724,46 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } this->unk_1EC |= 1; - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } else { this->type = HORSE_EPONA; this->boostSpeed = 15; Actor_MarkForDeath(&this->actor); } - this->actor.params &= ~0xE000; - if (this->actor.params == 0x1FFF) { - this->actor.params = ENHORSE_1; + thisx->params &= ~0xE000; + if (thisx->params == 0x1FFF) { + thisx->params = ENHORSE_1; } - if (this->actor.params == ENHORSE_3) { + if (thisx->params == ENHORSE_3) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; - } else if (this->actor.params == ENHORSE_8) { + } else if (thisx->params == ENHORSE_8) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; if (CHECK_QUEST_ITEM(14)) { this->stateFlags &= ~ENHORSE_CANT_JUMP; this->stateFlags |= ENHORSE_FLAG_26; } - } else if (this->actor.params == ENHORSE_13) { + } else if (thisx->params == ENHORSE_13) { this->stateFlags = ENHORSE_FLAG_29; this->unk_1EC |= 0x10; - } else if (this->actor.params == ENHORSE_4) { + } else if (thisx->params == ENHORSE_4) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_5) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_5) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_15) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_15) { this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; - } else if (this->actor.params == ENHORSE_17) { + } else if (thisx->params == ENHORSE_17) { this->stateFlags = 0; this->unk_1EC |= 8; - } else if (this->actor.params == ENHORSE_18) { + } else if (thisx->params == ENHORSE_18) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_1) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_1) { this->stateFlags = ENHORSE_FLAG_7; - } else if ((this->actor.params == ENHORSE_19) || (this->actor.params == ENHORSE_20)) { + } else if ((thisx->params == ENHORSE_19) || (thisx->params == ENHORSE_20)) { this->stateFlags = ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; } else { this->stateFlags = 0; @@ -774,10 +774,10 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->stateFlags |= ENHORSE_FLAG_25; } - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + thisx->gravity = -3.5f; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawHorse, 20.0f); this->action = ENHORSE_ACT_IDLE; - this->actor.speedXZ = 0.0f; + thisx->speedXZ = 0.0f; if (this->type == HORSE_2) { sJntSphInit.elements[0].dim.limb = 13; @@ -800,7 +800,7 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->colliderCylinder1.dim.radius = 50; } - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); if (this->type == HORSE_2) { Actor_SetScale(&this->actor, 0.00648f); @@ -810,11 +810,11 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); } - this->actor.focus.pos = this->actor.world.pos; + thisx->focus.pos = thisx->world.pos; this->playerControlled = false; - this->actor.focus.pos.y += 70.0f; + thisx->focus.pos.y += 70.0f; - if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (this->actor.update == EnHorse_Update)) { + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (thisx->update == EnHorse_Update)) { Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); } @@ -828,71 +828,69 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { EnHorse_ResetRace(this, globalCtx); EnHorse_ResetHorsebackArchery(this, globalCtx); - if (this->actor.params == ENHORSE_2) { + if (thisx->params == ENHORSE_2) { this->unk_53C = 0; EnHorse_InitInactive(this); - } else if (this->actor.params == ENHORSE_3) { + } else if (thisx->params == ENHORSE_3) { EnHorse_InitIngoHorse(this); - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->unk_398 = 14.34f; - } else if (this->actor.params == ENHORSE_4) { + } else if (thisx->params == ENHORSE_4) { func_80881634(this); this->unk_398 = 14.34f; - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->unk_1EC |= 0x100; - } else if (this->actor.params == ENHORSE_5) { + } else if (thisx->params == ENHORSE_5) { func_80881634(this); this->unk_398 = 14.525f; - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 2); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 2); this->unk_1EC |= 0x100; - } else if (this->actor.params == ENHORSE_9) { + } else if (thisx->params == ENHORSE_9) { EnHorse_InitCutscene(this, globalCtx); - } else if (this->actor.params == ENHORSE_10) { + } else if (thisx->params == ENHORSE_10) { EnHorse_InitHorsebackArchery(this); func_80112AFC(globalCtx); - } else if (this->actor.params == ENHORSE_14) { + } else if (thisx->params == ENHORSE_14) { func_808846F0(this, globalCtx); if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } - } else if (this->actor.params == ENHORSE_16) { + } else if (thisx->params == ENHORSE_16) { func_8087C9F8(this); - } else if (this->actor.params == ENHORSE_15) { + } else if (thisx->params == ENHORSE_15) { EnHorse_ResetIdleAnimation(this); - } else if (this->actor.params == ENHORSE_18) { + } else if (thisx->params == ENHORSE_18) { func_80884994(this); - } else if (this->actor.params == ENHORSE_19) { + } else if (thisx->params == ENHORSE_19) { EnIn* in; func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->rider = in; in->unk4AC |= (0x20 | 0x4); - } else if (this->actor.params == ENHORSE_20) { + } else if (thisx->params == ENHORSE_20) { EnIn* in; func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->rider = in; in->unk4AC |= (0x20 | 0x8 | 0x4); } else { EnHorse_StartIdleRidable(this); } - this->actor.shape.rot.z = 0; - this->actor.world.rot.z = this->actor.shape.rot.z; - this->actor.home.rot.z = this->actor.shape.rot.z; - this->unk_3EC = this->actor.world.rot.y; + thisx->shape.rot.z = 0; + thisx->world.rot.z = thisx->shape.rot.z; + thisx->home.rot.z = thisx->shape.rot.z; + this->unk_3EC = thisx->world.rot.y; this->unk_538 = 0; if (this->unk_1EC & 0x100) { @@ -906,9 +904,6 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") -#endif void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { EnHorse* this = THIS; @@ -2952,13 +2947,12 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distToHome; f32 playerDistToHome; f32 distToPlayer; - s32 nextAnim; + s32 nextAnim = this->animationIdx; s32 animFinished; s16 yaw; @@ -3098,10 +3092,6 @@ void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { -3.0f); } } -#else -void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_FleePlayer.s") -#endif void func_80883B70(EnHorse* this, CsCmdActorAction* action) { this->actor.world.pos.x = action->startPos.x; @@ -4156,37 +4146,36 @@ s32 EnHorse_RandInt(f32 arg0) { return Rand_ZeroOne() * arg0; } -#ifdef NON_MATCHING -void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { - static EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, - }; - s32 pad; +static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, +}; +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; EnHorse* this = THIS; Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; @@ -4200,7 +4189,7 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); } - this->lastYaw = this->actor.shape.rot.y; + this->lastYaw = thisx->shape.rot.y; EnHorse_UpdateStick(this, globalCtx); EnHorse_UpdatePlayerDir(this, globalCtx); @@ -4222,13 +4211,13 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { sActionFuncs[this->action](this, globalCtx); this->stateFlags &= ~ENHORSE_OBSTACLE; - this->unk_3EC = this->actor.world.rot.y; + this->unk_3EC = thisx->world.rot.y; if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { this->skin.skelAnime.jointTable[0].y += 0x154; } this->curFrame = this->skin.skelAnime.curFrame; - this->lastPos = this->actor.world.pos; + this->lastPos = thisx->world.pos; if (!(this->stateFlags & ENHORSE_INACTIVE)) { if ((this->action == ENHORSE_ACT_STOPPING) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || @@ -4241,7 +4230,7 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { } if (ActorCutscene_GetCurrentIndex() != -1) { - this->actor.speedXZ = 0.0f; + thisx->speedXZ = 0.0f; } if (this->action != ENHORSE_ACT_25) { @@ -4251,11 +4240,11 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->rider != NULL) { if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || (this->action == ENHORSE_ACT_25)) { - this->rider->actor.world.pos.x = this->actor.world.pos.x; - this->rider->actor.world.pos.y = this->actor.world.pos.y + 10.0f; - this->rider->actor.world.pos.z = this->actor.world.pos.z; - this->rider->actor.shape.rot.x = this->actor.shape.rot.x; - this->rider->actor.shape.rot.y = this->actor.shape.rot.y; + this->rider->actor.world.pos.x = thisx->world.pos.x; + this->rider->actor.world.pos.y = thisx->world.pos.y + 10.0f; + this->rider->actor.world.pos.z = thisx->world.pos.z; + this->rider->actor.shape.rot.x = thisx->shape.rot.x; + this->rider->actor.shape.rot.y = thisx->shape.rot.y; } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { EnIn* in = this->rider; s16 jnt = in->jointTable[0].y; @@ -4263,14 +4252,14 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { in->actor.world.pos.x = this->riderPos.x; in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); in->actor.world.pos.z = this->riderPos.z; - in->actor.shape.rot.x = this->actor.shape.rot.x; - in->actor.shape.rot.y = this->actor.shape.rot.y; + in->actor.shape.rot.x = thisx->shape.rot.x; + in->actor.shape.rot.y = thisx->shape.rot.y; } } if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { - if (this->actor.speedXZ > 10.0f) { - this->actor.speedXZ -= 1.0f; + if (thisx->speedXZ > 10.0f) { + thisx->speedXZ -= 1.0f; } } @@ -4309,22 +4298,22 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->type == HORSE_2) { this->colliderCylinder1.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; this->colliderCylinder1.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; this->colliderCylinder2.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; this->colliderCylinder2.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; } else { this->colliderCylinder1.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; this->colliderCylinder1.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; this->colliderCylinder2.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; this->colliderCylinder2.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; } CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); @@ -4346,18 +4335,18 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { EnHorse_UpdateBgCheckInfo(this, globalCtx); EnHorse_CheckFloors(this, globalCtx); - if (this->actor.world.pos.y < this->yFront) { - if (this->actor.world.pos.y < this->yBack) { + if (thisx->world.pos.y < this->yFront) { + if (thisx->world.pos.y < this->yBack) { if (this->yBack < this->yFront) { - this->actor.world.pos.y = this->yBack; + thisx->world.pos.y = this->yBack; } else { - this->actor.world.pos.y = this->yFront; + thisx->world.pos.y = this->yFront; } } } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 70.0f; if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { this->blinkTimer++; @@ -4368,13 +4357,13 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if ((this->actor.speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { - this->actor.colChkInfo.mass = MASS_IMMOVABLE; + if ((thisx->speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + thisx->colChkInfo.mass = MASS_IMMOVABLE; } else { - this->actor.colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.mass = MASS_HEAVY; } - if (this->actor.speedXZ >= 5.0f) { + if (thisx->speedXZ >= 5.0f) { this->colliderCylinder1.base.atFlags |= AT_ON; } else { this->colliderCylinder1.base.atFlags &= ~AT_ON; @@ -4400,39 +4389,6 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { this->stateFlags &= ~ENHORSE_DRAW; } } -#else -EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, -}; -Vec3f D_808891C8 = { 0.0f, 0.0f, 0.0f }; -Vec3f D_808891D4 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") -#endif s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { if (this->playerDir == PLAYER_DIR_SIDE_L) { diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index c3194461d..855cb0556 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -170,7 +170,7 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { i = 0; tempCutscene = this->actor.cutscene; while (tempCutscene != -1) { - // This might be a fake match, no others found yet + //! FAKE: tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); i++; } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 3464314b1..a1c276cad 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1277,7 +1277,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 09d2093ce..a75e0f489 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -368,7 +368,6 @@ s32 func_80BF42BC(EnRg* this, f32 arg1) { return false; } -#ifdef NON_MATCHING s32 func_80BF43FC(EnRg* this) { Vec3f sp9C; Vec3f sp90; @@ -378,11 +377,11 @@ s32 func_80BF43FC(EnRg* this) { f32 phi_f20 = 0.0f; s32 temp_s7 = ENRG_GET_7F80(&this->actor); s32 phi_s4 = -1; - s16 phi_s6 = 0; s32 temp_s5 = this->unk_344; + s16 phi_s6 = 0; s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; - while (true) { + do { SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, @@ -393,17 +392,10 @@ s32 func_80BF43FC(EnRg* this) { phi_s4 = phi_s0; } phi_s0++; - if ((temp_s5 == 18) || (phi_s0 >= D_80BF57E4[temp_s5 + 1][temp_s7])) { - break; - } - } + } while ((temp_s5 != 18) && (phi_s0 < D_80BF57E4[temp_s5 + 1][temp_s7])); return phi_s4; } -#else -s32 func_80BF43FC(EnRg* this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rg/func_80BF43FC.s") -#endif s32 func_80BF4560(EnRg* this, GlobalContext* globalCtx) { s32 temp_v0 = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index fc2ba1432..2bf6e61b5 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1191,7 +1191,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index dde803708..897a1d3ab 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -1221,7 +1221,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index 660e68b6d..abc8d6c85 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -148,7 +148,6 @@ f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { return temp_f20; } -#ifdef NON_MATCHING void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { ObjDrifticeStruct3* temp_s0; f32 temp_f22 = 0.0f; @@ -157,6 +156,7 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* if (this->unk_248 > 0) { f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; + if (temp_f20 > 1.0f) { temp_f20 = 1.0f; } else if (temp_f20 < 0.01f) { @@ -195,12 +195,9 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* temp_f22 *= arg0->unk_08; - *arg2 = (s32)temp_f22 + arg0->unk_00[2]; + //! FAKE: + *arg2 = arg0->unk_00[2] + (s32)((void)0, temp_f22); } -#else -void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") -#endif void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { ObjDrifticeStruct3* temp_s0; @@ -340,8 +337,6 @@ void func_80A671CC(ObjDriftice* this) { this->actionFunc = func_80A671E0; } -#ifdef NON_MATCHING -// stack void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { f32 phi_f0; Vec3f sp40; @@ -349,12 +344,12 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { f32 phi_f12; Vec3s* points; s32 sp30; - Vec3s* points2; + Actor* thisx = &this->dyna.actor; Math_Vec3s_ToVec3f(&sp40, &(&this->unk_16C[this->unk_164])[this->unk_168]); - Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &this->dyna.actor.velocity); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &thisx->velocity); - sp3C = Math3D_Vec3fMagnitude(&this->dyna.actor.velocity); + sp3C = Math3D_Vec3fMagnitude(&thisx->velocity); if (sp3C < (this->unk_23C * 8.0f)) { phi_f0 = this->unk_23C * 0.4f; phi_f12 = this->unk_23C * 0.05f; @@ -391,8 +386,8 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { this->unk_164 = this->unk_160; } - points2 = &this->unk_16C[0]; - if ((points2->x != points->x) || (points2->y != points->y) || (points2->z != points->z)) { + if ((this->unk_16C[0].x != points->x) || (this->unk_16C[0].y != points->y) || + (this->unk_16C[0].z != points->z)) { func_80A6743C(this); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); sp30 = false; @@ -405,9 +400,6 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") -#endif void func_80A6743C(ObjDriftice* this) { this->actionFunc = func_80A67450; diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 1bc0f57b2..1981c3b30 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -557,7 +557,8 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderTrisElementInit* element; Vec3f sp70[3]; Vec3f sp64; - s32 i, j; + s32 i; + s32 j; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); @@ -698,8 +699,9 @@ void func_80B30AD4(ObjSpidertent* this) { void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; TriNorm* triNorm; - s32 i, j; - ObjSpidertentStruct2* ptr; + s32 i; + s32 j; + s32 pad; Vec3f sp60; f32 sp5C; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index bfe1f24b1..ceb35bc7e 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -397,7 +397,8 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } if (type == OBJSWITCH_TYPE_EYE) { if (sIsSegmentTableInit == false) { - s32 i, j; + s32 i; + s32 j; sIsSegmentTableInit = true; diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 9e36e5a2a..5f2aed7a9 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -141,15 +141,15 @@ void func_80A3C7E8(ObjVspinyroll* this) { s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); index += 2; - this->unk_38C = index * 4; + this->unk_1A8.unk_1E4 = index * 4; tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); phi_f2 = 1.0f; - for (i = 0, j = 0; i < this->unk_38C; i++) { - this->unk_1A8[i].unk_00.x = D_80A3D4C4[j]; - this->unk_1A8[i].unk_00.y = phi_f2; - this->unk_1A8[i].unk_00.z = D_80A3D4B4[j]; + for (i = 0, j = 0; i < this->unk_1A8.unk_1E4; i++) { + this->unk_1A8.unk_000[i].unk_00.x = D_80A3D4C4[j]; + this->unk_1A8.unk_000[i].unk_00.y = phi_f2; + this->unk_1A8.unk_000[i].unk_00.z = D_80A3D4B4[j]; j++; if (j >= 4) { @@ -159,11 +159,10 @@ void func_80A3C7E8(ObjVspinyroll* this) { } } -#ifdef NON_MATCHING s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { s32 pad; - ObjVspinyrollStruct2* ptr = &this->unk_1A8[0]; - s32 pad2; + ObjVspinyrollStruct3* unk_1A8 = &this->unk_1A8; + ObjVspinyrollStruct2* ptr; s32 i; Vec3f spE4; Vec3f spD8; @@ -177,9 +176,11 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spE4.z = 0.0f; sp9C = false; - this->unk_388 = NULL; + unk_1A8->unk_1E0 = NULL; + + for (i = 0; i < unk_1A8->unk_1E4; i++) { + ptr = &unk_1A8->unk_000[i]; - for (i = 0; i < this->unk_38C; i++, ptr++) { spE4.x = ptr->unk_00.x; spE4.y = ptr->unk_00.y; func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); @@ -193,8 +194,8 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spCC.x += 30.0f * this->unk_3B4.x; spCC.z += 30.0f * this->unk_3B4.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &this->unk_1A8[i].collisionPoly, true, - false, false, true, &this->unk_1A8[i].bgId, &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &unk_1A8->unk_000[i].collisionPoly, true, + false, false, true, &unk_1A8->unk_000[i].bgId, &this->dyna.actor, 0.0f)) { if ((arg3 != 0) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { spA8.x = ptr->unk_00.x * 0.2f; spA8.y = ptr->unk_00.y; @@ -215,17 +216,13 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 temp_f20 = temp_f0; sp9C = true; Math_Vec3f_Diff(&spC0, &spCC, arg2); - this->unk_388 = ptr; + unk_1A8->unk_1E0 = ptr; } } } return sp9C; } -#else -s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") -#endif s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { Vec3f sp1C; @@ -239,8 +236,8 @@ s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { } DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { - if (this->unk_388 != NULL) { - return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_388->bgId); + if (this->unk_1A8.unk_1E0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_1A8.unk_1E0->bgId); } return NULL; } diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index af1048267..15879f86e 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -21,12 +21,16 @@ typedef struct { /* 0x10 */ s32 bgId; } ObjVspinyrollStruct2; // size = 0x14 +typedef struct { + /* 0x000 */ ObjVspinyrollStruct2 unk_000[24]; + /* 0x1E0 */ ObjVspinyrollStruct2* unk_1E0; + /* 0x1E4 */ s32 unk_1E4; +} ObjVspinyrollStruct3; // size = 0x1E8 + typedef struct ObjVspinyroll { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjVspinyrollStruct2 unk_1A8[24]; - /* 0x0388 */ ObjVspinyrollStruct2* unk_388; - /* 0x038C */ s32 unk_38C; + /* 0x01A8 */ ObjVspinyrollStruct3 unk_1A8; /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; /* 0x0394 */ f32 unk_394; /* 0x0398 */ s32 unk_398; From c2c724063478869146bdc35fe454df61735c24b9 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 26 May 2022 11:36:49 +1000 Subject: [PATCH 07/53] Improve Various Matchings and Cleanup (#809) * Improve various matchings and cleanup * Fix warnings * Missed 2 * Few hex to dec * PR Suggestions * More PR Suggestions * Document time calculation * Improved use of macros * DAY_LENGTH macro * More cleanup of functions Co-authored-by: hensldm * Missing a space * PR Suggestions * Use DAY_LENGTH more --- include/macros.h | 1 + include/z64save.h | 4 +- src/code/z_actor.c | 11 ++-- src/code/z_demo.c | 14 ++--- src/code/z_en_item00.c | 5 +- src/code/z_message.c | 10 ++-- src/code/z_message_nes.c | 21 ++++---- src/code/z_scene.c | 20 +++---- .../ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c | 9 +--- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- .../actors/ovl_Dm_Ravine/z_dm_ravine.c | 5 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 7 +-- .../actors/ovl_Door_Shutter/z_door_shutter.c | 4 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 27 +++++----- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 16 +++--- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 10 ++-- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 7 +-- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 5 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 6 +-- .../actors/ovl_En_Floormas/z_en_floormas.c | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 5 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 2 +- .../z_en_horse_game_check.c | 8 +-- .../z_en_horse_game_check.h | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 5 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 8 +-- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 10 ++-- .../actors/ovl_En_Kanban/z_en_kanban.c | 2 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 6 +-- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 4 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 9 ++-- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 19 +++---- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 6 +-- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 2 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 13 +++-- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 11 ++-- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 14 +++-- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 8 +-- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 6 +-- .../actors/ovl_En_Suttari/z_en_suttari.c | 8 +-- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 53 +++++++++---------- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 17 ++---- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 9 ++-- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 2 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 10 ++-- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 6 +-- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 2 +- 50 files changed, 190 insertions(+), 251 deletions(-) diff --git a/include/macros.h b/include/macros.h index 5e9c062c9..bb7315b3d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -51,6 +51,7 @@ #define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) +#define DAY_LENGTH (CLOCK_TIME(24, 0)) #define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f #define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) diff --git a/include/z64save.h b/include/z64save.h index 2595b3c27..260701473 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -129,9 +129,9 @@ typedef struct Save { /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 daySpeed; // "change_zelda_time" + /* 0x0014 */ s32 daySpeed; // "change_zelda_time" /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" + /* 0x001C */ s32 daysElapsed; // "eventday" /* 0x0020 */ u8 playerForm; // "player_character" /* 0x0021 */ u8 snowheadCleared; // "spring_flag" /* 0x0022 */ u8 hasTatl; // "bell_flag" diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 24bc91a17..2d75505d0 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -195,7 +195,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx CollisionPoly* spF8; s32 bgId; f32 floorHeight[2]; - f32 pad; + Light* firstLight = &mapper->l.l[0]; f32 shadowAlpha; f32 shadowScaleX; f32 shadowScaleZ; @@ -239,8 +239,6 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60); } actor->shape.unk_17 &= ~spB8; - - if ((uintptr_t)mapper->l.l) {} // POSSIBLE FAKE MATCH } } @@ -252,7 +250,8 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ = 1.0f - (distToFloor * (1.0f / 70.0f)); shadowScaleX = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; - for (lightPtr = mapper->l.l, j = 0; j < numLights; lightPtr++, j++) { + lightPtr = firstLight; + for (j = 0; j < numLights; j++) { if (lightPtr->l.dir[1] > 0) { lightNum = (lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS_ALT(lightPtr->l.dir[1]); @@ -263,9 +262,10 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ); } } + lightPtr++; } - for (j = 0; j < 2; lightPtr++, j++) { + for (j = 0; j < 2; j++) { if (lightPtr->l.dir[1] > 0) { lightNum = ((lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS_ALT(lightPtr->l.dir[1])) - @@ -275,6 +275,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ); } } + lightPtr++; } } feetPosPtr++; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index c9c6253d3..01ed87e70 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -132,7 +132,6 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs u8 isStartFrame = false; f32 progress; SceneTableEntry* loadedScene; - u16 time; if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { return; @@ -250,11 +249,9 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x12: if (!gSaveContext.save.isNight) { - time = gSaveContext.save.time; - gSaveContext.save.time = time - (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)REG(15); } else { - time = gSaveContext.save.time; - gSaveContext.save.time = time - (u16)(2 * REG(15)); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * REG(15)); } break; case 0x13: @@ -328,10 +325,9 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs D_801BB15C = csCtx->frames; if (REG(15) != 0) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = + ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } break; diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 3bec8471b..1c600bfa0 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -815,8 +815,6 @@ void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { } s16 func_800A7650(s16 dropId) { - s16 healthCapacity; - if ((((dropId == ITEM00_BOMBS_A) || (dropId == ITEM00_BOMBS_0) || (dropId == ITEM00_BOMBS_B)) && (INV_CONTENT(ITEM_BOMB) == ITEM_NONE)) || (((dropId == ITEM00_ARROWS_10) || (dropId == ITEM00_ARROWS_30) || (dropId == ITEM00_ARROWS_40) || @@ -828,8 +826,7 @@ s16 func_800A7650(s16 dropId) { } if (dropId == ITEM00_HEART) { - healthCapacity = gSaveContext.save.playerData.healthCapacity; - if (healthCapacity == gSaveContext.save.playerData.health) { + if (((void)0, gSaveContext.save.playerData.healthCapacity) == ((void)0, gSaveContext.save.playerData.health)) { return ITEM00_RUPEE_GREEN; } } diff --git a/src/code/z_message.c b/src/code/z_message.c index f41c713f6..2a90f38ca 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -405,23 +405,23 @@ void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { u32 func_80151C9C(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; - u8 flag; while (true) { if (msgCtx->unk120B1 == 0) { - return 0; + return false; } msgCtx->unk120B1--; if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { - flag = gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = - flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + ((void)0, gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]) | + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); play_sound(NA_SE_SY_SCHEDULE_WRITE); - return 1; + return true; } } } diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 1de839d68..485f016ff 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -193,29 +193,32 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg3; - u32 dayTime; + u32 timeLeft; s16 digits[4]; - f32 timeInMinutes; - s32 day; + f32 timeLeftInMinutes; s16 i; if (arg1 == 0xCF) { - day = gSaveContext.save.day; - dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.save.time); + // Calculates the time left before the moon crashes. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeLeft = (4 - CURRENT_DAY) * DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); } else { - dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.save.time); + // Calculates the time left before a new day. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeLeft = DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); } - timeInMinutes = TIME_TO_MINUTES_F(dayTime); + + timeLeftInMinutes = TIME_TO_MINUTES_F(timeLeft); digits[0] = 0; - digits[1] = (timeInMinutes / 60.0f); + digits[1] = (timeLeftInMinutes / 60.0f); while (digits[1] >= 10) { digits[0]++; digits[1] -= 10; } digits[2] = 0; - digits[3] = (s32)timeInMinutes % 60; + digits[3] = (s32)timeLeftInMinutes % 60; while (digits[3] >= 10) { digits[2]++; digits[3] -= 10; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index b03990702..b9dbb35dd 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -142,11 +142,9 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { // SceneTableEntry Header Command 0x00: Spawn List void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { - GlobalContext* globalCtx2 = globalCtx; s32 loadedCount; - void* nextObject; s16 playerObjectId; - u8 playerForm; + void* nextObject; globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; @@ -158,11 +156,10 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { } loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD); - nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; + nextObject = globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment; globalCtx->objectCtx.num = loadedCount; globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerForm = gSaveContext.save.playerForm; - playerObjectId = gLinkFormObjectIndexes[playerForm]; + playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&globalCtx->objectCtx, playerObjectId); @@ -378,8 +375,6 @@ void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x10: Time Settings void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - u32 dayTime; - if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { gSaveContext.environmentTime = gSaveContext.save.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); @@ -399,12 +394,9 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { REG(15) = globalCtx->envCtx.timeIncrement; } - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; + globalCtx->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + globalCtx->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + globalCtx->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f; if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { gSaveContext.environmentTime = gSaveContext.save.time; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 53ddd7b81..d562d1a7e 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -82,17 +82,12 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f offset; f32 rotZ; - f32 rotZtmp; Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - if (offset.z > 1100.0f) { - rotZ = 0.0f; - } else { - rotZtmp = CLAMP_MAX(1100.0f - offset.z, 1000.0f); - rotZ = rotZtmp; - } + rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f); func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17); this->dyna.actor.shape.rot.z = rotZ * 16.384f; + if (globalCtx->csCtx.frames == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); } diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index db1a954d0..f73423d5e 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -522,7 +522,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { temp_v0 = gSaveContext.save.time; if (temp_v0 > CLOCK_TIME(12, 0)) { - temp_v0 = 0xFFFF - temp_v0; + temp_v0 = (DAY_LENGTH - 1) - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index bb8b735a4..25a68056e 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -29,9 +29,10 @@ const ActorInit Dm_Ravine_InitVars = { }; void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; DmRavine* this = THIS; - u8 flag = gSaveContext.save.weekEventReg[0]; - if (((flag & 0x10) | cREG(0)) != 0) { + + if (((((void)0, gSaveContext.save.weekEventReg[0]) & 0x10) | cREG(0)) != 0) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 08e515d26..b778f3fcc 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1512,7 +1512,6 @@ void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - u16 time; if (this->actor.params != 1) { if (this->unk_2E0 == 33) { @@ -1569,11 +1568,9 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(15) + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); if (REG(15) != 0) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } } diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 01430acc3..999eec485 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -570,9 +570,7 @@ void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - s8 data = gSaveContext.respawn[RESTART_MODE_DOWN].data; - - func_801226E0(globalCtx, data); + func_801226E0(globalCtx, ((void)0, gSaveContext.respawn[RESTART_MODE_DOWN].data)); player->unk_A86 = -1; func_800B7298(globalCtx, NULL, 0x73); } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 9bfd07939..28b6251a1 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -100,11 +100,8 @@ void func_809C10B0(EnAob01* this, s32 arg1) { } void func_809C1124(void) { - u16 time = gSaveContext.save.time; - - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { @@ -882,8 +879,8 @@ void func_809C2F34(EnAob01* this, GlobalContext* globalCtx) { void func_809C2FA0(void) { u8 i; - u8 idx; - u8 idx2; + u8 rand; + u8 index; u8 orig; u8 orig2; u8 sp44[7]; @@ -892,11 +889,11 @@ void func_809C2FA0(void) { }; for (i = 0; i < ARRAY_COUNT(sp34); i++) { - idx = Rand_ZeroFloat(14.0f); + rand = Rand_ZeroFloat(14.0f); orig = sp34[i]; - sp34[i] = sp34[idx]; - sp34[idx] = orig; + sp34[i] = sp34[rand]; + sp34[rand] = orig; } for (i = 0; i < ARRAY_COUNT(sp44); i++) { @@ -906,14 +903,14 @@ void func_809C2FA0(void) { for (i = 0; i < ARRAY_COUNT(sp34); i++) { orig2 = sp34[i]; - idx2 = i / 2; + index = i / 2; if (i % 2) { - sp44[idx2] |= orig2 << 0x4; - idx = gSaveContext.save.weekEventReg[42 + idx2]; - gSaveContext.save.weekEventReg[42 + idx2] = idx | sp44[idx2]; + sp44[index] |= orig2 << 0x4; + gSaveContext.save.weekEventReg[42 + index] = + ((void)0, gSaveContext.save.weekEventReg[42 + index]) | sp44[index]; } else { - sp44[idx2] |= orig2; + sp44[index] |= orig2; } } } diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 818515446..20173ed15 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -116,8 +116,7 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { } void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { - s32 tempDay; - f32 tempTimeBeforeMoonCrash; + f32 timeBeforeMoonCrash; switch (this->actor.params) { case ENBJI01_PARAMS_DEFAULT: @@ -180,10 +179,11 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - tempDay = gSaveContext.save.day; - tempTimeBeforeMoonCrash = - ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.save.time - 0x4000))) + 0x40000); - if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 1 hr */ + // Calculates the time left before the moon crashes. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeBeforeMoonCrash = (4 - CURRENT_DAY) * DAY_LENGTH - + (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + if (timeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { this->textId = 0x5E8; } else { this->textId = 0x5EB; @@ -207,7 +207,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { @@ -235,7 +235,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; switch (globalCtx->msgCtx.currentTextId) { case 0x5DE: diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index eeae2b8de..70805438f 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -675,14 +675,14 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar f32 temp_f26 = Math_Vec3f_DistXYZ(arg3, arg1); s32 spB0; f32 temp_f2; - f32 sqrt; + f32 distXZ; Math_Vec3f_Copy(&ptr->unk_00, arg1); Math_Vec3f_Diff(arg2, arg1, &spCC); ptr->unk_18 = Math_FAtan2F(spCC.z, spCC.x); - sqrt = sqrtf(SQ(spCC.x) + SQ(spCC.z)); - ptr->unk_1A = Math_FAtan2F(sqrt, spCC.y); + distXZ = sqrtf(SQXZ(spCC)); + ptr->unk_1A = Math_FAtan2F(distXZ, spCC.y); spB0 = (arg4 / 240) + 1; @@ -721,8 +721,8 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar } ptr2->unk_18 = Math_FAtan2F(spCC.z, spCC.x); - sqrt = sqrtf(SQ(spCC.x) + SQ(spCC.z)); - ptr2->unk_1A = Math_FAtan2F(sqrt, spCC.y); + distXZ = sqrtf(SQXZ(spCC)); + ptr2->unk_1A = Math_FAtan2F(distXZ, spCC.y); ptr2->unk_18 = (s16)CLAMP(BINANG_SUB(ptr2->unk_18, ptr->unk_18), -8000, 8000) + ptr->unk_18; ptr2->unk_1A = (s16)CLAMP(BINANG_SUB(ptr2->unk_1A, ptr->unk_1A), -8000, 8000) + ptr->unk_1A; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index c18a94209..1657e031c 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -656,7 +656,6 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { 0x0721, 0x0722, 0x0723, 0x0724, 0x072C, }; Player* player = GET_PLAYER(globalCtx); - s16 idx; func_80C012E0(this); func_80C0113C(this, 21, 1.0f); @@ -683,10 +682,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - idx = gSaveContext.save.bombersCaughtNum; - Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); - idx = gSaveContext.save.bombersCaughtNum; - gSaveContext.save.bombersCaughtOrder[idx] = this->unk_2C8 + 1; + Message_StartTextbox(globalCtx, D_80C03230[((void)0, gSaveContext.save.bombersCaughtNum)], &this->actor); + gSaveContext.save.bombersCaughtOrder[((void)0, gSaveContext.save.bombersCaughtNum)] = this->unk_2C8 + 1; gSaveContext.save.bombersCaughtNum++; if (gSaveContext.save.bombersCaughtNum > 4) { diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 3acd2adf5..de1959ab4 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -177,14 +177,11 @@ void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { - s8 sp1F; - if ((arg2 < 1) || (arg2 >= 5)) { return 0; } - sp1F = gSaveContext.save.inventory.strayFairies[arg2 - 1]; - return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; + return (((void)0, gSaveContext.save.inventory.strayFairies[arg2 - 1]) - func_80A39C1C(globalCtx, arg2)) + 10; } s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index eccee0fe9..6dc9ff081 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1069,7 +1069,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } } else if (effect->type == FS_EFF_RAIN_DROP) { if (effect->pos.y < WATER_SURFACE_Y(globalCtx)) { - f32 sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + f32 sqDistXZ = SQXZ(effect->pos); if (sqDistXZ > SQ(920.0f)) { effect->pos.y = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); @@ -1106,7 +1106,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); - sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + sqDistXZ = SQXZ(effect->pos); bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); if (effect->pos.y > (bottomY - 10.0f)) { @@ -5188,7 +5188,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; - lureDistXZ = sqrtf(SQ(spFC.x) + SQ(spFC.z)); + lureDistXZ = sqrtf(SQXZ(spFC)); Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); sp114.x = 0.0f; diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index de7d34024..75d6ce63b 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -713,15 +713,13 @@ void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; - u8 playerForm; Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); - playerForm = gSaveContext.save.playerForm; - ptr = &D_808D3900[playerForm]; + ptr = &D_808D3900[(void)0, gSaveContext.save.playerForm]; this->actor.home.pos.x = ptr->z * Math_SinS(this->actor.shape.rot.y); this->actor.home.pos.y = CLAMP(-this->actor.playerHeightRel, ptr->x, ptr->y); this->actor.home.pos.z = ptr->z * Math_CosS(this->actor.shape.rot.y); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index b67a3080e..2b234d36b 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -652,9 +652,8 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { } if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { - s16 temp = gSaveContext.unk_3F30; - - Parameter_AddMagic(globalCtx, temp + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); } func_80962F10(this); diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 059f18c9c..e6ede8065 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -741,7 +741,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 2; } } - } else if ((temp_v0 == 4) && (Message_ShouldAdvance(globalCtx) != 0)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index 3a8cfdcd9..726287c0b 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -228,7 +228,7 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); } - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { if (D_80ABBE38[this->guardTextIndex] != 1) { if (D_80ABBE38[this->guardTextIndex] == 2) { func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 8844062b8..3830864d1 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -207,7 +207,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 7b9fa684e..6b9a8dda1 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -252,7 +252,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_4) + SET_RACE_FLAGS(RACE_FLAG_4); this->unk_174 = 60; } @@ -285,7 +285,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3) + SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -318,7 +318,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3) + SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -347,7 +347,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_2) + SET_RACE_FLAGS(RACE_FLAG_2); this->unk_174 = 60; } return true; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 1e4bf4f5a..886187b49 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -39,7 +39,7 @@ enum { gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ gSaveContext.save.weekEventReg[92] = \ gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ - } + } (void)0 typedef struct EnHorseGameCheck { /* 0x000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 80a5c7651..557b96b31 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -874,9 +874,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { } void func_80B442E4(EnInvadepoh* this) { - s32 pad; - s32 sp18 = gSaveContext.save.time; - s32 temp_v1_2 = sp18 - func_80B43A24(this->actor.params & 7); + s32 temp_v1_2 = ((void)0, (s32)gSaveContext.save.time) - func_80B43A24(this->actor.params & 7); if (D_80B4E940 == 1) { this->clockTime = 0.0f; @@ -1001,6 +999,7 @@ void func_80B44700(EnInvadepoh* this) { this->clockTime = 1.0f; } else { f32 new_var = 0.00153374229558f; + this->clockTime = (currentTime + new_var4) * new_var; this->clockTime = CLAMP(this->clockTime, 0.0f, 1.0f); } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 9412e5594..2fe0853cd 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -358,7 +358,7 @@ void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { // There is nothing more to say after these lines, so end the current conversation. globalCtx->msgCtx.msgMode = 0x43; @@ -425,7 +425,7 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { - if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((messageState == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; @@ -480,7 +480,7 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } - if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((messageState == 5) && Message_ShouldAdvance(globalCtx)) { temp = this->textId; if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { // There is nothing more to say after these lines, so end the current conversation. @@ -600,7 +600,7 @@ void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = EnJg_FrozenIdle; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 855cb0556..53dd9e671 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -415,7 +415,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx) != 0) { + if ((this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -560,7 +560,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -734,8 +734,8 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); - if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - Message_ShouldAdvance(globalCtx) != 0) { + if ((this->unkState1A8 != 0) && (Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC) && + Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); @@ -1101,7 +1101,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 33474cda5..dee9a5049 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -995,7 +995,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = 0xFFFF - dayTime; + dayTime = (DAY_LENGTH - 1) - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 031f2113f..8905a862d 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -357,7 +357,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { // Chooses the next dialogue based on player's selection void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { @@ -491,7 +491,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 aux; - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x2390: func_801477B4(globalCtx); @@ -643,7 +643,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 29eb6cdcc..721e2f742 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -359,7 +359,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYts_SetupStartDialogue(this); } break; @@ -426,7 +426,7 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { // Select the following dialogue based on the current one, and an appropiate face expression void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 27192800e..3e67b4db6 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -255,10 +255,9 @@ void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { } void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { - u8 flag; - EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); @@ -270,6 +269,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; + case 0xD82: // "What has brought you all this way?" if (gSaveContext.save.weekEventReg[33] & 0x80) { // Mountain village is unfrozen func_80151938(globalCtx, 0xD83); // "Could it be... Has spring finally come to the mountains?" @@ -277,10 +277,11 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { func_80151938(globalCtx, 0xD86); // "Could it be... You came all this way looking for me?" } - flag = gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = - flag | (u8)isFrogReturnedFlags[this->frogIndex]; + ((void)0, gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]) | + (u8)isFrogReturnedFlags[this->frogIndex]; break; + case 0xD85: // "I understand. I shall head for the mountains immediately." default: func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 396a3f040..393b253a9 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -375,24 +375,17 @@ void func_80A6FBA0(EnMm3* this) { void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - OSTime a; - OSTime b; if (gSaveContext.unk_3DD0[0] == 0x10) { player->stateFlags1 &= ~0x20; this->actor.flags |= ACTOR_FLAG_10000; - if (gSaveContext.unk_3DE0[0] >= 0x5DD) { - gSaveContext.unk_3DE0[0] = 0x5DC; - } else { - a = gSaveContext.unk_3DE0[0]; - if (a >= (OSTime)(995 - XREG(16))) { - b = gSaveContext.unk_3DE0[0]; - if ((OSTime)(XREG(17) + 1005) >= b) { - gSaveContext.unk_3DE0[0] = 1000; - } - } + if (gSaveContext.unk_3DE0[0] > 1500) { + gSaveContext.unk_3DE0[0] = 1500; + } else if ((((void)0, gSaveContext.unk_3DE0[0]) >= (OSTime)(995 - XREG(16))) && + (((void)0, gSaveContext.unk_3DE0[0]) <= (OSTime)(1005 + XREG(17)))) { + gSaveContext.unk_3DE0[0] = 1000; } - } else if (gSaveContext.unk_3DE0[0] >= 0x5DD) { + } else if (gSaveContext.unk_3DE0[0] > 1500) { gSaveContext.unk_3DD0[0] = 15; gSaveContext.unk_3DC8 = osGetTime(); } diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 729e36d49..4135fe701 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -99,13 +99,13 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 6: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnMs_Wait; } break; case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); @@ -114,7 +114,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { break; case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 6952f10c2..aa96b13c1 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -453,7 +453,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { * responded to the Goron Elder's son's question. */ void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 4aed3132f..c4b2beffc 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -133,11 +133,14 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { Player* player; this->actor.textId = sTextIds[this->textIdIndex]; - if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.save.weekEventReg[88] & 8)) { - this->actor.textId = 0x62C; - } else { - this->actor.textId = 0x62B; + if (!this->isInMayorsRoom) { + player = GET_PLAYER(globalCtx); + if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { + this->actor.textId = 0x62C; + } else { + this->actor.textId = 0x62B; + } } } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 4d5961732..633526f81 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1105,12 +1105,11 @@ void func_80AF8AC8(EnPm* this) { void func_80AF8BA8(s32 arg0) { static u16 D_80AFB8D4[] = { - 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, 0x0000, + 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, }; static u16 D_80AFB8E0[] = { - 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, 0x0000, + 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, }; - s32 temp; if (!(gSaveContext.save.weekEventReg[88] & 2)) { if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & @@ -1129,9 +1128,8 @@ void func_80AF8BA8(s32 arg0) { } } - temp = gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]; gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = - temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); + ((void)0, gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]) | (u8)D_80AFB8E0[arg0]; } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { @@ -1990,9 +1988,8 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { u16 time = gSaveContext.save.time; u16 sp3C = 0; ScheduleResult sp2C; - u32* unk_14 = &gSaveContext.save.daySpeed; - this->unk_374 = REG(15) + *unk_14; + this->unk_374 = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { time = gSaveContext.save.time - D_801F4E78; sp3C = gSaveContext.save.time; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 29df2aa2c..797d898ac 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -312,9 +312,8 @@ void func_80A76748(EnPrz* this) { void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnPr* pr = (EnPr*)this->actor.parent; - f32 sqrt; + f32 distXZ; s32 pad[2]; - u8 playerForm; if (func_80A762C0(this, globalCtx)) { func_80A75F18(this, 0); @@ -323,10 +322,10 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { return; } - sqrt = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + - SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); + distXZ = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); - if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < sqrt)) { + if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < distXZ)) { this->unk_1F2 = 100; this->skelAnime.playSpeed = 1.0f; func_80A76388(this); @@ -354,9 +353,8 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { this->unk_1C8 = 1; } - playerForm = gSaveContext.save.playerForm; - this->unk_1D8.y = - (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); + this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[((void)0, gSaveContext.save.playerForm)]) + + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 8c2f5b6c8..56846543e 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -120,7 +120,7 @@ void EnRecepgirl_SetupTalk(EnRecepgirl* this) { } void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { - u8 temp_v0_2; + u8 talkState; if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { @@ -140,11 +140,11 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); - if (temp_v0_2 == 2) { + talkState = Message_GetState(&globalCtx->msgCtx); + if (talkState == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + } else if ((talkState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index dc7715fa0..d522a4751 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -331,7 +331,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 4) { - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_358) { diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 2bf6e61b5..003f731b0 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -607,8 +607,8 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (Message_ShouldAdvance(globalCtx)) && - (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { + if ((talkState == 5) && Message_ShouldAdvance(globalCtx) && + !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); } else { @@ -1084,7 +1084,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index a4e6cfd41..40ebeb21b 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -227,12 +227,8 @@ void EnSuttari_SetNextEntrance(GlobalContext* globalCtx, u16 nextEntranceIndex) } void EnSuttari_UpdateTime(void) { - u32* unk_14 = &gSaveContext.save.daySpeed; - u16 time = gSaveContext.save.time; - - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)*unk_14 + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 91d602f87..512e90d4f 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -885,38 +885,33 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; func_808D8ED0(this, globalCtx); } - return; - if (1) {} - } - - if (ENSW_GET_3(&this->actor)) { + } else if (ENSW_GET_3(&this->actor)) { this->actionFunc = func_808DAEB4; - return; - } - - if (this->actor.bgCheckFlags & 1) { - f32 temp_f2; - - this->actor.shape.yOffset = 400.0f; - temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; - this->actor.velocity.y = temp_f2; - this->unk_448 = temp_f2; - this->actor.speedXZ = 0.0f; - if ((s32)temp_f2 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); - } else { - this->actionFunc = func_808DAEB4; - this->actor.velocity.y = 0.0f; - } - if ((s32)this->actor.velocity.y >= 2) { - func_808D8940(this, globalCtx); - } } else { - Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); - } + if (this->actor.bgCheckFlags & 1) { + f32 temp_f2; - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + this->actor.shape.yOffset = 400.0f; + temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.velocity.y = temp_f2; + this->unk_448 = temp_f2; + this->actor.speedXZ = 0.0f; + if ((s32)temp_f2 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + } else { + this->actionFunc = func_808DAEB4; + this->actor.velocity.y = 0.0f; + } + if ((s32)this->actor.velocity.y >= 2) { + func_808D8940(this, globalCtx); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } } void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 1bc5484ff..52ea1d8f1 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1097,26 +1097,19 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { }; static s32 D_809C94A8 = 0; Player* player = GET_PLAYER(globalCtx); - s32 sp30; - s32 pad; - u64 sp20; - - sp20 = gSaveContext.unk_3DE0[1]; - sp30 = (sp20 * 0.1f) + 1.0f; + s32 sp30 = (((void)0, gSaveContext.unk_3DE0[1]) * 0.1f) + 1.0f; if (sp30 < 0x2EF) { s32 temp; - // clang-format off if (D_809C94A8 == 0) { - sp20 = gSaveContext.unk_3DE0[1]; temp = sp20 % 0x1F4; + temp = ((void)0, gSaveContext.unk_3DE0[1]) % 500; } else { - sp20 = gSaveContext.unk_3DE0[1]; temp = (sp20 + 250) % 0x1F4; + temp = (((void)0, gSaveContext.unk_3DE0[1]) + 250) % 500; } - //clang-format on if (temp < 100) { - this->unk_26C = 0x50; + this->unk_26C = 80; } if (this->unk_26E != 0) { @@ -1292,7 +1285,7 @@ void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); + EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index f4d999fae..0f81d088d 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -482,18 +482,15 @@ void func_80967608(EnWeatherTag* this, GlobalContext* globalCtx) { void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag* this = THIS; - u16 oldTime; this->actionFunc(this, globalCtx); if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - oldTime = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(0xF) + oldTime; // cast req - if (REG(0xF) != 0) { - oldTime = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + oldTime; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + if (REG(15) != 0) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } } diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 25cf4c473..724d01710 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -287,7 +287,7 @@ void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; EnYb_UpdateAnimation(this, globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { case 0x147D: // I am counting on you func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 15bef2ca5..1382e3d1b 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -351,7 +351,7 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; f32 temp; - u16 phi_a0; + u16 time; if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); @@ -369,13 +369,13 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { - phi_a0 = gSaveContext.save.time; + time = gSaveContext.save.time; - if (phi_a0 > CLOCK_TIME(12, 0)) { - phi_a0 = 0xFFFF - phi_a0; + if (time > CLOCK_TIME(12, 0)) { + time = (DAY_LENGTH - 1) - time; } - temp = (phi_a0 * (1.0f / 0x8000)); + temp = (time * (1.0f / 0x8000)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 8a822bea4..e058ec7c4 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -290,7 +290,6 @@ void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { s32 potBreaks; - s16 temp_v0_2; s32 phi_v1; potBreaks = false; @@ -311,9 +310,8 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); if (this->myPotIndex == 4) { - temp_v0_2 = gSaveContext.save.weekEventReg[0x25]; - if (!(temp_v0_2 & 0x10)) { - gSaveContext.save.weekEventReg[0x25] = temp_v0_2 | 0x10; + if (!(((void)0, gSaveContext.save.weekEventReg[0x25]) & 0x10)) { + gSaveContext.save.weekEventReg[0x25] = ((void)0, gSaveContext.save.weekEventReg[0x25]) | 0x10; Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, this->actor.cutscene, this->actor.unk20, NULL); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index fde0406f1..052d6610a 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -138,7 +138,7 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x4D; From af1a4b01ef376f2c0a66ec4a7660395716ee7f60 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 26 May 2022 02:40:34 +0100 Subject: [PATCH 08/53] En_Scopecrow (#808) * En_Scopecrow * PR --- spec | 3 +- .../actors/ovl_En_Scopecrow/z_en_scopecrow.c | 324 ++++++++++++++++-- .../actors/ovl_En_Scopecrow/z_en_scopecrow.h | 21 +- undefined_syms.txt | 5 - 4 files changed, 318 insertions(+), 35 deletions(-) diff --git a/spec b/spec index 1a733af09..137ff6249 100644 --- a/spec +++ b/spec @@ -4546,8 +4546,7 @@ beginseg name "ovl_En_Scopecrow" compress include "build/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.o" - include "build/data/ovl_En_Scopecrow/ovl_En_Scopecrow.data.o" - include "build/data/ovl_En_Scopecrow/ovl_En_Scopecrow.reloc.o" + include "build/src/overlays/actors/ovl_En_Scopecrow/ovl_En_Scopecrow_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index bf0b6a839..5743f4a48 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -18,7 +18,6 @@ void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx); void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Scopecrow_InitVars = { ACTOR_EN_SCOPECROW, ACTORCAT_NPC, @@ -31,47 +30,324 @@ const ActorInit En_Scopecrow_InitVars = { (ActorFunc)EnScopecrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BCDB70[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 60, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BCDB94 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BCDB70, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void func_80BCD000(EnScopecrow* this, GlobalContext* globalCtx) { + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = + sJntSphInit.elements[0].dim.modelSphere.center.y + this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; -extern ColliderJntSphElementInit D_80BCDB70[1]; -extern ColliderJntSphInit D_80BCDB94; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_060010C0; +s32 func_80BCD09C(s16 arg0) { + switch (arg0) { + case 0: + if (gSaveContext.save.weekEventReg[53] & 4) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD000.s") + case 1: + if (gSaveContext.save.weekEventReg[53] & 0x80) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD09C.s") + case 2: + if (gSaveContext.save.weekEventReg[54] & 1) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD1AC.s") + case 3: + if (gSaveContext.save.weekEventReg[54] & 2) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD2BC.s") + case 4: + if (gSaveContext.save.weekEventReg[54] & 4) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD334.s") + case 5: + if (gSaveContext.save.weekEventReg[54] & 8) { + return true; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD4D0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD590.s") +s32 func_80BCD1AC(s16 arg0) { + switch (arg0) { + case 0: + if (!(gSaveContext.save.weekEventReg[53] & 4)) { + gSaveContext.save.weekEventReg[53] |= 4; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD640.s") + case 1: + if (!(gSaveContext.save.weekEventReg[53] & 0x80)) { + gSaveContext.save.weekEventReg[53] |= 0x80; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Init.s") + case 2: + if (!(gSaveContext.save.weekEventReg[54] & 1)) { + gSaveContext.save.weekEventReg[54] |= 1; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Destroy.s") + case 3: + if (!(gSaveContext.save.weekEventReg[54] & 2)) { + gSaveContext.save.weekEventReg[54] |= 2; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Update.s") + case 4: + if (!(gSaveContext.save.weekEventReg[54] & 4)) { + gSaveContext.save.weekEventReg[54] |= 4; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Draw.s") + case 5: + if (!(gSaveContext.save.weekEventReg[54] & 8)) { + gSaveContext.save.weekEventReg[54] |= 8; + return true; + } + break; + } + + return false; +} + +void func_80BCD2BC(EnScopecrow* this, GlobalContext* globalCtx) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SC_RUPPE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, this->actor.shape.rot.z, this->actor.params, + this->actor.cutscene, this->actor.unk20, NULL); +} + +s32 func_80BCD334(EnScopecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 index = pointIndex; + s32 ret = false; + f32 phi_fa0; + f32 phi_fa1; + Vec3f sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &points[index]); + + if (index == 0) { + phi_fa0 = points[1].x - points[0].x; + phi_fa1 = points[1].z - points[0].z; + } else if ((sp58 - 1) == index) { + phi_fa0 = points[sp58 - 1].x - points[sp58 - 2].x; + phi_fa1 = points[sp58 - 1].z - points[sp58 - 2].z; + } else { + phi_fa0 = points[index + 1].x - points[index - 1].x; + phi_fa1 = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_fa0, phi_fa1)), &sp3C.z, &sp3C.y, &sp3C.x); + + if (((this->actor.world.pos.x * sp3C.z) + (sp3C.y * this->actor.world.pos.z) + sp3C.x) > 0.0f) { + ret = true; + } + return ret; +} + +f32 func_80BCD4D0(Path* path, s32 count, Vec3f* arg2, Vec3s* arg3) { + Vec3s* temp; + Vec3f sp20; + Vec3s* points; + + if (path != NULL) { + temp = Lib_SegmentedToVirtual(path->points); + points = temp + count; + + sp20.x = points->x; + sp20.y = points->y; + sp20.z = points->z; + } + + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} + +void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + + if ((sp1C.x >= 130.0f) && (sp1C.x < 190.0f) && (sp1C.y >= 90.0f) && (sp1C.y < 150.0f)) { + this->actor.draw = EnScopecrow_Draw; + this->actionFunc = func_80BCD640; + } +} + +void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->path != NULL) { + func_80BCD4D0(this->path, this->unk_1FC, &this->actor.world.pos, &sp30); + if (this->actor.bgCheckFlags & 8) { + sp30.y = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.world.rot.x, -sp30.x, 4, 0x3E8, 1); + + if (func_80BCD334(this, this->path, this->unk_1FC)) { + if ((this->unk_1FC == this->unk_262) && func_80BCD1AC(this->unk_260)) { + func_80BCD2BC(this, globalCtx); + } + + if (this->unk_1FC >= (this->path->count - 1)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_1FC++; + } + } + } + + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 1.0f); + Actor_MoveWithoutGravity(&this->actor); + this->unk_264 += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->unk_264) * 500.0f; +} + +void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + Vec3s* temp; + CollisionPoly* sp4C; + Vec3s* points; + Vec3f sp3C; + + this->unk_260 = ENSCOPECROW_GET_1F(&this->actor); + if ((this->unk_260 < 0) || (this->unk_260 >= 6)) { + this->unk_260 = 0; + } + + if (func_80BCD09C(this->unk_260)) { + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); + + if (this->path != NULL) { + if ((this->unk_262 <= 0) || ((this->path->count - 1) < this->unk_262)) { + this->unk_262 = this->path->count - 1; + } + + temp = Lib_SegmentedToVirtual(this->path->points); + points = temp + this->unk_262; + + sp3C.x = points->x; + sp3C.y = points->y; + sp3C.z = points->z; + + this->actor.world.pos = sp3C; + this->actor.world.pos.y = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp4C, &sp3C); + if (this->actor.world.pos.y == BGCHECK_Y_MIN) { + Actor_MarkForDeath(&this->actor); + } + + func_80BCD2BC(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + if (globalCtx->actorCtx.unk5 & 2) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + + Actor_SetScale(&this->actor, 0.03f); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); + + if (this->path != NULL) { + if ((this->unk_262 <= 0) || ((this->path->count - 1) < this->unk_262)) { + this->unk_262 = this->path->count - 1; + } + this->actor.draw = NULL; + this->actor.gravity = 0.0f; + this->actionFunc = func_80BCD590; + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); +} + +void EnScopecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void EnScopecrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80BCD000(this, globalCtx); +} + +void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h index 2b5b38eae..72469bd75 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h @@ -2,16 +2,29 @@ #define Z_EN_SCOPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnScopecrow; typedef void (*EnScopecrowActionFunc)(struct EnScopecrow*, GlobalContext*); +#define ENSCOPECROW_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENSCOPECROW_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENSCOPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnScopecrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnScopecrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xDC]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnScopecrowActionFunc actionFunc; + /* 0x18C */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1C2 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1F8 */ Path* path; + /* 0x1FC */ s32 unk_1FC; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderElements[1]; + /* 0x260 */ s16 unk_260; + /* 0x262 */ s16 unk_262; + /* 0x264 */ s16 unk_264; } EnScopecrow; // size = 0x268 extern const ActorInit En_Scopecrow_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 91ead11f3..f24e3b627 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1444,11 +1444,6 @@ D_06003A20 = 0x06003A20; D_0600D768 = 0x0600D768; D_0600D8D8 = 0x0600D8D8; -// ovl_En_Scopecrow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Slime D_060004C0 = 0x060004C0; From a6e90d144cef5ac16327b9315acd50722d279bf1 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 18:44:09 -0700 Subject: [PATCH 09/53] SubS models (#807) * Bring model code over * SubS_UpdateLimb * SubS_TurnToPoint * SubS_TurnToPointMultiTarget * Adjust comment * Another comment * Review * options as structs * bss * adj -> step, SubS_TurnToPointMultiTarget -> SubS_TurnToPointStep, various comment cleanups * Fix SubS_TurnToPointStep header comment --- include/functions.h | 8 +- include/z64subs.h | 14 ++ include/z_en_hy_code.h | 4 +- src/boot_O2_g3/z_std_dma.c | 1 - src/code/z_sub_s.c | 179 +++++++++++++++++- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 32 ++-- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 24 +-- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 31 +-- src/overlays/actors/ovl_En_Al/z_en_al.c | 18 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 57 +++--- .../actors/ovl_En_Aob_01/z_en_aob_01.h | 6 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 39 ++-- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 6 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 27 +-- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 20 +- .../actors/ovl_En_Bji_01/z_en_bji_01.h | 8 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 27 +-- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 24 +-- src/overlays/actors/ovl_En_Go/z_en_go.c | 26 +-- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 18 +- src/overlays/actors/ovl_En_In/z_en_in.c | 39 ++-- src/overlays/actors/ovl_En_In/z_en_in.h | 6 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 26 +-- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 22 +-- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 18 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 55 +++--- .../actors/ovl_En_Suttari/z_en_suttari.h | 6 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 20 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 22 +-- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 23 ++- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 2 +- tools/disasm/functions.txt | 12 +- tools/namefixer.py | 23 ++- tools/sizes/code_functions.csv | 8 +- 34 files changed, 535 insertions(+), 316 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0f3a2e671..e3f700d72 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2424,7 +2424,7 @@ struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); s32 SubS_InCsMode(GlobalContext* globalCtx); -s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); @@ -2444,8 +2444,8 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); -s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); -s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); @@ -2474,7 +2474,7 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); diff --git a/include/z64subs.h b/include/z64subs.h index f01230fdb..3b13d2add 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -38,6 +38,20 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define ACTOR_PATHING_REACHED_END \ (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) +typedef struct TurnOptions { + /* 0x0 */ u16 rotMax; // binary angles + /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 + /* 0x4 */ u16 rotStepMin; // degrees + /* 0x6 */ u16 rotStepMax; // degrees +} TurnOptions; // size = 0x8 + +typedef struct TurnOptionsSet { + /* 0x00 */ TurnOptions headRotX; + /* 0x08 */ TurnOptions headRotY; + /* 0x10 */ TurnOptions torsoRotX; + /* 0x18 */ TurnOptions torsoRotY; +} TurnOptionsSet; // size = 0x20 + struct ActorPathing; typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 970706760..a0f9bcdd4 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -57,10 +57,10 @@ typedef struct EnHy { /* 0x205 */ u8 isRightFootOnGround; /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; - /* 0x2C6 */ Vec3s focusTarget; + /* 0x2C6 */ Vec3s turnTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmpFocusTarget; + /* 0x2D8 */ Vec3s tmpTurnTarget; /* 0x2DE */ Vec3s tmpHeadRot; /* 0x2E4 */ Vec3s tmpTorsoRot; /* 0x2EA */ s16 limbRotTableY[16]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 10d84dcb0..d9c7fb221 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u32 sDmaMgrDmaBuffSize = 0x2000; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index b51de4897..58812abc9 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -168,7 +168,47 @@ s32 SubS_InCsMode(GlobalContext* globalCtx) { return inCsMode; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") +/** + * Computes a limb's position and rotation for use in TransformLimbDraws + * + * @param[in] newRotZ value to override newRot's Z value if override is true + * @param[in] newRotY value to override newRot's Y value if override is true + * @param[out] pos limb's computed position + * @param[out] rot limb's computed rotation + * @param[in] stepRot boolean, step towards newRot instead of setting directly + * @param[in] overrideRot boolean, override newRot with the specified input. + * + * Note: + * If overrideRot is true, the rotation will automatically step instead of setting directly + */ +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { + Vec3f newPos; + Vec3f zeroVec = gZeroVec3f; + Vec3s newRot; + MtxF curState; + + Matrix_MultiplyVector3fByState(&zeroVec, &newPos); + Matrix_CopyCurrentState(&curState); + func_8018219C(&curState, &newRot, MTXMODE_NEW); + *pos = newPos; + + if (!stepRot && !overrideRot) { + rot->x = newRot.x; + rot->y = newRot.y; + rot->z = newRot.z; + return true; + } + + if (overrideRot) { + newRot.z = newRotZ; + newRot.y = newRotY; + } + + Math_SmoothStepToS(&rot->x, newRot.x, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&rot->y, newRot.y, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&rot->z, newRot.z, 3, 0x2AA8, 0xB6); + return true; +} void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { *flags = (*flags & ~unsetBits) | setBits; @@ -525,9 +565,93 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { CLOSE_DISPS(gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") +/** + * Computes the rotation based on the options and target rotation value + * + * @param[in,out] rot the computed rotation + * @param[in] rotMax the max rotation in binary angles + * @param[in] target the target rotation value + * @param[in] slowness how slow to rotate, the larger the number the slower the rotation, cannot be 0 + * @param[in] stepMin the minimun step in degrees + * @param[in] stepMax the maximum step in degrees + */ +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { + s16 prevRot = *rot; + f32 step; + f32 prevRotStep; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s") + step = (f32)(target - *rot) * (360.0f / (f32)0x10000); + step *= gFramerateDivisorHalf; + prevRotStep = step; + if (step >= 0.0f) { + step /= slowness; + step = CLAMP(step, stepMin, stepMax); + *rot += (s16)((step * (f32)0x10000) / 360.0f); + if (prevRotStep < stepMin) { + *rot = target; + } + if (rotMax != 0) { + *rot = CLAMP(*rot, -rotMax, rotMax); + } + } else { + step = (step / slowness) * -1.0f; + step = CLAMP(step, stepMin, stepMax); + *rot -= (s16)((step * (f32)0x10000) / 360.0f); + if (-stepMin < prevRotStep) { + *rot = target; + } + if (rotMax != 0) { + *rot = CLAMP(*rot, -rotMax, rotMax); + } + } + + return prevRot - *rot; +} + +/** + * Computes the necessary HeadRot and TorsoRot to smoothly turn an actors's head and torso to a point + * + * @param[in] point the point to turn to + * @param[in] focusPos the actor's focus postion + * @param[in] shapeRot the actor's shape rotation + * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards + * @param[in,out] headRot the computed head rotation + * @param[in,out] torsoRot the computed torso rotation + * @param[in] options various options to adjust how the actor turns, see `SubS_ComputeTurnToPointRot and + * TurnOptions/TurnOptionsSet` + * + */ +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, + TurnOptionsSet* options) { + s16 pitch; + s16 yaw; + s16 pad; + s16 targetY; + f32 diffX = point->x - focusPos->x; + s16 targetX; + f32 diffZ = point->z - focusPos->z; + + yaw = Math_FAtan2F(diffZ, diffX); + pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), point->y - focusPos->y); + Math_SmoothStepToS(&turnTarget->x, pitch, 4, 0x2710, 0); + Math_SmoothStepToS(&turnTarget->y, yaw, 4, 0x2710, 0); + + targetX = + SubS_ComputeTurnToPointRot(&headRot->x, options->headRotX.rotMax, turnTarget->x, options->headRotX.slowness, + options->headRotX.rotStepMin, options->headRotX.rotStepMax); + //! @bug: torsoRotX uses headRotX slowness + SubS_ComputeTurnToPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, + options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); + + targetY = turnTarget->y - shapeRot->y; + SubS_ComputeTurnToPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, + options->headRotY.rotStepMin, options->headRotY.rotStepMax); + SubS_ComputeTurnToPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, + options->torsoRotY.slowness, options->torsoRotY.rotStepMin, + options->torsoRotY.rotStepMax); + + return true; +} s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; @@ -987,4 +1111,51 @@ s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s") +/** + * Computes the necessary HeadRot and TorsoRot steps to be added to the normal rotation to smoothly turn an actors's + * head and torso to a point + * + * @param[in] worldPos the actor's world position + * @param[in] focusPos the actor's focus position + * @param[in] shapeYRot the actor's shape's Y rotation + * @param[in] yawTarget the target point to determine desired yaw + * @param[in] pitchTarget the target point to determine desired pitch + * @param[in,out] headZRotStep the computed actors' head's Z rotation step + * @param[in,out] headXRotStep the computed actors' head's X rotation step + * @param[in,out] torsoZRotStep the computed actors' torso's Z rotation step + * @param[in,out] torsoXRotStep the computed actors' torso's X rotation step + * @param[in] headZRotStepMax the max head's Z rotation step + * @param[in] headXRotStepMax the max head's X rotation step + * @param[in] torsoZRotStepMax the max torso's Z rotation step + * @param[in] torsoXRotStepMax the max torso's X rotation step + */ +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, + s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, + u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { + s16 yaw = Math_Vec3f_Yaw(worldPos, yawTarget) - shapeYRot; + s16 pad; + s16 pad2; + s16 pitch = Math_Vec3f_Pitch(focusPos, pitchTarget); + + if (BINANG_ADD(headXRotStepMax, torsoXRotStepMax) >= (s16)ABS(yaw)) { + Math_ApproachS(headXRotStep, yaw - *torsoXRotStep, 4, 0x2AA8); + *headXRotStep = CLAMP(*headXRotStep, -headXRotStepMax, headXRotStepMax); + Math_ApproachS(torsoXRotStep, yaw - *headXRotStep, 4, 0x2AA8); + *torsoXRotStep = CLAMP(*torsoXRotStep, -torsoXRotStepMax, torsoXRotStepMax); + } else { + Math_ApproachS(headXRotStep, 0, 4, 0x2AA8); + Math_ApproachS(torsoXRotStep, 0, 4, 0x2AA8); + } + + if (BINANG_ADD(headZRotStepMax, torsoZRotStepMax) >= (s16)ABS(pitch)) { + Math_ApproachS(headZRotStep, pitch - *torsoZRotStep, 4, 0x2AA8); + *headZRotStep = CLAMP(*headZRotStep, -headZRotStepMax, headZRotStepMax); + Math_ApproachS(torsoZRotStep, pitch - *headZRotStep, 4, 0x2AA8); + *torsoZRotStep = CLAMP(*torsoZRotStep, -torsoZRotStepMax, torsoZRotStepMax); + } else { + Math_ApproachS(headZRotStep, 0, 4, 0x2AA8); + Math_ApproachS(torsoZRotStep, 0, 4, 0x2AA8); + } + + return true; +} diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 2c23601f7..18548675d 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -301,25 +301,25 @@ void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { DmAn* this = THIS; - s16 phi_v1; - s16 phi_v0; + s16 stepRot; + s16 overrideRot; if (!(this->unk_2AE & 1)) { if (this->unk_2AE & 2) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == OBJECT_AN1_LIMB_09) { - func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, - this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, - phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, + &this->unk_1A4, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -328,8 +328,8 @@ void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { - func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, - &this->unk_1AA, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -342,13 +342,13 @@ void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { TexturePtr D_80C1D2E8[] = { object_an1_Tex_00E6E0, - &object_an1_Tex_00F7A0, - &object_an1_Tex_0101A0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, }; TexturePtr D_80C1D2F4[] = { - &object_an1_Tex_00E1E0, &object_an1_Tex_00EFA0, &object_an1_Tex_00F3A0, &object_an1_Tex_00EFA0, - &object_an1_Tex_00FDA0, &object_an1_Tex_00F9A0, &object_an1_Tex_0103A0, + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, }; void func_80C1D0B0(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 88a99ad53..969b7a80b 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -301,25 +301,25 @@ void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { DmGm* this = THIS; - s16 phi_v1; - s16 phi_v0; + s16 stepRot; + s16 overrideRot; if (!(this->unk_2AE & 1)) { if (this->unk_2AE & 2) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == OBJECT_AN1_LIMB_09) { - func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, - this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, - phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, + &this->unk_1A4, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -328,8 +328,8 @@ void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { - func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, - &this->unk_1AA, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 732b3e37b..405c2ffb4 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -564,7 +564,7 @@ void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnAh* this = THIS; if (limbIndex == 7) { @@ -573,27 +573,27 @@ void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnAh* this = THIS; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (!(this->unk_2D8 & 0x80)) { if (this->unk_2D8 & 0x20) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == 7) { - func_8013AD9C(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), - BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, - this->unk_200, phi_v1, phi_v0); + SubS_UpdateLimb(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), + BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -602,8 +602,8 @@ void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == 2) { - func_8013AD9C(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), - &this->unk_1E8[1], &this->unk_200[1], phi_v1, phi_v0); + SubS_UpdateLimb(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), + &this->unk_1E8[1], &this->unk_200[1], stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -626,7 +626,8 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, func_80BD3AA8, func_80BD3AF8, &this->actor); + this->skelAnime.dListCount, NULL, EnAh_PostLimbDraw, EnAh_TransformLimbDraw, + &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 149f82d45..063c50b61 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -871,24 +871,24 @@ void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnAl* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_4C2 & 0x200)) { if (this->unk_4C2 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == 16) { - func_8013AD9C(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, - &this->unk_378, phi_v0, phi_v1); + SubS_UpdateLimb(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, + &this->unk_378, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 28b6251a1..b949b4be3 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -462,24 +462,29 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { } void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { - static u16 D_809C392C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2D4, &this->unk_2DA, - &this->unk_2E0, D_809C392C); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk_2D4.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2D4.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DA.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DA.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E0.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_809C10B0(this, 3); SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); @@ -500,9 +505,9 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->unk_2D4; - this->unk_2EC = this->unk_2DA; - this->unk_2F2 = this->unk_2E0; + this->unk_2E6 = this->turnTarget; + this->unk_2EC = this->headRot; + this->unk_2F2 = this->torsoRot; func_809C16DC(this, globalCtx); this->actionFunc = func_809C21E0; } else { @@ -751,9 +756,9 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { - this->unk_2D4 = this->unk_2E6; - this->unk_2DA = this->unk_2EC; - this->unk_2E0 = this->unk_2F2; + this->turnTarget = this->unk_2E6; + this->headRot = this->unk_2EC; + this->torsoRot = this->unk_2F2; this->actor.parent = NULL; this->actor.shape.rot.y = this->actor.world.rot.y; if (gSaveContext.save.weekEventReg[8] & 0x20) { @@ -822,9 +827,9 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { - this->unk_2D4 = this->unk_2E6; - this->unk_2DA = this->unk_2EC; - this->unk_2E0 = this->unk_2F2; + this->turnTarget = this->unk_2E6; + this->headRot = this->unk_2EC; + this->torsoRot = this->unk_2F2; this->unk_434 = 0; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -995,14 +1000,14 @@ s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->headRot.x * -1, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { - Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->torsoRot.y * -1, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->torsoRot.x * -1, MTXMODE_APPLY); } if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index 69e15f658..d4ed3e71e 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -21,9 +21,9 @@ typedef struct EnAob01 { /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; - /* 0x2D4 */ Vec3s unk_2D4; - /* 0x2DA */ Vec3s unk_2DA; - /* 0x2E0 */ Vec3s unk_2E0; + /* 0x2D4 */ Vec3s turnTarget; + /* 0x2DA */ Vec3s headRot; + /* 0x2E0 */ Vec3s torsoRot; /* 0x2E6 */ Vec3s unk_2E6; /* 0x2EC */ Vec3s unk_2EC; /* 0x2F2 */ Vec3s unk_2F2; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 4d9c7bad3..9295b03a5 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -121,7 +121,12 @@ static u8 D_80BAA488[] = { s32 D_80BAA4A8[] = { -1, -1, 0 }; -u16 D_80BAA4B4[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; s32 func_80BA8820(EnBaba* this, GlobalContext* globalCtx) { this->unk_144 = (EnOssan*)SubS_FindActor(globalCtx, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); @@ -285,25 +290,25 @@ s32 func_80BA8D2C(EnBaba* this, f32 arg1) { void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && !(this->unk_40A & 4)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2DE, &this->unk_2E4, - &this->unk_2EA, D_80BAA4B4); + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk_2DE.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DE.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E4.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E4.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2EA.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2EA.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } SubS_FillLimbRotTables(globalCtx, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); @@ -696,14 +701,14 @@ s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (limbIndex == 6) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2E4.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk_2E4.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 5) { - Matrix_InsertXRotation_s(-this->unk_2EA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk_2EA.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index d26e68625..6a21168b6 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -32,9 +32,9 @@ typedef struct EnBaba { /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; /* 0x0206 */ Vec3s jointTable[18]; /* 0x0272 */ Vec3s morphTable[18]; - /* 0x02DE */ Vec3s unk_2DE; - /* 0x02E4 */ Vec3s unk_2E4; - /* 0x02EA */ Vec3s unk_2EA; + /* 0x02DE */ Vec3s turnTarget; + /* 0x02E4 */ Vec3s headRot; + /* 0x02EA */ Vec3s torsoRot; /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; /* 0x0302 */ s16 unk_302[18]; /* 0x0326 */ s16 unk_326[18]; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 883d4dd60..61d4df146 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -97,22 +97,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -u16 D_809CCCD8[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; EnHy_UpdateSkelAnime(&this->enHy, globalCtx); if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, - &this->enHy.headRot, &this->enHy.torsoRot, D_809CCCD8); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -129,7 +134,7 @@ s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpTurnTarget = this->enHy.turnTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -192,7 +197,7 @@ void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->focusTarget = this->tmpFocusTarget; + this->turnTarget = this->tmpTurnTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 20173ed15..43c09df0c 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -73,14 +73,14 @@ static AnimationSpeedInfo D_809CDC7C[] = { void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp58; + Vec3f pitchTarget; s32 pad[2]; - Math_Vec3f_Copy(&sp58, &player->actor.world.pos); - sp58.y = player->bodyPartsPos[7].y + 3.0f; - func_8013E950(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, &player->actor.world.pos, - &sp58, &this->headZRotAdj, &this->headXRotAdj, &this->torsoZRotAdj, &this->torsoXRotAdj, 0x1554, - 0x1FFE, 0xE38, 0x1C70); + Math_Vec3f_Copy(&pitchTarget, &player->actor.world.pos); + pitchTarget.y = player->bodyPartsPos[7].y + 3.0f; + SubS_TurnToPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, + &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, + &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { @@ -406,12 +406,12 @@ s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } switch (limbIndex) { case BJI_LIMB_TORSO: - rot->x += this->torsoXRotAdj; - rot->z += this->torsoZRotAdj; + rot->x += this->torsoXRotStep; + rot->z += this->torsoZRotStep; break; case BJI_LIMB_HEAD: - rot->x += this->headXRotAdj; - rot->z += this->headZRotAdj; + rot->x += this->headXRotStep; + rot->z += this->headZRotStep; break; } return false; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h index b1ed3f8af..c49da8bd2 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h @@ -45,10 +45,10 @@ typedef struct EnBji01 { /* 0x29C */ s16 eyeTexIndex; /* 0x29E */ s16 blinkSeqIndex; /* 0x2A0 */ s16 blinkTimer; - /* 0x2A2 */ s16 torsoZRotAdj; - /* 0x2A4 */ s16 torsoXRotAdj; - /* 0x2A6 */ s16 headZRotAdj; - /* 0x2A8 */ s16 headXRotAdj; + /* 0x2A2 */ s16 torsoZRotStep; + /* 0x2A4 */ s16 torsoXRotStep; + /* 0x2A6 */ s16 headZRotStep; + /* 0x2A8 */ s16 headXRotStep; /* 0x2AA */ u16 textId; /* 0x2AC */ s16 cutscenes[1]; /* 0x2B0 */ ObjMoonStone* moonsTear; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 53198c594..e65e0dfe9 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -89,22 +89,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -u16 D_809CBF58[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; EnHy_UpdateSkelAnime(&this->enHy, globalCtx); if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, - &this->enHy.headRot, &this->enHy.torsoRot, D_809CBF58); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -121,7 +126,7 @@ s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpTurnTarget = this->enHy.turnTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -182,7 +187,7 @@ void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->focusTarget = this->tmpFocusTarget; + this->turnTarget = this->tmpTurnTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index e598fe78f..8430547ab 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1779,25 +1779,25 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnGm* this = THIS; - s32 phi_v0 = 1; - s32 phi_v1 = 0; + s32 overrideRot = true; + s32 stepRot = false; if (!(this->unk_3A4 & 0x200)) { if (this->unk_3A4 & 0x80) { - phi_v0 = 1; - phi_v1 = 1; + overrideRot = true; + stepRot = true; } else { - phi_v0 = 0; - phi_v1 = 1; + overrideRot = false; + stepRot = true; } } else { - phi_v0 = 0; + overrideRot = false; } if (limbIndex == 16) { - func_8013AD9C(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), - BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, - &this->unk_2A8, phi_v1, phi_v0); + SubS_UpdateLimb(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), + BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, + &this->unk_2A8, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -1806,8 +1806,8 @@ void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == 9) { - func_8013AD9C(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), - &this->unk_29C, &this->unk_2AE, phi_v1, phi_v0); + SubS_UpdateLimb(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), + &this->unk_29C, &this->unk_2AE, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index c05de7ab8..c34b3e9a3 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -2011,30 +2011,30 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnGo* this = THIS; u16 temp_v0; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (this->unk_390 & 0x40) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_390 & 0x10) { - phi_v0 = true; + overrideRot = true; } else { - phi_v0 = false; + overrideRot = false; } - if (!phi_v1) { - phi_v0 = false; + if (!stepRot) { + overrideRot = false; } switch (limbIndex) { case 17: - func_8013AD9C(this->unk_3B0 + this->unk_3B4 + 0x4000, - this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, - &this->unk_2A8, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_3B0 + this->unk_3B4 + 0x4000, + this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, + &this->unk_2A8, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -2045,8 +2045,8 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this break; case 10: - func_8013AD9C(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, - &this->unk_2AE, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, + &this->unk_2AE, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index bbb706326..c9f4f9b70 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -997,24 +997,24 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnIg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnIg* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_3D0 & 0x200)) { if (this->unk_3D0 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == 9) { - func_8013AD9C(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, - &this->unk_2E6, phi_v0, phi_v1); + SubS_UpdateLimb(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, + &this->unk_2E6, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 758543f45..7dcaf7b64 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -139,8 +139,11 @@ static AnimationInfoS sAnimations[] = { { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; -static u16 D_808F6C0C[] = { - 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, }; s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { @@ -228,24 +231,24 @@ s32 func_808F33B8(void) { void func_808F3414(EnIn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; if (this->unk23D == 0) { this->unk494 = SkelAnime_Update(&this->skelAnime); } if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk352, &this->unk358, - &this->unk35E, D_808F6C0C); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk352.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk352.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_808F322C(this, 3); func_808F3178(this, globalCtx); @@ -1541,14 +1544,14 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 16) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk358.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk358.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->unk35E.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35E.x, MTXMODE_APPLY); + Matrix_RotateY(this->torsoRot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index 0a6f4be75..ae339ecaa 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,9 +36,9 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ Vec3s unk352; - /* 0x358 */ Vec3s unk358; - /* 0x35E */ Vec3s unk35E; + /* 0x352 */ Vec3s turnTarget; + /* 0x358 */ Vec3s headRot; + /* 0x35E */ Vec3s torsoRot; /* 0x364 */ char unk364[0x12]; /* 0x376 */ s16 unk376[20]; /* 0x39E */ s16 unk39E[20]; diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index b02b6f4ee..e6bc31eea 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -523,30 +523,30 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnJa* this = THIS; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (this->unk_340 & 0x10) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_340 & 0x20) { - phi_v0 = true; + overrideRot = true; } else { - phi_v0 = false; + overrideRot = false; } - if (!phi_v1) { - phi_v0 = false; + if (!stepRot) { + overrideRot = false; } if (limbIndex != 8) { if (limbIndex == 15) { - func_8013AD9C(this->unk_354 + this->unk_358 + 0x4000, - this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, - &this->unk_274, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_354 + this->unk_358 + 0x4000, + this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, + &this->unk_274, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -556,8 +556,8 @@ void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this Matrix_StatePush(); } } else { - func_8013AD9C(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, - &this->unk_27A, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, + &this->unk_27A, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 633526f81..b19f64c4d 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -2143,26 +2143,26 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 arg1, Actor* thisx, Gfx** gfx) { +void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnPm* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_356 & 0x200)) { if (this->unk_356 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } - if (arg1 == 15) { - func_8013AD9C(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, - &this->unk_290, phi_v0, phi_v1); + if (limbIndex == 15) { + SubS_UpdateLimb(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, + &this->unk_290, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 2ab16fb6a..808f38d5a 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -403,24 +403,24 @@ void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnShn* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_1D8 & 0x20)) { if (this->unk_1D8 & 0x10) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == BURLY_GUY_LIMB_HEAD) { - func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, - &this->unk_1F4, phi_v0, phi_v1); + SubS_UpdateLimb((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, + &this->unk_1F4, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 40ebeb21b..319cbbabd 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -120,8 +120,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static u16 D_80BAE800[] = { - 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, }; static u8 D_80BAE820[] = { @@ -516,7 +519,7 @@ void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; if (this->flags1 & 0x80) { EnSuttari_UpdateCollider(this, globalCtx); @@ -524,18 +527,18 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk2D6, &this->unk2DC, - &this->unk2E2, D_80BAE800); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk2D6.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2D6.y, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC.y, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } } SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); @@ -1014,12 +1017,12 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { func_80BAB434(this); if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA) { if (this->actor.playerHeightRel < 60.0f && this->actor.xzDistToPlayer < 500.0f) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; this->actionFunc = func_80BACBB0; } } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -1034,7 +1037,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 target; - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1064,7 +1067,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1232,7 +1235,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 4; EnSuttari_SetNextEntrance(globalCtx, 0xD670); } else { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); Actor_MoveWithGravity(&this->actor); func_80BAB374(this, globalCtx); @@ -1330,7 +1333,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags1 & 1) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAA9B4(this); } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { this->animationIndex = 1; @@ -1406,14 +1409,14 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[1] == -0x63) { this->actor.speedXZ = 0.0f; } else { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } Actor_MoveWithGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; @@ -1430,7 +1433,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] == -0x63) { Actor_MarkForDeath(&this->actor); } - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } @@ -1501,13 +1504,13 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (!(this->flags1 & 4)) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2DC.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->unk2E2.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2E2.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index c6f8cc153..2fbdff53b 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,9 +27,9 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ Vec3s unk2D6; - /* 0x2DC */ Vec3s unk2DC; - /* 0x2E2 */ Vec3s unk2E2; + /* 0x2D6 */ Vec3s turnTarget; + /* 0x2DC */ Vec3s headRot; + /* 0x2E2 */ Vec3s torsoRot; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index f1c9c6bbc..7c36af46f 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -584,25 +584,25 @@ void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTab* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 rotStep; + s32 overrideStep; if (!(this->unk_2FC & 0x40)) { if (this->unk_2FC & 0x10) { - phi_v1 = 1; + overrideStep = true; } else { - phi_v1 = 0; + overrideStep = false; } - phi_v0 = 1; + rotStep = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideStep = false; + rotStep = false; } if (limbIndex == 9) { - func_8013AD9C(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), - BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, - this->unk_200, phi_v0, phi_v1); + SubS_UpdateLimb(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), + BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, rotStep, overrideStep); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 7cf13c6af..3390b8422 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -1195,32 +1195,32 @@ void EnTru_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTru* this = THIS; s32 pad[3]; - s32 sp2C; - s32 phi_v1; + s32 overrideRot; + s32 stepRot; if (this->unk_34E & 0x10) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_34E & 0x20) { - sp2C = true; + overrideRot = true; } else { - sp2C = false; + overrideRot = false; } - if (!phi_v1) { - sp2C = false; + if (!stepRot) { + overrideRot = false; } if (limbIndex == 21) { - func_8013AD9C(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, phi_v1, - sp2C); + SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, + overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (sp2C) { + if (overrideRot) { s16 oldZ = this->unk_204.z; this->unk_204.z = this->unk_204.x; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 8759d3b86..95738b211 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -174,20 +174,25 @@ void EnZo_UpdateCollider(EnZo* this, GlobalContext* globalCtx) { } void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { - static u16 D_8099F5AC[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->actor.focus.pos, &this->actor.shape.rot, &this->headRotTarget, &this->headRot, - &this->upperBodyRot, D_8099F5AC); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->upperBodyRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->headRotTarget.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->headRotTarget.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 1000, 1); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 155c947d4..b5faef776 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -24,7 +24,7 @@ typedef struct EnZo { /* 0x01FD */ u8 isRightFootGrounded; /* 0x01FE */ Vec3s jointTable[20]; /* 0x0276 */ Vec3s morphTable[20]; - /* 0x02EE */ Vec3s headRotTarget; + /* 0x02EE */ Vec3s turnTarget; /* 0x02F4 */ Vec3s headRot; /* 0x02FA */ Vec3s upperBodyRot; /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index eac58c3e6..0c114748a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2659,7 +2659,7 @@ 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), 0x8013AD6C:("SubS_InCsMode",), - 0x8013AD9C:("func_8013AD9C",), + 0x8013AD9C:("SubS_UpdateLimb",), 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), 0x8013B010:("func_8013B010",), @@ -2679,8 +2679,8 @@ 0x8013CC2C:("SubS_FillShadowTex",), 0x8013CD64:("SubS_GenShadowTex",), 0x8013CF04:("SubS_DrawShadowTex",), - 0x8013D0E0:("func_8013D0E0",), - 0x8013D2E0:("func_8013D2E0",), + 0x8013D0E0:("SubS_ComputeTurnToPointRot",), + 0x8013D2E0:("SubS_TurnToPoint",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), 0x8013D648:("SubS_GetPathByIndex",), 0x8013D68C:("SubS_CopyPointFromPath",), @@ -2709,7 +2709,7 @@ 0x8013E748:("func_8013E748",), 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("func_8013E950",), + 0x8013E950:("SubS_TurnToPointStep",), 0x8013EC10:("func_8013EC10",), 0x8013EC44:("func_8013EC44",), 0x8013ECE0:("func_8013ECE0",), @@ -15758,8 +15758,8 @@ 0x80BD3854:("EnAh_Init",), 0x80BD396C:("EnAh_Destroy",), 0x80BD3998:("EnAh_Update",), - 0x80BD3AA8:("func_80BD3AA8",), - 0x80BD3AF8:("func_80BD3AF8",), + 0x80BD3AA8:("EnAh_PostLimbDraw",), + 0x80BD3AF8:("EnAh_TransformLimbDraw",), 0x80BD3CAC:("EnAh_Draw",), 0x80BD4090:("ObjHgdoor_SetChild",), 0x80BD40D0:("func_80BD40D0",), diff --git a/tools/namefixer.py b/tools/namefixer.py index db7d97e82..7ce3790db 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -422,10 +422,6 @@ wordReplace = { "func_8016A0AC": "Play_IsUnderwater", "func_801690CC": "Play_InCsMode", "func_8017D2FC": "Math3D_LineSegVsPlane", - "func_8013A7C0": "SubS_FindDoor", - "func_8013E640": "SubS_FindActorCustom", - "func_ActorCategoryIterateById": "SubS_FindActor", - "func_8013BB7C": "SubS_FindNearestActor", "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", @@ -443,11 +439,6 @@ wordReplace = { "func_800EE2F4": "Cutscene_IsPlaying", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", - "func_8013AB00": "SubS_DrawTransformFlex", - "func_8013A860": "SubS_DrawTransformFlexLimb", - "func_8013BC6C": "SubS_ChangeAnimationByInfoS", - "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", - "func_8013D9C8": "SubS_FillLimbRotTables", "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", @@ -455,13 +446,23 @@ wordReplace = { "Quake2_SetType": "Distortion_SetType", "Quake2_SetCountdown": "Distortion_SetCountdown", "func_800BE680": "Actor_DrawDamageEffects", + "func_8012F22C": "Inventory_GetSkullTokenCount", + + "func_8013AB00": "SubS_DrawTransformFlex", + "func_8013A860": "SubS_DrawTransformFlexLimb", + "func_8013BC6C": "SubS_ChangeAnimationByInfoS", + "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", + "func_8013D9C8": "SubS_FillLimbRotTables", + "func_8013A7C0": "SubS_FindDoor", + "func_8013E640": "SubS_FindActorCustom", + "func_ActorCategoryIterateById": "SubS_FindActor", + "func_8013BB7C": "SubS_FindNearestActor", "func_8013E2D4": "SubS_StartActorCutscene", "func_8013E3B8": "SubS_FillCutscenesList", "func_8013AED4": "SubS_UpdateFlags", "func_8013D8DC": "SubS_IsObjectLoaded", "func_8013D924": "SubS_GetObjectIndex", "func_8013D5E8": "SubS_AngleDiffLessEqual", - "func_8012F22C": "Inventory_GetSkullTokenCount", "func_8013DCE0": "SubS_ActorPathing_Init", "func_8013DE04": "SubS_ActorPathing_Update", "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", @@ -480,6 +481,8 @@ wordReplace = { "func_8013DB90": "SubS_IsFloorAbove", "func_8013DC40": "SubS_CopyPointFromPathList", "func_8013DCCC": "SubS_GetPathCount", + "func_8013AD9C": "SubS_UpdateLimb", + "func_8013D2E0": "SubS_TurnToPoint", "func_80147624": "Message_ShouldAdvance", "func_80147734": "Message_ShouldAdvanceSilent", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 8452179ab..ffff2a55b 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2173,7 +2173,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFlexLimb,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC -asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E +asm/non_matchings/code/z_sub_s/SubS_UpdateLimb.s,SubS_UpdateLimb,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E @@ -2193,8 +2193,8 @@ asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 -asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 -asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 +asm/non_matchings/code/z_sub_s/SubS_ComputeTurnToPointRot.s,SubS_ComputeTurnToPointRot,0x8013D0E0,0x80 +asm/non_matchings/code/z_sub_s/SubS_TurnToPoint.s,SubS_TurnToPoint,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 @@ -2223,7 +2223,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x801 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 -asm/non_matchings/code/z_sub_s/func_8013E950.s,func_8013E950,0x8013E950,0xB0 +asm/non_matchings/code/z_sub_s/SubS_TurnToPointStep.s,SubS_TurnToPointStep,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD asm/non_matchings/code/code_8013EC10/func_8013EC44.s,func_8013EC44,0x8013EC44,0x27 asm/non_matchings/code/code_8013EC10/func_8013ECE0.s,func_8013ECE0,0x8013ECE0,0x2F From c2afdf6eb01398ce0f237268da3dbd20247c8c33 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 19:01:46 -0700 Subject: [PATCH 10/53] EffectSsLightning OK (#800) * OK * Document and gameplay keep * cleanup * Rotate -> Rot * Update description --- assets/xml/objects/gameplay_keep.xml | 18 +-- spec | 3 +- .../z_eff_ss_lightning.c | 144 +++++++++++++++++- tools/disasm/functions.txt | 2 +- 4 files changed, 147 insertions(+), 20 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 41b144120..8328b14ab 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1062,15 +1062,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/spec b/spec index 137ff6249..b223f113c 100644 --- a/spec +++ b/spec @@ -1857,8 +1857,7 @@ beginseg name "ovl_Effect_Ss_Lightning" compress include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.o" - include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.data.o" - include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c index ad2ef29a5..15fdcfc50 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c @@ -1,29 +1,157 @@ /* * File: z_eff_ss_lightning.c * Overlay: ovl_Effect_Ss_Lightning - * Description: + * Description: Electric Discharge */ #include "z_eff_ss_lightning.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rNumBolts regs[8] +#define rScale regs[9] +#define rYaw regs[10] +#define rLifespan regs[11] #define PARAMS ((EffectSsLightningInitParams*)initParamsx) -s32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 +TexturePtr sLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; + const EffectSsInit Effect_Ss_Lightning_InitVars = { EFFECT_SS_LIGHTNING, EffectSsLightning_Init, }; -#endif +static s32 sIsDesegmented = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Init.s") +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsLightningInitParams* initParams = PARAMS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/func_8097A794.s") + this->pos = initParams->pos; + this->gfx = gEffLightningDL; + this->life = initParams->life; + this->draw = EffectSsLightning_Draw; + this->update = EffectSsLightning_Update; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rEnvColorA = initParams->envColor.a; + this->rNumBolts = initParams->numBolts; + this->rScale = initParams->scale; + this->rYaw = initParams->yaw; + this->rLifespan = initParams->life; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Draw.s") + if (!sIsDesegmented) { + for (i = 0; i < ARRAY_COUNT(sLightningTextures); i++) { + sLightningTextures[i] = Lib_SegmentedToVirtual(sLightningTextures[i]); + } + sIsDesegmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Update.s") + return 1; +} + +void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s32 yaw, EffectSs* this) { + EffectSs newLightning; + + EffectSS_Delete(&newLightning); + newLightning = *this; + newLightning.pos = *pos; + newLightning.rNumBolts--; + newLightning.rYaw = yaw; + newLightning.life = newLightning.rLifespan; + + EffectSS_Copy(globalCtx, &newLightning); +} + +void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mfResult; + MtxF mfTrans; + MtxF mfScale; + MtxF mfRot; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + Mtx* mtx; + f32 yScale; + s32 texIndex; + f32 xzScale; + + OPEN_DISPS(gfxCtx); + + yScale = this->rScale * 0.01f; + texIndex = this->rLifespan - this->life; + + if (texIndex >= ARRAY_COUNT(sLightningTextures)) { + texIndex = ARRAY_COUNT(sLightningTextures) - 1; + } + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + xzScale = yScale * 0.6f; + SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale); + SkinMatrix_SetRotateRPY(&mfRot, this->vec.x, this->vec.y, this->rYaw); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &mfScale, &mfResult); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, sLightningTextures[texIndex]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + Vec3f pos; + s32 yaw; + f32 scale; + s32 sign; + + if ((this->rNumBolts != 0) && ((this->life + 1) == this->rLifespan)) { + sign = (Rand_ZeroOne() < 0.5f) ? -1 : 1; + yaw = this->rYaw + sign * ((s32)((Rand_ZeroOne() * 3640.0f)) + 0xE38); + scale = (this->rScale * 0.01f) * 80.0f; + + pos.y = this->pos.y + (Math_SinS(this->rYaw - 0x4000) * scale); + + scale = Math_CosS(this->rYaw - 0x4000) * scale; + pos.x = this->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + + EffectSsLightning_NewLightning(globalCtx, &pos, yaw, this); + + if (Rand_ZeroOne() < 0.1f) { + EffectSsLightning_NewLightning(globalCtx, &pos, (this->rYaw * 2) - yaw, this); + } + } +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0c114748a..86758415a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8165,7 +8165,7 @@ 0x8097A548:("EffectSsGFire_Draw",), 0x8097A5F0:("EffectSsGFire_Update",), 0x8097A680:("EffectSsLightning_Init",), - 0x8097A794:("func_8097A794",), + 0x8097A794:("EffectSsLightning_NewLightning",), 0x8097A838:("EffectSsLightning_Draw",), 0x8097AA98:("EffectSsLightning_Update",), 0x8097AD60:("EffectSsDtBubble_Init",), From 0582c636b84462754b27713a1ff3b69a7974f599 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Thu, 26 May 2022 03:06:21 +0100 Subject: [PATCH 11/53] Contributing docs refresh (#793) * Contributing docs refresh * Apply suggestions from code review Co-authored-by: LtPeriwinkle <62761190+LtPeriwinkle@users.noreply.github.com> * Link MM tutorial * Add link to XML spec * Review Co-authored-by: LtPeriwinkle <62761190+LtPeriwinkle@users.noreply.github.com> --- .github/pull_request_template.md | 9 -- .gitignore | 1 + CONTRIBUTING.md | 133 ++++++++---------- README.md | 24 ++-- REVIEWING.md | 67 --------- docs/REVIEWING.md | 59 ++++++++ docs/STYLE.md | 232 +++++++++++++++++++++++++++++++ 7 files changed, 362 insertions(+), 163 deletions(-) delete mode 100644 .github/pull_request_template.md delete mode 100644 REVIEWING.md create mode 100644 docs/REVIEWING.md create mode 100644 docs/STYLE.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 299e41853..000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,9 +0,0 @@ -Before opening this PR, ensure the following: -- `./format.sh` was run to apply standard formatting. -- `make` successfully builds a matching ROM. -- No new compiler warnings were introduced during the build process. - - Can be verified locally by running `tools/warnings_count/check_new_warnings.sh` -- New variables & functions should follow standard naming conventions. -- Comments and variables have correct spelling. ---- - diff --git a/.gitignore b/.gitignore index a2acf29c3..80fe09807 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ tools/mips_to_c/ # Docs !docs/**/*.png +docs/doxygen/ !.vscode/extensions.json # Per-user configuration diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ee29e99e..e0839bb2d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ -Contributing to the Majora's Mask Decompilation Project -======================================================= +# Contributing to the Majora's Mask Decompilation Project + Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! All contributions are welcome. This is a group effort, and even small contributions can make a difference. Some tasks also don't require much knowledge to get started. @@ -10,21 +10,19 @@ For general information about the project, see [our readme](https://github.com/z Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. -Useful Links ------------- - -- [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. +## Useful Links - [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. -- [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. +- [Style Guide](docs/STYLE.md) - Description of the project style that we ask contributors to adhere to. +- [Code Review Guidelines](docs/REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/) - Our homepage, with links to other resources. -- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - A very detailed tutorial on how to get started with decomp. For OOT, but largely applicable to MM as well. -- The `#resources` channel on the Discord contains many more links +- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. +- [MM decomp tutorial](docs/tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. +- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - The tutorial the MM one was based on. For OOT, but largely applicable to MM as well. Covers slightly different topics, including how to get your data OK with `vbindiff`. +- The `#resources` channel on the Discord contains many more links on specific details of decompiling IDO MIPS code. -Getting Started ---------------- + +## Getting Started ### What should I know to take part? @@ -32,11 +30,14 @@ Basic knowledge of C, particularly arrays and pointers, is extremely useful. Kno You should be familiar with using git and GitHub. There are a number of tutorials available online, [such as this one](https://github.com/firstcontributions/first-contributions) which can help you get started. -The most useful knowledge to have is a general understanding of how the game works. An afternoon of constructive mucking about in the [OOT Practice Rom](http://practicerom.com/) (aka GZ) or the [MM Practice Rom](https://kz.zeldacodes.org/) (aka KZ) will be very beneficial if you have not looked at either of the N64 Zelda's internals before. -The [OOT Decompilation Project](https://github.com/zeldaret/oot) is farther along than this project, so it can also be a great resource. +The most useful knowledge to have is a general understanding of how the game works. An afternoon of constructive mucking about in the [MM Practice Rom](https://kz.zeldacodes.org/) (aka KZ) or the [OoT Practice Rom](http://practicerom.com/) (aka GZ) will be very beneficial if you have not looked at either of the N64 Zelda's internals before. + +The [OoT Decompilation Project](https://github.com/zeldaret/oot) is farther along than this project, so it can also be a great resource. This project only uses *publicly available code*. -Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64. + + +**N.B.** Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64. ### Environment Setup @@ -46,53 +47,28 @@ You should be able to build a matching ROM before you start making any changes. ### First Contribution Usually, the best place to get started is to decompile an actor overlay. -An *actor* is any thing in the game that moves or performs actions or interactions. This includes things like Link, enemies, NPCs, doors, pots, etc. +An *actor* is any thing in the game that moves or performs actions or interactions. This includes things like Link, enemies, NPCs, doors, pots, etc. Actors are good for a first file because they are generally small, self-contained systems. -You should [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. +We recommend that you [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. -We track who is working on what on the [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro). -After joining the Discord, open the Google Sheets reservation board so you can claim your code file and avoid duplicate work. +We track who is working on what on some Google Sheets available in the Discord. Once you've decided on or been recommended a good first file, mark it as Reserved. -The work flow is: Reserve a file, decompile it, submit a PR, and then repeat while addressing review comments. The expectation is that one reservation goes to one file which ends up in a one file PR. +The workflow is: +- Reserve a file, +- decompile it, +- submit a PR, +- repeat while addressing review comments. -Please note that unless it is communicated beforehand you will be expected to fully complete the file if you reserve it on Google Sheets reservation board. Exceptions are always easy to approve if it's communicated to the team. Real life circumstances can prevent someone from finishing. In these cases they should link their repo/branch in the Google Sheets reservation board and unreserve immediately. Communicate any issues with your reservations as early as possible. +The expectation is that one reservation goes to one file which ends up in a one file PR, although naturally some files are more sensibly worked on as a group, for example two actors that work together. This also does not apply to large asset files like `gameplay_keep`: you can just reserve the parts that are used in your files. -Style Guide & Conventions -------------------------- +If possible, we expect reserved files to be completed. If you find you cannot complete a file, because it is intractable for one reason or another, or real-life circumstances get in the way, please talk to one of the leads in Discord; we may find someone else interested in helping you finish, or who is happy to take over the file from you completely. If you unreserve a file on which you have useful progress, please leave a link to your branch in the Notes column on the Google Sheet that the next person who works on the file can use. -Most of the C formatting style is enforced by the `format.sh` script which is based on `clang-format`. -Running `./format.sh` will apply our standard style to all `.c` files in the repository. -There are some conventions that cannot be automatically enforced. +## Style Guide & Conventions -### Naming Scheme +See the [Style Guide](docs/STYLE.md). -The following overlays are good examples of our naming conventions: - -- [`ovl_Dm_Ravine`](src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c) -- [`ovl_En_Jc_Mato`](src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c) - -These files demonstrate the following: - -- Word order in names are from least-to-most specific (`DM_RAVINE_STATE_ACTIVE`, not `DM_RAVINE_ACTIVE_STATE`) -- Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) - - "Methods" for objects separate the object from the verb with an underscore (`DmRavine_Init`) -- Variable names are `camelCase` (`actionFunc`) - - Global variables start with `g` (`gSaveContext`) - - Static global variables start with `s` (`sSphereInit`) -- Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) -- Public structs, enums, and constants should be defined in the header file in the following cases: - - The primary `Actor` struct (`DmRavine`) - - The actor's `InitVars`, as an `extern` symbol (`Dm_Ravine_InitVars`) - - Types used in other public declarations, like `actionFunc` typedefs (`DmRavineActionFunc`) - - Macros and enums for accessing & setting actor `params` - - The struct/enum/define is needed by other files -- Trailing commas in array and struct definitions (see `EnJcMatoDamageTable`) -- Constants converted to whichever looks best in context: hexadecimal, decimal, or float - - Rotation angles should always be in hexadecimal -- Define macros for bitwise access to `actor->params` - -### `NON_MATCHING` & `NON_EQUIVALENT` +## `NON_MATCHING` and `NON_EQUIVALENT` If you make significant progress on decompiling a function, but can't get it to match perfectly, you can use a `NON_MATCHING` block to commit your code but have it excluded from the build, like so: @@ -102,20 +78,23 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { // ... } #else +void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v); #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s") #endif ``` -Before using `NON_MATCHING`, first try to use the [decomp-permuter](tools/decomp-permuter) tool to find a closer match. +Before PRing with a `NON_MATCHING`, you can try +- using the [decomp-permuter](tools/decomp-permuter) to find a closer match, +- Asking in `#mm-decomp-help` in Discord; the easiest way to allow other people to play around with the function you are stuck on is to make a scratch on [decomp.me](http://decomp.me). `NON_EQUIVALENT` can be used with the same syntax as `NON_MATCHING`, but it is used to mark sections of code which do not match *and* do not have the same behavior as the original code. -### Matching vs. Documenting +## Matching and Documenting Usually, the first step of decompiling a section of code is to get it *matching*: to produce a C version of the code that can be compiled into an identical ROM. However, the goal of this project is to produce a codebase that can be understood and modified. -So, beyond producing matching C code, the next steps are *documenting* the code. +Therefore once C code produces matching assembly, the next step is to *document* the code. Documenting is more than just adding comments. Documenting also includes: @@ -123,22 +102,19 @@ Documenting is more than just adding comments. Documenting also includes: - Using (or adding) constants, enums, and macros when possible - Explaining sections of code that are not straightforward -Overlays are not required to be documented at this time, but `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as possible. +Overlays are not required to be documented at this time, but files from `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as reasonable. -For right now, object segment symbols should not be documented/renamed. -These will be given names when object reconstruction is ready. -However, it can be useful to add comments with name suggestions. +See the [Style Guide](docs/STYLE.md) for more details on documentation style. -Pull Requests (PRs) -------------------- +## Pull Requests (PRs) ### Checklist Before opening a PR, walk through the following steps to ensure that your code conforms to the style guide and conventions. -- `./format.sh` was run to apply standard formatting. - `make` successfully builds a matching ROM. +- `./format.sh` was run to apply standard formatting. - No new compiler warnings were introduced during the build process. - Can be verified locally by running `tools/warnings_count/check_new_warnings.sh` - New variables & functions should follow standard naming conventions. @@ -148,15 +124,28 @@ Feel free to reach out on the Discord if you have any questions about these step ### Pull Request Process -After opening a PR, the Jenkins server will verify your changes. -If there is an error, double-check that you can successfully `make clean && make` locally. If the build is OK, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. +After opening a PR, the Jenkins agent will test formatting, the contents of the spec, build the rom and check for warnings. +If there is an error, double-check that you can successfully +```bash +make disasm +./extract_assets.py -f +make clean +make +``` +locally. If the build is `OK`, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. -Each PR needs a review from one reviewer and the project lead. +Each PR needs a review from two reviewers, at least one a project lead, and final approval from Kenix. -The PR author marks the comments as resolved: the commenter may not have permissions to do so. -Once all comments are addressed, it is courteous to ping the reviewer on either Discord or GitHub via re-requesting a review. +If the PR author agrees with a reviewer's suggestion, they make the change and resolve the conversation. If they disagree, have a better idea, or want to comment on something, they should at least leave a comment, and discuss it in Discord if it's not going to be resolved quickly, since long conversations on GitHub are hard to read. -After all the comments are addressed and at least one contributor has approved the review, the project lead can then review and merge the code. -The project lead is also responsible for ensuring that all of these procedures are followed. +Once all comments is addressed and all reviewers have approved, the PR will be merged. -Throughout the PR process, you (the author) should update the row on [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) with the appropriate information as the decompilation process progresses. +Project leads are responsible for ensuring that these conventions are followed. + +### Some git notes + +- You should work on a branch on your fork separate from your copy of master: it is always useful to have a clean master branch around if you need to fix something. +- When a PR is merged into master, it may conflict with your work. While your branch is private (in particular, not used for a PR), you can rebase, but when your branch is public/used for a PR always merge master instead of rebasing: it makes it much easier for people to understand what you changed since the last review. +- We squash commits when merging, so your commit history does not have to be completely spotless. + +Throughout the PR process, you (the author) should update the rows on the appropriate Google Sheets with the appropriate information as the decompilation process progresses. diff --git a/README.md b/README.md index c3ce27e97..f48230b90 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ ```diff - WARNING! - -The ROM this repository builds while has a matching checksum cannot be 'shifted' due -to hardcoded pointers which have yet to be dumped. Thus this repository is currently -in an experimental and research phase and cannot currently be used traditionally as a -source code base for general changes. +This repository is a work in progress, and while it can be used to make certain changes, it's +still constantly evolving. If you wish to use it for modding purposes in its current state, +please be aware that the codebase could drastically change at any time. Also note that some +parts of the ROM may not be 'shiftable' yet, so modifying them could currently be difficult. ``` -This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not producing a PC port.** For more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). +This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not, and will not, produce a PC port.** For frequently asked questions, you can visit [our website](https://zelda64.dev/mm), and for more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). -The only build currently supported is N64 US, but other versions are planned to be supported. +The only version currently supported is N64 US, but we intend to eventually support every retail version of the original game (i.e. not versions of MM3D, which is a totally different game). It currently builds the following ROM: * mm.us.rev1.rom.z64 `md5: 2a0a8acb61538235bc1094d297fb6556` @@ -137,16 +137,10 @@ The disadvantage that the ordering of the terminal output is scrambled, so for d ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. -Some tasks also don't require much knowledge to get started. +Some work also doesn't require much knowledge to get started. Please note that is is our strict policy that *Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64.* -Most discussions happen on our [Discord Server](https://discord.zelda64.dev), where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. +Most discussions happen on our [Discord Server](https://discord.zelda64.dev), where you are welcome to ask if you need help getting started, or if you have any questions regarding this project or ZeldaRET's other decompilation projects. -For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md) and our [Code Review Guidelines](REVIEWING.md) to see what code quality guidelines we follow. - - -## FAQ - -### Q: Why does MM use transient assembly? -A: It is the view of the MM project leads that transient asm is safer than storing the disassembly in the repo. We feel like the C code is more transformative than a straight disassembly. \ No newline at end of file +For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md), [Style Guide](docs/STYLE.md) and our [Code Review Guidelines](docs/REVIEWING.md) to see what code quality guidelines we follow. diff --git a/REVIEWING.md b/REVIEWING.md deleted file mode 100644 index 74f9dbac5..000000000 --- a/REVIEWING.md +++ /dev/null @@ -1,67 +0,0 @@ -Reviewing Pull Requests to the Majora's Mask Decompilation Project -======================================================= - -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! -We invite all contributors to participate in our code review program. Every review submitted helps us keep code quality high and code merged in more quickly. - -This document is meant to be a set of tips and guidelines for reviewers of pull requests to the project. -For general information about the project, see [our readme](https://github.com/zeldaret/mm/blob/master/README.md). - -Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. - -Useful Links ------------- - -- [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. - -- [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.md) - Instructions for contributors. -- [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. - -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/) - Our homepage, with links to other resources. -- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - A very detailed tutorial on how to get started with decomp. For OOT, but largely applicable to MM as well. -- The `#resources` channel on the Discord contains many more links - -Getting Started ---------------- - -### What should I know to take part in the review process? - -You should first get yourself familiar with our [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. - -Pull Requests (PRs) ------------- - -### How to review a Pull Request - -- When reviewing a PR it is suggested that you follow the checklist outlined in this section. -- You are not required to check for all of the items in the checklist. It is meant as a guide. -- Once the PR author has addressed all of your comments, you should add a comment with approval to the PR to signify to the project leads that this PR has been through peer review. -- If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors. The project lead will have final say in these situations. All decisions will generally be guided by a consensus of contributors. - -### Reviewer Checklist -- [ ] Jenkins build is successful. - - [ ] `make` builds a matching ROM. - - [ ] Any new compiler warnings that were added are required for matching. Ensure there is good reason if the warnings files have changed. `./tools/warnings_count/warnings_build_current.txt` and `./tools/warnings_count/warnings_setup_current.txt` -- [ ] Files with NON_MATCHING functions have equivalent behaviour. (This will only be reviewed once we have shiftability since equivalence testing is easiest in game) -- [ ] `code` and `boot` segment files should be documented as much as possible. Overlays with documentation should be complete. - - [ ] Overlays with documentation should have macros to define access to parameters if the parameter uses bitwise access. The params should have an enum when it makes sense. -- [ ] `format.sh` was run. -- [ ] Comments and variables have correct spelling. -- [ ] The following should be declared in an Actor header file. There should be nothing else in the Actor header file. - - [ ] Main Actor struct - - [ ] Extern'd initVar data. - - [ ] Types used in the actor struct. Specific example would be actionFunc typedefs. - - [ ] Param field macros and/or enums. - - [ ] For any other additional `enum`/`struct`/`define`/`function`/`global`, there needs to be evidence it is needed in another file. -- [ ] New variables and functions should follow standard naming conventions. - - [ ] Constants are converted to whichever looks best in context: hexadecimal, decimal, or float - - [ ] Rotation angles should always be in hexadecimal - - [ ] Colour values should always be in decimal. - - [ ] Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) - - [ ] "Methods" for objects separate the system from the verb with an underscore (`DmRavine_Init`) - - [ ] Variable names are `camelCase` (`actionFunc`) - - [ ] Global variables start with `g` (`gSaveContext`) - - [ ] Static global variables start with `s` (`sSphereInit`) - - [ ] Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) - - [ ] Trailing commas in array and struct definitions (see `EnJcMatoDamageTable`) diff --git a/docs/REVIEWING.md b/docs/REVIEWING.md new file mode 100644 index 000000000..11545fb27 --- /dev/null +++ b/docs/REVIEWING.md @@ -0,0 +1,59 @@ +# Reviewing Pull Requests to the Majora's Mask Decompilation Project + +Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask*! +We encourage all contributors to participate in code review: this is your codebase too! +Every review submitted helps us keep code quality high and code merged in more quickly. + +This document is meant to be a set of tips and guidelines for reviewers of pull requests to the project. +For general information about the project, see [our readme](https://github.com/zeldaret/mm/blob/master/README.md). + +Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. + +Other links are available in the [CONTRIBUTING.md](CONTRIBUTING.md) + + +## Getting Started + +### What should I know to take part in the review process? + +You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING.md) and [Style guide](docs/STYLE.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. + + +## Pull Requests (PRs) + +### How to review a Pull Request + +- When reviewing a PR it is suggested that you follow the checklist outlined in this section. +- You are not required to go through *every* item in the checklist. It is meant as a guide; if you have only one thing you want to mention, that's fine too. +- Once the PR author has addressed all of your comments, you should add a review with approval to the PR to signify to the project leads that this PR has been through peer review. +- If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors (we encourage discussing this sort of thing in Discord, since long GitHub conversations get hard to read). The project leads will have final say in these situations. All decisions are generally guided by a consensus of contributors. + +### Reviewer Checklist +- [ ] Jenkins build is successful. + - [ ] `make` builds a matching ROM. + - [ ] `format.sh` was run. + - [ ] `spec` contains correct relocation files. + - [ ] Any new compiler warnings that were added are required for matching. Ensure there is good reason if the warnings files have changed. +- [ ] Files with `NON_MATCHING` functions have equivalent behaviour. +- [ ] `code` and `boot` segment files should be documented as much as possible. Overlays with documentation should be as complete as is reasonable. + - [ ] Overlays should have macros to define access to parameters if the parameter uses bitwise access. The params should have an enum when it makes sense. +- [ ] Comments and variables have correct spelling. +- [ ] The following should be declared in an Actor header file. There should be nothing else in the Actor header file. + - [ ] Main Actor struct + - [ ] Extern'd initVar data. + - [ ] Types used in the actor struct. Specific example would be actionFunc typedefs. + - [ ] Param field macros and/or enums. + - [ ] For any other additional `enum`/`struct`/`define`/`function`/`global`, there needs to be evidence it is needed in another file. +- [ ] New variables and functions should follow standard naming conventions. + - [ ] Constants are converted to whichever looks best in context: hexadecimal, decimal, or float + - [ ] Rotation angles should always be in hexadecimal + - [ ] Colour values should always be in decimal. + - [ ] Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) + - [ ] Functions within a system separate the system from the function's own subname with an underscore (`DmRavine_Init`) + - [ ] Variable names are `camelCase` (`actionFunc`) + - [ ] Global variables start with `g` (`gSaveContext`) + - [ ] Static global variables start with `s` (`sSphereInit`) + - [ ] Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) + - [ ] Trailing commas in array and struct definitions chosen to make it look best (see e.g. `EnJcMatoDamageTable`) + +etc. diff --git a/docs/STYLE.md b/docs/STYLE.md new file mode 100644 index 000000000..6524e05d6 --- /dev/null +++ b/docs/STYLE.md @@ -0,0 +1,232 @@ +# Majora's Mask decompilation style guide + +In general, completed documented files are a good place to look to understand project style in general. + +## Types + +Use the types from `ultratypes.h`, not the standard C types: i.e. `u8`,`s8`,`s16`,`u16`,`s32`,`u32`,`f32` rather than `char`, `short`, `int`, `float` and their `signed`/`unsigned` varieties. + +We always write our enums and structs as `typedef`s. (Usually one can't use an enum typedef as a function argument since enum typedefs are implicitly `s32`.) + +## Naming + +Names are "big-endian": the most significant/largest part of the system goes first, e.g. `DM_RAVINE_STATE_ACTIVE` rather than `DM_RAVINE_ACTIVE_STATE`. + +| Type | Style | Example | +| -------------------- | ----------------------- | ----------------------- | +| Local variables | camelCase | `yawToPlayer` | +| Global variables | gCamelCase | `gSaveContext` | +| Static variables[^1] | sCamelCase | `sZeroVec` | +| Struct members | camelCase | `actionFunc` | +| Struct names | PascalCase | `EnFirefly` | +| Enum types | PascalCase | `EnFireflyMainType` | +| Enum values | SCREAMING_SNAKE_CASE | `AT_ON` | +| Defines/macros | SCREAMING_SNAKE_CASE | `SCREEN_WIDTH`,`ABS(x)` | +| Functions | SystemName_FunctionName | `Actor_SpawnAsChild` | +| Files | snake_case | `z_en_firefly.c` | + +[^1]: including in-function static + +Action functions are usually named with a simple present-tense verb or verb phrase: `{...}_Talk`, `{...}_Wait`, `{...}_FallToGround`, etc. Setup functions are `Setup{name of action}`. + +Ideally names should be both short and clear, although it's better to be clear than short. + +## Formatting + +A lot of formatting is done by clang-format, such as + +- indent is 4 spaces, tabs are not used +- case labels indented +- 120 column limit +- brackets go on the same line (`if (1) {`) +- pointer goes on type (`s32* var;` not `s32 *var;`) + +There are various other conventions that it does not catch, though: + +- Blank line between declarations and code: + ```c + s32 var; + + func(); + ``` +- combine declarations and definitions if possible: + ```c + s32 var = 0; + + func(); + ``` + instead of + ```c + s32 var; + + var = 0; + func(); + ``` +- blank lines between switch cases if they're long (use your judgement). + + +## Numbers + +### dec(imal) + +- timers +- colours and alpha +- Usually array accesses and sizes + +### hex(adecimal) + +- angles (for now; the code itself is very inconsistent with round hex, round dec, and degrees) +- Addresses +- Bitmasks (i.e. `& 0x80` etc.) +- Struct offset comments + +Numbers below `10`/`0xA` do not need the `0x` if by themselves in code. + +### Booleans + +If a function returns only `0` or `1`, and is used as a boolean (i.e. in conditionals), replace the returns by `false` and `true`. (We do not use `bool`, partly because is a C99 thing, and partly because the original has used almost every integer type as a boolean return at some point!) + +### Floats + +Floats usually need an `f` on the end to match, or IDO will use doubles. Our floats are always of the form `1.0f`, even when the decimal part is zero. + +## Conditionals/Loops + +- Spacing out conditional or loop blocks from surrounding code often makes them easier to read. +- Avoid assigning or mutating variables in conditionals if possible (including `++`/`--`), avoid side effects in the loop increment slot (i.e. incrementing/assigning to loop variables is fine, something like `*a = b++` is not). +- We *always* use `{}` on conditional/loop blocks, even if they're one line (clang-tidy will enforce this). +- When conditions are `&&`d or `||`d together, use brackets around each that includes an arithmetic comparison or bitwise operator (i.e. not `!var` or `func()`, but ones with `==` or `&` etc.) +- Flag checks or functions that return booleans do not need the `== 0`/`!= 0`. +- Prefer `if-else` over `if { return; }`, i.e. + ```c + if (cond) { + foo(); + } else { + bar(); + } + ``` + over + ```c + if (cond) { + foo(); + return; + } + bar(); + ``` +**Exception**: After `Actor_MarkForDeath` or sometimes setting the action function, if it makes sense to do so (this expresses the finality a bit better). + +## Macros and enums + +Become familiar with the various defines and enums we have available. There are too many to list all of them here, but the following are common: + +- Those in `macros.h` + - `ABS`, `ABS_ALT`, + - `CLAMP` and friends, + - `BINANG_*`, which are used for angles, especially when there's a lot of `s16` casts around +- `MTXMODE` for many of the `sys_matrix` functions +- CollisionCheck flags: `AT_ON` and so on. Pick the appropriate one for the collider type. +- Actor flags, `ACTOR_FLAG_N`. + +Damage flag enums are not being used at present: we want to wait until we have a better idea what the common groupings should be. + +Pre-C99, commas at the end of the last item in an enum will cause a compiler warning, so leave them off. + +All compound flag lists (e.g. `ACTOR_FLAG_4 | ACTOR_FLAG_8`) should be listed in *ascending* order + +## Arrays + +- It's better to not hardcode array sizes (easier to mod) +- Use `sizeof` or `ARRAY_COUNT`/`ARRAY_COUNTU` where it makes sense, e.g. in loops that are using an array. +- clang-format sometimes does weird things to array formatting. Experiment with and without a comma after the last element and see which looks better. + +## GlobalCtx2 + +In some particular instances, IDO requires the function argument `globalCtx` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `globalCtx2` and than this `globalCtx2` just assigned to a stack variable called `globalCtx`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c` +```c +void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFirefly* this = THIS; +``` + +In other places the cast is actually not explictly needed, but a stack `pad` variable is still needed. For this there should just be a stack variable called `pad` of type `s32` before the actor `THIS` cast. For example in `z_bg_goron_oyu` +```c +void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgGoronOyu* this = THIS; + CollisionHeader* colHeader = NULL; +``` + +In general, pads should be `s32`, or `s16`/`s8` if required. + + +## Documentation and Comments + +Documentation includes: +- Naming functions +- Naming struct variables +- Naming data +- Naming local variables +- Describing the general purpose of the file +- Describing any unusual, interesting or strange features of how the file or parts of its content work +- Labelling and explaining bugs +- Making enums or defines for significant numbers for the file, like actor params values. +- Naming the contents of the asset file(s) the file may use (for an actor, the object(s) it uses) + +If you are not sure what something does, it is better to leave it unnamed than name it wrongly. It is fine to make a note of something you are not sure about when PRing, it means the reviewers will pay special attention to it. + +We use comments for: +- Top of file: a short description of the system. For actors there is already a brief description of our current understanding, but feel free to add to it. +- For function descriptions, we use multiline comments, + ```c + /** + * Describe what the function does + */ + ``` + These are *optional*: if you think the code is clear enough, you do not need to put a comment. You can use Doxygen formatting if you think it adds something, but it is also not required. +- If something in a function is strange, or unintuitive, do leave a comment explaining what's going on. We use `//` for this. +- We also use `//` for temporary comments above a function. Feel free to use `TODO:` in these if appropriate. +- A bug should be commented with an `//! @bug Bug description` above the code that causes the bug. + +## What goes where + +This section mostly applies to actors. + +### Functions + +All functions should go in the main C file in the same order as the assembly (the latter is required to match anyway). (We may make exceptions for particularly large files with a particular organisational structure, but we ask that you check on Discord first before doing this) + +### Data + +- If in doubt, leave all the data at the top of the file. Reviewers will decide for you. +- Data must go in the same order as in the assembly files, but is only constrained by other data, not functions or rodata. +- Some data has to be inline static to match. Generally it's better to not use `static` on data outside funtions until the file is matching, since `static` data is left out of the mapfile and this makes debugging harder. +- *This is even more true of bss, where we have trouble with IDO unpredictably reordering it in certain files.* +- For small arrays or simple data that is used in only one function, we usually inline it, if it fits in the ordering. +- Generally data that is only used by the draw functions is put down near them: this is one of the few consistencies in ordering of actors' functions. + +### Enums and defines + +- Actors that bitpack params should have macros made for each access or write that is made. `z_en_dg.h` has an undocumented example, + ```c + #define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + #define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) + ``` + while `z_en_firefly.h` has a documented one, + ```c + #define KEESE_INVISIBLE (1 << 0xF) + #define KEESE_GET_MAIN_TYPE(thisx) ((thisx)->params & 0x7FFF) + ``` +- In a similar manner, actors that use `home.rot.(x|y|z)` like params should also macros made for accesses and writes. (See, e.g. `z_obj_bean.h`.) +- Stuff that only the actor itself will use goes in the C file unless needed in the header. +- Anything actor-specific that might be used by another file goes in the header, in particular params access macros. +- Anything that is expected to have widespread use should go in `macros.h` or an appropriate header in `include`. + +### Objects + +Are covered in the [ZAPD extraction xml spec](../tools/ZAPD/docs/zapd_extraction_xml_reference.md). Symbol names are `gPrefixDescriptionSuffix` for symbols accessed from the header (they will be global). Texture OutNames are in snake_case since they are filenames. + +## Above all else + +*All of the above is subservient to matching.* Sometimes IDO cares about newlines, for example. + +If you are not sure about any of the above, please ask in Discord. From 6d3bcc5cbb8f5a479d4b0a260cbff92d2e6decfb Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Wed, 25 May 2022 19:11:07 -0700 Subject: [PATCH 12/53] `EnFamos` OK with `object_famos` (#789) * EnFamos: redo begin * EnFamos: back to where I was previously * EnFamos: matched looping draw function * EnFamos: OK * Famos: some docs * Famos: some docs * Famos: sfx convert pass * EnFamos: some docs * EnFamos: more docs * Enfamos: more docks * EnFamos: more doc * EnFamos: more docks * EnFamos: mass to dec * Famos: limb enum * Famos: more docs all functions named * Famos: all struct mapped * Apply suggestions from code review Co-authored-by: EllipticEllipsis * Famos: fix declaration order * Famos: requested changes * Famos: draw func using proper sSetupDL indexing * Famos: fix text anim mismatch, change tlut to match gFamos SnakeCase * Famos: formater pls * Famos: requested changes * Famos: more requested changes * Apply suggestions from code review Co-authored-by: Derek Hensley * Update assets/xml/objects/object_famos.xml Co-authored-by: Tom Overton * Famos: requested changes and format pass * Apply suggestions from code review Co-authored-by: EllipticEllipsis * Famos: more requested changes * Famos: more requested changes * Famos: another change * Apply suggestions from code review Co-authored-by: EllipticEllipsis * Famos: made define macro for agro distance * Famos: separated conditions on separate lines Co-authored-by: Isghj8 Co-authored-by: EllipticEllipsis Co-authored-by: Derek Hensley Co-authored-by: Tom Overton --- assets/xml/objects/object_famos.xml | 51 +- spec | 3 +- src/code/z_bgcheck.c | 3 - src/overlays/actors/ovl_En_Famos/z_en_famos.c | 853 ++++++++++++++++-- src/overlays/actors/ovl_En_Famos/z_en_famos.h | 52 +- tools/disasm/functions.txt | 74 +- 6 files changed, 893 insertions(+), 143 deletions(-) diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index 4466f9b30..cbbf0057c 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -1,28 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index b223f113c..a92016e25 100644 --- a/spec +++ b/spec @@ -969,8 +969,7 @@ beginseg name "ovl_En_Famos" compress include "build/src/overlays/actors/ovl_En_Famos/z_en_famos.o" - include "build/data/ovl_En_Famos/ovl_En_Famos.data.o" - include "build/data/ovl_En_Famos/ovl_En_Famos.reloc.o" + include "build/src/overlays/actors/ovl_En_Famos/ovl_En_Famos_reloc.o" endseg beginseg diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index f0ebe5911..58c71c33e 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4208,9 +4208,6 @@ s32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return (func_800C9A4C(colCtx, poly, bgId) & 4) ? true : false; } -/** - * unused - */ u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 23da2fb30..cc8c799ee 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -1,10 +1,12 @@ /* * File: z_en_famos.c * Overlay: ovl_En_Famos - * Description: Death Armos + * Description: Death Armos (floating statue enemy in Inverted Stone Tower Temple) */ #include "z_en_famos.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -15,7 +17,39 @@ void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx); void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnFamos_SetupAttackDebris(EnFamos* this); +void EnFamos_SetupDeathDebris(EnFamos* this); +s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupStillIdle(EnFamos* this); +void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupPathingIdle(EnFamos* this); +void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupTurnHome(EnFamos* this); +void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupReturnHome(EnFamos* this); +void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAlert(EnFamos* this); +void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupChase(EnFamos* this); +void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttackAim(EnFamos* this); +void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttack(EnFamos* this); +void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupFinishAttack(EnFamos* this); +void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttackRebound(EnFamos* this); +void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupScanForPlayer(EnFamos* this); +void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathSlam(EnFamos* this); +void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathExplosion(EnFamos* this); +void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathFade(EnFamos* this); +void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx); + const ActorInit En_Famos_InitVars = { ACTOR_EN_FAMOS, ACTORCAT_ENEMY, @@ -28,133 +62,810 @@ const ActorInit En_Famos_InitVars = { (ActorFunc)EnFamos_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AE600 = { - { COLTYPE_METAL, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x20000000, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_METAL, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x20000000, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AE62C = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 70, 10, 0, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808AE658[2] = { +// the emblem at the from and the back is one limb running front to back through the torso +// this is both sides of the emblem, front and back +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 2, { { 2500, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { FAMOS_LIMB_EMBLEM, { { 2500, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 2, { { -1500, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { FAMOS_LIMB_EMBLEM, { { -1500, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AE6A0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808AE658, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808AE6B8[] = { +typedef enum { + /* 0 */ FAMOS_ANIMATED_MAT_NORMAL, // normal is greenish + /* 1 */ FAMOS_ANIMATED_MAT_FLIPPED // flipped is orange/yellowish +} FamosAnimatedMatArrayIndexes; + +static AnimatedMaterial* sEmblemAnimatedMats[] = { + gFamosNormalGlowingEmblemTexAnim, + gFamosFlippedGlowingEmblemTexAnim, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 15, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; -#endif +static s32 sAnimatedMaterialsDesgmented = false; -extern ColliderCylinderInit D_808AE600; -extern ColliderCylinderInit D_808AE62C; -extern ColliderJntSphElementInit D_808AE658[2]; -extern ColliderJntSphInit D_808AE6A0; -extern InitChainEntry D_808AE6B8[]; +void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; + Path* path; + s32 i; -extern UNK_TYPE D_060000F8; -extern UNK_TYPE D_06003DC8; + Actor_ProcessInitChain(&this->actor, sInitChain); + if (GET_FAMOS_PATH(thisx) != 0xFF) { + path = &globalCtx->setupPathList[this->actor.params]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->pathNodeCount = path->count; + if (this->pathNodeCount == 1) { + this->pathPoints = NULL; + this->pathNodeCount = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawSquare, 30.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gFamosSkeleton, &gFamosIdleAnim, this->jointTable, this->morphTable, + FAMOS_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetJntSph(globalCtx, &this->emblemCollider, &this->actor, &sJntSphInit, + this->emblemColliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Destroy.s") + if (!sAnimatedMaterialsDesgmented) { // init animated materials + for (i = 0; i < ARRAY_COUNT(sEmblemAnimatedMats); i++) { + sEmblemAnimatedMats[i] = Lib_SegmentedToVirtual(sEmblemAnimatedMats[i]); + } + sAnimatedMaterialsDesgmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACB58.s") + this->actor.colChkInfo.mass = 250; + this->baseHeight = this->actor.world.pos.y; + // params: [this->actor.shape.rot.x] is used to set aggro distance + this->aggroDistance = (GET_FAMOS_AGGRO_DISTANCE(thisx) <= 0) ? (200.0f) : (this->actor.shape.rot.x * 40.0f * 0.1f); + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + this->hasFinishedRotating = true; + this->isCalm = true; + if (this->pathPoints != NULL) { + EnFamos_SetupPathingIdle(this); + } else { + EnFamos_SetupStillIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACD2C.s") +void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyJntSph(globalCtx, &this->emblemCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF98.s") +/** + * Sets 20 rocks to draw from an explosion on the ground (slam attack). + */ +void EnFamos_SetupAttackDebris(EnFamos* this) { + EnFamosRock* rock; + f32 randFloat; + s16 randOffset; + s16 randVelDirection; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD05C.s") + this->debrisTimer = 40; + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + randVelDirection = Rand_Next() >> 0x10; + randOffset = Rand_S16Offset(0x1800, 0x2800); + randFloat = Rand_ZeroFloat(5.0f) + 5.0f; + rock->velocity.x = randFloat * Math_CosS(randOffset) * Math_SinS(randVelDirection); + rock->velocity.y = Math_SinS(randOffset) * randFloat + 3.0f; + rock->velocity.z = randFloat * Math_CosS(randOffset) * Math_CosS(randVelDirection); + rock->rotation.x = Rand_Next() >> 0x10; + rock->rotation.y = Rand_Next() >> 0x10; + rock->rotation.z = Rand_Next() >> 0x10; + rock->pos.x = (Math_SinS(randVelDirection) * 20.0f) + this->actor.world.pos.x; + rock->pos.y = this->actor.floorHeight; + rock->pos.z = (Math_CosS(randVelDirection) * 20.0f) + this->actor.world.pos.z; + rock->scale = Rand_ZeroFloat(0.0015f) + (2.0f * 0.001f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD170.s") +/** + * Sets 20 rocks to draw from an explosion on death. + */ +void EnFamos_SetupDeathDebris(EnFamos* this) { + f32 randFloat; + s16 randSmaller; + s16 randVelDirection; + EnFamosRock* rock; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD18C.s") + this->debrisTimer = 40; + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + randVelDirection = Rand_Next() >> 0x10; + randSmaller = (u32)Rand_Next() >> 0x12; + randFloat = Rand_ZeroFloat(6.0f) + 7.0f; + rock->velocity.x = randFloat * Math_CosS(randSmaller) * Math_SinS(randVelDirection); + rock->velocity.y = Math_SinS(randSmaller) * randFloat + 4.5f; + rock->velocity.z = randFloat * Math_CosS(randSmaller) * Math_CosS(randVelDirection); + rock->rotation.x = Rand_Next() >> 0x10; + rock->rotation.y = Rand_Next() >> 0x10; + rock->rotation.z = Rand_Next() >> 0x10; + rock->pos.x = Math_SinS(randVelDirection) * 20.0f + this->actor.world.pos.x; + rock->pos.y = randPlusMinusPoint5Scaled(60.0f) + (this->actor.world.pos.y + 40.0f); + rock->pos.z = Math_CosS(randVelDirection) * 20.0f + this->actor.world.pos.z; + rock->scale = Rand_ZeroFloat(0.002f) + (2.5f * 0.001f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD1F0.s") +s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx) { + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + (Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos) < this->aggroDistance) && + Actor_IsFacingPlayer(&this->actor, 0x5000)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD294.s") +void EnFamos_UpdateBobbingHeight(EnFamos* this) { + if (this->hoverTimer == 0) { + this->hoverTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD31C.s") + this->hoverTimer--; + this->actor.world.pos.y = (Math_SinS(this->hoverTimer * 0x888) * 10.0f) + this->baseHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD378.s") + if (ABS_ALT(this->flipRot) > 0x4000) { // is famos upside down + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD3E8.s") +/** + * Checks if emblem has been hit with light arrow. + * Also checks if previously flipped; handles flip status. + */ +void EnFamos_UpdateFlipStatus(EnFamos* this) { + u8 hasFinishedRotating; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD42C.s") + if (this->emblemCollider.base.acFlags & AC_HIT) { // light arrow collision, flip + this->emblemCollider.base.acFlags &= ~AC_HIT; + if (this->hasFinishedRotating == true) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + } else { + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_FLIPPED; + this->flippedTimer = 100; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + } + this->hasFinishedRotating = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD54C.s") + } else if (this->flippedTimer > 0) { + this->flippedTimer--; + if (this->flippedTimer == 0) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD5B0.s") + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; + this->hasFinishedRotating = false; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD66C.s") + if (this->hasFinishedRotating == false) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + hasFinishedRotating = Math_ScaledStepToS(&this->flipRot, -0x8000, 0x1000); + } else { + hasFinishedRotating = Math_ScaledStepToS(&this->flipRot, 0, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD68C.s") + this->hasFinishedRotating = hasFinishedRotating; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD7EC.s") +/** + * If Famos path is 0xFF, famos hovers stationary in the air + * facing forward, only bobbing up and down, without a path to follow. + */ +void EnFamos_SetupStillIdle(EnFamos* this) { + this->actionFunc = EnFamos_StillIdle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD840.s") +void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD888.s") +/** + * Regular Famos follows a path until seeing the player. + */ +void EnFamos_SetupPathingIdle(EnFamos* this) { + if (this->isCalm) { + this->currentPathNode++; + if (this->currentPathNode == this->pathNodeCount) { + this->currentPathNode = 0; + } + } else { + this->isCalm = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD8B8.s") + Math_Vec3s_ToVec3f(&this->targetDest, &this->pathPoints[this->currentPathNode]); + this->targetYaw = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actionFunc = EnFamos_PathingIdle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADA74.s") +void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADAE8.s") + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { + EnFamos_SetupReturnHome(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADB4C.s") +/** + * Famos lost player; Turning to face back toward home. + */ +void EnFamos_SetupTurnHome(EnFamos* this) { + this->targetYaw = Actor_YawToPoint(&this->actor, &this->calmPos); + Math_Vec3f_Copy(&this->targetDest, &this->calmPos); + this->actionFunc = EnFamos_TurnHome; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADB70.s") +void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { + EnFamos_SetupReturnHome(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADC40.s") +/** + * Famos has finished rotating toward home; Take off flying in straight line. + */ +void EnFamos_SetupReturnHome(EnFamos* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &this->targetDest); + this->actionFunc = EnFamos_ReturnHome; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADC64.s") +void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx) { + f32 distanceToHome = Actor_XZDistanceToPoint(&this->actor, &this->targetDest); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADD20.s") + this->actor.shape.rot.y = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actor.world.rot.y = this->actor.shape.rot.y; + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADDA8.s") + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (distanceToHome < 20.0f) { + if (this->pathPoints != NULL) { + EnFamos_SetupPathingIdle(this); + } else { + EnFamos_SetupStillIdle(this); + } + } else if (distanceToHome < 40.0f) { + Math_StepToF(&this->actor.speedXZ, 0.5f, 0.3f); + } else { + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADE00.s") +/** + * Famos has spotted the player; delayed by surprise. + */ +void EnFamos_SetupAlert(EnFamos* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->stateTimer = 8; + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADE74.s") + if (this->isCalm == true) { + this->isCalm = false; + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADFA4.s") + this->actionFunc = EnFamos_Alert; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADFF0.s") +void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx) { + if (ABS_ALT(this->flipRot) > 0x4000) { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE030.s") + this->stateTimer--; + if (this->stateTimer == 0) { + this->actor.world.pos.y = this->baseHeight; + EnFamos_SetupChase(this); + } else { + this->actor.world.pos.y = Math_SinS(this->stateTimer * 0x1000) * 30.0f + this->baseHeight; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Update.s") +/** + * Famos has spotted the player; Begin chasing to attack. + */ +void EnFamos_SetupChase(EnFamos* this) { + this->hoverTimer = 0; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnFamos_Chase; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE304.s") +void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f abovePlayerPos; + u32 surfaceType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE3A8.s") + EnFamos_UpdateBobbingHeight(this); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); + this->actor.world.rot.y = this->actor.shape.rot.y; + abovePlayerPos.x = player->actor.world.pos.x; + abovePlayerPos.y = player->actor.world.pos.y + 100.0f; + abovePlayerPos.z = player->actor.world.pos.z; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &abovePlayerPos); + Math_StepToF(&this->actor.speedXZ, 6.0f, 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE3FC.s") + surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((this->actor.xzDistToPlayer < 30.0f) && (this->actor.floorHeight > BGCHECK_Y_MIN) && // close enough + (surfaceType != 0xC && surfaceType != 0xD)) { + EnFamos_SetupAttackAim(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Draw.s") + } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (this->aggroDistance < Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos)) || + !Actor_IsFacingPlayer(&this->actor, 0x6000)) { + EnFamos_SetupScanForPlayer(this); + } +} + +void EnFamos_SetupAttackAim(EnFamos* this) { + Animation_PlayOnce(&this->skelAnime, &gFamosShakeAnim); + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->actionFunc = EnFamos_AttackAim; +} + +void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx) { + func_800B9010(&this->actor, NA_SE_EN_LAST1_FALL_OLD - SFX_FLAG); + if (SkelAnime_Update(&this->skelAnime)) { + EnFamos_SetupAttack(this); + } +} + +void EnFamos_SetupAttack(EnFamos* this) { + this->actor.world.rot.x = -0x4000; + this->collider1.base.atFlags |= AT_ON; + this->stateTimer = 4; + this->actionFunc = EnFamos_Attack; +} + +void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx) { + s32 hitFloor; + u32 surfaceType; + + Math_StepToF(&this->actor.speedXZ, 20.0f, 2.0f); + this->stateTimer--; + if (this->stateTimer == 0) { + this->emblemCollider.base.acFlags &= ~AC_ON; + } + + surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + hitFloor = this->actor.bgCheckFlags & 1; + if (hitFloor || (this->actor.floorHeight == BGCHECK_Y_MIN) || (surfaceType == 0xC) || (surfaceType == 0xD)) { + this->collider1.base.atFlags &= ~AT_ON; + this->collider2.base.atFlags |= AT_ON; + if (hitFloor) { + func_800DFD04(globalCtx->cameraPtrs[globalCtx->activeCamera], 2, 15, 10); // camera shake? + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + EnFamos_SetupAttackDebris(this); + + // spawn crator on floor + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, + this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x0); + + if (this->actor.child != NULL) { + Actor_SetScale(this->actor.child, 0.015f); + } + + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + this->cratorDespawnTimer = 70; + EnFamos_SetupDeathSlam(this); + } else { + this->cratorDespawnTimer = 20; + EnFamos_SetupFinishAttack(this); + } + } else { + this->emblemCollider.base.acFlags |= AC_ON; + EnFamos_SetupAttackRebound(this); + } + } else { + func_800B9010(&this->actor, NA_SE_EN_LAST1_FALL_OLD - SFX_FLAG); + } +} + +/** + * Attack has hit; Wait for animation to finish before recovering from attack. + */ +void EnFamos_SetupFinishAttack(EnFamos* this) { + Animation_PlayOnce(&this->skelAnime, &gFamosIdleAnim); + SkelAnime_Update(&this->skelAnime); + this->emblemCollider.base.acFlags |= AC_ON; + this->stateTimer = 3; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + this->actionFunc = EnFamos_FinishAttack; +} + +void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx) { + if (this->stateTimer == 0) { + this->collider2.base.atFlags &= ~AT_ON; + } + + this->stateTimer--; + if (SkelAnime_Update(&this->skelAnime)) { + EnFamos_SetupAttackRebound(this); + } +} + +void EnFamos_SetupAttackRebound(EnFamos* this) { + this->actor.world.rot.x = 0x4000; + this->actionFunc = EnFamos_AttackRebound; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 5.0f, 0.3f); + if (this->actor.speedXZ > 1.0f) { + if (ABS_ALT(this->flipRot) > 0x4000) { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } + } + + if ((this->baseHeight < this->actor.world.pos.y) || (this->actor.bgCheckFlags & 0x10)) { // touching ceiling + this->actor.speedXZ = 0.0f; + EnFamos_SetupChase(this); + } +} + +/** + * Looking around for player. + */ +void EnFamos_SetupScanForPlayer(EnFamos* this) { + this->stateTimer = 60; + this->actionFunc = EnFamos_ScanForPlayer; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + this->stateTimer--; + + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (this->stateTimer == 0) { + EnFamos_SetupTurnHome(this); + } else { + this->actor.shape.rot.y = (s32)(Math_SinS(this->stateTimer * 0x888) * 8192.0f) + this->actor.world.rot.y; + } +} + +/** + * Famos was upside down and hit the ground headfirst. This kills the Famos. + */ +void EnFamos_SetupDeathSlam(EnFamos* this) { + this->emblemCollider.base.acFlags &= ~AC_ON; + this->stateTimer = 20; + this->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->flippedTimer = -1; + this->actor.world.pos.y = this->actor.floorHeight - 60.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + this->actionFunc = EnFamos_DeathSlam; +} + +void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx) { + if (this->stateTimer == 17) { + this->collider2.base.atFlags &= ~AT_ON; + } + + if (this->stateTimer == 0) { + EnFamos_SetupDeathExplosion(this); + } else { + this->stateTimer--; + } +} + +void EnFamos_SetupDeathExplosion(EnFamos* this) { + this->actor.world.rot.x = 0x4000; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + this->stateTimer = 25; + Math_Vec3f_Copy(&this->targetDest, &this->actor.world.pos); + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = EnFamos_DeathExplosion; +} + +void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + if (this->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + } + + this->actor.world.pos.x = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.x; + this->actor.world.pos.z = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.z; + if (this->stateTimer == 1) { + EnBom* explosion = + (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + if (explosion != NULL) { + explosion->timer = 0; // instant explosion + } + this->stateTimer--; + + } else if (this->stateTimer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, + (0xD << 4)); // random item from droptable 0xD + EnFamos_SetupDeathFade(this); + + } else { + this->stateTimer--; + } +} + +void EnFamos_SetupDeathFade(EnFamos* this) { + EnFamos_SetupDeathDebris(this); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.shadowDraw = NULL; + this->actionFunc = EnFamos_DeathFade; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx) { + Actor* enBom; + + if (this->debrisTimer == 0) { + enBom = this->actor.child; + if (enBom != NULL) { + enBom->parent = NULL; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnFamos_UpdateDebrisPosRot(EnFamos* this) { + EnFamosRock* rock; + s32 i; + + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + rock->velocity.y -= 1.0f; + Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); + // all casts seem required + rock->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + } +} + +void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFamos* this = THIS; + f32 oldHeight; + s32 oldHoverTimer; // save old value to test if changed + + if (this->debrisTimer <= 0 || + (this->debrisTimer--, EnFamos_UpdateDebrisPosRot(this), (this->actionFunc != EnFamos_DeathFade))) { + oldHoverTimer = this->hoverTimer; + EnFamos_UpdateFlipStatus(this); + if (this->cratorDespawnTimer > 0) { + this->cratorDespawnTimer--; + if (this->cratorDespawnTimer == 0) { + this->actor.child->parent = NULL; // child is EnTest (Crator after stomp) + } + } + + this->actionFunc(this, globalCtx); + oldHeight = this->actor.world.pos.y; + Actor_MoveWithoutGravity(&this->actor); + if (oldHoverTimer != this->hoverTimer) { // test if updated in actionFunc + this->baseHeight += this->actor.world.pos.y - oldHeight; + } + + if (this->flippedTimer >= 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 30.0f, 80.0f, 0x1F); + if ((this->actionFunc == EnFamos_Attack) && (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) && + (this->actor.bgCheckFlags & 1)) { // touch floor + this->actor.world.pos.y -= 60.0f; + } + } + + this->actor.focus.rot.y = this->actor.shape.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider1); + if (this->collider1.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (this->emblemCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->emblemCollider.base); + } + + if (this->collider2.base.atFlags & AC_ON) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + this->collider2.dim.pos.y = this->actor.floorHeight; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + } +} + +s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFamos* this = THIS; + + if (limbIndex == FAMOS_LIMB_BODY) { + Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->flipRot, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); + + } else if (this->flippedTimer < 0) { // if set to -1, famos is dying + if ((limbIndex == FAMOS_LIMB_SWORD) || (limbIndex == FAMOS_LIMB_SHIELD) || (limbIndex == FAMOS_LIMB_HEAD)) { + *dList = NULL; + } + } + + return false; +} + +void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnFamos* this = THIS; + + if (limbIndex == FAMOS_LIMB_EMBLEM) { + Matrix_GetStateTranslation(&this->actor.focus.pos); + Collider_UpdateSpheres(limbIndex, &this->emblemCollider); + } +} + +void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { + s32 i; + + if (this->debrisTimer > 0) { + Gfx* dispOpa; + EnFamosRock* rock; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dispOpa = POLY_OPA_DISP; + + gSPDisplayList(&dispOpa[0], &sSetupDL[6 * 0x19]); + + gDPSetPrimColor(&dispOpa[1], 0, 0x80, 255, 255, 255, 255); + + gDPSetEnvColor(&dispOpa[2], 255, 255, 255, 255); + + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + + Matrix_SetStateRotationAndTranslation(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); + Matrix_Scale(rock->scale, rock->scale, rock->scale, MTXMODE_APPLY); + + gSPMatrix(&dispOpa[3 + i * 2], Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispOpa[4 + i * 2], &gameplay_keep_DL_06AB30); // greenish brown rock DL + } + + POLY_OPA_DISP = &dispOpa[3 + (ARRAY_COUNT(this->rocks) * 2)]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->actionFunc != EnFamos_DeathFade) { + AnimatedMat_Draw(globalCtx, sEmblemAnimatedMats[this->animatedMaterialIndex]); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFamos_OverrideLimbDraw, + EnFamos_PostLimbDraw, &this->actor); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + } + EnFamos_DrawDebris(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.h b/src/overlays/actors/ovl_En_Famos/z_en_famos.h index c38e87e7d..a3db181e6 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.h +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.h @@ -2,18 +2,58 @@ #define Z_EN_FAMOS_H #include "global.h" +#include "objects/object_famos/object_famos.h" struct EnFamos; typedef void (*EnFamosActionFunc)(struct EnFamos*, GlobalContext*); +typedef struct EnFamosRock { + /* 00 */ Vec3f pos; + /* 0C */ Vec3f velocity; + /* 18 */ Vec3s rotation; + /* 20 */ f32 scale; +} EnFamosRock; // size = 0x24 + +#define GET_FAMOS_PATH(thisx) (thisx->params) +#define GET_FAMOS_AGGRO_DISTANCE(thisx) (thisx->shape.rot.x) + +// stateTimer gets reused: +// after spotting player, counts frames until first attack (8) +// after lost aggro, measures frames looking around before returning to home (60) +// before smash attack, counts frames before disabling emblem colider (4) +// after smash attack collision, counts frames before rising (3) +// after smash attack finish, counts frames rising above ground before next attempt (20) + typedef struct EnFamos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8C]; - /* 0x01D0 */ EnFamosActionFunc actionFunc; - /* 0x01D4 */ char unk_1D4[0x440]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[FAMOS_LIMB_MAX]; + /* 0x1AC */ Vec3s morphTable[FAMOS_LIMB_MAX]; + /* 0x1D0 */ EnFamosActionFunc actionFunc; + /* 0x1D4 */ u8 animatedMaterialIndex; + /* 0x1D5 */ u8 hasFinishedRotating; // stable up or down + /* 0x1D6 */ u8 pathNodeCount; + /* 0x1D7 */ u8 currentPathNode; + /* 0x1D8 */ u8 isCalm; // is NOT aware of player + /* 0x1DA */ s16 hoverTimer; // start 30, decr to 0, repeat: for trig height adjustment when hovering + /* 0x1DC */ s16 stateTimer; // reused for different actionFunc + /* 0x1DE */ s16 debrisTimer; // also counts frames until despawning bom after death + /* 0x1E0 */ s16 flippedTimer; // frames until it flips right side up + /* 0x1E2 */ s16 cratorDespawnTimer; + /* 0x1E4 */ s16 targetYaw; + /* 0x1E6 */ s16 flipRot; // is used to detect if the actor has been flipped upside down by light arrows + /* 0x1E8 */ Vec3s* pathPoints; + /* 0x1EC */ f32 baseHeight; // because hover can hit the floor, we need to keep track so famos cannot by adjusted/moved by terain + /* 0x1F0 */ f32 aggroDistance; + /* 0x1F4 */ Vec3f targetDest; + /* 0x200 */ Vec3f calmPos; + // havent figured out what the difference between the colliders are, only one cylinder is visible in KZ + /* 0x20C */ ColliderCylinder collider1; + /* 0x258 */ ColliderCylinder collider2; + /* 0x2A4 */ ColliderJntSph emblemCollider; + /* 0x2C4 */ ColliderJntSphElement emblemColliderElements[2]; + /* 0x344 */ EnFamosRock rocks[20]; } EnFamos; // size = 0x614 -extern const ActorInit En_Famos_InitVars; - #endif // Z_EN_FAMOS_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 86758415a..c4f1a053b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5821,44 +5821,44 @@ 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), - 0x808ACB58:("func_808ACB58",), - 0x808ACD2C:("func_808ACD2C",), - 0x808ACF1C:("func_808ACF1C",), - 0x808ACF98:("func_808ACF98",), - 0x808AD05C:("func_808AD05C",), - 0x808AD170:("func_808AD170",), - 0x808AD18C:("func_808AD18C",), - 0x808AD1F0:("func_808AD1F0",), - 0x808AD294:("func_808AD294",), - 0x808AD31C:("func_808AD31C",), - 0x808AD378:("func_808AD378",), - 0x808AD3E8:("func_808AD3E8",), - 0x808AD42C:("func_808AD42C",), - 0x808AD54C:("func_808AD54C",), - 0x808AD5B0:("func_808AD5B0",), - 0x808AD66C:("func_808AD66C",), - 0x808AD68C:("func_808AD68C",), - 0x808AD7EC:("func_808AD7EC",), - 0x808AD840:("func_808AD840",), - 0x808AD888:("func_808AD888",), - 0x808AD8B8:("func_808AD8B8",), - 0x808ADA74:("func_808ADA74",), - 0x808ADAE8:("func_808ADAE8",), - 0x808ADB4C:("func_808ADB4C",), - 0x808ADB70:("func_808ADB70",), - 0x808ADC40:("func_808ADC40",), - 0x808ADC64:("func_808ADC64",), - 0x808ADD20:("func_808ADD20",), - 0x808ADDA8:("func_808ADDA8",), - 0x808ADE00:("func_808ADE00",), - 0x808ADE74:("func_808ADE74",), - 0x808ADFA4:("func_808ADFA4",), - 0x808ADFF0:("func_808ADFF0",), - 0x808AE030:("func_808AE030",), + 0x808ACB58:("EnFamos_SetupAttackDebris",), + 0x808ACD2C:("EnFamos_SetupDeathDebris",), + 0x808ACF1C:("EnFamos_IsPlayerSeen",), + 0x808ACF98:("EnFamos_UpdateBobbingHeight",), + 0x808AD05C:("EnFamos_UpdateFlipStatus",), + 0x808AD170:("EnFamos_SetupStillIdle",), + 0x808AD18C:("EnFamos_StillIdle",), + 0x808AD1F0:("EnFamos_SetupPathingIdle",), + 0x808AD294:("EnFamos_PathingIdle",), + 0x808AD31C:("EnFamos_SetupTurnHome",), + 0x808AD378:("EnFamos_TurnHome",), + 0x808AD3E8:("EnFamos_SetupReturnHome",), + 0x808AD42C:("EnFamos_ReturnHome",), + 0x808AD54C:("EnFamos_SetupAlert",), + 0x808AD5B0:("EnFamos_Alert",), + 0x808AD66C:("EnFamos_SetupChase",), + 0x808AD68C:("EnFamos_Chase",), + 0x808AD7EC:("EnFamos_SetupAttackAim",), + 0x808AD840:("EnFamos_AttackAim",), + 0x808AD888:("EnFamos_SetupAttack",), + 0x808AD8B8:("EnFamos_Attack",), + 0x808ADA74:("EnFamos_SetupFinishAttack",), + 0x808ADAE8:("EnFamos_FinishAttack",), + 0x808ADB4C:("EnFamos_SetupAttackRebound",), + 0x808ADB70:("EnFamos_AttackRebound",), + 0x808ADC40:("EnFamos_SetupScanForPlayer",), + 0x808ADC64:("EnFamos_ScanForPlayer",), + 0x808ADD20:("EnFamos_SetupDeathSlam",), + 0x808ADDA8:("EnFamos_DeathSlam",), + 0x808ADE00:("EnFamos_SetupDeathExplosion",), + 0x808ADE74:("EnFamos_DeathExplosion",), + 0x808ADFA4:("EnFamos_SetupDeathFade",), + 0x808ADFF0:("EnFamos_DeathFade",), + 0x808AE030:("EnFamos_UpdateDebrisPosRot",), 0x808AE0EC:("EnFamos_Update",), - 0x808AE304:("func_808AE304",), - 0x808AE3A8:("func_808AE3A8",), - 0x808AE3FC:("func_808AE3FC",), + 0x808AE304:("EnFamos_OverrideLimbDraw",), + 0x808AE3A8:("EnFamos_PostLimbDraw",), + 0x808AE3FC:("EnFamos_DrawDebris",), 0x808AE530:("EnFamos_Draw",), 0x808AE8C0:("EnBombf_SetupAction",), 0x808AE8CC:("EnBombf_Init",), From f1d1d8320675469e241bc5ee374af905e42a24bd Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 19:15:28 -0700 Subject: [PATCH 13/53] Makefile Changes (#727) * Change makefile so rom doesn't need to match by default for compression, also change JenkinsFile to split off compression step from building * Swap uncompressed and compressed in all target * Forgot to change check warnings stage name * Intentionally produce non_matching * Fix * Add assets target * Jenkins assets * Update update_current_warnings * .make_options config file * Change comment at top * Add toggle options for CC_CHECK and OBJDUMP * Small cleanup * Whitespace * More * bin dumping * Whitespace * Review * Fix comment --- .gitignore | 1 + Jenkinsfile | 22 ++++++- Makefile | 66 +++++++++++++------ .../warnings_count/update_current_warnings.sh | 4 +- .../warnings_assets_current.txt | 0 .../warnings_compress_current.txt | 0 6 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 tools/warnings_count/warnings_assets_current.txt create mode 100644 tools/warnings_count/warnings_compress_current.txt diff --git a/.gitignore b/.gitignore index 80fe09807..aa3f65077 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ docs/doxygen/ # Per-user configuration .python-version +.make_options diff --git a/Jenkinsfile b/Jenkinsfile index 3ebfd3614..fb60f0aca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,6 +36,16 @@ pipeline { sh 'bash -c "./tools/warnings_count/compare_warnings.sh setup"' } } + stage('Assets') { + steps { + sh 'bash -c "make -j assets 2> >(tee tools/warnings_count/warnings_assets_new.txt)"' + } + } + stage('Check assets warnings') { + steps { + sh 'bash -c "./tools/warnings_count/compare_warnings.sh assets"' + } + } stage('Disasm') { steps { sh 'bash -c "make -j disasm 2> >(tee tools/warnings_count/warnings_disasm_new.txt)"' @@ -48,7 +58,7 @@ pipeline { } stage('Build') { steps { - sh 'bash -c "make -j all 2> >(tee tools/warnings_count/warnings_build_new.txt)"' + sh 'bash -c "make -j uncompressed 2> >(tee tools/warnings_count/warnings_build_new.txt)"' } } stage('Check build warnings') { @@ -56,6 +66,16 @@ pipeline { sh 'bash -c "./tools/warnings_count/compare_warnings.sh build"' } } + stage('Compress') { + steps { + sh 'bash -c "make -j compressed 2> >(tee tools/warnings_count/warnings_compress_new.txt)"' + } + } + stage('Check compress warnings') { + steps { + sh 'bash -c "./tools/warnings_count/compare_warnings.sh compress"' + } + } stage('Report Progress') { when { branch 'master' diff --git a/Makefile b/Makefile index ac7174e89..f33f60848 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ +# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'. +# It is also possible to override the settings in Defaults in a file called .make_options as 'SETTING=value'. + +-include .make_options + MAKEFLAGS += --no-builtin-rules -# Build options can either be changed by modifying the makefile, or by building with 'make SETTING=value' +#### Defaults #### # If COMPARE is 1, check the output md5sum after building COMPARE ?= 1 @@ -14,6 +19,14 @@ WERROR ?= 0 KEEP_MDEBUG ?= 0 # Disassembles all asm from the ROM instead of skipping files which are entirely in C FULL_DISASM ?= 0 +# Check code syntax with host compiler +RUN_CC_CHECK ?= 1 +# Dump build object files +OBJDUMP_BUILD ?= 0 +# Number of threads to disassmble, extract, and compress with +N_THREADS ?= $(shell nproc) + +#### Setup #### ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING @@ -45,9 +58,8 @@ else endif endif -N_THREADS ?= $(shell nproc) - #### Tools #### + ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) MIPS_BINUTILS_PREFIX := mips-linux-gnu- else @@ -86,8 +98,15 @@ else endif # Check code syntax with host compiler -CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) +ifneq ($(RUN_CC_CHECK),0) + CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label + CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) + ifneq ($(WERROR), 0) + CC_CHECK += -Werror + endif +else + CC_CHECK := @: +endif CPP := cpp ELF2ROM := tools/buildtools/elf2rom @@ -103,12 +122,20 @@ MIPS_VERSION := -mips2 CFLAGS += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712,516 # Use relocations and abi fpr names in the dump -OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 +OBJDUMP_FLAGS := --disassemble --reloc --disassemble-zeroes -Mreg-names=32 + +ifneq ($(OBJDUMP_BUILD), 0) + OBJDUMP_CMD = $(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + OBJCOPY_BIN = $(OBJCOPY) -O binary $@ $@.bin +else + OBJDUMP_CMD = @: + OBJCOPY_BIN = @: +endif ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU export QEMU_GUEST_BASE := 1 -else +else ifneq ($(RUN_CC_CHECK),0) # Ensure that gcc treats the code as 32-bit CC_CHECK += -m32 endif @@ -116,11 +143,7 @@ endif # rom compression flags COMPFLAGS := --threads $(N_THREADS) ifneq ($(NON_MATCHING),1) - COMPFLAGS += --matching -endif - -ifneq ($(WERROR), 0) - CC_CHECK += -Werror + COMPFLAGS += --matching endif #### Files #### @@ -229,14 +252,14 @@ ifeq ($(COMPARE),1) @md5sum -c checksum.md5 endif -.PHONY: all uncompressed compressed clean assetclean distclean disasm init setup +.PHONY: all uncompressed compressed clean assetclean distclean assets disasm init setup .DEFAULT_GOAL := uncompressed -all: compressed +all: uncompressed compressed $(ROM): $(ELF) $(ELF2ROM) -cic 6105 $< $@ -$(ROMC): uncompressed +$(ROMC): $(ROM) python3 tools/z64compress_wrapper.py $(COMPFLAGS) $(ROM) $@ $(ELF) build/$(SPEC) $(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) build/ldscript.txt build/undefined_syms.txt @@ -263,6 +286,8 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py + +assets: python3 extract_assets.py -j $(N_THREADS) ## Assembly generation @@ -278,6 +303,7 @@ diff-init: uncompressed init: $(MAKE) distclean $(MAKE) setup + $(MAKE) assets $(MAKE) disasm $(MAKE) all $(MAKE) diff-init @@ -296,7 +322,7 @@ build/asm/%.o: asm/%.s build/assets/%.o: assets/%.c $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - $(OBJCOPY) -O binary $@ $@.bin + $(OBJCOPY_BIN) $(RM_MDEBUG) build/baserom/%.o: baserom/% @@ -308,7 +334,7 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s @@ -318,21 +344,21 @@ build/src/overlays/%.o: src/overlays/%.c build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) # Build C files from assets diff --git a/tools/warnings_count/update_current_warnings.sh b/tools/warnings_count/update_current_warnings.sh index afbc4a423..f2cff34c5 100755 --- a/tools/warnings_count/update_current_warnings.sh +++ b/tools/warnings_count/update_current_warnings.sh @@ -8,5 +8,7 @@ cd "$DIR/../.." make distclean make setup 2> tools/warnings_count/warnings_setup_current.txt +make assets 2> tools/warnings_count/warnings_assets_current.txt make disasm 2> tools/warnings_count/warnings_disasm_current.txt -make all 2> tools/warnings_count/warnings_build_current.txt +make uncompressed 2> tools/warnings_count/warnings_build_current.txt +make compressed 2> tools/warnings_count/warnings_compress_current.txt diff --git a/tools/warnings_count/warnings_assets_current.txt b/tools/warnings_count/warnings_assets_current.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tools/warnings_count/warnings_compress_current.txt b/tools/warnings_count/warnings_compress_current.txt new file mode 100644 index 000000000..e69de29bb From 12b995093fa0b3430669dbbf39321399422d5744 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Wed, 25 May 2022 19:19:38 -0700 Subject: [PATCH 14/53] `EnNwc` OK and three objects documented (`object_niw` and `object_nwc` and `object_hs`) and some Actor docs( `EnNiw` and `EnAttackNiw` and `EnHg`) (#715) * EnNwc: OK and some Niw Docs * Update src/overlays/actors/ovl_En_Nwc/z_en_nwc.c Co-authored-by: Parker Burnett * Update src/overlays/actors/ovl_En_Nwc/z_en_nwc.c Co-authored-by: Parker Burnett * Update src/overlays/actors/ovl_En_Nwc/z_en_nwc.c Co-authored-by: Parker Burnett * EnNwc: Overwrite->Override * EnAttackNiw: fix merges * AttackNiw and Niw: some docs * formater pass * EnNwc: fixed savecontext change * Niw and Attackniw: more docs * Apply suggestions from code review Co-authored-by: Anghelo Carvajal * Nwc,Niw: requested doc changes * Nwc: extracted and marked broken texture * Apply suggestions from code review Co-authored-by: Derek Hensley * EnNwc: more requested changes * Nwc: more requested changes * Apply suggestions from code review Co-authored-by: Derek Hensley * EnHs: object_hs documented, some ovl_En_Hs docs * EnHs: animation names * EnHs: some text docs * EnHs: fear anim changed to shivering now that we know it was used in OOT * EnHs: more docs and format pass * Apply suggestions from code review Co-authored-by: Derek Hensley * EnHs: more docs and updates to var name changes * Niw,Nwc,Hs: added description to object files * Hs: changed from playerOffset to offset Co-authored-by: Isghj8 Co-authored-by: Parker Burnett Co-authored-by: Anghelo Carvajal Co-authored-by: Derek Hensley --- assets/xml/objects/object_hs.xml | 62 +- assets/xml/objects/object_niw.xml | 66 +- assets/xml/objects/object_nwc.xml | 46 +- include/functions.h | 2 +- spec | 3 +- .../ovl_En_Attack_Niw/z_en_attack_niw.c | 479 +++++++------ .../ovl_En_Attack_Niw/z_en_attack_niw.h | 83 +-- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 168 ++--- src/overlays/actors/ovl_En_Hs/z_en_hs.h | 22 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 641 +++++++++--------- src/overlays/actors/ovl_En_Niw/z_en_niw.h | 99 +-- src/overlays/actors/ovl_En_Nwc/z_en_nwc.c | 506 +++++++++++++- src/overlays/actors/ovl_En_Nwc/z_en_nwc.h | 28 +- tools/disasm/functions.txt | 52 +- 14 files changed, 1411 insertions(+), 846 deletions(-) diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 0d36c4ff1..ae025f327 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -1,8 +1,9 @@  + - - - + + + @@ -13,35 +14,38 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index e49426560..0e533fb6e 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -1,38 +1,40 @@  + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nwc.xml b/assets/xml/objects/object_nwc.xml index 77b395b58..8c67159ce 100644 --- a/assets/xml/objects/object_nwc.xml +++ b/assets/xml/objects/object_nwc.xml @@ -1,29 +1,57 @@  + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index e3f700d72..0e12b35a5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3498,7 +3498,7 @@ void func_801A0238(s32 arg0, s32 arg1); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); void func_801A0810(Vec3f* arg0, u16 sfxId, u8 arg2); -// void func_801A0868(void); +void func_801A0868(Vec3f* pos, u16 sfxId, u8 val); // void func_801A09D4(void); // void Audio_SplitBgmChannels(void); // void func_801A0E44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); diff --git a/spec b/spec index a92016e25..5cb8e7123 100644 --- a/spec +++ b/spec @@ -1510,8 +1510,7 @@ beginseg name "ovl_En_Nwc" compress include "build/src/overlays/actors/ovl_En_Nwc/z_en_nwc.o" - include "build/data/ovl_En_Nwc/ovl_En_Nwc.data.o" - include "build/data/ovl_En_Nwc/ovl_En_Nwc.reloc.o" + include "build/src/overlays/actors/ovl_En_Nwc/ovl_En_Nwc_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index b100f692f..548e1e68d 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -1,7 +1,7 @@ /* * File: z_en_attack_niw.c * Overlay: ovl_En_Attack_Niw - * Description: Attacking cucco + * Description: Attacking Cucco */ #include "z_en_attack_niw.h" @@ -16,9 +16,9 @@ void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx); void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx); -void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx); -void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx); const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, @@ -43,289 +43,305 @@ void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, - this->morphTable, OBJECT_NIW_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); + // probably copy pasted from EnNiw, which has this same code, but AttackNiw has no params if (this->actor.params < 0) { - this->actor.params = 0; + this->actor.params = ATTACK_NIW_REGULAR; } Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = 0.0f; - this->unk_290.x = randPlusMinusPoint5Scaled(100.0f); - this->unk_290.y = randPlusMinusPoint5Scaled(10.0f); - this->unk_290.z = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.x = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.y = randPlusMinusPoint5Scaled(10.0f); + this->randomTargetCenterOffset.z = randPlusMinusPoint5Scaled(100.0f); Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_1; // Unnecessary: this actor does not start with this flag this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; - this->actionFunc = func_80958634; + this->actionFunc = EnAttackNiw_EnterViewFromOffscreen; } void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnAttackNiw* this = THIS; EnNiw* parent = (EnNiw*)this->actor.parent; - if ((thisx->parent != NULL) && (thisx->parent->update != NULL)) { - if (parent->unk290 > 0) { - parent->unk290--; + if (this->actor.parent != NULL && this->actor.parent->update != NULL) { + if (parent->attackNiwCount > 0) { + parent->attackNiwCount--; } } } -void func_80958228(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { - if (this->unk_24C == 0) { - if (arg2 == 0) { - this->unk_25C = 0.0f; +/** + * Summary: instead of using SkelAnime animations AttackNiw modifies head+wings directly to create animations + * + * EnNiw has its own version of this function, probably copy paste since AttackNiw only uses two animationState (2/5) + */ +void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s16 animationState) { + if (this->unkTimer24C == 0) { + if (animationState == 0) { + this->targetBodyRotY = 0.0f; } else { - this->unk_25C = -10000.0f; + this->targetBodyRotY = -10000.0f; } - this->unk_286++; - this->unk_24C = 3; - if ((this->unk_286 % 2) == 0) { - this->unk_25C = 0.0f; - if (arg2 == 0) { - this->unk_24C = Rand_ZeroFloat(30.0f); + + this->clearRotYToggleTimer++; + this->unkTimer24C = 3; + if ((this->clearRotYToggleTimer % 2) == 0) { + this->targetBodyRotY = 0.0f; + if (animationState == 0) { + this->unkTimer24C = Rand_ZeroFloat(30.0f); } } } - if (this->unk_250 == 0) { - this->unk_28A++; - this->unk_28A &= 1; + if (this->unkTimer250 == 0) { + this->unkToggle28A++; + this->unkToggle28A &= 1; - switch (arg2) { - case 0: - this->unk_264 = 0.0f; - this->unk_260 = 0.0f; + switch (animationState) { // only case 2 and 5 are ever called in AttackNiw + case NIW_ANIMATION_STILL: + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; break; - case 1: - this->unk_250 = 3; - this->unk_264 = 7000.0f; - this->unk_260 = 7000.0f; - if (this->unk_28A == 0) { - this->unk_264 = 0.0f; - this->unk_260 = 0.0f; + case NIW_ANIMATION_HEAD_PECKING: + this->unkTimer250 = 3; + this->targetLeftWingRotZ = 7000.0f; + this->targetRightWingRotZ = 7000.0f; + if (this->unkToggle28A == 0) { + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; } break; - case 2: - this->unk_250 = 2; - this->unk_264 = -10000.0f; - this->unk_260 = -10000.0f; - this->unk_278 = 25000.0f; - this->unk_270 = 25000.0f; - this->unk_27C = 6000.0f; - this->unk_274 = 6000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 8000.0f; - this->unk_278 = 8000.0f; + case NIW_ANIMATION_PECKING_AND_WAVING: + this->unkTimer250 = 2; + this->targetLeftWingRotZ = -10000.0f; + this->targetRightWingRotZ = -10000.0f; + this->targetLeftWingRotY = 25000.0f; + this->targetRightWingRotY = 25000.0f; + this->targetLeftWingRotX = 6000.0f; + this->targetRightWingRotX = 6000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 8000.0f; + this->targetLeftWingRotY = 8000.0f; } break; - case 3: - this->unk_250 = 2; - this->unk_270 = 10000.0f; - this->unk_278 = 10000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 3000.0f; - this->unk_278 = 3000.0f; + case NIW_ANIMATION_PECKING_AND_FORFLAPPING: + this->unkTimer250 = 2; + this->targetRightWingRotY = 10000.0f; + this->targetLeftWingRotY = 10000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 3000.0f; + this->targetLeftWingRotY = 3000.0f; } break; - case 4: - this->unk_24E = 5; - this->unk_24C = this->unk_24E; + case NIW_ANIMATION_FREEZE: + this->unusedTimer24E = 5; + this->unkTimer24C = this->unusedTimer24E; break; - case 5: - this->unk_250 = 5; - this->unk_270 = 14000.0f; - this->unk_278 = 14000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 10000.0f; - this->unk_278 = 10000.0f; + case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: + this->unkTimer250 = 5; + this->targetRightWingRotY = 14000.0f; + this->targetLeftWingRotY = 14000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 10000.0f; + this->targetLeftWingRotY = 10000.0f; } break; } } - if (this->unk_280 != this->unk_2B8) { - Math_ApproachF(&this->unk_2B8, this->unk_280, 0.5f, 4000.0f); + if (this->targetHeadRotZ != this->headRotZ) { + Math_ApproachF(&this->headRotZ, this->targetHeadRotZ, 0.5f, 4000.0f); } - if (this->unk_25C != this->unk_2B4) { - Math_ApproachF(&this->unk_2B4, this->unk_25C, 0.5f, 4000.0f); + if (this->targetBodyRotY != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetBodyRotY, 0.5f, 4000.0f); } - if (this->unk_264 != this->unk_29C) { - Math_ApproachF(&this->unk_29C, this->unk_264, 0.8f, 7000.0f); + if (this->targetLeftWingRotZ != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLeftWingRotZ, 0.8f, 7000.0f); } - if (this->unk_278 != this->unk_2A0) { - Math_ApproachF(&this->unk_2A0, this->unk_278, 0.8f, 7000.0f); + if (this->targetLeftWingRotY != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLeftWingRotY, 0.8f, 7000.0f); } - if (this->unk_27C != this->unk_2A4) { - Math_ApproachF(&this->unk_2A4, this->unk_27C, 0.8f, 7000.0f); + if (this->targetLeftWingRotX != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLeftWingRotX, 0.8f, 7000.0f); } - if (this->unk_260 != this->unk_2A8) { - Math_ApproachF(&this->unk_2A8, this->unk_260, 0.8f, 7000.0f); + if (this->targetRightWingRotZ != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetRightWingRotZ, 0.8f, 7000.0f); } - if (this->unk_270 != this->unk_2AC) { - Math_ApproachF(&this->unk_2AC, this->unk_270, 0.8f, 7000.0f); + if (this->targetRightWingRotY != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetRightWingRotY, 0.8f, 7000.0f); } - if (this->unk_274 != this->unk_2B0) { - Math_ApproachF(&this->unk_2B0, this->unk_274, 0.8f, 7000.0f); + if (this->targetRightWingRotX != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetRightWingRotX, 0.8f, 7000.0f); } } -s32 func_809585B0(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp1E; - s16 sp1C; +s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 posX; + s16 posY; - Actor_SetFocus(&this->actor, this->unk_2DC); - Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); - if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || - (sp1C > SCREEN_HEIGHT)) { + if ((this->actor.projectedPos.z < -20.0f) || (posX < 0) || (posX > SCREEN_WIDTH) || (posY < 0) || + (posY > SCREEN_HEIGHT)) { return false; } return true; } -void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp4E; - s16 sp4C; - Vec3f temp; - Vec3f sp34; +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 posX; + s16 posY; + Vec3f viewOffset; + Vec3f flightTarget; s32 pad; this->actor.speedXZ = 10.0f; - temp.x = (this->unk_290.x + globalCtx->view.at.x) - globalCtx->view.eye.x; - temp.y = (this->unk_290.y + globalCtx->view.at.y) - globalCtx->view.eye.y; - temp.z = (this->unk_290.z + globalCtx->view.at.z) - globalCtx->view.eye.z; + // randomTargetCenterOffset is set in _Init, only needs to be set once + // but the view is moving, so now we need to re-calculate the spot in space + viewOffset.x = this->randomTargetCenterOffset.x + globalCtx->view.at.x - globalCtx->view.eye.x; + viewOffset.y = this->randomTargetCenterOffset.y + globalCtx->view.at.y - globalCtx->view.eye.y; + viewOffset.z = this->randomTargetCenterOffset.z + globalCtx->view.at.z - globalCtx->view.eye.z; - sp34.x = globalCtx->view.at.x + temp.x; - sp34.y = globalCtx->view.at.y + temp.y; - sp34.z = globalCtx->view.at.z + temp.z; + // this is the 3D spot in space where the cucco is trying to fly into (until it lands or gets close) + flightTarget.x = globalCtx->view.at.x + viewOffset.x; + flightTarget.y = globalCtx->view.at.y + viewOffset.y; + flightTarget.z = globalCtx->view.at.z + viewOffset.z; - this->unk_2CC = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); - this->unk_2C8 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; + this->targetRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &flightTarget); + this->targetRotX = Math_Vec3f_Pitch(&this->actor.world.pos, &flightTarget) * -1.0f; - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 5, this->unk_2D4, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 5, this->rotStep, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); - Actor_SetFocus(&this->actor, this->unk_2DC); - Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); - if (this->actor.bgCheckFlags & 8) { - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_2C8 = this->actor.world.rot.x - 3000.0f; - this->unk_252 = 0; - this->unk_254 = 100; - this->unk_2D4 = 0.0f; - this->unk_27C = 0.0f; - this->unk_274 = 0.0f; - this->unk_250 = this->unk_252; - this->unk_24E = this->unk_252; - this->unk_24C = this->unk_252; + if (this->actor.bgCheckFlags & 8) { // touching a wall + this->targetRotY = this->actor.yawTowardsPlayer; + this->targetRotX = this->actor.world.rot.x - 3000.0f; + this->hopTimer = 0; + this->randomAngleChangeTimer = 100; + this->rotStep = 0.0f; + this->targetLeftWingRotX = 0.0f; + this->targetRightWingRotX = 0.0f; + this->unkTimer250 = this->hopTimer; + this->unusedTimer24E = this->hopTimer; + this->unkTimer24C = this->hopTimer; this->actor.gravity = -0.2f; - this->unk_280 = 0.0f; - this->actionFunc = func_80958974; - this->unk_2D8 = 5.0f; - } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && - (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && - (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || - (this->actor.bgCheckFlags & 1)) { - this->unk_252 = 0; - this->unk_250 = this->unk_252; - this->unk_24E = this->unk_252; - this->unk_24C = this->unk_252; - this->unk_2D4 = 0.0f; - this->unk_274 = 0.0f; - this->unk_27C = 0.0f; - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_2C8 = this->actor.world.rot.x - 2000.0f; - this->actor.gravity = -0.2f; - this->unk_280 = 0.0f; - this->actionFunc = func_80958974; - this->unk_2D8 = 5.0f; - } else { - this->unk_24C = 10; - this->unk_25C = -10000.0f; - this->unk_280 = -3000.0f; - func_80958228(this, globalCtx, 2); + this->targetHeadRotZ = 0.0f; + this->actionFunc = EnAttackNiw_AimAtPlayer; + this->targetXZSpeed = 5.0f; + + } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(flightTarget.x - this->actor.world.pos.x) < 50.0f) && + (fabsf(flightTarget.y - this->actor.world.pos.y) < 50.0f) && + (fabsf(flightTarget.z - this->actor.world.pos.z) < 50.0f)) || + (this->actor.bgCheckFlags & 1)) { // touching ground or with close distance of target + // reset state + this->hopTimer = 0; + this->unkTimer250 = this->hopTimer; + this->unusedTimer24E = this->hopTimer; + this->unkTimer24C = this->hopTimer; + this->rotStep = 0.0f; + this->targetRightWingRotX = 0.0f; + this->targetLeftWingRotX = 0.0f; + + this->targetRotY = this->actor.yawTowardsPlayer; // start turn to face player + this->targetRotX = this->actor.world.rot.x - 2000.0f; // bank into the turn + this->actor.gravity = -0.2f; // start gentle decent (no longer flying without gravity) + this->targetHeadRotZ = 0.0f; + this->actionFunc = EnAttackNiw_AimAtPlayer; + this->targetXZSpeed = 5.0f; + + } else { // keep flying at the flightTarget for now + this->unkTimer24C = 10; + this->targetBodyRotY = -10000.0f; + this->targetHeadRotZ = -3000.0f; + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809585B0(this, globalCtx)) { +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { Actor_MarkForDeath(&this->actor); return; } - if (this->actor.bgCheckFlags & 1) { - if (this->unk_252 == 0) { - this->unk_252 = 3; + if (this->actor.bgCheckFlags & 1) { // touching floor + if (this->hopTimer == 0) { + this->hopTimer = 3; this->actor.velocity.y = 3.5f; } - if (this->actor.gravity != -2.0f) { - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_25A = 50; - this->unk_254 = 100; - this->unk_270 = 14000.0f; - this->unk_278 = 14000.0f; - this->unk_274 = 0.0f; - this->unk_27C = 0.0f; - this->unk_260 = 0.0f; - this->unk_264 = 0.0f; - this->unk_2C8 = 0.0f; + if (this->actor.gravity != -2.0f) { // first landing + this->targetRotY = this->actor.yawTowardsPlayer; + this->unkTimer25A = 50; + this->randomAngleChangeTimer = 100; + this->targetRightWingRotY = 14000.0f; + this->targetLeftWingRotY = 14000.0f; + this->targetRightWingRotX = 0.0f; + this->targetLeftWingRotX = 0.0f; + this->targetRightWingRotZ = 0.0f; + this->targetLeftWingRotZ = 0.0f; + this->targetRotX = 0.0f; this->actor.gravity = -2.0f; } } - if (this->unk_254 == 50) { - this->unk_2CC = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + if (this->randomAngleChangeTimer == 50) { + this->targetRotY = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; } - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, this->unk_2D4, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 2, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 10000.0f, 1.0f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, this->unk_2D8, 0.9f, 1.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 2, this->rotStep, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 2, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetXZSpeed, 0.9f, 1.0f); - if ((this->actor.gravity == -2.0f) && (this->unk_25A == 0) && - ((this->actor.bgCheckFlags & 8) || (this->unk_254 == 0))) { - this->unk_2D8 = 0.0f; + if (this->actor.gravity == -2.0f && this->unkTimer25A == 0 && + (this->actor.bgCheckFlags & 8 || this->randomAngleChangeTimer == 0)) { + this->targetXZSpeed = 0.0f; this->actor.gravity = 0.0f; - this->unk_2D4 = 0.0f; - this->unk_2C8 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_80958BE4; - } else if (this->actor.bgCheckFlags & 1) { - func_80958228(this, globalCtx, 5); + this->rotStep = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + + } else if (this->actor.bgCheckFlags & 1) { // touching floor + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); + } else { - func_80958228(this, globalCtx, 2); + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809585B0(this, globalCtx)) { +void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { Actor_MarkForDeath(&this->actor); return; } - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); - func_80958228(this, globalCtx, 2); + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -334,37 +350,17 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { EnNiw* parent; Player* player = GET_PLAYER(globalCtx); s32 pad2; - Vec3f sp30; + Vec3f splashPos; - this->unk_284++; + this->unusedCounter284++; - if (this->unk_24C != 0) { - this->unk_24C--; - } - - if (this->unk_250 != 0) { - this->unk_250--; - } - - if (this->unk_252 != 0) { - this->unk_252--; - } - - if (this->unk_256 != 0) { - this->unk_256--; - } - - if (this->unk_258 != 0) { - this->unk_258--; - } - - if (this->unk_254 != 0) { - this->unk_254--; - } - - if (this->unk_25A != 0) { - this->unk_25A--; - } + DECR(this->unkTimer24C); + DECR(this->unkTimer250); + DECR(this->hopTimer); + DECR(this->crySfxTimer); + DECR(this->flutterSfxTimer); + DECR(this->randomAngleChangeTimer); + DECR(this->unkTimer25A); this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; @@ -373,45 +369,48 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - if (this->actionFunc == func_80958634) { + if (this->actionFunc == EnAttackNiw_EnterViewFromOffscreen) { Actor_MoveWithoutGravity(&this->actor); } else { Actor_MoveWithGravity(&this->actor); } - if (this->actor.floorHeight <= -32000.0f) { + if (this->actor.floorHeight <= BGCHECK_Y_MIN) { // under the world Actor_MarkForDeath(&this->actor); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_80958BE4)) { - Math_Vec3f_Copy(&sp30, &this->actor.world.pos); - sp30.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(globalCtx, &sp30, NULL, NULL, 0, 400); - this->unk_2D4 = 0.0f; + } else if ((this->actor.bgCheckFlags & 0x20) && // on or below water + (this->actionFunc != EnAttackNiw_FlyAway)) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.y += this->actor.depthInWater; + EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 0, 400); + this->rotStep = 0.0f; this->actor.gravity = 0.0f; - this->unk_2D8 = 0.0f; - this->unk_2C8 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_80958BE4; + this->targetXZSpeed = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + } else { - f32 temp = 20.0f; + f32 viewOffset = 20.0f; label: - if (this->actor.xyzDistToPlayerSq < SQ(temp)) { + if (this->actor.xyzDistToPlayerSq < SQ(viewOffset)) { parent = (EnNiw*)this->actor.parent; if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && - (parent->unusedTimer25E == 0) && (player->invincibilityTimer == 0)) { + (parent->unkAttackNiwTimer == 0) && (player->invincibilityTimer == 0)) { + // this updates some player values based on what we pass, need player decomp to know what this is doing func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); - parent->unusedTimer25E = 70; + parent->unkAttackNiwTimer = 70; } } - if (this->unk_256 == 0) { - this->unk_256 = 30; + if (this->crySfxTimer == 0) { + this->crySfxTimer = 30; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); } - if (this->unk_258 == 0) { - this->unk_258 = 7; + if (this->flutterSfxTimer == 0) { + this->flutterSfxTimer = 7; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); } } @@ -421,24 +420,24 @@ s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnAttackNiw* this = THIS; - if (limbIndex == OBJECT_NIW_LIMB_0D) { - rot->y += (s16)this->unk_2B4; + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; } - if (limbIndex == OBJECT_NIW_LIMB_0F) { - rot->z += (s16)this->unk_2B8; + if (limbIndex == NIW_LIMB_HEAD) { + rot->z += (s16)this->headRotZ; } - if (limbIndex == OBJECT_NIW_LIMB_0B) { - rot->x += (s16)this->unk_2B0; - rot->y += (s16)this->unk_2AC; - rot->z += (s16)this->unk_2A8; + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; } - if (limbIndex == OBJECT_NIW_LIMB_07) { - rot->x += (s16)this->unk_2A4; - rot->y += (s16)this->unk_2A0; - rot->z += (s16)this->unk_29C; + if (limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->x += (s16)this->leftWingRotX; + rot->y += (s16)this->leftWingRotY; + rot->z += (s16)this->leftWingRotZ; } return false; } diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h index 4d3243ef5..c4dcaf8d0 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h @@ -11,49 +11,52 @@ typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); typedef struct EnAttackNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_NIW_LIMB_MAX]; - /* 0x1E8 */ Vec3s morphTable[OBJECT_NIW_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; /* 0x248 */ EnAttackNiwActionFunc actionFunc; - /* 0x24C */ s16 unk_24C; - /* 0x24E */ s16 unk_24E; - /* 0x250 */ s16 unk_250; - /* 0x252 */ s16 unk_252; - /* 0x254 */ s16 unk_254; - /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ s16 unk_25A; - /* 0x25C */ f32 unk_25C; - /* 0x260 */ f32 unk_260; - /* 0x264 */ f32 unk_264; - /* 0x268 */ UNK_TYPE1 unk268[8]; - /* 0x270 */ f32 unk_270; - /* 0x274 */ f32 unk_274; - /* 0x278 */ f32 unk_278; - /* 0x27C */ f32 unk_27C; - /* 0x280 */ f32 unk_280; - /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ UNK_TYPE1 unk288[2]; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ UNK_TYPE1 unk28C[4]; - /* 0x290 */ Vec3f unk_290; - /* 0x29C */ f32 unk_29C; - /* 0x2A0 */ f32 unk_2A0; - /* 0x2A4 */ f32 unk_2A4; - /* 0x2A8 */ f32 unk_2A8; - /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; - /* 0x2BC */ UNK_TYPE1 unk2BC[0xC]; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ UNK_TYPE1 unk2D0[4]; - /* 0x2D4 */ f32 unk_2D4; - /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC; + /* 0x24C */ s16 unkTimer24C; // control behavior in _UpdateRotations + /* 0x24E */ s16 unusedTimer24E; // set never read + /* 0x250 */ s16 unkTimer250; // control behavior in _UpdateRotations + /* 0x252 */ s16 hopTimer; + /* 0x254 */ s16 randomAngleChangeTimer; + /* 0x256 */ s16 crySfxTimer; + /* 0x258 */ s16 flutterSfxTimer; + /* 0x25A */ s16 unkTimer25A; // set to 50 in run at player, locks fly away without water? + /* 0x25C */ f32 targetBodyRotY; + /* 0x260 */ f32 targetRightWingRotZ; + /* 0x264 */ f32 targetLeftWingRotZ; + /* 0x268 */ f32 unusedRotations[2]; // in EnNiw this is an array of targetRot + /* 0x270 */ f32 targetRightWingRotY; + /* 0x274 */ f32 targetRightWingRotX; + /* 0x278 */ f32 targetLeftWingRotY; + /* 0x27C */ f32 targetLeftWingRotX; + /* 0x280 */ f32 targetHeadRotZ; + /* 0x284 */ s16 unusedCounter284; // incremented in _Update, never read + /* 0x286 */ s16 clearRotYToggleTimer; + /* 0x288 */ UNK_TYPE1 pad288[2]; + /* 0x28A */ s16 unkToggle28A; + /* 0x28C */ UNK_TYPE1 pad28C[4]; + /* 0x290 */ Vec3f randomTargetCenterOffset; // see EnAttackNiw_EnterViewFromOffscreen + /* 0x29C */ f32 leftWingRotZ; + /* 0x2A0 */ f32 leftWingRotY; + /* 0x2A4 */ f32 leftWingRotX; + /* 0x2A8 */ f32 rightWingRotZ; + /* 0x2AC */ f32 rightWingRotY; + /* 0x2B0 */ f32 rightWingRotX; + /* 0x2B4 */ f32 upperBodyRotY; + /* 0x2B8 */ f32 headRotZ; + /* 0x2BC */ UNK_TYPE1 pad2BC[0xC]; // unused rotations? + /* 0x2C8 */ f32 targetRotX; + /* 0x2CC */ f32 targetRotY; + /* 0x2D0 */ UNK_TYPE1 pad2D0[4]; + /* 0x2D4 */ f32 rotStep; + /* 0x2D8 */ f32 targetXZSpeed; + /* 0x2DC */ f32 targetHeight; // never set, but sent to Actor_SetFocus } EnAttackNiw; // size = 0x2E0 extern const ActorInit En_Attack_Niw_InitVars; + +#define ATTACK_NIW_REGULAR 0 // spawned by EnNiw + #endif // Z_EN_ATTACK_NIW_H diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index e15e3adb3..5e886bcc0 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -18,8 +18,8 @@ void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80952FE0(EnHs* this, GlobalContext* globalCtx); void func_80953098(EnHs* this, GlobalContext* globalCtx); void func_80953180(EnHs* this, GlobalContext* globalCtx); -void func_809532C0(EnHs* this, GlobalContext* globalCtx); -void func_809532D0(EnHs* this, GlobalContext* globalCtx); +void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx); +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx); void func_80953354(EnHs* this, GlobalContext* globalCtx); void func_8095345C(EnHs* this, GlobalContext* globalCtx); @@ -61,12 +61,12 @@ void func_80952C50(EnHs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { - Math_Vec3f_Copy(&this->unk_2A4[i], &player->actor.world.pos); + for (i = 0; i < ARRAY_COUNT(this->nwcPos); i++) { + Math_Vec3f_Copy(&this->nwcPos[i], &player->actor.world.pos); } - this->actor.home.rot.x = 0; - this->actor.home.rot.z = 0; + this->actor.home.rot.x = 0; // reset adult transformed count + this->actor.home.rot.z = 0; // reset chick count } void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -74,17 +74,19 @@ void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { EnHs* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, - this->morphTable, OBJECT_HS_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gHsSkeleton, &gHsIdleAnim, this->jointTable, this->morphTable, + OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gHsIdleAnim); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_8095345C; + if (globalCtx->curSpawn == 1) { this->actor.flags |= ACTOR_FLAG_10000; } - this->unk_2A0 = 0; + + this->stateFlags = 0; this->actor.targetMode = 6; func_80952C50(this, globalCtx); } @@ -102,56 +104,56 @@ void func_80952DFC(GlobalContext* globalCtx) { func_80151BB4(globalCtx, 0x10); } -void func_80952E50(Vec3f* dst, Vec3f src, f32 arg2) { - Vec3f sp1C; - f32 temp_f0; +void EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { + Vec3f diff; + f32 distance; - Math_Vec3f_Diff(&src, dst, &sp1C); + Math_Vec3f_Diff(&src, dst, &diff); - temp_f0 = SQ(sp1C.x) + SQ(sp1C.z); + distance = SQ(diff.x) + SQ(diff.z); // gets un-squared after we check if we are too close - if (SQ(arg2) > temp_f0) { + if (SQ(offset) > distance) { return; } - temp_f0 = sqrtf(temp_f0); - sp1C.x *= (temp_f0 - arg2) / temp_f0; - sp1C.z *= (temp_f0 - arg2) / temp_f0; + distance = sqrtf(distance); + diff.x *= (distance - offset) / distance; + diff.z *= (distance - offset) / distance; - dst->x += sp1C.x; - dst->z += sp1C.z; + dst->x += diff.x; + dst->z += diff.z; } void func_80952F00(EnHs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; - f32 phi_f20; + f32 offset; - if (this->actor.home.rot.z >= 20) { - phi_f20 = 15.0f; + if (this->actor.home.rot.z >= 20) { // current chick count >= 10 + offset = 15.0f; } else { - phi_f20 = 10.0f; + offset = 10.0f; } - func_80952E50(&this->unk_2A4[0], player->actor.world.pos, phi_f20); + EnHs_UpdateChickPos(&this->nwcPos[0], player->actor.world.pos, offset); - for (i = 1; i < ARRAY_COUNT(this->unk_2A4); i++) { - func_80952E50(&this->unk_2A4[i], this->unk_2A4[i - 1], phi_f20); + for (i = 1; i < ARRAY_COUNT(this->nwcPos); i++) { + EnHs_UpdateChickPos(&this->nwcPos[i], this->nwcPos[i - 1], offset); } } void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { - if (this->unk_2A2 < 40) { - Math_SmoothStepToS(&this->unk_294.y, 0x1F40, 6, 0x1838, 0x64); - } else if (this->unk_2A2 < 80) { - Math_SmoothStepToS(&this->unk_294.y, -0x1F40, 6, 0x1838, 0x64); + if (this->stateTimer < 40) { + Math_SmoothStepToS(&this->headRot.y, 0x1F40, 6, 0x1838, 0x64); + } else if (this->stateTimer < 80) { + Math_SmoothStepToS(&this->headRot.y, -0x1F40, 6, 0x1838, 0x64); } else { this->actionFunc = func_80953180; - this->unk_2A0 &= ~4; + this->stateFlags &= ~4; func_80151938(globalCtx, 0x33F6); func_80952DFC(globalCtx); } - this->unk_2A2++; + this->stateTimer++; } void func_80953098(EnHs* this, GlobalContext* globalCtx) { @@ -159,10 +161,10 @@ void func_80953098(EnHs* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_8095345C; this->actor.flags |= ACTOR_FLAG_10000; - this->unk_2A0 |= 0x10; + this->stateFlags |= 0x10; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { - this->unk_2A0 |= 8; + this->stateFlags |= 8; if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); } else { @@ -174,31 +176,31 @@ void func_80953098(EnHs* this, GlobalContext* globalCtx) { void func_80953180(EnHs* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { - case 0x33F4: - case 0x33F6: + case 0x33F4: // text: laughing that they are all roosters (!) + case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood func_801477B4(globalCtx); this->actionFunc = func_8095345C; break; - case 0x33F7: + case 0x33F7: // text: notice his chicks are grown up, happy, wants to give you bunny hood this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = func_80953098; func_80953098(this, globalCtx); break; - case 0x33F9: + case 0x33F9: // text: laughing that they are all roosters (.) this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = func_8095345C; break; - case 0x33F5: + case 0x33F5: // He heard from his gramps (?) the moon is going to fall globalCtx->msgCtx.unk11F10 = 0; this->actionFunc = func_80952FE0; - this->unk_2A2 = 0; - this->unk_294.z = 0; - this->unk_2A0 |= 4; + this->stateTimer = 0; + this->headRot.z = 0; + this->stateFlags |= 4; break; default: @@ -209,34 +211,34 @@ void func_80953180(EnHs* this, GlobalContext* globalCtx) { } } -void func_809532C0(EnHs* this, GlobalContext* globalCtx) { +void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx) { } -void func_809532D0(EnHs* this, GlobalContext* globalCtx) { - if (DECR(this->unk_2A2) == 0) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENHS_GET_F(&this->actor)]; +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; globalCtx->sceneLoadFlag = 0x14; gSaveContext.save.weekEventReg[25] |= 8; - this->actionFunc = func_809532C0; + this->actionFunc = EnHs_DoNothing; } } void func_80953354(EnHs* this, GlobalContext* globalCtx) { if (!Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->actor, 7); - this->actionFunc = func_809532D0; + this->actionFunc = EnHs_SceneTransitToBunnyHoodDialogue; } } void func_809533A0(EnHs* this, GlobalContext* globalCtx) { u16 sp1E; - if ((globalCtx->curSpawn == 1) && !(this->unk_2A0 & 0x20)) { + if ((globalCtx->curSpawn == 1) && !(this->stateFlags & 0x20)) { sp1E = 0x33F7; - this->unk_2A0 |= 0x20; - } else if (this->unk_2A0 & 0x10) { + this->stateFlags |= 0x20; + } else if (this->stateFlags & 0x10) { sp1E = 0x33F9; - this->unk_2A0 &= ~0x10; + this->stateFlags &= ~0x10; } else if (gSaveContext.save.weekEventReg[25] & 8) { sp1E = 0x33F4; } else { @@ -254,21 +256,21 @@ void func_8095345C(EnHs* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80953180; func_809533A0(this, globalCtx); - if (this->unk_2A0 & 8) { + if (this->stateFlags & 8) { func_80952DFC(globalCtx); - this->unk_2A0 &= ~8; + this->stateFlags &= ~8; } - } else if (this->actor.home.rot.x >= 20) { + } else if (this->actor.home.rot.x >= 20) { // chicks turned adult >= 10 this->actionFunc = func_80953354; - this->unk_2A2 = 40; + this->stateTimer = 40; } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); - this->unk_2A0 |= 1; + this->stateFlags |= 1; } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { func_800B8614(&this->actor, globalCtx, 130.0f); - this->unk_2A0 |= 1; + this->stateFlags |= 1; } else { - this->unk_2A0 &= ~1; + this->stateFlags &= ~1; } } @@ -290,17 +292,17 @@ void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { func_80952F00(this, globalCtx); - if (this->unk_2A0 & 4) { - Math_SmoothStepToS(&this->unk_294.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); - } else if (this->unk_2A0 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_294, &this->unk_29A, this->actor.focus.pos); + if (this->stateFlags & 4) { + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); + } else if (this->stateFlags & 1) { + func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); } else { - Math_SmoothStepToS(&this->unk_294.x, 0x3200, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_294.y, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.x, 0x3200, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); } } @@ -308,29 +310,33 @@ s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnHs* this = THIS; switch (limbIndex) { - case OBJECT_HS_LIMB_09: - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; + case HS_LIMB_HEAD: + rot->x += this->headRot.y; + rot->z += this->headRot.x; break; - case OBJECT_HS_LIMB_0A: - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; + case HS_LIMB_HAIR_SPIKES: + rot->x += this->headRot.y; + rot->z += this->headRot.x; break; - case OBJECT_HS_LIMB_0B: + case HS_LIMB_HIDDEN_HAIR: + // for some reason this hair is always removed here in the Override limb + // if you do re-enable, make sure you add the head rot like above *dList = NULL; return false; + // these two limbs both have empty enddisplaylist, they do nothing + // at the same time (params == HS_TYPE_UNK1) is always false, because vanilla params is 0xFE01 case OBJECT_HS_LIMB_0C: - if (this->actor.params == ENHS_1) { + if (this->actor.params == HS_TYPE_UNK1) { *dList = NULL; return false; } break; case OBJECT_HS_LIMB_0D: - if (this->actor.params == ENHS_1) { + if (this->actor.params == HS_TYPE_UNK1) { *dList = NULL; return false; } @@ -342,7 +348,7 @@ s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHs* this = THIS; - if (limbIndex == OBJECT_HS_LIMB_09) { + if (limbIndex == HS_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index 0a50ee360..62fc1d2a1 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -8,9 +8,17 @@ struct EnHs; typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); -#define ENHS_GET_F(thisx) ((thisx)->params & 0xF) +#define HS_GET_EXIT_INDEX(thisx) ((thisx)->params & 0xF) -#define ENHS_1 1 +#define HS_TYPE_UNK1 1 + +// params mystery: Vanilla Grog is 0xFE01 +// 0xFE00 space is never checked in Grog code +// at the same time, type UNK1 is only checked directly with params == 1, no &F +// so HS_TYPE_UNK1 is never valid and is unused, as 0xFE00 is still present even if its not doing anything else + +// The count of [chicks following the player] is stored in [this->actor.home.rot.z] (incremented by 2) +// The count of [chicks transformed into adult] is stored in [this->actor.home.rot.x] (incremented by 2) typedef struct EnHs { /* 0x0000 */ Actor actor; @@ -18,11 +26,11 @@ typedef struct EnHs { /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; - /* 0x0294 */ Vec3s unk_294; - /* 0x029A */ Vec3s unk_29A; - /* 0x02A0 */ u16 unk_2A0; - /* 0x02A2 */ s16 unk_2A2; - /* 0x02A4 */ Vec3f unk_2A4[20]; + /* 0x0294 */ Vec3s headRot; + /* 0x029A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body + /* 0x02A0 */ u16 stateFlags; + /* 0x02A2 */ s16 stateTimer; // reused for different actionFunc + /* 0x02A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain /* 0x0394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index f6e398a33..e3be9ae03 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -5,7 +5,7 @@ */ #include "z_en_niw.h" -#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) @@ -30,12 +30,23 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx); void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx); void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx); void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx); -void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2); +void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState); void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); -// turned on during cucco storm, but not read by anything? -// maybe read by En_Attack_Niw -s16 D_80893460 = false; +s16 sCuccoStormActive = false; + +// why wouldnt they just use actionFunc? +enum EnNiwState { + /* 0 */ NIW_STATE_IDLE, + /* 1 */ NIW_STATE_ANGRY1, // 1/2/3 are stages of summoning cucco storm + /* 2 */ NIW_STATE_ANGRY2, + /* 3 */ NIW_STATE_ANGRY3, + /* 4 */ NIW_STATE_HELD, + /* 5 */ NIW_STATE_FALLING, + /* 6 */ NIW_STATE_SWIMMING, + /* 7 */ NIW_STATE_RUNNING, + /* 8 */ NIW_STATE_HOPPING, +}; const ActorInit En_Niw_InitVars = { ACTOR_EN_NIW, @@ -49,15 +60,11 @@ const ActorInit En_Niw_InitVars = { (ActorFunc)EnNiw_Draw, }; -static f32 D_80893484[] = { - 5000.0f, - -5000.0f, -}; -static f32 D_80893486[] = { - 5000.0f, - 3000.0f, - 4000.0f, -}; +static f32 sHeadRotations[] = { 5000.0f, -5000.0f }; + +static f32 sRunningAngles[] = { 5000.0f, 3000.0f }; + +static f32 sUnusedValue = 4000.0f; static ColliderCylinderInit sCylinderInit = { { @@ -109,8 +116,8 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = THIS; Vec3f dTemp = D_808934C4; - if (this->actor.params < 0) { // all neg values become zero - this->actor.params = ENNIW_TYPE_REGULAR; + if (this->actor.params < 0) { // all scene spawned cucco are (-1) + this->actor.params = NIW_TYPE_REGULAR; } Math_Vec3f_Copy(&this->unk2BC, &dTemp); @@ -122,32 +129,36 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelanime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, - this->morphTable, ENNIW_LIMBCOUNT); + SkelAnime_InitFlex(globalCtx, &this->skelanime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); Math_Vec3f_Copy(&this->unk2A4, &this->actor.world.pos); Math_Vec3f_Copy(&this->unk2B0, &this->actor.world.pos); this->unk308 = 10.0f; Actor_SetScale(&this->actor, 0.01f); - if (this->niwType == ENNIW_TYPE_UNK1) { + if (this->niwType == NIW_TYPE_UNK1) { + // @Bug this unused variant is broken and crashes on spawn (EnNiw_Update expects a parent, NULL) + // if modified to change niwType to TYPE_REGULAR here, new size is smaller than normal + // theory: was meant to be a small hand held cucco for grog to show the player Actor_SetScale(&this->actor, (BREG(86) / 10000.0f) + 0.004f); } // random health between 10-20 + // health at zero triggers cucco storm not death this->actor.colChkInfo.health = Rand_ZeroFloat(9.99f) + 10.0f; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if (this->niwType == ENNIW_TYPE_UNK2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + if (this->niwType == NIW_TYPE_HELD) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); this->sfxTimer1 = 30; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; this->unk2BC.z = 0.0f; @@ -161,105 +172,119 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = THIS; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { Collider_DestroyCylinder(globalCtx, &this->collider); } } -void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2) { - f32 tempOne = 1.0f; +/** + * Summary: instead of using SkelAnime animations, Niw modifies head+wings directly to create animations + * + * AttackNiw has a copy of this function that it barely uses + */ +void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState) { + f32 tempOne = 1.0f; // hopefully fake match, but no luck if (this->unkTimer24C == 0) { - if (arg2 == 0) { - this->unk264[0] = 0.0f; + // targetLimbRots[0] is bodyRotY + if (animationState == NIW_ANIMATION_STILL) { + this->targetLimbRots[0] = 0.0f; } else { - this->unk264[0] = (-10000.0f) * tempOne; + this->targetLimbRots[0] = -10000.0f * tempOne; } + this->unk292 += 1; this->unkTimer24C = 3; if ((this->unk292 % 2) == 0) { - this->unk264[0] = 0.0f; - if (arg2 == 0) { + this->targetLimbRots[0] = 0.0f; + if (animationState == NIW_ANIMATION_STILL) { this->unkTimer24C = Rand_ZeroFloat(30.0f); } } } + if (this->unkTimer24E == 0) { - this->unk296++; - this->unk296 &= 1; - switch (arg2) { - case 0: - this->unk264[2] = 0.0f; - this->unk264[1] = 0.0f; + this->unkToggle296++; + this->unkToggle296 &= 1; + + switch (animationState) { + case NIW_ANIMATION_STILL: + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; break; - case 1: + case NIW_ANIMATION_HEAD_PECKING: this->unkTimer24E = 3; - this->unk264[2] = 7000.0f * tempOne; - this->unk264[1] = 7000.0f * tempOne; - if (this->unk296 == 0) { - this->unk264[2] = 0.0f; - this->unk264[1] = 0.0f; + this->targetLimbRots[2] = 7000.0f * tempOne; // both wingRotZ + this->targetLimbRots[1] = 7000.0f * tempOne; + if (this->unkToggle296 == 0) { + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; } break; - case 2: + + case NIW_ANIMATION_PECKING_AND_WAVING: this->unkTimer24E = 2; - this->unk264[2] = -10000.0f; - this->unk264[1] = -10000.0f; - this->unk264[7] = 25000.0f; - this->unk264[5] = 25000.0f; - this->unk264[8] = 6000.0f; - this->unk264[6] = 6000.0f; - if (this->unk296 == 0) { - this->unk264[7] = 8000.0f; - this->unk264[5] = 8000.0f; + this->targetLimbRots[2] = -10000.0f; // both wingRotZ + this->targetLimbRots[1] = -10000.0f; + this->targetLimbRots[7] = 25000.0f; // both wingRotY + this->targetLimbRots[5] = 25000.0f; + this->targetLimbRots[8] = 6000.0f; // both wingRotX + this->targetLimbRots[6] = 6000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[7] = 8000.0f; // both wingRotY + this->targetLimbRots[5] = 8000.0f; } break; - case 3: + + case NIW_ANIMATION_PECKING_AND_FORFLAPPING: this->unkTimer24E = 2; - this->unk264[5] = 10000.0f; - this->unk264[7] = 10000.0f; - if (this->unk296 == 0) { - this->unk264[5] = 3000.0f; - this->unk264[7] = 3000.0f; + this->targetLimbRots[5] = 10000.0f; // both wingRotY + this->targetLimbRots[7] = 10000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[5] = 3000.0f; // both wingRotY + this->targetLimbRots[7] = 3000.0f; } break; - case 4: + + case NIW_ANIMATION_FREEZE: this->unkTimer24C = 5; break; - case 5: + + case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: this->unkTimer24E = 5; - this->unk264[5] = 14000.0f; - this->unk264[7] = 14000.0f; - if (this->unk296 == 0) { - this->unk264[5] = 10000.0f; - this->unk264[7] = 10000.0f; + this->targetLimbRots[5] = 14000.0f; // both wingRotY + this->targetLimbRots[7] = 14000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[5] = 10000.0f; // both wingRotY + this->targetLimbRots[7] = 10000.0f; } break; } } - if (this->unk264[9] != this->limbFRot) { - Math_ApproachF(&this->limbFRot, this->unk264[9], 0.5f, 4000.0f); + + if (this->targetLimbRots[9] != this->headRotY) { + Math_ApproachF(&this->headRotY, this->targetLimbRots[9], 0.5f, 4000.0f); } - if (this->unk264[0] != this->limbDRot) { - Math_ApproachF(&this->limbDRot, this->unk264[0], 0.5f, 4000.0f); + if (this->targetLimbRots[0] != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetLimbRots[0], 0.5f, 4000.0f); } - if (this->unk264[2] != this->limb7Rotz) { - Math_ApproachF(&this->limb7Rotz, this->unk264[2], 0.8f, 7000.0f); + if (this->targetLimbRots[2] != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLimbRots[2], 0.8f, 7000.0f); } - if (this->unk264[7] != this->limb7Roty) { - Math_ApproachF(&this->limb7Roty, this->unk264[7], 0.8f, 7000.0f); + if (this->targetLimbRots[7] != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLimbRots[7], 0.8f, 7000.0f); } - if (this->unk264[8] != this->limb7Rotx) { - Math_ApproachF(&this->limb7Rotx, this->unk264[8], 0.8f, 7000.0f); + if (this->targetLimbRots[8] != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLimbRots[8], 0.8f, 7000.0f); } - if (this->unk264[1] != this->limbBRotz) { - Math_ApproachF(&this->limbBRotz, this->unk264[1], 0.8f, 7000.0f); + if (this->targetLimbRots[1] != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetLimbRots[1], 0.8f, 7000.0f); } - if (this->unk264[5] != this->limbBRoty) { - Math_ApproachF(&this->limbBRoty, this->unk264[5], 0.8f, 7000.0f); + if (this->targetLimbRots[5] != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetLimbRots[5], 0.8f, 7000.0f); } - if (this->unk264[6] != this->limbBRotx) { - Math_ApproachF(&this->limbBRotx, this->unk264[6], 0.8f, 7000.0f); + if (this->targetLimbRots[6] != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetLimbRots[6], 0.8f, 7000.0f); } } @@ -270,7 +295,7 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { Vec3f newNiwPos; Actor* attackNiw; - if ((this->unkTimer252 == 0) && (this->unk290 < 7)) { + if (this->attackNiwSpawnTimer == 0 && this->attackNiwCount < 7) { xView = globalCtx->view.at.x - globalCtx->view.eye.x; yView = globalCtx->view.at.y - globalCtx->view.eye.y; zView = globalCtx->view.at.z - globalCtx->view.eye.z; @@ -278,54 +303,57 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { newNiwPos.y = randPlusMinusPoint5Scaled(0.3f) + (globalCtx->view.eye.y + 50.0f + (yView * 0.5f)); newNiwPos.z = ((Rand_ZeroOne() - 0.5f) * zView) + globalCtx->view.eye.z; attackNiw = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ATTACK_NIW, newNiwPos.x, - newNiwPos.y, newNiwPos.z, 0, 0, 0, 0); + newNiwPos.y, newNiwPos.z, 0, 0, 0, ATTACK_NIW_REGULAR); - if (attackNiw) { - this->unk290++; - this->unkTimer252 = 10; + if (attackNiw != NULL) { + this->attackNiwCount++; + this->attackNiwSpawnTimer = 10; } } } -void func_808917F8(EnNiw* this, GlobalContext* globalCtx, s32 arg2) { - f32 phi_f2; +void EnNiw_UpdateRunning(EnNiw* this, GlobalContext* globalCtx, s32 isStormCucco) { + f32 runningDirection; f32 targetRotY; - f32* D_8089348CPtr = D_80893486; + f32* runningAngles = sRunningAngles; - if (this->unkTimer250 == 0) { - this->unkTimer250 = 3; - if (this->actor.bgCheckFlags & 1) { - // hit floor - this->actor.velocity.y = 3.5f; // hop up? + if (this->hopTimer == 0) { + this->hopTimer = 3; + if (this->actor.bgCheckFlags & 1) { // hit floor + this->actor.velocity.y = 3.5f; // hopping up while running away } } - if (this->unkTimer252 == 0) { - this->unk29A++; - this->unk29A &= 1; - this->unkTimer252 = 5; + + if (this->runningDirectionTimer == 0) { + this->isRunningRight++; + this->isRunningRight &= 1; + this->runningDirectionTimer = 5; } - if (this->unk29A == 0) { - phi_f2 = D_8089348CPtr[arg2]; + + if (this->isRunningRight == false) { + runningDirection = runningAngles[isStormCucco]; } else { - phi_f2 = -D_8089348CPtr[arg2]; + runningDirection = -runningAngles[isStormCucco]; } - if (arg2 == 1 && (this->unkTimer254 == 0 || (this->actor.bgCheckFlags & 8))) { - this->unkTimer254 = 150; + + if (isStormCucco == true && + (this->runAwayTimer == 0 || (this->actor.bgCheckFlags & 8))) { // bgCheckFlags 8: hit a wall + this->runAwayTimer = 150; if (this->yawTimer == 0) { this->yawTimer = 70; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; } } - targetRotY = this->yawTowardsPlayer + phi_f2; + + targetRotY = this->yawTowardsPlayer + runningDirection; Math_SmoothStepToS(&this->actor.world.rot.y, targetRotY, 3, this->unk300, 0); Math_ApproachF(&this->unk300, 3000.0f, 1.0f, 500.0f); - func_80891320(this, globalCtx, 5); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); } void EnNiw_SetupIdle(EnNiw* this) { - Animation_Change(&this->skelanime, &object_niw_Anim_0000E8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_niw_Anim_0000E8), 0, -10.0f); - this->unknownState28E = 0; + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + this->niwState = NIW_STATE_IDLE; this->actionFunc = EnNiw_Idle; } @@ -334,40 +362,39 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { f32 posZ2; f32 posX1 = randPlusMinusPoint5Scaled(100.0f); f32 posZ1 = randPlusMinusPoint5Scaled(100.0f); - s16 s16tmp; + s16 nextAnimation; - if (this->niwType == ENNIW_TYPE_REGULAR) { - if (Actor_HasParent(&this->actor, globalCtx)) { - // picked up + if (this->niwType == NIW_TYPE_REGULAR) { + if (Actor_HasParent(&this->actor, globalCtx)) { // picked up Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actor.speedXZ = 0.0f; this->actionFunc = EnNiw_Held; return; } else { Actor_LiftActor(&this->actor, globalCtx); } - } else { - this->unkTimer252 = 10; + } else { // NIW_TYPE_UNK1 || NIW_TYPE_HELD + this->unkIdleTimer2 = 10; } - s16tmp = 0; - if (this->unkTimer252 != 0) { + nextAnimation = NIW_ANIMATION_STILL; // probably a scoped variable here, where their scope was different + if (this->unkIdleTimer2 != 0) { if (Rand_ZeroFloat(3.99f) < 1.0f) { - this->unk2EA++; - this->unk2EA &= 1; + this->headRotationToggle++; + this->headRotationToggle &= 1; } - Math_ApproachF(&this->unk264[9], D_80893484[this->unk2EA], 0.5f, 4000.0f); + + Math_ApproachF(&this->targetLimbRots[9], sHeadRotations[this->headRotationToggle], 0.5f, 4000.0f); // head rot } - if ((this->unkTimer252 == 0) && (this->unkTimer250 == 0)) { + if (this->unkIdleTimer2 == 0 && this->unkIdleTimer == 0) { this->unk298++; - if (this->unk298 > 7) { - this->unkTimer252 = Rand_ZeroFloat(30.0f); + this->unkIdleTimer2 = Rand_ZeroFloat(30.0f); this->unk298 = Rand_ZeroFloat(3.99f); if (posX1 < 0.0f) { @@ -385,17 +412,17 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { this->unk2B0.z = this->unk2A4.z + posZ1; } else { - this->unkTimer250 = 4; - if (this->actor.bgCheckFlags & 1) { + this->unkIdleTimer = 4; + if (this->actor.bgCheckFlags & 1) { // hit floor this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 3.5f; + this->actor.velocity.y = 3.5f; // hopping up and down } } } - if (this->unkTimer250 != 0) { - Math_ApproachZeroF(&this->unk264[9], 0.5f, 4000.0f); - s16tmp = 1; + if (this->unkIdleTimer != 0) { + Math_ApproachZeroF(&this->targetLimbRots[9], 0.5f, 4000.0f); // head rot + nextAnimation = NIW_ANIMATION_HEAD_PECKING; Math_ApproachF(&this->actor.world.pos.x, this->unk2B0.x, 1.0f, this->unk300); Math_ApproachF(&this->actor.world.pos.z, this->unk2B0.z, 1.0f, this->unk300); Math_ApproachF(&this->unk300, 3.0f, 1.0f, 0.3f); @@ -411,33 +438,34 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { } if ((posX2 == 0.0f) && (posZ2 == 0.0f)) { - this->unkTimer250 = 0; + this->unkIdleTimer = 0; this->unk298 = 7; } Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S(posX2, posZ2), 3, this->unk304, 0); Math_ApproachF(&this->unk304, 10000.0f, 1.0f, 1000.0f); } - func_80891320(this, globalCtx, s16tmp); + + EnNiw_AnimateWingHead(this, globalCtx, nextAnimation); } void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { Vec3f vec3fcopy = D_808934DC; s16 rotZ; - if (this->unkTimer250 == 0) { + if (this->heldTimer == 0) { this->unk29E = 2; - this->unkTimer250 = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; + this->heldTimer = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; } this->actor.shape.rot.x = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.x; this->actor.shape.rot.y = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.y; this->actor.shape.rot.z = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.z; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; - this->unknownState28E = 5; + this->niwState = NIW_STATE_FALLING; this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; this->actor.shape.rot.y = rotZ; @@ -449,9 +477,9 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.velocity.y = 8.0f; this->actor.speedXZ = 4.0f; this->actor.gravity = -2.0f; - this->unknownState28E = 5; + this->niwState = NIW_STATE_FALLING; this->unk2EC = 0; - this->niwType = ENNIW_TYPE_REGULAR; + this->niwType = NIW_TYPE_REGULAR; this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -459,29 +487,29 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } -// action function: recently thrown, and also hopping on the floor void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { if (this->unk2EC == 0) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->unk2EC = 1; - this->unkTimer252 = 80; // hop timer + this->hoppingTimer = 80; // hop timer this->actor.speedXZ = 0.0f; this->actor.velocity.y = 4.0f; } else { return; // wait until back on floor } } else { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->sfxTimer1 = 0; this->actor.velocity.y = 4.0f; // vertical hop this->unk29E = 1; } - if (this->unkTimer252 == 0) { - this->unkTimer254 = 100; - this->unkTimer250 = 0; + if (this->hoppingTimer == 0) { + this->runAwayTimer = 100; + this->heldTimer = 0; this->unk2EC = 0; EnNiw_SetupRunAway(this); return; @@ -493,20 +521,19 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; } else { - if (this->unkTimer252 > 5) { + if (this->hoppingTimer > 5) { Actor_LiftActor(&this->actor, globalCtx); } - func_80891320(this, globalCtx, 2); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -// action func: swimming and flying away after swimming void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { Vec3f ripplePos; @@ -517,73 +544,74 @@ void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { } this->actor.speedXZ = 2.0f; - if (this->actor.bgCheckFlags & 0x20) { - // still touching water + if (this->actor.bgCheckFlags & 0x20) { // touching water this->actor.gravity = 0.0f; if (this->actor.depthInWater > 15.0f) { this->actor.world.pos.y += 2.0f; } - if (this->unkTimer250 == 0) { - this->unkTimer250 = 30; + if (this->swimRippleTimer == 0) { + this->swimRippleTimer = 30; Math_Vec3f_Copy(&ripplePos, &this->actor.world.pos); ripplePos.y += this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 30); } - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y = 10.0f; + if (this->actor.bgCheckFlags & 8) { // hit a wall + this->actor.velocity.y = 10.0f; // fly up in straight line this->actor.speedXZ = 1.0f; } } else { this->actor.gravity = -2.0f; - if (this->actor.bgCheckFlags & 8) { - // has hit a wall - this->actor.velocity.y = 10.0f; // to the moon + if (this->actor.bgCheckFlags & 8) { // hit a wall + this->actor.velocity.y = 10.0f; // fly up in straight line this->actor.speedXZ = 1.0f; this->actor.gravity = 0.0f; } else { this->actor.speedXZ = 4.0f; } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->actor.gravity = -2.0f; - this->unkTimer254 = 100; - this->unkTimer250 = 0; + this->runAwayTimer = 100; + this->swimRippleTimer = 0; this->actor.velocity.y = 0.0f; if (!this->isStormActive) { EnNiw_SetupRunAway(this); } else { - this->unknownState28E = 3; + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } } } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { - s32 value; + s32 state; + + // Possible Fake Match: the weird way this state is set if (1) { - value = 1; + state = NIW_STATE_ANGRY1; } - this->unkTimer252 = 10; - this->unknownState28E = this->unk29C = value; + this->cuccoStormTimer = 10; + this->niwState = this->nextAnimation = state; // NIW_ANIMATION_HEAD_PECKING this->actionFunc = EnNiw_Upset; } void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx) { // assumption: CuccoStorm is split into smaller parts because it used to be a cutscene in OOT this->sfxTimer1 = 100; - if (this->unkTimer252 == 0) { - this->unkTimer252 = 60; + if (this->cuccoStormTimer == 0) { + this->cuccoStormTimer = 60; this->unkTimer24C = 10; - this->unk29C = 4; - this->unknownState28E = 2; + this->nextAnimation = NIW_ANIMATION_FREEZE; + this->niwState = NIW_STATE_ANGRY2; this->actionFunc = EnNiw_SetupCuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); } // the long crow with head back before they descend @@ -591,45 +619,46 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { f32 viewY; this->sfxTimer1 = 100; - if (this->unkTimer252 == 40) { + if (this->cuccoStormTimer == 40) { viewY = 14000.0f; - this->unk264[0] = 10000.0f; - this->unk264[7] = this->unk264[5] = viewY; - this->unk264[6] = 0.0f; - this->unk264[8] = 0.0f; - this->unk264[1] = 0.0f; - this->unk264[2] = 0.0f; + this->targetLimbRots[0] = 10000.0f; // body rot + this->targetLimbRots[7] = this->targetLimbRots[5] = viewY; + this->targetLimbRots[6] = 0.0f; + this->targetLimbRots[8] = 0.0f; + this->targetLimbRots[1] = 0.0f; + this->targetLimbRots[2] = 0.0f; this->unkTimer24C = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); } - if (this->unkTimer252 == 0) { - this->unkTimer252 = 10; + + if (this->cuccoStormTimer == 0) { + this->cuccoStormTimer = 10; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 3; + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + + EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); } void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { EnNiw_SpawnAttackNiw(this, globalCtx); - if (this->unkTimer252 == 1) { + if (this->cuccoStormTimer == 1) { // not countdown to 0? mistype? this->actor.speedXZ = 3.0f; - this->unk29A = Rand_ZeroFloat(1.99f); - this->unkTimer250 = 0; - this->unkTimer24E = this->unkTimer250; - this->unkTimer24C = this->unkTimer250; + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->generalTimer1 = 0; + this->unkTimer24E = this->generalTimer1; + this->unkTimer24C = this->generalTimer1; } else { - func_808917F8(this, globalCtx, 1); + EnNiw_UpdateRunning(this, globalCtx, true); } } void EnNiw_SetupRunAway(EnNiw* this) { - Animation_Change(&this->skelanime, &object_niw_Anim_0000E8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_niw_Anim_0000E8), 0, -10.0f); - this->unk29A = Rand_ZeroFloat(1.99f); - this->unknownState28E = 7; + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; this->actor.speedXZ = 4.0f; } @@ -641,22 +670,21 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { f32 dX; f32 dZ; - if (this->unkTimer254 == 0) { + if (this->runAwayTimer == 0) { this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; - - this->unkTimer252 = this->unkTimer250 = this->unk298 = 0; + this->generalTimer2 = this->generalTimer1 = this->unk298 = 0; this->unk300 = this->unk304 = 0; - this->actor.speedXZ = 0; - - this->unk264[8] = 0; - this->unk264[6] = 0; - this->unk264[5] = 0; - this->unk264[7] = 0; + this->targetLimbRots[8] = 0; + this->targetLimbRots[6] = 0; + this->targetLimbRots[5] = 0; + this->targetLimbRots[7] = 0; Math_Vec3f_Copy(&this->unk2BC, &tempVec3f); + EnNiw_SetupIdle(this); + } else { if (this->unk2BC.x != 90000.0f) { dX = this->actor.world.pos.x - this->unk2BC.x; @@ -666,25 +694,27 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { dZ = this->actor.world.pos.z - player->actor.world.pos.z; } this->yawTowardsPlayer = Math_Atan2S(dX, dZ); - func_808917F8(this, globalCtx, 0); - func_80891320(this, globalCtx, 2); + EnNiw_UpdateRunning(this, globalCtx, false); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } void EnNiw_LandBeforeIdle(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor EnNiw_SetupIdle(this); } } void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { - if (!this->isStormActive && (this->unkTimer260 == 0) && (this->niwType == ENNIW_TYPE_REGULAR)) { - if ((this->unknownState28E != 7) && (this->unk2BC.x != 90000.0f)) { - this->unkTimer260 = 10; + if (!this->isStormActive && this->iframeTimer == 0 && this->niwType == NIW_TYPE_REGULAR) { + + // is this used? this is before we even know if we've been hit + if (this->niwState != NIW_STATE_RUNNING && this->unk2BC.x != 90000.0f) { + this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow - this->unkTimer254 = 100; + this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); } @@ -696,32 +726,32 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health--; } - if ((!D_80893460) && (this->actor.colChkInfo.health == 0)) { - // now you've done it - this->unkTimer254 = 100; - D_80893460 = true; + if (!sCuccoStormActive && this->actor.colChkInfo.health == 0) { + this->runAwayTimer = 100; // main cucco will run away after storm starts + sCuccoStormActive = true; this->unk298 = 0; this->sfxTimer1 = 10000; this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; - this->unkTimer252 = this->unkTimer250 = this->unk298; + this->generalTimer2 = this->generalTimer1 = this->unk298; - this->unk264[8] = 0.0f; - this->unk264[6] = 0.0f; - this->unk264[5] = 0.0f; - this->unk264[7] = 0.0f; + this->targetLimbRots[8] = 0.0f; + this->targetLimbRots[6] = 0.0f; + this->targetLimbRots[5] = 0.0f; + this->targetLimbRots[7] = 0.0f; this->isStormActive = true; this->actionFunc = EnNiw_Trigger; this->unk304 = 0.0f; this->unk300 = 0.0f; this->actor.speedXZ = 0.0f; + } else { - this->unkTimer260 = 10; + this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow - this->unkTimer254 = 100; + this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); } @@ -737,10 +767,9 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s16 pad1; s16 featherCount; Vec3f pos; - Vec3f spB8; - Vec3f spAC; - s32 pad2[9]; - s16 temp29C; + Vec3f vel; + Vec3f accel; + s32 pad2[10]; f32 featherScale; f32 viewAtToEyeNormY; f32 floorHeight; @@ -749,16 +778,16 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->unusedCounter28C++; - if (this->niwType == ENNIW_TYPE_UNK1) { + if (this->niwType == NIW_TYPE_UNK1) { this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.parent->shape.rot.y; } - if (this->unknownState28E != 0) { - this->unk264[9] = 0.0f; + if (this->niwState != NIW_STATE_IDLE) { + this->targetLimbRots[9] = 0.0f; // head rot } if (this->unk29E != 0) { - featherCount = ENNIW_FEATHERCOUNT; + featherCount = NIW_FEATHER_COUNT; if (this->unk29E == 2) { featherCount = 4; } @@ -768,20 +797,20 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; featherScale = Rand_ZeroFloat(6.0f) + 6.0f; - if ((this->unk29E == 2) && (this->unk308 != 0)) { + if (this->unk29E == 2 && this->unk308 != 0) { pos.y += 10.0f; } if (this->unk308 == 0) { featherScale = Rand_ZeroFloat(2.0f) + 2.0f; } - spB8.x = randPlusMinusPoint5Scaled(3.0f); - spB8.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; - spB8.z = randPlusMinusPoint5Scaled(3.0f); - spAC.z = spAC.x = 0.0f; - spAC.y = -0.15000000596f; + vel.x = randPlusMinusPoint5Scaled(3.0f); + vel.y = Rand_ZeroFloat(2.0f) * 0.5f + 2.0f; + vel.z = randPlusMinusPoint5Scaled(3.0f); + accel.z = accel.x = 0.0f; + accel.y = -0.15f; - EnNiw_SpawnFeather(this, &pos, &spB8, &spAC, featherScale); + EnNiw_SpawnFeather(this, &pos, &vel, &accel, featherScale); } this->unk29E = 0; } @@ -790,15 +819,15 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { DECR(this->unkTimer24C); DECR(this->unkTimer24E); - DECR(this->unkTimer250); - DECR(this->unkTimer252); - DECR(this->unkTimer254); + DECR(this->generalTimer1); + DECR(this->generalTimer2); + DECR(this->runAwayTimer); DECR(this->sfxTimer1); DECR(this->flutterSfxTimer); DECR(this->unusedTimer25A); DECR(this->yawTimer); - DECR(this->unusedTimer25E); - DECR(this->unkTimer260); + DECR(this->unkAttackNiwTimer); + DECR(this->iframeTimer); this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; @@ -808,7 +837,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); - // if cucco is off the map? + // if cucco is off the map if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { Vec3f viewAtToEye; @@ -820,7 +849,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.x = this->actor.home.pos.x; this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (viewAtToEyeNormY * 160.0f); + this->actor.world.pos.y = this->actor.home.pos.y + globalCtx->view.eye.y + (viewAtToEyeNormY * 160.0f); if (this->actor.world.pos.y < this->actor.home.pos.y) { this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; @@ -833,75 +862,74 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk304 = 0.0f; this->unk300 = 0.0f; - this->unusedFloat2FC = 0.0f; + this->unusedFloat2FC = 0.0f; // assigned here but never used after this->unusedFloat2F8 = 0.0f; this->unusedFloat2F4 = 0.0f; - this->limbBRotx = 0.0f; - this->limbBRoty = 0.0f; - this->limbBRotz = 0.0f; - this->limb7Rotx = 0.0f; - this->limb7Roty = 0.0f; - this->limb7Rotz = 0.0f; - this->limbDRot = 0.0f; - this->limbFRot = 0.0f; + this->rightWingRotX = 0.0f; + this->rightWingRotY = 0.0f; + this->rightWingRotZ = 0.0f; + this->leftWingRotX = 0.0f; + this->leftWingRotY = 0.0f; + this->leftWingRotZ = 0.0f; + this->upperBodyRotY = 0.0f; + this->headRotY = 0.0f; // clang-format off - this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->unk29A = this->unk29C = 0; + this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->isRunningRight = this->nextAnimation = 0; // clang-format on for (i = 0; i < 10; i++) { - this->unk264[i] = 0.0f; + this->targetLimbRots[i] = 0.0f; } - this->unknownState28E = 8; + this->niwState = NIW_STATE_HOPPING; this->isStormActive = false; this->actionFunc = EnNiw_LandBeforeIdle; return; + } - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f) && - (this->unknownState28E != 6)) { + if ((this->actor.bgCheckFlags & 0x20) && // touching water + this->actor.depthInWater > 15.0f && this->niwState != NIW_STATE_SWIMMING) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; Math_Vec3f_Copy(&pos, &this->actor.world.pos); pos.y += this->actor.depthInWater; - this->unkTimer250 = 30; + this->swimRippleTimer = 30; EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); - this->unkTimer252 = 0; - this->unknownState28E = 6; + this->generalTimer2 = 0; + this->niwState = NIW_STATE_SWIMMING; this->actionFunc = EnNiw_Swimming; + return; + } - } else { - if (this->isStormActive && (this->actor.xyzDistToPlayerSq < (SQ(dist))) && (player->invincibilityTimer == 0)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + if (this->isStormActive && (this->actor.xyzDistToPlayerSq < SQ(dist)) && player->invincibilityTimer == 0) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + } + + EnNiw_CheckRage(this, globalCtx); + if (this->flutterSfxTimer == 0 && this->niwState == NIW_STATE_HELD) { + this->flutterSfxTimer = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + + if (this->sfxTimer1 == 0) { + if (this->niwState != NIW_STATE_IDLE) { + this->sfxTimer1 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } else { + this->sfxTimer1 = 300; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); } + } - EnNiw_CheckRage(this, globalCtx); - if ((this->flutterSfxTimer == 0) && (this->unknownState28E == 4)) { - this->flutterSfxTimer = 7; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); - } + if (!this->isStormActive && this->niwType == NIW_TYPE_REGULAR) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->sfxTimer1 == 0) { - if (this->unknownState28E != 0) { - this->sfxTimer1 = 30; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck - } else { - this->sfxTimer1 = 300; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck - } - } + if (globalCtx) {} - if (!this->isStormActive) { - if (this->niwType == ENNIW_TYPE_REGULAR) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (globalCtx) {} - - if ((this->unknownState28E != 4) && (this->unknownState28E != 5)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } + if (this->niwState != NIW_STATE_HELD && this->niwState != NIW_STATE_FALLING) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } } @@ -909,21 +937,21 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnNiw* this = THIS; - if (limbIndex == 13) { - rot->y += (s16)this->limbDRot; + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; } - if (limbIndex == 15) { - rot->y += (s16)this->limbFRot; + if (limbIndex == NIW_LIMB_HEAD) { + rot->y += (s16)this->headRotY; } - if (limbIndex == 11) { - rot->x += (s16)this->limbBRotx; - rot->y += (s16)this->limbBRoty; - rot->z += (s16)this->limbBRotz; + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; } - if (limbIndex == 7) { - rot->x += (s16)this->limb7Rotx; - rot->y += (s16)this->limb7Roty; - rot->z += (s16)this->limb7Rotz; + if (limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->x += (s16)this->leftWingRotX; + rot->y += (s16)this->leftWingRotY; + rot->z += (s16)this->leftWingRotZ; } return false; } @@ -939,7 +967,7 @@ void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { s16 i; - EnNiwFeather* feather = this->feathers; + EnNiwFeather* feather = &this->feathers[0]; for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { if (feather->isEnabled == false) { @@ -957,7 +985,7 @@ void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s } void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { - EnNiwFeather* feather = this->feathers; + EnNiwFeather* feather = &this->feathers[0]; f32 featherVelocityGoal = 0.05f; s16 i; @@ -988,7 +1016,6 @@ void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { } } -// feather draw function void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; u8 isMaterialApplied = false; diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index 5a03215bc..7c8b3e07e 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -2,6 +2,7 @@ #define Z_EN_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnNiw; @@ -19,55 +20,67 @@ typedef struct { /* 0x0034 */ u8 timer; } EnNiwFeather; // size = 0x38 -#define ENNIW_LIMBCOUNT 16 -#define ENNIW_FEATHERCOUNT 20 +#define NIW_FEATHER_COUNT 20 typedef struct EnNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelanime; - /* 0x188 */ Vec3s jointTable[ENNIW_LIMBCOUNT]; - /* 0x1E8 */ Vec3s morphTable[ENNIW_LIMBCOUNT]; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; /* 0x248 */ EnNiwActionFunc actionFunc; - /* 0x24C */ s16 unkTimer24C; + /* 0x24C */ s16 unkTimer24C; // set to 10, checked in mystery func /* 0x24E */ s16 unkTimer24E; - /* 0x250 */ s16 unkTimer250; - /* 0x252 */ s16 unkTimer252; - /* 0x254 */ s16 unkTimer254; + /* 0x250 */ union { + s16 generalTimer1; // default name for reset/decr + s16 hopTimer; // every 3 frames while running/idling + s16 swimRippleTimer; // how often swimming cucco spawns ripples + s16 heldTimer; // timer until updating unk29E + s16 unkIdleTimer; // not sure what _Idle is doing with it yet + }; + /* 0x252 */ union { + s16 generalTimer2; // default name for reset/decr + s16 hoppingTimer; // hopping after being thrown before running + s16 attackNiwSpawnTimer; // delay between re-attempting to spawn more attack_niw + s16 runningDirectionTimer; // delay between direction changes when running + s16 cuccoStormTimer; // delay between stages of summoning the storm + s16 unkIdleTimer2; // not sure what _Idle is doing with it yet + }; + /* 0x254 */ s16 runAwayTimer; /* 0x256 */ s16 sfxTimer1; /* 0x258 */ s16 flutterSfxTimer; /* 0x25A */ s16 unusedTimer25A; - /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer - /* 0x25E */ s16 unusedTimer25E; - /* 0x260 */ s16 unkTimer260; - /* 0x264 */ f32 unk264[10]; + /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer + /* 0x25E */ s16 unkAttackNiwTimer; // every 70 frames, updates some player unk values + /* 0x260 */ s16 iframeTimer; + /* 0x264 */ f32 targetLimbRots[10]; /* 0x28C */ s16 unusedCounter28C; - /* 0x28E */ s16 unknownState28E; - /* 0x290 */ s16 unk290; + /* 0x28E */ s16 niwState; + /* 0x290 */ s16 attackNiwCount; /* 0x292 */ s16 unk292; /* 0x294 */ s16 pad294; - /* 0x296 */ s16 unk296; + /* 0x296 */ s16 unkToggle296; /* 0x298 */ s16 unk298; - /* 0x29C */ s16 unk29A; - /* 0x29C */ u16 unk29C; - /* 0x29E */ s16 unk29E; - /* 0x2A0 */ s16 isStormActive; + /* 0x29C */ s16 isRunningRight; // toggle (direction cucco is turning while running) + /* 0x29C */ u16 nextAnimation; + /* 0x29E */ s16 unk29E; // three states 0/1/2 + /* 0x2A0 */ s16 isStormActive; // we have a data value shared between all cucco, this shouldn't need to exist /* 0x2A2 */ s16 niwType; /* 0x2A4 */ Vec3f unk2A4; /* 0x2B0 */ Vec3f unk2B0; - /* 0x2BC */ Vec3f unk2BC; - /* 0x2C8 */ f32 limb7Rotz; - /* 0x2CC */ f32 limb7Roty; - /* 0x2D0 */ f32 limb7Rotx; - /* 0x2D4 */ f32 limbBRotz; - /* 0x2D8 */ f32 limbBRoty; - /* 0x2DC */ f32 limbBRotx; - /* 0x2E0 */ f32 limbDRot; - /* 0x2E4 */ f32 limbFRot; + /* 0x2BC */ Vec3f unk2BC; // init from data (90000 on all three) + /* 0x2C8 */ f32 leftWingRotZ; + /* 0x2CC */ f32 leftWingRotY; + /* 0x2D0 */ f32 leftWingRotX; + /* 0x2D4 */ f32 rightWingRotZ; + /* 0x2D8 */ f32 rightWingRotY; + /* 0x2DC */ f32 rightWingRotX; + /* 0x2E0 */ f32 upperBodyRotY; + /* 0x2E4 */ f32 headRotY; /* 0x2E8 */ s16 yawTowardsPlayer; - /* 0x2EA */ s16 unk2EA; + /* 0x2EA */ s16 headRotationToggle; /* 0x2EC */ s16 unk2EC; /* 0x2EE */ UNK_TYPE1 pad2EE[0x6]; - /* 0x2F4 */ f32 unusedFloat2F4; + /* 0x2F4 */ f32 unusedFloat2F4; // set in EnNiw_Update if Cucco falls off map, never read /* 0x2F8 */ f32 unusedFloat2F8; /* 0x2FC */ f32 unusedFloat2FC; /* 0x300 */ f32 unk300; @@ -75,16 +88,26 @@ typedef struct EnNiw { /* 0x308 */ f32 unk308; /* 0x30C */ s32 pad30C; /* 0x310 */ ColliderCylinder collider; - /* 0x35C */ EnNiwFeather feathers[ENNIW_FEATHERCOUNT]; + /* 0x35C */ EnNiwFeather feathers[NIW_FEATHER_COUNT]; } EnNiw; // size = 0x7BC // in init, any value below zero becomes zero -// however, in vanilla, only 0xFFFF (-1) exists -#define ENNIW_TYPE_VANILLA 0xFFFF -#define ENNIW_TYPE_REGULAR 0 -#define ENNIW_TYPE_UNK1 1 -#define ENNIW_TYPE_UNK2 2 -// the attacking cuccos are not here, they are a different actor: -// ovl_En_Attack_Niw +// however, in vanilla, only 0xFFFF (-1) exists in scene spawns, actors can spawn 0x0 +#define NIW_TYPE_VANILLA 0xFFFF +#define NIW_TYPE_REGULAR 0 +#define NIW_TYPE_UNK1 1 +#define NIW_TYPE_HELD 2 // spawns held by the bomber kid in east clock town during hide and seek +// the attacking cuccos are not here, they are a different actor: [ ovl_En_Attack_Niw ] + +typedef enum { + /* 0 */ NIW_ANIMATION_STILL, + /* 1 */ NIW_ANIMATION_HEAD_PECKING, // forward and backward, feeding + /* 2 */ NIW_ANIMATION_PECKING_AND_WAVING, // wings move along their axis, like human hand waving + /* 3 */ NIW_ANIMATION_PECKING_AND_FORFLAPPING, // (unused) low (yaw based) flapping, forward and back + /* 4 */ NIW_ANIMATION_FREEZE, // used during Cucco Storm + /* 5 */ NIW_ANIMATION_PECKING_SLOW_FORFLAPPING, // wing speed half that of 3 + +} EnNiwHeadAndWingAnimationState; + #endif // Z_EN_NIW_H diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 4c0fdce1e..8d254b728 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -2,9 +2,14 @@ * File: z_en_nwc.c * Overlay: ovl_En_Nwc * Description: Cucco chick + * + * This actor requires object_niw to be present for the transformation during Breman Mask March + * EnHs (Grog) must also be present to maintain the count of the EnNwc in the march */ #include "z_en_nwc.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" +#include "objects/object_nwc/object_nwc.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,15 +20,27 @@ void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809448A4(EnNwc* this, GlobalContext* globalCtx); -void func_809449D0(EnNwc* this, GlobalContext* globalCtx); -void func_80944A50(EnNwc* this, GlobalContext* globalCtx); -void func_80944E44(EnNwc* this, GlobalContext* globalCtx); -void func_80944EFC(EnNwc* this, GlobalContext* globalCtx); -void func_80944FA8(EnNwc* this, GlobalContext* globalCtx); -void func_8094506C(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx); + +void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx); +s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +EnHs* EnNwc_FindGrog(GlobalContext* globalCtx); + +enum EnNiwState { + /* -1 */ NWC_STATE_NIW_LOADED = -1, // set after loading object_niw + /* 0 */ NWC_STATE_CHECK_BREMAN = 0, // checking for breman mask + /* 1 */ NWC_STATE_TURNING, // turning to face a new direction to explore + /* 2 */ NWC_STATE_HOPPING_FORWARD, // hopping to go explore + /* 3 */ NWC_STATE_FOLLOWING, // following the player + /* 4 */ NWC_STATE_RUNNING, // running from the player after failed breman march +}; -#if 0 const ActorInit En_Nwc_InitVars = { ACTOR_EN_NWC, ACTORCAT_PROP, @@ -36,47 +53,474 @@ const ActorInit En_Nwc_InitVars = { (ActorFunc)EnNwc_Draw, }; -#endif +Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; -extern UNK_TYPE D_060000E8; -extern UNK_TYPE D_060002E8; +Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Init.s") +void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 niwObjectIndex; + EnNwc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Destroy.s") + niwObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_NIW); + if (niwObjectIndex < 0) { + // niw object does not exist, we need it for tranformation, despawn + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944320.s") + if (gSaveContext.save.weekEventReg[25] & 8) { + // if breman mask was already used, replace with adult EnNiw + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, NIW_TYPE_REGULAR); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944554.s") + this->niwObjectIndex = niwObjectIndex; + this->nwcObjectIndex = this->actor.objBankIndex; + this->grog = EnNwc_FindGrog(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944590.s") + this->footRotY = this->footRotZ = 0; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = EnNwc_LoadNiwSkeleton; + this->hasGrownUp = false; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 6.0f); + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809445D4.s") +void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944630.s") +void EnNwc_SpawnDust(EnNwc* this, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f vec5; + Vec3f vel; + Vec3f accel; + s16 yaw; + s16 pitch; + Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809447A8.s") + yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); + pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); + vec5.x = this->actor.world.pos.x - 5.0f * Math_SinS(yaw) * Math_CosS(pitch); + vec5.y = this->actor.world.pos.y - 5.0f * Math_SinS(pitch); + vec5.z = this->actor.world.pos.z - 5.0f * Math_CosS(yaw) * Math_CosS(pitch); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944818.s") + for (i = 0; i < 5; i++) { + vel.x = randPlusMinusPoint5Scaled(4.0f); + vel.y = randPlusMinusPoint5Scaled(4.0f); + vel.z = randPlusMinusPoint5Scaled(4.0f); + accel.x = -vel.x * 0.1f; + accel.y = -vel.y * 0.1f; + accel.z = -vel.z * 0.1f; + pos.x = vec5.x + vel.x; + pos.y = vec5.y + vel.y; + pos.z = vec5.z + vel.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809448A4.s") + func_800B0F80(globalCtx, &pos, &vel, &accel, &sPrimColor, &sEnvColor, 300, 30, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809449D0.s") +EnHs* EnNwc_FindGrog(GlobalContext* globalCtx) { + Actor* grogSearch = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944A50.s") + while (grogSearch != NULL) { + if (grogSearch->id == ACTOR_EN_HS) { + return (EnHs*)grogSearch; + } + grogSearch = grogSearch->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944E44.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944EFC.s") +s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944FA8.s") + // Weird: home.rot.x holds count of chicks having transformed into adult. + // Weird: Its incremented by 1 unlike chicks following, so it should max at 10. + if (this->grog->actor.home.rot.x >= 20) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_8094506C.s") + if (player->stateFlags3 & 0x20000000) { // breman mask march + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Update.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Draw.s") +/** + * Summary: Checks 1) if grog exists, 2) player is using breman mask, 3) and within range. + * Used to identify if the chick should be captured by breman mask. + */ +s32 EnNwc_IsFound(EnNwc* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_8094529C.s") + if (this->grog == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80945310.s") + if (player->stateFlags3 & 0x20000000 && // breman mask march + this->actor.xzDistToPlayer < 100.0f) { + return true; + } + + return false; +} + +void EnNwc_ChangeState(EnNwc* this, s16 newState) { + this->actor.speedXZ = 0.0f; + switch (newState) { + case NWC_STATE_CHECK_BREMAN: + this->stateTimer = 10; + this->actionFunc = EnNwc_CheckForBreman; + break; + case NWC_STATE_TURNING: + this->stateTimer = Rand_ZeroFloat(20.0f) + 15.0f; + this->actionFunc = EnNwc_Turn; + this->fallingRotY = (s16)(s32)randPlusMinusPoint5Scaled(65536.0f); + break; + case NWC_STATE_HOPPING_FORWARD: + this->stateTimer = Rand_ZeroFloat(20.0f) + 15.0f; + this->actionFunc = EnNwc_HopForward; + break; + case NWC_STATE_FOLLOWING: + this->actionFunc = EnNwc_Follow; + this->transformTimer = 0; + this->randomRot = (s16)(s32)randPlusMinusPoint5Scaled(10000.0f); + break; + case NWC_STATE_RUNNING: + this->actor.world.rot.y = this->actor.home.rot.z * 0x3000 & 0xFFFF; // Fake Match?: & 0xFFFF + this->actor.shape.rot.y = this->actor.world.rot.y; + this->stateTimer = Rand_ZeroFloat(40.0f) + 120.0f; + this->actionFunc = EnNwc_RunAway; + break; + } + + this->state = newState; +} + +/** + * Summary: Changes the current actor state + * If previously random behavior -> check if breman mask is active + * If previously checking for breman -> select random (NWC_STATE_TURNING, NWC_STATE_HOPPING_FORWARD) + */ +void EnNwc_ToggleState(EnNwc* this) { + this->actor.speedXZ = 0.0f; + if (this->state != NWC_STATE_CHECK_BREMAN) { + EnNwc_ChangeState(this, NWC_STATE_CHECK_BREMAN); + } else { + EnNwc_ChangeState(this, Rand_ZeroFloat(2.0f) + 1.0f); + } +} + +void EnNwc_CheckFound(EnNwc* this, GlobalContext* globalCtx) { + if (EnNwc_IsFound(this, globalCtx)) { + u8 currentChickCount = (this->grog->actor.home.rot.z / 2); + + if (currentChickCount > 9) { + currentChickCount = 9; + } + + // save our current chick order + this->actor.home.rot.z = this->grog->actor.home.rot.z + 1; + + // if < 10 chicks, increment grog's chick counter + if (this->grog->actor.home.rot.z < 20) { + this->grog->actor.home.rot.z += 2; + } + + EnNwc_ChangeState(this, NWC_STATE_FOLLOWING); + func_801A0868(&D_801DB4A4, NA_SE_SY_CHICK_JOIN_CHIME, currentChickCount); + } +} + +void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->niwObjectIndex)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->niwObjectIndex].segment); + + SkelAnime_InitFlex(globalCtx, &this->niwSkeleton, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, + this->morphTable, NIW_LIMB_MAX); + Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, 0.0f); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->nwcObjectIndex].segment); + this->state = NWC_STATE_NIW_LOADED; + EnNwc_ToggleState(this); + } +} + +void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx) { + // I guess grog handles the scene transit? + Math_SmoothStepToS(&this->upperBodyRotY, 0x2710, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->footRotZ, 0, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->footRotY, 0x36B0, 2, 0x1B58, 0x3E8); +} + +/** + * Summary: Controls the Chick when following Breman Mask. + * + * ActionFunc for NWC Type: NWC_STATE_FOLLOWING + */ +void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { + Vec3f* chickCoords = this->grog->nwcPos; + Vec3f targetVector; + s32 pad; + s16 newRotY; + + this->stateTimer++; + if (this->hasGrownUp & 1) { + s16 targetUpperBodyRot = 0; + s16 targetFootRot = 0; + + if (this->actor.speedXZ > 0.0f) { + if (this->stateTimer & 4) { + targetFootRot = 0x1B58; + targetUpperBodyRot = -0x2710; + } + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + } + Math_SmoothStepToS(&this->footRotZ, targetFootRot, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->upperBodyRotY, targetUpperBodyRot, 2, 0x1B58, 0x3E8); + + } else { // NOT grown up + if ((this->stateTimer & 3) == 3 && this->stateTimer & 20) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0x1B) == 24) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + } + + if (this->grog->actor.home.rot.z >= 20 && // all 10 chicks have been found + (this->hasGrownUp & 1) == false) { + this->transformTimer += 2; + if (this->transformTimer >= (s32)(s16)((this->actor.home.rot.z * 0x1E) + 0x1E)) { + // it is our turn to transform + this->hasGrownUp |= 1; + this->grog->actor.home.rot.x += 2; // increment grog's adult tranformation counter + EnNwc_SpawnDust(this, globalCtx); + Actor_SetScale(&this->actor, 0.002f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_TO_CHICKEN); + } + } + + Math_Vec3f_Diff(&chickCoords[this->actor.home.rot.z], &this->actor.world.pos, &targetVector); + if (SQXZ(targetVector) < SQ(5.0f)) { // too close to keep moving, stop + this->actor.speedXZ = 0.0f; + + // first nwc in the line follows player, the rest follow the previous one + if (this->actor.home.rot.z == 1) { + newRotY = this->actor.yawTowardsPlayer; + } else { + // for some reason the array is 10 * 2, incremented by 2, so this is "index - 1" + newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z - 2]); + } + + } else { // not too close: keep moving + this->randomRot += (s16)randPlusMinusPoint5Scaled(1500.0f); + if (this->randomRot > 0x1388) { + this->randomRot = 0x1388; + } else if (this->randomRot < -0x1388) { + this->randomRot = -0x1388; + } + this->actor.speedXZ = 2.0f; + newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z]) + this->randomRot; + } + + this->actor.world.rot.y = newRotY; + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0xBB8, 0xC8); + + if (EnNwc_PlayerReleasedBremanMarch(this, globalCtx)) { + this->grog->actor.home.rot.x = 0; // reset adult count + this->grog->actor.home.rot.z = 0; // reset chick follow count + + EnNwc_ChangeState(this, NWC_STATE_RUNNING); + + if (this->hasGrownUp & 1) { + EnNwc_SpawnDust(this, globalCtx); + } + + this->hasGrownUp &= ~1; + Actor_SetScale(&this->actor, 0.01f); + } + + if (this->actor.scale.x < 0.01f) { + this->actor.scale.x += 0.002f; + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->grog->actor.home.rot.x >= 20) { // all chicks have turned into adult cucco, stop and crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + this->actionFunc = EnNwc_CrowAtTheEnd; + this->actor.speedXZ = 0.0f; + Actor_SetScale(&this->actor, 0.01f); + } +} + +/** + * Summary: Chick is Walking (Hopping) in a straight line. + * + * ActionFunc for NWC Type: NWC_STATE_HOPPING_FORWARD + */ +void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + // they only move forward while off the ground, which gives the visual of them hopping to move + if (this->actor.bgCheckFlags & 0x1) { // touching floor + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 2.0f; + } +} + +/** + * Summary: Chick is Running Away from player (Breman Mask was dropped). + * + * ActionFunc for NWC Type: NWC_STATE_RUNNING + */ +void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + this->actor.speedXZ = 2.0f; + if (this->actor.bgCheckFlags & 0x8) { // touching wall + EnNwc_ToggleState(this); + } +} + +/** + * Summary: Chick is turning to face a new direction. + * + * ActionFunc for NWC Type: NWC_STATE_TURNING + */ +void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 7) == 7) { + this->actor.velocity.y = 2.0f; // vertical hop + } + + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + // they only rotate when off the ground, giving the visual that they turn by hopping + if (!(this->actor.bgCheckFlags & 0x1)) { // NOT touching floor + Math_SmoothStepToS(&this->actor.shape.rot.y, this->fallingRotY, 0xA, 0x1000, 0x800); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} + +/** + * Summary: Chick is standing still. + * Looking around, can see the player with the Breman Mask + * + * ActionFunc for NWC Type: NWC_STATE_CHECK_BREMAN + */ +void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + } + + EnNwc_CheckFound(this, globalCtx); +} + +void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); + this->actionFunc(this, globalCtx); + if (this->hasGrownUp & 1) { + this->actor.objBankIndex = this->niwObjectIndex; + this->actor.draw = EnNwc_DrawAdultBody; + this->actor.shape.shadowScale = 15.0f; + } else { + this->actor.objBankIndex = this->nwcObjectIndex; + this->actor.draw = EnNwc_Draw; + this->actor.shape.shadowScale = 6.0f; + } + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(0x3C, 0x3C); + } + + if (this->blinkTimer == 1 || this->blinkTimer == 3) { + this->blinkState = true; + } else { + this->blinkState = false; + } +} + +void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr eyeTextures[] = { gNwcEyeOpenTex, gNwcEyeClosedTex }; + EnNwc* this = THIS; + Gfx* dispHead; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + dispHead = POLY_OPA_DISP; + + gSPSegment(&dispHead[0], 0x08, Lib_SegmentedToVirtual(eyeTextures[this->blinkState])); + + gSPMatrix(&dispHead[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[2], &gNwcBodyDL); + + POLY_OPA_DISP = &dispHead[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnNwc* this = THIS; + + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += this->upperBodyRotY; + } + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT || limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->y += this->footRotY; + rot->z += this->footRotZ; + } + + return false; +} + +void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->niwSkeleton.skeleton, this->niwSkeleton.jointTable, + this->niwSkeleton.dListCount, EnNwc_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h index ccdfb59bb..3815852af 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h @@ -2,15 +2,37 @@ #define Z_EN_NWC_H #include "global.h" +#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Hs/z_en_hs.h" // grog + struct EnNwc; typedef void (*EnNwcActionFunc)(struct EnNwc*, GlobalContext*); typedef struct EnNwc { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x120]; - /* 0x0264 */ EnNwcActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime niwSkeleton; // this skeleton is for when the chicks grow up into adults during the breman march + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; + /* 0x248 */ s8 niwObjectIndex; + /* 0x249 */ s8 nwcObjectIndex; + /* 0x24A */ s16 blinkState; + /* 0x24C */ s16 blinkTimer; + /* 0x250 */ EnHs* grog; + /* 0x254 */ s16 stateTimer; // count frames to next state change + /* 0x256 */ union { + s16 mixedValue256; // default name for reset + s16 transformTimer; // frames since transformation sequence started + s16 fallingRotY; // target rotation if off the ground in state 1 + }; + /* 0x258 */ s16 randomRot; + /* 0x25A */ s16 state; + /* 0x25C */ u16 hasGrownUp; // treated as both a boolean and a flag variable (0x1) + /* 0x25E */ s16 footRotY; + /* 0x260 */ s16 footRotZ; + /* 0x262 */ s16 upperBodyRotY; + /* 0x264 */ EnNwcActionFunc actionFunc; } EnNwc; // size = 0x268 extern const ActorInit En_Nwc_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c4f1a053b..e552ca336 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5424,9 +5424,9 @@ 0x808908D0:("func_808908D0",), 0x80891060:("EnNiw_Init",), 0x808912E8:("EnNiw_Destroy",), - 0x80891320:("func_80891320",), + 0x80891320:("EnNiw_AnimateWingHead",), 0x808916B0:("EnNiw_SpawnAttackNiw",), - 0x808917F8:("func_808917F8",), + 0x808917F8:("EnNiw_UpdateRunning",), 0x80891974:("EnNiw_SetupIdle",), 0x808919E8:("EnNiw_Idle",), 0x80891D78:("EnNiw_Held",), @@ -7514,24 +7514,24 @@ 0x80943EE4:("EnDaiku_Draw",), 0x809441E0:("EnNwc_Init",), 0x80944310:("EnNwc_Destroy",), - 0x80944320:("func_80944320",), - 0x80944554:("func_80944554",), - 0x80944590:("func_80944590",), - 0x809445D4:("func_809445D4",), - 0x80944630:("func_80944630",), - 0x809447A8:("func_809447A8",), - 0x80944818:("func_80944818",), - 0x809448A4:("func_809448A4",), - 0x809449D0:("func_809449D0",), - 0x80944A50:("func_80944A50",), - 0x80944E44:("func_80944E44",), - 0x80944EFC:("func_80944EFC",), - 0x80944FA8:("func_80944FA8",), - 0x8094506C:("func_8094506C",), + 0x80944320:("EnNwc_SpawnDust",), + 0x80944554:("EnNwc_FindGrog",), + 0x80944590:("EnNwc_PlayerReleasedBremanMarch",), + 0x809445D4:("EnNwc_IsFound",), + 0x80944630:("EnNwc_ChangeState",), + 0x809447A8:("EnNwc_ToggleState",), + 0x80944818:("EnNwc_CheckFound",), + 0x809448A4:("EnNwc_LoadNiwSkeleton",), + 0x809449D0:("EnNwc_CrowAtTheEnd",), + 0x80944A50:("EnNwc_Follow",), + 0x80944E44:("EnNwc_HopForward",), + 0x80944EFC:("EnNwc_RunAway",), + 0x80944FA8:("EnNwc_Turn",), + 0x8094506C:("EnNwc_CheckForBreman",), 0x809450C0:("EnNwc_Update",), 0x809451D8:("EnNwc_Draw",), - 0x8094529C:("func_8094529C",), - 0x80945310:("func_80945310",), + 0x8094529C:("EnNwc_OverrideLimbDraw",), + 0x80945310:("EnNwc_DrawAdultBody",), 0x809454F0:("ItemInbox_Init",), 0x80945524:("ItemInbox_Destroy",), 0x80945534:("ItemInbox_Idle",), @@ -7641,13 +7641,13 @@ 0x80952CC8:("EnHs_Init",), 0x80952DD0:("EnHs_Destroy",), 0x80952DFC:("func_80952DFC",), - 0x80952E50:("func_80952E50",), + 0x80952E50:("EnHs_UpdateChickPos",), 0x80952F00:("func_80952F00",), 0x80952FE0:("func_80952FE0",), 0x80953098:("func_80953098",), 0x80953180:("func_80953180",), - 0x809532C0:("func_809532C0",), - 0x809532D0:("func_809532D0",), + 0x809532C0:("EnHs_DoNothing",), + 0x809532D0:("EnHs_SceneTransitToBunnyHoodDialogue",), 0x80953354:("func_80953354",), 0x809533A0:("func_809533A0",), 0x8095345C:("func_8095345C",), @@ -7680,11 +7680,11 @@ 0x80956954:("EnKanban_Draw",), 0x809580C0:("EnAttackNiw_Init",), 0x809581F4:("EnAttackNiw_Destroy",), - 0x80958228:("func_80958228",), - 0x809585B0:("func_809585B0",), - 0x80958634:("func_80958634",), - 0x80958974:("func_80958974",), - 0x80958BE4:("func_80958BE4",), + 0x80958228:("EnAttackNiw_AnimateWingHead",), + 0x809585B0:("EnAttackNiw_IsOnScreen",), + 0x80958634:("EnAttackNiw_EnterViewFromOffscreen",), + 0x80958974:("EnAttackNiw_AimAtPlayer",), + 0x80958BE4:("EnAttackNiw_FlyAway",), 0x80958CA8:("EnAttackNiw_Update",), 0x80958F6C:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), From e1477702ca139175af769347a3ad0d7a13a31fde Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 19:23:27 -0700 Subject: [PATCH 15/53] EffectSsKirakira OK (#801) * OK * cleanup * KiraKira -> Kirakira --- assets/xml/objects/gameplay_keep.xml | 2 +- include/functions.h | 8 +- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 16 +- src/code/z_en_item00.c | 4 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 2 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 2 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 4 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 4 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 2 +- .../ovl_Obj_Bigicicle/z_obj_bigicicle.c | 2 +- .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 2 +- .../z_eff_ss_kirakira.c | 144 ++++++++++++++++-- .../z_eff_ss_kirakira.h | 2 +- tools/disasm/functions.txt | 8 +- tools/namefixer.py | 5 + tools/sizes/code_functions.csv | 8 +- 23 files changed, 180 insertions(+), 50 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 8328b14ab..f73e9252f 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1180,7 +1180,7 @@ - + diff --git a/include/functions.h b/include/functions.h index 0e12b35a5..8c04ba259 100644 --- a/include/functions.h +++ b/include/functions.h @@ -541,11 +541,11 @@ void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel); void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsKirakira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); +void EffectSsKirakira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); -// void EffectSsKiraKira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); +void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); +// void EffectSsKirakira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void EffectSsBomb2_SpawnFade(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); // void EffectSsBlast_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); diff --git a/spec b/spec index 5cb8e7123..5c30f08c1 100644 --- a/spec +++ b/spec @@ -1784,8 +1784,7 @@ beginseg name "ovl_Effect_Ss_Kirakira" compress include "build/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.o" - include "build/data/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira.data.o" - include "build/data/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira_reloc.o" endseg beginseg diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 0300144e1..1e9b25573 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -206,21 +206,21 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { } } -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsKirakira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 primColor = { 255, 255, 200, 255 }; Color_RGBA8 envColor = { 255, 200, 0, 0 }; - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); + EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); } -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); + EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); } -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); @@ -239,9 +239,9 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); } -void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 1c600bfa0..6b01753cc 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -346,7 +346,7 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f); pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f); pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if ((this->actor.bgCheckFlags & 3) != 0) { if (this->actor.velocity.y > -2.0f) { @@ -403,7 +403,7 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 10.0f); pos.y = this->actor.world.pos.y + ((Rand_ZeroOne() - 0.5f) * 10.0f); pos.z = this->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if (this->actor.bgCheckFlags & 0x0003) { 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 6e27d1dc9..7e5c39c2f 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 @@ -147,7 +147,7 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s for (i = 0; i < 2; i++) { Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 163619876..fa94a5981 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1148,6 +1148,6 @@ void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { sVelocity.x = -Math_SinS(rand - 0x8000) * 5.0f; sVelocity.z = Math_CosS(rand - 0x8000) * 5.0f; } - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); + EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); } } diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index e53635603..856b459a3 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -296,7 +296,7 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); } @@ -352,7 +352,7 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); } diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index c5b9381f6..20092f5b0 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -196,7 +196,7 @@ void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { effectPos.x = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.x; effectPos.y = randPlusMinusPoint5Scaled(10.0f) + (this->actor.world.pos.y + 40.0f); effectPos.z = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); + EffectSsKirakira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WALK); Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index 45cc5bdae..e60419846 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -731,7 +731,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); Matrix_StatePop(); Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 62d455147..a3a433cf1 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1259,7 +1259,7 @@ void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife) { envColor.g = this->outerColor.g; envColor.b = this->outerColor.b; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, + EffectSsKirakira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, 1000, sparkleLife); } } diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 36ad91c0f..7676a9b78 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -176,7 +176,7 @@ void EnElforg_SpawnSparkles(EnElforg* this, GlobalContext* globalCtx, s32 life) index = (this->area < STRAY_FAIRY_AREA_CLOCK_TOWN || this->area >= STRAY_FAIRY_AREA_MAX) ? STRAY_FAIRY_AREA_CLOCK_TOWN : this->area; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], + EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], &sEnvColors[index], 1000, life); } diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index ebe127fcf..f45cafa53 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -269,7 +269,7 @@ void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { sp64.x = (Rand_Centered() * 50.0f) + this->unk_304.x; sp64.y = this->unk_304.y; sp64.z = (Rand_Centered() * 50.0f) + this->unk_304.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); } } diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 557b96b31..6c698234b 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1577,7 +1577,7 @@ void func_80B45EC8(EnInvadepoh* this, GlobalContext* globalCtx, s32 arg2) { spA8.y = ((Rand_ZeroOne() * 180.0f) + this->actor.world.pos.y) - 90.0f; spA8.z = (spA8.z * 100.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); + EffectSsKirakira_SpawnDispersed(globalCtx, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); } } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index de1a18241..78b370c3b 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -237,7 +237,7 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -289,7 +289,7 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index f4514a9aa..2a990bc26 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -398,7 +398,7 @@ void func_80B93DE8(Vec3f* arg0, GlobalContext* globalCtx, s32 arg2) { sp2C.x = randPlusMinusPoint5Scaled(30.0f) + arg0->x; sp2C.y = arg0->y + 3.0f; sp2C.z = randPlusMinusPoint5Scaled(30.0f) + arg0->z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); } s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index b4a85a3a0..8a1ae2df7 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -302,7 +302,7 @@ void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { sp44.z = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.z) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); } CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index d6ac6f342..bdffb1b52 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -260,7 +260,7 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { } sp6C.z = (phi_v0 * (15.0f + (sp58 * 15.0f)) * this->actor.scale.z) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c index b78891a2e..4c7c01ca3 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c @@ -1,33 +1,159 @@ /* * File: z_eff_ss_kirakira.c * Overlay: ovl_Effect_Ss_Kirakira - * Description: + * Description: Sparkles */ #include "z_eff_ss_kirakira.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rRotSpeed regs[0] +#define rYaw regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rPrimColorA regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rEnvColorA regs[9] +#define rAlphaStep regs[10] +#define rScale regs[11] +#define rLifespan regs[12] #define PARAMS ((EffectSsKirakiraInitParams*)initParamsx) -s32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this); void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this); void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Kirakira_InitVars = { EFFECT_SS_KIRAKIRA, EffectSsKirakira_Init, }; -#endif +u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsKirakiraInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/EffectSsKirakira_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/EffectSsKirakira_Draw.s") + if ((this->life = initParams->life) < 0) { + this->life = -this->life; + this->gfx = gEffSparklesDL; + this->update = func_80977F28; + this->rEnvColorA = initParams->scale; + this->rScale = 0; + } else { + this->gfx = gEffSparklesDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977DB4.s") + if (initParams->updateMode == 0) { + this->update = func_80977DB4; + } else { + this->update = func_80977E6C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977E6C.s") + this->rEnvColorA = initParams->envColor.a; + this->rScale = initParams->scale; + if (this->rScale < 0) { + this->gfx = gameplay_keep_DL_06A800; + this->rScale = -this->rScale; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977F28.s") + this->draw = EffectSsKirakira_Draw; + this->rRotSpeed = initParams->rotSpeed; + this->rYaw = initParams->yaw; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rAlphaStep = initParams->alphaStep; + this->rLifespan = initParams->life; + + return 1; +} + +void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx; + f32 scale = this->rScale / 10000.0f; + s32 pad; + MtxF mfTrans; + MtxF mfRot; + MtxF mfScale; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + MtxF mfResult; + Mtx* mtx; + + gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetRotateRPY(&mfRot, 0, 0, this->rYaw); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &mfScale, &mfResult); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + (((s8)((55.0f / this->rLifespan) * this->life) + 200))); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } + + CLOSE_DISPS(gfxCtx); +} + +void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->rEnvColorA += this->rAlphaStep; + + if (this->rEnvColorA < 0) { + this->rEnvColorA = 0; + this->rAlphaStep = -this->rAlphaStep; + } else if (this->rEnvColorA > 255) { + this->rEnvColorA = 255; + this->rAlphaStep = -this->rAlphaStep; + } + + this->rYaw += this->rRotSpeed; +} + +void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->velocity.x *= 0.95f; + this->velocity.z *= 0.95f; + this->accel.x = randPlusMinusPoint5Scaled(0.2f); + this->accel.z = randPlusMinusPoint5Scaled(0.2f); + this->rEnvColorA += this->rAlphaStep; + + if (this->rEnvColorA < 0) { + this->rEnvColorA = 0; + this->rAlphaStep = -this->rAlphaStep; + } else if (this->rEnvColorA > 255) { + this->rEnvColorA = 255; + this->rAlphaStep = -this->rAlphaStep; + } + + this->rYaw += this->rRotSpeed; +} + +void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rScale = this->rEnvColorA * Math_SinS((32768.0f / this->rLifespan) * this->life); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h index c3020f590..66e73e0a5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h @@ -15,7 +15,7 @@ typedef struct { /* 0x34 */ s16 rotSpeed; /* 0x36 */ s16 yaw; /* 0x38 */ u8 updateMode; -} EffectSsKiraKiraInitParams; // size = 0x3C +} EffectSsKirakiraInitParams; // size = 0x3C extern const EffectSsInit Effect_Ss_Kirakira_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e552ca336..017df4ba1 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -596,10 +596,10 @@ 0x800B13D8:("func_800B13D8",), 0x800B14D4:("func_800B14D4",), 0x800B1598:("func_800B1598",), - 0x800B165C:("EffectSsKiraKira_SpawnSmallYellow",), - 0x800B16B8:("EffectSsKiraKira_SpawnSmall",), - 0x800B16F4:("EffectSsKiraKira_SpawnDispersed",), - 0x800B1830:("EffectSsKiraKira_SpawnFocused",), + 0x800B165C:("EffectSsKirakira_SpawnSmallYellow",), + 0x800B16B8:("EffectSsKirakira_SpawnSmall",), + 0x800B16F4:("EffectSsKirakira_SpawnDispersed",), + 0x800B1830:("EffectSsKirakira_SpawnFocused",), 0x800B1908:("EffectSsBomb2_SpawnFade",), 0x800B1970:("EffectSsBomb2_SpawnLayered",), 0x800B19E0:("EffectSsBlast_Spawn",), diff --git a/tools/namefixer.py b/tools/namefixer.py index 7ce3790db..c4a83d13f 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -499,6 +499,11 @@ wordReplace = { "func_8015E750": "Message_FindCreditsMessage", "func_80133038": "Schedule_RunScript", + "EffectSsKiraKira_SpawnSmallYellow": "EffectSsKirakira_SpawnSmallYellow", + "EffectSsKiraKira_SpawnSmall": "EffectSsKirakira_SpawnSmall", + "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", + "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index ffff2a55b..2989dbfb6 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -110,10 +110,10 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B139C.s,func_800B13 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B13D8.s,func_800B13D8,0x800B13D8,0x3F asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B14D4.s,func_800B14D4,0x800B14D4,0x31 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B1598.s,func_800B1598,0x800B1598,0x31 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnSmallYellow.s,EffectSsKiraKira_SpawnSmallYellow,0x800B165C,0x17 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnSmall.s,EffectSsKiraKira_SpawnSmall,0x800B16B8,0xF -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnDispersed.s,EffectSsKiraKira_SpawnDispersed,0x800B16F4,0x4F -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnFocused.s,EffectSsKiraKira_SpawnFocused,0x800B1830,0x36 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnSmallYellow.s,EffectSsKirakira_SpawnSmallYellow,0x800B165C,0x17 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnSmall.s,EffectSsKirakira_SpawnSmall,0x800B16B8,0xF +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnDispersed.s,EffectSsKirakira_SpawnDispersed,0x800B16F4,0x4F +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnFocused.s,EffectSsKirakira_SpawnFocused,0x800B1830,0x36 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBomb2_SpawnFade.s,EffectSsBomb2_SpawnFade,0x800B1908,0x1A asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBomb2_SpawnLayered.s,EffectSsBomb2_SpawnLayered,0x800B1970,0x1C asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBlast_Spawn.s,EffectSsBlast_Spawn,0x800B19E0,0x24 From 8049dec3393c4ade687dbdfd84d3ccde73168ab0 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Thu, 26 May 2022 04:24:39 +0100 Subject: [PATCH 16/53] `sys_matrix` OK, documented, rename some other mathematics functions (#787) * Import data and bss, add some name options * Decomp rest of stack functions, remove RSPMatrix, split header * sys_matrix OK (thanks Tharo) Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * pragma weaks in sinf and cosf, change documentation change mcros to use 0x8000 * Rename sinf and cosf * Correct initialisation of sMtxFClear * More minor cleanup * Rename stack functions * Matrix_InsertMatrix -> Matrix_Mult * The big transpose rename * Fix MirRay_DrawReflectedBeam * Matrix_InsertTranslation -> Matrix_Translate * Matrix_Insert.Rotation_s -> Matrix_Rotate$1S + RotateY -> RotateYS * Matrix_Insert(.)Rotation_f -> Matrix_Rotate$1F * Matrix_RotateStateAroundXAxis -> Matrix_RotateXFApply Matrix_SetStateXRotation -> Matrix_RotateXFNew * Matrix_MultiplyVector3fByState -> Matrix_MultVec3f * Matrix_MultiplyVector3fXZByCurrentState -> Matrix_MultVec3fXZ * Matrix_GetStateTranslation -> Matrix_MultZero * Matrix_GetStateTranslationAndScaled(.) -> Matrix_MultVec$1 * Matrix_FromRSPMatrix -> Matrix_MtxToMtxF * Matrix_MultiplyVector3fByMatrix -> Matrix_MultVec3fExt * Matrix_TransposeXYZ -> Matrix_Transpose * Matrix_ToRSPMatrix -> Matrix_MtxFToMtx * Matrix_AppendToPolyOpaDisp -> Matrix_MtxFToNewMtx and document the conversion functions * Matrix_NormalizeXYZ -> Matrix_ReplaceRotation * Matrix_InsertRotationAroundUnitVector_f -> Matrix_RotateAxisF and S * Matrix_InsertRotation -> Matrix_RotateZYX * Document the last functions * Small cleanup * Matrix_JointPosition -> Matrix_TranslateRotateZYX * Matrix_SetStateRotationAndTranslation -> Matrix_SetTranslateRotateYXZ * func_8018219C -> Matrix_MtxFToYXZRot * func_801822C4 -> Matrix_MtxFToZYXRot * Fix files * Format * Review 1 * Renames * Fix warning in EnDragon * Format * Convert `mode` to an actual enum * Add enums, typedefs, externs to sys_matrix header * Review * One more * More review * Fix function names * Format * Fix names * Format * Review * engineer's review * Fix build * Format * Fix again Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> --- docs/tutorial/documenting.md | 8 +- docs/tutorial/draw_functions.md | 14 +- include/PR/gbi.h | 365 +++- include/PR/ultratypes.h | 12 +- include/functions.h | 51 +- include/sys_matrix.h | 81 + include/variables.h | 2 - include/z64.h | 23 +- include/z64math.h | 8 +- spec | 2 - src/boot_O2/boot_80086760.c | 4 +- src/boot_O2/mtxuty-cvt.c | 13 +- src/code/sys_matrix.c | 1935 ++++++++++++++++- src/code/z_actor.c | 93 +- src/code/z_bgcheck.c | 24 +- src/code/z_collision_check.c | 4 +- src/code/z_debug_display.c | 8 +- src/code/z_eff_footmark.c | 2 +- src/code/z_fcurve_data_skelanime.c | 6 +- src/code/z_fireobj.c | 2 +- src/code/z_lights.c | 2 +- src/code/z_skelanime.c | 92 +- src/code/z_skin.c | 18 +- src/code/z_skin_matrix.c | 529 +++-- src/code/z_sub_s.c | 30 +- src/code/z_view.c | 16 +- src/code/z_vr_box_draw.c | 16 +- src/libultra/gu/cosf.c | 23 +- src/libultra/gu/perspective.c | 2 +- src/libultra/gu/position.c | 12 +- src/libultra/gu/rotate.c | 4 +- src/libultra/gu/sinf.c | 23 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 19 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 32 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 16 +- .../actors/ovl_Arrow_Light/z_arrow_light.c | 16 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 16 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 70 +- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 38 +- .../z_bg_dblue_waterfall.c | 8 +- .../actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c | 8 +- .../z_bg_hakugin_bombwall.c | 14 +- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 10 +- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.c | 12 +- .../z_bg_ikana_bombwall.c | 10 +- .../z_bg_ikana_rotaryroom.c | 249 ++- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 10 +- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c | 32 +- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 12 +- .../actors/ovl_Bg_Spdweb/z_bg_spdweb.c | 8 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 71 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 129 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 116 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 46 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 10 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 29 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.c | 12 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 32 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 4 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 2 +- .../actors/ovl_Dm_Char05/z_dm_char05.c | 23 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 32 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 12 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 12 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 28 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 22 +- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 26 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 2 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 30 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 4 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 14 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 22 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 16 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 8 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 18 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 20 +- .../actors/ovl_En_Bbfall/z_en_bbfall.c | 18 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 6 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 36 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 58 +- .../actors/ovl_En_Bigslime/z_en_bigslime.h | 2 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 2 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 34 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 32 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 4 +- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 13 +- src/overlays/actors/ovl_En_Bu/z_en_bu.c | 8 +- src/overlays/actors/ovl_En_Butte/z_en_butte.c | 12 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 4 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 61 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 20 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 2 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 4 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 24 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 12 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 12 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 16 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 14 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 36 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 28 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 16 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 18 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 18 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 12 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 8 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 4 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 8 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 6 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 17 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 10 +- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 16 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 8 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 12 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 354 +-- .../actors/ovl_En_Floormas/z_en_floormas.c | 16 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 50 +- .../actors/ovl_En_Fu_Kago/z_en_fu_kago.c | 12 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 12 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 18 +- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 7 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 4 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 56 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 40 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 6 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 4 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 12 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 2 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 48 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 30 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 77 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 20 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 30 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 2 +- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 2 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 10 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 6 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 6 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 8 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 2 +- .../z_en_horse_game_check.c | 16 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 20 +- src/overlays/actors/ovl_En_In/z_en_in.c | 20 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 88 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 12 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 54 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 14 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 6 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 61 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 23 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 12 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 2 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 6 +- src/overlays/actors/ovl_En_Light/z_en_light.c | 6 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 8 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 2 +- .../actors/ovl_En_Maruta/z_en_maruta.c | 22 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 4 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 2 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 6 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 4 +- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 28 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 8 +- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 6 +- src/overlays/actors/ovl_En_Osk/z_en_osk.c | 6 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 16 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 8 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 52 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 2 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 30 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 6 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 44 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 24 +- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.c | 6 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 20 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 23 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 6 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 6 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 4 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 14 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 20 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 8 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 2 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 2 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 4 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 22 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 34 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 4 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 2 +- src/overlays/actors/ovl_En_Sda/z_en_sda.c | 27 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 4 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 20 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 6 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 10 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 4 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 28 +- src/overlays/actors/ovl_En_St/z_en_st.c | 5 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 10 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 36 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 56 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 4 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 12 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 4 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 2 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 16 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 2 +- .../actors/ovl_En_Tanron1/z_en_tanron1.c | 34 +- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 41 +- .../actors/ovl_En_Tanron3/z_en_tanron3.c | 10 +- .../actors/ovl_En_Tanron4/z_en_tanron4.c | 2 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 4 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 6 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 55 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 22 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 18 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 16 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 6 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 22 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 24 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 46 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 48 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 13 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 18 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 4 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 52 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 4 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 4 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 65 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 8 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 22 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 2 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 8 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 26 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 10 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 14 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 6 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 20 +- src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 62 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 6 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 8 +- .../actors/ovl_Obj_Armos/z_obj_armos.c | 8 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 20 +- src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c | 22 +- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 2 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 32 +- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 12 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 12 +- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c | 18 +- .../actors/ovl_Obj_Entotu/z_obj_entotu.c | 9 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 12 +- .../actors/ovl_Obj_Funen/z_obj_funen.c | 2 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 6 +- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 32 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 8 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 24 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 26 +- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 24 +- .../actors/ovl_Obj_Kinoko/z_obj_kinoko.c | 2 +- .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 14 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 2 +- .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 2 +- .../actors/ovl_Obj_Smork/z_obj_smork.c | 5 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 8 +- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 6 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 16 +- .../ovl_Obj_Spinyroll/z_obj_spinyroll.c | 2 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 40 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 6 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 24 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 48 +- src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c | 2 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 24 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 16 +- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 12 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 24 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 10 +- .../z_eff_en_ice_block.c | 6 +- .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 2 +- .../ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c | 6 +- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c | 4 +- .../ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c | 2 +- .../ovl_Effect_Ss_Stick/z_eff_ss_stick.c | 4 +- .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 2 +- .../gamestates/ovl_daytelop/z_daytelop.c | 2 +- .../gamestates/ovl_opening/z_opening.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 6 +- tools/disasm/functions.txt | 74 +- tools/namefixer.py | 112 +- tools/sizes/boot_functions.csv | 4 +- tools/sizes/code_functions.csv | 70 +- 303 files changed, 5474 insertions(+), 3324 deletions(-) create mode 100644 include/sys_matrix.h diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index a5e64d2a9..7e8435da9 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -235,8 +235,8 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } @@ -426,8 +426,8 @@ void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } ``` diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index eae1c121e..4eb22bf4f 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -163,22 +163,22 @@ As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives ```C void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor) { if (limbIndex == 5) { - Matrix_RotateY((s16) (0x400 - actor->unk2AE), 1); - Matrix_GetStateTranslationAndScaledX(500.0f, (Vec3f *) &actor->focus); + Matrix_RotateYS((s16) (0x400 - actor->unk2AE), 1); + Matrix_MultVecX(500.0f, (Vec3f *) &actor->focus); } } ``` There is only minor cleanup needed here: - recasting the last argument, -- replacing the last argument of `Matrix_RotateY` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`. +- replacing the last argument of `Matrix_RotateYS` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`. - `(Vec3f *) &actor->focus` to `&actor->focus.pos` (this is the same issue as `(Actor*)this`, where mips2c doesn't climb deep enough into the struct). ```C void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } ``` @@ -213,7 +213,7 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) { temp_s0->polyOpa.p = temp_v0_2 + 8; temp_v0_2->words.w1 = (u32) &D_06000680; temp_v0_2->words.w0 = 0xDE000000; - Matrix_InsertRotation(sp36, 0, sp34, 1); + Matrix_RotateZYX(sp36, 0, sp34, 1); temp_v0_3 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0_3 + 8; temp_v0_3->words.w0 = 0xDA380003; @@ -286,7 +286,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000680); - Matrix_InsertRotation(sp36, 0, sp34, MTXMODE_APPLY); + Matrix_RotateZYX(sp36, 0, sp34, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_060007C8); diff --git a/include/PR/gbi.h b/include/PR/gbi.h index ace2cd2e8..8e5aefe8e 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -1347,60 +1347,329 @@ typedef union { long int force_structure_alignment[4]; } Hilite; -#define gdSPDefLights0(ar,ag,ab) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} } -#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } -#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} } -#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} } -#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} } -#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} } +#define gdSPDefLights0(ar,ag,ab) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights1(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }} \ + } \ + } -#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} } +#define gdSPDefLights2(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights3(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }} \ + } \ + } -#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \ - {{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} } +#define gdSPDefLights4(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights5(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }} \ + } \ + } -#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ - { {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \ - { {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} } +#define gdSPDefLights6(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5, \ + r6,g6,b6, \ + x6,y6,z6) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }}, \ + {{ \ + { r6, g6, b6 }, 0, \ + { r6, g6, b6 }, 0, \ + { x6, y6, z6 }, 0 \ + }} \ + } \ + } + +#define gdSPDefLights7(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5, \ + r6,g6,b6, \ + x6,y6,z6, \ + r7,g7,b7, \ + x7,y7,z7) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }}, \ + {{ \ + { r6, g6, b6 }, 0, \ + { r6, g6, b6 }, 0, \ + { x6, y6, z6 }, 0 \ + }}, \ + {{ \ + { r7, g7, b7 }, 0, \ + { r7, g7, b7 }, 0, \ + { x7, y7, z7 }, 0 \ + }} \ + } \ + } + +#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ + {{ \ + {{ \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0, \ + { rightx, righty, rightz }, 0 \ + }}, \ + {{ \ + { 0, 0x80, 0 }, 0, \ + { 0, 0x80, 0 }, 0, \ + { upx, upy, upz }, 0 \ + }} \ + }} + +#define qs1616(e) ((s32)((e) * 0x00010000)) + +#define IPART(x) ((qs1616(x) >> 16) & 0xFFFF) +#define FPART(x) (qs1616(x) & 0xFFFF) + +#define gdSPDefMtx( \ + xx, yx, zx, wx, \ + xy, yy, zy, wy, \ + xz, yz, zz, wz, \ + xw, yw, zw, ww) \ + {{ \ + (IPART(xx) << 0x10) | IPART(xy), \ + (IPART(xz) << 0x10) | IPART(xw), \ + (IPART(yx) << 0x10) | IPART(yy), \ + (IPART(yz) << 0x10) | IPART(yw), \ + (IPART(zx) << 0x10) | IPART(zy), \ + (IPART(zz) << 0x10) | IPART(zw), \ + (IPART(wx) << 0x10) | IPART(wy), \ + (IPART(wz) << 0x10) | IPART(ww), \ + (FPART(xx) << 0x10) | FPART(xy), \ + (FPART(xz) << 0x10) | FPART(xw), \ + (FPART(yx) << 0x10) | FPART(yy), \ + (FPART(yz) << 0x10) | FPART(yw), \ + (FPART(zx) << 0x10) | FPART(zy), \ + (FPART(zz) << 0x10) | FPART(zw), \ + (FPART(wx) << 0x10) | FPART(wy), \ + (FPART(wz) << 0x10) | FPART(ww), \ + }} /* * Graphics DMA Packet diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 0e6f4cf39..8b4e1a82c 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -27,6 +27,10 @@ typedef void* TexturePtr; typedef long int Mtx_t[4][4]; typedef union { Mtx_t m; + struct { + u16 intPart[4][4]; + u16 fracPart[4][4]; + }; long long int forc_structure_alignment; } Mtx; // size = 0x40 @@ -34,10 +38,10 @@ typedef float MtxF_t[4][4]; typedef union { MtxF_t mf; struct { - float xx, xy, xz, xw, - yx, yy, yz, yw, - zx, zy, zz, zw, - wx, wy, wz, ww; + float xx, yx, zx, wx, + xy, yy, zy, wy, + xz, yz, zz, wz, + xw, yw, zw, ww; }; } MtxF; // size = 0x40 diff --git a/include/functions.h b/include/functions.h index 8c04ba259..b4ff2ad8d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -148,8 +148,8 @@ void GfxPrint_Open(GfxPrint* printer, Gfx* dList); Gfx* GfxPrint_Close(GfxPrint* printer); s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2); -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); +void MtxConv_F2L(Mtx* m1, MtxF* m2); +void MtxConv_L2F(MtxF* m1, Mtx* m2); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); @@ -220,7 +220,7 @@ OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); // void osVoiceSetWord(void); // void guScale(void); -f32 __sinf(f32 __x); +f32 sinf(f32 __x); s16 sins(u16 x); OSTask* _VirtualToPhysicalTask(OSTask* intp); void osSpTaskLoad(OSTask* intp); @@ -377,7 +377,7 @@ void __osRestoreInt(OSIntMask im); void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); -f32 __cosf(f32 __x); +f32 cosf(f32 __x); s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); @@ -3072,53 +3072,12 @@ s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); // void func_8017FB1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); // void func_8017FD44(void); + u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent); s16 Math_Atan2S(f32 opposite, f32 adjacent); f32 Math_Atan2F(f32 opposite, f32 adjacent); s16 Math_FAtan2F(f32 adjacent, f32 opposite); f32 Math_Acot2F(f32 adjacent, f32 opposite); -void Matrix_StateAlloc(GameState* gameState); -void Matrix_StatePush(void); -void Matrix_StatePop(void); -void Matrix_CopyCurrentState(MtxF* matrix); -void Matrix_SetCurrentState(MtxF* matrix); -MtxF* Matrix_GetCurrentState(void); -void Matrix_InsertMatrix(MtxF* matrix, s32 appendToState); -void Matrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState); -void Matrix_Scale(f32 xScale, f32 yScale, f32 zScale, s32 appendToState); -void Matrix_InsertXRotation_s(s16 rotation, s32 appendToState); -void Matrix_InsertXRotation_f(f32 rotation, s32 appendToState); -void Matrix_RotateStateAroundXAxis(f32 rotation); -void Matrix_SetStateXRotation(f32 rotation); -void Matrix_RotateY(s16 rotation, s32 appendToState); -void Matrix_InsertYRotation_f(f32 rotation, s32 appendToState); -void Matrix_InsertZRotation_s(s16 rotation, s32 appendToState); -void Matrix_InsertZRotation_f(f32 rotation, s32 appendToState); -void Matrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState); -void Matrix_JointPosition(Vec3f* position, Vec3s* rotation); -void Matrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation); -void Matrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation); -RSPMatrix* Matrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst); -Mtx* Matrix_ToMtx(Mtx* dest); -RSPMatrix* Matrix_GetStateAsRSPMatrix(RSPMatrix* matrix); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); -RSPMatrix* Matrix_AppendStateToPolyOpaDisp(GraphicsContext* gfxCtx); -void Matrix_AppendToPolyOpaDisp(MtxF* mtx, GraphicsContext* gfxCtx); -void Matrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst); -void Matrix_GetStateTranslation(Vec3f* dst); -void Matrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst); -void Matrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst); -void Matrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst); -void Matrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst); -void Matrix_MtxFCopy(MtxF* dst, MtxF* src); -void Matrix_FromRSPMatrix(Mtx* src, MtxF* dst); -void Matrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix); -void Matrix_TransposeXYZ(MtxF* matrix); -void Matrix_NormalizeXYZ(MtxF* matrix); -void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); -// void func_801822C4(void); -void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); -void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); u64* SysUcode_GetUCodeBoot(void); size_t SysUcode_GetUCodeBootSize(void); diff --git a/include/sys_matrix.h b/include/sys_matrix.h new file mode 100644 index 000000000..536322624 --- /dev/null +++ b/include/sys_matrix.h @@ -0,0 +1,81 @@ +#ifndef SYS_MATRIX_H +#define SYS_MATRIX_H + +#include "z64math.h" + + +struct GraphicsContext; +struct GameState; + + +typedef enum { + /* 0 */ MTXMODE_NEW, // generates a new matrix + /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix +} MatrixMode; + + +extern Mtx gIdentityMtx; +extern MtxF gIdentityMtxF; + + +/* Stack operations */ + +void Matrix_Init(struct GameState* gameState); +void Matrix_Push(void); +void Matrix_Pop(void); +void Matrix_Get(MtxF* dest); +void Matrix_Put(MtxF* src); +MtxF* Matrix_GetCurrent(void); + +/* Basic operations */ + +void Matrix_Mult(MtxF* matrix, MatrixMode mode); +void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode); +void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode); +void Matrix_RotateXS(s16 x, MatrixMode mode); +void Matrix_RotateXF(f32 x, MatrixMode mode); +void Matrix_RotateXFApply(f32 x); +void Matrix_RotateXFNew(f32 x); +void Matrix_RotateYS(s16 y, MatrixMode mode); +void Matrix_RotateYF(f32 y, MatrixMode mode); +void Matrix_RotateZS(s16 z, MatrixMode mode); +void Matrix_RotateZF(f32 z, MatrixMode mode); + +/* Compound operations */ + +void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode); +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot); +void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot); + +/* Conversion and allocation operations */ + +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); +Mtx* Matrix_ToMtx(Mtx* dest); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx); +Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx); + +/* Vector operations */ + +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); +void Matrix_MultZero(Vec3f* dest); +void Matrix_MultVecX(f32 x, Vec3f* dest); +void Matrix_MultVecY(f32 y, Vec3f* dest); +void Matrix_MultVecZ(f32 z, Vec3f* dest); +void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest); + +/* Copy and another conversion */ + +void Matrix_MtxFCopy(MtxF* dest, MtxF* src); +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); + +/* Miscellaneous */ + +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); +void Matrix_Transpose(MtxF* mf); +void Matrix_ReplaceRotation(MtxF* mf); +void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale); +void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale); +void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode); +void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode); + +#endif diff --git a/include/variables.h b/include/variables.h index 4acb019a4..c37938555 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1574,8 +1574,6 @@ extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; -extern Mtx gIdentityMtx; -extern MtxF gIdentityMtxF; // extern UNK_TYPE1 D_801D1E70; extern s16 gLowPassFilterData[]; extern s16 gHighPassFilterData[]; diff --git a/include/z64.h b/include/z64.h index e5533234a..7f1dfd701 100644 --- a/include/z64.h +++ b/include/z64.h @@ -23,6 +23,7 @@ #include "sfx.h" #include "message_data_static.h" +#include "sys_matrix.h" #include "z64actor.h" #include "z64animation.h" #include "z64audio.h" @@ -304,11 +305,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef struct { - /* 0x00 */ s16 intPart[16]; - /* 0x20 */ u16 fracPart[16]; -} RSPMatrix; // size = 0x40 - typedef struct { /* 0x0 */ s8 letterboxTarget; /* 0x1 */ s8 letterboxMagnitude; @@ -383,13 +379,6 @@ typedef struct { /* 0x1A */ s16 unk1A; } s80874650; // size = 0x1C -typedef struct { - /* 0x00 */ f32 x[4]; - /* 0x10 */ f32 y[4]; - /* 0x20 */ f32 z[4]; - /* 0x30 */ f32 w[4]; -} z_Matrix; // size = 0x40 - typedef union { F3DVertexColor color; F3DVertexNormal normal; @@ -1421,16 +1410,6 @@ typedef struct { /* 0x14 */ Gfx* monoDl; } VisMono; // size = 0x18 -typedef enum { - MTXMODE_NEW, // generates a new matrix - MTXMODE_APPLY // applies transformation to the current matrix -} MatrixMode; - -typedef struct { - /* 0x00 */ u16 intPart[4][4]; - /* 0x20 */ u16 fracPart[4][4]; -} MatrixInternal; // size = 0x40 - typedef struct DebugDispObject { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3s rot; diff --git a/include/z64math.h b/include/z64math.h index 78e1743ec..33f05bb0a 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -1,5 +1,5 @@ -#ifndef _Z64MATH_H_ -#define _Z64MATH_H_ +#ifndef Z64MATH_H +#define Z64MATH_H #include "ultra64.h" @@ -111,7 +111,7 @@ typedef struct { // Trig macros #define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f) -#define RADF_TO_BINANG(radf) (s16)(radf * (32768.0f / M_PI)) +#define RADF_TO_BINANG(radf) (s16)(radf * (0x8000 / M_PI)) #define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI)) #define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f)) #define BINANG_ROT180(angle) ((s16)(angle + 0x8000)) @@ -119,7 +119,7 @@ typedef struct { #define BINANG_ADD(a, b) ((s16)(a + b)) #define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) #define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 32768.0f) * M_PI) +#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) // Vector macros #define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z)) diff --git a/spec b/spec index 5c30f08c1..273170579 100644 --- a/spec +++ b/spec @@ -598,8 +598,6 @@ beginseg include "build/data/code/code_801D15B0.data.o" include "build/src/code/sys_math_atan.o" include "build/src/code/sys_matrix.o" - include "build/data/code/sys_matrix.data.o" - include "build/data/code/sys_matrix.bss.o" include "build/src/code/sys_ucode.o" include "build/src/code/code_80182CE0.o" include "build/data/code/code_801D1E70.data.o" diff --git a/src/boot_O2/boot_80086760.c b/src/boot_O2/boot_80086760.c index 3c75bcd3f..398a1e41a 100644 --- a/src/boot_O2/boot_80086760.c +++ b/src/boot_O2/boot_80086760.c @@ -14,11 +14,11 @@ extern f32 func_80086D18(f32 x); s32 gUseAtanContFrac; /** - * Tangent function computed using libultra __sinf and __cosf + * Tangent function computed using libultra sinf and cosf */ // Math_FTanF f32 func_80086760(f32 x) { - return __sinf(x) / __cosf(x); + return sinf(x) / cosf(x); } // Unused diff --git a/src/boot_O2/mtxuty-cvt.c b/src/boot_O2/mtxuty-cvt.c index 221dbf554..2c1634392 100644 --- a/src/boot_O2/mtxuty-cvt.c +++ b/src/boot_O2/mtxuty-cvt.c @@ -1,18 +1,19 @@ #include "global.h" -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) { +void MtxConv_F2L(Mtx* mtx, MtxF* mf) { s32 i; s32 j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - s32 value = (m2->mf[i][j] * 0x10000); - m1->intPart[i][j] = value >> 16; - m1->fracPart[i][j] = value; + s32 value = (mf->mf[i][j] * 0x10000); + + mtx->intPart[i][j] = value >> 16; + mtx->fracPart[i][j] = value; } } } -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2) { - guMtxL2F(m1, (Mtx*)m2); +void MtxConv_L2F(MtxF* mtx, Mtx* mf) { + guMtxL2F(mtx, mf); } diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index a09d95200..f2ed19c38 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -1,89 +1,1944 @@ +/** + * @file sys_matrix.c + * @brief: Matrix system that mostly uses a matrix stack, and concerns affine transformations. + * + * @note The RSP matrix format (and hence the `MtxF` format) is column-major: vectors are presumed to be row vectors, + * and matrices as a column of row vectors. This means that, for example, a translation matrix + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & x \\ + * 0 & 1 & 0 & y \\ + * 0 & 0 & 1 & z \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * will be stored as + * + * { { 1, 0, 0, 0 }, + * { 0, 1, 0, 0 }, + * { 0, 0, 1, 0 }, + * { x, y, z, 1 }, } + * + * @note As such, we label the elements in column-major order so we can follow the same conventions for multiplying + * matrices as the rest of the world, i.e. that \f$ [AB]_{ij} = \sum_k A_{ik} B_{kj} \f$. + * + * This file is primarily concerned with matrices representing affine transformations, implemented using an augmented + * matrix formalism, + * + * \f[ + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ A \f$ is a \f$ 3 \times 3 \f$ matrix (the *linear part*) and \f$ b \f$ a \f$ 3 \times 1 \f$ matrix, i.e. a + * 3D vector (the *translation part*), and most of the functions assume that the matrices have this form. + * + * Throughout this file, `mode` indicates whether to multiply the matrix on top of the stack by the new construction + * (APPLY), or to just overwrite it (NEW). + */ + #include "global.h" -void Matrix_StateAlloc(GameState* gameState) { - sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gameState->heap, 0x500); +/* data */ + +// clang-format off +Mtx gIdentityMtx = gdSPDefMtx( + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f +); +// clang-format on + +MtxF gIdentityMtxF = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; + +/* bss */ + +MtxF* sMatrixStack; //!< original name: "Matrix_stack" +MtxF* sCurrentMatrix; //!< original name: "Matrix_now" + +#define MATRIX_STACK_SIZE 20 + +/* Stack operations */ + +/** + * @brief Create the matrix stack and set the pointer to the top of it. + * + * @remark original name: "new_Matrix" + */ +void Matrix_Init(GameState* gameState) { + sMatrixStack = THA_AllocEndAlign16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); sCurrentMatrix = sMatrixStack; } -void Matrix_StatePush(void) { +/** + * @brief Place a new matrix on the top of the stack and move the stack pointer up. + * + * @remark original name: "Matrix_push" + */ +void Matrix_Push(void) { MtxF* prev = sCurrentMatrix; sCurrentMatrix++; Matrix_MtxFCopy(sCurrentMatrix, prev); } -void Matrix_StatePop(void) { +/** + * @brief Discard the top matrix on the stack and move stack pointer to the next one down. + * + * @remark original name: "Matrix_pull" + */ +void Matrix_Pop(void) { sCurrentMatrix--; } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s") +/** + * @brief Copy the top matrix from the stack. + * + * @param[out] dest Matrix into which to copy. + * + * @remark original name: "Matrix_get" + */ +void Matrix_Get(MtxF* dest) { + Matrix_MtxFCopy(dest, sCurrentMatrix); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s") +/** + * @brief Overwrite the top matrix on the stack. + * + * @param[in] src Matrix from which to copy. + * + * @remark original name: "Matrix_put" + */ +void Matrix_Put(MtxF* src) { + Matrix_MtxFCopy(sCurrentMatrix, src); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s") +/** + * @brief Return pointer to the top of the matrix stack. + * + * @return pointer to top matrix on the stack. + * + * @remark original name: get_Matrix_now + */ +MtxF* Matrix_GetCurrent(void) { + return sCurrentMatrix; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s") +/* General transformation matrix functions */ -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s") +/** + * @brief General multiplication of current by a matrix. + * - APPLY: current * mf -> current + * - NEW: mf -> current + * + * @param mf Matrix to multiply by. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_mult" + */ +void Matrix_Mult(MtxF* mf, MatrixMode mode) { + MtxF* cmf = Matrix_GetCurrent(); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_Scale.s") + if (mode == MTXMODE_APPLY) { + SkinMatrix_MtxFMtxFMult(cmf, mf, cmf); + } else { + Matrix_MtxFCopy(sCurrentMatrix, mf); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s") +/** + * @brief Right-multiply current by a translation matrix T. + * - APPLY: current * T -> current + * - NEW: T -> current + * + * T is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & x \\ + * 0 & 1 & 0 & y \\ + * 0 & 0 & 1 & z \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} . + * \f] + * + * @param x translation distance in the x direction. + * @param y translation distance in the y direction. + * @param z translation distance in the z direction. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_translate" + */ +void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; + f32 tempX; + f32 tempY; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s") + if (mode == MTXMODE_APPLY) { + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xw += tempX * x + tempY * y + cmf->xz * z; + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yw += tempX * x + tempY * y + cmf->yz * z; + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zw += tempX * x + tempY * y + cmf->zz * z; + tempX = cmf->wx; + tempY = cmf->wy; + cmf->ww += tempX * x + tempY * y + cmf->wz * z; + } else { + SkinMatrix_SetTranslate(cmf, x, y, z); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s") +/** + * @brief Right-multiply by the diagonal scale matrix S = diag(x,y,z,1). + * - APPLY: current * S -> current + * - NEW: S -> current + * + * S is given by + * + * \f[ + * \begin{pmatrix} + * x & 0 & 0 & 0 \\ + * 0 & y & 0 & 0 \\ + * 0 & 0 & z & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} . + * \f] + * + * @param x scale in x direction. + * @param y scale in y direction. + * @param z scale in z direction. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_scale" + */ +void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s") + if (mode == MTXMODE_APPLY) { + cmf->xx *= x; + cmf->yx *= x; + cmf->zx *= x; + cmf->xy *= y; + cmf->yy *= y; + cmf->zy *= y; + cmf->xz *= z; + cmf->yz *= z; + cmf->zz *= z; + cmf->wx *= x; + cmf->wy *= y; + cmf->wz *= z; + } else { + SkinMatrix_SetScale(cmf, x, y, z); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateY.s") +/** + * @brief Right-multiply by a rotation about the x axis + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & 0 \\ + * 0 & c & -s & 0 \\ + * 0 & s & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos x, s = \sin x \f$. + * + * @note The same as Matrix_RotateXF(), but uses a binary angle. + * + * @param x rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateX" + */ +void Matrix_RotateXS(s16 x, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s") + if (mode == MTXMODE_APPLY) { + if (x != 0) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s") + sin = Math_SinS(x); + cos = Math_CosS(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = tempY * cos + tempZ * sin; + cmf->xz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = tempY * cos + tempZ * sin; + cmf->yz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_JointPosition.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = tempY * cos + tempZ * sin; + cmf->zz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = tempY * cos + tempZ * sin; + cmf->wz = tempZ * cos - tempY * sin; + } + } else { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s") + if (x != 0) { + sin = Math_SinS(x); + cos = Math_CosS(x); + } else { + sin = 0.0f; + cos = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s") + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->xx = 1.0f; + cmf->ww = 1.0f; + cmf->yy = cos; + cmf->zz = cos; + cmf->zy = sin; + cmf->yz = -sin; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s") +// Unused +/** + * @brief Right-multiply by a rotation about the x axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & 0 \\ + * 0 & c & -s & 0 \\ + * 0 & s & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos x, s = \sin x \f$. + * + * @note The same as Matrix_RotateXS(), but uses a float angle in radians. + * + * @param x rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateX", but clashed with the previous function. + */ +void Matrix_RotateXF(f32 x, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; + f32 zero = 0.0; + f32 one = 1.0; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s") + if (mode == MTXMODE_APPLY) { + if (x != 0) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s") + sin = sinf(x); + cos = cosf(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = tempY * cos + tempZ * sin; + cmf->xz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = tempY * cos + tempZ * sin; + cmf->yz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = tempY * cos + tempZ * sin; + cmf->zz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = tempY * cos + tempZ * sin; + cmf->wz = tempZ * cos - tempY * sin; + } + } else { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s") + if (x != 0) { + sin = sinf(x); + cos = cosf(x); + } else { + sin = zero; + cos = one; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s") + cmf->xx = one; + cmf->yx = zero; + cmf->zx = zero; + cmf->wx = zero; + cmf->xy = zero; + cmf->yy = cos; + cmf->zy = sin; + cmf->wy = zero; + cmf->xz = zero; + cmf->yz = -sin; + cmf->zz = cos; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->ww = one; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s") +/** + * @brief Right-multiply by a rotation about the x axis. + * current * R -> current + * + * @note Matrix_RotateXF() with mode APPLY. + * + * @param x rotation angle (radians). + */ +void Matrix_RotateXFApply(f32 x) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s") + if (x != 0.0f) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s") + sin = sins(RADF_TO_BINANG(x)) * SHT_MINV; + cos = coss(RADF_TO_BINANG(x)) * SHT_MINV; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = (tempY * cos) + (tempZ * sin); + cmf->xz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_8018219C.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = (tempY * cos) + (tempZ * sin); + cmf->yz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_801822C4.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = (tempY * cos) + (tempZ * sin); + cmf->zz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = (tempY * cos) + (tempZ * sin); + cmf->wz = (tempZ * cos) - (tempY * sin); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s") +/** + * @brief Replace current by a rotation about the x axis. + * R -> current + * + * @note Matrix_RotateXF() with mode NEW. + * + * @param x rotation angle (radians). + */ +void Matrix_RotateXFNew(f32 x) { + MtxF* cmf = sCurrentMatrix; + s32 pad[2]; + f32 sin; + f32 cos; + + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + + if (x != 0.0f) { + sin = sinf(x); + cos = cosf(x); + + cmf->yy = cos; + cmf->zz = cos; + cmf->yz = -sin; + cmf->zy = sin; + } else { + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + } +} + +/** + * @brief Right-multiply by a rotation about the y axis + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & 0 & s & 0 \\ + * 0 & 1 & 0 & 0 \\ + * -s & 0 & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos y, s = \sin y \f$. + * + * @note The same as Matrix_RotateYF(), but uses a binary angle. + * + * @param y rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateY" + */ +void Matrix_RotateYS(s16 y, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempZ; + + if (mode == MTXMODE_APPLY) { + if (y != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(y); + cos = Math_CosS(y); + + tempX = cmf->xx; + tempZ = cmf->xz; + cmf->xx = tempX * cos - tempZ * sin; + cmf->xz = tempX * sin + tempZ * cos; + + tempX = cmf->yx; + tempZ = cmf->yz; + cmf->yx = tempX * cos - tempZ * sin; + cmf->yz = tempX * sin + tempZ * cos; + + tempX = cmf->zx; + tempZ = cmf->zz; + cmf->zx = tempX * cos - tempZ * sin; + cmf->zz = tempX * sin + tempZ * cos; + + tempX = cmf->wx; + tempZ = cmf->wz; + cmf->wx = tempX * cos - tempZ * sin; + cmf->wz = tempX * sin + tempZ * cos; + } + } else { + cmf = sCurrentMatrix; + + if (y != 0) { + sin = Math_SinS(y); + cos = Math_CosS(y); + } else { + sin = 0.0f; + cos = 1.0f; + } + + cmf->yx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->yz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->yy = 1.0f; + cmf->ww = 1.0f; + cmf->xx = cos; + cmf->zz = cos; + cmf->zx = -sin; + cmf->xz = sin; + } +} + +/** + * @brief Right-multiply by a rotation about the y axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & 0 & s & 0 \\ + * 0 & 1 & 0 & 0 \\ + * -s & 0 & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos y, s = \sin y \f$. + * + * @note The same as Matrix_RotateYS(), but uses a float angle in radians. + * + * @param y rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateY", but clashed with the previous function. + */ +void Matrix_RotateYF(f32 y, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempZ; + f32 zero = 0.0; + f32 one = 1.0; + + if (mode == MTXMODE_APPLY) { + if (y != 0.0f) { + cmf = sCurrentMatrix; + + sin = sinf(y); + cos = cosf(y); + + tempX = cmf->xx; + tempZ = cmf->xz; + cmf->xx = tempX * cos - tempZ * sin; + cmf->xz = tempX * sin + tempZ * cos; + + tempX = cmf->yx; + tempZ = cmf->yz; + cmf->yx = tempX * cos - tempZ * sin; + cmf->yz = tempX * sin + tempZ * cos; + + tempX = cmf->zx; + tempZ = cmf->zz; + cmf->zx = tempX * cos - tempZ * sin; + cmf->zz = tempX * sin + tempZ * cos; + + tempX = cmf->wx; + tempZ = cmf->wz; + cmf->wx = tempX * cos - tempZ * sin; + cmf->wz = tempX * sin + tempZ * cos; + } + } else { + cmf = sCurrentMatrix; + + if (y != 0.0f) { + sin = sinf(y); + cos = cosf(y); + } else { + cos = one; + sin = zero; + } + + cmf->yx = zero; + cmf->wx = zero; + cmf->xy = zero; + cmf->zy = zero; + cmf->wy = zero; + cmf->yz = zero; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->yy = one; + cmf->ww = one; + cmf->xx = cos; + cmf->zz = cos; + cmf->zx = -sin; + cmf->xz = sin; + } +} + +/** + * @brief Right-multiply by a rotation about the z axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & -s & 0 & 0 \\ + * s & c & 0 & 0 \\ + * 0 & 0 & 1 & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos z, s = \sin z \f$. + * + * @note The same as Matrix_RotateZF, but uses a binary angle. + * + * @param z rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateZ" + */ +void Matrix_RotateZS(s16 z, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempY; + f32 zero = 0.0; + f32 one = 1.0; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(z); + cos = Math_CosS(z); + + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xx = tempX * cos + tempY * sin; + cmf->xy = tempY * cos - tempX * sin; + + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yx = tempX * cos + tempY * sin; + cmf->yy = tempY * cos - tempX * sin; + + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zx = tempX * cos + tempY * sin; + cmf->zy = tempY * cos - tempX * sin; + + tempX = cmf->wx; + tempY = cmf->wy; + cmf->wx = tempX * cos + tempY * sin; + cmf->wy = tempY * cos - tempX * sin; + } + } else { + cmf = sCurrentMatrix; + + if (z != 0) { + sin = Math_SinS(z); + cos = Math_CosS(z); + } else { + sin = zero; + cos = one; + } + + cmf->zx = zero; + cmf->wx = zero; + cmf->zy = zero; + cmf->wy = zero; + cmf->xz = zero; + cmf->yz = zero; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->zz = one; + cmf->ww = one; + cmf->xx = cos; + cmf->yy = cos; + cmf->yx = sin; + cmf->xy = -sin; + } +} + +/** + * @brief Right-multiply by a rotation about the z axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & -s & 0 & 0 \\ + * s & c & 0 & 0 \\ + * 0 & 0 & 1 & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos z, s = \sin z \f$. + * + * @note The same as Matrix_RotateYS(), but uses a float angle in radians. + * + * @param z rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateZ", but clashed with the previous function. + */ +void Matrix_RotateZF(f32 z, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempY; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { + cmf = sCurrentMatrix; + + sin = sinf(z); + cos = cosf(z); + + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xx = tempX * cos + tempY * sin; + cmf->xy = tempY * cos - tempX * sin; + + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yx = tempX * cos + tempY * sin; + cmf->yy = tempY * cos - tempX * sin; + + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zx = tempX * cos + tempY * sin; + cmf->zy = tempY * cos - tempX * sin; + + tempX = cmf->wx; + tempY = cmf->wy; + cmf->wx = tempX * cos + tempY * sin; + cmf->wy = tempY * cos - tempX * sin; + } + } else { + cmf = sCurrentMatrix; + + if (z != 0) { + sin = sinf(z); + cos = cosf(z); + } else { + sin = 0.0f; + cos = 1.0f; + } + + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->zz = 1.0f; + cmf->ww = 1.0f; + cmf->xx = cos; + cmf->yy = cos; + cmf->yx = sin; + cmf->xy = -sin; + } +} + +/** + * @brief Rotate using ZYX Tait-Bryan angles. + * - APPLY: current Rz Ry Rx -> current + * - NEW: Rz Ry Rx -> current + * + * This means a (column) vector is first rotated around X, then around Y, then around Z, then (if `mode` is APPLY) gets + * transformed by what the matrix was before adding the ZYX rotation. + * + * See previous functions for the forms of Rz, Ry, Rx + * + * @param x binary angle to rotate about x axis + * @param y binary angle to rotate about y axis + * @param z binary angle to rotate about z axis + * @param mode APPLY or NEW + * + * @remark original name: "Matrix_RotateXYZ", changed to reflect rotation order. + */ +void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; + f32 temp1; + f32 temp2; + f32 sin; + f32 cos; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { // Added in MM, OoT always follows the nonzero path + sin = Math_SinS(z); + cos = Math_CosS(z); + + temp1 = cmf->xx; + temp2 = cmf->xy; + cmf->xx = temp1 * cos + temp2 * sin; + cmf->xy = temp2 * cos - temp1 * sin; + + temp1 = cmf->yx; + temp2 = cmf->yy; + cmf->yx = temp1 * cos + temp2 * sin; + cmf->yy = temp2 * cos - temp1 * sin; + + temp1 = cmf->zx; + temp2 = cmf->zy; + cmf->zx = temp1 * cos + temp2 * sin; + cmf->zy = temp2 * cos - temp1 * sin; + + temp1 = cmf->wx; + temp2 = cmf->wy; + cmf->wx = temp1 * cos + temp2 * sin; + cmf->wy = temp2 * cos - temp1 * sin; + } + + if (y != 0) { + sin = Math_SinS(y); + cos = Math_CosS(y); + + temp1 = cmf->xx; + temp2 = cmf->xz; + cmf->xx = temp1 * cos - temp2 * sin; + cmf->xz = temp1 * sin + temp2 * cos; + + temp1 = cmf->yx; + temp2 = cmf->yz; + cmf->yx = temp1 * cos - temp2 * sin; + cmf->yz = temp1 * sin + temp2 * cos; + + temp1 = cmf->zx; + temp2 = cmf->zz; + cmf->zx = temp1 * cos - temp2 * sin; + cmf->zz = temp1 * sin + temp2 * cos; + + temp1 = cmf->wx; + temp2 = cmf->wz; + cmf->wx = temp1 * cos - temp2 * sin; + cmf->wz = temp1 * sin + temp2 * cos; + } + + if (x != 0) { + sin = Math_SinS(x); + cos = Math_CosS(x); + + temp1 = cmf->xy; + temp2 = cmf->xz; + cmf->xy = temp1 * cos + temp2 * sin; + cmf->xz = temp2 * cos - temp1 * sin; + + temp1 = cmf->yy; + temp2 = cmf->yz; + cmf->yy = temp1 * cos + temp2 * sin; + cmf->yz = temp2 * cos - temp1 * sin; + + temp1 = cmf->zy; + temp2 = cmf->zz; + cmf->zy = temp1 * cos + temp2 * sin; + cmf->zz = temp2 * cos - temp1 * sin; + + temp1 = cmf->wy; + temp2 = cmf->wz; + cmf->wy = temp1 * cos + temp2 * sin; + cmf->wz = temp2 * cos - temp1 * sin; + } + } else { + SkinMatrix_SetRotateRPY(cmf, x, y, z); + } +} + +/** + * @brief Translate and rotate using ZYX Tait-Bryan angles. + * current T Rz Ry Rx -> current + * + * This means a (column) vector is first rotated around X, then around Y, then around Z, then translated, then gets + * transformed by whatever the matrix was previously. + * + * @param translation vector by which to translate. + * @param rot vector of rotation angles. + * + * @remark original name appears to be "Matrix_softcv3_mult" + */ +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot) { + MtxF* cmf = sCurrentMatrix; + f32 sin = Math_SinS(rot->z); + f32 cos = Math_CosS(rot->z); + f32 temp1; + f32 temp2; + + // No check for z != 0, presumably since translation is interleaved. + temp1 = cmf->xx; + temp2 = cmf->xy; + cmf->xw += temp1 * translation->x + temp2 * translation->y + cmf->xz * translation->z; + cmf->xx = temp1 * cos + temp2 * sin; + cmf->xy = temp2 * cos - temp1 * sin; + + temp1 = cmf->yx; + temp2 = cmf->yy; + cmf->yw += temp1 * translation->x + temp2 * translation->y + cmf->yz * translation->z; + cmf->yx = temp1 * cos + temp2 * sin; + cmf->yy = temp2 * cos - temp1 * sin; + + temp1 = cmf->zx; + temp2 = cmf->zy; + cmf->zw += temp1 * translation->x + temp2 * translation->y + cmf->zz * translation->z; + cmf->zx = temp1 * cos + temp2 * sin; + cmf->zy = temp2 * cos - temp1 * sin; + + temp1 = cmf->wx; + temp2 = cmf->wy; + cmf->ww += temp1 * translation->x + temp2 * translation->y + cmf->wz * translation->z; + cmf->wx = temp1 * cos + temp2 * sin; + cmf->wy = temp2 * cos - temp1 * sin; + + if (rot->y != 0) { + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + + temp1 = cmf->xx; + temp2 = cmf->xz; + cmf->xx = temp1 * cos - temp2 * sin; + cmf->xz = temp1 * sin + temp2 * cos; + + temp1 = cmf->yx; + temp2 = cmf->yz; + cmf->yx = temp1 * cos - temp2 * sin; + cmf->yz = temp1 * sin + temp2 * cos; + + temp1 = cmf->zx; + temp2 = cmf->zz; + cmf->zx = temp1 * cos - temp2 * sin; + cmf->zz = temp1 * sin + temp2 * cos; + + temp1 = cmf->wx; + temp2 = cmf->wz; + cmf->wx = temp1 * cos - temp2 * sin; + cmf->wz = temp1 * sin + temp2 * cos; + } + + if (rot->x != 0) { + sin = Math_SinS(rot->x); + cos = Math_CosS(rot->x); + + temp1 = cmf->xy; + temp2 = cmf->xz; + cmf->xy = temp1 * cos + temp2 * sin; + cmf->xz = temp2 * cos - temp1 * sin; + + temp1 = cmf->yy; + temp2 = cmf->yz; + cmf->yy = temp1 * cos + temp2 * sin; + cmf->yz = temp2 * cos - temp1 * sin; + + temp1 = cmf->zy; + temp2 = cmf->zz; + cmf->zy = temp1 * cos + temp2 * sin; + cmf->zz = temp2 * cos - temp1 * sin; + + temp1 = cmf->wy; + temp2 = cmf->wz; + cmf->wy = temp1 * cos + temp2 * sin; + cmf->wz = temp2 * cos - temp1 * sin; + } +} + +/** + * @brief Set current to a general translation and rotation using YXZ Tait-Bryan angles: T Ry Rx Rz -> current + * + * This means a (column) vector is first rotated around Y, then around X, then around Z, then translated, then gets + * transformed by whatever the matrix was previously. + * + * @param x amount to translate in X direction. + * @param y amount to translate in Y direction. + * @param z amount to translate in Z direction. + * @param rot vector of rotation angles. + * + * @remark original name appears to be "Matrix_softcv3_load" + */ +void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot) { + MtxF* cmf = sCurrentMatrix; + f32 sinY = Math_SinS(rot->y); + f32 cosY = Math_CosS(rot->y); + f32 cosTemp; + f32 sinTemp; + + cmf->xx = cosY; + cmf->zx = -sinY; + cmf->xw = x; + cmf->yw = y; + cmf->zw = z; + cmf->wx = 0.0f; + cmf->wy = 0.0f; + cmf->wz = 0.0f; + cmf->ww = 1.0f; + + if (rot->x != 0) { + sinTemp = Math_SinS(rot->x); + cosTemp = Math_CosS(rot->x); + + cmf->zz = cosY * cosTemp; + cmf->zy = cosY * sinTemp; + cmf->xz = sinY * cosTemp; + cmf->xy = sinY * sinTemp; + cmf->yz = -sinTemp; + cmf->yy = cosTemp; + } else { + cmf->zz = cosY; + cmf->xz = sinY; + cmf->yz = 0.0f; + cmf->zy = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + } + + if (rot->z != 0) { + sinTemp = Math_SinS(rot->z); + cosTemp = Math_CosS(rot->z); + + sinY = cmf->xx; + cosY = cmf->xy; + cmf->xx = sinY * cosTemp + cosY * sinTemp; + cmf->xy = cosY * cosTemp - sinY * sinTemp; + + sinY = cmf->zx; + cosY = cmf->zy; + cmf->zx = sinY * cosTemp + cosY * sinTemp; + cmf->zy = cosY * cosTemp - sinY * sinTemp; + + cosY = cmf->yy; + cmf->yx = cosY * sinTemp; + cmf->yy = cosY * cosTemp; + } else { + cmf->yx = 0.0f; + } +} + +/** + * @brief Converts a floating-point MtxF to a fixed-point RSP-compatible matrix. + * + * @param[in] src MtxF to convert. + * @param[out] dest mtx to output to. + * + * @return dest + * + * @remark original name: "_MtxF_to_Mtx" + */ +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) { + s32 temp; + u16* intPart = (u16*)&dest->m[0][0]; + u16* fracPart = (u16*)&dest->m[2][0]; + + // For some reason the first 9 elements use the intPart temp for the fractional part. + temp = src->xx * 0x10000; + intPart[0] = (temp >> 0x10); + intPart[16 + 0] = temp; + + temp = src->yx * 0x10000; + intPart[1] = (temp >> 0x10); + intPart[16 + 1] = temp; + + temp = src->zx * 0x10000; + intPart[2] = (temp >> 0x10); + intPart[16 + 2] = temp; + + temp = src->wx * 0x10000; + intPart[3] = (temp >> 0x10); + intPart[16 + 3] = temp; + + temp = src->xy * 0x10000; + intPart[4] = (temp >> 0x10); + intPart[16 + 4] = temp; + + temp = src->yy * 0x10000; + intPart[5] = (temp >> 0x10); + intPart[16 + 5] = temp; + + temp = src->zy * 0x10000; + intPart[6] = (temp >> 0x10); + intPart[16 + 6] = temp; + + temp = src->wy * 0x10000; + intPart[7] = (temp >> 0x10); + intPart[16 + 7] = temp; + + temp = src->xz * 0x10000; + intPart[8] = (temp >> 0x10); + intPart[16 + 8] = temp; + + temp = src->yz * 0x10000; + intPart[9] = (temp >> 0x10); + fracPart[9] = temp; + + temp = src->zz * 0x10000; + intPart[10] = (temp >> 0x10); + fracPart[10] = temp; + + temp = src->wz * 0x10000; + intPart[11] = (temp >> 0x10); + fracPart[11] = temp; + + temp = src->xw * 0x10000; + intPart[12] = (temp >> 0x10); + fracPart[12] = temp; + + temp = src->yw * 0x10000; + intPart[13] = (temp >> 0x10); + fracPart[13] = temp; + + temp = src->zw * 0x10000; + intPart[14] = (temp >> 0x10); + fracPart[14] = temp; + + temp = src->ww * 0x10000; + intPart[15] = (temp >> 0x10); + fracPart[15] = temp; + + return dest; +} + +/** + * @brief Converts current to a fixed-point RSP-compatible matrix. + * + * @note Debug uses Matrix_CheckFloats to test current first. + * + * @param[out] dest mtx to output to. + * + * @return dest + * + * @remark original name: "_Matrix_to_Mtx" + */ +Mtx* Matrix_ToMtx(Mtx* dest) { + return Matrix_MtxFToMtx(sCurrentMatrix, dest); +} + +/** + * @brief Converts current to a RSP-compatible matrix and saves it to allocated space in the OPA buffer. + * + * @param[in,out] gfxCtx Graphics context. + * + * @return allocated mtx. + * + * @remark original name: "_Matrix_to_Mtx_new" + */ +Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx) { + return Matrix_ToMtx(GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); +} + +// Unused +/** + * @brief Converts src to a RSP-compatible matrix and saves it to allocated space in the OPA buffer. + * + * @param[in] src MtxF to convert. + * @param[in,out] gfxCtx Graphics context. + * + * @return allocated mtx. + * + * @remark original name unknown, likely close to "_Matrix_MtxF_to_Mtx_new" + */ +Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) { + return Matrix_MtxFToMtx(src, GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); +} + +/** + * @brief Calculates current * (src,1) and writes its components to dest. + * + * This assumes that current has the form + * + * \f[ + * M = + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * where A is \f$ 3 \times 3 \f$ and b \f$ 3 \times 1 \f$, and so calculates + * + * \f[ + * MX = + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \begin{pmatrix} + * x \\ + * 1 + * \end{pmatrix} + * = + * \begin{pmatrix} + * Ax + b \\ + * 1 + * \end{pmatrix} + * \f] + * + * and discards the extra w component (1). + * + * @param[in] src input vector + * @param[out] dest output vector + * + * @remark original name: "Matrix_Position" + */ +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + (cmf->xx * src->x + cmf->xy * src->y + cmf->xz * src->z); + dest->y = cmf->yw + (cmf->yx * src->x + cmf->yy * src->y + cmf->yz * src->z); + dest->z = cmf->zw + (cmf->zx * src->x + cmf->zy * src->y + cmf->zz * src->z); +} + +/** + * @brief Multiply the vector `(0, 0, 0, 1)` by current. + * + * Can also see it as obtaining the translation vector part of current, but the former interpretation is consistent with + * the other functions nearby. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, 0, 0 }`; the same assumptions apply. + * + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_Zero" + */ +void Matrix_MultZero(Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw; + dest->y = cmf->yw; + dest->z = cmf->zw; +} + +/** + * @brief Multiply the vector `(x, 0, 0, 1)` by current. + * + * I.e. calculate \f$ A(x, 0, 0) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { x, 0, 0 }`; the same assumptions apply. + * + * @param[in] x multiplier of unit vector in x direction. + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_VecX" + */ +void Matrix_MultVecX(f32 x, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xx * x; + dest->y = cmf->yw + cmf->yx * x; + dest->z = cmf->zw + cmf->zx * x; +} + +/** + * @brief Multiply the vector `(0, y, 0, 1)` by current. + * + * I.e. calculate \f$ A(0, y, 0) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, y, 0 }`; the same assumptions apply. + * + * @param[in] y multiplier of unit vector in y direction. + * @param[out] dest output vector. + * + * @remark original name is most likely "Matrix_Position_VecY" by analogy with the other two. + */ +void Matrix_MultVecY(f32 y, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xy * y; + dest->y = cmf->yw + cmf->yy * y; + dest->z = cmf->zw + cmf->zy * y; +} + +/** + * @brief Multiply the vector `(0, 0, z, 1)` by current. + * + * I.e. calculate \f$ A(0, 0, z) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, 0, z }`; the same assumptions apply. + * + * @param[in] z multiplier of unit vector in z direction. + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_VecZ" + */ +void Matrix_MultVecZ(f32 z, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xz * z; + dest->y = cmf->yw + cmf->yz * z; + dest->z = cmf->zw + cmf->zz * z; +} + +/** + * @brief Calculates current * (src,1) and writes its x and z components to dest. + * + * The same as Matrix_MultVec3f(), but only applies to the x and z components; the same assumptions apply. + * + * @note Unlike the previous functions, does *not* just multiply (x, 0, z, 1) and save the x,y,z components. + * + * @param[in] src input vector. + * @param[out] dest output vector. + */ +void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + (cmf->xx * src->x + cmf->xy * src->y + cmf->xz * src->z); + dest->z = cmf->zw + (cmf->zx * src->x + cmf->zy * src->y + cmf->zz * src->z); +} + +/** + * @brief Copies the matrix src into dest. + * + * @param[out] dest matrix to copy to. + * @param[in] src matrix to copy from. + * + * @remark original name: "Matrix_copy_MtxF" + */ +void Matrix_MtxFCopy(MtxF* dest, MtxF* src) { + f32 fv0; + f32 fv1; + + // This ought to be a loop, but all attempts to match it as one have so far failed. + if (1) { + fv0 = src->mf[0][0]; + fv1 = src->mf[0][1]; + dest->mf[0][0] = fv0; + dest->mf[0][1] = fv1; + fv0 = src->mf[0][2]; + fv1 = src->mf[0][3]; + dest->mf[0][2] = fv0; + dest->mf[0][3] = fv1; + } + if (1) { + fv0 = src->mf[1][0]; + fv1 = src->mf[1][1]; + dest->mf[1][0] = fv0; + dest->mf[1][1] = fv1; + fv0 = src->mf[1][2]; + fv1 = src->mf[1][3]; + dest->mf[1][2] = fv0; + dest->mf[1][3] = fv1; + } + if (1) { + fv0 = src->mf[2][0]; + fv1 = src->mf[2][1]; + dest->mf[2][0] = fv0; + dest->mf[2][1] = fv1; + fv0 = src->mf[2][2]; + fv1 = src->mf[2][3]; + dest->mf[2][2] = fv0; + dest->mf[2][3] = fv1; + } + if (1) { + fv0 = src->mf[3][0]; + fv1 = src->mf[3][1]; + dest->mf[3][0] = fv0; + dest->mf[3][1] = fv1; + fv0 = src->mf[3][2]; + fv1 = src->mf[3][3]; + dest->mf[3][2] = fv0; + dest->mf[3][3] = fv1; + } +} + +/** + * @brief Converts fixed-point RSP-compatible matrix to an MtxF. + * + * @param[in] src mtx to convert + * @param[out] dest MtxF to output to + * + * @remark original name: "Matrix_MtxtoMtxF" + */ +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest) { + u16* intPart = (u16*)&src->m[0][0]; + u16* fracPart = (u16*)&src->m[2][0]; + + dest->xx = ((intPart[0] << 0x10) | fracPart[0]) * (1 / (f32)0x10000); + dest->yx = ((intPart[1] << 0x10) | fracPart[1]) * (1 / (f32)0x10000); + dest->zx = ((intPart[2] << 0x10) | fracPart[2]) * (1 / (f32)0x10000); + dest->wx = ((intPart[3] << 0x10) | fracPart[3]) * (1 / (f32)0x10000); + dest->xy = ((intPart[4] << 0x10) | fracPart[4]) * (1 / (f32)0x10000); + dest->yy = ((intPart[5] << 0x10) | fracPart[5]) * (1 / (f32)0x10000); + dest->zy = ((intPart[6] << 0x10) | fracPart[6]) * (1 / (f32)0x10000); + dest->wy = ((intPart[7] << 0x10) | fracPart[7]) * (1 / (f32)0x10000); + dest->xz = ((intPart[8] << 0x10) | fracPart[8]) * (1 / (f32)0x10000); + dest->yz = ((intPart[9] << 0x10) | fracPart[9]) * (1 / (f32)0x10000); + dest->zz = ((intPart[10] << 0x10) | fracPart[10]) * (1 / (f32)0x10000); + dest->wz = ((intPart[11] << 0x10) | fracPart[11]) * (1 / (f32)0x10000); + dest->xw = ((intPart[12] << 0x10) | fracPart[12]) * (1 / (f32)0x10000); + dest->yw = ((intPart[13] << 0x10) | fracPart[13]) * (1 / (f32)0x10000); + dest->zw = ((intPart[14] << 0x10) | fracPart[14]) * (1 / (f32)0x10000); + dest->ww = ((intPart[15] << 0x10) | fracPart[15]) * (1 / (f32)0x10000); +} + +// Unused +/** + * @brief Calculates mf * (src,1) and writes its components to dest. + * + * This is the same as Matrix_MultVec3f() but using a specified matrix rather than the current one; the same + * assumptions apply. + * + * @param[in] src input vector + * @param[out] dest output vector + * @param[in] mf matrix to multiply by + */ +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf) { + dest->x = mf->xw + (mf->xx * src->x + mf->xy * src->y + mf->xz * src->z); + dest->y = mf->yw + (mf->yx * src->x + mf->yy * src->y + mf->yz * src->z); + dest->z = mf->zw + (mf->zx * src->x + mf->zy * src->y + mf->zz * src->z); +} + +/** + * @brief Overwrite the linear part of mf with its transpose (ignores the translational part). + * + * Viz., + * + * \f[ + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \longrightarrow + * \begin{pmatrix} + * A^T & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * @param[in,out] mf matrix to transpose + * + * @remark original name: "Matrix_reverse" + */ +void Matrix_Transpose(MtxF* mf) { + f32 temp; + + temp = mf->yx; + mf->yx = mf->xy; + mf->xy = temp; + + temp = mf->zx; + mf->zx = mf->xz; + mf->xz = temp; + + temp = mf->zy; + mf->zy = mf->yz; + mf->yz = temp; +} + +/** + * @brief Decompose the linear part A of current into B * S, where B has normalised columns and S is diagonal, and + * replace B by `mf`. + * + * Since B is typically a rotation matrix, and the linear part R * S to `mf` * S, this operation can be + * seen as replacing the B rotation with `mf`, hence the function name. + * + * @param[in] mf matrix whose linear part will replace the normalised part of A. + */ +void Matrix_ReplaceRotation(MtxF* mf) { + MtxF* cmf = sCurrentMatrix; + f32 acc; + f32 component; + f32 curColNorm; + + // compute the Euclidean norm of the first column of the current matrix + acc = cmf->xx; + acc *= acc; + component = cmf->yx; + acc += SQ(component); + component = cmf->zx; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xx = mf->xx * curColNorm; + cmf->yx = mf->yx * curColNorm; + cmf->zx = mf->zx * curColNorm; + + // second column + acc = cmf->xy; + acc *= acc; + component = cmf->yy; + acc += SQ(component); + component = cmf->zy; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xy = mf->xy * curColNorm; + cmf->yy = mf->yy * curColNorm; + cmf->zy = mf->zy * curColNorm; + + // third column + acc = cmf->xz; + acc *= acc; + component = cmf->yz; + acc += SQ(component); + component = cmf->zz; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xz = mf->xz * curColNorm; + cmf->yz = mf->yz * curColNorm; + cmf->zz = mf->zz * curColNorm; +} + +/** + * @brief Extract the YXZ Tait-Bryan rotation angles from the linear part \f$ A \f$ of a matrix. + * + * \f$ A \f$ should have orthogonal columns; the most general matrix of this form can be written as \f$ RS \f$ + * with \f$ S \f$ a scale matrix. + * + * If A has columns with the same norm (such as if it is just a rotation matrix), it is sufficient (and faster) to use + * `nonUniformScale` off: `nonUniformScale` being set enables extraction of the angles from a matrix with columns that + * are orthogonal but have different scales, at the cost of requiring extra calculation. + * + * @param[in] src Matrix to extract angles from. + * @param[out] dest vector to write angles to. + * @param[in] nonUniformScale boolean: true enables handling matrices with differently-scaled columns. + * + * @remark original name: "Matrix_to_rotate_new"? + */ +void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale) { + f32 temp; + f32 temp2; + f32 temp3; + f32 temp4; + + temp = src->xz; + temp *= temp; + temp += SQ(src->zz); + dest->x = Math_Atan2S(-src->yz, sqrtf(temp)); + + if ((dest->x == 0x4000) || (dest->x == -0x4000)) { + // cos(x) = 0 if either of these is true, and we get gimbal locking + // (https://en.wikipedia.org/wiki/Gimbal_lock#Loss_of_a_degree_of_freedom_with_Euler_angles); fix z to make y + // well-defined. + dest->z = 0; + + dest->y = Math_Atan2S(-src->zx, src->xx); + } else { + dest->y = Math_Atan2S(src->xz, src->zz); + + if (!nonUniformScale) { + // assume the columns have the same normalisation + dest->z = Math_Atan2S(src->yx, src->yy); + } else { + temp = src->xx; + temp2 = src->zx; + temp3 = src->zy; + + // find norm of the first column + temp *= temp; + temp += SQ(temp2); + temp2 = src->yx; + temp += SQ(temp2); + // temp = xx^2+zx^2+yx^2 == 1 for a rotation matrix + temp = sqrtf(temp); + temp = temp2 / temp; // yx in normalised column + + // find norm of the second column + temp2 = src->xy; + temp2 *= temp2; + temp2 += SQ(temp3); + temp3 = src->yy; + temp2 += SQ(temp3); + // temp2 = xy^2+zy^2+yy^2 == 1 for a rotation matrix + temp2 = sqrtf(temp2); + temp2 = temp3 / temp2; // yy in normalised column + + // for a rotation matrix, temp == yx and temp2 == yy which is the same as in the !nonUniformScale branch + dest->z = Math_Atan2S(temp, temp2); + } + } +} + +/** + * @brief Extract the ZYX Tait-Bryan rotation angles from the linear part \f$ A \f$ of a matrix. + * + * \f$ A \f$ should have orthogonal columns; the most general matrix of this form can be written as \f$ RS \f$ + * with \f$ S \f$ a scale matrix. + * + * If A has columns with the same norm (such as if it is just a rotation matrix), it is sufficient (and faster) to use + * `nonUniformScale` off: `nonUniformScale` being set enables extraction of the angles from a matrix with columns that + * are orthogonal but have different scales, at the cost of requiring extra calculation. + * + * @param[in] src Matrix to extract angles from. + * @param[out] dest vector to write angles to. + * @param[in] nonUniformScale boolean: true enables handling matrices with unnormalised columns. + * + * @remark original name: "Matrix_to_rotate2_new"? + * + * See Matrix_MtxFToYXZRot() for full inline documentation. + */ +void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale) { + f32 temp; + f32 temp2; + f32 temp3; + f32 temp4; + + temp = src->xx; + temp *= temp; + temp += SQ(src->yx); + dest->y = Math_Atan2S(-src->zx, sqrtf(temp)); + + if ((dest->y == 0x4000) || (dest->y == -0x4000)) { + dest->x = 0; + dest->z = Math_Atan2S(-src->xy, src->yy); + } else { + dest->z = Math_Atan2S(src->yx, src->xx); + + if (!nonUniformScale) { + dest->x = Math_Atan2S(src->zy, src->zz); + } else { + temp = src->xy; + temp2 = src->yy; + temp3 = src->yz; + + temp *= temp; + temp += SQ(temp2); + temp2 = src->zy; + temp += SQ(temp2); + temp = sqrtf(temp); + temp = temp2 / temp; + + temp2 = src->xz; + temp2 *= temp2; + temp2 += SQ(temp3); + temp3 = src->zz; + temp2 += SQ(temp3); + temp2 = sqrtf(temp2); + temp2 = temp3 / temp2; + + dest->x = Math_Atan2S(temp, temp2); + } + } +} + +/** + * @brief Rotate by `angle` radians about `axis`, which is assumed to be a unit vector. + * + * @param angle rotation angle (radians). + * @param axis axis about which to rotate, must be a unit vector. + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateVector", but clashed with the next function. + */ +void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 versin; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + f32 temp5; + + if (mode == MTXMODE_APPLY) { + if (angle != 0) { + cmf = sCurrentMatrix; + + sin = sinf(angle); + cos = cosf(angle); + + temp1 = cmf->xx; + temp2 = cmf->xy; + temp3 = cmf->xz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->xx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->xy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->xz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->yx; + temp2 = cmf->yy; + temp3 = cmf->yz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->yx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->yy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->yz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->zx; + temp2 = cmf->zy; + temp3 = cmf->zz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->zx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->zy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->zz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + } + } else { + cmf = sCurrentMatrix; + + if (angle != 0) { + sin = sinf(angle); + cos = cosf(angle); + versin = 1.0f - cos; + + cmf->xx = axis->x * axis->x * versin + cos; + cmf->yy = axis->y * axis->y * versin + cos; + cmf->zz = axis->z * axis->z * versin + cos; + + if (0) {} + + temp2 = axis->x * versin * axis->y; + temp3 = axis->z * sin; + cmf->yx = temp2 + temp3; + cmf->xy = temp2 - temp3; + + temp2 = axis->x * versin * axis->z; + temp3 = axis->y * sin; + cmf->zx = temp2 - temp3; + cmf->xz = temp2 + temp3; + + temp2 = axis->y * versin * axis->z; + temp3 = axis->x * sin; + cmf->zy = temp2 + temp3; + cmf->yz = temp2 - temp3; + + cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f; + cmf->ww = 1.0f; + } else { + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + } + } +} + +/** + * @brief Rotate by binary angle `angle` about `axis`, which is assumed to be a unit vector. + * + * @param angle rotation angle (binary). + * @param axis axis about which to rotate, must be a unit vector. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateVector" + */ +void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode) { + MtxF* cmf; + f32 cos; + f32 sin; + f32 versin; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + + if (mode == MTXMODE_APPLY) { + if (angle != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(angle); + cos = Math_CosS(angle); + + temp1 = cmf->xx; + temp2 = cmf->xy; + temp3 = cmf->xz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->xx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->xy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->xz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->yx; + temp2 = cmf->yy; + temp3 = cmf->yz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->yx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->yy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->yz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->zx; + temp2 = cmf->zy; + temp3 = cmf->zz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->zx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->zy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->zz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + } + } else { + cmf = sCurrentMatrix; + + if (angle != 0) { + sin = Math_SinS(angle); + cos = Math_CosS(angle); + versin = 1.0f - cos; + + cmf->xx = axis->x * axis->x * versin + cos; + cmf->yy = axis->y * axis->y * versin + cos; + cmf->zz = axis->z * axis->z * versin + cos; + + if (0) {} + + temp2 = axis->x * versin * axis->y; + temp3 = axis->z * sin; + cmf->yx = temp2 + temp3; + cmf->xy = temp2 - temp3; + + temp2 = axis->x * versin * axis->z; + temp3 = axis->y * sin; + cmf->zx = temp2 - temp3; + cmf->xz = temp2 + temp3; + + temp2 = axis->y * versin * axis->z; + temp3 = axis->x * sin; + cmf->zy = temp2 + temp3; + cmf->yz = temp2 - temp3; + + cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f; + cmf->ww = 1.0f; + } else { + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + } + } +} diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 2d75505d0..6d0b9573d 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -92,10 +92,10 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf } func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx); - Matrix_SetCurrentState(&mtx); + Matrix_Put(&mtx); if ((dlist != gCircleShadowDL) || (actor->scale.x != actor->scale.z)) { - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); } shadowScale *= actor->shape.shadowScale; @@ -151,8 +151,8 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3 sp58 = Math_FAtan2F(dir2, dir0); shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f)); shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f); - Matrix_SetCurrentState(arg2); - Matrix_RotateY(sp58, MTXMODE_APPLY); + Matrix_Put(arg2); + Matrix_RotateYS(sp58, MTXMODE_APPLY); Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); @@ -301,9 +301,9 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos) { if (limbIndex == leftFootIndex) { - Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); + Matrix_MultVec3f(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); } else if (limbIndex == rightFootIndex) { - Matrix_MultiplyVector3fByState(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); + Matrix_MultVec3f(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); } } @@ -533,22 +533,22 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { var2 = ((entry->unkC - 120.0f) * 0.001f) + 0.15f; } - Matrix_InsertTranslation(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); + Matrix_Translate(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); Matrix_Scale(var2, 0.15f, 1.0f, MTXMODE_APPLY); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b, (u8)alpha); - Matrix_InsertZRotation_s((targetCtx->unk4B * 512), MTXMODE_APPLY); + Matrix_RotateZS((targetCtx->unk4B * 512), MTXMODE_APPLY); for (i = 0; i < 4; i++) { - Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertTranslation(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -566,10 +566,10 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); - Matrix_InsertTranslation(actor->focus.pos.x, - actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, - actor->focus.pos.z, MTXMODE_NEW); - Matrix_RotateY((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); + Matrix_Translate(actor->focus.pos.x, + actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, + actor->focus.pos.z, MTXMODE_NEW); + Matrix_RotateYS((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); @@ -2511,14 +2511,13 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { Lights_Draw(light, globalCtx->state.gfxCtx); if (actor->flags & ACTOR_FLAG_1000) { - Matrix_SetStateRotationAndTranslation( + Matrix_SetTranslateRotateYXZ( actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); } else { - Matrix_SetStateRotationAndTranslation(actor->world.pos.x, - actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), - actor->world.pos.z, &actor->shape.rot); + Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z, &actor->shape.rot); } Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); @@ -3543,14 +3542,14 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx* MtxF* currentMatrix; if (*dList != NULL) { - currentMatrix = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); spawnedPart = Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0], currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); if (spawnedPart != NULL) { part = (EnPart*)spawnedPart; - func_8018219C(currentMatrix, &part->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false); part->unk_150 = *dList; Math_Vec3f_Copy(&part->actor.scale, &actor->scale); } @@ -3772,9 +3771,9 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48); if (sp44 != NULL) { func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); - Matrix_SetCurrentState(&sp58); + Matrix_Put(&sp58); } else { - Matrix_InsertTranslation(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); } Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); @@ -3841,16 +3840,16 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&baseMtxF); + Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); + Matrix_Get(&baseMtxF); - chainsTranslateX = __sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; - chainsTranslateY = __cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; + chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; + chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; for (i = 0; i < 4; i++) { - Matrix_SetCurrentState(&baseMtxF); - Matrix_InsertZRotation_f(chainRotZ, MTXMODE_APPLY); - Matrix_InsertTranslation(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); + Matrix_Put(&baseMtxF); + Matrix_RotateZF(chainRotZ, MTXMODE_APPLY); + Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); if (entry->chainsScale != 1.0f) { Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); } @@ -3867,7 +3866,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { chainRotZ += rotZStep; } - Matrix_SetCurrentState(&baseMtxF); + Matrix_Put(&baseMtxF); Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4516,7 +4515,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP u32 gameplayFrames = globalCtx->gameplayFrames; f32 effectAlphaScaled; - currentMatrix = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { @@ -4565,15 +4564,15 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); - Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); if (limbIndex & 1) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } if (limbIndex & 2) { - Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateZF(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4604,8 +4603,8 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4625,7 +4624,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP type = 255; } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, MTXMODE_APPLY); @@ -4651,7 +4650,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); currentMatrix->mf[3][0] = limbPos->x; currentMatrix->mf[3][1] = limbPos->y; currentMatrix->mf[3][2] = limbPos->z; @@ -4688,12 +4687,12 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); // Apply and draw a light orb over each limb of frozen actor for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateZF(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = limbPos->x; currentMatrix->mf[3][1] = limbPos->y; currentMatrix->mf[3][2] = limbPos->z; @@ -4726,14 +4725,14 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); // Every limb draws two electric sparks at random orientations for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { // first electric spark - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; @@ -4744,8 +4743,8 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); // second electric spark - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 58c71c33e..0667bd84b 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -248,20 +248,20 @@ void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) { phi_f12 = 0.0f; } dest->xx = z_f14; - dest->xy = (-nx) * phi_f14; - dest->xz = (-nx) * phi_f12; - dest->yx = nx; + dest->yx = (-nx) * phi_f14; + dest->zx = (-nx) * phi_f12; + dest->xy = nx; dest->yy = ny; - dest->yz = nz; - dest->zx = 0.0f; - dest->zy = -phi_f12; + dest->zy = nz; + dest->xz = 0.0f; + dest->yz = -phi_f12; dest->zz = phi_f14; - dest->wx = tx; - dest->wy = ty; - dest->wz = tz; - dest->xw = 0.0f; - dest->yw = 0.0f; - dest->zw = 0.0f; + dest->xw = tx; + dest->yw = ty; + dest->zw = tz; + dest->wx = 0.0f; + dest->wy = 0.0f; + dest->wz = 0.0f; dest->ww = 1.0f; } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index a08e3f822..7ac956e5d 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -3691,7 +3691,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) { D_801EE1C0.x = collider->elements[i].dim.modelSphere.center.x; D_801EE1C0.y = collider->elements[i].dim.modelSphere.center.y; D_801EE1C0.z = collider->elements[i].dim.modelSphere.center.z; - Matrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0); + Matrix_MultVec3f(&D_801EE1C0, &D_801EE1D0); collider->elements[i].dim.worldSphere.center.x = D_801EE1D0.x; collider->elements[i].dim.worldSphere.center.y = D_801EE1D0.y; collider->elements[i].dim.worldSphere.center.z = D_801EE1D0.z; @@ -3733,7 +3733,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) { D_801EE1E0.x = collider->dim.modelSphere.center.x; D_801EE1E0.y = collider->dim.modelSphere.center.y; D_801EE1E0.z = collider->dim.modelSphere.center.z; - Matrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0); + Matrix_MultVec3f(&D_801EE1E0, &D_801EE1F0); collider->dim.worldSphere.center.x = D_801EE1F0.x; collider->dim.worldSphere.center.y = D_801EE1F0.y; collider->dim.worldSphere.center.z = D_801EE1F0.z; diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index ab3478fa1..fb7378751 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -68,10 +68,10 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo func_8012C6FC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); - Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); + Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -94,7 +94,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1); - Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); + Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index d246aaffa..f959867fe 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -106,7 +106,7 @@ void EffFootmark_Draw(GlobalContext* globalCtx) { for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { if (footmark->actor != NULL) { - Matrix_SetCurrentState(&footmark->displayMatrix); + Matrix_Put(&footmark->displayMatrix); Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY); gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index e22b5f351..c8eb927fa 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -104,7 +104,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (overrideLimbDraw == NULL || (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { @@ -126,7 +126,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* pos.y = transform->y; pos.z = transform->z; - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); if (lod == 0) { @@ -164,7 +164,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->nextLimbIdx != LIMB_DONE) { SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 379ebda1d..f627c6394 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -159,7 +159,7 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { vec.x = 0; vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; vec.z = 0; - Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec); + Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec); Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 5d47b4153..e9fae530a 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -431,7 +431,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { gDPSetPrimColor(dl++, 0, 0, params->color[0], params->color[1], params->color[2], 50); - Matrix_InsertTranslation(params->x, params->y, params->z, MTXMODE_NEW); + Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 6563eecfc..0a3334bc8 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -33,7 +33,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -44,7 +44,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -63,7 +63,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -91,7 +91,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -102,7 +102,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa dList = rootLimb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -123,7 +123,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa lod); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -143,7 +143,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -157,7 +157,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*mtx); gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); @@ -178,7 +178,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s lod, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -211,7 +211,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi OPEN_DISPS(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -223,7 +223,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -246,7 +246,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi actor, lod, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -263,7 +263,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -274,7 +274,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -292,7 +292,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); @@ -318,7 +318,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -329,7 +329,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa dList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -347,7 +347,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -363,7 +363,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -376,7 +376,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*limbMatricies); gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD); @@ -397,7 +397,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s limbMatricies); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -430,7 +430,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -442,7 +442,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -467,7 +467,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -483,7 +483,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -496,8 +496,8 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, limbIndex, actor); @@ -514,7 +514,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, (*mtx)++; } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -526,7 +526,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, transformLimbDraw, actor, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, @@ -566,7 +566,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -578,8 +578,8 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, 1, actor); @@ -595,7 +595,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V Matrix_ToMtx(mtx++); } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -607,7 +607,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V postLimbDraw, transformLimbDraw, actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -660,7 +660,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -673,7 +673,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton dList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); @@ -690,7 +690,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -716,7 +716,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable return NULL; } - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -729,7 +729,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable dList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); @@ -746,7 +746,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable actor, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -763,7 +763,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -776,7 +776,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -799,7 +799,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel actor, mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, @@ -832,7 +832,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -845,7 +845,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -868,7 +868,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT actor, &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } diff --git a/src/code/z_skin.c b/src/code/z_skin.c index 808a00da0..de449c02d 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -13,13 +13,13 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod Vec3f normal; Vec3f sp44; - wTemp.x = mtx->wx; - wTemp.y = mtx->wy; - wTemp.z = mtx->wz; + wTemp.x = mtx->xw; + wTemp.y = mtx->yw; + wTemp.z = mtx->zw; - mtx->wx = 0.0f; - mtx->wy = 0.0f; - mtx->wz = 0.0f; + mtx->xw = 0.0f; + mtx->yw = 0.0f; + mtx->zw = 0.0f; for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { vtx = &vtxBuf[vertexEntry->index]; @@ -39,9 +39,9 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod vtx->n.n[2] = normal.z; } - mtx->wx = wTemp.x; - mtx->wy = wTemp.y; - mtx->wz = wTemp.z; + mtx->xw = wTemp.x; + mtx->yw = wTemp.y; + mtx->zw = wTemp.z; } void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.c index f355aec9b..9b30a3c0b 100644 --- a/src/code/z_skin_matrix.c +++ b/src/code/z_skin_matrix.c @@ -1,13 +1,11 @@ #include "global.h" -// clang-format off -MtxF sMtxFClear = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, -}; -// clang-format on +MtxF sMtxFClear = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; /** * Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting 4 components to xyzDest @@ -16,10 +14,10 @@ MtxF sMtxFClear = { * \f[ [\texttt{xyzDest}, \texttt{wDest}] = [\texttt{src}, 1] \cdot [mf] \f] */ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) { - xyzDest->x = mf->wx + ((src->x * mf->xx) + (src->y * mf->yx) + (src->z * mf->zx)); - xyzDest->y = mf->wy + ((src->x * mf->xy) + (src->y * mf->yy) + (src->z * mf->zy)); - xyzDest->z = mf->wz + ((src->x * mf->xz) + (src->y * mf->yz) + (src->z * mf->zz)); - *wDest = mf->ww + ((src->x * mf->xw) + (src->y * mf->yw) + (src->z * mf->zw)); + xyzDest->x = mf->xw + ((src->x * mf->xx) + (src->y * mf->xy) + (src->z * mf->xz)); + xyzDest->y = mf->yw + ((src->x * mf->yx) + (src->y * mf->yy) + (src->z * mf->yz)); + xyzDest->z = mf->zw + ((src->x * mf->zx) + (src->y * mf->zy) + (src->z * mf->zz)); + *wDest = mf->ww + ((src->x * mf->wx) + (src->y * mf->wy) + (src->z * mf->wz)); } /** @@ -29,21 +27,22 @@ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDe */ void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) { f32 mx = mf->xx; - f32 my = mf->yx; - f32 mz = mf->zx; - f32 mw = mf->wx; + f32 my = mf->xy; + f32 mz = mf->xz; + f32 mw = mf->xw; + dest->x = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); - mx = mf->xy; + mx = mf->yx; my = mf->yy; - mz = mf->zy; - mw = mf->wy; + mz = mf->yz; + mw = mf->yw; dest->y = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); - mx = mf->xz; - my = mf->yz; + mx = mf->zx; + my = mf->zy; mz = mf->zz; - mw = mf->wz; + mw = mf->zw; dest->z = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); } @@ -59,122 +58,122 @@ void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest) { //---COL1--- f32 cx = mfB->xx; - f32 cy = mfB->yx; - f32 cz = mfB->zx; - f32 cw = mfB->wx; + f32 cy = mfB->xy; + f32 cz = mfB->xz; + f32 cw = mfB->xw; //-------- rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; dest->xx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->zx; - ry = mfA->zy; - rz = mfA->zz; - rw = mfA->zw; - dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; - rw = mfA->ww; - dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - //---2Col--- - cx = mfB->xy; - cy = mfB->yy; - cz = mfB->zy; - cw = mfB->wy; - //-------- - rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + rz = mfA->zy; + rw = mfA->wy; dest->xy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; - ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; - dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; - rw = mfA->ww; - dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - //---3Col--- - cx = mfB->xz; - cy = mfB->yz; - cz = mfB->zz; - cw = mfB->wz; - //-------- - rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + rw = mfA->wz; dest->xz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; + rw = mfA->ww; + dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---2Col--- + cx = mfB->yx; + cy = mfB->yy; + cz = mfB->yz; + cw = mfB->yw; + //-------- + rx = mfA->xx; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; + rz = mfA->zy; + rw = mfA->wy; + dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xz; + ry = mfA->yz; + rz = mfA->zz; + rw = mfA->wz; dest->yz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; + rw = mfA->ww; + dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---3Col--- + cx = mfB->zx; + cy = mfB->zy; + cz = mfB->zz; + cw = mfB->zw; + //-------- + rx = mfA->xx; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xy; + ry = mfA->yy; + rz = mfA->zy; + rw = mfA->wy; + dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; + rw = mfA->wz; dest->zz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; rw = mfA->ww; - dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); //---4Col--- - cx = mfB->xw; - cy = mfB->yw; - cz = mfB->zw; + cx = mfB->wx; + cy = mfB->wy; + cz = mfB->wz; cw = mfB->ww; //-------- rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; - dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + rz = mfA->zy; + rw = mfA->wy; + dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; - dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + rw = mfA->wz; + dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; rw = mfA->ww; dest->ww = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); } @@ -188,39 +187,39 @@ void SkinMatrix_GetClear(MtxF** mfp) { void SkinMatrix_Clear(MtxF* mf) { mf->xx = 1.0f; - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yy = 1.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zz = 1.0f; - mf->zw = 0.0f; mf->wx = 0.0f; + mf->xy = 0.0f; + mf->yy = 1.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; + mf->zz = 1.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; mf->ww = 1.0f; } void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) { dest->xx = src->xx; - dest->xy = src->xy; - dest->xz = src->xz; - dest->xw = src->xw; dest->yx = src->yx; - dest->yy = src->yy; - dest->yz = src->yz; - dest->yw = src->yw; dest->zx = src->zx; - dest->zy = src->zy; - dest->zz = src->zz; - dest->zw = src->zw; dest->wx = src->wx; + dest->xy = src->xy; + dest->yy = src->yy; + dest->zy = src->zy; dest->wy = src->wy; + dest->xz = src->xz; + dest->yz = src->yz; + dest->zz = src->zz; dest->wz = src->wz; + dest->xw = src->xw; + dest->yw = src->yw; + dest->zw = src->zw; dest->ww = src->ww; } @@ -282,18 +281,18 @@ s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) { * Produces a matrix which scales x,y,z components of vectors or x,y,z rows of matrices (when applied on LHS) */ void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) { - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zw = 0.0f; mf->wx = 0.0f; + mf->xy = 0.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; mf->ww = 1.0f; mf->xx = x; mf->yy = y; @@ -307,16 +306,16 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { f32 cos2; f32 sin = Math_SinS(yaw); f32 cos = Math_CosS(yaw); - f32 yx; + f32 xy; f32 sin2; - f32 zx; + f32 xz; f32 yy; - f32 zy; + f32 yz; mf->yy = cos; - mf->yx = -sin; - mf->xw = mf->yw = mf->zw = 0; + mf->xy = -sin; mf->wx = mf->wy = mf->wz = 0; + mf->xw = mf->yw = mf->zw = 0; mf->ww = 1; if (pitch != 0) { @@ -324,19 +323,19 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { cos2 = Math_CosS(pitch); mf->xx = cos * cos2; - mf->zx = cos * sin2; + mf->xz = cos * sin2; - mf->xy = sin * cos2; - mf->zy = sin * sin2; - mf->xz = -sin2; + mf->yx = sin * cos2; + mf->yz = sin * sin2; + mf->zx = -sin2; mf->zz = cos2; } else { mf->xx = cos; if (1) {} if (1) {} - zx = sin; // required to match - mf->xy = sin; - mf->xz = mf->zx = mf->zy = 0; + xz = sin; // required to match + mf->yx = sin; + mf->zx = mf->xz = mf->yz = 0; mf->zz = 1; } @@ -344,22 +343,22 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { sin2 = Math_SinS(roll); cos2 = Math_CosS(roll); - yx = mf->yx; - zx = mf->zx; - mf->yx = (yx * cos2) + (zx * sin2); - mf->zx = (zx * cos2) - (yx * sin2); + xy = mf->xy; + xz = mf->xz; + mf->xy = (xy * cos2) + (xz * sin2); + mf->xz = (xz * cos2) - (xy * sin2); if (1) {} - zy = mf->zy; + yz = mf->yz; yy = mf->yy; - mf->yy = (yy * cos2) + (zy * sin2); - mf->zy = (zy * cos2) - (yy * sin2); + mf->yy = (yy * cos2) + (yz * sin2); + mf->yz = (yz * cos2) - (yy * sin2); if (cos2) {} - mf->yz = mf->zz * sin2; + mf->zy = mf->zz * sin2; mf->zz = mf->zz * cos2; } else { - mf->yz = 0; + mf->zy = 0; } } @@ -370,23 +369,23 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { f32 cos2; f32 sin; f32 cos; - f32 xz; + f32 zx; f32 sin2; - f32 yz; + f32 zy; f32 xx; - f32 yx; + f32 xy; sin = Math_SinS(roll); cos = Math_CosS(roll); mf->xx = cos; - mf->xz = -sin; - mf->zw = 0; - mf->yw = 0; - mf->xw = 0; + mf->zx = -sin; mf->wz = 0; mf->wy = 0; mf->wx = 0; + mf->zw = 0; + mf->yw = 0; + mf->xw = 0; mf->ww = 1; if (yaw != 0) { @@ -394,19 +393,19 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { cos2 = Math_CosS(yaw); mf->zz = cos * cos2; - mf->yz = cos * sin2; + mf->zy = cos * sin2; - mf->zx = sin * cos2; - mf->yx = sin * sin2; - mf->zy = -sin2; + mf->xz = sin * cos2; + mf->xy = sin * sin2; + mf->yz = -sin2; mf->yy = cos2; } else { mf->zz = cos; if (1) {} if (1) {} - yx = sin; // required to match - mf->zx = sin; - mf->yx = mf->yz = mf->zy = 0; + xy = sin; // required to match + mf->xz = sin; + mf->xy = mf->zy = mf->yz = 0; mf->yy = 1; } @@ -414,19 +413,19 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { sin2 = Math_SinS(pitch); cos2 = Math_CosS(pitch); xx = mf->xx; - yx = mf->yx; - mf->xx = (xx * cos2) + (yx * sin2); - mf->yx = yx * cos2 - (xx * sin2); + xy = mf->xy; + mf->xx = (xx * cos2) + (xy * sin2); + mf->xy = xy * cos2 - (xx * sin2); if (1) {} - yz = mf->yz; - xz = mf->xz; - mf->xz = (xz * cos2) + (yz * sin2); - mf->yz = (yz * cos2) - (xz * sin2); + zy = mf->zy; + zx = mf->zx; + mf->zx = (zx * cos2) + (zy * sin2); + mf->zy = (zy * cos2) - (zx * sin2); if (cos2) {} - mf->xy = mf->yy * sin2; + mf->yx = mf->yy * sin2; mf->yy = mf->yy * cos2; } else { - mf->xy = 0; + mf->yx = 0; } } @@ -434,22 +433,22 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { * Produces a matrix which translates a vector by amounts in the x, y and z directions */ void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z) { - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; + mf->wx = 0.0f; + mf->xy = 0.0f; mf->zy = 0.0f; - mf->zw = 0.0f; + mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; + mf->wz = 0.0f; mf->xx = 1.0f; mf->yy = 1.0f; mf->zz = 1.0f; mf->ww = 1.0f; - mf->wx = x; - mf->wy = y; - mf->wz = z; + mf->xw = x; + mf->yw = y; + mf->zw = z; } /** @@ -515,19 +514,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[0] = (temp >> 0x10); m1[16 + 0] = temp & 0xFFFF; - temp = src->xy * 0x10000; + temp = src->yx * 0x10000; m1[1] = (temp >> 0x10); m1[16 + 1] = temp & 0xFFFF; - temp = src->xz * 0x10000; + temp = src->zx * 0x10000; m1[2] = (temp >> 0x10); m1[16 + 2] = temp & 0xFFFF; - temp = src->xw * 0x10000; + temp = src->wx * 0x10000; m1[3] = (temp >> 0x10); m1[16 + 3] = temp & 0xFFFF; - temp = src->yx * 0x10000; + temp = src->xy * 0x10000; m1[4] = (temp >> 0x10); m1[16 + 4] = temp & 0xFFFF; @@ -535,19 +534,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[5] = (temp >> 0x10); m1[16 + 5] = temp & 0xFFFF; - temp = src->yz * 0x10000; + temp = src->zy * 0x10000; m1[6] = (temp >> 0x10); m1[16 + 6] = temp & 0xFFFF; - temp = src->yw * 0x10000; + temp = src->wy * 0x10000; m1[7] = (temp >> 0x10); m1[16 + 7] = temp & 0xFFFF; - temp = src->zx * 0x10000; + temp = src->xz * 0x10000; m1[8] = (temp >> 0x10); m1[16 + 8] = temp & 0xFFFF; - temp = src->zy * 0x10000; + temp = src->yz * 0x10000; m1[9] = (temp >> 0x10); m2[9] = temp & 0xFFFF; @@ -555,19 +554,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[10] = (temp >> 0x10); m2[10] = temp & 0xFFFF; - temp = src->zw * 0x10000; + temp = src->wz * 0x10000; m1[11] = (temp >> 0x10); m2[11] = temp & 0xFFFF; - temp = src->wx * 0x10000; + temp = src->xw * 0x10000; m1[12] = (temp >> 0x10); m2[12] = temp & 0xFFFF; - temp = src->wy * 0x10000; + temp = src->yw * 0x10000; m1[13] = (temp >> 0x10); m2[13] = temp & 0xFFFF; - temp = src->wz * 0x10000; + temp = src->zw * 0x10000; m1[14] = (temp >> 0x10); m2[14] = temp & 0xFFFF; @@ -612,21 +611,21 @@ void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z) { xz = x * z; mf->xx = (1.0f - xx) * cosA + xx; - mf->xy = (1.0f - cosA) * xy + z * sinA; - mf->xz = (1.0f - cosA) * xz - y * sinA; - mf->xw = 0.0f; + mf->yx = (1.0f - cosA) * xy + z * sinA; + mf->zx = (1.0f - cosA) * xz - y * sinA; + mf->wx = 0.0f; - mf->yx = (1.0f - cosA) * xy - z * sinA; + mf->xy = (1.0f - cosA) * xy - z * sinA; mf->yy = (1.0f - yy) * cosA + yy; - mf->yz = (1.0f - cosA) * yz + x * sinA; - mf->yw = 0.0f; + mf->zy = (1.0f - cosA) * yz + x * sinA; + mf->wy = 0.0f; - mf->zx = (1.0f - cosA) * xz + y * sinA; - mf->zy = (1.0f - cosA) * yz - x * sinA; + mf->xz = (1.0f - cosA) * xz + y * sinA; + mf->yz = (1.0f - cosA) * yz - x * sinA; mf->zz = (1.0f - zz) * cosA + zz; - mf->zw = 0.0f; + mf->wz = 0.0f; - mf->wx = mf->wy = mf->wz = 0.0f; + mf->xw = mf->yw = mf->zw = 0.0f; mf->ww = 1.0f; } @@ -642,27 +641,27 @@ void SkinMatrix_SetXRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; - mf->yx = 0.0f; - mf->yw = 0.0f; - mf->zx = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->xy = 0.0f; mf->wy = 0.0f; + + mf->xz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->xx = 1.0f; mf->ww = 1.0f; mf->yy = cosA; mf->zz = cosA; - mf->yz = sinA; - mf->zy = -sinA; + mf->zy = sinA; + mf->yz = -sinA; } void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { @@ -675,25 +674,25 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { sinA = Math_SinS(a); cosA = Math_CosS(a); - ry = mf->yx; - rz = mf->zx; - mf->yx = ry * cosA + rz * sinA; - mf->zx = rz * cosA - ry * sinA; + ry = mf->xy; + rz = mf->xz; + mf->xy = ry * cosA + rz * sinA; + mf->xz = rz * cosA - ry * sinA; ry = mf->yy; - rz = mf->zy; + rz = mf->yz; mf->yy = ry * cosA + rz * sinA; - mf->zy = rz * cosA - ry * sinA; + mf->yz = rz * cosA - ry * sinA; - ry = mf->yz; + ry = mf->zy; rz = mf->zz; - mf->yz = ry * cosA + rz * sinA; + mf->zy = ry * cosA + rz * sinA; mf->zz = rz * cosA - ry * sinA; - ry = mf->yw; - rz = mf->zw; - mf->yw = ry * cosA + rz * sinA; - mf->zw = rz * cosA - ry * sinA; + ry = mf->wy; + rz = mf->wz; + mf->wy = ry * cosA + rz * sinA; + mf->wz = rz * cosA - ry * sinA; } } @@ -709,27 +708,27 @@ void SkinMatrix_SetYRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xy = 0.0f; - mf->xw = 0.0f; - mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; - - mf->zy = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->xy = 0.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->yy = 1.0f; mf->ww = 1.0f; mf->xx = cosA; mf->zz = cosA; - mf->xz = -sinA; - mf->zx = sinA; + mf->zx = -sinA; + mf->xz = sinA; } void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { @@ -743,24 +742,24 @@ void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { cosA = Math_CosS(a); rx = mf->xx; - rz = mf->zx; + rz = mf->xz; mf->xx = rx * cosA - rz * sinA; - mf->zx = rx * sinA + rz * cosA; + mf->xz = rx * sinA + rz * cosA; - rx = mf->xy; - rz = mf->zy; - mf->xy = rx * cosA - rz * sinA; - mf->zy = rx * sinA + rz * cosA; + rx = mf->yx; + rz = mf->yz; + mf->yx = rx * cosA - rz * sinA; + mf->yz = rx * sinA + rz * cosA; - rx = mf->xz; + rx = mf->zx; rz = mf->zz; - mf->xz = rx * cosA - rz * sinA; + mf->zx = rx * cosA - rz * sinA; mf->zz = rx * sinA + rz * cosA; - rx = mf->xw; - rz = mf->zw; - mf->xw = rx * cosA - rz * sinA; - mf->zw = rx * sinA + rz * cosA; + rx = mf->wx; + rz = mf->wz; + mf->wx = rx * cosA - rz * sinA; + mf->wz = rx * sinA + rz * cosA; } } @@ -776,25 +775,25 @@ void SkinMatrix_SetZRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xz = 0.0f; - mf->xw = 0.0f; - - mf->yz = 0.0f; - mf->yw = 0.0f; - mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->zy = 0.0f; mf->wy = 0.0f; + + mf->xz = 0.0f; + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->zz = 1.0f; mf->ww = 1.0f; mf->xx = cosA; mf->yy = cosA; - mf->xy = sinA; - mf->yx = -sinA; + mf->yx = sinA; + mf->xy = -sinA; } diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 58812abc9..3e5443bc6 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -53,7 +53,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -63,8 +63,8 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, limbIndex, actor, &gfx); @@ -77,7 +77,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** Matrix_ToMtx(*mtx); (*mtx)++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx); @@ -86,7 +86,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); @@ -119,7 +119,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo } gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable->x; pos.y = jointTable->y; @@ -129,8 +129,8 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo limbDList = rootLimb->dList; if (overrideLimbDraw == NULL || !overrideLimbDraw(globalCtx, 1, &newDlist, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, 1, actor, &gfx); @@ -143,7 +143,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo Matrix_ToMtx(mtx); mtx++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -154,7 +154,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo gfx = SubS_DrawTransformFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -187,9 +187,9 @@ s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRo Vec3s newRot; MtxF curState; - Matrix_MultiplyVector3fByState(&zeroVec, &newPos); - Matrix_CopyCurrentState(&curState); - func_8018219C(&curState, &newRot, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(&curState); + Matrix_MtxFToYXZRot(&curState, &newRot, MTXMODE_NEW); *pos = newPos; if (!stepRot && !overrideRot) { @@ -538,7 +538,7 @@ void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween pos.z = bodyPartPos->z - worldPos->z; } - Matrix_MultiplyVector3fByState(&pos, &startVec); + Matrix_MultVec3f(&pos, &startVec); startCol = 64.0f + startVec.x; startRow = 64.0f - startVec.z; SubS_FillShadowTex(startCol >> 1, startRow >> 1, tex, sizes[i]); @@ -554,7 +554,7 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { func_8012C28C(gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 100); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - Matrix_InsertTranslation(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); + Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gShadowDL); diff --git a/src/code/z_view.c b/src/code/z_view.c index d11a18201..915c196b7 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -262,15 +262,15 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { F32_LERPIMP(view->curDistortionScale.z, view->distortionScale.z, view->distortionSpeed); } - Matrix_FromRSPMatrix(projectionMtx, &projectionMtxF); - Matrix_SetCurrentState(&projectionMtxF); - Matrix_RotateStateAroundXAxis(view->curDistortionDirRot.x); - Matrix_InsertYRotation_f(view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_f(view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_MtxToMtxF(projectionMtx, &projectionMtxF); + Matrix_Put(&projectionMtxF); + Matrix_RotateXFApply(view->curDistortionDirRot.x); + Matrix_RotateYF(view->curDistortionDirRot.y, MTXMODE_APPLY); + Matrix_RotateZF(view->curDistortionDirRot.z, MTXMODE_APPLY); Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); - Matrix_InsertZRotation_f(-view->curDistortionDirRot.z, MTXMODE_APPLY); - Matrix_InsertYRotation_f(-view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-view->curDistortionDirRot.x); + Matrix_RotateZF(-view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_RotateYF(-view->curDistortionDirRot.y, MTXMODE_APPLY); + Matrix_RotateXFApply(-view->curDistortionDirRot.x); Matrix_ToMtx(projectionMtx); return true; diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index d7f99eed9..326fcb3e2 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -3,11 +3,11 @@ Mtx* sSkyboxDrawMatrix; Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { - Matrix_InsertTranslation(x, y, z, MTXMODE_NEW); + Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(skyboxCtx->rotX); - Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rotX); + Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); return Matrix_ToMtx(sSkyboxDrawMatrix); } @@ -30,11 +30,11 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb sSkyboxDrawMatrix = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - Matrix_InsertTranslation(x, y, z, MTXMODE_NEW); + Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(skyboxCtx->rotX); - Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rotX); + Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); Matrix_ToMtx(sSkyboxDrawMatrix); gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.c index b71ba7234..65330e9a6 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.c @@ -1,22 +1,25 @@ #include "libc/math.h" #include "macros.h" -// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 -// [https://mathworld.wolfram.com/MaclaurinSeries.html]. -// The commented versions do not match. +#pragma weak cosf = __cosf + +// Coefficients of a degree 9 polynomial approximation of sine. It is not the Maclaurin polynamial, but some as-yet +// undetermined more uniform approximation. static const du P[] = { - { 1.0 }, // 1 - { -0.16666659550427756 }, // -1/3! = 1/6 - { 0.008333066246082155 }, // 1/5! = 1/120 - { -0.0001980960290193795 }, // -1/7! = -1/5040 - { 0.000002605780637968037 }, // 1/9! = 1/362880 + { 1.0 }, + { -0.16666659550427756 }, + { 0.008333066246082155 }, + { -0.0001980960290193795 }, + { 0.000002605780637968037 }, }; static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" +// pihi + pilo is the closest double to pi, this representation allows more precise calculations since pi itself is not +// an exact float static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi +static const du pilo = { 3.178650954705639E-8 }; static const fu zero = { 0x00000000 }; @@ -28,7 +31,7 @@ f32 __cosf(f32 x) { f32 absx; f64 dx; // x promoted to double f64 xSq; // square of dx - f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 polyApprox; // Most of the polynomial approximation to sin(x) f64 dn; // n promoted to double s32 n; // number of multiples of pi away from the first half-period f64 result; diff --git a/src/libultra/gu/perspective.c b/src/libultra/gu/perspective.c index 2af2d6ac5..d3dab2ef4 100644 --- a/src/libultra/gu/perspective.c +++ b/src/libultra/gu/perspective.c @@ -7,7 +7,7 @@ void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, fl guMtxIdentF(mf); fovy *= 3.1415926 / 180.0; - cot = __cosf(fovy / 2) / __sinf(fovy / 2); + cot = cosf(fovy / 2) / sinf(fovy / 2); mf[0][0] = cot / aspect; mf[1][1] = cot; diff --git a/src/libultra/gu/position.c b/src/libultra/gu/position.c index 589d4f4a3..95bd65fe3 100644 --- a/src/libultra/gu/position.c +++ b/src/libultra/gu/position.c @@ -13,12 +13,12 @@ void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f3 pitch *= D_80134D00; yaw *= D_80134D00; - sinr = __sinf(rot); - cosr = __cosf(rot); - sinp = __sinf(pitch); - cosp = __cosf(pitch); - sinh = __sinf(yaw); - cosh = __cosf(yaw); + sinr = sinf(rot); + cosr = cosf(rot); + sinp = sinf(pitch); + cosp = cosf(pitch); + sinh = sinf(yaw); + cosh = cosf(yaw); mf[0][0] = (cosp * cosh) * scale; mf[0][1] = (cosp * sinh) * scale; diff --git a/src/libultra/gu/rotate.c b/src/libultra/gu/rotate.c index c79c733bb..11d00ff73 100644 --- a/src/libultra/gu/rotate.c +++ b/src/libultra/gu/rotate.c @@ -16,8 +16,8 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) { a = a * D_80097F90; - sine = __sinf(a); - cosine = __cosf(a); + sine = sinf(a); + cosine = cosf(a); ab = x * y * (1 - cosine); bc = y * z * (1 - cosine); diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.c index 746d141a4..963bc2022 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.c @@ -1,22 +1,25 @@ #include "libc/math.h" #include "macros.h" -// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 -// [https://mathworld.wolfram.com/MaclaurinSeries.html]. -// The commented versions do not match. +#pragma weak sinf = __sinf + +// Coefficients of a degree 9 polynomial approximation of sine. It is not the Maclaurin polynamial, but some as-yet +// undetermined more uniform approximation. static const du P[] = { - { 1.0 }, // 1 - { -0.16666659550427756 }, // -1/3! = 1/6 - { 0.008333066246082155 }, // 1/5! = 1/120 - { -0.0001980960290193795 }, // -1/7! = -1/5040 - { 0.000002605780637968037 }, // 1/9! = 1/362880 + { 1.0 }, + { -0.16666659550427756 }, + { 0.008333066246082155 }, + { -0.0001980960290193795 }, + { 0.000002605780637968037 }, }; static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" +// pihi + pilo is the closest double to pi, this representation allows more precise calculations since pi itself is not +// an exact float static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi +static const du pilo = { 3.178650954705639E-8 }; static const fu zero = { 0x00000000 }; @@ -26,7 +29,7 @@ static const fu zero = { 0x00000000 }; f32 __sinf(f32 x) { f64 dx; // x promoted to double f64 xSq; // square of dx - f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 polyApprox; // Most of the polynomial approximation to sin(x) f64 dn; // n promoted to double s32 n; // number of multiples of pi away from the first half-period f64 result; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index b0a61382c..16aa93bd9 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -309,14 +309,14 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { - Matrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); - Matrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); - Matrix_MultiplyVector3fByState(&D_808C1C34, &sp50); + Matrix_MultVec3f(&D_808C1C10, &this->unk1E0); + Matrix_MultVec3f(&D_808C1C28, &sp5C); + Matrix_MultVec3f(&D_808C1C34, &sp50); this->unk1C4.active = false; } else { - Matrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); - Matrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); - Matrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); + Matrix_MultVec3f(&D_808C1C1C, &this->unk1E0); + Matrix_MultVec3f(&D_808C1C40, &sp5C); + Matrix_MultVec3f(&D_808C1C4C, &sp50); } func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50); func_8012C28C(globalCtx->state.gfxCtx); @@ -324,13 +324,12 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_link_child_DL_01D960); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68); sp48 = SQXZ(sp68); sp4C = sqrtf(SQXZ(sp68)); - Matrix_RotateY(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); - Matrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); + Matrix_RotateYS(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); + Matrix_RotateXS(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); f0 = sqrtf(SQ(sp68.y) + sp48); Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 0b9bedbb8..6a2590259 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -225,15 +225,15 @@ void FireArrow_SetQuadVerticies(ArrowFire* this) { Vec3f sp2C; Vec3f sp20; - Matrix_MultiplyVector3fByState(&D_80922284, &sp44); - Matrix_MultiplyVector3fByState(&D_80922290, &sp38); - Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C); - Matrix_MultiplyVector3fByState(&D_809222A8, &sp20); + Matrix_MultVec3f(&D_80922284, &sp44); + Matrix_MultVec3f(&D_80922290, &sp38); + Matrix_MultVec3f(&D_8092229C, &sp2C); + Matrix_MultVec3f(&D_809222A8, &sp20); Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20); - Matrix_MultiplyVector3fByState(&D_809222B4, &sp44); - Matrix_MultiplyVector3fByState(&D_809222C0, &sp38); - Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C); - Matrix_MultiplyVector3fByState(&D_809222D8, &sp20); + Matrix_MultVec3f(&D_809222B4, &sp44); + Matrix_MultVec3f(&D_809222C0, &sp38); + Matrix_MultVec3f(&D_809222CC, &sp2C); + Matrix_MultVec3f(&D_809222D8, &sp20); Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20); } @@ -249,10 +249,10 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); if (this->screenFillIntensity > 0.0f) { @@ -271,16 +271,16 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 8a402dfbe..6ae539178 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -196,10 +196,10 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw blue effect over the screen when arrow hits @@ -217,14 +217,14 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, (s32)(this->alpha * 0.5f) & 0xFF); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL); gSPDisplayList(POLY_XLU_DISP++, diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index ac8eb1ae9..1b25b8fbb 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -190,10 +190,10 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); if (this->screenFillIntensity > 0.0f) { POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); @@ -210,14 +210,14 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 09876c350..6ac390ce5 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -74,15 +74,15 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { s16 rotZ = this->dyna.actor.shape.rot.z & 0x1FFF; if (flag40 && (rotZ < 0x1B58) && (rotZ >= 0x1388)) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { if ((u32)Rand_Next() >= 0x40000000) { splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = sExitSplashOffsets[i].y; splashOffset.z = sExitSplashOffsets[i].z; - Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultVec3f(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); @@ -92,15 +92,15 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { } if ((rotZ < 0x1F4) && (rotZ >= 0)) { if (flag40) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { splashOffset.x = sEnterSplashOffsets[i].x + (Rand_ZeroOne() * 10.0f); splashOffset.y = sEnterSplashOffsets[i].y; splashOffset.z = sEnterSplashOffsets[i].z; - Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultVec3f(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 07693307b..0c5b92496 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -110,22 +110,22 @@ void func_80B823B0(BgDblueBalance* this) { s32 pad; Vec3f sp28; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp28.x = -138.28f; sp28.y = 0.0f; sp28.z = 0.0f; if (this->unk_15C != NULL) { - Matrix_MultiplyVector3fByState(&sp28, &this->unk_15C->dyna.actor.world.pos); + Matrix_MultVec3f(&sp28, &this->unk_15C->dyna.actor.world.pos); } sp28.x = 138.28f; if (this->unk_160 != NULL) { - Matrix_MultiplyVector3fByState(&sp28, &this->unk_160->dyna.actor.world.pos); + Matrix_MultVec3f(&sp28, &this->unk_160->dyna.actor.world.pos); } } @@ -136,16 +136,16 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { Vec3f sp48; Vec3f sp3C; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp48.x = -138.28f; sp48.y = 0.0f; sp48.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp48, &sp3C); + Matrix_MultVec3f(&sp48, &sp3C); this->unk_15C = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x100); @@ -157,7 +157,7 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { } sp48.x = 138.28f; - Matrix_MultiplyVector3fByState(&sp48, &sp3C); + Matrix_MultVec3f(&sp48, &sp3C); this->unk_160 = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x200); @@ -212,20 +212,20 @@ void func_80B8264C(BgDblueBalance* this) { } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); for (i = 0, phi_s0 = &this->unk_188[0], phi_s2 = 0; i < ARRAY_COUNT(this->unk_188); i++, phi_s2 += 0x2000, phi_s0++) { phi_s0->unk_0C = this->dyna.actor.shape.rot.x + phi_s2; - Matrix_StatePush(); - Matrix_InsertXRotation_s(phi_s0->unk_0C, MTXMODE_NEW); - Matrix_InsertTranslation(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&sp78); - Matrix_StatePop(); - Matrix_MultiplyVector3fByState(&sp78, &phi_s0->unk_00); + Matrix_Push(); + Matrix_RotateXS(phi_s0->unk_0C, MTXMODE_NEW); + Matrix_Translate(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_MultZero(&sp78); + Matrix_Pop(); + Matrix_MultVec3f(&sp78, &phi_s0->unk_00); temp_f0 = (sp78.z - 135.0f); if (sp78.z > 135.0f) { @@ -486,10 +486,10 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { if (this->unk_182) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp5C = this->unk_15C; - Matrix_StatePush(); - Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(45.0f, &sp60); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(45.0f, &sp60); + Matrix_Pop(); sp50.x = sp5C->dyna.actor.world.pos.x + sp60.x; sp50.y = this->unk_228; @@ -511,10 +511,10 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { if (this->unk_182) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp3C = this->unk_160; - Matrix_StatePush(); - Matrix_RotateY(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(30.0f, &sp40); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(30.0f, &sp40); + Matrix_Pop(); sp30.x = sp3C->dyna.actor.world.pos.x + sp40.x; sp30.y = this->unk_228; @@ -653,9 +653,9 @@ void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { AnimatedMat_Draw(globalCtx, D_80B83C74); sp38 = this->unk_160; - Matrix_SetStateRotationAndTranslation(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, - sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); - Matrix_InsertTranslation(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_SetTranslateRotateYXZ(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, + sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); + Matrix_Translate(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(sp38->dyna.actor.scale.x, sp38->dyna.actor.scale.y, sp38->dyna.actor.scale.z, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -708,9 +708,9 @@ void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { if (ptr->unk_0E != 0) { - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_0C, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_0C, MTXMODE_APPLY); Matrix_Scale(ptr->unk_10, ptr->unk_10, ptr->unk_10, MTXMODE_APPLY); temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index 3a12f286d..857eb43cf 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -259,9 +259,9 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); this->unk_1CC = D_80A2B96C[this->unk_178]; this->unk_1CE = this->unk_1CC; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledX(2240.0f, &this->unk_190); - Matrix_GetStateTranslationAndScaledX(-10.0f, &this->unk_19C); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecX(2240.0f, &this->unk_190); + Matrix_MultVecX(-10.0f, &this->unk_19C); Math_Vec3f_Sum(&this->unk_190, &this->dyna.actor.world.pos, &this->unk_190); Math_Vec3f_Sum(&this->unk_19C, &this->dyna.actor.world.pos, &this->unk_19C); D_80A2BBF0 = this; @@ -591,10 +591,10 @@ void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { } for (j = 0; j < ARRAY_COUNT(this->unk_1D8[0]); j++) { - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80A2B988, &spAC); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80A2B988, &spAC); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spAC); Math_Vec3f_Copy(&this->unk_238[i][j], &spAC); temp_f20 = spAC.y - this->unk_2F8[i]->world.pos.y; @@ -770,7 +770,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { Gfx* gfx; Gfx* gfx2; - Matrix_StatePush(); + Matrix_Push(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -808,7 +808,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -817,11 +817,11 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); gfx = func_8012C2B4(POLY_XLU_DISP); for (i = 0; i < ARRAY_COUNT(this->unk_1D8[0]); i++) { @@ -834,11 +834,11 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { (s32)(((globalCtx->gameplayFrames % 128) * -9.0f) / this->unk_1F8[j][i]), 0x20, 0x20, 1, 0, 0, 0x20, 0x20)); } - Matrix_StatePush(); - Matrix_InsertXRotation_s(i * 0x2000, MTXMODE_APPLY); - Matrix_InsertTranslation(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(i * 0x2000, MTXMODE_APPLY); + Matrix_Translate(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); if (j != 0) { - Matrix_InsertZRotation_s(-0x8000, MTXMODE_APPLY); + Matrix_RotateZS(-0x8000, MTXMODE_APPLY); } Matrix_Scale(this->unk_1F8[j][i] * this->dyna.actor.scale.x, this->unk_1F8[j][i] * this->dyna.actor.scale.y, @@ -849,7 +849,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(gfx++, 255, 255, 255, this->unk_1D8[j][i]); gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); - Matrix_StatePop(); + Matrix_Pop(); } } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index cd3b8a9d6..fcec4ebb3 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -314,10 +314,10 @@ void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { } } - Matrix_StatePush(); - Matrix_RotateY(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1A8, &sp34); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(this->unk_1A8, &sp34); + Matrix_Pop(); player->actor.world.pos.x += sp34.x; player->actor.world.pos.z += sp34.z; diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 7cb4aab5e..6985878fe 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -118,10 +118,10 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f vec; this->actionFunc(this, globalCtx); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.world.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.world.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80BD68A4, &vec); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.world.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.world.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80BD68A4, &vec); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &vec, &this->dyna.actor.focus.pos); } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index bf3e44154..20d68e7a4 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -133,7 +133,7 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { s32 i; s32 j; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < 6; i++) { temp = (i + 1) * (80.0f / 3.0f); @@ -146,8 +146,8 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; spCC.z = spD8.z * 0.3f; - Matrix_MultiplyVector3fByState(&spD8, &spF0); - Matrix_MultiplyVector3fByState(&spCC, &spE4); + Matrix_MultVec3f(&spD8, &spF0); + Matrix_MultVec3f(&spCC, &spE4); spF0.x += this->dyna.actor.world.pos.x; spF0.y += this->dyna.actor.world.pos.y; @@ -245,7 +245,7 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spA8.y = 0.0f; spB4.y = 0.3f; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s1 = 0; i < 21; i++, phi_s1 += 0x618) { temp_f20 = Math_SinS(phi_s1); @@ -261,9 +261,9 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB4.x = spA8.x * -0.09f; spB4.z = spA8.z * -0.09f; - Matrix_MultiplyVector3fByState(&sp9C, &spC0); - Matrix_MultiplyVector3fByState(&spA8, &spCC); - Matrix_MultiplyVector3fByState(&spB4, &spD8); + Matrix_MultVec3f(&sp9C, &spC0); + Matrix_MultVec3f(&spA8, &spCC); + Matrix_MultVec3f(&spB4, &spD8); spC0.x += this->dyna.actor.world.pos.x; spC0.y += this->dyna.actor.world.pos.y; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 1ad88f3f8..a7f20b7b4 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -230,7 +230,7 @@ BgHakuginPostUnkStruct1* func_80A9B32C(BgHakuginPostUnkStruct* unkStruct, BgHaku } void func_80A9B384(Vec3f* arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] = arg0->x; matrix->mf[3][1] = arg0->y; @@ -1010,8 +1010,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); for (i = 0; i < D_80A9E028.count; i++) { @@ -1032,8 +1032,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_80A9E028.unk_02A4); i++) { unkStruct2 = &D_80A9E028.unk_02A4[i]; if (unkStruct2->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, - &unkStruct2->unk_20); + Matrix_SetTranslateRotateYXZ(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, + &unkStruct2->unk_20); Matrix_Scale(unkStruct2->unk_00, unkStruct2->unk_00, unkStruct2->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index f69302278..b7ebb4f40 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -111,7 +111,7 @@ s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { sp70.y = this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; sp70.z = this->dyna.actor.world.pos.z; - Matrix_RotateY(phi_a0, MTXMODE_NEW); + Matrix_RotateYS(phi_a0, MTXMODE_NEW); if (sp4C) { phi_f12 = 89.0f; @@ -119,7 +119,7 @@ s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { phi_f12 = 119.0f; } - Matrix_GetStateTranslationAndScaledZ(phi_f12, &sp64); + Matrix_MultVecZ(phi_f12, &sp64); sp64.x += this->dyna.actor.world.pos.x; sp64.y += this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; @@ -137,10 +137,10 @@ void func_80B7ED54(BgIkanaBlock* this) { s32 pad; Vec3f sp18; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(30.0f, &sp18); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(30.0f, &sp18); this->unk_170 = sp18.y - 30.0f; } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index a5176bc64..bc08c9451 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -109,8 +109,8 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { s16 temp; s16 phi_t0; - Matrix_StatePush(); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); temp_fs0 = 0.0f; phi_fs1 = 0.0f; @@ -130,8 +130,8 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { spBC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; spBC.z = (Rand_ZeroOne() * 4.0f) - 2.0f; - Matrix_MultiplyVector3fByState(&spC8, &spE0); - Matrix_MultiplyVector3fByState(&spBC, &spD4); + Matrix_MultVec3f(&spC8, &spE0); + Matrix_MultVec3f(&spBC, &spD4); spE0.x += this->dyna.actor.world.pos.x; spE0.y += this->dyna.actor.world.pos.y; @@ -161,7 +161,7 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); } - Matrix_StatePop(); + Matrix_Pop(); } #else void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx); diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 944ab5828..d395fd6ee 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -140,8 +140,8 @@ CollisionHeader* D_80B82218[] = { &object_ikana_obj_Colheader_006368, &object_ik void func_80B802E0(BgIkanaRotaryroom* this) { s32 pad; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); @@ -164,21 +164,21 @@ void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp50; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Push(); + 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); if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { - Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); + Matrix_Translate(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); } - Matrix_GetStateTranslation(&sp50); + Matrix_MultZero(&sp50); func_80B80358(&sp50); this->unk_204.unk_00 = Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_BLOCK, sp50.x, sp50.y, sp50.z, this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1, ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene), this->dyna.actor.unk20, NULL); - Matrix_StatePop(); + Matrix_Pop(); } void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { @@ -200,12 +200,12 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; - Matrix_StatePush(); + Matrix_Push(); sp60.x = BINANG_ROT180(this->dyna.actor.home.rot.x); sp60.y = this->dyna.actor.home.rot.y; sp60.z = this->dyna.actor.home.rot.z; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp60); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp60); while (actor != NULL) { if (actor->id == ACTOR_DOOR_SHUTTER) { @@ -215,24 +215,24 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { ptr = &D_80B82184[spC8][i]; if ((Math3D_Vec3fDistSq(&spB4, &D_80B82184[spC8][i].unk_04) < SQ(250.0f)) && - ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0U))) { - Matrix_StatePush(); - Matrix_InsertTranslation(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslation(&actor->world.pos); + ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0))) { + Matrix_Push(); + Matrix_Translate(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_MultZero(&actor->world.pos); func_80B80358(&actor->world.pos); - Matrix_CopyCurrentState(&sp68); - func_8018219C(&sp68, &actor->shape.rot, 0); - Matrix_StatePop(); + Matrix_Get(&sp68); + Matrix_MtxFToYXZRot(&sp68, &actor->shape.rot, false); + Matrix_Pop(); } } } actor = actor->next; } - Matrix_StatePop(); + Matrix_Pop(); } BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* globalCtx, Actor* arg2) { @@ -246,21 +246,20 @@ BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* if (1) {} if (arg2->id == ACTOR_DOOR_SHUTTER) { - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { ptr = &D_80B82184[temp_s3][i]; if ((ptr->unk_01 == 0) && - (Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), - Matrix_MultiplyVector3fByState(&ptr->unk_04, &sp68), - (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { + (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), + Matrix_MultVec3f(&ptr->unk_04, &sp68), (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { sp58 = ptr; break; } } - Matrix_StatePop(); + Matrix_Pop(); } return sp58; } @@ -270,24 +269,24 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Actor* actor = this->unk_204.unk_00; s32 i; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertZRotation_s(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_RotateY(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, - -this->dyna.actor.world.pos.z, MTXMODE_APPLY); + Matrix_RotateZS(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); + Matrix_RotateXS(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, -this->dyna.actor.world.pos.z, + MTXMODE_APPLY); if (actor != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_204.unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_204.unk_04); - Matrix_StatePop(); + Matrix_Pop(); } for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { @@ -300,15 +299,15 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if (func_80B80778(this, globalCtx, actor) && (i < 2)) { this->unk_248[i].unk_00 = actor; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_248[i].unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_248[i].unk_04); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -324,15 +323,15 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if ((actor->id == ACTOR_EN_TORCH2) && (actor->update != NULL) && (i < ARRAY_COUNT(this->unk_2D0))) { this->unk_2D0[i].unk_00 = actor; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_2D0[i].unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_2D0[i].unk_04); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -350,15 +349,15 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { this->unk_3E0[i].unk_44 = actor->shape.rot; this->unk_3E0[i].unk_4C = 0.0f; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_3E0[i].unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_3E0[i].unk_04); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -368,18 +367,18 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if (actor->update != NULL) { this->unk_520.unk_40 = actor->shape.rot; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_520.unk_00); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_520.unk_00); - Matrix_StatePop(); + Matrix_Pop(); } - Matrix_StatePop(); + Matrix_Pop(); } void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { @@ -392,83 +391,83 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 i; MtxF sp3C; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Push(); + 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); if (ikanaBlock != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ikanaBlock->dyna.actor.world.pos); + Matrix_Mult(&this->unk_204.unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ikanaBlock->dyna.actor.world.pos); func_80B80358(&ikanaBlock->dyna.actor.world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ikanaBlock->dyna.actor.shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ikanaBlock->dyna.actor.shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { ptr = this->unk_248[i].unk_00; if (ptr != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_248[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr->world.pos); + Matrix_Mult(&this->unk_248[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr->world.pos); func_80B80358(&ptr->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { ptr2 = this->unk_2D0[i].unk_00; if (ptr2 != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr2->world.pos); + Matrix_Mult(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr2->world.pos); func_80B80358(&ptr2->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr2->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr2->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { ptr3 = this->unk_3E0[i].unk_00; if (ptr3 != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr3->world.pos); + Matrix_Mult(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr3->world.pos); func_80B80358(&ptr3->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr3->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr3->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } player = GET_PLAYER(globalCtx); if (player != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_520.unk_00, MTXMODE_APPLY); - Matrix_GetStateTranslation(&player->actor.world.pos); + Matrix_Mult(&this->unk_520.unk_00, MTXMODE_APPLY); + Matrix_MultZero(&player->actor.world.pos); Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); func_80B80358(&player->actor.world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &player->actor.shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &player->actor.shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); player->actor.freezeTimer = 2; } - Matrix_StatePop(); + Matrix_Pop(); } s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { @@ -479,18 +478,18 @@ s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 sp24 = false; if (ikanaBlock != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); - Matrix_GetStateTranslation(&sp34); - Matrix_SetStateRotationAndTranslation(ikanaBlock->dyna.actor.world.pos.x, - ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, - ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); - Matrix_GetStateTranslation(&sp28); + 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); + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_MultZero(&sp34); + Matrix_SetTranslateRotateYXZ(ikanaBlock->dyna.actor.world.pos.x, + ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, + ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); + Matrix_MultZero(&sp28); - Matrix_StatePop(); + Matrix_Pop(); if (Math3D_Vec3fDistSq(&sp34, &sp28) < 3.0f) { if (!Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { @@ -604,14 +603,14 @@ void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } ptr->unk_4C.y += ptr->unk_48; - Matrix_StatePush(); + Matrix_Push(); - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(player->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(player->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(sp44, &sp4C); + Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(player->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(player->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(sp44, &sp4C); - Matrix_StatePop(); + Matrix_Pop(); temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp40, &sp3C, NULL, &sp58); if (ptr->unk_4C.y <= temp_f0) { @@ -666,15 +665,15 @@ void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 pad; s32 pad2; - Matrix_StatePush(); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < ARRAY_COUNT(D_80B821C4); i++) { sp64.x = D_80B821C4[i].x; sp64.y = D_80B821C4[i].y; sp64.z = D_80B821C4[i].z; - Matrix_MultiplyVector3fByState(&sp64, &sp70); + Matrix_MultVec3f(&sp64, &sp70); sp70.x += this->dyna.actor.world.pos.x; sp70.y += this->dyna.actor.world.pos.y; @@ -683,7 +682,7 @@ void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); } - Matrix_StatePop(); + Matrix_Pop(); } s32 func_80B816A4(BgIkanaRotaryroom* this) { 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 7e5c39c2f..37d176f5a 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 @@ -142,11 +142,11 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s Vec3f sp58; s32 pad[2]; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); for (i = 0; i < 2; i++) { - Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); + Matrix_MultVec3f(&eyeSparkleSpawnPositions[mask][i], &sp58); EffectSsKirakira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } @@ -160,8 +160,8 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kin2_obj_Colheader_000908); Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index dc504ecb7..499fb034a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -77,22 +77,22 @@ s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { spA4 = D_80B70750[temp_v1] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70768[temp_v1]; - Matrix_InsertTranslation(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); - Matrix_RotateY(spA2, MTXMODE_APPLY); + Matrix_Translate(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); + Matrix_RotateYS(spA2, MTXMODE_APPLY); sp58.x = 0.0f; sp58.y = 0.0f; sp58.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp58, &sp94); + Matrix_MultVec3f(&sp58, &sp94); sp58.z = spA4; - Matrix_MultiplyVector3fByState(&sp58, &sp88); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_MultiplyVector3fByState(&sp94, &sp7C); - Matrix_MultiplyVector3fByState(&sp88, &sp70); + Matrix_MultVec3f(&sp58, &sp88); + 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); + Matrix_MultVec3f(&sp94, &sp7C); + Matrix_MultVec3f(&sp88, &sp70); return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, &this->dyna.actor, 0.0f); @@ -119,22 +119,22 @@ s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { spA0 = D_80B70758[0] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70770[0]; - Matrix_InsertTranslation(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); - Matrix_RotateY(sp9E, MTXMODE_APPLY); + Matrix_Translate(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); + Matrix_RotateYS(sp9E, MTXMODE_APPLY); sp54.x = 0.0f; sp54.y = 0.0f; sp54.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp54, &sp90); + Matrix_MultVec3f(&sp54, &sp90); sp54.z = spA0; - Matrix_MultiplyVector3fByState(&sp54, &sp84); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_MultiplyVector3fByState(&sp90, &sp78); - Matrix_MultiplyVector3fByState(&sp84, &sp6C); + Matrix_MultVec3f(&sp54, &sp84); + 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); + Matrix_MultVec3f(&sp90, &sp78); + Matrix_MultVec3f(&sp84, &sp6C); return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, &this->dyna.actor, 0.0f); diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index 186376d9b..d30fd2d74 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -391,14 +391,14 @@ void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { innerPetalPosRot = &this->innerPetalPosRot[i]; outerPetalPosRot = &this->outerPetalPosRot[i]; - Matrix_SetStateRotationAndTranslation(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, - &innerPetalPosRot->rot); + Matrix_SetTranslateRotateYXZ(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, + &innerPetalPosRot->rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL); - Matrix_SetStateRotationAndTranslation(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, - &outerPetalPosRot->rot); + Matrix_SetTranslateRotateYXZ(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, + &outerPetalPosRot->rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL); @@ -406,8 +406,8 @@ void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI); if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) { - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(1.5f, 1.5f, 1.5f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index d1847009c..5e3eed13b 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -186,12 +186,12 @@ void func_809CE068(BgSpdweb* this) { s32 i; s32 j; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); for (i = 0; i < this->collider.count; i++) { for (j = 0; j < ARRAY_COUNT(sp64); j++) { - Matrix_MultiplyVector3fByState(this->collider.elements[i].dim.vtx + j, &sp64[j]); + Matrix_MultVec3f(this->collider.elements[i].dim.vtx + j, &sp64[j]); } Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); } @@ -513,7 +513,7 @@ void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_spdweb_DL_000060); } else { - Matrix_InsertTranslation(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 4a9061207..12d59b530 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -912,8 +912,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0152 = 15; if ((s16)(BREG(71) + 140) < this->unk_0146[1]) { if (this->unk_0146[0] == 0) { - Matrix_RotateY(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(1500.0f * D_809DF5B0, &spA4); + Matrix_RotateYS(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); + Matrix_MultVecZ(1500.0f * D_809DF5B0, &spA4); this->unk_0146[0] = 50; this->unk_01B0.x = player->actor.world.pos.x + spA4.x; this->unk_01B0.y = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + (600.0f * D_809DF5B0); @@ -1023,15 +1023,14 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { sp9C = Rand_ZeroFloat(M_PI); for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, - &sp90); + Matrix_RotateYF(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW); + Matrix_MultVecZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, &sp90); spD0.x = this->unk_0170.x + sp90.x; spD0.y = this->unk_0170.y + (1000.0f * D_809DF5B0); spD0.z = this->unk_0170.z + sp90.z; if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { spA0 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp8C, &spD0); - Matrix_GetStateTranslationAndScaledZ(5.0f * D_809DF5B0, &sp70); + Matrix_MultVecZ(5.0f * D_809DF5B0, &sp70); sp70.y = 2.0f * D_809DF5B0; sp64.y = 0.3f * D_809DF5B0; sp64.z = 0.0f; @@ -1376,14 +1375,14 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { } idx = (this->unk_014E + 196) % ARRAY_COUNT(this->unk_01BC); - Matrix_InsertTranslation(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); - Matrix_InsertYRotation_f(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(spAC - this->unk_0B1C[idx].x); + Matrix_Translate(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); + Matrix_RotateYF(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); + Matrix_RotateXFApply(spAC - this->unk_0B1C[idx].x); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(150.0f, &this->unk_147C[0]); + Matrix_Translate(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); + Matrix_MultVecZ(150.0f, &this->unk_147C[0]); this->unk_0188 = this->unk_017C; - Matrix_GetStateTranslationAndScaledZ(300.0f, &this->unk_017C); + Matrix_MultVecZ(300.0f, &this->unk_017C); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_017C); if ((this->unk_0156 & 1) && (this->unk_0158 == 0)) { @@ -1407,14 +1406,13 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA0 = spA8; } - Matrix_InsertTranslation(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(spA4 - this->unk_0B1C[phi_v0].x); - Matrix_InsertZRotation_f(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); + Matrix_Translate(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, MTXMODE_NEW); + Matrix_RotateYF(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); + Matrix_RotateXFApply(spA4 - this->unk_0B1C[phi_v0].x); + Matrix_RotateZF(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-(M_PI / 2)); + Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateXFApply(-(M_PI / 2)); Matrix_ToMtx(mtxIter); gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1436,13 +1434,13 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { phi_f12 = 200.0f; } - Matrix_GetStateTranslationAndScaledX(phi_f12, &this->unk_147C[i + 1]); + Matrix_MultVecX(phi_f12, &this->unk_147C[i + 1]); if (i == 21) { Actor* child = this->actor.child; if (child != NULL) { - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.child->world.pos); + Matrix_MultVecX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); @@ -1543,8 +1541,8 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1562,9 +1560,9 @@ void func_809DD2F8(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 100, 100, 120, 255); flag++; } - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(effect->unk_30, MTXMODE_APPLY); - Matrix_InsertXRotation_s(effect->unk_2E, MTXMODE_APPLY); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(effect->unk_30, MTXMODE_APPLY); + Matrix_RotateXS(effect->unk_2E, MTXMODE_APPLY); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, MTXMODE_APPLY); @@ -1584,8 +1582,8 @@ void func_809DD2F8(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1608,8 +1606,8 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -2021,8 +2019,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1D64, &sp58); + Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(this->unk_1D64, &sp58); this->unk_1D24.x = player->actor.world.pos.x + sp58.x; this->unk_1D24.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; @@ -2033,8 +2031,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D30.z = player->actor.world.pos.z; this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; - Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &this->unk_1D3C); Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); ShrinkWindow_SetLetterboxTarget(27); } @@ -2084,9 +2082,8 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { } this->unk_0150 += 0x4000; sp58 = (Math_SinS(this->unk_0150) * (BREG(19) + 5)) * 0.1f; - Matrix_InsertZRotation_f(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), - MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + Matrix_RotateZF(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), MTXMODE_NEW); + Matrix_MultVecY(1.0f, &this->unk_1D3C); func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); } diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 31e8fb0ae..1959ba26b 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -491,10 +491,10 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { f32 rand; rand = Boss03_RandZeroOne(); - Matrix_InsertYRotation_f((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); + Matrix_RotateYF((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); rand = Boss03_RandZeroOne(); - Matrix_GetStateTranslationAndScaledZ((rand * 800.0f) + 400.0f, &sp70); + Matrix_MultVecZ((rand * 800.0f) + 400.0f, &sp70); rand = Boss03_RandZeroOne(); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, @@ -574,8 +574,8 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); xDiff = this->unk_268.x - this->actor.world.pos.x; yDiff = this->unk_268.y - this->actor.world.pos.y; @@ -589,10 +589,10 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { - Matrix_GetStateTranslationAndScaledZ(-500.0f, &this->unk_268); + Matrix_MultVecZ(-500.0f, &this->unk_268); this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; this->workTimer[WORK_TIMER_UNK2_A] = 60; this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; @@ -677,7 +677,7 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); @@ -706,10 +706,9 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { sp44 = 100.0f; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(sp44, &sp50); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_MultVecZ(sp44, &sp50); xDiff = sp50.x - player->actor.world.pos.x; zDiff = sp50.z - player->actor.world.pos.z; @@ -774,7 +773,7 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); @@ -834,12 +833,12 @@ void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { this->actionFunc = Boss03_ChewPlayer; pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); - Matrix_RotateY(pitchAngle, MTXMODE_NEW); + Matrix_RotateYS(pitchAngle, MTXMODE_NEW); out.x = 0.0f; out.y = 200.0f; out.z = 700.0f; - Matrix_MultiplyVector3fByState(&out, &this->unk_268); + Matrix_MultVec3f(&out, &this->unk_268); this->unk_276 = 0x800; this->unk_242 = 0; @@ -864,8 +863,8 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); xDiff = this->unk_268.x - this->actor.world.pos.x; yDiff = this->unk_268.y - this->actor.world.pos.y; @@ -877,7 +876,7 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { -0.5f, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); switch (this->unk_242) { case 0: @@ -1041,7 +1040,7 @@ void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { this->actor.shape.rot = this->actor.world.rot; Math_ApproachF(&this->actor.speedXZ, 25.0f, 1.0f, 3.0f); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); if (this->actor.speedXZ >= 20.0f) { @@ -1394,12 +1393,11 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { phi_f2 = CLAMP_MAX(phi_f2, 0.12f); sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_InsertYRotation_f(sp5C, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(100.0f, &this->csCamAt); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_RotateYF(sp5C, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultVecZ(100.0f, &this->csCamAt); this->csCamEye = this->actor.world.pos; @@ -1491,8 +1489,8 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { this->csCamTargetAt.z = this->actor.world.pos.z; this->unk_568 += this->unk_56C; - Matrix_InsertYRotation_f(this->unk_568, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp90, &this->csCamTargetEye); + Matrix_RotateYF(this->unk_568, MTXMODE_NEW); + Matrix_MultVec3f(&sp90, &this->csCamTargetEye); this->csCamTargetEye.x += this->actor.world.pos.x; this->csCamTargetEye.y += this->waterHeight; @@ -1517,8 +1515,8 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, 1.0f, 10.0f); this->actor.shape.rot.z += 0x100; - Matrix_RotateY(this->unk_2BE, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(500.0f, &sp84); + Matrix_RotateYS(this->unk_2BE, MTXMODE_NEW); + Matrix_MultVecZ(500.0f, &sp84); Math_ApproachF(&this->actor.world.pos.x, sp84.x, 0.1f, 5.0f); Math_ApproachF(&this->actor.world.pos.z, sp84.z, 0.1f, 5.0f); @@ -1692,10 +1690,10 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(340.0f, &this->csCamEye); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); + Matrix_MultVecZ(340.0f, &this->csCamEye); this->csCamAt.x = this->actor.world.pos.x; this->csCamAt.y = this->actor.world.pos.y; @@ -2065,8 +2063,8 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_290 != 0) { this->unk_294 += 0.1f; this->unk_298 += 0.12f; - this->leftFinYRot = __sinf(this->unk_294) * 1280.0f; - this->rightFinYRot = __sinf(this->unk_298) * 1280.0f; + this->leftFinYRot = sinf(this->unk_294) * 1280.0f; + this->rightFinYRot = sinf(this->unk_298) * 1280.0f; } else { Math_ApproachS(&this->rightFinYRot, 0, 0xA, 0x100); Math_ApproachS(&this->leftFinYRot, 0, 0xA, 0x100); @@ -2132,8 +2130,8 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { yRot = 0.0f; for (j = 0, i = 0; i < 20; j++) { - Matrix_InsertYRotation_f(yRot, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + Matrix_RotateYF(yRot, MTXMODE_NEW); + Matrix_MultVecZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); dropletPos.x += this->unk_284 + randPlusMinusPoint5Scaled(40.0f); dropletPos.y = PLATFORM_HEIGHT; dropletPos.z += this->unk_28C + randPlusMinusPoint5Scaled(40.0f); @@ -2236,12 +2234,12 @@ void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V Player* player = GET_PLAYER(globalCtx); if (limbIndex == GYORG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809E9148, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809E9148, &this->actor.focus.pos); } sphereElementIndex = sGyorgSphElementIndices[limbIndex]; if (sphereElementIndex >= 0) { - Matrix_MultiplyVector3fByState(&D_809E9154[sphereElementIndex], &spherePos); + Matrix_MultVec3f(&D_809E9154[sphereElementIndex], &spherePos); if (sphereElementIndex < 2) { if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { @@ -2258,9 +2256,9 @@ void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V MtxF mf; D_809E91B4.x = this->unk_2C4 + 300.0f; - Matrix_MultiplyVector3fByState(&D_809E91B4, &this->insideJawPos); - Matrix_CopyCurrentState(&mf); - func_8018219C(&mf, &this->unk_2A2, 0); + Matrix_MultVec3f(&D_809E91B4, &this->insideJawPos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &this->unk_2A2, false); } } @@ -2276,8 +2274,8 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertYRotation_f(this->unk_260, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYF(this->unk_260, MTXMODE_APPLY); + Matrix_Translate(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); @@ -2346,11 +2344,11 @@ void Boss03_UpdateEffects(GlobalContext* globalCtx) { eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; for (j = 0; j < 4; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 6.0f, 0); + Matrix_RotateYF((2.0f * (j * M_PI)) / 6.0f, MTXMODE_NEW); sp94.x = 0.0f; sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; - Matrix_MultiplyVector3fByState(&sp94, &velocity); + Matrix_MultVec3f(&sp94, &velocity); Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); } } @@ -2413,9 +2411,9 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { flag = true; } - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2444,18 +2442,17 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); if (eff->type == GYORG_EFFECT_DROPLET) { - Matrix_InsertYRotation_f(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * - (M_PI / 0x8000), - MTXMODE_APPLY); + Matrix_RotateYF(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * (M_PI / 0x8000), + MTXMODE_APPLY); } else { // GYORG_EFFECT_SPLASH - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(eff->unk_34.z, MTXMODE_APPLY); + Matrix_RotateZF(eff->unk_34.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); @@ -2481,10 +2478,10 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, eff->alpha); - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); Matrix_Scale(eff->unk_34.x, 1.0f, eff->unk_34.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(eff->unk_34.z, MTXMODE_APPLY); + Matrix_RotateYF(eff->unk_34.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); @@ -2610,27 +2607,27 @@ void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); // The indices looks a bit random... - Matrix_RotateY(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateYS(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateXS(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateZS(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(sGyorgSeaweedDLs); i++, mtx++) { - Matrix_RotateY(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + Matrix_RotateYS(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); + Matrix_RotateXS(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); + Matrix_RotateZS(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); Matrix_ToMtx(mtx); gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sGyorgSeaweedDLs[i]); - Matrix_GetStateTranslation(&this->seaweedSegmentPositions[i]); - Matrix_InsertTranslation(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->seaweedSegmentPositions[i]); + Matrix_Translate(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index b74d9c66b..659fdbe3f 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -214,8 +214,8 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_6F6 = 82; phi_s0_2 = 0; for (i = 0; i < 82; i++) { - Matrix_RotateY(phi_s0_2, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(phi_f20, &sp90); + Matrix_RotateYS(phi_s0_2, MTXMODE_NEW); + Matrix_MultVecZ(phi_f20, &sp90); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, phi_f24, this->unk_6F0 + sp90.z, 0, 0, 0, i); phi_f20 += 2.5f; @@ -245,7 +245,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_1FE = 15; if ((this->unk_708 != 0) && (this->unk_708 < 10)) { this->actor.world.pos.y = (Math_SinS(this->unk_1F4 * 512) * 10.0f) + (this->actor.floorHeight + 160.0f); - Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); } switch (this->unk_708) { @@ -339,7 +339,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 1: player->actor.shape.rot.y = 0x7FFF; player->actor.world.rot.y = player->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledZ(-100.0f, &this->unk_70C); + Matrix_MultVecZ(-100.0f, &this->unk_70C); this->unk_70C.x += player->actor.world.pos.x; this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; @@ -358,7 +358,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 2: case 3: - Matrix_GetStateTranslationAndScaledZ(500.0f, &this->unk_70C); + Matrix_MultVecZ(500.0f, &this->unk_70C); this->unk_70C.x += this->actor.world.pos.x; this->unk_70C.y += this->actor.world.pos.y - 50.0f; this->unk_70C.z += this->actor.world.pos.z; @@ -591,82 +591,82 @@ void func_809ED50C(Boss04* this) { this->unk_2DE += this->unk_2E2; this->unk_2DC += this->unk_2E0; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6BC); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_6BC); Matrix_Scale(this->actor.scale.x * 13.0f, this->actor.scale.y * 13.0f, this->actor.scale.z * 16.0f, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2DC, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DE, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2DC, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2DE, MTXMODE_APPLY); + Matrix_Push(); for (i = 0; i < ARRAY_COUNT(this->unk_2E4); i++) { - Matrix_RotateStateAroundXAxis(0.3926991f); - Matrix_GetStateTranslationAndScaledZ(100.0f, &this->unk_2E4[i]); + Matrix_RotateXFApply(0.3926991f); + Matrix_MultVecZ(100.0f, &this->unk_2E4[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_3A4); i++) { - Matrix_RotateStateAroundXAxis(0.41887903f); - Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_3A4[i]); + Matrix_RotateXFApply(0.41887903f); + Matrix_MultVecZ(92.0f, &this->unk_3A4[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_458); i++) { - Matrix_RotateStateAroundXAxis(0.41887903f); - Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_458[i]); + Matrix_RotateXFApply(0.41887903f); + Matrix_MultVecZ(92.0f, &this->unk_458[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_50C); i++) { - Matrix_RotateStateAroundXAxis(0.5711987f); - Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_50C[i]); + Matrix_RotateXFApply(0.5711987f); + Matrix_MultVecZ(71.0f, &this->unk_50C[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_590); i++) { - Matrix_RotateStateAroundXAxis(0.5711987f); - Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_590[i]); + Matrix_RotateXFApply(0.5711987f); + Matrix_MultVecZ(71.0f, &this->unk_590[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_614); i++) { - Matrix_RotateStateAroundXAxis(1.0471976f); - Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_614[i]); + Matrix_RotateXFApply(1.0471976f); + Matrix_MultVecZ(38.0f, &this->unk_614[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_65C); i++) { - Matrix_RotateStateAroundXAxis(1.0471976f); - Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_65C[i]); + Matrix_RotateXFApply(1.0471976f); + Matrix_MultVecZ(38.0f, &this->unk_65C[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6A4); - Matrix_StatePop(); - Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6B0); + Matrix_MultZero(&this->unk_6A4); + Matrix_Pop(); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_6B0); } void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { @@ -805,10 +805,10 @@ void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V Vec3f sp18; if (limbIndex == 1) { - Matrix_GetStateTranslationAndScaledY(-500.0f, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&D_809EE228, &sp18); + Matrix_MultVecY(-500.0f, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809EE228, &sp18); func_809EC040(0, &this->collider1, &sp18); - Matrix_MultiplyVector3fByState(&D_809EE234, &sp18); + Matrix_MultVec3f(&D_809EE234, &sp18); func_809EC040(0, &this->collider2, &sp18); } } @@ -824,7 +824,7 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertTranslation(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_6F8, this->unk_6FC, this->unk_700, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); @@ -837,9 +837,9 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); - Matrix_InsertTranslation(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_6F8 * 1.8f, 0.0f, this->unk_700 * 2.8f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index f73423d5e..07016aff9 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -467,15 +467,14 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { phi_f24 = 0.0f; for (i = 0; i < 1024; i++) { - temp_f22 = - (((__sinf(phi_f24) * this->unk_1D4) + 1.0f) * ((__sinf(phi_f26) * this->unk_1D0) + this->unk_1D0)) + - this->unk_1CC; + temp_f22 = (((sinf(phi_f24) * this->unk_1D4) + 1.0f) * ((sinf(phi_f26) * this->unk_1D0) + this->unk_1D0)) + + this->unk_1CC; phi_f26 += (M_PI / 64); phi_f24 += 0.030679617f; - Matrix_InsertZRotation_f(i * (M_PI / 512), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledY(temp_f22, &sp7C); + Matrix_RotateZF(i * (M_PI / 512), MTXMODE_NEW); + Matrix_MultVecY(temp_f22, &sp7C); sp7C.x += 32.0f + this->unk_1BC; sp7C.y += 32.0f + this->unk_1C0; @@ -573,10 +572,10 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { } AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_knight_Matanimheader_019360)); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y - 234.0f, - this->actor.world.pos.z + 30.0f, 0); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y - 234.0f, this->actor.world.pos.z + 30.0f, + MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 155, 255, maxColor, (u8)((140.0f * sp68) + 115.0f), spD3); @@ -590,18 +589,18 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_144 & 1) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&this->unk_200)); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->unk_1A8, - this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->unk_1A8, this->actor.world.pos.z, + MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_knight_DL_0193B0); if (this->unk_1D8 > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 84.0f, - this->actor.world.pos.z - 2.0f, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 84.0f, this->actor.world.pos.z - 2.0f, + MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); func_809F2120(1, 0x71A5, 0x263A); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); @@ -609,18 +608,18 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_809F4370); i++) { if ((fabsf(D_809F4370[i].x - 32.0f) < 30.0f) && (fabsf(D_809F4370[i].y - 32.0f) < 30.0f)) { - Matrix_StatePush(); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, ((globalCtx->gameplayFrames + (i * 10)) * -20) % 512, 0x20, 0x80)); - Matrix_InsertTranslation((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, - MTXMODE_APPLY); - Matrix_InsertZRotation_f(i * (M_PI / 64), MTXMODE_APPLY); + Matrix_Translate((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, + MTXMODE_APPLY); + Matrix_RotateZF(i * (M_PI / 64), MTXMODE_APPLY); if (func_809F2140() < 0.5f) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } Matrix_Scale(-0.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); @@ -629,7 +628,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - Matrix_StatePop(); + Matrix_Pop(); } } } else { @@ -640,16 +639,15 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_1DC > 0.0f) { u8 temp_s2 = (this->unk_1E0 - 50.0f) + (50.0f * sp68); - Matrix_InsertTranslation(this->actor.world.pos.x + this->unk_1B0, - this->actor.world.pos.y + 84.0f + this->unk_1B4, - (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x + this->unk_1B0, this->actor.world.pos.y + 84.0f + this->unk_1B4, + (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)((140.0f * sp68) + 115.0f), temp_s2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 205, (u8)((100.0f * sp68) + 65.0f), 128); Matrix_Scale(this->unk_1DC, this->unk_1DC, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 108f128ae..48ef3cd3d 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -297,15 +297,15 @@ void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertZRotation_s(sp46, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(sp46, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); - Matrix_StatePop(); - Matrix_InsertZRotation_s(sp46 * -1, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateZS(sp46 * -1, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index b51fc64ec..2c676abbf 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -153,12 +153,9 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += - __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += - __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += - __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; + this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; + this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; switch ((i >> 1) & 3) { case 0: @@ -205,7 +202,7 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa this->particles[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); this->particles[i].LostWoodsSkyFishSpeedXZClock += this->particles[i].LostWoodsSkyFishSpeedXZ; - this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y); + this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y); this->particles[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation this->particles[i].speedClock.y += this->particles[i].LostWoodsSkyFishSpeedY; this->particles[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation @@ -377,9 +374,9 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx Math_SmoothStepToF(&this->particles[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; + this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; + this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; switch ((i >> 1) & 3) { case 0: @@ -536,7 +533,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { // checking if particle is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { - Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); scaleAlpha = this->particles[i].alpha / 50.0f; if (scaleAlpha > 1.0f) { scaleAlpha = 1.0f; @@ -586,8 +583,8 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -625,7 +622,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { // checking if particle is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { - Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); alphaScale = this->particles[i].alpha / 50.0f; if (alphaScale > 1.0f) { alphaScale = 1.0f; @@ -657,9 +654,9 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, &gLightOrb1DL); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index aa25fddfd..72f101d18 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -489,7 +489,7 @@ void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { if (matrix != NULL) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); } } @@ -518,14 +518,14 @@ void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); if (this->unk_3E4 & 4) { - Matrix_InsertZRotation_s(-this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_Scale(1.0f, 5.0f, 1.0f, MTXMODE_APPLY); } if (this->unk_3E4 & 1) { - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); } if (this->unk_3E4 & 8) { @@ -555,7 +555,7 @@ void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); if (this->unk_3E4 & 8) { func_80C17468(globalCtx); diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 18548675d..19f7844ac 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -280,21 +280,21 @@ void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80C1D2C8, &D_80C1D2D4); + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80C1D2C8, &D_80C1D2D4); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80C1D2DC, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80C1D2DC, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -320,23 +320,23 @@ void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, &this->unk_1AA, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index c72634216..ce9f844d0 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -901,8 +901,8 @@ s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi if (limbIndex == 6) { sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); - Matrix_MultiplyVector3fByState(&D_80AA7808, &sp1C); - Matrix_InsertTranslation(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_MultVec3f(&D_80AA7808, &sp1C); + Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); } return false; diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index b4537b1af..375edda4a 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -411,7 +411,7 @@ void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); - Matrix_InsertTranslation(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); } AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 956f7317c..94935db3c 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -671,7 +671,7 @@ void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { } if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { - Matrix_InsertTranslation(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); } } @@ -716,8 +716,8 @@ void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_44); } @@ -729,8 +729,8 @@ void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_45); } @@ -742,8 +742,8 @@ void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_6B); } @@ -756,8 +756,8 @@ void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { void func_80AAE030(GlobalContext* globalCtx, DmChar05* this) { if (this->unk_18E != 0) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_03); } @@ -776,9 +776,8 @@ void func_80AAE114(GlobalContext* globalCtx, DmChar05* this) { sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, sp24[sp34]); } diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 969b7a80b..a6970e050 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -280,21 +280,21 @@ void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80C25218, &D_80C25224); + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80C25218, &D_80C25224); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80C2522C, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -320,23 +320,23 @@ void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, &this->unk_1AA, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index b778f3fcc..782ef8679 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1618,7 +1618,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V DmStk* this = THIS; if (limbIndex == 17) { - Matrix_GetStateTranslation(&this->unk_304); + Matrix_MultZero(&this->unk_304); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1658,7 +1658,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (Cutscene_CheckActorAction(globalCtx, 513) && (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && (this->unk_337 >= 0)) { - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); @@ -1670,7 +1670,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); - Matrix_StatePop(); + Matrix_Pop(); } break; } @@ -1706,9 +1706,9 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V break; case 5: - Matrix_InsertTranslation(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); - Matrix_RotateY(0x6142, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-0x1988, MTXMODE_APPLY); + Matrix_Translate(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); + Matrix_RotateYS(0x6142, MTXMODE_APPLY); + Matrix_RotateXS(-0x1988, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 999eec485..fe52a8288 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -673,9 +673,9 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if (this->unk_164 == 7) { - Matrix_InsertTranslation(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); } if (sp44->unk_04 != 0) { @@ -687,10 +687,10 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&globalCtx->view.eye, &this->actor.world.pos); if (ABS_ALT(yaw) < 0x4000) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } } else if (this->actor.room == transitionEntry->sides[0].room) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } } else if (this->doorType == 5) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->unk_15E])); @@ -700,7 +700,7 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, sp44->unk_00); if ((this->unk_168 != 0.0f) && (sp44->unk_04 != 0)) { - Matrix_InsertTranslation(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); + Matrix_Translate(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index fa94a5981..6217361f2 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -972,8 +972,8 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B4); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255.0f * sp84, 255, 255); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); phi_f12 = 1.0f; if (this->unk_203 != 0) { phi_f12 = this->unk_204 * phi_f12; @@ -981,19 +981,19 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { Matrix_Scale(phi_f12, phi_f12, phi_f12, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx)); - Matrix_StatePush(); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100, 1, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100)); - Matrix_InsertTranslation(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C6 * sp90) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C6 * sp90) / 100.0f) + 1.0f, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_1B0 > 0.0f) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B0); @@ -1004,7 +1004,7 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100, 1, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100)); - Matrix_InsertTranslation(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, MTXMODE_APPLY); @@ -1031,8 +1031,8 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { s32 sp60 = 0; if (this->unk_1D4 != 0) { - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, + this->dyna.actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(4.0f, this->unk_1AC, 4.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0044D8)); Gfx_DrawDListXlu(globalCtx, object_warp1_DL_003230); @@ -1049,9 +1049,9 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, this->unk_1A8, 1.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0057D8)); @@ -1069,9 +1069,9 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); func_8012C2DC(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 856b459a3..211b32412 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -283,14 +283,14 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->distanceTraveled); i++) { if (*distanceTraveled < 1.0f) { aux = 1.0f - SQ(*distanceTraveled); - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(sp92, MTXMODE_APPLY); - Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), - initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(sp92, MTXMODE_APPLY); + Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), + initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -339,15 +339,15 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (*distanceTraveled * 255.0f)); aux = 1.0f - SQ(*distanceTraveled); - Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); - Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, - (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, + (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 405c2ffb4..dd719d6fb 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -568,7 +568,7 @@ void EnAh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnAh* this = THIS; if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&D_80BD3F00, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BD3F00, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -594,23 +594,23 @@ void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, this->unk_200, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == 2) { SubS_UpdateLimb(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), &this->unk_1E8[1], &this->unk_200[1], stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_200[1].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[1].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[1].z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_200[1].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[1].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[1].z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 70e98fc15..22b2a0228 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1699,7 +1699,7 @@ void EnAkindonuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Act } if (limbIndex == 24) { - Matrix_RotateY(this->unk_352, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_352, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 063c50b61..a14b2e106 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -839,31 +839,31 @@ void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec switch (limbIndex) { case 3: - Matrix_CopyCurrentState(&this->unk_190[0]); + Matrix_Get(&this->unk_190[0]); break; case 11: - Matrix_CopyCurrentState(&this->unk_190[1]); + Matrix_Get(&this->unk_190[1]); break; case 12: - Matrix_CopyCurrentState(&this->unk_190[2]); + Matrix_Get(&this->unk_190[2]); break; case 13: - Matrix_CopyCurrentState(&this->unk_190[3]); + Matrix_Get(&this->unk_190[3]); break; case 14: - Matrix_CopyCurrentState(&this->unk_190[4]); + Matrix_Get(&this->unk_190[4]); break; case 15: - Matrix_CopyCurrentState(&this->unk_190[5]); + Matrix_Get(&this->unk_190[5]); break; case 16: - Matrix_MultiplyVector3fByState(&D_80BE0070, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BE0070, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); break; } @@ -889,13 +889,13 @@ void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this if (limbIndex == 16) { SubS_UpdateLimb(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, &this->unk_378, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_378.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_378.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_378.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_378.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_378.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_378.z, MTXMODE_APPLY); + Matrix_Push(); } } @@ -907,13 +907,13 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAl_OverrideLimbDraw, EnAl_PostLimbDraw, EnAl_TransformLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { - Matrix_SetCurrentState(&this->unk_190[i]); + Matrix_Put(&this->unk_190[i]); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 20092f5b0..00c07327e 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -551,7 +551,7 @@ void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec phi_s3 = 0; } for (i = 0; i < phi_s3; i++, phi_s2++, phi_s1++) { - Matrix_MultiplyVector3fByState(phi_s1, phi_s2); + Matrix_MultVec3f(phi_s1, phi_s2); } } diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 43e9de4f0..098d91be4 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -331,7 +331,7 @@ void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve static Vec3f D_809686A4 = { 800.0f, 500.0f, 0.0f }; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809686A4, &thisx->focus.pos); + Matrix_MultVec3f(&D_809686A4, &thisx->focus.pos); } } @@ -342,7 +342,7 @@ void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); func_8012C5B0(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index b949b4be3..1d74c45ae 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -999,15 +999,15 @@ s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.x * -1, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.x * -1, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { - Matrix_InsertXRotation_s(this->torsoRot.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->torsoRot.x * -1, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->torsoRot.x * -1, MTXMODE_APPLY); } if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || @@ -1023,7 +1023,7 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnAob01* this = THIS; if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809C3968, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index e60419846..0a8eeffce 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -579,15 +579,15 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar Vec3f sp34; s32 sp30; - Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); + Matrix_MultVec3f(&arg2->unk_48, &this->unk_234); if (func_8088ACE0 == this->actionFunc) { if (!this->unk_244.active) { sp4C = arg2->unk_00; } else { sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; } - Matrix_MultiplyVector3fByState(&sp4C[0], &sp40); - Matrix_MultiplyVector3fByState(&sp4C[1], &sp34); + Matrix_MultVec3f(&sp4C[0], &sp40); + Matrix_MultVec3f(&sp4C[1], &sp34); if (this->actor.params < ENARROW_8) { sp30 = this->actor.params < ENARROW_6; if (this->unk_264 == 0) { @@ -666,7 +666,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->bubble.unk_144 * sp9C, this->bubble.unk_144 * sp9C, this->bubble.unk_144 * spA0, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); if (this->actor.speedXZ == 0.0f) { func_800B8118(&this->actor, globalCtx, MTXMODE_NEW); @@ -677,7 +677,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { COMBINED, 0, ENVIRONMENT, 0, COMBINED, 0, ENVIRONMENT, 0); gDPSetEnvColor(POLY_XLU_DISP++, 230, 225, 150, spA4); - Matrix_NormalizeXYZ(&gIdentityMtxF); + Matrix_ReplaceRotation(&gIdentityMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -718,8 +718,8 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { sp5C = 150.0f; } - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); if (this->actor.speedXZ == 0.0f) { phi_v0 = 0; @@ -727,21 +727,21 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { phi_v0 = (globalCtx->gameplayFrames % 256) * 4000; } - Matrix_InsertZRotation_s(phi_v0, MTXMODE_APPLY); + Matrix_RotateZS(phi_v0, MTXMODE_APPLY); Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); - Matrix_StatePop(); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (this->actor.velocity.y != 0.0f) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 9295b03a5..e6dd15a32 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -700,19 +700,19 @@ s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList EnBaba* this = THIS; if (limbIndex == 6) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 5) { - Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { @@ -736,7 +736,7 @@ void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y; this->actor.focus.pos.z = this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 8e70d5d6b..88fc11072 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -498,10 +498,10 @@ void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isVisible) { - Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 311c2f633..f48976cd6 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -640,17 +640,17 @@ void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); - Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } } } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } if (limbIndex == BUBBLE_LIMB_CRANIUM) { @@ -660,11 +660,11 @@ void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; - Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->limbDList); @@ -689,9 +689,9 @@ void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBb_PostLimbDraw, &this->actor); if (this->flameScaleX > 0.0f) { - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY( + Matrix_RotateYS( ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 61d4df146..f2c70dac8 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -255,7 +255,7 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis bodyPart = gEnHyBodyParts[limbIndex]; if (bodyPart >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + Matrix_MultVec3f(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { @@ -266,20 +266,20 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == BBA_LIMB_BAG) { - Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if ((limbIndex == BBA_LIMB_BAG) || (limbIndex == BBA_LIMB_TORSO) || (limbIndex == BBA_LIMB_LEFT_FOREARM)) { @@ -303,7 +303,7 @@ void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); } } @@ -325,7 +325,7 @@ void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, this->enHy.skelAnime.dListCount, EnBba01_OverrideLimbDraw, EnBba01_PostLimbDraw, EnBba01_TransformLimbDraw, &this->enHy.actor); - Matrix_InsertXRotation_s(0, MTXMODE_NEW); + Matrix_RotateXS(0, MTXMODE_NEW); for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 3ccd807d8..9e55e8508 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -674,17 +674,17 @@ void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); - Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } } } else if (this->bodyPartDrawStatus > BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } if (limbIndex == BUBBLE_LIMB_CRANIUM) { @@ -694,11 +694,11 @@ void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; - Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->limbDList); @@ -727,12 +727,12 @@ void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->flameOpacity > 0) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY( + Matrix_RotateYS( ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); opacity = this->flameOpacity; pos = &this->flamePos[0]; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 8431d6706..e25d1e02a 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -636,12 +636,12 @@ void EnBigokuta_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (limbPosIndex != -1) { if (limbPosIndex < 6) { - Matrix_GetStateTranslationAndScaledX(800.0f, &this->limbPos[limbPosIndex]); + Matrix_MultVecX(800.0f, &this->limbPos[limbPosIndex]); } else if (limbPosIndex < 8) { - Matrix_GetStateTranslation(&this->limbPos[limbPosIndex]); + Matrix_MultZero(&this->limbPos[limbPosIndex]); } else { for (i = 0; i < ARRAY_COUNT(D_80AC45D0); i++) { - Matrix_MultiplyVector3fByState(&D_80AC45D0[i], &this->limbPos[limbPosIndex + i]); + Matrix_MultVec3f(&D_80AC45D0[i], &this->limbPos[limbPosIndex + i]); } } } diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 09ed84312..acf465f83 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -734,9 +734,9 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.draw = EnBigpo_DrawLantern; this->actor.shape.shadowDraw = NULL; - this->actor.world.pos.x = this->drawMtxF.wx; - this->actor.world.pos.y = this->drawMtxF.wy; - this->actor.world.pos.z = this->drawMtxF.wz; + this->actor.world.pos.x = this->drawMtxF.xw; + this->actor.world.pos.y = this->drawMtxF.yw; + this->actor.world.pos.z = this->drawMtxF.zw; Actor_SetScale(&this->actor, 0.014f); this->actor.gravity = -1.0f; @@ -1249,31 +1249,31 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 7) { // we scale the vec3f... then do nothing with it? - Matrix_GetStateTranslationAndScaledY(1400.0f, &unusedVec); + Matrix_MultVecY(1400.0f, &unusedVec); if ((this->actionFunc == EnBigpo_BurnAwayDeath) && (this->idleTimer > 18)) { if (this->actor.scale.x != 0.0f) { Matrix_Scale(0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 1); } } - Matrix_CopyCurrentState(&this->drawMtxF); + Matrix_Get(&this->drawMtxF); } limbByte = D_80B65078[limbIndex]; if (limbByte != -1) { if (limbByte < 3) { - Matrix_GetStateTranslation(&this->limbPos[limbByte]); + Matrix_MultZero(&this->limbPos[limbByte]); } else if (limbByte == 3) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); + Matrix_MultVecX(3000.0f, &this->limbPos[limbByte]); } else if (limbByte == 4) { - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); + Matrix_MultVecY(-2000.0f, &this->limbPos[limbByte]); } else { v2ptr = &this->limbPos[limbByte + 1]; v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); + Matrix_MultVecX(-4000.0f, &this->limbPos[limbByte]); for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + Matrix_MultVec3f(v1ptr, v2ptr); v2ptr++; v1ptr++; } @@ -1315,7 +1315,7 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); - Matrix_SetCurrentState(&this->drawMtxF); + Matrix_Put(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { EnBigpo_DrawCircleFlames(&this->actor, globalCtx); @@ -1344,7 +1344,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a * 2); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1386,7 +1386,7 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); + Matrix_MultVecY(1400.0f, &vec2); Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); @@ -1415,11 +1415,11 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { MtxF* mtfxPtr; s32 i; - mtfxPtr = Matrix_GetCurrentState(); + mtfxPtr = Matrix_GetCurrent(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; @@ -1439,9 +1439,9 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); - mtfxPtr->wx = firePtr->pos.x; - mtfxPtr->wy = firePtr->pos.y; - mtfxPtr->wz = firePtr->pos.z; + mtfxPtr->xw = firePtr->pos.x; + mtfxPtr->yw = firePtr->pos.y; + mtfxPtr->zw = firePtr->pos.z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 5428e701a..1a507b5b6 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2873,35 +2873,35 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDList, f32 scaleX, f32 scalez, f32 scaleY, s16 rotation, f32 alpha) { f32 yDistMinY; - f32 xz; - MtxF* sysMatrix = Matrix_GetCurrentState(); + f32 zx; + MtxF* sysMatrix = Matrix_GetCurrent(); yDistMinY = pos->y - scaleY - GBT_ROOM_5_MIN_Y; yDistMinY = CLAMP((yDistMinY), 0.0f, (GBT_ROOM_5_CENTER_Y - GBT_ROOM_5_MIN_Y) / 2); - xz = 1.0f - (yDistMinY * (1.0f / 1550.0f)); + zx = 1.0f - (yDistMinY * (1.0f / 1550.0f)); OPEN_DISPS(globalCtx->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); - sysMatrix->xx = xz; + sysMatrix->xx = zx; sysMatrix->yy = 1.0f; - sysMatrix->zz = xz; - sysMatrix->xz = sysMatrix->xy = 0.0f; - sysMatrix->yz = sysMatrix->yx = 0.0f; - sysMatrix->zy = sysMatrix->zx = 0.0f; - sysMatrix->wx = pos->x; - sysMatrix->wy = GBT_ROOM_5_MIN_Y; - sysMatrix->wz = pos->z; - sysMatrix->xw = sysMatrix->yw = sysMatrix->zw = 0.0f; + sysMatrix->zz = zx; + sysMatrix->zx = sysMatrix->yx = 0.0f; + sysMatrix->zy = sysMatrix->xy = 0.0f; + sysMatrix->yz = sysMatrix->xz = 0.0f; + sysMatrix->xw = pos->x; + sysMatrix->yw = GBT_ROOM_5_MIN_Y; + sysMatrix->zw = pos->z; + sysMatrix->wx = sysMatrix->wy = sysMatrix->wz = 0.0f; sysMatrix->ww = 1.0f; - Matrix_RotateY(rotation, MTXMODE_APPLY); + Matrix_RotateYS(rotation, MTXMODE_APPLY); Matrix_Scale(scaleX, 1.0f, scalez, MTXMODE_APPLY); if (shadowDList != gBigslimeShadowDL) { gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); } - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * xz)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * zx)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, shadowDList); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -2940,14 +2940,14 @@ void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { Lights_Draw(lights, globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); func_800B8118(&minislime->actor, globalCtx, 0); - Matrix_SetStateRotationAndTranslation(minislime->actor.world.pos.x, minislime->actor.world.pos.y, - minislime->actor.world.pos.z, &minislime->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(minislime->actor.world.pos.x, minislime->actor.world.pos.y, + minislime->actor.world.pos.z, &minislime->actor.shape.rot); Matrix_Scale(minislime->actor.scale.x, minislime->actor.scale.y, minislime->actor.scale.z, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->actor.shape.shadowAlpha); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gMinislimeNormalDL); if (minislime->frozenAlpha > 0) { - Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.1f, minislime->frozenScale, 0.1f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, this->minislimeFrozenTexAnim); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->frozenAlpha); @@ -2999,18 +2999,18 @@ void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { // Draw bubbles inside Bigslime if (this->actor.scale.x > 0.0f) { - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(0.0050000003f, 0.0050000003f, 0.0050000003f, MTXMODE_APPLY); - billboardMtxF = Matrix_GetCurrentState(); + billboardMtxF = Matrix_GetCurrent(); for (i = 0; i < 28; i++) { bubblesInfoPtr = &bubblesInfo[i]; dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][bubblesInfoPtr->v]; - billboardMtxF->wx = + billboardMtxF->xw = dynamicVtx->n.ob[0] * this->actor.scale.x * bubblesInfoPtr->scaleVtx + this->actor.world.pos.x; - billboardMtxF->wy = + billboardMtxF->yw = dynamicVtx->n.ob[1] * this->actor.scale.y * bubblesInfoPtr->scaleVtx + this->actor.world.pos.y; - billboardMtxF->wz = + billboardMtxF->zw = dynamicVtx->n.ob[2] * this->actor.scale.z * bubblesInfoPtr->scaleVtx + this->actor.world.pos.z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3048,16 +3048,16 @@ void EnBigslime_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Vec3f rightFootOffset; if (limbIndex == GEKKO_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); this->actor.focus.rot.y = this->gekkoRot.y; } if (limbPosIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[limbPosIndex[limbIndex]]); + Matrix_MultZero(&this->limbPos[limbPosIndex[limbIndex]]); } if (limbIndex == GEKKO_LIMB_R_ANKLE) { - Matrix_MultiplyVector3fByState(&rightFootOffsetRef, &rightFootOffset); + Matrix_MultVec3f(&rightFootOffsetRef, &rightFootOffset); this->gekkoCollider.dim.pos.y = rightFootOffset.y; } } @@ -3087,7 +3087,7 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); Math_Vec3f_Sum(&this->actor.world.pos, &this->gekkoPosOffset, &gekkoPos); - Matrix_SetStateRotationAndTranslation(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); + Matrix_SetTranslateRotateYXZ(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); Matrix_Scale(this->gekkoScale, this->gekkoScale, this->gekkoScale, MTXMODE_APPLY); SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &gekkoPos, &this->gekkoProjectedPos); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3131,7 +3131,7 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, (u8)(globalCtx->gameplayFrames * 8), 32, 64, 1, (-globalCtx->gameplayFrames * 2) % 64, 0, 16, 16)); - Matrix_InsertTranslation(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); + Matrix_Translate(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); Matrix_Scale(this->shockwaveScale, this->shockwaveScale, this->shockwaveScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeShockwaveDL); @@ -3144,8 +3144,8 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; if (iceShardEffect->isActive > false) { - Matrix_SetStateRotationAndTranslation(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + Matrix_SetTranslateRotateYXZ(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, + &iceShardEffect->rotation); Matrix_Scale(iceShardEffect->scale, iceShardEffect->scale, iceShardEffect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index f59a934bc..579ec5d50 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -97,7 +97,7 @@ typedef struct EnBigslime { /* 0x02C4 */ s16 numGekkoPosGrabPlayer; // The Gekko will melee-attack link at 6 positions while engulfed in bigslime /* 0x02C6 */ s16 subCamId; /* 0x02C8 */ s16 subCamYawGrabPlayer; - /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateY + /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateYS /* 0x02CC */ s16 itemDropTimer; // items only drop when zero, Set to 40 then decrements, prevents itemDrop spam /* 0x02CE */ Vec3s gekkoRot; /* 0x02D4 */ Vec3f gekkoPosOffset; // Used when Bigslime grabs link diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 43c09df0c..c60971034 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -428,7 +428,7 @@ void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, sp20.x += temp_f4 * 0.1f; sp20.y += temp_f4 * 0.1f; sp20.z += temp_f4 * 0.1f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 70805438f..48550b656 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -383,8 +383,8 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { spCC = Rand_ZeroFloat(M_PI); for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + spCC, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ((10 - this->timer) * 300.0f * 0.1f, &spC0); + Matrix_RotateYF(((2.0f * (i * M_PI)) / 15.0f) + spCC, MTXMODE_NEW); + Matrix_MultVecZ((10 - this->timer) * 300.0f * 0.1f, &spC0); spB4.x = this->actor.world.pos.x + spC0.x; spB4.y = this->actor.world.pos.y + 500.0f; spB4.z = this->actor.world.pos.z + spC0.z; @@ -400,7 +400,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { sp84 = D_80872E94; sp80 = D_80872E94; } - Matrix_GetStateTranslationAndScaledZ(5.0f, &sp94); + Matrix_MultVecZ(5.0f, &sp94); sp88.x = sp88.z = 0.0f; sp94.y = 2.0f; sp88.y = 0.2f; @@ -606,14 +606,14 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!this->isPowderKeg) { func_800B8050(&this->actor, globalCtx, 0); - Matrix_MultiplyVector3fByState(&D_80872EE0, &this->actor.home.pos); + Matrix_MultVec3f(&D_80872EE0, &this->actor.home.pos); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_015FA0); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -629,15 +629,15 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 sp4A = this->actor.world.rot.y - this->actor.shape.rot.y; f32 sp44 = (1000.0f / Math_CosS(ABS_ALT((s16)(this->unk_1FA % 10922)) - 0x1555)) + -1000.0f; - Matrix_RotateY(sp4A, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, sp44, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1FA, MTXMODE_APPLY); - Matrix_RotateY(-sp4A, MTXMODE_APPLY); + Matrix_RotateYS(sp4A, MTXMODE_APPLY); + Matrix_Translate(0.0f, sp44, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1FA, MTXMODE_APPLY); + Matrix_RotateYS(-sp4A, MTXMODE_APPLY); } - Matrix_MultiplyVector3fByState(&D_80872EEC, &this->actor.home.pos); - Matrix_MultiplyVector3fByState(&D_80872EF8, &sp58); - Matrix_MultiplyVector3fByState(&D_80872F04, &sp4C); + Matrix_MultVec3f(&D_80872EEC, &this->actor.home.pos); + Matrix_MultVec3f(&D_80872EF8, &sp58); + Matrix_MultVec3f(&D_80872F04, &sp4C); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -776,8 +776,8 @@ void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -787,8 +787,8 @@ void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { ptr2 = &D_80874650[1]; for (i = 1; i < temp_s5; i++, ptr2++) { - Matrix_InsertTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); + Matrix_Translate(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index fc63795de..541fc071c 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -136,8 +136,8 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon } Math_Vec3f_Scale(&vec, 1.0f / magnitude); - Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->axisLeft, &vec); + Matrix_RotateAxisF(angle, &vec, MTXMODE_NEW); + Matrix_MultVec3f(&this->axisLeft, &vec); Math_Vec3f_Copy(&this->axisLeft, &vec); Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); @@ -156,18 +156,18 @@ void EnBomChu_UpdateRotation(EnBomChu* this) { MtxF mf; mf.xx = this->axisLeft.x; - mf.xy = this->axisLeft.y; - mf.xz = this->axisLeft.z; + mf.yx = this->axisLeft.y; + mf.zx = this->axisLeft.z; - mf.yx = this->axisUp.x; + mf.xy = this->axisUp.x; mf.yy = this->axisUp.y; - mf.yz = this->axisUp.z; + mf.zy = this->axisUp.z; - mf.zx = this->axisForwards.x; - mf.zy = this->axisForwards.y; + mf.xz = this->axisForwards.x; + mf.yz = this->axisForwards.y; mf.zz = this->axisForwards.z; - func_8018219C(&mf, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&mf, &this->actor.world.rot, false); this->actor.world.rot.x = -this->actor.world.rot.x; } @@ -205,13 +205,13 @@ s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* pos void EnBomChu_SetupMove(EnBomChu* this) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->axisUp); - Matrix_GetStateTranslationAndScaledZ(1.0f, &this->axisForwards); - Matrix_GetStateTranslationAndScaledX(1.0f, &this->axisLeft); + Matrix_MultVecY(1.0f, &this->axisUp); + Matrix_MultVecZ(1.0f, &this->axisForwards); + Matrix_MultVecX(1.0f, &this->axisLeft); this->actor.world.rot.x = -this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -564,7 +564,7 @@ void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { colorIntensity = blinkTime / (f32)blinkHalfPeriod; gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, (s32)(colorIntensity * -35.0f) + 35, 255); - Matrix_InsertTranslation(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index fef26002b..d4633c02d 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -450,7 +450,7 @@ Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); Gfx* gfx = head; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); @@ -473,7 +473,7 @@ void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); - Matrix_InsertTranslation(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_204, this->unk_204, this->unk_204, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 15347d0ea..4c3f6b241 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -325,19 +325,18 @@ void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - - Matrix_InsertZRotation_s((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp58->unk_04, &sp4C); - Matrix_MultiplyVector3fByState(&sp58->unk_10, &sp40); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_RotateZS((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultVec3f(&sp58->unk_04, &sp4C); + Matrix_MultVec3f(&sp58->unk_10, &sp40); if (func_80126440(globalCtx, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); } func_8012C28C(globalCtx->state.gfxCtx); - Matrix_RotateY(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sp58->unk_00); diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 937759ff6..ec0a0a6c2 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -53,10 +53,10 @@ void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr); diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index ea70a1480..0042442ff 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -144,12 +144,12 @@ void func_8091C178(EnButte* this, GlobalContext* globalCtx) { sp48 = CLAMP(sp48, 0, 255); func_800DFC90(&sp40, GET_ACTIVE_CAM(globalCtx)); - Matrix_RotateY(sp40.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(sp40.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp40.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_8091D3A4, &sp4C); - Matrix_SetStateRotationAndTranslation(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, - this->actor.focus.pos.z + sp4C.z, &sp40); + Matrix_RotateYS(sp40.y, MTXMODE_NEW); + Matrix_RotateXS(sp40.x, MTXMODE_APPLY); + Matrix_RotateZS(sp40.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_8091D3A4, &sp4C); + Matrix_SetTranslateRotateYXZ(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, + this->actor.focus.pos.z + sp4C.z, &sp40); Matrix_Scale(D_8091D39C, D_8091D39C, D_8091D39C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 0f340da3a..ae704672d 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -116,7 +116,7 @@ void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCha* this = THIS; Gfx_DrawDListOpa(globalCtx, object_cha_DL_000710); - Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.home.rot.x, MTXMODE_APPLY); + Matrix_Translate(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.home.rot.x, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_cha_DL_000958); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index cddff71cc..beb2f2d17 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -427,9 +427,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 54; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - Matrix_InsertYRotation_f(Rand_ZeroFloat(M_PI * 2), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(M_PI * 2)); - Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_RotateYF(Rand_ZeroFloat(M_PI * 2), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(M_PI * 2)); + Matrix_MultVecZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -478,8 +478,8 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { if (thisx->params != CLEAR_TAG_POP) { pos.y = this->actor.world.pos.y; for (i = 0; i < 18; i++) { - vel.x = __sinf(i * (33.0f / 40.0f)) * i * .5f; - vel.z = __cosf(i * (33.0f / 40.0f)) * i * .5f; + vel.x = sinf(i * (33.0f / 40.0f)) * i * .5f; + vel.z = cosf(i * (33.0f / 40.0f)) * i * .5f; vel.y = Rand_ZeroFloat(8.0f) + 7.0f; vel.x += randPlusMinusPoint5Scaled(0.5f); @@ -500,9 +500,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { pos = this->actor.world.pos; for (i = 0; i < 44; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_RotateYF(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_MultVecZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -809,10 +809,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectDL); } @@ -828,7 +828,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)effect->primColor.a); func_800C0094(this->actor.floorPoly, effect->position.x, effect->position.y, effect->position.z, &mtxF); - Matrix_SetCurrentState(&mtxF); + Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); @@ -853,7 +853,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)(effect->primColor.a * 0.7f)); func_800C0094(this->actor.floorPoly, effect->position.x, this->actor.floorHeight, effect->position.z, &mtxF); - Matrix_SetCurrentState(&mtxF); + Matrix_Put(&mtxF); Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectGroundDL); @@ -881,10 +881,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->smokeScaleX * effect->scale, effect->smokeScaleY * effect->scale, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); } @@ -907,8 +907,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); @@ -929,8 +929,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the flash billboard effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)effect->primColor.a); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectDL); @@ -954,12 +954,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the light ray effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)effect->primColor.r, (u8)effect->primColor.g, (u8)effect->primColor.b, (u8)effect->primColor.a); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); - Matrix_InsertZRotation_f(effect->rotationZ, MTXMODE_APPLY); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); + Matrix_RotateZF(effect->rotationZ, MTXMODE_APPLY); Matrix_Scale(effect->scale * 0.5f, effect->scale * 0.5f, effect->maxScale * effect->scale, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectDL); } @@ -979,8 +979,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Apply material 16 times along a circle to give the appearance of a splash for (j = 0; j < 16; j++) { - Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(effect->maxScale, &vec); + Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); + Matrix_MultVecZ(effect->maxScale, &vec); /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * returns true if point is within the xz boundaries of an active water box, else false @@ -991,10 +991,9 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { effect->position.z + vec.z, &ySurface, &waterBox)) { if ((effect->position.y - ySurface) < 200.0f) { // Draw the splash effect. - Matrix_InsertTranslation(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_Translate(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, MTXMODE_NEW); + Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gExplosionSplashDL); diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index e65e0dfe9..1a35e8e50 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -245,7 +245,7 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis bodyPart = gEnHyBodyParts[limbIndex]; if (bodyPart >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + Matrix_MultVec3f(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); } if (limbIndex == CNE_LIMB_HEAD) { @@ -257,19 +257,19 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == CNE_LIMB_TORSO) { - Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if ((limbIndex == CNE_LIMB_TORSO) || (limbIndex == CNE_LIMB_LEFT_UPPER_ARM) || @@ -294,7 +294,7 @@ void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == CNE_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); } } @@ -317,7 +317,7 @@ void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, this->enHy.skelAnime.dListCount, EnCne01_OverrideLimbDraw, EnCne01_PostLimbDraw, EnCne01_TransformLimbDraw, &this->enHy.actor); - Matrix_InsertXRotation_s(0, MTXMODE_NEW); + Matrix_RotateXS(0, MTXMODE_NEW); for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 772d054ab..c3396fe29 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -414,7 +414,7 @@ void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnCow* this = THIS; if (limbIndex == COW_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_8099D63C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8099D63C, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index bf77b1897..3ab93e1be 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -551,12 +551,12 @@ void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V EnCrow* this = (EnCrow*)thisx; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_GetStateTranslationAndScaledX(2500.0f, this->bodyPartsPos); + Matrix_MultVecX(2500.0f, this->bodyPartsPos); return; } if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_TAIL)) { - Matrix_GetStateTranslation(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + Matrix_MultZero(&this->bodyPartsPos[(limbIndex >> 1) - 1]); } } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index f8118e199..184a8b81b 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -74,7 +74,7 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { isDisplayListSet = true; } - Matrix_StatePush(); + Matrix_Push(); alpha = (particle->unk_02 / (f32)particle->unk_01); alpha *= 255.0f; @@ -85,15 +85,15 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (particle->unk_02 + (i * 3)) * 3, (particle->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(particle->unk_34, particle->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_0002E8); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -580,7 +580,7 @@ s32 EnDai_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_1E4); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_1E4); } if (limbIndex == 10) { @@ -602,15 +602,15 @@ void EnDai_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve D_80B3FE4C.x = sREG(0); D_80B3FE4C.y = sREG(1); D_80B3FE4C.z = sREG(2); - Matrix_MultiplyVector3fByState(&D_80B3FE4C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B3FE4C, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - Matrix_CopyCurrentState(&sp24); - func_8018219C(&sp24, &sp64, 0); + Matrix_Get(&sp24); + Matrix_MtxFToYXZRot(&sp24, &sp64, false); this->unk_1D4 = BINANG_SUB(sp64.y, 0x4000); break; case 10: - Matrix_CopyCurrentState(&this->unk_18C); + Matrix_Get(&this->unk_18C); break; } } @@ -662,7 +662,7 @@ void func_80B3F78C(EnDai* this, GlobalContext* globalCtx) { this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_XLU_DISP); if (this->unk_1CE & 0x40) { - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); @@ -694,7 +694,7 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); @@ -713,7 +713,7 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { POLY_XLU_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_XLU_DISP); - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 64a8c3d9b..167c11835 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -549,17 +549,17 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isEnabled) { - Matrix_StatePush(); - Matrix_InsertTranslation(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(particle->unk_28.x, MTXMODE_APPLY); - Matrix_RotateY(particle->unk_28.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->unk_28.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(particle->unk_28.x, MTXMODE_APPLY); + Matrix_RotateYS(particle->unk_28.y, MTXMODE_APPLY); + Matrix_RotateZS(particle->unk_28.z, MTXMODE_APPLY); Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_0009E0); - Matrix_StatePop(); + Matrix_Pop(); } } } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index da9f37237..9486507bc 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -710,20 +710,20 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[value]); + Matrix_MultVecX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->limbPos[value]); + Matrix_MultZero(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; ptr2 = &this->limbPos[value + 1]; for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(ptr1, ptr2); + Matrix_MultVec3f(ptr1, ptr2); ptr1++, ptr2++; } } } if (limbIndex == DEKU_SCRUB_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -732,8 +732,8 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDekunuts_OverrideLimbDraw, EnDekunuts_PostLimbDraw, &this->actor); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 23bd7e183..b56063880 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -202,8 +202,8 @@ void func_8098933C(EnDg* this, Vec3f* arg1) { sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - __sinf(0.0f); - __cosf(0.0f); + sinf(0.0f); + cosf(0.0f); arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); arg1->z = Math_Acot2F(1.0f, -sp24 * sp20); } @@ -1190,9 +1190,9 @@ void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == DOG_LIMB_HEAD) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } else if (this->actionFunc != func_8098BC54) { - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } } } @@ -1236,10 +1236,10 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->unk_294.x); - Matrix_InsertZRotation_f(this->unk_294.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateXFApply(this->unk_294.x); + Matrix_RotateZF(this->unk_294.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDg_OverrideLimbDraw, EnDg_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index e06e2e776..d093f29ff 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -1429,15 +1429,15 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_8089E3B0[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && ((this->actionFunc == func_8089C56C) || (this->actionFunc == func_8089C2A8))) { Math_Vec3f_Copy(&sp74, &this->colliderQuad.dim.quad[0]); Math_Vec3f_Copy(&sp80, &this->colliderQuad.dim.quad[1]); - Matrix_MultiplyVector3fByState(&D_8089E38C, &sp68); - Matrix_MultiplyVector3fByState(&D_8089E398, &sp5C); + Matrix_MultVec3f(&D_8089E38C, &sp68); + Matrix_MultVec3f(&D_8089E398, &sp5C); Collider_SetQuadVertices(&this->colliderQuad, &sp5C, &sp68, &sp74, &sp80); if (this->colliderQuad.base.atFlags & AT_ON) { EffectBlure_AddVertex(Effect_GetByIndex(this->unk_2A0), &sp68, &sp5C); @@ -1446,18 +1446,18 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } if (limbIndex == 4) { - Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[0]); + Matrix_MultVecX(300.0f, &this->actor.shape.feetPos[0]); } else if (limbIndex == 7) { - Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[1]); + Matrix_MultVecX(300.0f, &this->actor.shape.feetPos[1]); } if ((limbIndex == 16) && (this->actionFunc == func_8089B580)) { if ((this->skelAnime.curFrame > 38.0f) && (this->skelAnime.curFrame <= 55.0f) && (this->unk_292 != this->unk_290)) { - sp48 = Matrix_GetCurrentState(); + sp48 = Matrix_GetCurrent(); sp58 = 48 - (s32)this->skelAnime.curFrame; sp58 = CLAMP_MIN(sp58, 0); - Matrix_MultiplyVector3fByState(&D_8089E3A4, &sp4C); + Matrix_MultVec3f(&D_8089E3A4, &sp4C); sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index d074753be..914e0f355 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -159,17 +159,17 @@ void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, + MTXMODE_NEW); + Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gfx[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -184,17 +184,17 @@ void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, + MTXMODE_NEW); + Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gfx[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -275,16 +275,16 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); isGfxSetup = true; } - Matrix_StatePush(); + Matrix_Push(); if (1) {}; arg0->unk_24 = (arg0->unk_01 / (f32)arg0->unk_02) * 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)arg0->unk_24); - Matrix_InsertTranslation(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); + Matrix_Translate(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -292,7 +292,7 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A50CBC[idx])); gSPDisplayList(POLY_XLU_DISP++, object_hanareyama_obj_DL_000020); - Matrix_StatePop(); + Matrix_Pop(); sp5C += 1; } } diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 99c5d23d9..62b040c9e 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -285,10 +285,10 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - Matrix_MultiplyVector3fByState(&sp50, &sp44); - Matrix_CopyCurrentState(&sp5C); - func_8018219C(&sp5C, &sp3C, 0); - Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_MultVec3f(&sp50, &sp44); + Matrix_Get(&sp5C); + Matrix_MtxFToYXZRot(&sp5C, &sp3C, false); + Matrix_Translate(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { if (this->unk_28C & 0x20) { @@ -311,9 +311,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* this->unk_294 = sp3C.z; } - Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_292, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -361,10 +361,10 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - Matrix_MultiplyVector3fByState(&sp50, &sp44); - Matrix_CopyCurrentState(&sp5C); - func_8018219C(&sp5C, &sp3C, 0); - Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_MultVec3f(&sp50, &sp44); + Matrix_Get(&sp5C); + Matrix_MtxFToYXZRot(&sp5C, &sp3C, false); + Matrix_Translate(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { @@ -388,9 +388,9 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* this->unk_294 = sp3C.z; } - Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_292, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index e774c8965..326f3fbf2 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -152,8 +152,8 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { if (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); - Matrix_RotateY(-crace->actor.home.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp7C, &sp70); + Matrix_RotateYS(-crace->actor.home.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp7C, &sp70); if ((fabsf(sp70.x) < 100.0f) && (sp70.y >= -10.0f) && (sp70.y <= 180.0f) && (sp70.z < 0.0f)) { crace->unk_170 |= 1; } @@ -970,7 +970,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve func_8012C28C(globalCtx->state.gfxCtx); if (limbIndex == 13) { Matrix_Scale(this->unk_454, this->unk_454, this->unk_454, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_45C, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_45C, MTXMODE_APPLY); } gfxOpa = POLY_OPA_DISP; @@ -986,13 +986,13 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); frames = globalCtx->gameplayFrames; - Matrix_MultiplyVector3fByState(&D_80A73B40, &sp84); + Matrix_MultVec3f(&D_80A73B40, &sp84); func_80A711D0(this, globalCtx, &sp84); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(0.15f, 0.15f, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); gfxXlu = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(gfxXlu, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1004,7 +1004,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve POLY_XLU_DISP = gfxXlu + 5; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 3e9bd9f6e..a4ea26f37 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -425,9 +425,9 @@ s32 func_80B3D974(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); - Matrix_CopyCurrentState(&sp2C); - func_8018219C(&sp2C, &sp6C, 0); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + Matrix_Get(&sp2C); + Matrix_MtxFToYXZRot(&sp2C, &sp6C, false); *arg2 = sp74; if (arg4 == 0) { if (arg5 != 0) { @@ -468,13 +468,13 @@ void EnDnp_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi if (limbIndex == 12) { func_80B3D974(this->unk_330 + 0x4000, this->unk_332 + this->actor.shape.rot.y + 0x4000, &this->unk_1D8, &this->unk_1E4, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1E4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1E4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1E4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1E4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1E4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1E4.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 6b7943504..1cad6dd8f 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -380,8 +380,8 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -566,9 +566,9 @@ s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); - Matrix_CopyCurrentState(&sp2C); - func_8018219C(&sp2C, &sp6C, 0); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + Matrix_Get(&sp2C); + Matrix_MtxFToYXZRot(&sp2C, &sp6C, false); *arg2 = sp74; if (arg4 == 0) { @@ -617,11 +617,11 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1, phi_v0); - Matrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); + Matrix_Translate(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_224.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_224.z, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_224.x, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_224.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_224.z, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_224.x, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index a630a0dcb..914ee2bca 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -1081,16 +1081,16 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80879388[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80879388[limbIndex]]); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - Matrix_MultiplyVector3fByState(&D_8087937C, &this->limbPos[0]); - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->limbPos[1]); + Matrix_MultVec3f(&D_80879370, &this->unk_308); + Matrix_MultVec3f(&D_8087937C, &this->limbPos[0]); + Matrix_MultZero(&this->actor.focus.pos); + Matrix_MultVecY(-200.0f, &this->limbPos[1]); } else if (limbIndex == 13) { - Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); + Matrix_MultVecX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index efd901eb3..a37d8f828 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -725,7 +725,7 @@ void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u32 sp30; - if ((this->action == DEEP_PYTHON_ACTION_EXTEND)) { + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || (this->collider.elements[3].info.bumperFlags & BUMP_HIT) || (this->collider.elements[4].info.bumperFlags & BUMP_HIT) || @@ -816,15 +816,15 @@ void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; if (limbIndex == DEEP_PYTHON_LIMB_JAW) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->jawPos); + Matrix_MultVec3f(&gZeroVec3f, &this->jawPos); playerGrabOffsetFromJawPos.x = 350.0f; playerGrabOffsetFromJawPos.y = -120.0f; playerGrabOffsetFromJawPos.z = -60.0f; - Matrix_MultiplyVector3fByState(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + Matrix_MultVec3f(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); } if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->focusPos); + Matrix_MultVec3f(&gZeroVec3f, &this->focusPos); } Collider_UpdateSpheres(limbIndex, &this->collider); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index a3a433cf1..f71c0b30d 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1558,8 +1558,8 @@ s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } scale *= this->actor.scale.x * 124.99999f; - Matrix_MultiplyVector3fByState(&zeroVec, &sp34); - Matrix_InsertTranslation(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &sp34); + Matrix_Translate(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 3693b258b..ec64038ce 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -153,12 +153,12 @@ void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(this->xyScale + 1.0f, this->xyScale + 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->zRot, MTXMODE_APPLY); + Matrix_RotateZS(this->zRot, MTXMODE_APPLY); Matrix_Scale(this->xScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->zRot * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->zRot * -1, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 7676a9b78..16139fa08 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -611,7 +611,7 @@ void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 83f04b013..ea7ee7aa4 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -274,7 +274,7 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { if (sPtr->enabled) { - Matrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); + Matrix_Translate(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); @@ -282,8 +282,8 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index dabd62e0f..b84eb3d74 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -737,7 +737,7 @@ void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_MultiplyVector3fByState(sFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(sFocusOffset, &this->actor.focus.pos); primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); @@ -807,11 +807,11 @@ void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx) { translation.x = (-(globalCtx->view.eye.x - thisx->world.pos.x) * scale) + globalCtx->view.eye.x; translation.y = (-(globalCtx->view.eye.y - thisx->world.pos.y) * scale) + globalCtx->view.eye.y; translation.z = (-(globalCtx->view.eye.z - thisx->world.pos.z) * scale) + globalCtx->view.eye.z; - Matrix_InsertTranslation(translation.x, translation.y, translation.z, MTXMODE_NEW); + Matrix_Translate(translation.x, translation.y, translation.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(thisx->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(thisx->shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); } EnFall_LodMoon_Draw(thisx, globalCtx); @@ -870,11 +870,10 @@ void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { if (debrisParticles[i].modelIndex < 3) { - Matrix_InsertTranslation(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, - MTXMODE_NEW); + Matrix_Translate(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_InsertRotation(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, - MTXMODE_APPLY); + Matrix_RotateZYX(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, + MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisParticles[i].modelIndex]); diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index cc8c799ee..42ff95aba 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -799,9 +799,9 @@ s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFamos* this = THIS; if (limbIndex == FAMOS_LIMB_BODY) { - Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->flipRot, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->flipRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); } else if (this->flippedTimer < 0) { // if set to -1, famos is dying if ((limbIndex == FAMOS_LIMB_SWORD) || (limbIndex == FAMOS_LIMB_SHIELD) || (limbIndex == FAMOS_LIMB_HEAD)) { @@ -816,7 +816,7 @@ void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnFamos* this = THIS; if (limbIndex == FAMOS_LIMB_EMBLEM) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); Collider_UpdateSpheres(limbIndex, &this->emblemCollider); } } @@ -840,7 +840,7 @@ void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - Matrix_SetStateRotationAndTranslation(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); + Matrix_SetTranslateRotateYXZ(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); Matrix_Scale(rock->scale, rock->scale, rock->scale, MTXMODE_APPLY); gSPMatrix(&dispOpa[3 + i * 2], Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index 060678506..bd3bd9e29 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -377,16 +377,16 @@ void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&vec1, &this->actor.focus.pos); + Matrix_MultVec3f(&vec1, &this->actor.focus.pos); } } @@ -398,9 +398,9 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, { 0, 0, 0, 255 }, }; - Matrix_StatePush(); + Matrix_Push(); EnFg_DrawDust(globalCtx, &this->dustEffect[0]); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -471,8 +471,8 @@ void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect) { alpha = (255.0f / 16.0f) * dustEffect->timer; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); gDPPipeSync(POLY_XLU_DISP++); - Matrix_InsertTranslation(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(dustEffect->xyScale, dustEffect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 711b4ca6e..677edb81a 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -760,7 +760,7 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && ((limbIndex == 15) || (limbIndex == 21))) { if (this->actionFunc != EnFirefly_Die) { - Matrix_GetStateTranslation(&auraPos); + Matrix_MultZero(&auraPos); auraPos.x += Rand_ZeroFloat(5.0f); auraPos.y += Rand_ZeroFloat(5.0f); auraPos.z += Rand_ZeroFloat(5.0f); @@ -793,11 +793,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->limbPos[0]); + Matrix_MultZero(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->limbPos[1]); + Matrix_MultZero(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->limbPos[2]); + Matrix_MultZero(&this->limbPos[2]); } } diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index f86cda7d8..bceaa7225 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -1053,23 +1053,23 @@ void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if ((limbIndex == 20) || (limbIndex == 21)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_318); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_318); } if (limbIndex == 17) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_300); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_300); } Collider_UpdateSpheres(limbIndex, &this->collider); @@ -1161,7 +1161,7 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { if (ptr->unk_00) { - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_14, ptr->unk_14, ptr->unk_14, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 6dc9ff081..668033cd6 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -570,9 +570,9 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { effect->unk_34 = rot->x; effect->unk_38 = rot->y; effect->unk_3C = rot->z; - Matrix_InsertYRotation_f(rot->y, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rot->x); - Matrix_MultiplyVector3fByState(&velSrc, &effect->vel); + Matrix_RotateYF(rot->y, MTXMODE_NEW); + Matrix_RotateXFApply(rot->x); + Matrix_MultVec3f(&velSrc, &effect->vel); break; } @@ -896,14 +896,14 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { fish->type = FS_GROUP_FISH_NORMAL; if (i <= 20) { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle1) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle1) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; } else if (i <= 40) { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle2) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle2) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; } else { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle3) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle3) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; } fish->unk_10.y = fish->pos.y = -35.0f; @@ -1150,7 +1150,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); @@ -1164,7 +1164,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1187,8 +1187,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1215,8 +1215,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1238,8 +1238,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1261,10 +1261,10 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(effect->unk_38, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->unk_34); - Matrix_InsertZRotation_f(effect->unk_3C, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF(effect->unk_38, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->unk_34); + Matrix_RotateZF(effect->unk_3C, MTXMODE_APPLY); Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1288,7 +1288,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1315,9 +1315,9 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { rotY = M_PI; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertYRotation_f(rotY, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateYF(rotY, MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1330,19 +1330,19 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { effect = firstEffect; if (effect->type == FS_EFF_OWNER_HAT) { - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((sEffOwnerHatRot.x * M_PI) / 32768); - Matrix_InsertZRotation_f((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); + Matrix_RotateXFApply((sEffOwnerHatRot.x * M_PI) / 32768); + Matrix_RotateZF((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); - Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1358,7 +1358,7 @@ void EnFishing_DrawStreamSplash(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 50); - Matrix_InsertTranslation(670.0f, -24.0f, -600.0f, MTXMODE_NEW); + Matrix_Translate(670.0f, -24.0f, -600.0f, MTXMODE_NEW); Matrix_Scale(0.02f, 1.0f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1494,9 +1494,9 @@ void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, (rot + i - 1)->y = ry; (rot + i - 1)->x = rx; - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i - 1)->x + posStep.x; (pos + i)->y = (pos + i - 1)->y + posStep.y; @@ -1527,9 +1527,9 @@ void EnFishing_UpdateLinePos(Vec3f* pos) { dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i + 1)->x + posStep.x; (pos + i)->y = (pos + i + 1)->y + posStep.y; @@ -1551,7 +1551,7 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(globalCtx)) || ((D_8090CD0C != 0) && hookIndex))) { offsetY = 0.0f; @@ -1569,15 +1569,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); refPos->x = pos->x + posStep.x; refPos->y = pos->y + posStep.y; refPos->z = pos->z + posStep.z; - Matrix_InsertTranslation(pos->x, pos->y, pos->z, MTXMODE_NEW); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); if ((player->actor.speedXZ == 0.0f) && (D_809101B4 == 0.0f)) { Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); @@ -1585,31 +1585,31 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, sLureHookRotY[hookIndex] = ry; } - Matrix_InsertYRotation_f(sLureHookRotY[hookIndex], MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_RotateYF(sLureHookRotY[hookIndex], MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.005f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); - Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); if ((hookIndex == 1) && (D_8090CD0C != 0)) { Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Translate(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); + Matrix_Push(); if (D_8090CD10 != 0) { FishingEffect* effect = globalCtx->specialEffects; MtxF mf; - Matrix_MultiplyVector3fByState(&sZeroVec, &effect->pos); - Matrix_CopyCurrentState(&mf); - func_8018219C(&mf, &sEffOwnerHatRot, 0); + Matrix_MultVec3f(&sZeroVec, &effect->pos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &sEffOwnerHatRot, false); D_8090CD10 = 0; D_8090CD0C = 0; @@ -1620,15 +1620,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, effect->accel = sZeroVec; } - Matrix_StatePop(); - Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_Pop(); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1665,11 +1665,11 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } if (D_8090CD14 == 5) { - Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); sp94.x = 5.0f; sp94.y = 0.0f; sp94.z = 3.0f; - Matrix_MultiplyVector3fByState(&sp94, &sp88); + Matrix_MultVec3f(&sp94, &sp88); } for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { @@ -1690,9 +1690,9 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i - 1)->x + posStep.x; (pos + i)->y = (pos + i - 1)->y + posStep.y; @@ -1720,10 +1720,10 @@ void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1737,10 +1737,10 @@ void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1764,7 +1764,7 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (D_8090CD54 != 0) { Vec3f posTemp = sLurePos; @@ -1778,11 +1778,11 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* sLurePos = sFishingHookedFish->fishMouthPos; if ((D_8090CD14 == 5) && (D_80917206 == 2)) { - Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); posSrc.x = 2.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_MultVec3f(&posSrc, &posStep); sLurePos.x += posStep.x; sLurePos.z += posStep.z; } @@ -1798,13 +1798,13 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* } if (D_80917206 != 2) { - Matrix_InsertTranslation(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(sLureRot.y + D_80917254, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(sLureRot.x); + Matrix_Translate(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); + Matrix_RotateYF(sLureRot.y + D_80917254, MTXMODE_APPLY); + Matrix_RotateXFApply(sLureRot.x); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); func_8012C28C(globalCtx->state.gfxCtx); @@ -1814,16 +1814,16 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* posSrc.x = -850.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &D_80917218); + Matrix_MultVec3f(&posSrc, &D_80917218); posSrc.x = 500.0f; posSrc.z = -300.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[0]); + Matrix_MultVec3f(&posSrc, &hookPos[0]); EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); posSrc.x = 2100.0f; posSrc.z = -50.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[1]); + Matrix_MultVec3f(&posSrc, &hookPos[1]); EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); } @@ -1850,9 +1850,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; - Matrix_InsertTranslation(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_Translate(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); + Matrix_RotateYF(ry, MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1877,9 +1877,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_RotateYF(ry, MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1888,9 +1888,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* break; } - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f((lineRot + i)->y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((lineRot + i)->x); + Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_RotateYF((lineRot + i)->y, MTXMODE_APPLY); + Matrix_RotateXFApply((lineRot + i)->x); Matrix_Scale(D_809101C8, 1.0f, 0.005f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1899,7 +1899,7 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* } } - Matrix_StatePop(); + Matrix_Pop(); func_8012C2DC(globalCtx->state.gfxCtx); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -2001,34 +2001,34 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 0, 255); - Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); if (sLinkAge != 1) { - Matrix_InsertTranslation(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); } if (D_8090CD14 == 5) { - Matrix_InsertYRotation_f(1.7592919f, MTXMODE_APPLY); + Matrix_RotateYF(1.7592919f, MTXMODE_APPLY); } else { - Matrix_InsertYRotation_f(1.288053f, MTXMODE_APPLY); + Matrix_RotateYF(1.288053f, MTXMODE_APPLY); } - Matrix_RotateStateAroundXAxis(-0.6283185f); - Matrix_InsertZRotation_f((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((D_8090CD40 + 20.0f) * 0.01f * M_PI); + Matrix_RotateXFApply(-0.6283185f); + Matrix_RotateZF((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); + Matrix_RotateXFApply((D_8090CD40 + 20.0f) * 0.01f * M_PI); Matrix_Scale(0.70000005f, 0.70000005f, 0.70000005f, MTXMODE_APPLY); spC0 = (D_8090CD3C * (((player->unk_B08[1] - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); - Matrix_InsertTranslation(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_InsertYRotation_f(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(sRodBendRatios[i] * spC0 * 0.5f); + Matrix_RotateYF(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); + Matrix_RotateXFApply(sRodBendRatios[i] * spC0 * 0.5f); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(sRodScales[i], sRodScales[i], 0.52f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2046,11 +2046,11 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gFishingRodSegmentDL); - Matrix_StatePop(); - Matrix_InsertTranslation(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Translate(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); if (i == 21) { - Matrix_MultiplyVector3fByState(&sRodTipOffset, &sRodTipPos); + Matrix_MultVec3f(&sRodTipOffset, &sRodTipPos); } } @@ -2175,11 +2175,11 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if (D_80917204 == 18) { D_8090CD14 = 1; sLurePos = sRodTipPos; - Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp90.x = 0.0f; sp90.y = 0.0f; sp90.z = 25.0f; - Matrix_MultiplyVector3fByState(&sp90, &D_80917238); + Matrix_MultVec3f(&sp90, &D_80917238); D_80917238.y = 15.0f; D_80917248.x = D_80917248.z = 0.0f; D_80917248.y = -1.0f; @@ -2292,8 +2292,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp7C = Rand_ZeroFloat(1.5f) + 0.5f; sp78 = Rand_ZeroFloat(6.28f); - sp9C.x = __sinf(sp78) * sp7C; - sp9C.z = __cosf(sp78) * sp7C; + sp9C.x = sinf(sp78) * sp7C; + sp9C.z = cosf(sp78) * sp7C; sp9C.y = Rand_ZeroFloat(3.0f) + 3.0f; spA8 = sLurePos; @@ -2471,17 +2471,17 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp90.y = 0.0f; sp90.z = D_809101B4; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); if (D_80917206 == 2) { s8 requiredScopeTemp; - Matrix_MultiplyVector3fByState(&sp90, &sp64); + Matrix_MultVec3f(&sp90, &sp64); D_80917278.x = sp64.x; D_80917278.z = sp64.z; phi_f0 = 10.0f; } else { - Matrix_MultiplyVector3fByState(&sp90, &D_80917278); + Matrix_MultVec3f(&sp90, &D_80917278); phi_f0 = 0.0f; } @@ -2648,8 +2648,8 @@ s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = (Rand_ZeroFloat(3.0f) + 3.0f) * scale; pos = this->actor.world.pos; @@ -2695,8 +2695,8 @@ void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(2.0f) + 2.0f; pos = this->actor.world.pos; @@ -2721,8 +2721,8 @@ void func_809038A4(EnFishing* this, Input* input) { sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); if ((D_8090CD14 == 3) && (this->unk_19A == 0) && (D_8090CD0C == 0)) { - Matrix_InsertYRotation_f((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp34, &sp28); + Matrix_RotateYF((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sp34, &sp28); if ((sp28.z > 0.0f) || (this->unk_1A4 < 40.0f)) { if ((this->unk_150 == 7) && (sp24 < SQ(200.0f))) { @@ -2945,10 +2945,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_184 += this->unk_190; - temp = __cosf(this->unk_184); + temp = cosf(this->unk_184); this->unk_164 = this->unk_166 + (temp * this->unk_194); - temp = __cosf(this->unk_184 + -1.2f); + temp = cosf(this->unk_184 + -1.2f); this->unk_16E = this->unk_166 + (temp * this->unk_194 * 1.6f); } else { Actor_SetScale(&this->actor, this->unk_1A4 * 65.0f * 0.000001f); @@ -2959,11 +2959,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_184 += this->unk_190 * 0.8f; for (i = 0; i < 3; i++) { - temp = __cosf(this->unk_184 + (i * 2.1f)); + temp = cosf(this->unk_184 + (i * 2.1f)); this->unk_1C4[i] = this->unk_166 + (temp * this->unk_194 * 2.0f); } - temp = __cosf(this->unk_184 + 0.4f); + temp = cosf(this->unk_184 + 0.4f); this->unk_164 = (this->unk_194 * temp * 2.0f) * 0.6f; } @@ -3246,8 +3246,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } sp10C.y = 0.0f; sp10C.z = 0.0f; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = sLurePos.x + sp100.x; this->unk_1AC.z = sLurePos.z + sp100.z; @@ -3378,8 +3378,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = 0.0f; sp10C.z = 30.0f; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = sLurePos.x + sp100.x; this->unk_1AC.z = sLurePos.z + sp100.z; @@ -3607,10 +3607,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { for (spA2 = 0; spA2 < 100; spA2++) { - Matrix_InsertYRotation_f(randPlusMinusPoint5Scaled(2.3561945f) + - (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), - MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(randPlusMinusPoint5Scaled(2.3561945f) + + (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = this->actor.world.pos.x + sp100.x; this->unk_1AC.z = this->actor.world.pos.z + sp100.z; @@ -3812,8 +3812,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = 10.0f; sp10C.z = 50.0f; } - Matrix_InsertYRotation_f((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sCameraEye); + Matrix_RotateYF((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sCameraEye); sCameraEye.x += player->actor.world.pos.x; sCameraEye.y += player->actor.world.pos.y; @@ -3855,7 +3855,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.x = 4.0f; sp10C.y = -10.0f; sp10C.z = 5.0f; - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_MultVec3f(&sp10C, &sp100); Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); @@ -4199,7 +4199,7 @@ void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d EnFishing* this = THIS; if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&sFishMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sFishMouthOffset, &this->fishMouthPos); } } @@ -4223,7 +4223,7 @@ void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** EnFishing* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sLoachMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sLoachMouthOffset, &this->fishMouthPos); } } @@ -4232,24 +4232,24 @@ void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); - Matrix_InsertZRotation_f(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYF(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateXFApply(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); + Matrix_RotateZF(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_148 == 0) { - Matrix_InsertYRotation_f((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); + Matrix_RotateYF((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_FishOverrideLimbDraw, EnFishing_FishPostLimbDraw, &this->actor); } else { - Matrix_InsertTranslation(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(-(M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); + Matrix_RotateYF(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); + Matrix_RotateYF(-(M_PI / 2), MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_LoachOverrideLimbDraw, EnFishing_LoachPostLimbDraw, @@ -4359,7 +4359,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_REED) { @@ -4369,11 +4369,11 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(prop->rotX); - Matrix_InsertYRotation_f(prop->reedAngle, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); + Matrix_RotateXFApply(prop->rotX); + Matrix_RotateYF(prop->reedAngle, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4394,7 +4394,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4416,11 +4416,11 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateYF(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4441,9 +4441,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4454,7 +4454,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { prop++; } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -4487,9 +4487,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { refPos = &player->actor.world.pos; } - basePos[0].x = __sinf(sFishGroupAngle1) * 720.0f; + basePos[0].x = sinf(sFishGroupAngle1) * 720.0f; basePos[0].y = -35.0f; - basePos[0].z = __cosf(sFishGroupAngle1) * 720.0f; + basePos[0].z = cosf(sFishGroupAngle1) * 720.0f; temp1 = refPos->x - basePos[0].x; temp2 = refPos->z - basePos[0].z; @@ -4504,9 +4504,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&sFishGroupAngle1, 0.7f, 1.0f, 0.001f); } - basePos[1].x = __sinf(sFishGroupAngle2) * 720.0f; + basePos[1].x = sinf(sFishGroupAngle2) * 720.0f; basePos[1].y = -35.0f; - basePos[1].z = __cosf(sFishGroupAngle2) * 720.0f; + basePos[1].z = cosf(sFishGroupAngle2) * 720.0f; temp1 = refPos->x - basePos[1].x; temp2 = refPos->z - basePos[1].z; @@ -4521,9 +4521,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&sFishGroupAngle2, 2.3f, 1.0f, 0.001f); } - basePos[2].x = __sinf(sFishGroupAngle3) * 720.0f; + basePos[2].x = sinf(sFishGroupAngle3) * 720.0f; basePos[2].y = -35.0f; - basePos[2].z = __cosf(sFishGroupAngle3) * 720.0f; + basePos[2].z = cosf(sFishGroupAngle3) * 720.0f; temp1 = refPos->x - basePos[2].x; temp2 = refPos->z - basePos[2].z; @@ -4635,7 +4635,7 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); fish->unk_30 += fish->unk_34; - fish->unk_2C = (__cosf(fish->unk_30) * fish->unk_38) + offset; + fish->unk_2C = (cosf(fish->unk_30) * fish->unk_38) + offset; } } @@ -4669,9 +4669,9 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { } if (fish->shouldDraw) { - Matrix_InsertTranslation(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((-(f32)fish->unk_3C * M_PI) / 32768.0f); + Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); + Matrix_RotateYF(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); + Matrix_RotateXFApply((-(f32)fish->unk_3C * M_PI) / 32768.0f); Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -5189,12 +5189,12 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; lureDistXZ = sqrtf(SQXZ(spFC)); - Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); + Matrix_RotateYF(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); sp114.x = 0.0f; sp114.y = 0.0f; sp114.z = 100.0f; - Matrix_MultiplyVector3fByState(&sp114, &spFC); + Matrix_MultVec3f(&sp114, &spFC); if (D_8090CD14 == 1) { camAtFraction = 0.2f; @@ -5214,7 +5214,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } sp114.z = -80.0f; - Matrix_MultiplyVector3fByState(&sp114, &sp108); + Matrix_MultVec3f(&sp114, &sp108); sp108.x += player->actor.world.pos.x; sp108.y += player->actor.world.pos.y; sp108.z += player->actor.world.pos.z; @@ -5270,7 +5270,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.x = 0.0f; sp114.y = 0.0f; sp114.z = 100.0f; - Matrix_MultiplyVector3fByState(&sp114, &spFC); + Matrix_MultVec3f(&sp114, &spFC); Math_ApproachF(&sCameraEye.x, sp108.x, 0.3f, fabsf(spFC.x) * D_80911F4C); Math_ApproachF(&sCameraEye.y, sp108.y, 0.3f, 20.0f * D_80911F4C); @@ -5369,7 +5369,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_8090CD54 = 1; Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); - Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp114.x = Math_SinS(globalCtx->gameplayFrames * 0x1000); sp114.y = D_80911F64; @@ -5378,7 +5378,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.y -= 20.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sp108); + Matrix_MultVec3f(&sp114, &sp108); sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; @@ -5396,7 +5396,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.z = -35.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sCameraEye); + Matrix_MultVec3f(&sp114, &sCameraEye); sCameraEye.x += player->actor.world.pos.x; sCameraEye.y += player->actor.world.pos.y; sCameraEye.z += player->actor.world.pos.z; @@ -5484,8 +5484,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { speedXZ = Rand_ZeroFloat(1.5f) + 1.5f; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(3.0f) + 2.0f; pos = player->actor.world.pos; @@ -5600,7 +5600,7 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** if (limbIndex == 8) { // Head OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_MultiplyVector3fByState(&sZeroVec, &sOwnerHeadPos); + Matrix_MultVec3f(&sZeroVec, &sOwnerHeadPos); if (D_8090CD08 == 1) { gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); @@ -5672,7 +5672,7 @@ void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { D_8090CCF4 = true; - Matrix_InsertTranslation(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); + Matrix_Translate(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 75d6ce63b..e7fb183c1 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -1160,23 +1160,23 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_808D393C[limbIndex]]); } if (limbIndex == WALLMASTER_LIMB_WRIST) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); } else if (limbIndex == WALLMASTER_LIMB_HAND) { - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 12, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateYF(M_PI / 3, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 12, MTXMODE_APPLY); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); - Matrix_StatePop(); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 04d4100b1..670bafff2 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1566,7 +1566,7 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 limbRotTableIdx; if (limbIndex == FSN_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 2b234d36b..77450f9ab 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -361,10 +361,10 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { sp34 = D_80964B24; } - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp34, &this->actor.focus.pos); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp34, &this->actor.focus.pos); + Matrix_Pop(); this->actor.focus.pos.x += this->actor.world.pos.x; this->actor.focus.pos.y += this->actor.world.pos.y; this->actor.focus.pos.z += this->actor.world.pos.z; @@ -1347,17 +1347,17 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnFu* this = THIS; if (limbIndex == 9) { - Matrix_InsertTranslation(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_524[1], MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_524[0], MTXMODE_APPLY); - Matrix_RotateY(this->unk_524[2], MTXMODE_APPLY); - Matrix_InsertTranslation(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_524[1], MTXMODE_APPLY); + Matrix_RotateZS(this->unk_524[0], MTXMODE_APPLY); + Matrix_RotateYS(this->unk_524[2], MTXMODE_APPLY); + Matrix_Translate(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 20) { - Matrix_InsertTranslation(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_52A[1], MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_52A[0], MTXMODE_APPLY); - Matrix_RotateY(this->unk_52A[2], MTXMODE_APPLY); - Matrix_InsertTranslation(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_52A[1], MTXMODE_APPLY); + Matrix_RotateZS(this->unk_52A[0], MTXMODE_APPLY); + Matrix_RotateYS(this->unk_52A[2], MTXMODE_APPLY); + Matrix_Translate(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); } return false; } @@ -1368,9 +1368,9 @@ void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnFu* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80964C28, &this->unk_508); + Matrix_MultVec3f(&D_80964C28, &this->unk_508); } else if (limbIndex == 20) { - Matrix_MultiplyVector3fByState(&D_80964C34, &this->unk_514); + Matrix_MultVec3f(&D_80964C34, &this->unk_514); } } @@ -1378,9 +1378,9 @@ void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFu* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1431,11 +1431,11 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { ptr->unk_08.y += ptr->unk_20.y; ptr->unk_08.x += 2.0f * Math_SinS(ptr->unk_2C); ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); - Matrix_StatePush(); - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_RotateY(yaw, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateYS(yaw, MTXMODE_APPLY); + Matrix_MultVec3f(&sp44, &ptr->unk_08); + Matrix_Pop(); ptr->unk_2C += 6000; } } @@ -1456,8 +1456,8 @@ void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0A0); flag = true; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index ad92b34d6..ef4c8b6bb 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -366,17 +366,17 @@ void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); - Matrix_InsertTranslation(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); - Matrix_InsertTranslation(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); + Matrix_Translate(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Translate(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index ec0209729..4591eab65 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -406,8 +406,8 @@ void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < 2; i++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -430,7 +430,7 @@ void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { break; } - Matrix_StatePop(); + Matrix_Pop(); temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); ptr++; @@ -449,14 +449,14 @@ void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 067e8c50d..bd6f66e34 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -259,13 +259,13 @@ void func_80932784(EnFz* this, GlobalContext* globalCtx) { sp5C.y = this->actor.world.pos.y + 20.0f; sp5C.z = this->actor.world.pos.z; - Matrix_InsertTranslation(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); - Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); + Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); sp44.x = sp44.y = 0.0f; sp44.z = 440.0f; - Matrix_MultiplyVector3fByState(&sp44, &this->unk_22C); + Matrix_MultVec3f(&sp44, &this->unk_22C); if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, &sp40)) { Math_Vec3f_Copy(&this->unk_22C, &sp50); @@ -620,7 +620,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -629,7 +629,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { : 0.0f) + 20; - Matrix_MultiplyVector3fByState(&sp64, &sp4C); + Matrix_MultVec3f(&sp64, &sp4C); if ((this->unk_BCA & 7) == 0) { sp3F = 1; @@ -737,7 +737,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -746,7 +746,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { : 0.0f) + 20; - Matrix_MultiplyVector3fByState(&sp64, &sp4C); + Matrix_MultVec3f(&sp64, &sp4C); if (!(this->unk_BC6 & 7)) { sp3F = 1; @@ -1013,8 +1013,8 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 + (i * 3)) * 3, (ptr->unk_01 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_30, ptr->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 1d9175b49..de6a752d8 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -265,9 +265,8 @@ void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, - MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, MTXMODE_APPLY); Matrix_Scale(0.6f, 0.6f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -284,7 +283,7 @@ void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); - Matrix_StatePop(); + Matrix_Pop(); } gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 947afd914..41783a1b7 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -982,7 +982,7 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGb2* this = THIS; if (limbIndex == 7) { - Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_270.y, MTXMODE_APPLY); } if (limbIndex == 1) { @@ -997,7 +997,7 @@ void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = { 2400.0f, 0.0f, 0.0f }; if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index d022058dd..79e5a3480 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -915,9 +915,9 @@ s32 func_80BB3728(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; if (!arg4 && !arg5) { @@ -967,12 +967,12 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve sp2C.y += 2.0f * Rand_Centered(); sp2C.z += Rand_Centered(); - Matrix_MultiplyVector3fByState(&D_80BB407C, &this->unk_4B4); - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp38, &this->unk_4C0[0]); - Matrix_MultiplyVector3fByState(&sp2C, &this->unk_4C0[1]); - Matrix_StatePop(); + Matrix_MultVec3f(&D_80BB407C, &this->unk_4B4); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp38, &this->unk_4C0[0]); + Matrix_MultVec3f(&sp2C, &this->unk_4C0[1]); + Matrix_Pop(); } } @@ -998,13 +998,13 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi func_80BB3728(this->unk_468 + this->unk_46C + 0x4000, this->unk_46A + this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_470, &this->unk_47C, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_47C.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_47C.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_47C.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_47C.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_47C.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_47C.z, MTXMODE_APPLY); + Matrix_Push(); break; case 10: @@ -1022,13 +1022,13 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi func_80BB3728(this->unk_46C + 0x4000, this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_484, &this->unk_490, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_490.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_490.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_490.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_490.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_490.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_490.z, MTXMODE_APPLY); + Matrix_Push(); break; } } @@ -1062,14 +1062,14 @@ void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp24, MTXMODE_APPLY); + Matrix_RotateXS(sp24, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index 3d80cc847..2683e1296 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -509,7 +509,7 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = sp74; i < phi_s7; i += temp) { temp_f20 = i * 0.14f; @@ -520,22 +520,22 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { if (1) {} - Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); - Matrix_StatePush(); + Matrix_Push(); for (i = sp74; i < phi_s7; i += temp) { temp_f20 = i * 0.14f; @@ -544,20 +544,20 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { temp_f26 = ptr->unk_0C.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); temp_f20 = Rand_ZeroOne() * 0.003f; - Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -583,7 +583,7 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { if (phi_s4 > 0) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < phi_s4; i++) { if (ptr->unk_48 != 0) { @@ -596,22 +596,22 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { temp_f28 = ptr->unk_0C.z + (ptr->unk_18.z * i) + (0.5f * ptr->unk_24.z * i * i); temp_f20 = Rand_ZeroOne() * 0.003f; - Matrix_InsertTranslation((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, - ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); + Matrix_Translate((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, + ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -739,7 +739,7 @@ s32 EnGg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGg* this = THIS; if (limbIndex == 2) { - Matrix_InsertZRotation_s(this->unk_2E8, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2E8, MTXMODE_APPLY); } return false; } @@ -764,12 +764,12 @@ void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&D_80B36DF0, &this->unk_320); - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp30, &this->unk_32C); - Matrix_MultiplyVector3fByState(&sp24, &this->unk_338); - Matrix_StatePop(); + Matrix_MultVec3f(&D_80B36DF0, &this->unk_320); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp30, &this->unk_32C); + Matrix_MultVec3f(&sp24, &this->unk_338); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index f45cafa53..46f0b657c 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -457,11 +457,11 @@ s32 func_80B3BD44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { if (limbIndex == 1) { - Matrix_RotateY(this->unk_2F6, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_2F6, MTXMODE_APPLY); } if (limbIndex == 2) { - Matrix_InsertZRotation_s(this->unk_2F4, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2F4, MTXMODE_APPLY); } } return false; @@ -471,7 +471,7 @@ void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnGg2* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&D_80B3C0A0, &this->unk_304); + Matrix_MultVec3f(&D_80B3C0A0, &this->unk_304); } } diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 90d945e2a..26dfcb756 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -485,7 +485,7 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnGiant* this = THIS; if (limbIndex == GIANT_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->headDrawMtxF); + Matrix_Get(&this->headDrawMtxF); } } @@ -517,7 +517,7 @@ void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); + Matrix_Mult(&this->headDrawMtxF, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 34b0e36b4..300987214 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -636,13 +636,13 @@ s32 EnGinkoMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->limb15Rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->limb15Rot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->limb15Rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->limb15Rot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->limb8Rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->limb8Rot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->limb8Rot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->limb8Rot.x, MTXMODE_APPLY); } return false; diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index b509d4500..45fe0c132 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -597,7 +597,7 @@ void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx) { void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx) { EnGirlA* this = THIS; - Matrix_RotateY(this->rotY, MTXMODE_APPLY); + Matrix_RotateYS(this->rotY, MTXMODE_APPLY); if (this->drawFunc != NULL) { this->drawFunc(&this->actor, globalCtx, 0); } diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index e6ede8065..ae9dd8553 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -403,9 +403,9 @@ s32 func_80B50ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -1146,17 +1146,17 @@ void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec this->actor.focus.pos.y = this->actor.world.pos.y + phi_f0; this->actor.focus.pos.z = this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp58, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&sp34, &this->unk_2E8); - Matrix_MultiplyVector3fByState(&sp28, &this->unk_2F4); + Matrix_MultVec3f(&sp58, &this->actor.focus.pos); + Matrix_MultVec3f(&sp34, &this->unk_2E8); + Matrix_MultVec3f(&sp28, &this->unk_2F4); - Matrix_StatePush(); + Matrix_Push(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp4C, &this->unk_30C); - Matrix_MultiplyVector3fByState(&sp40, &this->unk_300); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp4C, &this->unk_30C); + Matrix_MultVec3f(&sp40, &this->unk_300); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1182,15 +1182,15 @@ void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { this->unk_320 + this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_328, &this->unk_334, phi_v0, phi_v1); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); + Matrix_Translate(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_334.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_334.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_334.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_334.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_334.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_334.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); break; case 9: @@ -1208,15 +1208,15 @@ void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { func_80B50ED4(this->unk_322 + 0x4000, this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_33C, &this->unk_348, phi_v0, phi_v1); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_348.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_348.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_348.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_348.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_348.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_348.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); break; } } @@ -1239,7 +1239,7 @@ void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006688); diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 8430547ab..07699e7de 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -874,7 +874,7 @@ void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { this->unk_3AC = 0.0f; } Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_3F0 = sp28; } @@ -1759,7 +1759,7 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 pad2; if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == 16)) { - Matrix_MultiplyVector3fByState(&D_80951E24, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80951E24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } @@ -1772,7 +1772,7 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp30); + Matrix_MultVec3f(&gZeroVec3f, &sp30); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } } @@ -1798,23 +1798,23 @@ void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, &this->unk_2A8, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == 9) { SubS_UpdateLimb(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_29C, &this->unk_2AE, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index c34b3e9a3..27c307777 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -253,7 +253,7 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = ((f32)ptr->unk_02 / ptr->unk_01); temp *= 255; @@ -263,15 +263,15 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_02 + (i * 3)) * 3, (ptr->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); - Matrix_StatePop(); + Matrix_Pop(); if (globalCtx->state.gfxCtx) {} } } @@ -328,7 +328,7 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = (f32)ptr->unk_02 / ptr->unk_01; @@ -337,16 +337,16 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80A16670[(s32)ptr->unk_00 - 4].r, D_80A16670[(s32)ptr->unk_00 - 4].g, D_80A16670[(s32)ptr->unk_00 - 4].b, 0); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); - Matrix_StatePop(); + Matrix_Pop(); } if (globalCtx->state.gfxCtx) {} } @@ -465,12 +465,12 @@ void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* ar flag = true; } - Matrix_StatePush(); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Push(); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(0.08f, 0.08f, 0.08f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(ptr->unk_0A.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_0A.x, MTXMODE_APPLY); - Matrix_RotateY(ptr->unk_0A.y, MTXMODE_APPLY); + Matrix_RotateZS(ptr->unk_0A.z, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_0A.x, MTXMODE_APPLY); + Matrix_RotateYS(ptr->unk_0A.y, MTXMODE_APPLY); if (1) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -478,7 +478,7 @@ void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* ar gSPDisplayList(POLY_OPA_DISP++, arg3); } - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1067,14 +1067,13 @@ void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { u32 frames2; if (this->unk_390 & 0x400) { - Matrix_StatePush(); + Matrix_Push(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(arg2 * 0.7f, arg2 * 0.8f, arg2, MTXMODE_APPLY); func_800B8118(&this->actor, globalCtx, 0); @@ -1088,7 +1087,7 @@ void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1951,12 +1950,12 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); if (this->unk_390 & 0x100) { Matrix_Scale(this->actor.scale.x * 8.0f, this->actor.scale.y * 8.0f, this->actor.scale.z * 8.0f, MTXMODE_APPLY); @@ -1964,7 +1963,7 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); } - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); @@ -1978,7 +1977,7 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - Matrix_GetStateTranslation(&sp30); + Matrix_MultZero(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } @@ -2035,25 +2034,25 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(this->unk_3B0 + this->unk_3B4 + 0x4000, this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, &this->unk_2A8, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_Push(); break; case 10: SubS_UpdateLimb(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, &this->unk_2AE, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_Push(); break; } } @@ -2073,7 +2072,7 @@ void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A1670C[this->unk_3BE])); if (this->unk_3DC == 14) { - Matrix_InsertTranslation(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); } SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGo_OverrideLimbDraw, NULL, EnGo_TransfromLimbDraw, diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 7f6db7264..f17a75f6a 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -560,12 +560,12 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp64 = this->unk_1B4; } - Matrix_InsertRotationAroundUnitVector_f(sp7C, &sp64, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp24); - func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); + Matrix_RotateAxisF(sp7C, &sp64, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp24); + Matrix_MtxFToYXZRot(&sp24, &this->actor.shape.rot, false); } void func_8093FC00(EnGoroiwa* this) { @@ -1349,8 +1349,8 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80942E6C, &spB8); + Matrix_RotateZYX(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); + Matrix_MultVec3f(&D_80942E6C, &spB8); temp_f20 = this->unk_1DC * 0.9f; if (spB8.y > 0.0f) { @@ -1566,7 +1566,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { sp80.y = ptr->unk_1E; sp80.z = ptr->unk_20; - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, phi_fp); @@ -1580,7 +1580,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_Put(&sp88); Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 37f56469d..a97de7b80 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -349,8 +349,8 @@ f32 func_80998334(EnGs* this, GlobalContext* globalCtx, f32* arg2, f32* arg3, s1 if (arg9 == 0) { sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); - this->unk_1B0[0].x = (__sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; - this->unk_1B0[0].y = 1.0f - (__sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); + this->unk_1B0[0].x = (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; + this->unk_1B0[0].y = 1.0f - (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); (*arg4)++; } return sp2C; @@ -383,8 +383,8 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { Player* player = GET_PLAYER(globalCtx); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(160.0f, &sp38); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(160.0f, &sp38); Math_Vec3f_Sum(&player->actor.world.pos, &sp38, &player->actor.world.pos); Math_Vec3f_Copy(&player->actor.prevPos, &player->actor.world.pos); this->unk_200 = 0.0f; @@ -725,8 +725,8 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { sp40 = Math_SmoothStepToF(&this->unk_1EC, this->unk_1F0, 0.8f, 0.02f, 0.001f); this->unk_1B0[0].x = this->unk_1E4 + 1.0f; this->unk_1B0[0].y = this->unk_1DC + 1.0f; - this->unk_1B0[0].x += __sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; - this->unk_1B0[0].y += __sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].x += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].y += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; this->unk_1D4++; if ((sp48 == 0.0f) && (sp44 == 0.0f) && (sp40 == 0.0f)) { this->unk_216 = 0; @@ -1070,16 +1070,16 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { frames = globalCtx->gameplayFrames; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (this->unk_19A & 1) { - Matrix_RotateY(this->unk_19E[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_19E[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_19E[0].z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_19E[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_19E[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_19E[0].z, MTXMODE_APPLY); Matrix_Scale(this->unk_1B0[0].x, this->unk_1B0[0].y, this->unk_1B0[0].z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_19E[1].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_19E[1].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_19E[1].z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_19E[1].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_19E[1].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_19E[1].z, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1088,11 +1088,11 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_0009D0); gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000A60); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_19A & 2) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(0.05f, -0.05f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index 726287c0b..1394efff7 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -374,7 +374,7 @@ void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, NULL, &this->actor); - Matrix_InsertTranslation(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + Matrix_Translate(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); Matrix_Scale(0.015f, 0.015f, 0.015f, 1); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 108d62afd..d8551103d 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -350,7 +350,7 @@ void func_80B228F4(Actor* thisx, GlobalContext* globalCtx) { void EnHakurock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011100); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011178); diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index d7ec6103f..f90ed476b 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -153,15 +153,15 @@ void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { for (i = 0; i < 400; i++, arg0++) { if (arg0->unk_00 == 1) { - Matrix_InsertTranslation(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); if (arg0->unk_01 < 40) { Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, MTXMODE_APPLY); } else { Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); } - Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -348,7 +348,7 @@ void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHanabi* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80B22FA8(this->unk_148, globalCtx); - Matrix_StatePop(); + Matrix_Pop(); } diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 0bbef0b9e..2b77feacf 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -402,9 +402,9 @@ s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHg* this = THIS; if (limbIndex == HG_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->unk1D8); + Matrix_Get(&this->unk1D8); } else if (limbIndex == HG_LIMB_PELVIS) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -415,7 +415,7 @@ void EnHg_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&this->unk1D8); + Matrix_Put(&this->unk1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_005E28); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index 2aa217846..a16e0d94a 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -361,8 +361,8 @@ void EnHgo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnHgo* this = THIS; if (limbIndex == HGO_LIMB_PELVIS) { - Matrix_CopyCurrentState(&this->unk_1D8); - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_Get(&this->unk_1D8); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -374,7 +374,7 @@ void EnHgo_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->unk_30C])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHgo_OverrideLimbDraw, &EnHgo_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&this->unk_1D8); + Matrix_Put(&this->unk_1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_00F248); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index 51a408e6e..c9b9485ce 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -852,9 +852,9 @@ s32 EnHintSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3DE == 1)) { - Matrix_InsertZRotation_s(0x71C, MTXMODE_APPLY); + Matrix_RotateZS(0x71C, MTXMODE_APPLY); } if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_3E8 & 2)) { @@ -883,10 +883,10 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80C21E70, &this->limbPos[this->limbCount]); this->limbCount++; } } diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index 8d5816c16..c3d577e7a 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -330,7 +330,7 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { } dl = Gfx_CallSetupDL(dl, dlIndex); if (this->playerSide == EN_HOLL_BEHIND) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(dl++, 0, 0, 0, 0, 0, this->alpha); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 54e388bc2..a0756abdf 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -4675,7 +4675,7 @@ s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p EnHorse* this = THIS; if (limbIndex == 3) { - Matrix_MultiplyVector3fByState(&sp1C, &this->riderPos); + Matrix_MultVec3f(&sp1C, &this->riderPos); } return false; } diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 6b9a8dda1..ae5f25c87 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -77,12 +77,12 @@ s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp38); - Matrix_SetCurrentState(&sp38); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Put(&sp38); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp38); + Matrix_Get(&sp38); - func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; return true; } @@ -373,12 +373,12 @@ s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp38); - Matrix_SetCurrentState(&sp38); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Put(&sp38); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp38); + Matrix_Get(&sp38); - func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; return true; } diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index 5e886bcc0..1e9fdfbf9 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -349,7 +349,7 @@ void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnHs* this = THIS; if (limbIndex == HS_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8095393C, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index c9f4f9b70..e687b770d 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -973,7 +973,7 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp2C; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80BF3528, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BF3528, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); gSPDisplayList((*gfx)++, object_dai_DL_008710); @@ -986,12 +986,12 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == 9) { gSPDisplayList((*gfx)++, object_dai_DL_008B00); - Matrix_MultiplyVector3fByState(&D_80BF351C, &sp2C); + Matrix_MultVec3f(&D_80BF351C, &sp2C); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp2C); } if (limbIndex == 10) { - Matrix_CopyCurrentState(&this->unk_190); + Matrix_Get(&this->unk_190); } } @@ -1015,13 +1015,13 @@ void EnIg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this if (limbIndex == 9) { SubS_UpdateLimb(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, &this->unk_2E6, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2E6.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2E6.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E6.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2E6.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2E6.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2E6.z, MTXMODE_APPLY); + Matrix_Push(); } } @@ -1045,7 +1045,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnIg_OverrideLimbDraw, EnIg_PostLimbDraw, EnIg_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_SetCurrentState(&this->unk_190); + Matrix_Put(&this->unk_190); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 7dcaf7b64..ef4db6f9e 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1482,7 +1482,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (&this->actor == player->targetActor && !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { @@ -1543,15 +1543,15 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 16) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->torsoRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->torsoRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); @@ -1581,16 +1581,16 @@ void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 16) { - Matrix_MultiplyVector3fByState(&sp50, &this->unk4B4); + Matrix_MultVec3f(&sp50, &this->unk4B4); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk4B4); } if (this->unk23D == 0) { Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&sp44, &this->unk248); + Matrix_MultVec3f(&sp44, &this->unk248); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&sp44, &this->unk254); + Matrix_MultVec3f(&sp44, &this->unk254); } if (this->unk23C == 0) { if (!(this->unk4AC & 8)) { diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 6c698234b..2eace7815 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1325,11 +1325,11 @@ void func_80B454BC(EnInvadepoh* this, GlobalContext* globalCtx) { } void EnInvadepoh_SetSysMatrix(Vec3f* vec) { - MtxF* sysMatrix = Matrix_GetCurrentState(); + MtxF* sysMatrix = Matrix_GetCurrent(); - sysMatrix->wx = vec->x; - sysMatrix->wy = vec->y; - sysMatrix->wz = vec->z; + sysMatrix->xw = vec->x; + sysMatrix->yw = vec->y; + sysMatrix->zw = vec->z; } s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 arg3) { @@ -2388,16 +2388,16 @@ void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, D_80B4EDC0[temp], 0x32); if (this->actor.child != NULL) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_InsertTranslation(0, 57.0f, -36.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->actor.child->world.pos); - Matrix_CopyCurrentState(&unkMtx); - func_8018219C(&unkMtx, &this->actor.child->shape.rot, 0); - Matrix_StatePop(); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Translate(0, 57.0f, -36.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); + Matrix_MultZero(&this->actor.child->world.pos); + Matrix_Get(&unkMtx); + Matrix_MtxFToYXZRot(&unkMtx, &this->actor.child->shape.rot, false); + Matrix_Pop(); } } @@ -4314,7 +4314,7 @@ void func_80B4D7B8(GlobalContext* globalCtx) { temp_v0 = globalCtx->gameplayFrames; temp_s5 = (temp_v0 + ((0x10 * i) & 0xFFU)) & 0x7F; temp_s6 = (u8)(temp_v0 * -0xF); - Matrix_InsertTranslation(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); + Matrix_Translate(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, phi_s2->unk2); @@ -4343,22 +4343,22 @@ void func_80B4D9F4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if ((limbIndex == 12) && (this->alienBeamAlpha != 0)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); - Matrix_RotateY(-0x3830, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); + Matrix_RotateYS(-0x3830, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&D_80B502A0); - Matrix_StatePop(); + Matrix_Get(&D_80B502A0); + Matrix_Pop(); } else if ((limbIndex == 13) && (this->alienBeamAlpha != 0)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); - Matrix_RotateY(-0x47D0, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); + Matrix_RotateYS(-0x47D0, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&D_80B502E0); - Matrix_StatePop(); + Matrix_Get(&D_80B502E0); + Matrix_Pop(); } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80B4EE24, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B4EE24, &this->actor.focus.pos); } } @@ -4369,7 +4369,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(spCC); func_8012C2DC(spCC); - Matrix_StatePush(); + Matrix_Push(); if (this->drawAlien) { Gfx* new_var6; Gfx* spBC; @@ -4399,10 +4399,10 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(spBC++); gDPSetPrimColor(spBC++, 0, 255, 240, 180, 100, 60); gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); - Matrix_InsertMatrix(&D_80B502A0, MTXMODE_NEW); + Matrix_Mult(&D_80B502A0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, object_uch_DL_000080); - Matrix_InsertMatrix(&D_80B502E0, MTXMODE_NEW); + Matrix_Mult(&D_80B502E0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, object_uch_DL_000080); spB8->polyXlu.p = spBC; @@ -4410,8 +4410,8 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } if (this->drawAlienDeathEffect) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->alienDeathEffectScale.x, this->alienDeathEffectScale.y, this->alienDeathEffectScale.z, MTXMODE_APPLY); gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4431,12 +4431,12 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gDPSetDither(gfx++, G_CD_NOISE); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(60.0f, &sp80); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(60.0f, &sp80); sp74.x = thisx->world.pos.x + sp80.x; sp74.y = thisx->world.pos.y + sp80.y + 68.0f; sp74.z = thisx->world.pos.z + sp80.z; - Matrix_InsertTranslation(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); + Matrix_Translate(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); Matrix_Scale(0.25f, 0.25f, 0.25f, MTXMODE_APPLY); alpha2 = this->alienAlpha * (100.0f / 255.0f); gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); @@ -4450,7 +4450,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(spCC); } @@ -4502,7 +4502,7 @@ void func_80B4E2AC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* gSPDisplayList(POLY_OPA_DISP++, object_ma1_DL_0003B0); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&D_80B4EE30, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B4EE30, &this->actor.focus.pos); } } @@ -4522,16 +4522,16 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; Vec3f sp5C; - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(200.0f, &sp5C); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(200.0f, &sp5C); + Matrix_Pop(); sp5C.x += thisx->world.pos.x; sp5C.y += thisx->world.pos.y; sp5C.z += thisx->world.pos.z; EnInvadepoh_SetSysMatrix(&sp5C); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateZS(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4563,7 +4563,7 @@ void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); + Matrix_MultVecY(20.0f, &this->actor.focus.pos); } } @@ -4597,7 +4597,7 @@ void func_80B4E784(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if (limbIndex == 9) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index ac42d0c7a..9b60a41dd 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -309,11 +309,11 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { if (temp >= 0) { sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); if (sp3C != NULL) { - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &sp30); sp2C = Math3D_Parallel(&sp30, &D_8095F778); if (sp2C < 0.707f) { temp_v1_2 = Math_FAtan2F(sp30.z, sp30.x) - sp3C->world.rot.y; @@ -326,7 +326,7 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { } sp3C->velocity.y *= temp_f2; } - Matrix_StatePop(); + Matrix_Pop(); } } } diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index e6bc31eea..5659e5ba9 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -235,7 +235,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_34C += (this->unk_348 != 0.0f) ? 60.0f : -60.0f; this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); - Matrix_InsertTranslation(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_374 = sp20; } @@ -420,18 +420,18 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 pad2; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BC3780, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BC3780, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } else if ((this->unk_340 & 0x40) && (limbIndex == 11)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80BC3774, &D_80BC37A4); + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80BC3774, &D_80BC37A4); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BA30); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -441,9 +441,9 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec ((this->skelAnime.curFrame >= 35.0f) && (this->skelAnime.curFrame <= 47.0f)))) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_Translate(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -473,17 +473,17 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 14) { if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -513,7 +513,7 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -547,24 +547,24 @@ void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(this->unk_354 + this->unk_358 + 0x4000, this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, &this->unk_274, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_274.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_274.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_274.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_274.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_274.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_274.z, MTXMODE_APPLY); + Matrix_Push(); } } else { SubS_UpdateLimb(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, &this->unk_27A, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_27A.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_27A.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_27A.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_27A.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_27A.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_27A.z, MTXMODE_APPLY); + Matrix_Push(); } } @@ -725,8 +725,8 @@ void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { if (((ptr->unk_0E < 0) || (ptr->unk_0E >= 19)) && ((ptr->unk_0E < 83) || (ptr->unk_0E >= 103))) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); switch (ptr->unk_0C) { diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 4e50ceba6..6afe9c1a0 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -162,6 +162,6 @@ void EnJcMato_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultiplyVector3fByState(&movement, &this->pos); + Matrix_MultVec3f(&movement, &this->pos); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 2fe0853cd..8f2408495 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -1004,10 +1004,10 @@ s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (this->flags & FLAG_LOOKING_AT_PLAYER) { Math_SmoothStepToS(&this->rootRotationWhenTalking, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 5, 0x1000, 0x100); - Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); } else { Math_SmoothStepToS(&this->rootRotationWhenTalking, 0, 5, 0x1000, 0x100); - Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); } } @@ -1018,14 +1018,14 @@ void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnJg* this = THIS; if (limbIndex == GORON_ELDER_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } if (limbIndex == GORON_ELDER_LIMB_LOWER_LIP) { - Matrix_MultiplyVector3fByState(&sBreathPosOffset, &this->breathPos); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sBreathVelOffset, &this->breathVelocity); - Matrix_MultiplyVector3fByState(&sBreathAccelOffset, &this->breathAccel); + Matrix_MultVec3f(&sBreathPosOffset, &this->breathPos); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sBreathVelOffset, &this->breathVelocity); + Matrix_MultVec3f(&sBreathAccelOffset, &this->breathAccel); } } diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 104e2bc3c..c16fa4147 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -626,7 +626,7 @@ s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == OBJECT_TSN_LIMB_0F) { - Matrix_GetStateTranslation(&thisx->focus.pos); + Matrix_MultZero(&thisx->focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 53dd9e671..78441bc41 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -1148,7 +1148,7 @@ void EnKakasi_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnKakasi* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk1BC); + Matrix_MultVec3f(&gZeroVec3f, &this->unk1BC); } } diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index e457ec219..d2a1f9902 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -770,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80AD8EA4[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -779,13 +779,13 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3f* ptr2; if (this->actor.shape.shadowDraw == NULL) { - Matrix_GetStateTranslation(&this->actor.world.pos); + Matrix_MultZero(&this->actor.world.pos); } ptr2 = D_80AD8E68; ptr = &this->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { - Matrix_MultiplyVector3fByState(ptr2, ptr); + Matrix_MultVec3f(ptr2, ptr); ptr2++; ptr++; } diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index dee9a5049..921cb9633 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -339,8 +339,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->pieceType = PIECE_WHOLE_SIGN; } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sPieceOffsets[piece->pieceType], &offset); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sPieceOffsets[piece->pieceType], &offset); piece->actor.world.pos.x += offset.x; piece->actor.world.pos.y += offset.y; piece->actor.world.pos.z += offset.z; @@ -549,9 +549,9 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } else { Vec3f spC8; - Matrix_SetStateXRotation(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(KREG(20) + 10.0f, &spC8); + Matrix_RotateXFNew(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); + Matrix_MultVecY(KREG(20) + 10.0f, &spC8); Math_ApproachF(&this->actor.velocity.x, spC8.x, 0.5f, (KREG(21) * 0.01f) + 0.1f); Math_ApproachF(&this->actor.velocity.z, spC8.z, 0.5f, (KREG(21) * 0.01f) + 0.3f); this->actor.world.rot.y = Math_Atan2S(spC8.x, spC8.z); @@ -855,8 +855,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } - Matrix_RotateY(signpost->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sPieceOffsets[this->pieceType], &offset); + Matrix_RotateYS(signpost->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sPieceOffsets[this->pieceType], &offset); distX = Math_SmoothStepToF(&this->actor.world.pos.x, signpost->actor.world.pos.x + offset.x, 1.0f, 3.0f, 0.0f); distY = @@ -927,24 +927,23 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_kanban_DL_000C30); if (this->actionState != ENKANBAN_SIGN) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXFApply(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); zShift = fabsf(Math_SinS(this->spinRot.x) * this->pieceHeight); zShift2 = fabsf(Math_SinS(this->spinRot.z) * this->pieceWidth); zShift = CLAMP_MIN(zShift, zShift2); zShift *= -(f32)this->direction; - Matrix_InsertTranslation(0.0f, 0.0f, zShift, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); - Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, zShift, MTXMODE_APPLY); + Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -960,7 +959,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { phi_f0 = -15.0f; } this->actor.world.pos.y = this->actor.home.pos.y + phi_f0; - Matrix_InsertTranslation(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->partFlags == 0xFFFF) { @@ -976,8 +975,8 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->cutMarkAlpha != 0) { f32 cutOffset = (this->cutType == CUT_POST) ? -1200.0f : 0.0f; - Matrix_InsertTranslation(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(sCutAngles[this->cutType], MTXMODE_APPLY); + Matrix_Translate(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); + Matrix_RotateZF(sCutAngles[this->cutType], MTXMODE_APPLY); Matrix_Scale(0.0f, 10.0f, 2.0f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); @@ -1011,21 +1010,21 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { zShift = ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, - MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, + MTXMODE_NEW); + Matrix_RotateXFApply(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, 0.0f, this->actor.scale.z, MTXMODE_APPLY); if (this->actionState == ENKANBAN_SIGN) { - Matrix_RotateStateAroundXAxis(-M_PI / 5); + Matrix_RotateXFApply(-M_PI / 5); } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); - Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < ARRAY_COUNT(sShadowTexFlags); i++) { diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index 7a59e702c..94452e054 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -633,7 +633,7 @@ void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); func_800C0094(this->unk_22C, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &sp40); - Matrix_InsertMatrix(&sp40, MTXMODE_NEW); + Matrix_Mult(&sp40, MTXMODE_NEW); Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -656,7 +656,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actionFunc == func_808F21A4) { if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { - Matrix_InsertTranslation(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -665,8 +665,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } else if (this->actionFunc != func_808F254C) { func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); if ((this->actionFunc == func_808F241C) || (this->actionFunc == func_808F200C) || (this->actionFunc == func_808F15B0)) { @@ -674,7 +673,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); - Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); if (this->actor.params == ENKAREBABA_2) { sp94 = 1; @@ -685,15 +684,15 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } for (i = 0; i < sp94; i++) { - Matrix_InsertTranslation(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); - Matrix_GetStateTranslation(&this->limbPos[1 + i]); + Matrix_MultZero(&this->limbPos[1 + i]); if ((i == 0) && (this->actionFunc == func_808F1C84)) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -701,25 +700,25 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); - Matrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); if (this->actionFunc != func_808F15B0) { sp8C = 0.01f; } Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); - Matrix_RotateY(this->actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); if (this->actionFunc == func_808F1C84) { - Matrix_InsertRotation(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); + Matrix_RotateZYX(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); - Matrix_GetStateTranslation(&this->limbPos[3]); + Matrix_MultZero(&this->limbPos[3]); } func_800AE5A0(globalCtx); diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index 9a42980db..095378137 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -537,7 +537,7 @@ void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnKbt* this = THIS; if (limbIndex == OBJECT_KBT_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80B34B84, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B34B84, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 176a556e5..cc184cfed 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -1121,11 +1121,11 @@ void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnKgy* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80B432D8, &this->unk_2A8); + Matrix_MultVec3f(&D_80B432D8, &this->unk_2A8); } if (limbIndex == 16) { - Matrix_MultiplyVector3fByState(&D_80B432E4, &this->unk_2C0); + Matrix_MultVec3f(&D_80B432E4, &this->unk_2C0); } } @@ -1137,9 +1137,9 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); - Matrix_StatePush(); - Matrix_InsertTranslation(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); if (func_80B40D8C(globalCtx)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kgy_Matanimheader_00F6A0)); @@ -1161,7 +1161,7 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 4c9f10ff8..1767f3c86 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -117,7 +117,7 @@ static InitChainEntry sInitChain[] = { * */ void EnKusa_ApplySway(MtxF* matrix) { - MtxF* mtxState = Matrix_GetCurrentState(); + MtxF* mtxState = Matrix_GetCurrent(); f32* tmp = &mtxState->mf[0][0]; f32* tmp2 = &matrix->mf[0][0]; s32 i; diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index e4e821427..6ba532cef 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -241,7 +241,7 @@ void func_80A5B508(void) { void func_80A5B954(MtxF* matrix, f32 arg1) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = (f32*)&temp->mf[0]; f32* tmp2 = (f32*)&matrix->mf[0]; @@ -1325,7 +1325,7 @@ void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { EnKusa2UnkBssSubStruct2* s = &D_80A5F1C0.unk_0480[i]; if (s->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); + Matrix_SetTranslateRotateYXZ(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); Matrix_Scale(s->unk_00, s->unk_00, s->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1369,7 +1369,7 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.x = thisx->shape.rot.x + D_80A5EAFC.x; sp18.y = thisx->shape.rot.y + D_80A5EAFC.y; sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; - Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); + Matrix_SetTranslateRotateYXZ(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index f815147a2..9dc919e0e 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -186,11 +186,11 @@ void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); } - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), - MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), + MTXMODE_APPLY); if (ENLIGHT_GET_1(&this->actor)) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 73a559a70..774acf118 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -334,11 +334,11 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; effectPos.y += 30.0f; effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (!this->isPlayerDetected) { s16 drawFlag = 1; if (gSaveContext.save.isNight) { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 8905a862d..226059ae2 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -1052,7 +1052,7 @@ void EnMa4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp28 = { 800.0f, 0.0f, 0.0f }; if (limbIndex == MA1_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); + Matrix_MultVec3f(&sp28, &this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 5847aa897..52c6a2998 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -1451,7 +1451,7 @@ void EnMaYto_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYto* this = THIS; if (limbIndex == MA2_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 721e2f742..f5bf0625b 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -526,7 +526,7 @@ void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYts* this = THIS; if (limbIndex == MA1_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 9d6f6312e..cc56a5e5e 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -621,10 +621,10 @@ void func_80B38060(EnMaruta* this, Vec3f* arg1) { } void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { - Matrix_StatePush(); - Matrix_InsertRotation(arg2, arg3, arg4, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(arg0, arg1); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateZYX(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultVec3f(arg0, arg1); + Matrix_Pop(); } void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { @@ -672,10 +672,10 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { sp50 = D_80B387E4[this->unk_210]; - Matrix_StatePush(); - Matrix_InsertTranslation(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); - Matrix_InsertRotationAroundUnitVector_s(this->unk_218, &this->unk_194, MTXMODE_APPLY); - Matrix_InsertTranslation(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); + Matrix_RotateAxisS(this->unk_218, &this->unk_194, MTXMODE_APPLY); + Matrix_Translate(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -687,12 +687,12 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1A0 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { - Matrix_MultiplyVector3fByState(&this->unk_1A0[i], &this->unk_1A4[i]); + Matrix_MultVec3f(&this->unk_1A0[i], &this->unk_1A4[i]); } - Matrix_MultiplyVector3fByState(&sp50, &this->unk_204); + Matrix_MultVec3f(&sp50, &this->unk_204); } - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 3e67b4db6..d8b4296cb 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -620,14 +620,14 @@ void EnMinifrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index 8c20b4106..b0e468ab2 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -474,7 +474,7 @@ void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnMk* this = THIS; if (limbIndex == OBJECT_MK_LIMB_0B) { - Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8095A2A0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 5f79cf9e4..7cdddfcfd 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -212,9 +212,9 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_190 != 0) { s16 rotY = this->actor.world.rot.y - this->actor.shape.rot.y; - Matrix_RotateY(rotY, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_190, MTXMODE_APPLY); - Matrix_RotateY(-rotY, MTXMODE_APPLY); + Matrix_RotateYS(rotY, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_190, MTXMODE_APPLY); + Matrix_RotateYS(-rotY, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_055628); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 393b253a9..6ee806d2e 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -534,7 +534,7 @@ s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, rot->x += this->unk_2A0.y; rot->z += this->unk_2A0.x; if ((this->unk_2B0 & 2) && ((globalCtx->gameplayFrames % 3) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } return false; @@ -544,7 +544,7 @@ void EnMm3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnMm3* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80A704F0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A704F0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 60de87422..4afae5793 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -106,7 +106,7 @@ static InitChainEntry sInitChain[] = { static f32 D_80A6BA14[] = { 0.06f, 0.1f, 0.13f }; void func_80A687A0(EnMushi2* this) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] += this->unk_348 * this->unk_31C.x; matrix->mf[3][1] += this->unk_348 * this->unk_31C.y; @@ -114,8 +114,8 @@ void func_80A687A0(EnMushi2* this) { } void func_80A68808(EnMushi2* this) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -283,12 +283,12 @@ void func_80A68ED8(EnMushi2* this) { } void func_80A68F24(EnMushi2* this) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80A6B9A0, &this->unk_310); - Matrix_MultiplyVector3fByState(&D_80A6B9AC, &this->unk_31C); - Matrix_MultiplyVector3fByState(&D_80A6B9B8, &this->unk_328); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80A6B9A0, &this->unk_310); + Matrix_MultVec3f(&D_80A6B9AC, &this->unk_31C); + Matrix_MultVec3f(&D_80A6B9B8, &this->unk_328); } s32 func_80A68F9C(EnMushi2* this, s16 arg1) { @@ -298,7 +298,7 @@ s32 func_80A68F9C(EnMushi2* this, s16 arg1) { return false; } - matrix = Matrix_GetCurrentState(); + matrix = Matrix_GetCurrent(); matrix->mf[0][0] = this->unk_310.x; matrix->mf[0][1] = this->unk_310.y; @@ -320,7 +320,7 @@ s32 func_80A68F9C(EnMushi2* this, s16 arg1) { matrix->mf[3][2] = 0.0f; matrix->mf[3][3] = 0.0f; - Matrix_RotateY(arg1, MTXMODE_APPLY); + Matrix_RotateYS(arg1, MTXMODE_APPLY); this->unk_310.x = matrix->mf[0][0]; this->unk_310.y = matrix->mf[0][1]; @@ -345,7 +345,7 @@ s32 func_80A690C4(EnMushi2* this, s16 arg1) { return false; } - matrix = Matrix_GetCurrentState(); + matrix = Matrix_GetCurrent(); matrix->mf[0][0] = this->unk_310.x; matrix->mf[0][1] = this->unk_310.y; @@ -367,7 +367,7 @@ s32 func_80A690C4(EnMushi2* this, s16 arg1) { matrix->mf[3][2] = 0.0f; matrix->mf[3][3] = 0.0f; - Matrix_InsertXRotation_s(arg1, MTXMODE_APPLY); + Matrix_RotateXS(arg1, MTXMODE_APPLY); this->unk_310.x = matrix->mf[0][0]; this->unk_310.y = matrix->mf[0][1]; @@ -435,7 +435,7 @@ void func_80A69388(EnMushi2* this) { D_80A6B9C4.mf[2][1] = this->unk_328.y; D_80A6B9C4.mf[2][2] = this->unk_328.z; - func_8018219C(&D_80A6B9C4, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&D_80A6B9C4, &this->actor.world.rot, false); this->actor.shape.rot = this->actor.world.rot; } diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index e3be9ae03..493666856 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -1033,11 +1033,11 @@ void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { isMaterialApplied++; } - Matrix_InsertTranslation(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(feather->zRot, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZF(feather->zRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 3eed47b71..87100d17f 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -112,7 +112,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((player->currentShield == PLAYER_SHIELD_HEROS_SHIELD) && (this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_TYPE_ENEMY) && (this->collider.base.atFlags & AT_BOUNCED)) { EnNutsball_InitColliderParams(this); - func_8018219C(&player->shieldMf, &worldRot, 0); + Matrix_MtxFToYXZRot(&player->shieldMf, &worldRot, false); this->actor.world.rot.y = BINANG_ROT180(worldRot.y); this->timer = 20; } else { @@ -171,8 +171,8 @@ void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 30d9a1666..20c0dd19d 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -505,7 +505,7 @@ void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnOsk* this = THIS; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80BF7024, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BF7024, &this->actor.focus.pos); } } @@ -539,8 +539,8 @@ void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { sp80.y = -(Math_SinS(sp60) * 15.0f); sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); - Matrix_InsertTranslation(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, - sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + Matrix_Translate(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, + sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); sp80.z = Math_SinS(globalCtx->gameplayFrames << 0xE); sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 48a87b30e..90cd6785f 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -854,7 +854,7 @@ s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnOsn* this = (EnOsn*)thisx; if (this->unk_1F0 && limbIndex == 11) { - Matrix_InsertXRotation_s(this->unk_1D8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1D8.y, MTXMODE_APPLY); } if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { *dList = NULL; @@ -868,18 +868,18 @@ void EnOsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3s sp28 = { 0x9920, -0x384, -0x320 }; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sp30, &thisx->focus.pos); + Matrix_MultVec3f(&sp30, &thisx->focus.pos); } if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { - Matrix_StatePush(); - Matrix_InsertTranslation(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp28.x, MTXMODE_APPLY); - Matrix_RotateY(sp28.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp28.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); + Matrix_RotateXS(sp28.x, MTXMODE_APPLY); + Matrix_RotateYS(sp28.y, MTXMODE_APPLY); + Matrix_RotateZS(sp28.z, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); - Matrix_StatePop(); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index a1c276cad..ff85b7625 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1673,7 +1673,7 @@ s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb EnOssan* this = THIS; if (limbIndex == FSN_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } return false; } @@ -1683,8 +1683,8 @@ s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIn EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); + Matrix_RotateXS(this->headRotPartTimeWorker.y, MTXMODE_APPLY); + Matrix_RotateZS(this->headRotPartTimeWorker.x, MTXMODE_APPLY); } return false; } @@ -1705,7 +1705,7 @@ void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 7573947e6..8ef3e1bfc 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -181,8 +181,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { &bgId, &this->actor.world.pos) + 50.0f; if (gSaveContext.save.weekEventReg[84] & 0x10) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(52.519997f, &sp64); Math_Vec3f_Sum(&this->actor.world.pos, &sp64, &sp64); this->unk_360 = (EnOt*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, sp64.x, sp64.y, sp64.z, 0, BINANG_ROT180(this->actor.shape.rot.y), 1, @@ -206,8 +206,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { } else if ((D_80B5E888 != NULL) && (D_80B5E888->unk_32C & 1)) { this->unk_360 = D_80B5E888; this->unk_360->unk_360 = this; - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(800.0f, &sp58); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(800.0f, &sp58); Math_Vec3f_Sum(&this->actor.world.pos, &sp58, &sp58); Math_Vec3f_Copy(&this->unk_360->actor.world.pos, &sp58); Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &sp58); @@ -354,8 +354,8 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { if (Actor_DistanceBetweenActors(&this->actor, &this->unk_360->actor) <= 52.519997f) { this->unk_73C = 50; - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp34); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(52.519997f, &sp34); this->unk_360->actor.world.pos.x = this->actor.world.pos.x + sp34.x; this->unk_360->actor.world.pos.y = this->actor.world.pos.y + sp34.y; this->unk_360->actor.world.pos.z = this->actor.world.pos.z + sp34.z; @@ -437,9 +437,9 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { Vec3f sp38; this->unk_3A0 += 0x2D8; - Matrix_RotateY(this->unk_3A0, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp5C); - Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp50); + Matrix_RotateYS(this->unk_3A0, MTXMODE_NEW); + Matrix_MultVecZ(26.259998f, &sp5C); + Matrix_MultVecZ(-26.259998f, &sp50); this->unk_348.x = this->unk_394.x + sp5C.x; this->unk_348.y = this->unk_394.y; this->unk_348.z = this->unk_394.z + sp5C.z; @@ -461,17 +461,17 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); sp38.x = 1.0f; sp38.y = 8.1f; sp38.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp38, &sp44); + Matrix_MultVec3f(&sp38, &sp44); Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); func_80B5DF58(this->unk_3A4, 1, &sp44, &this->actor.shape.rot, 10); sp38.x = -1.0f; sp38.y = 8.1f; sp38.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp38, &sp44); + Matrix_MultVec3f(&sp38, &sp44); Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); func_80B5DF58(this->unk_3A4, 2, &sp44, &this->actor.shape.rot, 10); } @@ -500,9 +500,9 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Vec3f sp30; sp3E = Actor_YawToPoint(&player->actor, &this->unk_394); - Matrix_RotateY(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); + Matrix_RotateYS(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); if (this->unk_33C == 2) { - Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp30); + Matrix_MultVecZ(26.259998f, &sp30); } else { if (this->unk_73C == 0) { gSaveContext.save.weekEventReg[84] |= 0x10; @@ -519,7 +519,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { } else { this->unk_73C--; } - Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp30); + Matrix_MultVecZ(-26.259998f, &sp30); } this->unk_348.x = this->unk_394.x + sp30.x; this->unk_348.y = this->unk_394.y; @@ -711,8 +711,8 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { this->unk_360 = D_80B5E888; this->unk_360->unk_360 = this; - Matrix_RotateY(this->actor.home.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(800.0f, &sp2C); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(800.0f, &sp2C); Math_Vec3f_Sum(&this->actor.world.pos, &sp2C, &this->unk_360->actor.world.pos); Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &this->unk_360->actor.world.pos); this->unk_32C &= ~0x800; @@ -1024,9 +1024,9 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; Gfx* gfx; - Matrix_StatePush(); + Matrix_Push(); func_80B5E1D8(globalCtx, this->unk_3A4, 10); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1038,7 +1038,7 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnOt_PostLimbDraw, &this->actor); - Matrix_InsertTranslation(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); + Matrix_Translate(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); Matrix_Scale(0.0882f, 0.0882f, 0.0882f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1068,11 +1068,11 @@ void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec gSPDisplayList(&gfx[0], object_ot_DL_0004A0); POLY_OPA_DISP = &gfx[1]; - Matrix_MultiplyVector3fByState(&D_80B5E410, &this->unk_74C); + Matrix_MultVec3f(&D_80B5E410, &this->unk_74C); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 1) { - Matrix_GetStateTranslation(&this->unk_378); + Matrix_MultZero(&this->unk_378); this->unk_32C |= 0x400; } } @@ -1123,8 +1123,8 @@ void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { sp54.x = arg1->unk_30; sp54.y = arg1->unk_34; sp54.z = 0.0f; - Matrix_RotateY(temp, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp54, &arg1->unk_0C); + Matrix_RotateYS(temp, MTXMODE_NEW); + Matrix_MultVec3f(&sp54, &arg1->unk_0C); Math_Vec3f_Sum(&arg1->unk_0C, &arg1->unk_50, &arg1->unk_0C); arg1->unk_4C--; } @@ -1148,8 +1148,8 @@ void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { if (globalCtx) {} } - Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_Translate(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index ab8f721ae..d324c8d92 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -1136,7 +1136,7 @@ void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 3) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } @@ -1166,9 +1166,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 500.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3D8 - 0x4000, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -500.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 500.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3D8 - 0x4000, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -500.0f, MTXMODE_APPLY); if (this->unk_3DC >= 0x20) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 06cf9b22d..e17cba0e2 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -546,7 +546,7 @@ void EnPamera_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnPamera* this = THIS; if (limbIndex == PAMERA_LIMB_HAIR) { - Matrix_MultiplyVector3fByState(&D_80BDA5F0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BDA5F0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 542238a17..86b2eb671 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -278,16 +278,16 @@ void func_8086A238(EnPametfrog* this) { MtxF unkMtx; unkMtx.xx = this->unk_2E8.x; - unkMtx.xy = this->unk_2E8.y; - unkMtx.xz = this->unk_2E8.z; - unkMtx.yx = this->unk_2DC.x; + unkMtx.yx = this->unk_2E8.y; + unkMtx.zx = this->unk_2E8.z; + unkMtx.xy = this->unk_2DC.x; unkMtx.yy = this->unk_2DC.y; - unkMtx.yz = this->unk_2DC.z; - unkMtx.zx = this->unk_2D0.x; - unkMtx.zy = this->unk_2D0.y; + unkMtx.zy = this->unk_2DC.z; + unkMtx.xz = this->unk_2D0.x; + unkMtx.yz = this->unk_2D0.y; unkMtx.zz = this->unk_2D0.z; - func_8018219C(&unkMtx, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&unkMtx, &this->actor.shape.rot, false); this->actor.world.rot.x = -this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.z = this->actor.shape.rot.z; @@ -315,8 +315,8 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { Math3D_CrossProduct(&this->unk_2DC, &floorNorm, &vec2); EnPametfrog_Vec3fNormalize(&vec2); - Matrix_InsertRotationAroundUnitVector_f(rotation, &vec2, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_2E8, &vec2); + Matrix_RotateAxisF(rotation, &vec2, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_2E8, &vec2); Math_Vec3f_Copy(&this->unk_2E8, &vec2); Math3D_CrossProduct(&this->unk_2E8, &floorNorm, &this->unk_2D0); EnPametfrog_Vec3fNormalize(&this->unk_2D0); @@ -683,8 +683,8 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_2D0, &vec); + Matrix_RotateAxisF(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_2D0, &vec); Math_Vec3f_Copy(&this->unk_2D0, &vec); Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); @@ -1395,9 +1395,9 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi s8 index; if (limbIndex == GEKKO_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); this->actor.focus.rot.y = this->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledY(2500.0f, &vec); + Matrix_MultVecY(2500.0f, &vec); center = &this->collider.elements[0].dim.worldSphere.center; center->x = vec.x; center->y = vec.y; @@ -1410,7 +1410,7 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi index = limbPosIndex[limbIndex]; if (index != -1) { - Matrix_GetStateTranslation(&this->limbPos[index]); + Matrix_MultZero(&this->limbPos[index]); } } @@ -1418,7 +1418,7 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { EnPametfrog* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); + Matrix_RotateYS(this->spinYaw, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnPametfrog_PostLimbDraw, &this->actor); Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 2b21f3ea3..1a10575cf 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -68,9 +68,9 @@ typedef struct EnPametfrog { /* 0x2C4 */ f32 drawDmgEffAlpha; /* 0x2C8 */ f32 drawDmgEffScale; /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz - /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? - /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz + /* 0x2D0 */ Vec3f unk_2D0; // MtxF xz/yz/zz + /* 0x2DC */ Vec3f unk_2DC; // MtxF xy/yy/zy: wallNorm/floorNorm/Base of Gekko walking??? + /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/yx/zx /* 0x2F4 */ Vec3f limbPos[12]; /* 0x384 */ ColliderJntSph collider; /* 0x3A4 */ ColliderJntSphElement colElement[2]; diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index a5321bf26..708bae3ef 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -843,19 +843,19 @@ s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); Gfx* gfx = POLY_OPA_DISP; - Matrix_StatePush(); - Matrix_RotateStateAroundXAxis(this->unk_2BC * 0.115f); - Matrix_InsertYRotation_f(this->unk_2BC * 0.13f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(this->unk_2BC * 0.1f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXFApply(this->unk_2BC * 0.115f); + Matrix_RotateYF(this->unk_2BC * 0.13f, MTXMODE_APPLY); + Matrix_RotateZF(this->unk_2BC * 0.1f, MTXMODE_APPLY); Matrix_Scale(1.0f - this->unk_2C4, this->unk_2C4 + 1.0f, 1.0f - this->unk_2C4, MTXMODE_APPLY); - Matrix_InsertZRotation_f(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); - Matrix_InsertYRotation_f(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-(this->unk_2BC * 0.115f)); + Matrix_RotateZF(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); + Matrix_RotateYF(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); + Matrix_RotateXFApply(-(this->unk_2BC * 0.115f)); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], *dList); - Matrix_StatePop(); + Matrix_Pop(); POLY_OPA_DISP = &gfx[2]; @@ -882,31 +882,31 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->limbPos[index + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[index]); + Matrix_MultVecX(4000.0f, &this->limbPos[index + 1]); } if (limbIndex == 4) { - Matrix_GetStateTranslationAndScaledZ(5500.0f, &this->unk_2D4[0]); - Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); + Matrix_MultVecZ(5500.0f, &this->unk_2D4[0]); + Matrix_MultVecZ(-5500.0f, &this->unk_2D4[1]); } else if ((limbIndex == 3) && (thisx->params == 0)) { Vec3f* vec = &D_80899570[0]; Vec3f* vec2 = &this->limbPos[12]; for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec, vec2); + Matrix_MultVec3f(vec, vec2); } - Matrix_GetStateTranslationAndScaledX(3000.0f, vec2++); - Matrix_GetStateTranslationAndScaledX(-400.0f, vec2); + Matrix_MultVecX(3000.0f, vec2++); + Matrix_MultVecX(-400.0f, vec2); OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_InsertTranslation(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); Collider_UpdateSphere(0, &this->colliderSphere); - Matrix_InsertTranslation(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(3.2f, MTXMODE_APPLY); + Matrix_Translate(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYF(3.2f, MTXMODE_APPLY); Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -932,11 +932,11 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.params == 0) ? EnPeehat_PostLimbDraw : NULL, &this->actor); if ((this->actor.speedXZ != 0.0f) || (this->actor.velocity.y != 0.0f)) { - Matrix_GetStateTranslationAndScaledZ(4500.0f, &sp40); - Matrix_GetStateTranslationAndScaledZ(-4500.0f, &sp4C); - Matrix_GetStateTranslationAndScaledX(4500.0f, &sp58); + Matrix_MultVecZ(4500.0f, &sp40); + Matrix_MultVecZ(-4500.0f, &sp4C); + Matrix_MultVecX(4500.0f, &sp58); Collider_SetTrisVertices(&this->colliderTris, 0, &sp40, &sp4C, &sp58); - Matrix_GetStateTranslationAndScaledX(-4500.0f, &sp58); + Matrix_MultVecX(-4500.0f, &sp58); Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index b19f64c4d..bc41461d9 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1038,7 +1038,7 @@ s32 func_80AF87C4(EnPm* this, GlobalContext* globalCtx) { } void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { - Matrix_StatePush(); + Matrix_Push(); switch (arg2) { case 0: @@ -1060,7 +1060,7 @@ void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { break; } - Matrix_StatePop(); + Matrix_Pop(); } void func_80AF898C(EnPm* this) { @@ -1150,7 +1150,7 @@ void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { this->unk_360 = 0.0f; } Math_SmoothStepToF(&this->unk_364, this->unk_360, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_388 = sp28; } @@ -2116,7 +2116,7 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec switch (limbIndex) { case 15: if (ActorCutscene_GetCurrentIndex() == -1) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->actor.focus.pos); + Matrix_MultVec3f(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } if ((this->unk_356 & 0x8000) && !(gSaveContext.save.weekEventReg[90] & 4)) { @@ -2132,10 +2132,10 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec case 8: if ((this->unk_258 == 9) || (this->unk_258 == 20) || (this->unk_258 == 21) || (this->unk_258 == 22)) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); + Matrix_MultVec3f(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } else if (this->unk_258 == 24) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); + Matrix_MultVec3f(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } func_80AF8890(this, gfx, 2); @@ -2163,13 +2163,13 @@ void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this if (limbIndex == 15) { SubS_UpdateLimb(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, &this->unk_290, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_290.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_290.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_290.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_290.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index d6c9d7065..42fd2b418 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -288,10 +288,10 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL yScale = yScale * yScale; xRot = ((Math_SinS(this->randXZRotChange) * 2730.0f)); zRot = ((Math_CosS(this->randXZRotChange) * 2730.0f)); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); Matrix_Scale(xScale, yScale, zScale, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-zRot, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-xRot, MTXMODE_APPLY); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); + Matrix_RotateXS(-xRot, MTXMODE_APPLY); } else if (limbIndex == 3) { rot->y += this->limb3Rot; } else if (limbIndex == 6) { diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 29dc269d4..bb128935d 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -1057,14 +1057,14 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi f32 temp_f2; if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80B1DB08[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80B1DB08[limbIndex]]); } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->limbPos[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->limbPos[5]); + Matrix_MultVecY(-2500.0f, &this->limbPos[4]); + Matrix_MultVecY(3000.0f, &this->limbPos[5]); } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->limbPos[6]); + Matrix_MultVecY(-4000.0f, &this->limbPos[6]); } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[7]); + Matrix_MultVecX(3000.0f, &this->limbPos[7]); } if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { @@ -1078,7 +1078,7 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi this->unk_22C[end] = this->unk_22C[end - 1]; } - Matrix_MultiplyVector3fByState(&D_80B1DAFC, this->unk_22C); + Matrix_MultVec3f(&D_80B1DAFC, this->unk_22C); } if (this->unk_190 > 0) { @@ -1100,7 +1100,7 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } if (!(this->unk_191 & 0x80)) { - Matrix_CopyCurrentState(&this->unk_358); + Matrix_Get(&this->unk_358); } } } @@ -1136,7 +1136,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (!(this->unk_191 & 0x80)) { - Matrix_SetCurrentState(&this->unk_358); + Matrix_Put(&this->unk_358); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_po_sisters_DL_0027B0); @@ -1163,8 +1163,8 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); - Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_InsertRotation(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); + Matrix_RotateZYX(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); if (this->actionFunc == func_80B1BA90) { f32 phi_f0; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 22f590c44..478c306b0 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -567,9 +567,9 @@ void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B2F328; this->actor.draw = func_80B2F37C; this->actor.shape.shadowDraw = NULL; - this->actor.world.pos.x = this->unk_3D8.wx; - this->actor.world.pos.y = this->unk_3D8.wy; - this->actor.world.pos.z = this->unk_3D8.wz; + this->actor.world.pos.x = this->unk_3D8.xw; + this->actor.world.pos.y = this->unk_3D8.yw; + this->actor.world.pos.z = this->unk_3D8.zw; Actor_SetScale(&this->actor, 0.01f); this->actor.flags |= ACTOR_FLAG_10; this->actor.gravity = -1.0f; @@ -888,7 +888,7 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Matrix_Scale(0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, MTXMODE_APPLY); } - Matrix_CopyCurrentState(&this->unk_3D8); + Matrix_Get(&this->unk_3D8); func_80B2C910(&sp60, globalCtx); Lights_PointGlowSetInfo(&this->lightInfo, this->colliderSph.elements[0].dim.worldSphere.center.x + (s32)sp60.x, this->colliderSph.elements[0].dim.worldSphere.center.y + (s32)sp60.y, @@ -899,19 +899,19 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - Matrix_GetStateTranslation(&this->limbPos[temp_s3]); + Matrix_MultZero(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[temp_s3]); + Matrix_MultVecX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->limbPos[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[temp_s3 + 1]); + Matrix_MultVecX(-2000.0f, &this->limbPos[temp_s3]); + Matrix_MultVecY(-2000.0f, &this->limbPos[temp_s3 + 1]); for (i = temp_s3 + 2; i < ARRAY_COUNT(this->limbPos); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec2, vec); + Matrix_MultVec3f(vec2, vec); } } } @@ -952,7 +952,7 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(&gfx[0]); gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); - Matrix_SetCurrentState(&this->unk_3D8); + Matrix_Put(&this->unk_3D8); gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[3], object_po_DL_002D28); @@ -1007,8 +1007,7 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - Matrix_InsertYRotation_f((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), - MTXMODE_APPLY); + Matrix_RotateYF((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 8c5d417f3..8f3a30d75 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -574,13 +574,13 @@ void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnPr* this = THIS; if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp24, &this->unk_2D4); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp24, &this->unk_2D4); } if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { - Matrix_GetStateTranslation(&this->limbPos[this->unk_228]); + Matrix_MultZero(&this->limbPos[this->unk_228]); this->unk_228++; if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { this->unk_228 = 0; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 6bb60f174..797433892 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -710,10 +710,10 @@ void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (this->unk_1E0 < 10) { if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_270); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_270); } - Matrix_GetStateTranslation(&this->unk_234[limbIndex]); + Matrix_MultZero(&this->unk_234[limbIndex]); } } diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 797d898ac..99cc24158 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -494,8 +494,8 @@ void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnPrz* this = THIS; if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp1C, &this->unk_1CC); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp1C, &this->unk_1CC); } } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index e6fb2535a..cf6b1d63f 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -713,8 +713,8 @@ void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); EnRacedog_UpdateSelectionArrow(this); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, - this->actor.world.pos.z, &rotation); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, + &rotation); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->selectionArrowGreenPrimColor, 0, 255); @@ -740,7 +740,7 @@ void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&focusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&focusOffset, &this->actor.focus.pos); } if (limbIndex == DOG_LIMB_TAIL) { @@ -787,10 +787,10 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->curRot.x); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateXFApply(this->curRot.x); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRacedog_OverrideLimbDraw, EnRacedog_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index 4d880a389..fb3b1070e 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -829,13 +829,13 @@ void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* th // These matrix operations make the trap petals look a bit more "wobbly" as it chews // by stretching the limbs in various random directions. if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { - Matrix_RotateY((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_InsertXRotation_s((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_InsertZRotation_s((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateYS((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateZS((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_InsertXRotation_s(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_RotateY(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateZS(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateYS(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); } break; @@ -948,11 +948,11 @@ void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isVisible) { - Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); - Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index e1971c182..99d30f14c 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -1099,9 +1099,9 @@ s32 EnRailSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL } else if (limbIndex == 10) { Vec3f sp24 = { 0.0f, 1000.0f, 0.0f }; - Matrix_MultiplyVector3fByState(&sp24, &this->actor.focus.pos); + Matrix_MultVec3f(&sp24, &this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3FA == 1)) { - Matrix_InsertZRotation_s(1820, MTXMODE_APPLY); + Matrix_RotateZS(1820, MTXMODE_APPLY); } if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_402 & 2)) { @@ -1129,10 +1129,10 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80B734D0, &this->limbPos[this->limbCount]); this->limbCount++; } } diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index 70d9fb708..ba6043f52 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -1060,7 +1060,7 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 0326c13b7..c24a5e5a9 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1317,7 +1317,7 @@ void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec (limbIndex == REDEAD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == REDEAD_LIMB_RIGHT_FOREARM) || (limbIndex == REDEAD_LIMB_RIGHT_HAND) || (limbIndex == REDEAD_LIMB_HEAD) || (limbIndex == REDEAD_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 56846543e..13ab86f52 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -196,8 +196,8 @@ void EnRecepgirl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->headRot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->headRot.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index a75e0f489..c5f2954f9 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -175,7 +175,7 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { phi_fp = true; } - Matrix_StatePush(); + Matrix_Push(); if (globalCtx) {} temp_f20 = (f32)ptr->unk_02 / ptr->unk_01; @@ -185,9 +185,9 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80BF5960[ptr->unk_00 - 4].r, D_80BF5960[ptr->unk_00 - 4].g, D_80BF5960[ptr->unk_00 - 4].b, 0); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -195,7 +195,7 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF5934[idx])); gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -804,14 +804,14 @@ void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 4bd5bcf32..2ad27aab5 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -887,7 +887,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (this->unk_1E8 * 0) & 0x7F, (this->unk_1E8 * 0) & 0x3F, 0x20, 0x10, 1, (this->unk_1E8 * 0) & 0x3F, (this->unk_1E8 * -6) & 0x7F, 0x20, 0x10)); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); @@ -895,38 +895,38 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); - Matrix_StatePop(); + Matrix_MultVecZ(1842.1053f, vecPtr++); + Matrix_MultVecZ(-1842.1053f, vecPtr++); + Matrix_MultVecX(1842.1053f, vecPtr++); + Matrix_MultVecX(-1842.1053f, vecPtr++); + Matrix_Pop(); for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { temp_f20 = this->unk_324[i].unk_08 * (this->unk_324[i].unk_10 + 1.0f); ptr = &this->unk_324[i]; - Matrix_InsertTranslation(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertRotation(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Translate(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); + Matrix_Push(); Matrix_Scale(temp_f20, 1.0f, temp_f20, MTXMODE_APPLY); Matrix_ToMtx(matrix); if ((i & 1) != 0) { - Matrix_RotateY(0x2000, MTXMODE_APPLY); + Matrix_RotateYS(0x2000, MTXMODE_APPLY); } - Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); - Matrix_StatePop(); + Matrix_MultVecZ(1842.1053f, vecPtr++); + Matrix_MultVecZ(-1842.1053f, vecPtr++); + Matrix_MultVecX(1842.1053f, vecPtr++); + Matrix_MultVecX(-1842.1053f, vecPtr++); + Matrix_Pop(); matrix++; if (i == 3) { - Matrix_GetStateTranslation(&spA4); + Matrix_MultZero(&spA4); } } - Matrix_GetStateTranslation(&this->unk_228); + Matrix_MultZero(&this->unk_228); this->collider2.dim.pos.x = ((this->unk_228.x - spA4.x) * 0.85f) + spA4.x; this->collider2.dim.pos.y = ((this->unk_228.y - spA4.y) * 0.85f) + spA4.y; this->collider2.dim.pos.z = ((this->unk_228.z - spA4.z) * 0.85f) + spA4.z; diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index cb110f780..3a29b5081 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -68,7 +68,7 @@ s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnRsn* this = THIS; if (limbIndex == 14) { - Matrix_InsertXRotation_s(this->unk1D8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk1D8.y, MTXMODE_APPLY); } return false; } @@ -80,7 +80,7 @@ void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = D_80C26028; if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index d522a4751..3f0ae6154 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -817,7 +817,7 @@ void EnScopenuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto } if (limbIndex == 24) { - Matrix_RotateY(this->unk_340, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_340, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 0103b1d62..fc4f91308 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -138,7 +138,7 @@ void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; } - Matrix_MultiplyVector3fByState(&sp88, &sp7C); + Matrix_MultVec3f(&sp88, &sp7C); sp7C.x *= (1.0f + (BREG(49) / 100.0f)); sp7C.y *= (1.0f + (BREG(49) / 100.0f)); temp_t0 = sp7C.x + 32.0f; @@ -240,7 +240,7 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } } - Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); for (i = 0; i < 18; i++) { if (D_80947AFC[i] >= 0) { @@ -258,31 +258,31 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } if (this->actor.params != ENSDA_1) { - func_8018219C(&player->shieldMf, &sp178, false); + Matrix_MtxFToYXZRot(&player->shieldMf, &sp178, false); sp178.y += (KREG(87) * 0x8000) + 0x8000; sp178.x *= (KREG(88) - 1); - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80947A60, &sp16C); - Matrix_RotateY(sp178.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(sp178.x, MTXMODE_APPLY); + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + Matrix_MultVec3f(&D_80947A60, &sp16C); + Matrix_RotateYS(sp178.y, MTXMODE_NEW); + Matrix_RotateXS(sp178.x, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_MultiplyVector3fByState(&D_80947B10[i], &sp188); + Matrix_MultVec3f(&D_80947B10[i], &sp188); sp64[i].x = (((KREG(82) / 100.0f) + 4.0f) * sp188.x) + sp16C.x; sp64[i].y = (((KREG(82) / 100.0f) + 4.0f) * sp188.y) + sp16C.y; sp64[i].z = (((KREG(82) / 100.0f) + 4.0f) * sp188.z) + sp16C.z; } - Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); for (i = 0; i < 22; i++) { sp194.x = sp64[i].x - player->actor.world.pos.x; sp194.y = sp64[i].y - player->actor.world.pos.y + KREG(80) + 16.0f; sp194.z = sp64[i].z - player->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp194, &sp188); + Matrix_MultVec3f(&sp194, &sp188); sp188.x *= (1.0f + (KREG(90) / 100.0f)); sp188.y *= (1.0f + (KREG(90) / 100.0f)); @@ -328,16 +328,15 @@ void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); - Matrix_InsertTranslation(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_Translate(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYF(BREG(51) / 100.0f, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, (BREG(63) / 10.0f) + 1.0f, MTXMODE_APPLY); tempx = (BREG(62) / 10.0f) + 2.0f; tempz = ((player->actor.world.pos.y - player->actor.floorHeight + BREG(54)) * (BREG(55) - 5) / 10.0f) + BREG(58) - 20.0f; - Matrix_InsertTranslation(tempx, 0.0f, tempz, MTXMODE_APPLY); + Matrix_Translate(tempx, 0.0f, tempz, MTXMODE_APPLY); Matrix_Scale(((BREG(56) - 250) / 1000.0f) + 0.6f, 1.0f, ((BREG(59) - 250) / 1000.0f) + 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 5735d1e28..0d53b127e 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -1101,7 +1101,7 @@ s32 EnSellnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 24) { - Matrix_InsertXRotation_s(this->unk_342, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_342, MTXMODE_APPLY); } if (limbIndex == 26) { @@ -1131,7 +1131,7 @@ void EnSellnuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor } if (limbIndex == 24) { - Matrix_RotateY(this->unk_344, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_344, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 808f38d5a..0b9905ba5 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -184,7 +184,7 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { tempMsgState = Message_GetState(&globalCtx->msgCtx); this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); + Matrix_Translate(this->unk_2D4, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && (tempMsgState == 3) && (this->msgState == 3)) { @@ -396,7 +396,7 @@ s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == BURLY_GUY_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); + Matrix_MultVec3f(&D_80AE7270, &thisx->focus.pos); Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); } } @@ -419,15 +419,15 @@ void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } if (limbIndex == BURLY_GUY_LIMB_HEAD) { - SubS_UpdateLimb((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, + SubS_UpdateLimb(this->unk_2BA + 0x4000, this->unk_2BC + this->actor.shape.rot.y + 0x4000, &this->unk_1E8, &this->unk_1F4, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); - Matrix_RotateY(this->unk_1F4.y, 1); - Matrix_InsertXRotation_s(this->unk_1F4.x, 1); - Matrix_InsertZRotation_s(this->unk_1F4.z, 1); - Matrix_StatePush(); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1F4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1F4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1F4.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index f7fca7448..6d3a118f4 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -1087,7 +1087,7 @@ s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } return false; @@ -1112,10 +1112,10 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80997564, &this->limbPos[this->limbCount]); this->limbCount++; } } diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 683685889..ef0ad1b57 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1144,10 +1144,10 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (sLimbIndexToBodyPartsPosIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsPosIndex[limbIndex] == 4) { for (i = 0; i < 5; i++) { - Matrix_MultiplyVector3fByState(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); + Matrix_MultVec3f(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); } } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); } } @@ -1157,9 +1157,9 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList gfx = POLY_OPA_DISP; if (EN_SNOWMAN_GET_TYPE(thisx) != EN_SNOWMAN_TYPE_LARGE) { - Matrix_InsertTranslation(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); + Matrix_Translate(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); } @@ -1170,7 +1170,7 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_GetStateTranslation(&this->snowballPos); + Matrix_MultZero(&this->snowballPos); } } diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 003f731b0..08c1a8aaf 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1586,7 +1586,7 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd EnSob1* this = THIS; if (limbIndex == 15) { - Matrix_InsertXRotation_s(this->headRot, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot, MTXMODE_APPLY); } return false; } @@ -1675,7 +1675,7 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSob1_DrawStickDirectionPrompt(globalCtx, this); frames = globalCtx->gameplayFrames; func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index d880c4873..b9ccdb579 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -172,10 +172,10 @@ void EnSsh_AddBlureVertex(EnSsh* this) { p2Base.y *= this->colliderScale; p2Base.z *= this->colliderScale; - Matrix_StatePush(); - Matrix_MultiplyVector3fByState(&p1Base, &p1); - Matrix_MultiplyVector3fByState(&p2Base, &p2); - Matrix_StatePop(); + Matrix_Push(); + Matrix_MultVec3f(&p1Base, &p1); + Matrix_MultVec3f(&p2Base, &p2); + Matrix_Pop(); EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &p1, &p2); } @@ -425,11 +425,11 @@ void EnSsh_Sway(EnSsh* this) { swayVecBase.y = Math_CosS(swayAngle) * temp_f20; swayVecBase.z = 0.0f; - Matrix_StatePush(); - Matrix_InsertTranslation(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&swayVecBase, &swayVec); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); + Matrix_RotateYF(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&swayVecBase, &swayVec); + Matrix_Pop(); this->actor.shape.rot.z = -(swayAngle * 2); this->actor.world.pos.x = swayVec.x; @@ -592,11 +592,11 @@ s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { colliderOffsets[i].y *= this->colliderScale; colliderOffsets[i].z *= this->colliderScale; - Matrix_StatePush(); - Matrix_InsertTranslation(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&colliderOffsets[i], &colliderPos); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); + Matrix_MultVec3f(&colliderOffsets[i], &colliderPos); + Matrix_Pop(); this->collider1[3 + i].dim.pos.x = colliderPos.x; this->collider1[3 + i].dim.pos.y = colliderPos.y; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index a50bf92b4..e2915a614 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -247,9 +247,8 @@ void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_2C0].segment); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.06f, 0.12f, 0.06f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 82e314d60..23b1b6223 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -665,7 +665,7 @@ void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (limbIndex == 15) { s32 pad; - Matrix_MultiplyVector3fByState(&D_80B6D200, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B6D200, &this->actor.focus.pos); if (!ENSTH_GET_100(&this->actor)) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -678,16 +678,16 @@ void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (this->unk_29C & 1) { if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29F)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(0x3A98, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(0x3A98, MTXMODE_APPLY); + Matrix_Translate(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x0A, globalCtx->objectCtx.status[this->unk_29F].segment); gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); - Matrix_StatePop(); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 319cbbabd..4a7e56682 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -439,11 +439,11 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 10.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 10.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } @@ -471,11 +471,11 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 350.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 350.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } @@ -1502,15 +1502,15 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (limbIndex == 15) { *dList = object_boj_DL_00AF90; if (!(this->flags1 & 4)) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk3F2, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); @@ -1530,15 +1530,15 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (((this->flags1 & 8) && (this->flags1 & 0x10)) || ((this->flags1 & 2) && !(this->flags1 & 0x20)) || ((this->flags1 & 4) && !(this->flags1 & 0x20))) { if (limbIndex == 8) { - curState = Matrix_GetCurrentState(); - Matrix_MultiplyVector3fByState(&D_80BAE95C, &this->unk3F8); + curState = Matrix_GetCurrent(); + Matrix_MultVec3f(&D_80BAE95C, &this->unk3F8); if (this->actor.child == NULL) { if (this->flags1 & 0x100) { bombBag = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_NIMOTSU, curState->mf[3][0], curState->mf[3][1], curState->mf[3][2], 0, 0, 0, -1); if (bombBag != NULL) { - func_8018219C(curState, &bombBag->shape.rot, 0); + Matrix_MtxFToYXZRot(curState, &bombBag->shape.rot, false); } } else { func_8012C28C(globalCtx->state.gfxCtx); @@ -1550,7 +1550,7 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BAE950, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BAE950, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 512e90d4f..0188b323c 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -277,8 +277,8 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_350, &sp2C); + Matrix_RotateAxisF(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); } @@ -316,8 +316,8 @@ s32 func_808D91C4(EnSw* this, CollisionPoly* arg1) { } Math_Vec3f_Scale(&sp2C, 1.0f / temp_f0); - Matrix_InsertRotationAroundUnitVector_f(sp4C, &sp2C, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_35C, &sp2C); + Matrix_RotateAxisF(sp4C, &sp2C, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_35C, &sp2C); Math_Vec3f_Copy(&this->unk_35C, &sp2C); Math3D_CrossProduct(&this->unk_35C, &sp38, &this->unk_350); @@ -336,15 +336,15 @@ void func_808D93BC(EnSw* this) { MtxF sp18; sp18.xx = this->unk_35C.x; - sp18.xy = this->unk_35C.y; - sp18.xz = this->unk_35C.z; - sp18.yx = this->unk_368.x; + sp18.yx = this->unk_35C.y; + sp18.zx = this->unk_35C.z; + sp18.xy = this->unk_368.x; sp18.yy = this->unk_368.y; - sp18.yz = this->unk_368.z; - sp18.zx = this->unk_350.x; - sp18.zy = this->unk_350.y; + sp18.zy = this->unk_368.z; + sp18.xz = this->unk_350.x; + sp18.yz = this->unk_350.y; sp18.zz = this->unk_350.z; - func_8018219C(&sp18, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&sp18, &this->actor.world.rot, false); this->actor.world.rot.x = -this->actor.world.rot.x; } @@ -459,30 +459,30 @@ void func_808D9894(EnSw* this, Vec3f* vec) { MtxF sp1C; sp1C.xx = this->unk_35C.x; - sp1C.yx = this->unk_35C.y; - sp1C.zx = this->unk_35C.z; - sp1C.wx = 0.0f; - - sp1C.xy = this->unk_368.x; - sp1C.yy = this->unk_368.y; - sp1C.zy = this->unk_368.z; - sp1C.wy = 0.0f; - - sp1C.xz = this->unk_350.x; - sp1C.yz = this->unk_350.y; - sp1C.zz = this->unk_350.z; - sp1C.wz = 0.0f; - + sp1C.xy = this->unk_35C.y; + sp1C.xz = this->unk_35C.z; sp1C.xw = 0.0f; + + sp1C.yx = this->unk_368.x; + sp1C.yy = this->unk_368.y; + sp1C.yz = this->unk_368.z; sp1C.yw = 0.0f; + + sp1C.zx = this->unk_350.x; + sp1C.zy = this->unk_350.y; + sp1C.zz = this->unk_350.z; sp1C.zw = 0.0f; + + sp1C.wx = 0.0f; + sp1C.wy = 0.0f; + sp1C.wz = 0.0f; sp1C.ww = 0.0f; - Matrix_SetCurrentState(&sp1C); + Matrix_Put(&sp1C); sp5C.x = vec->x - this->actor.world.pos.x; sp5C.y = vec->y - this->actor.world.pos.y; sp5C.z = vec->z - this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp5C, vec); + Matrix_MultVec3f(&sp5C, vec); } s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { @@ -1317,7 +1317,7 @@ void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); } func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); + Matrix_RotateXS(-0x3C72, MTXMODE_APPLY); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 23a16debc..b45da318d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -304,12 +304,12 @@ void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Vec3f* sp1C; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); + Matrix_MultVec3f(&D_809CB0D8, &this->unk_144[0]); this->unk_144[0].y -= 20.0f; } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_TAIL)) { sp1C = &this->unk_144[(limbIndex >> 1) - 1]; - Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); + Matrix_MultVec3f(&D_809CB050, sp1C); sp1C->y -= 20.0f; } } diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 92168ef76..bd5dece41 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -423,7 +423,7 @@ void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Translate(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 52ea1d8f1..6ea613a6b 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1238,12 +1238,12 @@ s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } if (limbIndex == BURLY_GUY_LIMB_HEAD) { - Matrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); - Matrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_258.x, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_258.y, MTXMODE_APPLY); + Matrix_Translate(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == BURLY_GUY_LIMB_TORSO) { - Matrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); + Matrix_RotateXS(-this->unk_25E.y, MTXMODE_APPLY); } return false; @@ -1254,7 +1254,7 @@ void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; if (limbIndex == BURLY_GUY_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 617577884..34afad373 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -500,8 +500,8 @@ void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { NULL, &this->actor); func_8012C2DC(globalCtx->state.gfxCtx); if (this->actionFunc == func_80A365EC) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, - this->actor.world.pos.z + 20.0f, 0); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, this->actor.world.pos.z + 20.0f, + MTXMODE_NEW); if (this->unk_2AA >= 256) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index e72cb296d..0a0b3f66c 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -461,7 +461,7 @@ void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Collider_UpdateSpheres(limbIndex, &this->unk_34C); if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { - Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); + Matrix_MultVec3f(&D_80A20FD0, &sp18); this->unk_300.dim.pos.x = sp18.x; this->unk_300.dim.pos.y = sp18.y; this->unk_300.dim.pos.z = sp18.z; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 7c36af46f..5745da0fd 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -266,7 +266,7 @@ void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && @@ -577,7 +577,7 @@ void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnTab* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BE1B18, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BE1B18, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -603,13 +603,13 @@ void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) SubS_UpdateLimb(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, this->unk_200, rotStep, overrideStep); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a2324aaf6..a52c9391d 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -1173,7 +1173,7 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index b7e5588f7..0f8b56068 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -264,9 +264,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); - Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_18, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(6.0f, &ptr->unk_0C); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_18, MTXMODE_APPLY); + Matrix_MultVecZ(6.0f, &ptr->unk_0C); if (phi_s2 != NULL) { temp.x = phi_s2->x - ptr->unk_00.x; @@ -277,9 +277,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { ptr->unk_20 = Math_Atan2S(temp.x, temp.z); ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); - Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + Matrix_RotateYS(ptr->unk_20, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_MultVecZ(-20.0f, &ptr->unk_0C); if (phi_f28 >= 100000.0f) { ptr->unk_28 = 1; @@ -299,8 +299,8 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { } else { ptr->unk_1A += ptr->unk_2A; Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); - Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(ptr->unk_30, &spA4); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_NEW); + Matrix_MultVecZ(ptr->unk_30, &spA4); ptr->unk_0C.x = spA4.x; ptr->unk_0C.z = spA4.z; @@ -315,9 +315,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { ptr->unk_20 = Math_Atan2S(temp.x, temp.z); ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); - Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + Matrix_RotateYS(ptr->unk_20, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_MultVecZ(-20.0f, &ptr->unk_0C); ptr->unk_3C = ptr->unk_00.y - 1000.0f; ptr->unk_30 = 5.0f; @@ -378,9 +378,9 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); flag++; } - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_18 * -1, MTXMODE_APPLY); Matrix_Scale(1.2f, ptr->unk_2C, 1.2f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -403,9 +403,9 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_18 * -1, MTXMODE_APPLY); Matrix_Scale(1.0f, ptr->unk_2C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index e391669e5..66ee6080e 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -261,8 +261,8 @@ void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { } break; } - Matrix_RotateY(sp32, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->actor.speedXZ, &this->actor.velocity); + Matrix_RotateYS(sp32, MTXMODE_NEW); + Matrix_MultVecZ(this->actor.speedXZ, &this->actor.velocity); this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; this->unk_14E = 5; } @@ -359,9 +359,9 @@ void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { Vec3f sp90; for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(6.2831855f)); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); + Matrix_RotateYF(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(6.2831855f)); + Matrix_MultVecZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); sp90.x = this->actor.world.pos.x + spA8.x; sp90.y = this->actor.world.pos.y + spA8.y; sp90.z = this->actor.world.pos.z + spA8.z; @@ -436,13 +436,13 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { } else { this->unk_154 = 15; if (this->actionFunc != func_80BB69FC) { - Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); if ((acHitInfo->toucher.dmgFlags & 0x300000) != 0) { this->unk_154 = 10; - Matrix_GetStateTranslationAndScaledZ(-10.0f, &this->actor.velocity); + Matrix_MultVecZ(-10.0f, &this->actor.velocity); } else { this->unk_156 = 15; - Matrix_GetStateTranslationAndScaledZ(-20.0f, &this->actor.velocity); + Matrix_MultVecZ(-20.0f, &this->actor.velocity); damage = this->actor.colChkInfo.damage; this->actor.colChkInfo.health -= damage; func_80BB7398(this, globalCtx); @@ -464,10 +464,10 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { block_18: func_80BB6B80(this); this->unk_158 = 2; - Matrix_RotateY(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, - this->actor.world.pos.z - D_80BB8450->unk_6BC.z), - MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(10.0f, &this->actor.velocity); + Matrix_RotateYS(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z), + MTXMODE_NEW); + Matrix_MultVecZ(10.0f, &this->actor.velocity); this->unk_152 = Rand_ZeroFloat(100.0f) + 200.0f; } else if (D_80BB8450->unk_1F6 == 10) { Actor_MarkForDeath(&this->actor); @@ -624,13 +624,13 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { if (D_80BB8458[i] != NULL) { - Matrix_InsertTranslation(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, - D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, + D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_RotateZS(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_RotateZS(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -646,8 +646,7 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { - Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, - MTXMODE_NEW); + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -668,8 +667,8 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && (tanron2->world.pos.y <= tanron2->floorHeight)) { - Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, - MTXMODE_NEW); + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, + MTXMODE_NEW); Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index 15d307326..5e6bd32ee 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -135,9 +135,9 @@ void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { Vec3f acceleration; for (i = 0; i < 20; i++) { - Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(3.0f) + 2.0f, &velocity); + Matrix_RotateYF(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_MultVecZ(Rand_ZeroFloat(3.0f) + 2.0f, &velocity); acceleration.x = velocity.x * -0.05f; acceleration.y = velocity.y * -0.05f; acceleration.z = velocity.z * -0.05f; @@ -232,8 +232,8 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { // opposite direction and swim away. In both cases, the fish's target y-position // will be slightly above the halfway point of the water. atanTemp = Math_FAtan2F(this->targetPos.z, this->targetPos.x); - Matrix_RotateY(atanTemp, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(700.0f, &this->targetPos); + Matrix_RotateYS(atanTemp, MTXMODE_NEW); + Matrix_MultVecZ(700.0f, &this->targetPos); this->targetPos.y = 250.0f; extraScaleY = 150.0f; diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 969a87cf6..48eea6828 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -276,7 +276,7 @@ void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { EnTanron4* this = THIS; if (this->timeInfluence < 1400.0f) { - Matrix_InsertZRotation_s(this->roll, MTXMODE_APPLY); + Matrix_RotateZS(this->roll, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 85baedbc8..09da81cee 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -517,8 +517,8 @@ void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); - Matrix_InsertTranslation(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_198, MTXMODE_APPLY); + Matrix_Translate(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_198, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 7f99833b4..e3e22939f 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -145,8 +145,8 @@ void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { continue; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); @@ -182,7 +182,7 @@ void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->world.pos.y = thisx->floorHeight; func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); - func_8018219C(&sp38, &thisx->shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, true); thisx->world.rot = thisx->shape.rot; this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 78b370c3b..2efb3eb6b 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -214,7 +214,7 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) OPEN_DISPS(globalCtx->state.gfxCtx); if (ptr->unk_00 != 0) { - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); @@ -224,11 +224,11 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); } - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->state.frames * 512, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -267,20 +267,20 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); - Matrix_InsertTranslation(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + Matrix_Translate(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); } - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->state.frames * 256, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1117,10 +1117,10 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { temp_s3 += 0x1000; cos = Math_CosS(temp_s3) * this->unk_150; sin = Math_SinS(temp_s3) * this->unk_150; - Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(phi_s2, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); @@ -1131,10 +1131,10 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { temp_s4 += 0x1000; cos = Math_CosS(temp_s4) * this->unk_150; sin = Math_SinS(temp_s4) * this->unk_150; - Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(-phi_s2, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); @@ -1203,11 +1203,11 @@ void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < 51; i++) { temp_f20 = Math_CosS(phi_s2) * this->unk_150; temp_f22 = Math_SinS(phi_s2) * this->unk_150; - Matrix_InsertZRotation_s(this->unk_27E, MTXMODE_NEW); - Matrix_InsertTranslation(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_27E, MTXMODE_NEW); + Matrix_Translate(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(phi_s2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp78, MTXMODE_APPLY); + Matrix_RotateXS(phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(sp78, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); @@ -1247,10 +1247,10 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { this->unk_148 = POLY_XLU_DISP; for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { - Matrix_InsertTranslation(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_Translate(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_278, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1265,16 +1265,15 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { if (this->unk_254 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { temp_f20 = Rand_ZeroOne() * 0.0025f; - Matrix_InsertTranslation((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, - MTXMODE_NEW); + Matrix_Translate((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_278 + (i << 2), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278 + (i << 2), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index c5fda21f0..8aacf408d 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -332,7 +332,7 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { func_8012C1C0(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); @@ -348,18 +348,18 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { continue; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); } else { SkinMatrix_SetRotateYRP(&sp6C, ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z); - Matrix_InsertMatrix(&sp6C, MTXMODE_APPLY); + Matrix_Mult(&sp6C, MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); if (ptr->unk_00 == 2) { - Matrix_InsertTranslation(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); } temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); @@ -371,7 +371,7 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { if (ptr) {} - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -939,7 +939,7 @@ s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limb Vec3f sp18; if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp18); + Matrix_MultVec3f(&gZeroVec3f, &sp18); func_80AF0C30(this->unk_15C, &sp18, 0); } return true; @@ -961,15 +961,15 @@ void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_144 & 2) { - Matrix_StatePush(); - Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZYX(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); Matrix_Scale(this->unk_148.unk_08 * 100.0f, this->unk_148.unk_0C * 100.0f, this->unk_148.unk_08 * 100.0f, MTXMODE_APPLY); sp40 = this->unk_148.unk_00; AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); Gfx_DrawDListXlu(globalCtx, gameplay_keep_DL_080FC8); - Matrix_StatePop(); + Matrix_Pop(); } func_80AF14FC(globalCtx, this->unk_15C); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 5a89347e7..faeb3163e 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -1066,7 +1066,7 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E4); POLY_OPA_DISP = &gfx[2]; @@ -1098,11 +1098,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[idx]); + Matrix_MultVecX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->limbPos[idx]); + Matrix_MultZero(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[idx + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[idx + 1]); } } } @@ -1123,11 +1123,11 @@ void func_80C13354(EnThiefbird* this, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { if (ptr->unk_22 != 0) { - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_RotateY(ptr->unk_1E, MTXMODE_APPLY); - Matrix_InsertZRotation_s(ptr->unk_20, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateYS(ptr->unk_1E, MTXMODE_APPLY); + Matrix_RotateZS(ptr->unk_20, MTXMODE_APPLY); + Matrix_Translate(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(ptr->unk_18, ptr->unk_18, 1.0f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 7839e4585..153bb8722 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -1121,14 +1121,14 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (this->unk_2BA == 0) { idx = D_80896B70[limbIndex]; if (idx != -1) { - Matrix_GetStateTranslation(&this->limbPos[idx]); + Matrix_MultZero(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->limbPos[idx + 4]); + Matrix_MultVecX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80896B8C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { @@ -1137,11 +1137,11 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } else if (D_80896B8C[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - matrix = Matrix_GetCurrentState(); - matrix->wx = this->limbPos[D_80896B8C[limbIndex]].x; - matrix->wy = this->limbPos[D_80896B8C[limbIndex]].y; - matrix->wz = this->limbPos[D_80896B8C[limbIndex]].z; - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + matrix = Matrix_GetCurrent(); + matrix->xw = this->limbPos[D_80896B8C[limbIndex]].x; + matrix->yw = this->limbPos[D_80896B8C[limbIndex]].y; + matrix->zw = this->limbPos[D_80896B8C[limbIndex]].z; + Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_3A8); diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index d239a6cb7..4f61ac43f 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -1353,11 +1353,11 @@ void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->unk_2B0 != 2) { switch (limbIndex) { case 16: - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); break; case 14: - Matrix_MultiplyVector3fByState(&D_80AEFA84, &this->unk_2B4); + Matrix_MultVec3f(&D_80AEFA84, &this->unk_2B4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1384,7 +1384,7 @@ void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AEFA90[this->unk_2C2])); - Matrix_RotateY(this->unk_318, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_318, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTk_OverrideLimbDraw, EnTk_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 897a1d3ab..470f4908a 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -1697,9 +1697,9 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i Vec3s newRot; MtxF currentState; - Matrix_MultiplyVector3fByState(&zeroVec, &newPos); - Matrix_CopyCurrentState(¤tState); - func_8018219C(¤tState, &newRot, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(¤tState); + Matrix_MtxFToYXZRot(¤tState, &newRot, false); *pos = newPos; if (isFullyAwake) { newRot.x += pitch; @@ -1740,11 +1740,11 @@ void EnTrt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 21) { EnTrt_UpdateHeadPosAndRot(this->headPitch, this->headYaw, &this->headPos, &this->headRot, isFullyAwake); - Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_Translate(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.z, MTXMODE_APPLY); } } @@ -1752,11 +1752,11 @@ void EnTrt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi EnTrt* this = THIS; if (limbIndex == 21) { - Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_Translate(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 0af7ac4bb..f2b8c9138 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -854,9 +854,9 @@ void func_80AD5394(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -895,12 +895,12 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (limbIndex == 21) { func_80AD5394(this->unk_3D4, this->unk_3D6, &this->unk_3C8, &this->unk_3C2, phi_v0); - Matrix_InsertTranslation(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); + Matrix_Translate(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_3C2.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3C2.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_3C2.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); + Matrix_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3C2.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_3C2.z, MTXMODE_APPLY); + Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } } @@ -908,11 +908,11 @@ void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* th EnTrt2* this = THIS; if (limbIndex == 21) { - Matrix_InsertTranslation(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); + Matrix_Translate(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_3C2.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3C2.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_3C2.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3C2.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_3C2.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 3390b8422..d428553f8 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -176,10 +176,10 @@ void func_80A85788(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -arg0->unk_02 * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -234,8 +234,8 @@ void func_80A85BCC(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -286,7 +286,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { flag = true; } - Matrix_StatePush(); + Matrix_Push(); do { alpha = (f32)arg0->unk_02 / arg0->unk_01; @@ -303,9 +303,9 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80A8B25C[arg0->unk_00 - 3].r, D_80A8B25C[arg0->unk_00 - 3].g, D_80A8B25C[arg0->unk_00 - 3].b, 0); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -313,7 +313,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B280[idx])); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A830); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -478,7 +478,7 @@ s32 func_80A86B0C(EnTru* this, GlobalContext* globalCtx) { s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { if (this->unk_34E & 0x400) { - Matrix_StatePush(); + Matrix_Push(); func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -497,30 +497,30 @@ s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { break; } - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0020C8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (this->unk_34E & 0x800) { - Matrix_StatePush(); + Matrix_Push(); func_8012C2DC(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_001F90); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1168,13 +1168,13 @@ s32 EnTru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnTru* this = THIS; if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); Math_Vec3f_ToVec3s(&this->collider.dim.worldSphere.center, &this->actor.focus.pos); this->actor.focus.pos.x = (this->actor.focus.pos.x / 10.0f) * 10.0f; this->actor.focus.pos.y = ((this->actor.focus.pos.y + 10.0f) / 10.0f) * 10.0f; this->actor.focus.pos.z = (this->actor.focus.pos.z / 10.0f) * 10.0f; Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - Matrix_MultiplyVector3fByState(&D_80A8B3FC, &this->unk_1F8); + Matrix_MultVec3f(&D_80A8B3FC, &this->unk_1F8); } if (!(this->unk_34E & 0x200) && (limbIndex == 14)) { @@ -1217,8 +1217,8 @@ void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi if (limbIndex == 21) { SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (overrideRot) { s16 oldZ = this->unk_204.z; @@ -1226,10 +1226,10 @@ void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi this->unk_204.z = this->unk_204.x; this->unk_204.x = oldZ; } - Matrix_RotateY(this->unk_204.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_204.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_204.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_204.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_204.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_204.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index e191cc3cd..3be859a99 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -455,9 +455,9 @@ void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -479,11 +479,11 @@ s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnTruMt* this = THIS; if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_35C); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); } if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_MultiplyVector3fByState(&D_80B7765C, &this->unk_350); + Matrix_MultVec3f(&D_80B7765C, &this->unk_350); } return false; } @@ -501,11 +501,11 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, phi_v0 = 0; } func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_336.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } if (limbIndex == OBJECT_TRU_LIMB_0E) { @@ -513,11 +513,11 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_MultiplyVector3fByState(&D_80B77668, &this->unk_370); - Matrix_InsertTranslation(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_38E.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_38E.x, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80B77668, &this->unk_370); + Matrix_Translate(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateZS(this->unk_38E.z, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_38E.x, MTXMODE_APPLY); Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -525,15 +525,15 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, CLOSE_DISPS(globalCtx->state.gfxCtx); - sp54 = Matrix_GetCurrentState(); + sp54 = Matrix_GetCurrent(); if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->wx, sp54->wy, - sp54->wz, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->xw, sp54->yw, + sp54->zw, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), this->unk_38E.z, -1); } else if (!((EnJcMato*)this->actor.child)->hitFlag) { - this->actor.child->world.pos.x = sp54->wx; - this->actor.child->world.pos.y = sp54->wy; - this->actor.child->world.pos.z = sp54->wz; + this->actor.child->world.pos.x = sp54->xw; + this->actor.child->world.pos.y = sp54->yw; + this->actor.child->world.pos.z = sp54->zw; this->actor.child->world.rot = this->unk_38E; this->actor.child->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); @@ -547,11 +547,11 @@ void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t EnTruMt* this = THIS; if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_336.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index e999e5c5c..217d32540 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -614,7 +614,7 @@ void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = D_80AE11BC; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 6103cb577..77449c7a3 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -483,9 +483,9 @@ void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == OBJECT_VM_LIMB_02) { sp4C = NULL; - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledZ(1600.0f, &this->unk_228); - Matrix_GetStateTranslationAndScaledZ(this->unk_224 * 71.428566f, &this->unk_234); + Matrix_MultZero(&this->actor.focus.pos); + Matrix_MultVecZ(1600.0f, &this->unk_228); + Matrix_MultVecZ(this->unk_224 * 71.428566f, &this->unk_234); if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.focus.pos, &this->unk_234, &sp5C, &sp4C, true, true, false, true, &sp48)) { @@ -526,7 +526,7 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); gDPSetColorDither(&gfx[1], G_CD_DISABLE); - Matrix_InsertTranslation(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_Translate(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -543,9 +543,8 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); - Matrix_InsertTranslation(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, - MTXMODE_NEW); - Matrix_InsertRotation(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Translate(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); Matrix_Scale(this->unk_220, this->unk_220, this->unk_224 * 0.0015f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 1b88d692b..8ebb04c22 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -670,7 +670,7 @@ void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, &mf); - Matrix_InsertMatrix(&mf, MTXMODE_NEW); + Matrix_Mult(&mf, MTXMODE_NEW); if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { @@ -709,21 +709,21 @@ void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Gfx* gfx; if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + Matrix_MultZero(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); } if (limbIndex == WALLMASTER_LIMB_WRIST) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); } else if (limbIndex == WALLMASTER_LIMB_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_RotateY(0x2AAA, MTXMODE_APPLY); - Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateYS(0x2AAA, MTXMODE_APPLY); + Matrix_RotateZS(0xAAA, MTXMODE_APPLY); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -731,7 +731,7 @@ void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList POLY_OPA_DISP = &gfx[2]; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 51ef3ef38..4065bdf39 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -80,8 +80,8 @@ void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { Vec3f sp24; this->actor.textId = 0; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80A664FC, &sp24); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&D_80A664FC, &sp24); Math_Vec3f_Sum(&this->actor.world.pos, &sp24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.shape.rot); this->actionFunc = func_80A66278; diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 127bcc1c2..df347dc36 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -225,8 +225,8 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { } for (j = 0; j < 12; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); + Matrix_RotateYF((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); + Matrix_MultVecZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); spA4.y = Rand_ZeroFloat(4.0f) + 2.0f; func_80A58908(this, &ptr->unk_04, &spA4, ptr->unk_2A); } @@ -293,16 +293,16 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, 150); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } else { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateZF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); @@ -326,9 +326,9 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, ptr->unk_3C); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateYF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); @@ -530,18 +530,18 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (ptr->unk_01 * -20) & 0x1FF, 0x20, 0x80)); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_2A >= 2) { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } else { - Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); if ((i & 1) != 0) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -549,8 +549,8 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0043E8); if ((ptr->unk_2A & 1) == 0) { - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(ptr->unk_28, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(ptr->unk_28, MTXMODE_APPLY); Matrix_Scale(ptr->unk_2C.z, ptr->unk_2C.z, ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -610,16 +610,16 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 165, 235, 255, 128); - Matrix_StatePush(); - Matrix_StatePush(); - Matrix_StatePush(); + Matrix_Push(); + Matrix_Push(); + Matrix_Push(); if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { if (this->unk_E2C > 1.0f) { @@ -633,7 +633,7 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000420); } - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_E30 > 1.0f) { func_8012C2DC(globalCtx->state.gfxCtx); @@ -645,10 +645,10 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E30); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000730); } - Matrix_StatePop(); + Matrix_Pop(); } else { - Matrix_StatePop(); - Matrix_StatePop(); + Matrix_Pop(); + Matrix_Pop(); } if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { @@ -661,7 +661,7 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000A48); } - Matrix_StatePop(); + Matrix_Pop(); if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_780)) { func_8012C2DC(globalCtx->state.gfxCtx); @@ -690,9 +690,9 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, ptr->unk_3C); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateYF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index fdd82b864..89e765b98 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -1550,11 +1550,11 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_809942FC[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_809942FC[limbIndex]]); } if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { - Matrix_GetStateTranslationAndScaledX(1200.0f, &sp20); + Matrix_MultVecX(1200.0f, &sp20); this->collider3.dim.pos.x = sp20.x; this->collider3.dim.pos.y = sp20.y; this->collider3.dim.pos.z = sp20.z; diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d3fffb667..ddfa6af47 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -108,8 +108,8 @@ void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); if (this->dyna.actor.colChkInfo.health != 0) { Scene_SetRenderModeXlu(globalCtx, 0, 1); diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index 80dd47feb..53713bbb1 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -134,9 +134,9 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { } this->unk_16E = 0; - Matrix_StatePush(); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); if (this->unk_162 != 0) { sp44.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; @@ -144,8 +144,8 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { sp44.z = 12.0f; } - Matrix_MultiplyVector3fByState(&sp44, &this->actor.velocity); - Matrix_StatePop(); + Matrix_MultVec3f(&sp44, &this->actor.velocity); + Matrix_Pop(); this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; this->unk_168 = 50; if (this->unk_162 != 0) { @@ -202,11 +202,11 @@ void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { if (this->unk_162 == 1) { this->unk_16A = 10; - Matrix_StatePush(); - Matrix_RotateY((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; - Matrix_MultiplyVector3fByState(&sp54, &this->actor.velocity); - Matrix_StatePop(); + Matrix_MultVec3f(&sp54, &this->actor.velocity); + Matrix_Pop(); this->actor.velocity.y = 6.0f; this->actor.gravity = -0.7f; @@ -629,8 +629,7 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { if ((this->unk_162 == 0) && (this->unk_160 == 2)) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -645,7 +644,7 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { -globalCtx->state.frames & 0x7F, 0x20, 0x40, 1, globalCtx->state.frames & 0xFF, globalCtx->state.frames & 0xFF, 0x10, 0x10)); - Matrix_RotateY(0, MTXMODE_APPLY); + Matrix_RotateYS(0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); @@ -664,9 +663,8 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { if ((this->unk_162 == 0) && (this->unk_160 == 2)) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -678,11 +676,10 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames % 128, @@ -698,10 +695,9 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); - Matrix_StatePop(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-globalCtx->state.frames * 3) % 128, 0, 0x20, 0x20, 1, @@ -728,7 +724,7 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 9; i >= this->unk_16E; i--) { f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); @@ -742,11 +738,11 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); } - Matrix_InsertTranslation(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, - this->unk_178[i].z, MTXMODE_NEW); + Matrix_Translate(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, this->unk_178[i].z, + MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -754,7 +750,7 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -771,8 +767,7 @@ void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_14C + this->unk_154, this->unk_14C + this->unk_158, this->unk_14C + this->unk_15C, MTXMODE_APPLY); @@ -782,7 +777,7 @@ void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); @@ -865,8 +860,8 @@ void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, (ptr->unk_01 * 0xF) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 724d01710..b23282c31 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -430,10 +430,10 @@ void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnYb* this = THIS; if (limbIndex == YB_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80BFB2F4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BFB2F4, &this->actor.focus.pos); } if (limbIndex == YB_LIMB_LEGS_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); } } @@ -441,10 +441,10 @@ void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnYb* this = THIS; if (limbIndex == YB_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80BFB300, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BFB300, &this->actor.focus.pos); } if (limbIndex == YB_LIMB_LEGS_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); } } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 95738b211..2c5f76f2e 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -292,15 +292,15 @@ s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnZo* this = THIS; if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->upperBodyRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->upperBodyRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->upperBodyRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->upperBodyRot.x, MTXMODE_APPLY); } if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { @@ -316,16 +316,16 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; if (sBodyParts[limbIndex] >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); + Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); + Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->leftFootPos); + Matrix_MultVec3f(&zeroVec, &this->leftFootPos); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->rightFootPos); + Matrix_MultVec3f(&zeroVec, &this->rightFootPos); } } @@ -357,7 +357,7 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_InsertXRotation_s(0, 0); + Matrix_RotateXS(0, MTXMODE_NEW); for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter = 0; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 6e9ddb5c0..24b03ab5f 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -749,7 +749,7 @@ void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnZob* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BA1120, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BA1120, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 2a990bc26..925eaeec0 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -1003,12 +1003,12 @@ void EnZog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve D_80B959B8.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B959B8, &this->actor.focus.pos); } D_80B959B8.y = 0.0f; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->unk_2F0); + Matrix_MultVec3f(&D_80B959B8, &this->unk_2F0); } if ((this->unk_30A & 2) && (limbIndex == 17)) { @@ -1026,12 +1026,12 @@ void func_80B95598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* D_80B959C4.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B959C4, &this->actor.focus.pos); } D_80B959C4.y = 0.0f; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->unk_2F0); + Matrix_MultVec3f(&D_80B959C4, &this->unk_2F0); } if ((this->unk_30A & 2) && (limbIndex == 17)) { diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 61be7c8e7..b65da70e2 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -682,7 +682,7 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp4C; s32 pad2; - Matrix_StatePush(); + Matrix_Push(); sp4C = GET_ACTIVE_CAM(globalCtx)->eye; @@ -693,14 +693,14 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { sp78 = -(15.0f * Math_SinS(sp60)); sp7C = -((15.0f * Math_CosS(sp62)) * Math_CosS(sp60)); - Matrix_InsertTranslation(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, - temp_f2 = this->actor.world.pos.z + sp7C, 0); + Matrix_Translate(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, + temp_f2 = this->actor.world.pos.z + sp7C, MTXMODE_NEW); sp7C = Math_SinS(globalCtx->gameplayFrames * 0x4000); Matrix_Scale(this->actor.scale.x * (((sp7C + 1.0f) * 0.1f) + 9.0f), this->actor.scale.y * (((sp7C + 1.0f) * 0.1f) + 9.0f), - this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), 1); + this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_XLU_DISP; @@ -716,7 +716,7 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = gfx; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -726,7 +726,7 @@ void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(this->unk_1E0, this->unk_1E0, this->unk_1E0, MTXMODE_APPLY); @@ -745,7 +745,7 @@ void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, object_zoraegg_DL_005250); } - Matrix_StatePop(); + Matrix_Pop(); func_80B32F04(thisx, globalCtx); @@ -773,7 +773,7 @@ s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL } void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(arg2, arg2, arg2, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -781,7 +781,7 @@ void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -796,7 +796,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList switch (limbIndex) { case 2: temp_f20 = this->unk_1EE * 0.01f; - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -809,7 +809,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList break; case 4: - Matrix_StatePop(); + Matrix_Pop(); break; case 5: @@ -824,7 +824,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList switch (limbIndex) { case 2: temp_f20 = (this->unk_1EE * 0.005f) + 0.5f; - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(1.0f, temp_f20, temp_f20, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -849,7 +849,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); break; case 5: diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 419d3325e..0f299f255 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -693,7 +693,7 @@ void func_80BBC500(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* static Vec3f D_80BBC750 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BBC750, &thisx->focus.pos); + Matrix_MultVec3f(&D_80BBC750, &thisx->focus.pos); } } @@ -718,9 +718,9 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80BBC75C[this->unk_2AC])); - Matrix_StatePush(); - Matrix_RotateY(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateYS(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_zos_DL_0136E0); @@ -728,7 +728,7 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[4]; - Matrix_StatePop(); + Matrix_Pop(); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80BBC4E4, func_80BBC500, &this->actor); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index bfab9fcf6..1cf8ad992 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1356,15 +1356,15 @@ s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 pad; if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2C4.y, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2C4.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - Matrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2CA.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2CA.x * -1, MTXMODE_APPLY); } if (((this->unk_2F0 == 8) || (this->unk_2F0 == 9)) && @@ -1380,7 +1380,7 @@ void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnZot* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B99934, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index f593709cf..4bb5f2a5a 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -535,17 +535,17 @@ void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnZov* this = THIS; if (limbIndex == 12) { - Matrix_MultiplyVector3fByState(&D_80BD2744, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BD2744, &this->actor.focus.pos); Math_Vec3f_Copy(&this->unk_2FC, &this->actor.focus.pos); this->unk_2FC.y += 10.0f; } if (limbIndex == 18) { - Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_308); + Matrix_MultVec3f(&D_80BD2750, &this->unk_308); } if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_314); + Matrix_MultVec3f(&D_80BD2750, &this->unk_314); } } diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index ff258fc20..d29141499 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -196,7 +196,7 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_04, 1.0f, ptr->unk_04, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -227,8 +227,8 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { flag = true; } - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -260,8 +260,8 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -294,8 +294,8 @@ void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { temp_f22 = Rand_ZeroOne() * 6.28f; sp78.y = (Rand_ZeroOne() * 3.0f) + 3.0f; - sp78.x = __sinf(temp_f22) * temp_f20; - sp78.z = __cosf(temp_f22) * temp_f20; + sp78.x = sinf(temp_f22) * temp_f20; + sp78.z = cosf(temp_f22) * temp_f20; sp84 = this->actor.world.pos; sp84.x += sp78.x * 6.0f; @@ -603,7 +603,7 @@ Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BDDD4C, &thisx->focus.pos); + Matrix_MultVec3f(&D_80BDDD4C, &thisx->focus.pos); } } @@ -619,13 +619,13 @@ void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnZow* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80BDC830(this->unk_2D0, globalCtx); func_80BDC9DC(this->unk_2D0, globalCtx); func_80BDCB84(this->unk_2D0, globalCtx); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_2CE != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index c6de60ce2..eee9de294 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -399,9 +399,9 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { this->reflectIntensity = 0.0f; - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->wx, shieldMtx->wy, shieldMtx->wz, + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->xw, shieldMtx->yw, shieldMtx->zw, this->sourceEndRad, this->poolEndRad)) { - temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->zx) + SQ(shieldMtx->zy))); + temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->xz) + SQ(shieldMtx->yz))); if (temp_f0 == 0.0f) { this->reflectRange = 1.0f; } else { @@ -415,7 +415,7 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { sp4C[1] = this->poolPt.y - this->sourcePt.y; sp4C[2] = this->poolPt.z - this->sourcePt.z; - temp_f2 = (-shieldMtx->zx * sp4C[0]) - (shieldMtx->zy * sp4C[1]) - (shieldMtx->zz * sp4C[2]); + temp_f2 = (-shieldMtx->xz * sp4C[0]) - (shieldMtx->yz * sp4C[1]) - (shieldMtx->zz * sp4C[2]); if (temp_f2 < 0.0f) { temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); @@ -439,17 +439,17 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS CollisionPoly* outPoly; f32 sp60[3]; - sp60[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; sp60[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; for (i = 0; i < ARRAY_COUNT(this->shieldCorners); i++) { posA.x = - (shieldMtx->wx + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).yx); + (shieldMtx->xw + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).xy); posA.y = - (shieldMtx->wy + (this->shieldCorners[i].x * shieldMtx->xy)) + (this->shieldCorners[i].y * (*shieldMtx).yy); + (shieldMtx->yw + (this->shieldCorners[i].x * shieldMtx->yx)) + (this->shieldCorners[i].y * (*shieldMtx).yy); posA.z = - (shieldMtx->wz + (this->shieldCorners[i].x * shieldMtx->xz)) + (this->shieldCorners[i].y * (*shieldMtx).yz); + (shieldMtx->zw + (this->shieldCorners[i].x * shieldMtx->zx)) + (this->shieldCorners[i].y * (*shieldMtx).zy); posB.x = sp60[0] + posA.x; posB.y = sp60[1] + posA.y; @@ -501,25 +501,25 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe Vec3f vecA; Vec3f vecC; - spE8[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; spE8[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; - vecB.x = shieldMtx->wx; - vecB.y = shieldMtx->wy; - vecB.z = shieldMtx->wz; + vecB.x = shieldMtx->xw; + vecB.y = shieldMtx->yw; + vecB.z = shieldMtx->zw; vecD.x = spE8[0] + vecB.x; vecD.y = spE8[1] + vecB.y; vecD.z = spE8[2] + vecB.z; vecA.x = vecB.x + (shieldMtx->xx * 300.0f); - vecA.y = vecB.y + (shieldMtx->xy * 300.0f); - vecA.z = vecB.z + (shieldMtx->xz * 300.0f); + vecA.y = vecB.y + (shieldMtx->yx * 300.0f); + vecA.z = vecB.z + (shieldMtx->zx * 300.0f); vecC.x = vecD.x + (shieldMtx->xx * 300.0f); - vecC.y = vecD.y + (shieldMtx->xy * 300.0f); - vecC.z = vecD.z + (shieldMtx->xz * 300.0f); + vecC.y = vecD.y + (shieldMtx->yx * 300.0f); + vecC.z = vecD.z + (shieldMtx->zx * 300.0f); Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); @@ -547,8 +547,8 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; - sp10C.y = (shieldMtx->xy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->xz * 100.0f) + vecB.z; + sp10C.y = (shieldMtx->yx * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->zx * 100.0f) + vecB.z; sp100.x = (spE8[0] * 4.0f) + sp10C.x; sp100.y = (spE8[1] * 4.0f) + sp10C.y; @@ -556,21 +556,21 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; - reflection[i].mtx.xy = reflection[i].mtx.xz = reflection[i].mtx.xw = reflection[i].mtx.yx = - reflection[i].mtx.yz = reflection[i].mtx.yw = reflection[i].mtx.zx = reflection[i].mtx.zy = - reflection[i].mtx.zw = reflection[i].mtx.wx = reflection[i].mtx.wy = reflection[i].mtx.wz = + reflection[i].mtx.yx = reflection[i].mtx.zx = reflection[i].mtx.wx = reflection[i].mtx.xy = + reflection[i].mtx.zy = reflection[i].mtx.wy = reflection[i].mtx.xz = reflection[i].mtx.yz = + reflection[i].mtx.wz = reflection[i].mtx.xw = reflection[i].mtx.yw = reflection[i].mtx.zw = 0.0f; if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { reflection[i].mtx.xx = intersection.x - sp118.x; - reflection[i].mtx.xy = intersection.y - sp118.y; - reflection[i].mtx.xz = intersection.z - sp118.z; + reflection[i].mtx.yx = intersection.y - sp118.y; + reflection[i].mtx.zx = intersection.z - sp118.z; } - sp10C.x = (shieldMtx->yx * 100.0f) + vecB.x; + sp10C.x = (shieldMtx->xy * 100.0f) + vecB.x; sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->yz * 100.0f) + vecB.z; + sp10C.z = (shieldMtx->zy * 100.0f) + vecB.z; sp100.x = (spE8[0] * 4.0f) + sp10C.x; sp100.y = (spE8[1] * 4.0f) + sp10C.y; @@ -578,9 +578,9 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { - reflection[i].mtx.yx = intersection.x - sp118.x; + reflection[i].mtx.xy = intersection.x - sp118.x; reflection[i].mtx.yy = intersection.y - sp118.y; - reflection[i].mtx.yz = intersection.z - sp118.z; + reflection[i].mtx.zy = intersection.z - sp118.z; } } else { reflection[i].reflectionPoly = NULL; @@ -603,7 +603,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { this->reflectIntensity = 0.0f; if (!D_808E3BF0 && !this->unLit && func_80124088(globalCtx)) { - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); MirRay_SetIntensity(this, globalCtx); if (this->reflectIntensity <= 0.0f) { @@ -640,9 +640,9 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(reflection); i++) { if (reflection[i].reflectionPoly != NULL) { - Matrix_InsertTranslation(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + Matrix_Translate(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - Matrix_InsertMatrix(&reflection[i].mtx, MTXMODE_APPLY); + Matrix_Mult(&reflection[i].mtx, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 1382e3d1b..f5209c392 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -354,7 +354,7 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { u16 time; if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); func_80B9E544(this, globalCtx); if (this->unk_214 <= 0.1f) { @@ -406,9 +406,9 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sp8C); i++) { if (sp8C[i].unk_4C != NULL) { - Matrix_InsertTranslation(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_Translate(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - Matrix_InsertMatrix(&sp8C[i].unk_0C, MTXMODE_APPLY); + Matrix_Mult(&sp8C[i].unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 5237d9021..97865650d 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -123,7 +123,7 @@ void func_80ACBA10(ObjAqua* this) { func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, &sp2C); - func_8018219C(&sp2C, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp2C, &this->actor.shape.rot, false); } s32 func_80ACBA60(ObjAqua* this, GlobalContext* globalCtx) { @@ -284,12 +284,12 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { if (actionFuncTemp) { s16 rotation = Math_SinS(this->unk_198) * 8000.0f; - Matrix_InsertZRotation_s(rotation, MTXMODE_APPLY); + Matrix_RotateZS(rotation, MTXMODE_APPLY); Matrix_Scale(1.3f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(rotation * -1, MTXMODE_APPLY); + Matrix_RotateZS(rotation * -1, MTXMODE_APPLY); Matrix_Scale(10.0f / 13.0f, 1.0f, 1.0f, MTXMODE_APPLY); } - Matrix_RotateY(yaw, MTXMODE_APPLY); + Matrix_RotateYS(yaw, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 998e85d68..3e72b809e 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -346,9 +346,9 @@ void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { Vec3f sp28; sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); - Matrix_SetStateRotationAndTranslation( - (sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ((sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, + &this->dyna.actor.shape.rot); Matrix_Scale(0.014f, 0.014f, 0.014f, MTXMODE_APPLY); func_8012C28C(globalCtx->state.gfxCtx); @@ -374,7 +374,7 @@ void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, &sp48); - Matrix_SetCurrentState(&sp48); + Matrix_Put(&sp48); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index a02f7f604..3ee4be021 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -140,10 +140,10 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { Vec3f sp88; MtxF sp48; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80939018, &spAC); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80939018, &spAC); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spA0); Math_Vec3f_Diff(&this->dyna.actor.world.pos, &spAC, &sp94); @@ -154,10 +154,10 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.z = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.z) * 1.9f) + sp88.z; func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, &sp48); - Matrix_SetCurrentState(&sp48); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp48); - func_8018219C(&sp48, &this->dyna.actor.shape.rot, 0); + Matrix_Put(&sp48); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Get(&sp48); + Matrix_MtxFToYXZRot(&sp48, &this->dyna.actor.shape.rot, false); return true; } return false; @@ -948,8 +948,8 @@ void func_80938E00(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_1FE & 1) { - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); Matrix_Scale(this->unk_1B8, this->unk_1B8, this->unk_1B8, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index 14e25c57d..602311116 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -213,13 +213,13 @@ void func_80A358FC(ObjBell* this, GlobalContext* globalCtx) { } void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(thisx->world.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(thisx->world.rot.x, MTXMODE_APPLY); - Matrix_RotateY(-thisx->world.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(thisx->world.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->world.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-thisx->world.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -231,9 +231,9 @@ void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -242,7 +242,7 @@ void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35BD4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); @@ -290,9 +290,9 @@ void ObjBell_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80A35BD4(thisx, globalCtx); func_80A359B4(thisx, globalCtx); Math_Vec3s_ToVec3f(&sp30, &this->collider1.dim.modelSphere.center); - Matrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider1.dim.worldSphere.center, &sp24); Math_Vec3s_ToVec3f(&sp30, &this->collider2.dim.modelSphere.center); - Matrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp24); } diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 8a09c6f01..55304d195 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -516,7 +516,7 @@ void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { ptr = &this->unk_190[i]; if (ptr->unk_1A == 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); + Matrix_SetTranslateRotateYXZ(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index e058ec7c4..c90e5d8f8 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -137,11 +137,11 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* s16 childAngle) { Vec3f offset; - Matrix_RotateY(parentRot->y, MTXMODE_NEW); - Matrix_InsertXRotation_s(parentRot->x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(parentRot->z, MTXMODE_APPLY); - Matrix_RotateY(childAngle, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(-280.0f, &offset); + Matrix_RotateYS(parentRot->y, MTXMODE_NEW); + Matrix_RotateXS(parentRot->x, MTXMODE_APPLY); + Matrix_RotateZS(parentRot->z, MTXMODE_APPLY); + Matrix_RotateYS(childAngle, MTXMODE_APPLY); + Matrix_MultVecX(-280.0f, &offset); childPosOut->x = parentPos->x + offset.x; childPosOut->y = parentPos->y + offset.y; @@ -239,11 +239,11 @@ void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; ActorCutscene_Stop(this->cutscenes[0]); } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->rotation, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(this->unk1CC, &this->actor.world.pos); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->rotation, MTXMODE_APPLY); + Matrix_MultVecY(this->unk1CC, &this->actor.world.pos); Math_Vec3f_Sum(&this->actor.world.pos, &this->unk1C0, &this->actor.world.pos); Collider_UpdateCylinder(&this->actor, &this->collider); for (i = 0; i < 5; i++) { @@ -373,7 +373,7 @@ void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx* xlu; OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_RotateY(this->rotation, MTXMODE_APPLY); + Matrix_RotateYS(this->rotation, MTXMODE_APPLY); opa = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); gSPMatrix(&opa[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); @@ -387,11 +387,11 @@ void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { ObjChan_DrawFire(this, globalCtx); } - Matrix_StatePop(); + Matrix_Pop(); } void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { @@ -418,11 +418,11 @@ void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { sp4C = globalCtx->gameplayFrames; - Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, - MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); dl = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 573b34fdc..737f9ef46 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -554,12 +554,12 @@ void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index bec773c2f..c6eef8626 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -241,8 +241,8 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* Vec3f sp88; ObjDhouseStruct2* ptr2; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fXZByCurrentState(&D_80B13FC4, &sp94); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3fXZ(&D_80B13FC4, &sp94); sp94.y = 100.0f; func_80B12A50(ptr, ptr3, &spA0); @@ -511,9 +511,9 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { if (ptr->unk_1E >= 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, - ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); - Matrix_InsertTranslation(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, + ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); + Matrix_Translate(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -525,7 +525,7 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { if (ptr2->unk_28 > 0) { - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); Matrix_Scale(ptr2->unk_18, ptr2->unk_18, ptr2->unk_18, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index a1d149f3d..163dd851d 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -193,13 +193,13 @@ void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { for (j = 0; j < ARRAY_COUNT(vtx); j++) { - Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); } @@ -329,19 +329,19 @@ void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { gongForceX *= -1.0f; } - Matrix_StatePush(); - Matrix_InsertXRotation_s(this->gongRotation.x, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(this->gongRotation.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); - Matrix_InsertTranslation(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-position.x, -position.y, -position.z, MTXMODE_APPLY); + Matrix_Translate(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_RotateXS(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_Translate(-position.x, -position.y, -position.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); - Matrix_StatePop(); + Matrix_Pop(); } else { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 8ed237927..7d662432a 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -97,9 +97,9 @@ void func_80A349C0(ObjEntotu* this) { } void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -129,10 +129,9 @@ void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { } if (this->unk_1B8.x > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 16ac7e8e9..57964559d 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -176,7 +176,7 @@ void func_80A1B3D0(void) { } void func_80A1B840(MtxF* matrix) { - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = (f32*)&temp->mf[0]; f32* tmp2 = (f32*)&matrix->mf[0]; s32 i; @@ -208,9 +208,9 @@ void func_80A1B9CC(ObjFlowerpot* this, GlobalContext* globalCtx) { } void func_80A1BA04(ObjFlowerpot* this, Vec3f* arg1) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_MultiplyVector3fByState(&D_80A1D408, arg1); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_MultVec3f(&D_80A1D408, arg1); } void func_80A1BA44(ObjFlowerpot* this, GlobalContext* globalCtx) { @@ -404,8 +404,8 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.shape.rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); Collider_UpdateSpheres(1, &this->collider); diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 2ec24e73e..7bdaa8654 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -35,7 +35,7 @@ void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); + Matrix_RotateYS((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index d95cc0631..51f2febc7 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -86,7 +86,7 @@ s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { void func_809A91FC(MtxF* matrix) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = &temp->xx; f32* tmp2 = &matrix->xx; @@ -457,7 +457,7 @@ void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { sp70.y = ptr2->unk_0C; - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (ptr2->unk_0F & 2) { func_809A91FC(&this->unk_2F88[j]); @@ -497,7 +497,7 @@ void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { sp6C.y = ptr2->unk_0C; - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index 4b96d3a77..d3199e8d8 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -131,19 +131,19 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp3C); - Matrix_SetCurrentState(&sp3C); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Put(&sp3C); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &this->dyna.actor.shape.rot, 1); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80B155B0, &this->dyna.actor.focus.pos); + Matrix_MultVec3f(&D_80B155B0, &this->dyna.actor.focus.pos); for (i = 0; i < ARRAY_COUNT(D_80B155BC); i++) { - Matrix_MultiplyVector3fByState(&D_80B155BC[i], &this->unk_160[i]); + Matrix_MultVec3f(&D_80B155BC[i], &this->unk_160[i]); } func_80B1444C(this); @@ -386,8 +386,8 @@ void func_80B15264(ObjHakaisi* this) { s32 pad; s16 sp32 = Rand_Next(); - Matrix_InsertRotation(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80B15600, &this->unk_184); + Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultVec3f(&D_80B15600, &this->unk_184); this->dyna.actor.gravity = -1.0f; this->unk_19C = Rand_Next() >> 0x12; this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; @@ -409,13 +409,13 @@ void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->dyna.actor); } - Matrix_InsertRotationAroundUnitVector_s(this->unk_19C, &this->unk_184, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp34); + Matrix_RotateAxisS(this->unk_19C, &this->unk_184, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp34); - func_8018219C(&sp34, &this->dyna.actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp34, &this->dyna.actor.shape.rot, false); } void func_80B1544C(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index f07b9c6d4..840488810 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -91,14 +91,14 @@ void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertXRotation_s(this->headRotation.x, MTXMODE_APPLY); - Matrix_RotateY(this->headRotation.y, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(this->headRotation.x, MTXMODE_APPLY); + Matrix_RotateYS(this->headRotation.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 06293bf40..3fc7f84b1 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -439,8 +439,8 @@ void func_80A54E10(ObjHugebombiwa* this) { s32 pad; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -455,7 +455,7 @@ void func_80A54E10(ObjHugebombiwa* this) { sp84.y = (i + 1) * 10.0f; sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; - Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + Matrix_MultVec3f(&sp84, &ptr->unk_0C); ptr->unk_0C.x += this->actor.world.pos.x; ptr->unk_0C.y += this->actor.world.pos.y; @@ -471,7 +471,7 @@ void func_80A54E10(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55064; } @@ -534,8 +534,8 @@ void func_80A55310(ObjHugebombiwa* this) { s16 phi_s2; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -549,7 +549,7 @@ void func_80A55310(ObjHugebombiwa* this) { sp84.x = Math_SinS(phi_s2) * temp_f20_2; sp84.y = (i + 1) * 14.0f; sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; - Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + Matrix_MultVec3f(&sp84, &ptr->unk_0C); ptr->unk_0C.x += this->actor.world.pos.x; ptr->unk_0C.y += this->actor.world.pos.y; @@ -567,7 +567,7 @@ void func_80A55310(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55564; } @@ -671,7 +671,7 @@ void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { ptr = &this->unk_190[i]; if (ptr->unk_24 == 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); Matrix_Scale(ptr->unk_00.x, ptr->unk_00.x, ptr->unk_00.x, MTXMODE_APPLY); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -708,10 +708,10 @@ void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { continue; } - Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, - &ptr->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, + &ptr->unk_1C); Matrix_Scale(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_bombiwa_DL_0009E0); diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 582c3a299..a4db0d04e 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -866,26 +866,26 @@ void func_80A25440(ObjIceblock* this) { if (this->unk_2B0 == 3) { sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp34.x = this->unk_248.x; sp34.y = this->unk_248.y - sp24; sp34.z = this->unk_248.z; - Matrix_MultiplyVector3fByState(&sp34, &sp28); + Matrix_MultVec3f(&sp34, &sp28); sp34.x = this->dyna.actor.world.pos.x; sp34.y = this->dyna.actor.world.pos.y + sp24; sp34.z = this->dyna.actor.world.pos.z; Math_Vec3f_Sum(&sp34, &sp28, &temp_s1->world.pos); - Matrix_RotateY(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp40); - func_8018219C(&sp40, &temp_s1->shape.rot, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp40); + Matrix_MtxFToYXZRot(&sp40, &temp_s1->shape.rot, true); } else { Math_Vec3f_Sum(&this->dyna.actor.world.pos, &this->unk_248, &temp_s1->world.pos); } @@ -1534,8 +1534,8 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { ptr = &this->unk_1B4[i]; sp70.x = ptr->unk_00; sp70.y = ptr->unk_02; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp70); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp70); Matrix_Scale(ptr->unk_04, ptr->unk_08, ptr->unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1544,8 +1544,8 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_2B4, this->unk_2B4, this->unk_2B4, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index d6a2df4cf..1ca1c4b58 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -173,13 +173,13 @@ void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitTris(globalCtx, &this->colliderTris); Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { for (j = 0; j < ARRAY_COUNT(sp70); j++) { - Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); } @@ -339,14 +339,14 @@ void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { this->unk_2FC = index; this->unk_2E4 = this->unk_29C[index]; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&this->unk_2E4, &this->actor.world.pos); + Matrix_MultVec3f(&this->unk_2E4, &this->actor.world.pos); this->actor.world.pos = sp5C; this->actor.prevPos = this->actor.world.pos; - Matrix_StatePop(); + Matrix_Pop(); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); @@ -474,8 +474,8 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); } else { - Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); - Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + Matrix_RotateAxisS(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); + Matrix_Translate(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -499,10 +499,10 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - Matrix_MultiplyVector3fByState(&this->unk_29C[i], &this->unk_26C[i]); + Matrix_MultVec3f(&this->unk_29C[i], &this->unk_26C[i]); } - Matrix_MultiplyVector3fByState(&this->unk_2CC, &this->unk_2D8); + Matrix_MultVec3f(&this->unk_2CC, &this->unk_2D8); } #else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 740439ead..33cadc8f6 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -81,7 +81,7 @@ void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetRenderMode(&gfx[2], G_RM_PASS, G_RM_ZB_CLD_SURF2); gSPMatrix(&gfx[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[4], &gameplay_keep_DL_029D10[2]); - Matrix_InsertXRotation_s(-0x4000, 1); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[6], &gameplay_keep_DL_029D10[2]); POLY_XLU_DISP = &gfx[7]; diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index e9456bac1..b1d54899b 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -89,9 +89,9 @@ void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->elements); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -384,13 +384,13 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000408); @@ -420,13 +420,13 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000408); diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 546f0db16..d6d780a04 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -151,7 +151,7 @@ void ObjMoonStone_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_gi_reserve00_Matanimheader_001C60)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_gi_reserve00_DL_000D78); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_gi_reserve00_DL_000C80); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index fa3b46cf7..fac52301a 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -588,7 +588,7 @@ void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if (ObjOshihiki_MoveWithBlockUnder(this, globalCtx)) { - Matrix_InsertTranslation(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); + Matrix_Translate(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); } this->stateFlags &= ~PUSHBLOCK_MOVE_UNDER; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index ded17da2d..83e286e97 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -108,10 +108,9 @@ void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { } if (this->unk_1B8 > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 15a63746b..3979479f6 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -687,8 +687,8 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &sp98, &this->actor, &sp9C); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80B04FE4, &sp88); + Matrix_RotateZYX(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); + Matrix_MultVec3f(&D_80B04FE4, &sp88); sp84 = this->unk_20C * 60.0f * 0.9f; if (sp88.y > 0.0f) { @@ -812,7 +812,7 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { sp80.y = ptr->unk_1C.y; sp80.z = ptr->unk_1C.z; - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_0082D0); @@ -826,7 +826,7 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_Put(&sp88); Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 229cdf516..5356e2e88 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -79,9 +79,9 @@ Gfx* D_80B3A91C[] = { Vec3f D_80B3A92C = { 0.0f, 0.3f, 0.0f }; void func_80B38E20(ObjSnowball2* this) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 1981c3b30..37ceb7268 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -478,8 +478,8 @@ void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triN for (i = 0; i < sp80->unk_0F; i++) { temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; - Matrix_InsertRotationAroundUnitVector_f(temp_f2, &spAC, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&spA0, &sp94); + Matrix_RotateAxisF(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultVec3f(&spA0, &sp94); if (arg5 == 0) { spC4.x = (sp94.x * arg4) + arg3->x; @@ -571,23 +571,23 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); sp64.x = ptr->unk_10 * 1.2f; sp64.y = ptr->unk_10 * 1.2f; sp64.z = ptr->unk_10 * 1.2f; - Matrix_MultiplyVector3fByState(&sp64, &this->dyna.actor.focus.pos); - Matrix_InsertTranslation(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + Matrix_MultVec3f(&sp64, &this->dyna.actor.focus.pos); + Matrix_Translate(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); Matrix_Scale(ptr->unk_0C, ptr->unk_0C, ptr->unk_0C, MTXMODE_APPLY); - Matrix_InsertTranslation(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); + Matrix_Translate(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); for (i = 0; i < 6; i++) { element = &ptr->unk_08->elements[i]; for (j = 0; j < ARRAY_COUNT(sp70); j++) { - Matrix_MultiplyVector3fByState(&element->dim.vtx[j], &sp70[j]); + Matrix_MultVec3f(&element->dim.vtx[j], &sp70[j]); } Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index 20f4a1c50..2b15ef0b6 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -694,7 +694,7 @@ void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { sp84.z = this->dyna.actor.shape.rot.z; for (i = 0; i < phi_s4; i++) { - Matrix_SetStateRotationAndTranslation(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_SetTranslateRotateYXZ(phi_f22, temp_f30, phi_f24, &sp84); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index ceb35bc7e..8b61f265b 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -208,10 +208,10 @@ void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, Col Collider_InitJntSph(globalCtx, &this->colliderJntSph); Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); - Matrix_SetStateRotationAndTranslation(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_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_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->colliderJntSph); } @@ -224,20 +224,20 @@ void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, Colli Collider_InitTris(globalCtx, &this->colliderTris); Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(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_Push(); + 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); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { if (this) {} for (j = 0; j < ARRAY_COUNT(vtx); j++) { - Matrix_MultiplyVector3fByState(&init->elements[i].dim.vtx[j], &vtx[j]); + Matrix_MultVec3f(&init->elements[i].dim.vtx[j], &vtx[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); } - Matrix_StatePop(); + Matrix_Pop(); } Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { @@ -640,15 +640,15 @@ s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { Vec3f sp2C; Vec3f sp20; - Matrix_StatePush(); - Matrix_RotateY(acActor->world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(acActor->world.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, &sp2C); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, &sp20); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(acActor->world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(acActor->world.rot.x, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, &sp2C); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, &sp20); + Matrix_Pop(); if ((Math3D_Parallel(&sp2C, &sp20) < COS_OF_5_PI_DIV_8)) { return true; } diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 2996ce5ae..9001ea27a 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -312,9 +312,9 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->flameTexScroll * -OBJ_SYOKUDAI_SNUFF_DEFAULT) & 0x1FF, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), - MTXMODE_APPLY); + Matrix_Translate(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), + MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index b46f2626e..1567e90cc 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -52,11 +52,11 @@ static InitChainEntry sInitChain[] = { }; void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { - MtxF* mtx = Matrix_GetCurrentState(); + MtxF* mtx = Matrix_GetCurrent(); - mtx->wx = panel->pos.x; - mtx->wy = panel->pos.y; - mtx->wz = panel->pos.z; + mtx->xw = panel->pos.x; + mtx->yw = panel->pos.y; + mtx->zw = panel->pos.z; } void ObjTokeiStep_AddQuake(ObjTokeiStep* this, GlobalContext* globalCtx) { @@ -75,13 +75,13 @@ void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, Global Vec3f dustSpawnOffset; Vec3f dustSpawnPos; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); dustSpawnOffset.y = 115.0f; dustSpawnOffset.z = -10.0f; for (i = 0; i < 7; i++) { dustSpawnOffset.x = sDustSpawnXOffsets[i]; - Matrix_MultiplyVector3fByState(&dustSpawnOffset, &dustSpawnPos); + Matrix_MultVec3f(&dustSpawnOffset, &dustSpawnPos); dustSpawnPos.x += panel->pos.x; dustSpawnPos.y += panel->pos.y; dustSpawnPos.z += panel->pos.z; @@ -96,15 +96,15 @@ void ObjTokeiStep_InitSteps(ObjTokeiStep* this) { Vec3f panelOffset; s32 pad; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); panelOffset.x = 0.0f; panelOffset.y = 0.0f; for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.z = i * -20.0f; - Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultVec3f(&panelOffset, &panel->pos); panel->posChangeY = 0.0f; panel->numBounces = 0; } @@ -115,15 +115,15 @@ void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this) { ObjTokeiStepPanel* panel; Vec3f panelOffset; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + 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); panelOffset.x = 0.0f; for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.y = sPanelXOffsets[i]; panelOffset.z = i * -20.0f; - Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultVec3f(&panelOffset, &panel->pos); } } diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 95f0eb3a8..546e29a8e 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -819,22 +819,22 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertZRotation_s(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerMinuteRingDL); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockCenterAndHandDL); - Matrix_InsertZRotation_s(-this->clockFaceRotation * 2, MTXMODE_APPLY); + Matrix_RotateZS(-this->clockFaceRotation * 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_WALL_CLOCK || OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK) { @@ -843,8 +843,8 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockFace); } - Matrix_InsertTranslation(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); - Matrix_RotateY((s16)this->sunMoonPanelRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); + Matrix_RotateYS(this->sunMoonPanelRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerSunAndMoonPanelDL); @@ -856,12 +856,12 @@ void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 gameplayFrames = globalCtx->gameplayFrames; ObjTokeidai* this = THIS; - Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -888,13 +888,13 @@ void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); - Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gClockTowerExteriorGearDL); diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index e19edead3..223ebad74 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -189,7 +189,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_000680); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_0007C8); diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 5f2aed7a9..067bd58ec 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -252,9 +252,9 @@ s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { } void func_80A3CC84(f32 arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); - matrix->wy += arg0; + matrix->yw += arg0; } void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -416,11 +416,11 @@ void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjVspinyroll* this = THIS; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_spinyroll_DL_000460); } @@ -436,11 +436,11 @@ void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(sp3C.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp3C.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp3C.x, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(sp3C.y, MTXMODE_APPLY); + Matrix_RotateZS(sp3C.z, MTXMODE_APPLY); + Matrix_RotateXS(sp3C.x, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 052d6610a..c676b4960 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -169,21 +169,21 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->dyna.actor.home.rot.x != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 200, this->dyna.actor.home.rot.x); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); - Matrix_InsertZRotation_f((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_RotateZF((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - Matrix_StatePop(); - Matrix_InsertZRotation_f((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateZF((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 3ed787918..3dfea0818 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -85,15 +85,15 @@ void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjYasi* this = THIS; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); if (this->dyna.actor.shape.rot.x != 0) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); } else { - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); } Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 324e53fee..2f976f2cc 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -268,8 +268,8 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { phi_f20 = globalCtx->envCtx.windSpeed / 120.0f; phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); + this->unk_14C[i].unk_0C += sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); + this->unk_14C[i].unk_14 += cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); @@ -431,8 +431,8 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { temp_f20 = globalCtx->envCtx.windSpeed / 120.0f; temp_f20 = CLAMP(temp_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); + this->unk_14C[i].unk_0C += sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); + this->unk_14C[i].unk_14 += cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); if ((i % 2) == 0) { this->unk_14C[i].unk_10 += this->unk_14C[i].unk_18; @@ -557,7 +557,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); } - Matrix_InsertTranslation(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); + Matrix_Translate(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); tempf = (i & 7) * 0.008f; Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY); temp_f2 = Math_Vec3f_DistXYZ(&spC4, &globalCtx->view.eye) / 300.0f; @@ -566,7 +566,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2)); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -616,7 +616,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { func_80169474(globalCtx, &spBC, &spB0); if ((spB0.x >= 0.0f) && (spB0.x < 320.0f) && (spB0.y >= 0.0f) && (spB0.y < 240.0f)) { - Matrix_InsertTranslation(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); + Matrix_Translate(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); temp_f0 = Math_Vec3f_DistXYZ(&spBC, &globalCtx->view.eye); temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f)); @@ -625,7 +625,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0); gDPSetEnvColor(POLY_XLU_DISP++, 55, 50, 255, temp_f0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -679,12 +679,12 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { continue; } - Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + Matrix_Translate(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - Matrix_RotateY((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); - Matrix_InsertXRotation_s((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_RotateYS((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_RotateXS((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); if (this->unk_114C == 0) { Matrix_Scale(0.5f, 1.0f, 0.5f, MTXMODE_APPLY); @@ -715,7 +715,7 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { continue; } - Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + Matrix_Translate(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); temp_f12 = (Rand_ZeroOne() * 0.05f) + 0.05f; Matrix_Scale(temp_f12, temp_f12, temp_f12, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index a16821f00..a54ca583c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -87,12 +87,12 @@ void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, - activeCamEye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Translate(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, activeCamEye.z + quakeOffset.z, + MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x708, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c index 29ac6b18b..a2449af92 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c @@ -66,10 +66,10 @@ void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) globalCtx->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->rRot, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->rRot, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index 41a8f92ff..6627e1c87 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -51,7 +51,7 @@ void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index d2ea02f7c..a345f0b5c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -100,9 +100,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { } } - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->rYaw, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->rPitch, MTXMODE_APPLY); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c index 26901bac5..2e8646a54 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c @@ -128,7 +128,7 @@ void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); SkinMatrix_MulYRotation(&mtx, this->rRotAngle); - Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Mult(&mtx, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); @@ -168,7 +168,7 @@ void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); SkinMatrix_MulYRotation(&mtx, this->rRotAngle); - Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Mult(&mtx, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c index d4356f90c..5d30ecf04 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c @@ -67,7 +67,7 @@ void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index d26135729..adca90668 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -46,9 +46,9 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->rYaw, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, this->rYaw, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 06cfa5b18..abcd52393 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -62,7 +62,7 @@ void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f; - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C9BC(gfxCtx); diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 0ac471162..df16aae5b 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -226,7 +226,7 @@ void Daytelop_Init(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; Game_SetFramerateDivisor(thisx, 1); - Matrix_StateAlloc(thisx); + Matrix_Init(thisx); ShrinkWindow_Destroy(); View_Init(&this->view, thisx->gfxCtx); thisx->main = Daytelop_Main; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index f0dd8190e..c705cb708 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -50,7 +50,7 @@ void Opening_Init(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; Game_SetFramerateDivisor(&this->gameState, 1); - Matrix_StateAlloc(&this->gameState); + Matrix_Init(&this->gameState); ShrinkWindow_Init(); View_Init(&this->view, this->gameState.gfxCtx); this->gameState.main = Opening_Main; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index afeafe09f..1c32f6490 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -80,9 +80,9 @@ void Title_Draw(GameState* thisx) { Title_RenderView(this, 0.0f, 150.0f, 300.0f); func_8012C28C(this->gameState.gfxCtx); - Matrix_InsertTranslation(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); + Matrix_Translate(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertRotation(0, titleRotation, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, titleRotation, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); @@ -159,7 +159,7 @@ void Title_Init(GameState* thisx) { DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); Game_SetFramerateDivisor(thisx, 1); - Matrix_StateAlloc(thisx); + Matrix_Init(thisx); ShrinkWindow_Init(); View_Init(&this->view, thisx->gfxCtx); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 017df4ba1..bdb5188e3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -251,7 +251,7 @@ 0x800880B0:("osGetIntMask",), 0x80088110:("osVoiceSetWord",), 0x800882A0:("guScale",), - 0x80088350:("__sinf",), + 0x80088350:("sinf",), 0x80088510:("sins",), 0x80088580:("_VirtualToPhysicalTask",), 0x8008868C:("osSpTaskLoad",), @@ -410,7 +410,7 @@ 0x80091AF0:("__osViInit",), 0x80091C10:("__osViSwapContext",), 0x80091F10:("osPiGetCmdQueue",), - 0x80091F40:("__cosf",), + 0x80091F40:("cosf",), 0x800920B0:("osEPiReadIo",), 0x80092100:("osViSetSpecialFeatures",), 0x80092260:("coss",), @@ -3354,45 +3354,45 @@ 0x801800CC:("Math_Atan2F",), 0x80180100:("Math_FAtan2F",), 0x8018012C:("Math_Acot2F",), - 0x80180160:("Matrix_StateAlloc",), - 0x8018019C:("Matrix_StatePush",), - 0x801801CC:("Matrix_StatePop",), - 0x801801E8:("Matrix_CopyCurrentState",), - 0x8018020C:("Matrix_SetCurrentState",), - 0x80180234:("Matrix_GetCurrentState",), - 0x80180244:("Matrix_InsertMatrix",), - 0x8018029C:("Matrix_InsertTranslation",), + 0x80180160:("Matrix_Init",), + 0x8018019C:("Matrix_Push",), + 0x801801CC:("Matrix_Pop",), + 0x801801E8:("Matrix_Get",), + 0x8018020C:("Matrix_Put",), + 0x80180234:("Matrix_GetCurrent",), + 0x80180244:("Matrix_Mult",), + 0x8018029C:("Matrix_Translate",), 0x8018039C:("Matrix_Scale",), - 0x80180478:("Matrix_InsertXRotation_s",), - 0x80180610:("Matrix_InsertXRotation_f",), - 0x801807B8:("Matrix_RotateStateAroundXAxis",), - 0x80180900:("Matrix_SetStateXRotation",), - 0x801809AC:("Matrix_RotateY",), - 0x80180B48:("Matrix_InsertYRotation_f",), - 0x80180CF8:("Matrix_InsertZRotation_s",), - 0x80180E90:("Matrix_InsertZRotation_f",), - 0x8018103C:("Matrix_InsertRotation",), - 0x801812FC:("Matrix_JointPosition",), - 0x80181650:("Matrix_SetStateRotationAndTranslation",), - 0x801817FC:("Matrix_ToRSPMatrix",), + 0x80180478:("Matrix_RotateXS",), + 0x80180610:("Matrix_RotateXF",), + 0x801807B8:("Matrix_RotateXFApply",), + 0x80180900:("Matrix_RotateXFNew",), + 0x801809AC:("Matrix_RotateYS",), + 0x80180B48:("Matrix_RotateYF",), + 0x80180CF8:("Matrix_RotateZS",), + 0x80180E90:("Matrix_RotateZF",), + 0x8018103C:("Matrix_RotateZYX",), + 0x801812FC:("Matrix_TranslateRotateZYX",), + 0x80181650:("Matrix_SetTranslateRotateYXZ",), + 0x801817FC:("Matrix_MtxFToMtx",), 0x80181A18:("Matrix_ToMtx",), 0x80181A40:("Matrix_NewMtx",), - 0x80181A6C:("Matrix_AppendToPolyOpaDisp",), - 0x80181A98:("Matrix_MultiplyVector3fByState",), - 0x80181B50:("Matrix_GetStateTranslation",), - 0x80181B78:("Matrix_GetStateTranslationAndScaledX",), - 0x80181BC4:("Matrix_GetStateTranslationAndScaledY",), - 0x80181C10:("Matrix_GetStateTranslationAndScaledZ",), - 0x80181C5C:("Matrix_MultiplyVector3fXZByCurrentState",), + 0x80181A6C:("Matrix_MtxFToNewMtx",), + 0x80181A98:("Matrix_MultVec3f",), + 0x80181B50:("Matrix_MultZero",), + 0x80181B78:("Matrix_MultVecX",), + 0x80181BC4:("Matrix_MultVecY",), + 0x80181C10:("Matrix_MultVecZ",), + 0x80181C5C:("Matrix_MultVec3fXZ",), 0x80181CDC:("Matrix_MtxFCopy",), - 0x80181D64:("Matrix_FromRSPMatrix",), - 0x80181FB8:("Matrix_MultiplyVector3fByMatrix",), - 0x80182068:("Matrix_TransposeXYZ",), - 0x801820A0:("Matrix_NormalizeXYZ",), - 0x8018219C:("func_8018219C",), - 0x801822C4:("func_801822C4",), - 0x801823EC:("Matrix_InsertRotationAroundUnitVector_f",), - 0x8018284C:("Matrix_InsertRotationAroundUnitVector_s",), + 0x80181D64:("Matrix_MtxToMtxF",), + 0x80181FB8:("Matrix_MultVec3fExt",), + 0x80182068:("Matrix_Transpose",), + 0x801820A0:("Matrix_ReplaceRotation",), + 0x8018219C:("Matrix_MtxFToYXZRot",), + 0x801822C4:("Matrix_MtxFToZYXRot",), + 0x801823EC:("Matrix_RotateAxisF",), + 0x8018284C:("Matrix_RotateAxisS",), 0x80182C90:("SysUcode_GetUCodeBoot",), 0x80182CA0:("SysUcode_GetUCodeBootSize",), 0x80182CBC:("SysUcode_GetUCode",), diff --git a/tools/namefixer.py b/tools/namefixer.py index c4a83d13f..1d6c89a7b 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -22,42 +22,80 @@ wordReplace = { "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", - "SysMatrix_StateAlloc": "Matrix_StateAlloc", - "SysMatrix_StatePush": "Matrix_StatePush", - "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", - "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", - "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", - "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", - "SysMatrix_Scale": "Matrix_Scale", - "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", - "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", - "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", - "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", - "SysMatrix_RotateY": "Matrix_RotateY", - "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", - "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", - "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", - "SysMatrix_InsertRotation": "Matrix_InsertRotation", - "SysMatrix_JointPosition": "Matrix_JointPosition", - "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", - "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", - "SysMatrix_ToMtx": "Matrix_ToMtx", - "SysMatrix_NewMtx": "Matrix_NewMtx", - "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", - "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", - "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", - "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", - "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", - "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", - "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", - "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", - "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", - "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", - "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", - "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", - "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", - "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", - "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", + + # "SysMatrix_StateAlloc": "Matrix_StateAlloc", + # "SysMatrix_StatePush": "Matrix_StatePush", + # "SysMatrix_StatePop": "Matrix_StatePop", + # "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", + # "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", + # "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", + # "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", + # "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", + # "SysMatrix_Scale": "Matrix_Scale", + # "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", + # "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", + # "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", + # "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", + # "SysMatrix_RotateY": "Matrix_RotateY", + # "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", + # "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", + # "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", + # "SysMatrix_InsertRotation": "Matrix_InsertRotation", + # "SysMatrix_JointPosition": "Matrix_JointPosition", + # "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", + # "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", + # "SysMatrix_ToMtx": "Matrix_ToMtx", + # "SysMatrix_NewMtx": "Matrix_NewMtx", + # "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", + # "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", + # "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", + # "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", + # "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", + # "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", + # "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", + # "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", + # "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", + # "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", + # "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", + # "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", + # "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", + # "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", + # "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", + + "Matrix_StateAlloc": "Matrix_Init", + "Matrix_StatePush": "Matrix_Push", + "Matrix_StatePop": "Matrix_Pop", + "Matrix_CopyCurrentState": "Matrix_Get", + "Matrix_SetCurrentState": "Matrix_Put", + "Matrix_GetCurrentState": "Matrix_GetCurrent", + "Matrix_InsertMatrix": "Matrix_Mult", + "Matrix_InsertTranslation": "Matrix_Translate", + "Matrix_InsertXRotation_s": "Matrix_RotateXS", + "Matrix_InsertXRotation_f": "Matrix_RotateXF", + "Matrix_RotateStateAroundXAxis": "Matrix_RotateXFApply", + "Matrix_SetStateXRotation": "Matrix_RotateXFNew", + # "Matrix_RotateY": "Matrix_RotateYS", + "Matrix_InsertYRotation_f": "Matrix_RotateYF", + "Matrix_InsertZRotation_s": "Matrix_RotateZS", + "Matrix_InsertZRotation_f": "Matrix_RotateZF", + "Matrix_InsertRotation": "Matrix_RotateZYX", + "Matrix_JointPosition": "Matrix_TranslateRotateZYX", + "Matrix_SetStateRotationAndTranslation": "Matrix_SetTranslateRotateYXZ", + "Matrix_ToRSPMatrix": "Matrix_MtxFToMtx", + "Matrix_MultiplyVector3fByState": "Matrix_MultVec3f", + "Matrix_GetStateTranslation": "Matrix_MultZero", + "Matrix_GetStateTranslationAndScaledX": "Matrix_MultVecX", + "Matrix_GetStateTranslationAndScaledY": "Matrix_MultVecY", + "Matrix_GetStateTranslationAndScaledZ": "Matrix_MultVecZ", + "Matrix_MultiplyVector3fXZByCurrentState": "Matrix_MultVec3fXZ", + "Matrix_FromRSPMatrix": "Matrix_MtxToMtxF", + "Matrix_TransposeXYZ": "Matrix_Transpose", + "Matrix_NormalizeXYZ": "Matrix_ReplaceRotation", + "func_8018219C": "Matrix_MtxFToYXZRot", + "func_801822C4": "Matrix_MtxFToZYXRot", + "Matrix_InsertRotationAroundUnitVector_f": "Matrix_RotateAxisF", + "Matrix_InsertRotationAroundUnitVector_s": "Matrix_RotateAxisS", + "func_800B78B8": "Actor_UpdateBgCheckInfo", "func_8012403C": "Player_GetMask", "func_8012404c": "Player_RemoveMask", @@ -184,8 +222,6 @@ wordReplace = { "func_80137748": "SkelAnime_UpdateTranslation", "func_801378B8": "Animation_OnFrame", "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", - "SysMatrix_StatePop": "Matrix_StatePop", - "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", "Actor_SetObjectSegment": "Actor_SetObjectDependency", "func_800B3FC0": "ActorShadow_DrawCircle", "func_800B4024": "ActorShadow_DrawSquare", diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 6c5c92e16..a86be3b83 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -248,7 +248,7 @@ asm/non_matchings/boot/setintmask/osSetIntMask.s,osSetIntMask,0x80088010,0x28 asm/non_matchings/boot/getintmask/osGetIntMask.s,osGetIntMask,0x800880B0,0x18 asm/non_matchings/boot/voicesetword/osVoiceSetWord.s,osVoiceSetWord,0x80088110,0x64 asm/non_matchings/boot/guScale/guScale.s,guScale,0x800882A0,0x2C -asm/non_matchings/boot/sinf/__sinf.s,__sinf,0x80088350,0x70 +asm/non_matchings/boot/sinf/sinf.s,sinf,0x80088350,0x70 asm/non_matchings/boot/sins/sins.s,sins,0x80088510,0x1C asm/non_matchings/boot/sptask/_VirtualToPhysicalTask.s,_VirtualToPhysicalTask,0x80088580,0x43 asm/non_matchings/boot/sptask/osSpTaskLoad.s,osSpTaskLoad,0x8008868C,0x5A @@ -407,7 +407,7 @@ asm/non_matchings/boot/interrupt/__osRestoreInt.s,__osRestoreInt,0x80091AD0,0x8 asm/non_matchings/boot/vi/__osViInit.s,__osViInit,0x80091AF0,0x48 asm/non_matchings/boot/viswapcontext/__osViSwapContext.s,__osViSwapContext,0x80091C10,0xC0 asm/non_matchings/boot/pigetcmdq/osPiGetCmdQueue.s,osPiGetCmdQueue,0x80091F10,0xC -asm/non_matchings/boot/cosf/__cosf.s,__cosf,0x80091F40,0x5C +asm/non_matchings/boot/cosf/cosf.s,cosf,0x80091F40,0x5C asm/non_matchings/boot/epiread/osEPiReadIo.s,osEPiReadIo,0x800920B0,0x14 asm/non_matchings/boot/visetspecial/osViSetSpecialFeatures.s,osViSetSpecialFeatures,0x80092100,0x58 asm/non_matchings/boot/coss/coss.s,coss,0x80092260,0xC diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 2989dbfb6..5b7c0d71d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2868,45 +2868,45 @@ asm/non_matchings/code/sys_math_atan/Math_Atan2S.s,Math_Atan2S,0x8017FEE4,0x7A asm/non_matchings/code/sys_math_atan/Math_Atan2F.s,Math_Atan2F,0x801800CC,0xD asm/non_matchings/code/sys_math_atan/Math_FAtan2F.s,Math_FAtan2F,0x80180100,0xB asm/non_matchings/code/sys_math_atan/Math_Acot2F.s,Math_Acot2F,0x8018012C,0xD -asm/non_matchings/code/sys_matrix/Matrix_StateAlloc.s,Matrix_StateAlloc,0x80180160,0xF -asm/non_matchings/code/sys_matrix/Matrix_StatePush.s,Matrix_StatePush,0x8018019C,0xC -asm/non_matchings/code/sys_matrix/Matrix_StatePop.s,Matrix_StatePop,0x801801CC,0x7 -asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s,Matrix_CopyCurrentState,0x801801E8,0x9 -asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s,Matrix_SetCurrentState,0x8018020C,0xA -asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s,Matrix_GetCurrentState,0x80180234,0x4 -asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s,Matrix_InsertMatrix,0x80180244,0x16 -asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s,Matrix_InsertTranslation,0x8018029C,0x40 +asm/non_matchings/code/sys_matrix/Matrix_Init.s,Matrix_Init,0x80180160,0xF +asm/non_matchings/code/sys_matrix/Matrix_Push.s,Matrix_Push,0x8018019C,0xC +asm/non_matchings/code/sys_matrix/Matrix_Pop.s,Matrix_Pop,0x801801CC,0x7 +asm/non_matchings/code/sys_matrix/Matrix_Get.s,Matrix_Get,0x801801E8,0x9 +asm/non_matchings/code/sys_matrix/Matrix_Put.s,Matrix_Put,0x8018020C,0xA +asm/non_matchings/code/sys_matrix/Matrix_GetCurrent.s,Matrix_GetCurrent,0x80180234,0x4 +asm/non_matchings/code/sys_matrix/Matrix_Mult.s,Matrix_Mult,0x80180244,0x16 +asm/non_matchings/code/sys_matrix/Matrix_Translate.s,Matrix_Translate,0x8018029C,0x40 asm/non_matchings/code/sys_matrix/Matrix_Scale.s,Matrix_Scale,0x8018039C,0x37 -asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s,Matrix_InsertXRotation_s,0x80180478,0x66 -asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s,Matrix_InsertXRotation_f,0x80180610,0x6A -asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s,Matrix_RotateStateAroundXAxis,0x801807B8,0x52 -asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s,Matrix_SetStateXRotation,0x80180900,0x2B -asm/non_matchings/code/sys_matrix/Matrix_RotateY.s,Matrix_RotateY,0x801809AC,0x67 -asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s,Matrix_InsertYRotation_f,0x80180B48,0x6C -asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s,Matrix_InsertZRotation_s,0x80180CF8,0x66 -asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s,Matrix_InsertZRotation_f,0x80180E90,0x6B -asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s,Matrix_InsertRotation,0x8018103C,0xB0 +asm/non_matchings/code/sys_matrix/Matrix_RotateXS.s,Matrix_RotateXS,0x80180478,0x66 +asm/non_matchings/code/sys_matrix/Matrix_RotateXF.s,Matrix_RotateXF,0x80180610,0x6A +asm/non_matchings/code/sys_matrix/Matrix_RotateXFApply.s,Matrix_RotateXFApply,0x801807B8,0x52 +asm/non_matchings/code/sys_matrix/Matrix_RotateXFNew.s,Matrix_RotateXFNew,0x80180900,0x2B +asm/non_matchings/code/sys_matrix/Matrix_RotateYS.s,Matrix_RotateYS,0x801809AC,0x67 +asm/non_matchings/code/sys_matrix/Matrix_RotateYF.s,Matrix_RotateYF,0x80180B48,0x6C +asm/non_matchings/code/sys_matrix/Matrix_RotateZS.s,Matrix_RotateZS,0x80180CF8,0x66 +asm/non_matchings/code/sys_matrix/Matrix_RotateZF.s,Matrix_RotateZF,0x80180E90,0x6B +asm/non_matchings/code/sys_matrix/Matrix_RotateZYX.s,Matrix_RotateZYX,0x8018103C,0xB0 asm/non_matchings/code/sys_matrix/Matrix_RotateAndTranslateState.s,Matrix_RotateAndTranslateState,0x801812FC,0xD5 -asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s,Matrix_SetStateRotationAndTranslation,0x80181650,0x6B -asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s,Matrix_ToRSPMatrix,0x801817FC,0x87 -asm/non_matchings/code/sys_matrix/Matrix_GetStateAsRSPMatrix.s,Matrix_GetStateAsRSPMatrix,0x80181A18,0xA +asm/non_matchings/code/sys_matrix/Matrix_SetTranslateRotateYXZ.s,Matrix_SetTranslateRotateYXZ,0x80181650,0x6B +asm/non_matchings/code/sys_matrix/Matrix_MtxFToMtx.s,Matrix_MtxFToMtx,0x801817FC,0x87 +asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s,Matrix_ToMtx,0x80181A18,0xA asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s,Matrix_NewMtx,0x80181A40,0xB -asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s,Matrix_AppendToPolyOpaDisp,0x80181A6C,0xB -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s,Matrix_MultiplyVector3fByState,0x80181A98,0x2E -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s,Matrix_GetStateTranslation,0x80181B50,0xA -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s,Matrix_GetStateTranslationAndScaledX,0x80181B78,0x13 -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s,Matrix_GetStateTranslationAndScaledY,0x80181BC4,0x13 -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s,Matrix_GetStateTranslationAndScaledZ,0x80181C10,0x13 -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s,Matrix_MultiplyVector3fXZByCurrentState,0x80181C5C,0x20 +asm/non_matchings/code/sys_matrix/Matrix_MtxFToNewMtx.s,Matrix_MtxFToNewMtx,0x80181A6C,0xB +asm/non_matchings/code/sys_matrix/Matrix_MultVec3f.s,Matrix_MultVec3f,0x80181A98,0x2E +asm/non_matchings/code/sys_matrix/Matrix_MultZero.s,Matrix_MultZero,0x80181B50,0xA +asm/non_matchings/code/sys_matrix/Matrix_MultVecX.s,Matrix_MultVecX,0x80181B78,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVecY.s,Matrix_MultVecY,0x80181BC4,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVecZ.s,Matrix_MultVecZ,0x80181C10,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVec3fXZ.s,Matrix_MultVec3fXZ,0x80181C5C,0x20 asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s,Matrix_MtxFCopy,0x80181CDC,0x22 -asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s,Matrix_FromRSPMatrix,0x80181D64,0x95 -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s,Matrix_MultiplyVector3fByMatrix,0x80181FB8,0x2C -asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s,Matrix_TransposeXYZ,0x80182068,0xE -asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s,Matrix_NormalizeXYZ,0x801820A0,0x3F -asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A -asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A -asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 -asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 +asm/non_matchings/code/sys_matrix/Matrix_MtxToMtxF.s,Matrix_MtxToMtxF,0x80181D64,0x95 +asm/non_matchings/code/sys_matrix/Matrix_MultVec3fExt.s,Matrix_MultVec3fExt,0x80181FB8,0x2C +asm/non_matchings/code/sys_matrix/Matrix_Transpose.s,Matrix_Transpose,0x80182068,0xE +asm/non_matchings/code/sys_matrix/Matrix_ReplaceRotation.s,Matrix_ReplaceRotation,0x801820A0,0x3F +asm/non_matchings/code/sys_matrix/Matrix_MtxFToYXZRot.s,Matrix_MtxFToYXZRot,0x8018219C,0x4A +asm/non_matchings/code/sys_matrix/Matrix_MtxFToZYXRot.s,Matrix_MtxFToZYXRot,0x801822C4,0x4A +asm/non_matchings/code/sys_matrix/Matrix_RotateAxisF.s,Matrix_RotateAxisF,0x801823EC,0x118 +asm/non_matchings/code/sys_matrix/Matrix_RotateAxisS.s,Matrix_RotateAxisS,0x8018284C,0x111 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 asm/non_matchings/code/sys_ucode/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 From ec43a32c2677dbaea2f4332ba5a624ec7759b711 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Sat, 18 Jun 2022 10:33:59 -0400 Subject: [PATCH 17/53] z_en_box.c, z_demo_tre_lgt.c OK, some object_box documentation (#703) * All functions attempted, 2 NON_MATCHINGs * z_en_box OK, more documentation * format * en_box cleanups, fix GI item table * z_demo_tre_lgt OK * format.sh * pr suggestions 1 * object_box improvements * Merge remote-tracking branch 'origin/master' into z_en_box * Revert "Merge remote-tracking branch 'origin/master' into z_en_box" This reverts commit 5aacdf26e49c91fadc6f50dc2b9e19935a8f3ec4. * more suggested changes * fix comment --- assets/xml/objects/object_box.xml | 87 +-- include/functions.h | 2 +- include/z64item.h | 30 +- spec | 6 +- src/code/z_actor.c | 15 +- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 145 +++- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h | 14 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 693 +++++++++++++++++- src/overlays/actors/ovl_En_Box/z_en_box.h | 62 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 90 +-- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 2 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 2 +- tools/disasm/functions.txt | 44 +- tools/disasm/variables.txt | 4 +- 15 files changed, 1006 insertions(+), 192 deletions(-) diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index fb1fb3fd5..85e788633 100644 --- a/assets/xml/objects/object_box.xml +++ b/assets/xml/objects/object_box.xml @@ -1,52 +1,53 @@  - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index b4ff2ad8d..a29024850 100644 --- a/include/functions.h +++ b/include/functions.h @@ -794,7 +794,7 @@ void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); -s32 func_800BE63C(struct EnBox* chest); +s32 Actor_IsSmallChest(struct EnBox* chest); void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); diff --git a/include/z64item.h b/include/z64item.h index 785d56577..2281ded92 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -279,6 +279,7 @@ typedef enum { /* 0x0A */ GI_RECOVERY_HEART, /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, + /* 0x11 */ GI_STRAY_FAIRY = 0x11, /* 0x16 */ GI_BOMBS_10 = 0x16, /* 0x19 */ GI_STICKS_1 = 0x19, /* 0x1A */ GI_BOMBCHUS_10, @@ -298,22 +299,25 @@ typedef enum { /* 0x33 */ GI_SHIELD_MIRROR, /* 0x35 */ GI_MAGIC_BEANS = 0x35, /* 0x3C */ GI_KEY_SMALL = 0x3C, - /* 0x3E */ GI_MAP = 0x3E, + /* 0x3D */ GI_KEY_BOSS, + /* 0x3E */ GI_MAP, /* 0x3F */ GI_COMPASS, /* 0x50 */ GI_50 = 0x50, /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, - /* 0x5B */ GI_POTION_RED = 0x5B, + /* 0x5A */ GI_BOTTLE, + /* 0x5B */ GI_POTION_RED, /* 0x5C */ GI_POTION_GREEN, /* 0x5D */ GI_POTION_BLUE, /* 0x5E */ GI_FAIRY, /* 0x60 */ GI_MILK_BOTTLE = 0x60, + /* 0x76 */ GI_ICE_TRAP = 0x76, /* 0x78 */ GI_MASK_DEKU = 0x78, /* 0x79 */ GI_MASK_GORON, /* 0x7A */ GI_MASK_ZORA, /* 0x7B */ GI_MASK_FIERCE_DEITY, - /* 0x7C */ GI_MASK_TRUTH, - /* 0x7D */ GI_MASK_KAFEIS_MASK, + /* 0x7C */ GI_MASK_CAPTAIN, + /* 0x7D */ GI_MASK_GIANT, /* 0x7E */ GI_MASK_ALL_NIGHT, /* 0x7F */ GI_MASK_BUNNY, /* 0x80 */ GI_MASK_KEATON, @@ -326,27 +330,31 @@ typedef enum { /* 0x87 */ GI_MASK_GIBDO, /* 0x88 */ GI_MASK_DON_GERO, /* 0x89 */ GI_MASK_KAMARO, - /* 0x8A */ GI_MASK_CAPTAIN, + /* 0x8A */ GI_MASK_TRUTH, /* 0x8B */ GI_MASK_STONE, /* 0x8C */ GI_MASK_BREMEN, /* 0x8D */ GI_MASK_BLAST, /* 0x8E */ GI_MASK_SCENTS, - /* 0x8F */ GI_MASK_GIANT, - /* 0x92 */ GI_MILK = 0x92, - /* 0x95 */ GI_95 = 0x95, + /* 0x8F */ GI_MASK_KAFEIS_MASK, + /* 0x91 */ GI_CHATEAU = 0x91, + /* 0x92 */ GI_MILK, + /* 0x93 */ GI_GOLD_DUST, + /* 0x94 */ GI_EEL, // Unused bottled eel + /* 0x95 */ GI_SEAHORSE, /* 0x96 */ GI_MOON_TEAR, /* 0x97 */ GI_DEED_LAND, /* 0x98 */ GI_DEED_SWAMP, /* 0x99 */ GI_DEED_MOUNTAIN, /* 0x9A */ GI_DEED_OCEAN, - /* 0x9B */ GI_SWORD_GREAT_FAIRY = 0x9B, + /* 0x9B */ GI_SWORD_GREAT_FAIRY, /* 0x9C */ GI_SWORD_KOKIRI, /* 0x9D */ GI_SWORD_RAZOR, /* 0x9E */ GI_SWORD_GILDED, /* 0x9F */ GI_SHIELD_HERO_2, // Code that treats this as hero's shield is unused, so take with a grain of salt /* 0xA1 */ GI_LETTER_TO_MAMA = 0xA1, - /* 0xA9 */ GI_BOTTLE = 0xA9, - /* 0xAB */ GI_PENDANT_OF_MEMORIES = 0xAB, + /* 0xA9 */ GI_BOTTLE_STOLEN = 0xA9, // buy back stolen bottle + /* 0xAA */ GI_LETTER_TO_KAFEI, + /* 0xAB */ GI_PENDANT_OF_MEMORIES, /* 0xBA */ GI_MAX = 0xBA } GetItemID; diff --git a/spec b/spec index 273170579..d0351563a 100644 --- a/spec +++ b/spec @@ -768,8 +768,7 @@ beginseg name "ovl_En_Box" compress include "build/src/overlays/actors/ovl_En_Box/z_en_box.o" - include "build/data/ovl_En_Box/ovl_En_Box.data.o" - include "build/data/ovl_En_Box/ovl_En_Box.reloc.o" + include "build/src/overlays/actors/ovl_En_Box/ovl_En_Box_reloc.o" endseg beginseg @@ -1193,8 +1192,7 @@ beginseg name "ovl_Demo_Tre_Lgt" compress include "build/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.o" - include "build/data/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt.data.o" - include "build/data/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt_reloc.o" endseg beginseg diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 6d0b9573d..9325d315c 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2003,11 +2003,11 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { - if (((getItemId == GI_MASK_CIRCUS_LEADER) || (getItemId == GI_PENDANT_OF_MEMORIES) || - (getItemId == GI_DEED_LAND) || - (((player->heldActor != NULL) || (actor == player->targetActor)) && + if ((getItemId == GI_MASK_CIRCUS_LEADER || getItemId == GI_PENDANT_OF_MEMORIES || + getItemId == GI_DEED_LAND || + ((player->heldActor != NULL || actor == player->targetActor) && (getItemId > GI_NONE && getItemId < GI_MAX))) || - (!(player->stateFlags1 & 0x20000800))) { + !(player->stateFlags1 & 0x20000800)) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS_ALT(yawDiff); @@ -4482,9 +4482,10 @@ void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex) { } } -s32 func_800BE63C(struct EnBox* chest) { - if ((chest->unk_1F1 == 5) || (chest->unk_1F1 == 6) || (chest->unk_1F1 == 7) || (chest->unk_1F1 == 8) || - (chest->unk_1F1 == 0xC)) { +s32 Actor_IsSmallChest(struct EnBox* chest) { + if (chest->type == ENBOX_TYPE_SMALL || chest->type == ENBOX_TYPE_SMALL_INVISIBLE || + chest->type == ENBOX_TYPE_SMALL_ROOM_CLEAR || chest->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL || + chest->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) { return true; } return false; diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 060a201d7..6d921c4c6 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -5,6 +5,8 @@ */ #include "z_demo_tre_lgt.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "objects/object_box/object_box.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +17,24 @@ void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void DemoTreLgt_SetupWait(DemoTreLgt* this); + +void DemoTreLgt_Wait(DemoTreLgt* this, GlobalContext* globalCtx); +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 frame); +void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx); + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} DemoTreLgtInfo; + +static DemoTreLgtInfo D_808E1490[2] = { + { 1.0f, 136.0f, 190.0f, 40.0f }, + { 1.0f, 136.0f, 220.0f, 50.0f }, +}; + const ActorInit Demo_Tre_Lgt_InitVars = { ACTOR_DEMO_TRE_LGT, ACTORCAT_ITEMACTION, @@ -28,24 +47,126 @@ const ActorInit Demo_Tre_Lgt_InitVars = { (ActorFunc)DemoTreLgt_Draw, }; -#endif +static TransformUpdateIndex* sBoxLightAnimations[] = { + &gBoxLightAdultCurveAnim, + &gBoxLightChildCurveAnim, +}; -extern UNK_TYPE D_06007D78; +static DemoTreLgtActionFunc sActionFuncs[] = { + DemoTreLgt_Wait, + DemoTreLgt_Animate, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Init.s") +void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Destroy.s") + SkelCurve_Init(globalCtx, &this->skelCurve, &gBoxLightCurveSkel, sBoxLightAnimations[0]); + this->colorAlpha1 = 255; + this->colorAlpha2 = 255; + this->status = 0; + //! @bug Zora Link should also use animationType 0 + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { + this->animationType = 0; + } else { + this->animationType = 1; + } + DemoTreLgt_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EE8.s") +void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EF4.s") + SkelCurve_Destroy(globalCtx, &this->skelCurve); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0F4C.s") +void DemoTreLgt_SetupWait(DemoTreLgt* this) { + this->action = DEMO_TRE_LGT_ACTION_WAIT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0FE0.s") +void DemoTreLgt_Wait(DemoTreLgt* this, GlobalContext* globalCtx) { + EnBox* chest = (EnBox*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Update.s") + if (chest != NULL) { + if (Animation_OnFrame(&chest->skelAnime, 10.0f)) { + DemoTreLgt_SetupAnimate(this, globalCtx, chest->skelAnime.curFrame); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E12A4.s") +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 frame) { + this->action = DEMO_TRE_LGT_ACTION_ANIMATE; + SkelCurve_SetAnim(&this->skelCurve, sBoxLightAnimations[this->animationType], 1.0f, + D_808E1490[this->animationType].unk4 + D_808E1490[this->animationType].unk8, frame, 1.0f); + SkelCurve_Update(globalCtx, &this->skelCurve); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Draw.s") +void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelCurve.animCurFrame; + + if (curFrame < D_808E1490[this->animationType].unk4) { + this->colorAlpha1 = 255; + } else if (curFrame <= (D_808E1490[this->animationType].unk4 + D_808E1490[this->animationType].unk8)) { + this->colorAlpha1 = + ((D_808E1490[this->animationType].unk4 - curFrame) / D_808E1490[this->animationType].unk8) * 255 + 255; + } else { + this->colorAlpha1 = 0; + } + + if (curFrame < D_808E1490[this->animationType].unkC) { + this->colorAlpha2 = 255; + } else if (curFrame < (D_808E1490[this->animationType].unkC + 10.0f)) { + this->colorAlpha2 = ((D_808E1490[this->animationType].unkC - curFrame) / 10.0f) * 255 + 255; + } else { + this->colorAlpha2 = 0; + } + if (curFrame > 30.0f) { + if (!(this->status & 1)) { + this->status |= 1; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_TRE_BOX_FLASH); + } + } + if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + Actor_MarkForDeath(&this->actor); + } +} + +void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; + + sActionFuncs[this->action](this, globalCtx); +} + +s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoTreLgt* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->state.frames * 2) % 256, 0, 64, 32, 1, + (globalCtx->state.frames * -2) % 256, 0, 64, 32)); + + if (limbIndex == OBJECT_BOX_LIGHT_LIMB_01) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha1); + } else if (limbIndex == OBJECT_BOX_LIGHT_LIMB_13 || limbIndex == OBJECT_BOX_LIGHT_LIMB_07 || + limbIndex == OBJECT_BOX_LIGHT_LIMB_04 || limbIndex == OBJECT_BOX_LIGHT_LIMB_10) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha2); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoTreLgt* this = THIS; + + OPEN_DISPS(gfxCtx); + if (this->action == DEMO_TRE_LGT_ACTION_ANIMATE) { + func_8012C2DC(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, &this->actor); + } + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h index 07e2a9bc8..08677b803 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h @@ -5,11 +5,23 @@ struct DemoTreLgt; +typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt* this, GlobalContext* globalCtx); + typedef struct DemoTreLgt { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x34]; + /* 0x144 */ SkelAnimeCurve skelCurve; + /* 0x164 */ s32 action; + /* 0x168 */ u32 colorAlpha1; + /* 0x16C */ u32 colorAlpha2; + /* 0x170 */ u8 status; + /* 0x174 */ s32 animationType; } DemoTreLgt; // size = 0x178 +typedef enum { + /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed + /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE +} DemoTreLgtAction; + extern const ActorInit Demo_Tre_Lgt_InitVars; #endif // Z_DEMO_TRE_LGT_H diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 7367f49bc..1259df33e 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -5,9 +5,39 @@ */ #include "z_en_box.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_box/object_box.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS 0x00000000 +/* +set on init unless treasure flag is set +if clear, chest moves (Actor_MoveForward) (falls, likely) +ends up cleared from SWITCH_FLAG_FALL types when switch flag is set +*/ +#define ENBOX_MOVE_IMMOBILE (1 << 0) +/* +set in the logic for SWITCH_FLAG_FALL types +otherwise unused +*/ +#define ENBOX_MOVE_UNUSED (1 << 1) +/* +set with 50% chance on init for SWITCH_FLAG_FALL types +only used for SWITCH_FLAG_FALL types +ends up "blinking" (set/clear every frame) once switch flag is set, +if some collision-related condition (?) is met +only used for signum of z rotation +*/ +#define ENBOX_MOVE_FALL_ANGLE_SIDE (1 << 2) +/* +when set, gets cleared next EnBox_Update call and clip to the floor +*/ +#define ENBOX_MOVE_STICK_TO_GROUND (1 << 4) +#define ENBOX_MOVE_0x20 (1 << 5) +#define ENBOX_MOVE_0x40 (1 << 6) +#define ENBOX_MOVE_0x80 (1 << 7) + #define THIS ((EnBox*)thisx) void EnBox_Init(Actor* thisx, GlobalContext* globalCtx); @@ -15,7 +45,17 @@ void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBox_Update(Actor* thisx, GlobalContext* globalCtx); void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx); +void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx); +void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx); +void func_80868AFC(EnBox* this, GlobalContext* globalCtx); +void func_80868B74(EnBox* this, GlobalContext* globalCtx); +void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx); +void EnBox_Open(EnBox* this, GlobalContext* globalCtx); + +void func_80867FBC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, s32 arg2); +void func_80867FE4(func_80867BDC_a0* arg0, GlobalContext* globalCtx); + const ActorInit En_Box_InitVars = { ACTOR_EN_BOX, ACTORCAT_CHEST, @@ -28,66 +68,653 @@ const ActorInit En_Box_InitVars = { (ActorFunc)EnBox_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80869B50[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +typedef struct { + f32 data[5]; +} EnBox_PlaybackSpeed; // 0x14 -extern InitChainEntry D_80869B50[]; +static EnBox_PlaybackSpeed sPlaybackSpeed = { { 1.5f, 1.0f, 1.5f, 1.0f, 1.5f } }; -extern UNK_TYPE D_0600043C; -extern UNK_TYPE D_06000DB0; +static AnimationHeader* sBigChestAnimations[5] = { + &gBoxBigChestOpenAdultAnim, &gBoxBigChestOpenGoronAnim, &gBoxBigChestOpenAdultAnim, + &gBoxBigChestOpenDekuAnim, &gBoxBigChestOpenChildAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867BD0.s") +void EnBox_SetupAction(EnBox* this, EnBoxActionFunc func) { + this->actionFunc = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867BDC.s") +void func_80867BDC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, Vec3f* pos) { + arg0->pos = *pos; + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + arg0->unk_14 = 0; + arg0->unk_18 = 0; + arg0->unk_1C = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C14.s") +void func_80867C14(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + arg0->unk_18++; + if (arg0->unk_18 > 85) { + arg0->unk_18 = 85; + } + if (arg0->unk_18 != 85) { + arg0->unk_1C = arg0->unk_18 - 28; + if (arg0->unk_18 - 28 < 0) { + arg0->unk_1C = 0; + } + } else { + arg0->unk_1C++; + if (arg0->unk_1C > 85) { + func_80867FE4(arg0, globalCtx); + } + } + arg0->unk_14++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C8C.s") +void func_80867C8C(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + s32 temp_s6 = arg0->unk_18 - arg0->unk_1C; + s32 i; + f32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867FBC.s") + if (temp_s6 > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_Push(); + for (i = 0; i < temp_s6; i++) { + f32 temp_f0 = (f32)i / temp_s6; + s16 temp_s0 = ((f32)arg0->unk_18 - arg0->unk_1C) * temp_f0 + arg0->unk_1C; + f32 temp_f24 = 1.0f - (temp_s0 * 0.011764706f); + f32 temp_f26 = Rand_ZeroOne() * 0.03f * temp_f0 * temp_f24; + f32 temp_f28; + f32 temp_f30 = Math_SinS(temp_s0 * 0x9A6) * 45.0f + arg0->pos.x; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867FE4.s") + if (arg0->unk_20 != 0) { + phi_f24 = arg0->pos.y - (0.03f * temp_s0) - (0.01f * temp_s0 * temp_s0); + } else { + phi_f24 = arg0->pos.y + (0.03f * temp_s0) + (0.01f * temp_s0 * temp_s0); + } + temp_f28 = (Math_CosS(temp_s0 * 0x9A6) * 45.0f) + arg0->pos.z; + Matrix_Translate(2.0f * Rand_Centered() + temp_f30, 2.0f * Rand_Centered() + phi_f24, + 2.0f * Rand_Centered() + temp_f28, MTXMODE_NEW); + Matrix_Scale(temp_f26, temp_f26, temp_f26, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + Matrix_Pop(); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_8086800C.s") +void func_80867FBC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, s32 arg2) { + arg0->unk_0C = func_80867C14; + arg0->unk_10 = func_80867C8C; + arg0->unk_20 = arg2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Init.s") +void func_80867FE4(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + func_80867BDC(arg0, globalCtx, &arg0->pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Destroy.s") +void EnBox_ClipToGround(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + f32 floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868630.s") + if (!(this->movementFlags & ENBOX_MOVE_0x80)) { + pos = this->dyna.actor.world.pos; + pos.y += 1.0f; + floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->dyna.actor, &pos); + if (floorHeight != BGCHECK_Y_MIN) { + this->dyna.actor.world.pos.y = floorHeight; + this->dyna.actor.floorHeight = floorHeight; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868734.s") +void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { + s16 cutsceneIdx; + EnBox* this = (EnBox*)thisx; + s32 pad; + CollisionHeader* colHeader; + f32 animFrame; + f32 animFrameEnd; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808687E8.s") + colHeader = NULL; + animFrame = 0.0f; + animFrameEnd = Animation_GetLastFrame(&gBoxChestOpenAnim); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gBoxChestCol, &colHeader); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868944.s") + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->movementFlags = 0; + this->type = ENBOX_GET_TYPE(&this->dyna.actor); + this->iceSmokeTimer = 0; + this->unk_1F3 = 0; + this->dyna.actor.gravity = -5.5f; + this->dyna.actor.terminalVelocity = -50.0f; + this->switchFlag = ENBOX_GET_SWITCH_FLAG(&this->dyna.actor); + this->dyna.actor.floorHeight = this->dyna.actor.world.pos.y; + if (this->dyna.actor.world.rot.x == 180) { + this->movementFlags |= ENBOX_MOVE_0x80; + this->dyna.actor.world.rot.x = 0x7FFF; + this->collectableFlag = 0; + } else { + func_800C636C(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->collectableFlag = (this->dyna.actor.world.rot.x & 0x7F); + this->dyna.actor.world.rot.x = 0; + } + thisx->shape.rot.x = this->dyna.actor.world.rot.x; + this->getItem = ENBOX_GET_ITEM(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808689E8.s") + if (Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)) || this->getItem == GI_NONE) { + this->alpha = 255; + this->iceSmokeTimer = 100; + EnBox_SetupAction(this, EnBox_Open); + this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + animFrame = animFrameEnd; + } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL) && + !Flags_GetSwitch(globalCtx, this->switchFlag)) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (Rand_ZeroOne() < 0.5f) { + this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + this->unk_1A0 = -12; + EnBox_SetupAction(this, EnBox_FallOnSwitchFlag); + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else if ((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR || this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR) && + !Flags_GetClear(globalCtx, this->dyna.actor.room)) { + EnBox_SetupAction(this, EnBox_AppearOnRoomClear); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; + } + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else if (this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY || this->type == ENBOX_TYPE_BIG_SONG_SUNS) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868A6C.s") + } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) && + !Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnBox_SetupAction(this, EnBox_AppearSwitchFlag); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; + } + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else { + if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + this->dyna.actor.flags |= ACTOR_FLAG_80; + } + EnBox_SetupAction(this, EnBox_WaitOpen); + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868AFC.s") + if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868B74.s") + this->dyna.actor.shape.rot.y += 0x8000; + this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868CC8.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gBoxChestSkel, &gBoxChestOpenAnim, this->jointTable, this->morphTable, + OBJECT_BOX_CHEST_LIMB_MAX); + Animation_Change(&this->skelAnime, &gBoxChestOpenAnim, 1.5f, animFrame, animFrameEnd, ANIMMODE_ONCE, 0.0f); + if (Actor_IsSmallChest(this)) { + Actor_SetScale(&this->dyna.actor, 0.0075f); + Actor_SetFocus(&this->dyna.actor, 20.0f); + } else { + Actor_SetScale(&this->dyna.actor, 0.01f); + Actor_SetFocus(&this->dyna.actor, 40.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869020.s") + this->cutsceneIdxA = -1; + this->cutsceneIdxB = -1; + cutsceneIdx = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808692E0.s") + while (cutsceneIdx != -1) { + if (func_800F2178(cutsceneIdx) == 1) { + this->cutsceneIdxB = cutsceneIdx; + } else { + this->cutsceneIdxA = cutsceneIdx; + } + cutsceneIdx = ActorCutscene_GetAdditionalCutscene(cutsceneIdx); + } + func_80867BDC(&this->unk_1F4, globalCtx, &this->dyna.actor.home.pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Update.s") +void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = (EnBox*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869600.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869850.s") +void EnBox_RandomDustKinematic(EnBox* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + f32 randomRadius = Rand_ZeroOne() * 25.0f; + s16 randomAngle = Rand_ZeroOne() * 0x10000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869874.s") + *pos = this->dyna.actor.world.pos; + pos->x += Math_SinS(randomAngle) * randomRadius; + pos->z += Math_CosS(randomAngle) * randomRadius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808698B4.s") + velocity->y = 1.0f; + velocity->x = Math_SinS(randomAngle); + velocity->z = Math_CosS(randomAngle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Draw.s") + accel->x = 0.0f; + accel->y = 0.0f; + accel->z = 0.0f; +} + +void EnBox_SpawnDust(EnBox* this, GlobalContext* globalCtx) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + for (i = 0; i < 20; i++) { + EnBox_RandomDustKinematic(this, &pos, &velocity, &accel); + func_800B1280(globalCtx, &pos, &velocity, &accel, 100, 30, 15); + } +} + +void EnBox_Fall(EnBox* this, GlobalContext* globalCtx) { + f32 yDiff; + + this->alpha = 255; + this->movementFlags &= ~ENBOX_MOVE_IMMOBILE; + if (this->dyna.actor.bgCheckFlags & 1) { + this->movementFlags |= ENBOX_MOVE_UNUSED; + if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + this->movementFlags &= ~ENBOX_MOVE_FALL_ANGLE_SIDE; + } else { + this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + if (this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) { + this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.55f; + } else { + this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.65f; + } + if (this->dyna.actor.velocity.y < 5.5f) { + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; + EnBox_SetupAction(this, EnBox_WaitOpen); + } + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_BOUND); + EnBox_SpawnDust(this, globalCtx); + } + yDiff = this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight; + if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + this->dyna.actor.shape.rot.z = yDiff * 50.0f; + } else { + this->dyna.actor.shape.rot.z = -yDiff * 50.0f; + } +} + +void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (this->unk_1A0 >= 0) { + EnBox_SetupAction(this, EnBox_Fall); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else if (this->unk_1A0 >= -11) { + this->unk_1A0++; + } else if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->unk_1A0++; + } +} + +void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + Flags_SetClear(globalCtx, this->dyna.actor.room); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void func_80868AFC(EnBox* this, GlobalContext* globalCtx) { + if (func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0 || this->unk_1A0 != 0) { + EnBox_SetupAction(this, func_80868B74); + this->unk_1A0 = 0; + func_80867FBC(&this->unk_1F4, globalCtx, (this->movementFlags & ENBOX_MOVE_0x80) != 0); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); + } +} + +void func_80868B74(EnBox* this, GlobalContext* globalCtx) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->unk_1A0 < 0) { + this->unk_1A0++; + } else if (this->unk_1A0 < 40) { + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y -= 1.25f; + } else { + this->dyna.actor.world.pos.y += 1.25f; + } + this->unk_1A0++; + if (this->cutsceneIdxA != -1 && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { + if (this->unk_1A0 == 2) { + func_800B724C(globalCtx, &this->dyna.actor, 4); + } else if (this->unk_1A0 == 22) { + func_800B724C(globalCtx, &this->dyna.actor, 1); + } + } + } else if (this->unk_1A0 < 60) { + this->alpha += 12; + this->unk_1A0++; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } else { + EnBox_SetupAction(this, EnBox_WaitOpen); + ActorCutscene_Stop(this->dyna.actor.cutscene); + } +} + +void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + AnimationHeader* animHeader; + f32 frameCount; + f32 playbackSpeed; + EnBox_PlaybackSpeed playbackSpeedTable; + Player* player; + Vec3f offset; + + this->alpha = 255; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + if (this->unk_1EC != 0 && (this->cutsceneIdxB < 0 || ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB || + ActorCutscene_GetCurrentIndex() == -1)) { + if (this->unk_1EC < 0) { + animHeader = &gBoxChestOpenAnim; + playbackSpeed = 1.5f; + } else { + u8 playerForm; + + playbackSpeedTable = sPlaybackSpeed; + playerForm = gSaveContext.save.playerForm; + animHeader = sBigChestAnimations[playerForm]; + playbackSpeed = playbackSpeedTable.data[playerForm]; + } + + frameCount = Animation_GetLastFrame(animHeader); + Animation_Change(&this->skelAnime, animHeader, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + EnBox_SetupAction(this, EnBox_Open); + if (this->unk_1EC > 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DEMO_TRE_LGT, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, + -1); + func_801A3098(0x2B | 0x900); + } + + if (this->getItem == GI_STRAY_FAIRY) { + this->movementFlags |= ENBOX_MOVE_0x20; + } else { + if (this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) { + Flags_SetCollectible(globalCtx, this->collectableFlag); + } + Flags_SetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)); + } + } else { + player = GET_PLAYER(globalCtx); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); + if (offset.z > -50.0f && offset.z < 0.0f && fabsf(offset.y) < 10.0f && fabsf(offset.x) < 20.0f && + Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { + if ((this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) && + Flags_GetCollectible(globalCtx, this->collectableFlag)) { + this->getItem = GI_RECOVERY_HEART; + } + if (this->getItem == GI_MASK_CAPTAIN && INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + this->getItem = GI_RECOVERY_HEART; + } + if (this->getItem == GI_MASK_GIANT && INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + this->getItem = GI_RECOVERY_HEART; + } + Actor_PickUpNearby(&this->dyna.actor, globalCtx, -this->getItem); + } + if (Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + EnBox_SetupAction(this, EnBox_Open); + } + } +} + +void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + + this->dyna.actor.flags &= ~ACTOR_FLAG_80; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_1EC > 0) { + if (this->unk_1EC < 120) { + this->unk_1EC++; + } else { + Math_StepToF(&this->unk_1A8, 0.0f, 0.05f); + } + } else if (this->unk_1EC > -120) { + this->unk_1EC--; + } else { + Math_StepToF(&this->unk_1A8, 0.0f, 0.05f); + } + if (this->movementFlags & ENBOX_MOVE_0x20) { + this->movementFlags &= ~ENBOX_MOVE_0x20; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_ELFORG, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, + ((ENBOX_GET_CHEST_FLAG(&this->dyna.actor) & 0x7F) << 9) | STRAY_FAIRY_TYPE_CHEST); + } else if (this->movementFlags & ENBOX_MOVE_0x40) { + this->movementFlags &= ~ENBOX_MOVE_0x40; + } + } else { + f32 waterSurface; + WaterBox* waterBox; + s32 bgId; + u16 sfxId = 0; + + if (Animation_OnFrame(&this->skelAnime, gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 14.0f : 30.0f)) { + sfxId = NA_SE_EV_TBOX_UNLOCK; + } else if (Animation_OnFrame(&this->skelAnime, + gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 15.0f : 90.0f)) { + sfxId = NA_SE_EV_TBOX_OPEN; + } + if (sfxId != 0) { + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, sfxId); + } + if (this->skelAnime.jointTable[3].z > 0) { + this->unk_1A8 = (0x7D00 - this->skelAnime.jointTable[3].z) * 0.00006f; + if (this->unk_1A8 < 0.0f) { + this->unk_1A8 = 0.0f; + } else if (this->unk_1A8 > 1.0f) { + this->unk_1A8 = 1.0f; + } + } + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &waterSurface, &waterBox, &bgId) && + this->dyna.actor.floorHeight < waterSurface) { + EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); + } + } +} + +void EnBox_SpawnIceSmoke(EnBox* this, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f velocity = { 0, 1.0f, 0 }; + Vec3f accel = { 0, 0, 0 }; + f32 randomf; + + this->iceSmokeTimer++; + //! @bug sfxId should be NA_SE_EN_MIMICK_BREATH, but uses OoT's sfxId value + func_800B9010(&this->dyna.actor, NA_SE_EN_LAST3_COIL_ATTACK_OLD - SFX_FLAG); + if (Rand_ZeroOne() < 0.3f) { + randomf = 2.0f * Rand_ZeroOne() - 1.0f; + pos = this->dyna.actor.world.pos; + pos.x += randomf * 20.0f * Math_SinS(this->dyna.actor.world.rot.y + 0x4000); + pos.z += randomf * 20.0f * Math_CosS(this->dyna.actor.world.rot.y + 0x4000); + + randomf = 2.0f * Rand_ZeroOne() - 1.0f; + velocity.x = randomf * 1.6f * Math_SinS(this->dyna.actor.world.rot.y); + velocity.y = 1.8f; + velocity.z = randomf * 1.6f * Math_CosS(this->dyna.actor.world.rot.y); + EffectSsIceSmoke_Spawn(globalCtx, &pos, &velocity, &accel, 150); + } +} + +void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = (EnBox*)thisx; + + if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { + this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; + EnBox_ClipToGround(this, globalCtx); + } + if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + globalCtx->actorCtx.unk5 |= 8; + } + this->actionFunc(this, globalCtx); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + } + if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + } + Actor_SetFocus(&this->dyna.actor, 40.0f); + if (this->getItem == GI_ICE_TRAP && this->actionFunc == EnBox_Open && this->skelAnime.curFrame > 45.0f && + this->iceSmokeTimer < 100) { + EnBox_SpawnIceSmoke(this, globalCtx); + } + if (this->unk_1F4.unk_0C != NULL) { + this->unk_1F4.unk_0C(&this->unk_1F4, globalCtx); + } +} + +void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnBox* this = THIS; + s32 pad; + + if (limbIndex == OBJECT_BOX_CHEST_LIMB_01) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->type == ENBOX_TYPE_BIG_ORNATE) { + gSPDisplayList((*gfx)++, &gBoxChestBaseOrnateDL); + } else if (Actor_IsSmallChest(this)) { + if (this->getItem == GI_KEY_SMALL) { + gSPDisplayList((*gfx)++, &gBoxChestBaseGildedDL); + } else { + gSPDisplayList((*gfx)++, &gBoxChestBaseDL); + } + } else { + gSPDisplayList((*gfx)++, &gBoxChestBaseGildedDL); + } + } else if (limbIndex == OBJECT_BOX_CHEST_LIMB_03) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->type == ENBOX_TYPE_BIG_ORNATE) { + gSPDisplayList((*gfx)++, &gBoxChestLidOrnateDL); + } else if (Actor_IsSmallChest(this)) { + if (this->getItem == GI_KEY_SMALL) { + gSPDisplayList((*gfx)++, &gBoxChestLidGildedDL); + } else { + gSPDisplayList((*gfx)++, &gBoxChestLidDL); + } + } else { + gSPDisplayList((*gfx)++, &gBoxChestLidGildedDL); + } + } +} + +Gfx* EnBox_SetRenderMode1(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(dl); + return dl; +} + +Gfx* EnBox_SetRenderMode2(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* cur = dl; + + gDPSetRenderMode( + cur++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + + gSPEndDisplayList(cur++); + return dl; +} + +Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* cur = dl; + + gDPSetRenderMode(cur++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPEndDisplayList(cur++); + return dl; +} + +void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = (EnBox*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (this->unk_1F4.unk_10 != NULL) { + this->unk_1F4.unk_10(&this->unk_1F4, globalCtx); + } + if ((this->alpha == 255 && this->type != ENBOX_TYPE_BIG_INVISIBLE && this->type != ENBOX_TYPE_SMALL_INVISIBLE) || + (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && + (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_SetRenderMode1(globalCtx->state.gfxCtx)); + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_OPA_DISP); + } else if (this->alpha != 0) { + gDPPipeSync(POLY_XLU_DISP++); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode3(globalCtx->state.gfxCtx)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode2(globalCtx->state.gfxCtx)); + } + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_XLU_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.h b/src/overlays/actors/ovl_En_Box/z_en_box.h index aa7c425d2..02d9d95f9 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -2,22 +2,68 @@ #define Z_EN_BOX_H #include "global.h" +#include "objects/object_box/object_box.h" struct EnBox; +struct func_80867BDC_a0; typedef void (*EnBoxActionFunc)(struct EnBox*, GlobalContext*); +typedef void (*EnBoxUnkFunc)(struct func_80867BDC_a0* arg0, GlobalContext* globalCtx); + +typedef struct func_80867BDC_a0 { + /* 0x00 */ Vec3f pos; + /* 0x0C */ EnBoxUnkFunc unk_0C; + /* 0x10 */ EnBoxUnkFunc unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s32 unk_18; + /* 0x1C */ s32 unk_1C; + /* 0x20 */ s32 unk_20; +} func_80867BDC_a0; //size 0x24 + +typedef enum { + /* 0 */ ENBOX_TYPE_BIG, // big + /* 1 */ ENBOX_TYPE_BIG_ROOM_CLEAR, // appear on room clear, store temp clear as permanent clear + /* 2 */ ENBOX_TYPE_BIG_ORNATE, // boss key chest + /* 3 */ ENBOX_TYPE_BIG_SWITCH_FLAG_FALL, // falling, appear on switch flag set + /* 4 */ ENBOX_TYPE_BIG_INVISIBLE, // big, revealed with lens of truth or when opened + /* 5 */ ENBOX_TYPE_SMALL, // small + /* 6 */ ENBOX_TYPE_SMALL_INVISIBLE, // small, revealed with lens of truth or when opened + /* 7 */ ENBOX_TYPE_SMALL_ROOM_CLEAR, // use room clear, store temp clear as perm clear + /* 8 */ ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL, // falling, appear on switch flag set + /* 9 */ ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY,// NOT IMPLEMENTED, behaves like big chest + /* 10 */ ENBOX_TYPE_BIG_SONG_SUNS, // NOT IMPLEMENTED, behaves like big chest + /* 11 */ ENBOX_TYPE_BIG_SWITCH_FLAG, // big, appear on switch flag set + /* 12 */ ENBOX_TYPE_SMALL_SWITCH_FLAG // small, appear on switch flag set +} EnBoxType; typedef struct EnBox { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; - /* 0x01F0 */ char unk_1F0[0x01]; - /* 0x01F1 */ u8 unk_1F1; - /* 0x01F2 */ char unk_1F2[0x02]; - /* 0x01F4 */ char unk_1F4[0x0C]; - /* 0x0200 */ EnBoxActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x20]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ s32 unk_1A0; + /* 0x01A4 */ UNK_TYPE1 unk_1A4[0x04]; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ EnBoxActionFunc actionFunc; + /* 0x01B0 */ Vec3s jointTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x01CE */ Vec3s morphTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ u8 movementFlags; + /* 0x01EF */ u8 alpha; + /* 0x01F0 */ u8 switchFlag; + /* 0x01F1 */ u8 type; + /* 0x01F2 */ u8 iceSmokeTimer; + /* 0x01F3 */ s8 unk_1F3; + /* 0x01F4 */ func_80867BDC_a0 unk_1F4; + /* 0x0218 */ s16 cutsceneIdxA; + /* 0x021A */ s16 cutsceneIdxB; + /* 0x021C */ s32 getItem; + /* 0x0220 */ s32 collectableFlag; } EnBox; // size = 0x224 extern const ActorInit En_Box_InitVars; +#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) +#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) +#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) + #endif // Z_EN_BOX_H diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 45fe0c132..846989c0c 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -31,7 +31,7 @@ s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this); +s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this); @@ -64,91 +64,91 @@ const ActorInit En_GirlA_InitVars = { }; static ShopItemEntry sShopItemEntries[] = { - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X083F, 0X0840, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x083F, 0x0840, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X0841, 0X0842, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x0841, 0x0842, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_BLUE, func_800B8050, 1, 0X0843, 0X0844, GI_POTION_BLUE, EnGirlA_CanBuyPotionBlue, + { OBJECT_GI_LIQUID, GID_POTION_BLUE, func_800B8050, 1, 0x0843, 0x0844, GI_POTION_BLUE, EnGirlA_CanBuyPotionBlue, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06B6, 0X06B7, GI_FAIRY, EnGirlA_CanBuyFairy, + { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0x06B6, 0x06B7, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06BA, 0X06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0x06BA, 0x06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06B2, 0X06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x06B2, 0x06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X06AE, 0X06AF, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x06AE, 0x06AF, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06B4, 0X06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, + { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0x06B4, 0x06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06B8, 0X06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0x06B8, 0x06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06B0, 0X06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, + { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0x06B0, 0x06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X06AC, 0X06AD, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x06AC, 0x06AD, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06D3, 0X06D4, GI_FAIRY, EnGirlA_CanBuyFairy, + { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0x06D3, 0x06D4, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06D5, 0X06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0x06D5, 0x06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06D7, 0X06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0x06D7, 0x06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06CF, 0X06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x06CF, 0x06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06CD, 0X06CE, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, + { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0x06CD, 0x06CE, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, - { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06D1, 0X06D2, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, + { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0x06D1, 0x06D2, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X06CB, 0X06CC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x06CB, 0x06CC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X06C9, 0X06CA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x06C9, 0x06CA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, func_800B8050, 1, 0X29D9, 0X29DA, GI_MASK_ALL_NIGHT, + { OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, func_800B8050, 1, 0x29D9, 0x29DA, GI_MASK_ALL_NIGHT, EnGirlA_CanBuyMaskAllNight, EnGirlA_BuyMaskAllNight, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0X29DB, 0X29DC, GI_BOMB_BAG_20, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0x29DB, 0x29DC, GI_BOMB_BAG_20, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0X29DB, 0X29DC, GI_BOMB_BAG_30, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0x29DB, 0x29DC, GI_BOMB_BAG_30, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, func_800B8050, 3, 0X29DB, 0X29DC, GI_BOMB_BAG_40, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, func_800B8050, 3, 0x29DB, 0x29DC, GI_BOMB_BAG_40, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0X0654, 0X0655, GI_BOMB_BAG_20, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0x0654, 0x0655, GI_BOMB_BAG_20, EnGirlA_CanBuyBombBag20BombShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0X0656, 0X0657, GI_BOMB_BAG_30, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0x0656, 0x0657, GI_BOMB_BAG_30, EnGirlA_CanBuyBombBag30BombShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_2, GID_BOMBCHU, func_800B8050, 10, 0X0652, 0X0653, GI_BOMBCHUS_10, EnGirlA_CanBuyBombchus, + { OBJECT_GI_BOMB_2, GID_BOMBCHU, func_800B8050, 10, 0x0652, 0x0653, GI_BOMBCHUS_10, EnGirlA_CanBuyBombchus, EnGirlA_BuyBombchus, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0650, 0X0651, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0650, 0x0651, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X12DB, 0X12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x12DB, 0x12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X12DD, 0X12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x12DD, 0x12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X12DF, 0X12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x12DF, 0x12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BC5, 0X0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0BC5, 0x0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BC7, 0X0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x0BC7, 0x0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BC9, 0X0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x0BC9, 0x0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BCB, 0X0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0BCB, 0x0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BCD, 0X0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x0BCD, 0x0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BCF, 0X0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x0BCF, 0x0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE, GID_BOTTLE, func_800B8050, 1, 0X29F8, 0X29F9, GI_BOTTLE, EnGirlA_CanBuyBottle, + { OBJECT_GI_BOTTLE, GID_BOTTLE, func_800B8050, 1, 0x29F8, 0x29F9, GI_BOTTLE_STOLEN, EnGirlA_CanBuyBottleStolen, EnGirlA_BuyBottle, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, func_800B8050, 4, 0X29F2, 0X29F3, GI_SWORD_GREAT_FAIRY, + { OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, func_800B8050, 4, 0x29F2, 0x29F3, GI_SWORD_GREAT_FAIRY, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, func_800B8050, 1, 0X29F4, 0X29F5, GI_SWORD_KOKIRI, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, func_800B8050, 1, 0x29F4, 0x29F5, GI_SWORD_KOKIRI, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0X29F4, 0X29F5, GI_SWORD_RAZOR, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0x29F4, 0x29F5, GI_SWORD_RAZOR, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0X29F4, 0X29F5, GI_SWORD_GILDED, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0x29F4, 0x29F5, GI_SWORD_GILDED, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X29F6, 0X29F7, GI_SHIELD_HERO_2, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_HERO_2, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0X29F6, 0X29F7, GI_SHIELD_MIRROR, + { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_MIRROR, EnGirlA_CanBuyShieldMirror, EnGirlA_BuyShieldMirror, EnGirlA_BuyFanfare }, }; @@ -341,7 +341,7 @@ s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this) { if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 23b1b6223..6d89bef7b 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -486,7 +486,7 @@ void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { } else { this->unk_29C &= ~1; gSaveContext.save.weekEventReg[34] |= 8; - Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_TRUTH, 10000.0f, 50.0f); } } diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 217d32540..1a357dcd8 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -299,7 +299,7 @@ void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { ENTSN_SET_Z(&this->unk_1D8->actor, false); this->actionFunc = func_80AE0418; } else { - Actor_PickUp(&this->actor, globalCtx, GI_95, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, globalCtx, GI_SEAHORSE, 2000.0f, 1000.0f); } } diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index d29141499..2f1b4a1a4 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -333,7 +333,7 @@ void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; +static AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { if ((arg1 >= 0) && (arg1 < 3)) { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bdb5188e3..5989a3114 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -892,7 +892,7 @@ 0x800BE504:("func_800BE504",), 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), - 0x800BE63C:("func_800BE63C",), + 0x800BE63C:("Actor_IsSmallChest",), 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), @@ -4912,7 +4912,7 @@ 0x80863E48:("EnGirlA_CanBuyBombBag30BombShop",), 0x80863EC8:("EnGirlA_CanBuyBombchus",), 0x80863F94:("EnGirlA_CanBuyBombs",), - 0x80864034:("EnGirlA_CanBuyBottle",), + 0x80864034:("EnGirlA_CanBuyBottleStolen",), 0x8086406C:("EnGirlA_CanBuySword",), 0x808640A4:("EnGirlA_CanBuyShieldMirror",), 0x80864108:("EnGirlA_CanBuyFairy",), @@ -4962,31 +4962,31 @@ 0x8086732C:("EnDoor_Update",), 0x80867350:("EnDoor_OverrideLimbDraw",), 0x808674B0:("EnDoor_Draw",), - 0x80867BD0:("func_80867BD0",), + 0x80867BD0:("EnBox_SetupAction",), 0x80867BDC:("func_80867BDC",), 0x80867C14:("func_80867C14",), 0x80867C8C:("func_80867C8C",), 0x80867FBC:("func_80867FBC",), 0x80867FE4:("func_80867FE4",), - 0x8086800C:("func_8086800C",), + 0x8086800C:("EnBox_ClipToGround",), 0x808680AC:("EnBox_Init",), 0x808685FC:("EnBox_Destroy",), - 0x80868630:("func_80868630",), - 0x80868734:("func_80868734",), - 0x808687E8:("func_808687E8",), - 0x80868944:("func_80868944",), - 0x808689E8:("func_808689E8",), - 0x80868A6C:("func_80868A6C",), + 0x80868630:("EnBox_RandomDustKinematic",), + 0x80868734:("EnBox_SpawnDust",), + 0x808687E8:("EnBox_Fall",), + 0x80868944:("EnBox_FallOnSwitchFlag",), + 0x808689E8:("EnBox_AppearSwitchFlag",), + 0x80868A6C:("EnBox_AppearOnRoomClear",), 0x80868AFC:("func_80868AFC",), 0x80868B74:("func_80868B74",), - 0x80868CC8:("func_80868CC8",), - 0x80869020:("func_80869020",), - 0x808692E0:("func_808692E0",), + 0x80868CC8:("EnBox_WaitOpen",), + 0x80869020:("EnBox_Open",), + 0x808692E0:("EnBox_SpawnIceSmoke",), 0x808694A0:("EnBox_Update",), - 0x80869600:("func_80869600",), - 0x80869850:("func_80869850",), - 0x80869874:("func_80869874",), - 0x808698B4:("func_808698B4",), + 0x80869600:("EnBox_PostLimbDraw",), + 0x80869850:("EnBox_SetRenderMode1",), + 0x80869874:("EnBox_SetRenderMode2",), + 0x808698B4:("EnBox_SetRenderMode3",), 0x808698F4:("EnBox_Draw",), 0x80869D90:("EnPametfrog_Init",), 0x80869F90:("EnPametfrog_Destroy",), @@ -6508,12 +6508,12 @@ 0x808E0DA8:("EnEncount1_Update",), 0x808E0E40:("DemoTreLgt_Init",), 0x808E0EBC:("DemoTreLgt_Destroy",), - 0x808E0EE8:("func_808E0EE8",), - 0x808E0EF4:("func_808E0EF4",), - 0x808E0F4C:("func_808E0F4C",), - 0x808E0FE0:("func_808E0FE0",), + 0x808E0EE8:("DemoTreLgt_SetupWait",), + 0x808E0EF4:("DemoTreLgt_Wait",), + 0x808E0F4C:("DemoTreLgt_SetupAnimate",), + 0x808E0FE0:("DemoTreLgt_Animate",), 0x808E1270:("DemoTreLgt_Update",), - 0x808E12A4:("func_808E12A4",), + 0x808E12A4:("DemoTreLgt_OverrideLimbDraw",), 0x808E13FC:("DemoTreLgt_Draw",), 0x808E1560:("EnEncount2_Init",), 0x808E16B4:("EnEncount2_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index fd8ee4d45..9529203e4 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -7047,8 +7047,8 @@ 0x808E0DF8:("D_808E0DF8","UNK_TYPE1","",0x1), 0x808E1490:("D_808E1490","UNK_TYPE1","",0x1), 0x808E14B0:("Demo_Tre_Lgt_InitVars","UNK_TYPE1","",0x1), - 0x808E14D0:("D_808E14D0","UNK_TYPE4","",0x4), - 0x808E14D8:("D_808E14D8","UNK_TYPE1","",0x1), + 0x808E14D0:("sBoxLightAnimations","UNK_TYPE4","[2]",0x8), + 0x808E14D8:("sActionFuncs","UNK_TYPE4","[2]",0x8), 0x808E1ED0:("En_Encount2_InitVars","UNK_TYPE1","",0x1), 0x808E1EF0:("D_808E1EF0","UNK_TYPE1","",0x1), 0x808E1F14:("D_808E1F14","UNK_TYPE1","",0x1), From e729f104429cacdc915e27887090ceb8d956c9ab Mon Sep 17 00:00:00 2001 From: Kristopher Early <1191258+MrPolymorph@users.noreply.github.com> Date: Sun, 19 Jun 2022 02:29:44 +0100 Subject: [PATCH 18/53] Yasi descriptive names (#831) * Cleaned up yasi by giving symbols descriptive names * renamed variables to palm tree * Adding descriptive comment to root of xml asset file Co-authored-by: MrPolymorph <{ID}+{username}@users.noreply.github.com> --- assets/xml/objects/object_obj_yasi.xml | 15 ++++++++------- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 6 +++--- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/assets/xml/objects/object_obj_yasi.xml b/assets/xml/objects/object_obj_yasi.xml index b7d2c1fd1..a8e153edd 100644 --- a/assets/xml/objects/object_obj_yasi.xml +++ b/assets/xml/objects/object_obj_yasi.xml @@ -1,11 +1,12 @@  + - - - - - - - + + + + + + + diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 3dfea0818..4e9bb84b2 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -42,11 +42,11 @@ void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_obj_yasi_Colheader_001428); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gPalmTreeCol); this->dyna.actor.home.rot.y = 0; - if (OBJYASI_IS_WIDE(thisx)) { + if (PALM_TREE_IS_WIDE(thisx)) { this->dyna.actor.scale.x = 0.2f; this->dyna.actor.scale.z = 0.2f; } @@ -97,5 +97,5 @@ void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, object_obj_yasi_DL_000360); + Gfx_DrawDListOpa(globalCtx, gPalmTreeDL); } diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h index f4ab9ca9c..d1fdc6aed 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -11,6 +11,6 @@ typedef struct ObjYasi { extern const ActorInit Obj_Yasi_InitVars; -#define OBJYASI_IS_WIDE(thisx) ((thisx)->params & 1) +#define PALM_TREE_IS_WIDE(thisx) ((thisx)->params & 1) #endif // Z_OBJ_YASI_H From b6362cacbe5cf2d7ad541ce14d24ebb11417a8fe Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 18 Jun 2022 18:37:31 -0700 Subject: [PATCH 19/53] ClearTag cleanup (#830) --- assets/xml/objects/gameplay_keep.xml | 18 +++++----- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 34 +++++++++++++------ .../actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 12 ------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index f73e9252f..6b624857f 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1044,15 +1044,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index beb2f2d17..bfc6102b0 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -11,6 +11,18 @@ #define THIS ((EnClearTag*)thisx) +typedef enum { + /* 0x00 */ CLEAR_TAG_EFFECT_AVAILABLE, + /* 0x01 */ CLEAR_TAG_EFFECT_DEBRIS, + /* 0x02 */ CLEAR_TAG_EFFECT_FIRE, // never set to, remnant of OoT + /* 0x03 */ CLEAR_TAG_EFFECT_SMOKE, + /* 0x04 */ CLEAR_TAG_EFFECT_FLASH, + /* 0x05 */ CLEAR_TAG_EFFECT_LIGHT_RAYS, + /* 0x06 */ CLEAR_TAG_EFFECT_SHOCKWAVE, + /* 0x07 */ CLEAR_TAG_EFFECT_SPLASH, + /* 0x08 */ CLEAR_TAG_EFFECT_ISOLATED_SMOKE, +} ClearTagEffectType; + void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx); void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx); @@ -82,15 +94,15 @@ static f32 sLightRayMaxScale[] = { 25.0f, 100.0f, 48.0f, 20.0f, 32.0f, }; -static TexturePtr sSplashTex[] = { - gExplosionSplashTex1, - gExplosionSplashTex2, - gExplosionSplashTex3, - gExplosionSplashTex4, - gExplosionSplashTex5, - gExplosionSplashTex6, - gExplosionSplashTex7, - gExplosionSplashTex8, +static TexturePtr sWaterSplashTextures[] = { + gEffWaterSplash1Tex, + gEffWaterSplash2Tex, + gEffWaterSplash3Tex, + gEffWaterSplash4Tex, + gEffWaterSplash5Tex, + gEffWaterSplash6Tex, + gEffWaterSplash7Tex, + gEffWaterSplash8Tex, NULL, NULL, NULL, @@ -972,7 +984,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 200); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sSplashTex[effect->actionTimer])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sWaterSplashTextures[effect->actionTimer])); func_8012C9BC(gfxCtx); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK); isMaterialApplied++; @@ -996,7 +1008,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gExplosionSplashDL); + gSPDisplayList(POLY_XLU_DISP++, gEffWaterSplashDL); } } } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 61c4a638b..a2d188cba 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -5,18 +5,6 @@ struct EnClearTag; -typedef enum { - /* 0x00 */ CLEAR_TAG_EFFECT_AVAILABLE, - /* 0x01 */ CLEAR_TAG_EFFECT_DEBRIS, - /* 0x02 */ CLEAR_TAG_EFFECT_FIRE, // never set to, remnant of OoT - /* 0x03 */ CLEAR_TAG_EFFECT_SMOKE, - /* 0x04 */ CLEAR_TAG_EFFECT_FLASH, - /* 0x05 */ CLEAR_TAG_EFFECT_LIGHT_RAYS, - /* 0x06 */ CLEAR_TAG_EFFECT_SHOCKWAVE, - /* 0x07 */ CLEAR_TAG_EFFECT_SPLASH, - /* 0x08 */ CLEAR_TAG_EFFECT_ISOLATED_SMOKE, -} ClearTagEffectType; - typedef struct EnClearTagEffect { /* 0x00 */ u8 type; /* 0x01 */ u8 actionTimer; From d1b75e4c4b9fa365b9ba39e431734c150bfc9f40 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 18 Jun 2022 18:46:41 -0700 Subject: [PATCH 20/53] VisMono OK and documented (#829) * VisMono OK and documented * Add some more parentheses * Fix functions.h * Respond to hansldm's review --- include/PR/gbi.h | 1 + include/functions.h | 12 +- include/variables.h | 2 +- include/z64.h | 6 +- src/code/game.c | 6 +- src/code/z_rcp.c | 8 +- src/code/z_vismono.c | 177 +++++++++++++++++- .../fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c | 2 +- tools/disasm/functions.txt | 10 +- tools/sizes/code_functions.csv | 10 +- 10 files changed, 200 insertions(+), 34 deletions(-) diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 8e5aefe8e..34ec8af31 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -216,6 +216,7 @@ #define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ (((g)<<3) & 0x7c0) | \ (((b)>>2) & 0x3e) | ((a) & 0x1)) +#define GPACK_IA16(i, a) (((i) << 8) | (a)) #define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) /* diff --git a/include/functions.h b/include/functions.h index a29024850..1f19f5da4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2534,12 +2534,12 @@ void func_80140E80(void* param_1); // void func_8014151C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_80141678(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80141778(void); -void func_801418B0(void* arg0); -void func_80141900(void* arg0); -// void func_80141924(void); -// void func_80141C34(void); -void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); -// void func_8014204C(void); +void VisMono_Init(VisMono* this); +void VisMono_Destroy(VisMono* this); +// void VisMono_DesaturateTLUT(u16* tlut); +// void VisMono_DesaturateDList(Gfx* gfx); +void VisMono_Draw(VisMono* this, Gfx** gfxp); +// void VisMono_DrawOld(VisMono* this); void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); diff --git a/include/variables.h b/include/variables.h index c37938555..e8f8d5a3e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3562,7 +3562,7 @@ extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH]; // other segments extern GfxMasterList D_0E000000; extern Mtx D_01000000; -extern UNK_TYPE D_0F000000; +extern u16 D_0F000000[]; #endif diff --git a/include/z64.h b/include/z64.h index 7f1dfd701..5852b9212 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1404,10 +1404,10 @@ typedef struct { typedef struct { /* 0x00 */ u32 unk_00; /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8 primColor; - /* 0x0C */ Color_RGBA8 envColor; + /* 0x08 */ Color_RGBA8_u32 primColor; + /* 0x0C */ Color_RGBA8_u32 envColor; /* 0x10 */ u16* tlut; - /* 0x14 */ Gfx* monoDl; + /* 0x14 */ Gfx* dList; } VisMono; // size = 0x18 typedef struct DebugDispObject { diff --git a/src/code/game.c b/src/code/game.c index 2713be299..6f796bc12 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -52,7 +52,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &dlist, arg1); + VisMono_Draw(&sMonoColors, &dlist); } } } @@ -213,7 +213,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g func_80140CE0(&D_801F8010); func_801420C0(&D_801F8020); - func_801418B0(&sMonoColors); + VisMono_Init(&sMonoColors); func_80140898(&D_801F8048); func_801773A0(&D_801F7FF0); func_8013ED9C(); @@ -235,7 +235,7 @@ void GameState_Destroy(GameState* gameState) { func_801773C4(&D_801F7FF0); func_80140D04(&D_801F8010); func_801420F4(&D_801F8020); - func_80141900(&sMonoColors); + VisMono_Destroy(&sMonoColors); func_80140900(&D_801F8048); THA_Dt(&gameState->heap); GameAlloc_Cleanup(&gameState->alloc); diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index f4ffd43c1..1d13be316 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1239,11 +1239,11 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gSPDisplayList(&masterGfx[0], D_0E000000.syncSegments); gSPDisplayList(&masterGfx[1], sFillSetupDL); - gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); if (zbuffer != NULL) { gDPSetDepthImage(&masterGfx[3], zbuffer); } else { - gDPSetDepthImage(&masterGfx[3], &D_0F000000); + gDPSetDepthImage(&masterGfx[3], D_0F000000); } gSPEndDisplayList(&masterGfx[4]); @@ -1267,7 +1267,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); - gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1275,7 +1275,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g masterGfx = gGfxMasterDL->clearFrameBuffer; - gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gDPSetCycleType(&masterGfx[1], G_CYC_FILL); gDPSetRenderMode(&masterGfx[2], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[3], (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index 6c0d1ef22..b28ed2aa6 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -1,14 +1,179 @@ +/* + * File: z_vismono.c + * Description: Color frame buffer effect to desaturate the colors. + */ + #include "global.h" #include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_801418B0.s") +// Height of the fragments the color frame buffer (CFB) is split into. +// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into +// the half of tmem (0x800 bytes) dedicated to color-indexed data. +#define VISMONO_CFBFRAG_HEIGHT (0x800 / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141900.s") +// Maximum size of the dlist written by `VisMono_DesaturateDList`. +// `VisMono_DesaturateDList` consistently uses `VISMONO_DLSIZE - 2` double words, so this can be 2 less. +#define VISMONO_DLSIZE (3 + SCREEN_HEIGHT / VISMONO_CFBFRAG_HEIGHT * (7 + 2 + 2 + 3) + 2 + 2) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141924.s") +// How much each color component contributes to the desaturated result. +// These coefficients are close to what the YUV color space defines Y (luminance) as: +// https://en.wikipedia.org/wiki/YUV#Conversion_to/from_RGB +#define VISMONO_FAC_RED 2 +#define VISMONO_FAC_GREEN 4 +#define VISMONO_FAC_BLUE 1 +#define VISMONO_FAC_NORM (0x1F * VISMONO_FAC_RED + 0x1F * VISMONO_FAC_GREEN + 0x1F * VISMONO_FAC_BLUE) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141C34.s") +void VisMono_Init(VisMono* this) { + bzero(this, sizeof(VisMono)); + this->unk_00 = 0; + this->setScissor = false; + this->primColor.r = 255; + this->primColor.g = 255; + this->primColor.b = 255; + this->primColor.a = 255; + this->envColor.r = 0; + this->envColor.g = 0; + this->envColor.b = 0; + this->envColor.a = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/VisMono_Draw.s") +void VisMono_Destroy(VisMono* this) { + SystemArena_Free(this->dList); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_8014204C.s") +void VisMono_DesaturateTLUT(u16* tlut) { + s32 i; + + for (i = 0; i < 256; i++) { + // `tlut[i]` is a IA16 color + // `i` corresponds to either byte of a RGBA16 color RRRR_RGGG GGBB_BBBA from the color frame buffer + + // The high byte I (intensity) corresponds to `i` being interpreted as the high byte RRRR_RGGG + // I = (RRRRR * FAC_RED + GGG00 * FAC_GREEN) * (255 / FAC_NORM) + + // The low byte A (alpha) corresponds to `i` being interpreted as the low byte GGBB_BBBA + // A = (000GG * FAC_GREEN + BBBBB * FAC_BLUE) * (255 / FAC_NORM) + + // Note: I + A = (RRRRR * FAC_RED + GGGGG * FAC_GREEN + BBBBB * FAC_BLUE) * (255 / FAC_NORM) + + tlut[i] = GPACK_IA16( + (((i >> 3) & 0x1F) * VISMONO_FAC_RED + ((i << 2) & 0x1F) * VISMONO_FAC_GREEN) * 255 / VISMONO_FAC_NORM, + (((i >> 6) & 0x1F) * VISMONO_FAC_GREEN + ((i >> 1) & 0x1F) * VISMONO_FAC_BLUE) * 255 / VISMONO_FAC_NORM); + } +} + +Gfx* VisMono_DesaturateDList(Gfx* gfx) { + s32 y; + s32 height = VISMONO_CFBFRAG_HEIGHT; + u16* cfbFrag = D_0F000000; + + gDPPipeSync(gfx++); + // `G_TT_IA16`: use color-indexed images, and IA16 palettes + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_IA16 | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_2CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PRIM | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) | G_RM_CLD_SURF2); + // First color cycle sums texel 1 alpha and texel 0 color + // By using IA16 palettes, this means summing A (from the IA16 color texel 1 maps to) + // with I (from the IA16 color texel 0 maps to) + gDPSetCombineLERP(gfx++, 1, 0, TEXEL1_ALPHA, TEXEL0, 0, 0, 0, 1, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, + 0, 0, PRIMITIVE); + + for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { + // Load a few lines of the color frame buffer + gDPLoadTextureBlock(gfx++, cfbFrag, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2, height, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + // Set texel 0 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` + // Its position in texture image space is shifted along +S by 2 + gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, G_TX_RENDERTILE, + 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); + gDPSetTileSize(gfx++, G_TX_RENDERTILE, 2 << 2, 0, (SCREEN_WIDTH * 2 + 1) << 2, + (VISMONO_CFBFRAG_HEIGHT - 1) << 2); + + // Set texel 1 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` + // Its position in texture image space is shifted along +S by 1 + gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, 1, 1, + G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); + gDPSetTileSize(gfx++, 1, 1 << 2, 0, (SCREEN_WIDTH * 2) << 2, (VISMONO_CFBFRAG_HEIGHT - 1) << 2); + + // Draw a `SCREEN_WIDTH` wide, `height` high rectangle. + // Texture coordinate T (vertical) starts at 0 and changes by one each line (dtdy = 1) + // Texture coordinate S (horizontal) starts at 2 and changes by two each column (dsdx = 2) + + // Because texel 0 is shifted by 2 and texel 1 only by 1 along +S, + // a pixel at S coordinates s = 2+2*n will look at the 2*n-th byte of texel 0 and the 2*n+1-th byte of texel 1. + // (in "s = 2+2*n" the first "2" is the starting S coordinate and the second "2" is the dsdx value) + + // The 2*n-th byte of texel 0 is the high byte of the n-th RGBA16 color of the color frame buffer. + // The 2*n+1-th byte of texel 1 is the low byte of the n-th RGBA16 color of the color frame buffer. + + // With the TLUT computed by `VisMono_DesaturateTLUT`: + // The 2*n-th byte of texel 0 maps to a IA16 color where the high byte I (intensity) corresponds to + // the high byte of the n-th RGBA16 color of the color frame buffer. + // The 2*n+1-th byte of texel 1 maps to a IA16 color where the low byte A (alpha) corresponds to + // the low byte of the n-th RGBA16 color of the color frame buffer. + + // Since the combiner is in part set up to sum texel 0 color (I, intensity) with texel 1 alpha (A, alpha), + // the resulting color in the drawn rectangle is a desaturated color as defined by the `VISMONO_FAC_*` values. + + gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 2 << 5, 0, 2 << 10, + 1 << 10); + cfbFrag += SCREEN_WIDTH * height; + } + + gDPPipeSync(gfx++); + gSPEndDisplayList(gfx++); + return gfx; +} + +void VisMono_Draw(VisMono* this, Gfx** gfxp) { + Gfx* gfx = *gfxp; + u16* tlut; + Gfx* dList; + Gfx* dListEnd; + + if (this->tlut) { + tlut = this->tlut; + } else { + tlut = Graph_DlistAlloc(&gfx, 256 * G_IM_SIZ_16b_BYTES); + VisMono_DesaturateTLUT(tlut); + } + + if (this->dList) { + dList = this->dList; + } else { + dList = Graph_DlistAlloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx)); + dListEnd = VisMono_DesaturateDList(dList); + } + + gDPPipeSync(gfx++); + + if (this->setScissor == true) { + gSPDisplayList(gfx++, D_0E000000.setScissor); + } + + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + + gDPLoadTLUT_pal256(gfx++, tlut); + + gSPDisplayList(gfx++, dList); + + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +void VisMono_DrawOld(VisMono* this) { + if (this->tlut == NULL) { + this->tlut = SystemArena_Malloc(256 * G_IM_SIZ_16b_BYTES); + VisMono_DesaturateTLUT(this->tlut); + } + + if (this->dList == NULL) { + this->dList = SystemArena_Malloc(VISMONO_DLSIZE * sizeof(Gfx)); + VisMono_DesaturateDList(this->dList); + } +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index 4c27fe134..87f5638ac 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -31,7 +31,7 @@ const TransitionInit TransitionWipe5_InitVars = { #endif -extern UNK_TYPE D_0F000000; +extern u16 D_0F000000[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Start.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5989a3114..a0eae0028 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2769,12 +2769,12 @@ 0x8014151C:("func_8014151C",), 0x80141678:("func_80141678",), 0x80141778:("func_80141778",), - 0x801418B0:("func_801418B0",), - 0x80141900:("func_80141900",), - 0x80141924:("func_80141924",), - 0x80141C34:("func_80141C34",), + 0x801418B0:("VisMono_Init",), + 0x80141900:("VisMono_Destroy",), + 0x80141924:("VisMono_DesaturateTLUT",), + 0x80141C34:("VisMono_DesaturateDList",), 0x80141E60:("VisMono_Draw",), - 0x8014204C:("func_8014204C",), + 0x8014204C:("VisMono_DrawOld",), 0x801420C0:("func_801420C0",), 0x801420F4:("func_801420F4",), 0x80142100:("func_80142100",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 5b7c0d71d..bb57bb8a8 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2283,12 +2283,12 @@ asm/non_matchings/code/code_80140E80/func_80141200.s,func_80141200,0x80141200,0x asm/non_matchings/code/code_80140E80/func_8014151C.s,func_8014151C,0x8014151C,0x57 asm/non_matchings/code/code_80140E80/func_80141678.s,func_80141678,0x80141678,0x40 asm/non_matchings/code/code_80140E80/func_80141778.s,func_80141778,0x80141778,0x4E -asm/non_matchings/code/z_vismono/func_801418B0.s,func_801418B0,0x801418B0,0x14 -asm/non_matchings/code/z_vismono/func_80141900.s,func_80141900,0x80141900,0x9 -asm/non_matchings/code/z_vismono/func_80141924.s,func_80141924,0x80141924,0xC4 -asm/non_matchings/code/z_vismono/func_80141C34.s,func_80141C34,0x80141C34,0x8B +asm/non_matchings/code/z_vismono/VisMono_Init.s,VisMono_Init,0x801418B0,0x14 +asm/non_matchings/code/z_vismono/VisMono_Destroy.s,VisMono_Destroy,0x80141900,0x9 +asm/non_matchings/code/z_vismono/VisMono_DesaturateTLUT.s,VisMono_DesaturateTLUT,0x80141924,0xC4 +asm/non_matchings/code/z_vismono/VisMono_DesaturateDList.s,VisMono_DesaturateDList,0x80141C34,0x8B asm/non_matchings/code/z_vismono/VisMono_Draw.s,VisMono_Draw,0x80141E60,0x7B -asm/non_matchings/code/z_vismono/func_8014204C.s,func_8014204C,0x8014204C,0x1D +asm/non_matchings/code/z_vismono/VisMono_DrawOld.s,VisMono_DrawOld,0x8014204C,0x1D asm/non_matchings/code/code_801420C0/func_801420C0.s,func_801420C0,0x801420C0,0xD asm/non_matchings/code/code_801420C0/func_801420F4.s,func_801420F4,0x801420F4,0x3 asm/non_matchings/code/code_801420C0/func_80142100.s,func_80142100,0x80142100,0xD0 From 03ba9178537f722c2670e69fbb3d3a677f896f57 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 18 Jun 2022 18:51:58 -0700 Subject: [PATCH 21/53] Dm_Stk (Skull Kid) documented, object_stk and object_stk3 fully documented, object_stk2 mostly documented (#827) * Most of object_stk done * Document the original name for every animation * First pass names on every single animation * Enum for animations * Enum for limbs * Very low hanging fruit in dm_stk * Document a lot more in dm_stk * Name most remaining struct vars * Name a bunch of functions * First pass names to all sound functions * Name most functions * Name all other object symbols used by dm_stk * Name all remaining functions and struct vars * Much better animation names and documentation * Lots more function documentation * Document some stuff * Name the title cutscene thing * Last little bit of cleanup * Format * Rename SFX functions * Fix typo in header comment * Respond to Elliptic's review * Respond to Elliptic's clarification about Version1/2 * hitCount -> deflectCount * Take into account some of the feedback that was given for DmZl4 --- assets/xml/objects/object_stk.xml | 240 ++-- assets/xml/objects/object_stk2.xml | 131 +- assets/xml/objects/object_stk3.xml | 15 +- src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c | 4 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 1328 ++++++++++++--------- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h | 73 +- tools/disasm/functions.txt | 72 +- 7 files changed, 1087 insertions(+), 776 deletions(-) diff --git a/assets/xml/objects/object_stk.xml b/assets/xml/objects/object_stk.xml index 68e8ae26b..9698e335e 100644 --- a/assets/xml/objects/object_stk.xml +++ b/assets/xml/objects/object_stk.xml @@ -1,110 +1,138 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk2.xml b/assets/xml/objects/object_stk2.xml index fe62266a8..2aab5947e 100644 --- a/assets/xml/objects/object_stk2.xml +++ b/assets/xml/objects/object_stk2.xml @@ -1,86 +1,105 @@  + - + + - + - - + + - - - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + - + - + - - - - - - - - - + + + + + + + + + - + - - + + - - + + - + - - - - - + + + + + - + - + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk3.xml b/assets/xml/objects/object_stk3.xml index dbd5da652..7b45bf201 100644 --- a/assets/xml/objects/object_stk3.xml +++ b/assets/xml/objects/object_stk3.xml @@ -1,11 +1,12 @@  + - - - - - - - + + + + + + + diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 4d5a20114..88932cd71 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -30,7 +30,7 @@ const ActorInit Dm_Sa_InitVars = { (ActorFunc)DmSa_Draw, }; -static AnimationInfo D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; +static AnimationInfo D_80A2ED00[] = { { &gSkullKidTPoseAnim, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { f32 frameCount; @@ -52,7 +52,7 @@ void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0xFF; this->actor.targetArrowOffset = 3000.0f; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_stk_Skel_013328, NULL, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); func_80A2E960(&this->skelAnime, D_80A2ED00, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 782ef8679..10cd5550c 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1,11 +1,14 @@ /* * File: z_dm_stk.c * Overlay: ovl_Dm_Stk - * Description: Skull Kid (cutscene) + * Description: Skull Kid. Also manages Majora's Mask in the cutscene where its backstory is explained. + * + * This actor is responsible for some somewhat unintuitive things. For example, during certain cutscenes, + * it is responsible for handling the player's sound effects as well. As another example, this actor makes + * time pass when the player looks through the Astral Observatory telescope. */ #include "z_dm_stk.h" -#include "objects/object_stk/object_stk.h" #include "objects/object_stk2/object_stk2.h" #include "objects/object_stk3/object_stk3.h" @@ -18,20 +21,134 @@ void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmStk_Update(Actor* thisx, GlobalContext* globalCtx); void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx); -void func_80AA1704(DmStk* this, GlobalContext* globalCtx); -void func_80AA1714(DmStk* this, GlobalContext* globalCtx); -void func_80AA17F8(DmStk* this, GlobalContext* globalCtx); -void func_80AA18D8(DmStk* this, GlobalContext* globalCtx); -void func_80AA192C(DmStk* this, GlobalContext* globalCtx); -void func_80AA1998(DmStk* this, GlobalContext* globalCtx); -void func_80AA19EC(DmStk* this, GlobalContext* globalCtx); -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx); -void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx); -void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx); -void func_80AA1C64(DmStk* this, GlobalContext* globalCtx); -void func_80AA2720(DmStk* this, GlobalContext* globalCtx); -void func_80AA27EC(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_DoNothing(DmStk* this, GlobalContext* globalCtx); +void DmStk_DoNothing(DmStk* this, GlobalContext* globalCtx); +void DmStk_WaitForTelescope(DmStk* this, GlobalContext* globalCtx); +void DmStk_StartTelescopeCutscene(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_DeflectHit(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_Idle(DmStk* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SK_ANIMATION_SHAKE_HEAD, + /* 1 */ SK_ANIMATION_WALK, + /* 2 */ SK_ANIMATION_LOOK_AROUND, // Not used in the final game + /* 3 */ SK_ANIMATION_IDLE, + /* 4 */ SK_ANIMATION_UNUSED_IDLE, // Unused duplicate of SK_ANIMATION_IDLE + /* 5 */ SK_ANIMATION_BENT_OVER_HEAD_TWITCH, + /* 6 */ SK_ANIMATION_GLITCHY_HORSE_RIDE_START, // Not used in the final game + /* 7 */ SK_ANIMATION_RECLINING_FLOAT, + /* 8 */ SK_ANIMATION_CURSE_START, + /* 9 */ SK_ANIMATION_CURSE_LOOP, + /* 10 */ SK_ANIMATION_LAUGH_START, + /* 11 */ SK_ANIMATION_LAUGH_LOOP, + /* 12 */ SK_ANIMATION_HIDE_OCARINA_START, + /* 13 */ SK_ANIMATION_HIDE_OCARINA_LOOP, + /* 14 */ SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING, + /* 15 */ SK_ANIMATION_PLAY_OCARINA_AND_LAUGH, + /* 16 */ SK_ANIMATION_PICK_UP_OCARINA, // Not used in the final game + /* 17 */ SK_ANIMATION_LOOK_AT_OCARINA, // Not used in the final game + /* 18 */ SK_ANIMATION_KICK_OVER_LINK, + /* 19 */ SK_ANIMATION_SEARCH_LINK, + /* 20 */ SK_ANIMATION_UNUSED_KICK_OVER_LINK, // Unused duplicate of SK_ANIMATION_KICK_OVER_LINK + /* 21 */ SK_ANIMATION_UNUSED_SEARCH_LINK, // Unused duplicate of SK_ANIMATION_SEARCH_LINK + /* 22 */ SK_ANIMATION_HORSE_RIDE_START, + /* 23 */ SK_ANIMATION_HORSE_RIDE_LOOP, + /* 24 */ SK_ANIMATION_RAISE_MASK_START, + /* 25 */ SK_ANIMATION_RAISE_MASK_LOOP, + /* 26 */ SK_ANIMATION_LOWER_MASK, + /* 27 */ SK_ANIMATION_JUMP_WHILE_HIDING_OCARINA, + /* 28 */ SK_ANIMATION_HORSE_RIDE_AND_ROTATE, // Used when Link gets thrown off his horse + /* 29 */ SK_ANIMATION_PLAY_OCARINA_WHILE_FLOATING, + /* 30 */ SK_ANIMATION_FLOATING_TURN_AROUND, + /* 31 */ SK_ANIMATION_OCARINA_JUGGLE, + /* 32 */ SK_ANIMATION_CALL_DOWN_MOON_START, + /* 33 */ SK_ANIMATION_CALL_DOWN_MOON_LOOP, + /* 34 */ SK_ANIMATION_SMACK_FAIRY_START, + /* 35 */ SK_ANIMATION_SMACK_FAIRY_LOOP, + /* 36 */ SK_ANIMATION_HIT_BY_BUBBLE, + /* 37 */ SK_ANIMATION_DROP_OCARINA, + /* 38 */ SK_ANIMATION_FLOATING_ARMS_CROSSED, + /* 39 */ SK_ANIMATION_DEFLECT_ATTACK, + /* 40 */ SK_ANIMATION_TELESCOPE_LOOK_UP_START, + /* 41 */ SK_ANIMATION_TELESCOPE_LOOK_UP_LOOP, + /* 42 */ SK_ANIMATION_SURPRISE_START, + /* 43 */ SK_ANIMATION_SURPRISE_LOOP, + /* 44 */ SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START, + /* 45 */ SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_LOOP, + /* 46 */ SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START, + /* 47 */ SK_ANIMATION_HOLD_HEAD_AND_SHAKE_LOOP, + /* 48 */ SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START, + /* 49 */ SK_ANIMATION_HOLD_HEAD_AND_SCREAM_LOOP, + /* 50 */ SK_ANIMATION_HUDDLE_WITH_FAIRIES, + /* 51 */ SK_ANIMATION_SEARCH_MASK_SALESMAN, + /* 52 */ SK_ANIMATION_HOLD_UP_MASK_START, + /* 53 */ SK_ANIMATION_HOLD_UP_MASK_LOOP, + /* 54 */ SK_ANIMATION_SHIVER, + /* 55 */ SK_ANIMATION_DRAW, + /* 56 */ SK_ANIMATION_BENT_OVER_LOOK_UP, + /* 57 */ SK_ANIMATION_SPANK, + /* 58 */ SK_ANIMATION_HIP_SHAKE_AND_JUMP, + /* 59 */ SK_ANIMATION_PLAY_FLUTE, + /* 60 */ SK_ANIMATION_CARTWHEEL, + /* 61 */ SK_ANIMATION_LIE_FLAT, + /* 62 */ SK_ANIMATION_DANGLE_FROM_MASK_START, + /* 63 */ SK_ANIMATION_DANGLE_FROM_MASK_LOOP, + /* 64 */ SK_ANIMATION_DROPPED_FROM_MASK, + /* 65 */ SK_ANIMATION_LOOK_UP_AT_GIANTS, + /* 66 */ SK_ANIMATION_ASHAMED_START, + /* 67 */ SK_ANIMATION_ASHAMED_LOOP, + /* 68 */ SK_ANIMATION_LOOK_LEFT_START, + /* 69 */ SK_ANIMATION_LOOK_LEFT_LOOP, + /* 70 */ SK_ANIMATION_SNIFF, + /* 71 */ SK_ANIMATION_LAUGH_AFTER_SNIFF, +} SkullKidAnimationIndex; + +typedef enum { + /* 0 */ SK_MASK_TYPE_NO_MASK, + /* 1 */ SK_MASK_TYPE_NORMAL, + /* 2 */ SK_MASK_TYPE_GLOWING_EYES, + /* 3 */ SK_MASK_TYPE_FADING_OUT, + /* 9 */ SK_MASK_TYPE_RAISED = 9, +} SkullKidMaskType; + +typedef enum { + /* 0 */ SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE, + /* 1 */ SK_HAND_TYPE_HOLDING_LINK_MASK, + /* 2 */ SK_HAND_TYPE_HOLDING_MAJORAS_MASK, + /* 3 */ SK_HAND_TYPE_HOLDING_OCARINA, + /* 4 */ SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA, + /* 5 */ SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE, + /* 6 */ SK_HAND_TYPE_HOLDING_FLUTE, + /* 9 */ SK_HAND_TYPE_DEFAULT = 9, +} SkullKidHandType; + +typedef enum { + /* 0 */ SK_FADE_IN_STATE_NONE, + /* 1 */ SK_FADE_IN_STATE_START, + /* 2 */ SK_FADE_IN_STATE_INCREASE_FOG, + /* 3 */ SK_FADE_IN_STATE_INCREASE_ALPHA, +} SkullKidFadeInState; + +typedef enum { + /* 0 */ SK_FADE_OUT_STATE_NONE, + /* 1 */ SK_FADE_OUT_STATE_FADING_OUT, +} SkullKidFadeOutState; + +typedef enum { + /* 0 */ SK_DEKU_PIPES_CS_STATE_NOT_READY, + /* 1 */ SK_DEKU_PIPES_CS_STATE_READY, + /* 2 */ SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA, + /* 3 */ SK_DEKU_PIPES_CS_STATE_START, + /* 4 */ SK_DEKU_PIPES_CS_STATE_END +} SkullKidDekuPipesCutsceneState; const ActorInit Dm_Stk_InitVars = { ACTOR_DM_STK, @@ -103,101 +220,111 @@ static DamageTable sDamageTable = { }; static AnimationInfo sAnimations[] = { - { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidShakeHeadAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidBentOverHeadTwitchAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidGlitchyHorseRideStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidRecliningFloatAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCurseStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidCurseLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLaughStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLaughLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHideOcarinaStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHideOcarinaLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidPickUpOcarinaAndStartPlayingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayOcarinaAndLaughAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidPickUpOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookAtOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidKickOverLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSearchLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidKickOverLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSearchLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHorseRideStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHorseRideLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidRaiseMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidRaiseMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLowerMaskAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidJumpWhileHidingOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHorseRideAndRotateAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayOcarinaWhileFloatingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidFloatingTurnAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidOcarinaJuggleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCallDownMoonStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidCallDownMoonLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSmackFairyStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSmackFairyLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHitByBubbleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDropOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidFloatingArmsCrossedAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDeflectAttackAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidTelescopeLookUpStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidTelescopeLookUpLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSurpriseStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSurpriseLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookAroundForGiantsStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookAroundForGiantsLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldHeadAndShakeStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldHeadAndShakeLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldHeadAndScreamStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldHeadAndScreamLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHuddleWithFairiesAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSearchMaskSalesmanAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldUpMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldUpMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidShiverAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDrawAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidBentOverLookUpAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSpankAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHipShakeAndJumpAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayFluteAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCartwheelAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDroppedFromMaskAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookUpAtGiantsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidAshamedStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidAshamedLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookLeftStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookLeftLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSniffAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLaughAfterSniffAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; -void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { - s32 objectIdx; +/** + * Ensures the correct object for the current animation is in segment 6. + */ +void DmStk_LoadObjectForAnimation(DmStk* this, GlobalContext* globalCtx) { + s32 objectIndex; - if (((this->unk_2E0 >= 0) && (this->unk_2E0 <= 5)) || (this->unk_2E0 == 32) || (this->unk_2E0 == 33) || - (this->unk_2E0 == 40) || (this->unk_2E0 == 41)) { - objectIdx = this->unk_336; - } else if (this->unk_2E0 > 64) { - objectIdx = this->unk_338; + if (((this->animationId >= SK_ANIMATION_SHAKE_HEAD) && (this->animationId <= SK_ANIMATION_BENT_OVER_HEAD_TWITCH)) || + (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_START) || + (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) || + (this->animationId == SK_ANIMATION_TELESCOPE_LOOK_UP_START) || + (this->animationId == SK_ANIMATION_TELESCOPE_LOOK_UP_LOOP)) { + objectIndex = this->objectStkObjectIndex; + } else if (this->animationId >= SK_ANIMATION_LOOK_UP_AT_GIANTS) { + objectIndex = this->objectStk3ObjectIndex; } else { - objectIdx = this->unk_337; + objectIndex = this->objectStk2ObjectIndex; } - if (objectIdx >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIdx].segment); + if (objectIndex >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); } } -void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, u16 index) { - func_80A9FDB0(this, globalCtx); +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmStk_ChangeAnimation(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, + u16 unusedExtraOffset) { + DmStk_LoadObjectForAnimation(this, globalCtx); - animation += index; + animation += unusedExtraOffset; Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, (animation->frameCount < 0.0f) ? Animation_GetLastFrame(&animation->animation->common) @@ -205,7 +332,12 @@ void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, animation->mode, animation->morphFrames); } -void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the intro cutscene, i.e., the cutscene + * that starts when the player start a new game and ends when the screen fades to white + * after Skull Kid steals Epona. + */ +void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames + 20) { case 1195: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); @@ -291,13 +423,22 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA00CC(DmStk* this, GlobalContext* globalCtx) { +/** + * This is supposed to play a bell sound in the title cutscene where the Skull Kid is + * looking at the moon on top of the Clock Tower. However, it doesn't actually play + * any sound in-game, since all sound effects are muted when it plays. + */ +void DmStk_PlaySfxForTitleCutscene(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 535) { func_8019F128(NA_SE_EV_CLOCK_TOWER_BELL); } } -void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the intro cutscene, i.e., the cutscene + * that starts after the fade-to-white and ends when the player gains control. + */ +void DmStk_PlaySfxForIntroCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 78: case 89: @@ -325,7 +466,11 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid steals Majora's Mask from + * the Happy Mask Salesman. + */ +void DmStk_PlaySfxForObtainingMajorasMaskCutscene(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 18: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); @@ -341,7 +486,12 @@ void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the curse cutscene, i.e., the cutscene + * that starts when Link falls down the large hole and ends with a fade-to-black to + * the hallucinatory Deku Scrubs scene. + */ +void DmStk_PlaySfxForCurseCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 415: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 100); @@ -362,7 +512,12 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the curse cutscene, i.e., the cutscene + * that starts once the hallucinatory Deku Scrubs scene is over and ends when the player + * gains control. + */ +void DmStk_PlaySfxForCurseCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); switch (globalCtx->csCtx.frames) { @@ -410,8 +565,13 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { - static s32 D_80AA3CB8 = 0; +/** + * Handles sound effects for the intro cutscene at the top of the Clock Tower. Specifically, + * it handles the variation of the cutscene that plays the first time the player reaches the + * top of the Clock Tower, which is slightly longer. + */ +void DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { + static s32 sMoonCallTimer = 0; switch (globalCtx->csCtx.frames) { case 140: @@ -436,7 +596,7 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { break; } - if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { + if ((this->animationId == SK_ANIMATION_OCARINA_JUGGLE) && (globalCtx->csCtx.frames < 700)) { if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { @@ -445,33 +605,44 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { } if (globalCtx->csCtx.frames >= 700) { - if (D_80AA3CB8 < 128) { - if ((D_80AA3CB8 & 0x1F) == 0) { + if (sMoonCallTimer < 128) { + if ((sMoonCallTimer & 0x1F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); - } else if ((D_80AA3CB8 & 0x1F) == 16) { + } else if ((sMoonCallTimer & 0x1F) == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } - D_80AA3CB8++; + + sMoonCallTimer++; } } else { - D_80AA3CB8 = 0; + sMoonCallTimer = 0; } } -void func_80AA05F0(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid drops the Ocarina of Time. + */ +void DmStk_PlaySfxForDroppingOcarinaCutscene(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } -void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid is shivering in the rain. + */ +void DmStk_PlaySfxForShiveringInRainCutscene(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } -void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid is playing with Tatl and Tael + * in Termina Field. + */ +void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 58: case 61: @@ -493,7 +664,12 @@ void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the ending cutscene, i.e., the cutscene + * that starts after the Dawn of the New Day screen and ends with a fade to black as + * the Giants are walking away. + */ +void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 5: func_801A4A28(12); @@ -505,7 +681,11 @@ void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the ending cutscene, i.e., the cutscene + * that starts after a fade-to-black and ends after the credits start. + */ +void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); switch (globalCtx->csCtx.frames) { @@ -554,7 +734,7 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; } - if (this->unk_2E0 == 0) { + if (this->animationId == SK_ANIMATION_SHAKE_HEAD) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } @@ -562,19 +742,24 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); } - } else if (this->unk_2E0 == 71) { + } else if (this->animationId == SK_ANIMATION_LAUGH_AFTER_SNIFF) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } - } else if ((this->unk_2E0 == 70) && + } else if ((this->animationId == SK_ANIMATION_SNIFF) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } -void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { - static s32 D_80AA3CBC = 0; +/** + * Handles sound effects for the intro cutscene at the top of the Clock Tower. Specifically, + * it handles the variation of the cutscene that plays the second or later time the player + * reaches the top of the Clock Tower, which is slightly shorter. + */ +void DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { + static s32 sMoonCallTimer = 0; switch (globalCtx->csCtx.frames) { case 40: @@ -596,27 +781,32 @@ void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { } if (globalCtx->csCtx.frames >= 408) { - if (D_80AA3CBC < 128) { - if ((D_80AA3CBC & 0x1F) == 0) { + if (sMoonCallTimer < 128) { + if ((sMoonCallTimer & 0x1F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); - } else if ((D_80AA3CBC & 0x1F) == 16) { + } else if ((sMoonCallTimer & 0x1F) == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } - D_80AA3CBC++; + + sMoonCallTimer++; } } else { - D_80AA3CBC = 0; + sMoonCallTimer = 0; } } -void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { - this->unk_310.x = this->actor.projectedPos.x; - this->unk_310.y = this->actor.projectedPos.y; - this->unk_310.z = this->actor.projectedPos.z; +/** + * Handles sound effects for the cutscene that plays after the player plays the + * Oath to Order at the top of the Clock Tower. + */ +void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, GlobalContext* globalCtx) { + this->oathToOrderCutsceneVoicePos.x = this->actor.projectedPos.x; + this->oathToOrderCutsceneVoicePos.y = this->actor.projectedPos.y; + this->oathToOrderCutsceneVoicePos.z = this->actor.projectedPos.z; switch (globalCtx->csCtx.frames) { case 64: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL06_SURPRISED); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL06_SURPRISED); break; case 327: @@ -636,11 +826,11 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { case 486: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL08_CRY_BIG); break; case 496: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL09_SCREAM); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL09_SCREAM); break; case 590: @@ -652,7 +842,7 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { break; case 594: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL24_SCREAM2); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL24_SCREAM2); break; } @@ -679,7 +869,12 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene before the player warps to the moon. Specifically, + * it handles the variation of the cutscene that plays the first time the player warps to the + * moon, which is slightly longer. + */ +void DmStk_PlaySfxForMoonWarpCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 551: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); @@ -696,7 +891,12 @@ void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene before the player warps to the moon. Specifically, + * it handles the variation of the cutscene that plays the second or later time the player + * warps to the moon, which is slightly shorter. + */ +void DmStk_PlaySfxForMoonWarpCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 311: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); @@ -713,31 +913,34 @@ void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for all cutscenes. + */ +void DmStk_PlaySfxForCutscenes(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { switch (globalCtx->sceneNum) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { - func_80A9FED8(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneFirstPart(this, globalCtx); } else if (gSaveContext.sceneSetupIndex == 0) { - func_80AA0100(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneSecondPart(this, globalCtx); } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { - func_80AA0158(this, globalCtx); + DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, globalCtx); } break; case SCENE_CLOCKTOWER: if (gSaveContext.sceneSetupIndex == 1) { - func_80AA00CC(this, globalCtx); + DmStk_PlaySfxForTitleCutscene(this, globalCtx); } break; case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA01C0(this, globalCtx); + DmStk_PlaySfxForCurseCutsceneFirstPart(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA0264(this, globalCtx); + DmStk_PlaySfxForCurseCutsceneSecondPart(this, globalCtx); } } break; @@ -745,19 +948,19 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0420(this, globalCtx); + DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA05F0(this, globalCtx); + DmStk_PlaySfxForDroppingOcarinaCutscene(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 2) { - func_80AA09DC(this, globalCtx); + DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 3) { - func_80AA0B08(this, globalCtx); + DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 2) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0DA8(this, globalCtx); + DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA0E1C(this, globalCtx); + DmStk_PlaySfxForMoonWarpCutsceneVersion2(this, globalCtx); } } break; @@ -765,35 +968,35 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0634(this, globalCtx); + DmStk_PlaySfxForShiveringInRainCutscene(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 2) { - func_80AA066C(this, globalCtx); + DmStk_PlaySfxForPlayingWithFairiesCutscene(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 7) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA071C(this, globalCtx); + DmStk_PlaySfxForEndingCutsceneFirstPart(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA076C(this, globalCtx); + DmStk_PlaySfxForEndingCutsceneSecondPart(this, globalCtx); } } break; } } - if (this->unk_2E0 == 1) { + if (this->animationId == SK_ANIMATION_WALK) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); } - } else if (this->unk_2E0 == 19) { + } else if (this->animationId == SK_ANIMATION_SEARCH_LINK) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); } - } else if (this->unk_2E0 == 14) { + } else if (this->animationId == SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } - } else if (this->unk_2E0 == 15) { + } else if (this->animationId == SK_ANIMATION_PLAY_OCARINA_AND_LAUGH) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } @@ -808,42 +1011,43 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; DmStk* this = THIS; - this->unk_33B = 1; - if (this->actor.params != 1) { - this->unk_33A = 0; - this->unk_336 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); - this->unk_337 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); - this->unk_338 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); - if (this->unk_336 < 0) { + this->shouldDraw = true; + if (DM_STK_GET_TYPE(&this->actor) != DM_STK_TYPE_MAJORAS_MASK) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_NOT_READY; + this->objectStkObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); + this->objectStk2ObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); + this->objectStk3ObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); + if (this->objectStkObjectIndex < 0) { Actor_MarkForDeath(&this->actor); } - this->unk_328 = 0; - this->unk_339 = 0; - this->unk_32C = 1; - this->unk_2E0 = 3; - this->unk_2E8 = globalCtx->lightCtx.unk7; - this->unk_2EC = globalCtx->lightCtx.unk8; - this->unk_2F0 = globalCtx->lightCtx.unk9; + this->tatlMessageTimer = 0; + this->deflectCount = 0; + this->maskType = SK_MASK_TYPE_NORMAL; + this->animationId = SK_ANIMATION_IDLE; + this->fogR = globalCtx->lightCtx.unk7; + this->fogG = globalCtx->lightCtx.unk8; + this->fogB = globalCtx->lightCtx.unk9; if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { - this->unk_2E4 = 0; - this->unk_2F8 = 0; - this->unk_2FC = 1000; - this->unk_300 = 1.0f; - this->actionFunc = func_80AA1704; + this->alpha = 0; + this->fogN = 0; + this->fogF = 1000; + this->fogScale = 1.0f; + this->actionFunc = DmStk_DoNothing; } else if (globalCtx->sceneNum == SCENE_OKUJOU) { - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->unk_335 = 0; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->hasBeenHit = false; Collider_InitCylinder(globalCtx, &this->collider); if (gSaveContext.save.entranceIndex == 0x2C00) { if (gSaveContext.sceneSetupIndex == 0) { if (gSaveContext.unk_3DD0[3] == 0) { + // Starts a 5 minute (300 second) timer until the moon falls. func_8010E9F0(3, 300); XREG(80) = 200; XREG(81) = 115; @@ -851,32 +1055,35 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA18D8; + this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion1; } else { sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA1998; + this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion2; } } else if (gSaveContext.sceneSetupIndex == 3) { - this->unk_2E0 = 38; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; if (gSaveContext.unk_3DD0[3] == 0) { + // This code is called when the Giants fail to stop the moon. + // Starts a 1 minute (60 second) timer until the moon falls. func_8010E9F0(3, 60); XREG(80) = 200; XREG(81) = 115; } + this->actor.world.pos.y = 120.0f; sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } else { - this->unk_2E0 = 38; - this->actionFunc = func_80AA16F4; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + this->actionFunc = DmStk_ClockTower_DoNothing; } } else { - this->unk_33A = 1; - this->unk_2E0 = 38; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_READY; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; this->actor.world.pos.y = 120.0f; sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -886,35 +1093,37 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } - this->unk_32C = 2; - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->unk_2E0 = 5; - this->actionFunc = func_80AA1714; + + this->maskType = SK_MASK_TYPE_GLOWING_EYES; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->animationId = SK_ANIMATION_BENT_OVER_HEAD_TWITCH; + this->actionFunc = DmStk_WaitForTelescope; } else { if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } - this->unk_32C = 2; - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->actionFunc = func_80AA1704; + + this->maskType = SK_MASK_TYPE_GLOWING_EYES; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->actionFunc = DmStk_DoNothing; } - this->unk_32D = 9; - this->unk_32E = 0; - this->unk_32F = 0; - this->unk_330 = 0; - this->unk_2E4 = this->unk_2E4; + this->handType = SK_HAND_TYPE_DEFAULT; + this->fadeInState = SK_FADE_IN_STATE_NONE; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; + this->fadeOutTimer = 0; + this->alpha = this->alpha; this->actor.targetArrowOffset = 1100.0f; - this->unk_334 = 99; + this->csAction = 99; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_stk_Skel_013328, NULL, NULL, NULL, 0); - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); } Actor_SetScale(&this->actor, 0.01f); @@ -929,111 +1138,121 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_DoNothing(DmStk* this, GlobalContext* globalCtx) { } -void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { +void DmStk_DoNothing(DmStk* this, GlobalContext* globalCtx) { } -void func_80AA1714(DmStk* this, GlobalContext* globalCtx) { - Vec3f sp1C; +/** + * Waits around until the player zooms the telescope in on Skull Kid, + * then starts the telescope cutscene. + */ +void DmStk_WaitForTelescope(DmStk* this, GlobalContext* globalCtx) { + Vec3f screenPos; if (!(gSaveContext.save.weekEventReg[74] & 0x20)) { - func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + func_80169474(globalCtx, &this->actor.world.pos, &screenPos); if (globalCtx->view.fovy < 25.0f) { - if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { + if ((screenPos.x >= 70.0f) && (screenPos.x < 250.0f) && (screenPos.y >= 30.0f) && (screenPos.y < 210.0f)) { func_800FE484(); - this->actionFunc = func_80AA17F8; + this->actionFunc = DmStk_StartTelescopeCutscene; } } } } -void func_80AA17F8(DmStk* this, GlobalContext* globalCtx) { - s16 sp1E = this->actor.cutscene; - s16 sp1C = ActorCutscene_GetAdditionalCutscene(sp1E); - s16 sp18 = ActorCutscene_GetAdditionalCutscene(sp1C); +/** + * Plays the cutscene in the telescope where the Moon's Tear falls. + */ +void DmStk_StartTelescopeCutscene(DmStk* this, GlobalContext* globalCtx) { + s16 dayOneAndTwoCutscene = this->actor.cutscene; + s16 dayThreeCutscene = ActorCutscene_GetAdditionalCutscene(dayOneAndTwoCutscene); + s16 finalHoursCutscene = ActorCutscene_GetAdditionalCutscene(dayThreeCutscene); s16 cutscene; if (gSaveContext.save.day < 3) { - cutscene = sp1E; + cutscene = dayOneAndTwoCutscene; } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { - cutscene = sp18; + cutscene = finalHoursCutscene; } else { - cutscene = sp1C; + cutscene = dayThreeCutscene; } if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->actor); func_800FE498(); - this->actionFunc = func_80AA1704; + this->actionFunc = DmStk_DoNothing; } else { ActorCutscene_SetIntentToPlay(cutscene); } } -void func_80AA18D8(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(9)) { ActorCutscene_Start(9, &this->actor); - this->actionFunc = func_80AA192C; + this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd; } else { ActorCutscene_SetIntentToPlay(9); } } -void func_80AA192C(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 33; - this->unk_32D = 3; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA2720; + this->animationId = SK_ANIMATION_CALL_DOWN_MOON_LOOP; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_IdleWithOcarina; } } -void func_80AA1998(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xB)) { - ActorCutscene_Start(0xB, &this->actor); - this->actionFunc = func_80AA19EC; +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(11)) { + ActorCutscene_Start(11, &this->actor); + this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd; } else { - ActorCutscene_SetIntentToPlay(0xB); + ActorCutscene_SetIntentToPlay(11); } } -void func_80AA19EC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xA)) { +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(10)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); - ActorCutscene_Start(0xA, &this->actor); + ActorCutscene_Start(10, &this->actor); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.shape.rot.y = this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.x; - this->actionFunc = func_80AA1AC8; + this->actionFunc = DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd; } else { - ActorCutscene_SetIntentToPlay(0xA); + ActorCutscene_SetIntentToPlay(10); } } -void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != 0) && (globalCtx->csCtx.frames > 20)) { - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { +/** + * Makes Skull Kid bob up and down and face the player. + */ +void DmStk_ClockTower_AdjustHeightAndRotation(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 sin; - this->unk_32A += 0x4B0; - sin = Math_SinS(this->unk_32A) * 10.0f; + this->bobPhase += 0x4B0; + sin = Math_SinS(this->bobPhase) * 10.0f; Math_SmoothStepToF(&this->actor.world.pos.y, 160.0f + sin, 0.2f, 1.0f, 0.0001f); this->actor.world.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); @@ -1043,148 +1262,161 @@ void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = this->actor.world.rot.x; } -void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { +/** + * Starts the deflection animation and, depending on how many times Skull Kid has been hit, + * prints a message taunting the player. + */ +void DmStk_ClockTower_DeflectHit(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - func_80AA1AF8(this, globalCtx); - this->unk_339++; - if (this->unk_339 >= 3) { - this->unk_339 = 0; + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); + this->deflectCount++; + if (this->deflectCount >= 3) { + this->deflectCount = 0; if (!(player->stateFlags2 & 0x8000000)) { + // That won't do you any good Message_StartTextbox(globalCtx, 0x2013, &this->actor); } } - this->unk_2E0 = 39; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->animationId = SK_ANIMATION_DEFLECT_ATTACK; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); - this->actionFunc = func_80AA1C64; + this->actionFunc = DmStk_ClockTower_WaitForDeflectionToEnd; } -void func_80AA1C64(DmStk* this, GlobalContext* globalCtx) { - func_80AA1AF8(this, globalCtx); +/** + * Resets Skull Kid back to his idle state once the deflection animation ends. + * If he is hit again before the animation ends, this function will make his deflection restart. + */ +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, GlobalContext* globalCtx) { + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_Idle; } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->actionFunc = func_80AA1B9C; + this->actionFunc = DmStk_ClockTower_DeflectHit; } } -void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { +/** + * Updates a variety of states based on Skull Kid's current cutscene, including his current + * animation, his hand/mask type, his fade in/fade out state, and his current cutscene action. + */ +void DmStk_UpdateCutscenes(DmStk* this, GlobalContext* globalCtx) { s32 pad; - s32 temp_v0; + s32 actorActionIndex; if (Cutscene_CheckActorAction(globalCtx, 107)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 107); + actorActionIndex = Cutscene_GetActorActionIndex(globalCtx, 107); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { - if (this->unk_334 != globalCtx->csCtx.actorActions[temp_v0]->action) { - this->unk_334 = globalCtx->csCtx.actorActions[temp_v0]->action; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actorActionIndex]->startFrame) { + if (this->csAction != globalCtx->csCtx.actorActions[actorActionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actorActionIndex]->action; if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { - this->unk_32D = 6; + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; } else { - this->unk_32D = 9; + this->handType = SK_HAND_TYPE_DEFAULT; } - switch (globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (globalCtx->csCtx.actorActions[actorActionIndex]->action) { case 0: case 1: - this->unk_2E0 = 3; + this->animationId = SK_ANIMATION_IDLE; break; case 2: - this->unk_2E0 = 1; + this->animationId = SK_ANIMATION_WALK; break; case 3: - this->unk_2E0 = 20; + this->animationId = SK_ANIMATION_UNUSED_KICK_OVER_LINK; break; case 4: - this->unk_2E0 = 18; + this->animationId = SK_ANIMATION_KICK_OVER_LINK; break; case 6: - this->unk_2E0 = 16; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PICK_UP_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 7: - this->unk_2E0 = 14; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 8: - this->unk_2E0 = 0; + this->animationId = SK_ANIMATION_SHAKE_HEAD; break; case 9: - this->unk_2E0 = 3; - this->unk_32E = 1; + this->animationId = SK_ANIMATION_IDLE; + this->fadeInState = SK_FADE_IN_STATE_START; break; case 12: - this->unk_2E0 = 12; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_HIDE_OCARINA_START; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 13: - this->unk_2E0 = 27; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_JUMP_WHILE_HIDING_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 14: - this->unk_2E0 = 22; + this->animationId = SK_ANIMATION_HORSE_RIDE_START; break; case 15: - this->unk_2E0 = 23; + this->animationId = SK_ANIMATION_HORSE_RIDE_LOOP; break; case 16: - this->unk_2E0 = 28; + this->animationId = SK_ANIMATION_HORSE_RIDE_AND_ROTATE; break; case 17: - this->unk_2E0 = 7; + this->animationId = SK_ANIMATION_RECLINING_FLOAT; break; case 18: - this->unk_2E0 = 8; + this->animationId = SK_ANIMATION_CURSE_START; break; case 19: - this->unk_2E0 = 10; + this->animationId = SK_ANIMATION_LAUGH_START; break; case 20: - this->unk_2E0 = 24; + this->animationId = SK_ANIMATION_RAISE_MASK_START; break; case 21: - this->unk_2E0 = 26; + this->animationId = SK_ANIMATION_LOWER_MASK; break; case 22: - this->unk_2E0 = 29; + this->animationId = SK_ANIMATION_PLAY_OCARINA_WHILE_FLOATING; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 23: - this->unk_2E0 = 30; - this->unk_32D = 4; + this->animationId = SK_ANIMATION_FLOATING_TURN_AROUND; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 24: - this->unk_2E0 = 32; + this->animationId = SK_ANIMATION_CALL_DOWN_MOON_START; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1193,148 +1425,148 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; case 26: - this->unk_2E0 = 34; + this->animationId = SK_ANIMATION_SMACK_FAIRY_START; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 27: - this->unk_2E0 = 36; + this->animationId = SK_ANIMATION_HIT_BY_BUBBLE; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 28: - this->unk_2E0 = 37; - this->unk_32D = 4; + this->animationId = SK_ANIMATION_DROP_OCARINA; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 30: - this->unk_2E0 = 38; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; break; case 31: - this->unk_2E0 = 39; + this->animationId = SK_ANIMATION_DEFLECT_ATTACK; break; case 32: - this->unk_2E0 = 42; + this->animationId = SK_ANIMATION_SURPRISE_START; break; case 33: - this->unk_2E0 = 44; + this->animationId = SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START; break; case 34: - this->unk_2E0 = 46; + this->animationId = SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START; break; case 35: - this->unk_2E0 = 48; + this->animationId = SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START; break; case 36: - this->unk_2E0 = 50; + this->animationId = SK_ANIMATION_HUDDLE_WITH_FAIRIES; break; case 37: - this->unk_2E0 = 51; + this->animationId = SK_ANIMATION_SEARCH_MASK_SALESMAN; break; case 38: - this->unk_2E0 = 52; + this->animationId = SK_ANIMATION_HOLD_UP_MASK_START; break; case 39: - this->unk_2E0 = 54; + this->animationId = SK_ANIMATION_SHIVER; break; case 40: - this->unk_2E0 = 55; + this->animationId = SK_ANIMATION_DRAW; break; case 41: - this->unk_2E0 = 40; + this->animationId = SK_ANIMATION_TELESCOPE_LOOK_UP_START; break; case 42: - this->unk_2E0 = 5; + this->animationId = SK_ANIMATION_BENT_OVER_HEAD_TWITCH; break; case 43: - this->unk_2E0 = 56; + this->animationId = SK_ANIMATION_BENT_OVER_LOOK_UP; break; case 44: - this->unk_2E0 = 57; + this->animationId = SK_ANIMATION_SPANK; break; case 45: - this->unk_2E0 = 58; - this->unk_32F = 1; + this->animationId = SK_ANIMATION_HIP_SHAKE_AND_JUMP; + this->fadeOutState = SK_FADE_OUT_STATE_FADING_OUT; break; case 46: - this->unk_32D = 6; - this->unk_2E0 = 59; + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; + this->animationId = SK_ANIMATION_PLAY_FLUTE; break; case 47: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 48: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 49: - this->unk_2E0 = 65; + this->animationId = SK_ANIMATION_LOOK_UP_AT_GIANTS; break; case 50: - this->unk_2E0 = 66; + this->animationId = SK_ANIMATION_ASHAMED_START; break; case 51: - this->unk_2E0 = 68; + this->animationId = SK_ANIMATION_LOOK_LEFT_START; break; case 52: - this->unk_2E0 = 70; + this->animationId = SK_ANIMATION_SNIFF; break; case 53: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 54: - this->unk_2E0 = 61; + this->animationId = SK_ANIMATION_LIE_FLAT; break; case 55: - this->unk_2E0 = 62; + this->animationId = SK_ANIMATION_DANGLE_FROM_MASK_START; break; case 56: - this->unk_2E0 = 64; + this->animationId = SK_ANIMATION_DROPPED_FROM_MASK; break; case 57: - this->unk_2E0 = 65; + this->animationId = SK_ANIMATION_LOOK_UP_AT_GIANTS; break; case 58: - this->unk_2E0 = 66; + this->animationId = SK_ANIMATION_ASHAMED_START; break; case 59: - this->unk_2E0 = 68; + this->animationId = SK_ANIMATION_LOOK_LEFT_START; break; case 60: - this->unk_2E0 = 70; + this->animationId = SK_ANIMATION_SNIFF; break; case 5: @@ -1342,129 +1574,131 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; default: - this->unk_2E0 = 0; + this->animationId = SK_ANIMATION_SHAKE_HEAD; break; } - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actorActionIndex); } else { - this->unk_334 = 99; + this->csAction = 99; } - if (this->unk_32E == 1) { - Math_SmoothStepToF(&this->unk_300, 0.7f, 0.1f, 0.007f, 0.005f); - if (this->unk_300 < 0.71f) { - this->unk_300 = 0.7f; - this->unk_2F8 = 800; - this->unk_32E++; - } - this->unk_2E8 = globalCtx->lightCtx.unk7 * this->unk_300; - this->unk_2EC = globalCtx->lightCtx.unk8 * this->unk_300; - this->unk_2F0 = globalCtx->lightCtx.unk9 * this->unk_300; - - } else if (this->unk_32E == 2) { - if (this->unk_2F8 < 996) { - this->unk_2F8 += 10; + if (this->fadeInState == SK_FADE_IN_STATE_START) { + Math_SmoothStepToF(&this->fogScale, 0.7f, 0.1f, 0.007f, 0.005f); + if (this->fogScale < 0.71f) { + this->fogScale = 0.7f; + this->fogN = 800; + this->fadeInState++; } - if (this->unk_2F8 > 996) { - this->unk_32E++; - this->unk_2F8 = 996; - } - } else if (this->unk_32E == 3) { - if (this->unk_2E4 < 128) { - this->unk_2E4 += 3; + this->fogR = globalCtx->lightCtx.unk7 * this->fogScale; + this->fogG = globalCtx->lightCtx.unk8 * this->fogScale; + this->fogB = globalCtx->lightCtx.unk9 * this->fogScale; + } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_FOG) { + if (this->fogN < 996) { + this->fogN += 10; } - if (this->unk_2E4 < 255) { - this->unk_2E4 += 20; + if (this->fogN > 996) { + this->fadeInState++; + this->fogN = 996; + } + } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_ALPHA) { + if (this->alpha < 128) { + this->alpha += 3; + } + + if (this->alpha < 255) { + this->alpha += 20; } else { - this->unk_2E4 = 255; - this->unk_32E = 0; + this->alpha = 255; + this->fadeInState = SK_FADE_IN_STATE_NONE; } } - if (this->unk_32F == 1) { - if (this->unk_330 > 40) { - this->unk_32C = 3; + if (this->fadeOutState == SK_FADE_OUT_STATE_FADING_OUT) { + if (this->fadeOutTimer > 40) { + this->maskType = SK_MASK_TYPE_FADING_OUT; } - this->unk_330++; - if (this->unk_330 >= 44) { - this->unk_2E4 -= 35; - if (this->unk_2E4 < 0) { - this->unk_2E4 = 0; - this->unk_32F = 0; + this->fadeOutTimer++; + if (this->fadeOutTimer >= 44) { + this->alpha -= 35; + if (this->alpha < 0) { + this->alpha = 0; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; gSaveContext.save.weekEventReg[12] |= 4; if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } else { - this->unk_33B = 0; + this->shouldDraw = false; } } } } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->unk_2E0) { - case 2: - case 8: - case 10: - case 12: - case 14: - case 16: - case 18: - case 20: - case 22: - case 24: - case 30: - case 32: - case 34: - case 40: - case 42: - case 44: - case 46: - case 48: - case 52: - case 62: - case 66: - case 68: - case 70: - this->unk_2E0++; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + switch (this->animationId) { + case SK_ANIMATION_LOOK_AROUND: + case SK_ANIMATION_CURSE_START: + case SK_ANIMATION_LAUGH_START: + case SK_ANIMATION_HIDE_OCARINA_START: + case SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING: + case SK_ANIMATION_PICK_UP_OCARINA: + case SK_ANIMATION_KICK_OVER_LINK: + case SK_ANIMATION_UNUSED_KICK_OVER_LINK: + case SK_ANIMATION_HORSE_RIDE_START: + case SK_ANIMATION_RAISE_MASK_START: + case SK_ANIMATION_FLOATING_TURN_AROUND: + case SK_ANIMATION_CALL_DOWN_MOON_START: + case SK_ANIMATION_SMACK_FAIRY_START: + case SK_ANIMATION_TELESCOPE_LOOK_UP_START: + case SK_ANIMATION_SURPRISE_START: + case SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START: + case SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START: + case SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START: + case SK_ANIMATION_HOLD_UP_MASK_START: + case SK_ANIMATION_DANGLE_FROM_MASK_START: + case SK_ANIMATION_ASHAMED_START: + case SK_ANIMATION_LOOK_LEFT_START: + case SK_ANIMATION_SNIFF: + this->animationId++; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); break; - case 26: - this->unk_2E0 = 3; - this->unk_32C = 1; - this->unk_32D = 9; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + case SK_ANIMATION_LOWER_MASK: + this->animationId = SK_ANIMATION_IDLE; + this->maskType = SK_MASK_TYPE_NORMAL; + this->handType = SK_HAND_TYPE_DEFAULT; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); break; } } - if (((this->unk_2E0 == 24) && (this->skelAnime.curFrame >= 16.0f)) || (this->unk_2E0 == 25) || - (this->unk_2E0 == 26)) { - this->unk_32C = 9; - this->unk_32D = 2; - } else if (((this->unk_2E0 >= 50) && (this->unk_2E0 < 56)) || ((this->unk_2E0 > 58) && (this->unk_2E0 <= 60)) || + if (((this->animationId == SK_ANIMATION_RAISE_MASK_START) && (this->skelAnime.curFrame >= 16.0f)) || + (this->animationId == SK_ANIMATION_RAISE_MASK_LOOP) || (this->animationId == SK_ANIMATION_LOWER_MASK)) { + this->maskType = SK_MASK_TYPE_RAISED; + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; + } else if (((this->animationId >= SK_ANIMATION_HUDDLE_WITH_FAIRIES) && (this->animationId <= SK_ANIMATION_DRAW)) || + ((this->animationId >= SK_ANIMATION_PLAY_FLUTE) && (this->animationId <= SK_ANIMATION_CARTWHEEL)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { - this->unk_32C = 0; - if ((this->unk_2E0 == 52) || (this->unk_2E0 == 53)) { - this->unk_32D = 5; + this->maskType = SK_MASK_TYPE_NO_MASK; + if ((this->animationId == SK_ANIMATION_HOLD_UP_MASK_START) || + (this->animationId == SK_ANIMATION_HOLD_UP_MASK_LOOP)) { + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE; } } - if (this->unk_2E0 == 64) { - this->unk_32C = 0; + if (this->animationId == SK_ANIMATION_DROPPED_FROM_MASK) { + this->maskType = SK_MASK_TYPE_NO_MASK; } } -void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_UpdateCollision(DmStk* this, GlobalContext* globalCtx) { s32 pad; Collider_UpdateCylinder(&this->actor, &this->collider); @@ -1472,40 +1706,54 @@ void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } -void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles Skull Kid when he is at the top of the Clock Tower with the Ocarina of Time. + * If he is hit in this state, he will drop the Ocarina. + * + * If the player waits a while while Skull Kid is in this state, they will see a message + * from Tatl telling them to hurry up and do something. + */ +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); this->actor.flags |= ACTOR_FLAG_1; - this->unk_328++; - if (this->unk_328 > 800) { - this->unk_328 = 0; + this->tatlMessageTimer++; + if (this->tatlMessageTimer > 800) { + this->tatlMessageTimer = 0; if (!(player->stateFlags2 & 0x8000000)) { + // Why are you just standing around? Message_StartTextbox(globalCtx, 0x2014, &this->actor); } } + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->unk_335 = 1; - this->actionFunc = func_80AA1A50; + this->hasBeenHit = true; + this->actionFunc = DmStk_ClockTower_StartDropOcarinaCutscene; } } } -void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles Skull Kid when he is at the top of the Clock Tower after the Ocarina of Time + * has been returned to the player. + * If he is hit in this state, he will just deflect the attack. + */ +void DmStk_ClockTower_Idle(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); this->actor.flags |= ACTOR_FLAG_1; - if (this->unk_2E0 == 33) { + if (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) { this->actor.targetArrowOffset = 3100.0f; } else { this->actor.targetArrowOffset = 200.0f; } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->unk_335 = 1; - this->actionFunc = func_80AA1B9C; + this->hasBeenHit = true; + this->actionFunc = DmStk_ClockTower_DeflectHit; } } } @@ -1513,57 +1761,60 @@ void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - if (this->actor.params != 1) { - if (this->unk_2E0 == 33) { + if (DM_STK_GET_TYPE(&this->actor) != DM_STK_TYPE_MAJORAS_MASK) { + if (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) { Actor_SetFocus(&this->actor, 40.0f); } else { Actor_SetFocus(&this->actor, 6.0f); } - func_80A9FDB0(this, globalCtx); + DmStk_LoadObjectForAnimation(this, globalCtx); - if (this->unk_2E0 != 61) { + if (this->animationId != SK_ANIMATION_LIE_FLAT) { SkelAnime_Update(&this->skelAnime); } - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; this->actionFunc(this, globalCtx); if (globalCtx->sceneNum == SCENE_OKUJOU) { - func_80AA26CC(this, globalCtx); + DmStk_UpdateCollision(this, globalCtx); } - func_80AA1D1C(this, globalCtx); - func_80AA0E90(this, globalCtx); + DmStk_UpdateCutscenes(this, globalCtx); + DmStk_PlaySfxForCutscenes(this, globalCtx); - switch (this->unk_33A) { - case 1: + // This handles the cutscene where the player takes out the Deku Pipes for the first time. + switch (this->dekuPipesCutsceneState) { + case SK_DEKU_PIPES_CS_STATE_READY: if (func_800B8718(&this->actor, &globalCtx->state)) { - this->unk_33A = 2; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA; } else { func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, fabsf(this->actor.playerHeightRel)); } break; - case 2: - if (ActorCutscene_GetCanPlayNext(0x10)) { - this->unk_33A = 3; - ActorCutscene_Start(0x10, &this->actor); - this->actionFunc = func_80AA27EC; + case SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA: + if (ActorCutscene_GetCanPlayNext(16)) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_START; + ActorCutscene_Start(16, &this->actor); + this->actionFunc = DmStk_ClockTower_Idle; } else { - ActorCutscene_SetIntentToPlay(0x10); + ActorCutscene_SetIntentToPlay(16); } break; - case 3: + case SK_DEKU_PIPES_CS_STATE_START: if (globalCtx->csCtx.state == 0) { - this->unk_33A = 4; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_END; } break; } + // This code is responsible for making in-game time pass while using the telescope in the Astral Observatory. + // Skull Kid is always loaded in the scene, even if he isn't visible, hence why time always passes. if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && @@ -1585,27 +1836,28 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { s32 DmStk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { DmStk* this = THIS; - if (limbIndex == 15) { - if ((this->unk_32D == 0) || (this->unk_32D == 1) || (this->unk_32D == 3)) { + if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { + if ((this->handType == SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE) || + (this->handType == SK_HAND_TYPE_HOLDING_LINK_MASK) || (this->handType == SK_HAND_TYPE_HOLDING_OCARINA)) { *dList = NULL; } - } else if (limbIndex == 12) { - switch (this->unk_32D) { - case 1: - case 2: - case 3: - case 4: - case 6: + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK: + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK: + case SK_HAND_TYPE_HOLDING_OCARINA: + case SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA: + case SK_HAND_TYPE_HOLDING_FLUTE: *dList = NULL; break; - case 9: - if (this->unk_2E4 == 255) { + case SK_HAND_TYPE_DEFAULT: + if (this->alpha == 255) { *dList = NULL; } break; } - } else if (limbIndex == 17) { + } else if (limbIndex == SKULL_KID_LIMB_HEAD) { *dList = NULL; } @@ -1617,58 +1869,60 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V s32 pad2; DmStk* this = THIS; - if (limbIndex == 17) { - Matrix_MultZero(&this->unk_304); + if (limbIndex == SKULL_KID_LIMB_HEAD) { + Matrix_MultZero(&this->headPos); OPEN_DISPS(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if ((this->unk_2E0 == 69) || (this->unk_2E0 == 11) || (this->unk_2E0 == 71)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00AEC0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00AE30); + if ((this->animationId == SK_ANIMATION_LOOK_LEFT_LOOP) || (this->animationId == SK_ANIMATION_LAUGH_LOOP) || + (this->animationId == SK_ANIMATION_LAUGH_AFTER_SNIFF)) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLaughingHeadDL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLaughingEyesDL); } else { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00A5C0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00A530); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidNormalHeadDL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidNormalEyesDL); } - switch (this->unk_32C) { - case 0: + switch (this->maskType) { + case SK_MASK_TYPE_NO_MASK: break; - case 1: + case SK_MASK_TYPE_NORMAL: if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.frames < 1400)) { - if (this->unk_2F8 == this->unk_2FC) { - this->unk_2FC = this->unk_2F8; + if (this->fogN == this->fogF) { + this->fogF = this->fogN; } - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_2E8, this->unk_2EC, this->unk_2F0, - this->unk_2F4, this->unk_2F8, this->unk_2FC); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->fogR, this->fogG, this->fogB, this->fogA, + this->fogN, this->fogF); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); } else { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); } break; - case 2: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_005870); + case SK_MASK_TYPE_GLOWING_EYES: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMaskEyesDL); if (Cutscene_CheckActorAction(globalCtx, 513) && (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && - (this->unk_337 >= 0)) { + (this->objectStk2ObjectIndex >= 0)) { Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); + gSegments[6] = + PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStk2ObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectStk2ObjectIndex].segment); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_stk2_Matanimheader_008658)); - Gfx_DrawDListOpa(globalCtx, object_stk2_DL_007840); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gSkullKidMajorasMaskCurseOverlayTexAnim)); + Gfx_DrawDListOpa(globalCtx, gSkullKidMajorasMaskCurseOverlayDL); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); Matrix_Pop(); } @@ -1677,85 +1931,85 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 15) { + } else if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->unk_32D != 5) { + if (this->handType != SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } - switch (this->unk_32D) { - case 0: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009AC0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0046B0); + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidUntexturedRightHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLinkMask2DL); break; - case 1: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009710); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0053C0); + case SK_HAND_TYPE_HOLDING_LINK_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMaskHoldingRightHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLinkMask3DL); break; - case 3: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009DA0); + case SK_HAND_TYPE_HOLDING_OCARINA: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaHoldingRightHand); if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; - case 5: + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE: Matrix_Translate(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); Matrix_RotateYS(0x6142, MTXMODE_APPLY); Matrix_RotateXS(-0x1988, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); break; } CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 12) { + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - switch (this->unk_32D) { - case 0: + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE: break; - case 1: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0084C0); + case SK_HAND_TYPE_HOLDING_LINK_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidUntexturedLeftHand); break; - case 2: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0079F0); + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask2DL); break; - case 3: + case SK_HAND_TYPE_HOLDING_OCARINA: if ((globalCtx->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); break; - case 4: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); + case SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); break; - case 6: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_008A80); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_016620); + case SK_HAND_TYPE_HOLDING_FLUTE: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidFluteHoldingLeftHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidFluteDL); break; - case 9: - if (this->unk_2E4 == 255) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0087B0); + case SK_HAND_TYPE_DEFAULT: + if (this->alpha == 255) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOpenLeftHand); } break; } @@ -1773,25 +2027,25 @@ void DmStk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - if (this->unk_33B != 0) { - if (this->actor.params == 1) { - Gfx_DrawDListOpa(globalCtx, object_stk_DL_006BB0); + if (this->shouldDraw) { + if (DM_STK_GET_TYPE(&this->actor) == DM_STK_TYPE_MAJORAS_MASK) { + Gfx_DrawDListOpa(globalCtx, gSkullKidMajorasMask1DL); return; } - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; func_8012C28C(globalCtx->state.gfxCtx); - if (this->unk_2E4 < 255) { + if (this->alpha < 255) { func_8012C2DC(globalCtx->state.gfxCtx); Scene_SetRenderModeXlu(globalCtx, 1, 2); gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2E4); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h index 2b8c54383..4e69c1dfc 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h @@ -2,44 +2,53 @@ #define Z_DM_STK_H #include "global.h" +#include "objects/object_stk/object_stk.h" struct DmStk; typedef void (*DmStkActionFunc)(struct DmStk*, GlobalContext*); +#define DM_STK_GET_TYPE(thisx) ((thisx)->params) + +typedef enum { + /* 0 */ DM_STK_TYPE_SKULL_KID, + /* 1 */ DM_STK_TYPE_MAJORAS_MASK, +} DmStkType; + typedef struct DmStk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ UNK_TYPE1 unk_188[0x108]; - /* 0x0290 */ DmStkActionFunc actionFunc; - /* 0x0294 */ ColliderCylinder collider; - /* 0x02E0 */ s16 unk_2E0; - /* 0x02E4 */ s32 unk_2E4; - /* 0x02E8 */ u32 unk_2E8; - /* 0x02EC */ u32 unk_2EC; - /* 0x02F0 */ u32 unk_2F0; - /* 0x02F4 */ s32 unk_2F4; - /* 0x02F8 */ s32 unk_2F8; - /* 0x02FC */ s32 unk_2FC; - /* 0x0300 */ f32 unk_300; - /* 0x0304 */ Vec3f unk_304; - /* 0x0310 */ Vec3f unk_310; - /* 0x031C */ UNK_TYPE1 unk31C[0xC]; - /* 0x0328 */ u16 unk_328; - /* 0x032A */ u16 unk_32A; - /* 0x032C */ u8 unk_32C; - /* 0x032D */ u8 unk_32D; - /* 0x032E */ u8 unk_32E; - /* 0x032F */ u8 unk_32F; - /* 0x0330 */ s32 unk_330; - /* 0x0334 */ u8 unk_334; - /* 0x0335 */ u8 unk_335; - /* 0x0336 */ s8 unk_336; - /* 0x0337 */ s8 unk_337; - /* 0x0338 */ s8 unk_338; - /* 0x0339 */ u8 unk_339; - /* 0x033A */ u8 unk_33A; - /* 0x033B */ u8 unk_33B; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[SKULL_KID_LIMB_MAX]; // Not used, since it's allocated dynamically instead. + /* 0x20C */ Vec3s morphTable[SKULL_KID_LIMB_MAX]; // Not used, since it's allocated dynamically instead. + /* 0x290 */ DmStkActionFunc actionFunc; + /* 0x294 */ ColliderCylinder collider; + /* 0x2E0 */ s16 animationId; + /* 0x2E4 */ s32 alpha; + /* 0x2E8 */ u32 fogR; + /* 0x2EC */ u32 fogG; + /* 0x2F0 */ u32 fogB; + /* 0x2F4 */ s32 fogA; + /* 0x2F8 */ s32 fogN; + /* 0x2FC */ s32 fogF; + /* 0x300 */ f32 fogScale; + /* 0x304 */ Vec3f headPos; // set but never used + /* 0x310 */ Vec3f oathToOrderCutsceneVoicePos; + /* 0x31C */ UNK_TYPE1 unk31C[0xC]; + /* 0x328 */ u16 tatlMessageTimer; + /* 0x32A */ u16 bobPhase; + /* 0x32C */ u8 maskType; + /* 0x32D */ u8 handType; + /* 0x32E */ u8 fadeInState; + /* 0x32F */ u8 fadeOutState; + /* 0x330 */ s32 fadeOutTimer; + /* 0x334 */ u8 csAction; + /* 0x335 */ u8 hasBeenHit; // set but never used + /* 0x336 */ s8 objectStkObjectIndex; + /* 0x337 */ s8 objectStk2ObjectIndex; + /* 0x338 */ s8 objectStk3ObjectIndex; + /* 0x339 */ u8 deflectCount; + /* 0x33A */ u8 dekuPipesCutsceneState; + /* 0x33B */ u8 shouldDraw; } DmStk; // size = 0x33C extern const ActorInit Dm_Stk_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a0eae0028..637e1c229 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11463,44 +11463,44 @@ 0x80A9FA58:("func_80A9FA58",), 0x80A9FB54:("DmOpstage_Update",), 0x80A9FBB8:("DmOpstage_Draw",), - 0x80A9FDB0:("func_80A9FDB0",), - 0x80A9FE3C:("func_80A9FE3C",), - 0x80A9FED8:("func_80A9FED8",), - 0x80AA00CC:("func_80AA00CC",), - 0x80AA0100:("func_80AA0100",), - 0x80AA0158:("func_80AA0158",), - 0x80AA01C0:("func_80AA01C0",), - 0x80AA0264:("func_80AA0264",), - 0x80AA0420:("func_80AA0420",), - 0x80AA05F0:("func_80AA05F0",), - 0x80AA0634:("func_80AA0634",), - 0x80AA066C:("func_80AA066C",), - 0x80AA071C:("func_80AA071C",), - 0x80AA076C:("func_80AA076C",), - 0x80AA09DC:("func_80AA09DC",), - 0x80AA0B08:("func_80AA0B08",), - 0x80AA0DA8:("func_80AA0DA8",), - 0x80AA0E1C:("func_80AA0E1C",), - 0x80AA0E90:("func_80AA0E90",), + 0x80A9FDB0:("DmStk_LoadObjectForAnimation",), + 0x80A9FE3C:("DmStk_ChangeAnimation",), + 0x80A9FED8:("DmStk_PlaySfxForIntroCutsceneFirstPart",), + 0x80AA00CC:("DmStk_PlaySfxForTitleCutscene",), + 0x80AA0100:("DmStk_PlaySfxForIntroCutsceneSecondPart",), + 0x80AA0158:("DmStk_PlaySfxForObtainingMajorasMaskCutscene",), + 0x80AA01C0:("DmStk_PlaySfxForCurseCutsceneFirstPart",), + 0x80AA0264:("DmStk_PlaySfxForCurseCutsceneSecondPart",), + 0x80AA0420:("DmStk_PlaySfxForClockTowerIntroCutsceneVersion1",), + 0x80AA05F0:("DmStk_PlaySfxForDroppingOcarinaCutscene",), + 0x80AA0634:("DmStk_PlaySfxForShiveringInRainCutscene",), + 0x80AA066C:("DmStk_PlaySfxForPlayingWithFairiesCutscene",), + 0x80AA071C:("DmStk_PlaySfxForEndingCutsceneFirstPart",), + 0x80AA076C:("DmStk_PlaySfxForEndingCutsceneSecondPart",), + 0x80AA09DC:("DmStk_PlaySfxForClockTowerIntroCutsceneVersion2",), + 0x80AA0B08:("DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder",), + 0x80AA0DA8:("DmStk_PlaySfxForMoonWarpCutsceneVersion1",), + 0x80AA0E1C:("DmStk_PlaySfxForMoonWarpCutsceneVersion2",), + 0x80AA0E90:("DmStk_PlaySfxForCutscenes",), 0x80AA1234:("DmStk_Init",), 0x80AA16E4:("DmStk_Destroy",), - 0x80AA16F4:("func_80AA16F4",), - 0x80AA1704:("func_80AA1704",), - 0x80AA1714:("func_80AA1714",), - 0x80AA17F8:("func_80AA17F8",), - 0x80AA18D8:("func_80AA18D8",), - 0x80AA192C:("func_80AA192C",), - 0x80AA1998:("func_80AA1998",), - 0x80AA19EC:("func_80AA19EC",), - 0x80AA1A50:("func_80AA1A50",), - 0x80AA1AC8:("func_80AA1AC8",), - 0x80AA1AF8:("func_80AA1AF8",), - 0x80AA1B9C:("func_80AA1B9C",), - 0x80AA1C64:("func_80AA1C64",), - 0x80AA1D1C:("func_80AA1D1C",), - 0x80AA26CC:("func_80AA26CC",), - 0x80AA2720:("func_80AA2720",), - 0x80AA27EC:("func_80AA27EC",), + 0x80AA16F4:("DmStk_ClockTower_DoNothing",), + 0x80AA1704:("DmStk_DoNothing",), + 0x80AA1714:("DmStk_WaitForTelescope",), + 0x80AA17F8:("DmStk_StartTelescopeCutscene",), + 0x80AA18D8:("DmStk_ClockTower_StartIntroCutsceneVersion1",), + 0x80AA192C:("DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd",), + 0x80AA1998:("DmStk_ClockTower_StartIntroCutsceneVersion2",), + 0x80AA19EC:("DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd",), + 0x80AA1A50:("DmStk_ClockTower_StartDropOcarinaCutscene",), + 0x80AA1AC8:("DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd",), + 0x80AA1AF8:("DmStk_ClockTower_AdjustHeightAndRotation",), + 0x80AA1B9C:("DmStk_ClockTower_DeflectHit",), + 0x80AA1C64:("DmStk_ClockTower_WaitForDeflectionToEnd",), + 0x80AA1D1C:("DmStk_UpdateCutscenes",), + 0x80AA26CC:("DmStk_UpdateCollision",), + 0x80AA2720:("DmStk_ClockTower_IdleWithOcarina",), + 0x80AA27EC:("DmStk_ClockTower_Idle",), 0x80AA2884:("DmStk_Update",), 0x80AA2B14:("DmStk_OverrideLimbDraw",), 0x80AA2BC0:("DmStk_PostLimbDraw2",), From 271b7c78276f7488f4c75328d79364f3a1cd423d Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 18 Jun 2022 18:56:10 -0700 Subject: [PATCH 22/53] Gfxprint OK (#826) * Match last two functions as well as some cleanup * One more small cleanup * Reviews * format * Move internal GFXP_FLAG defines to c file * Format --- include/PR/gbi.h | 12 +-- include/functions.h | 17 +-- include/gfxprint.h | 49 +++++++++ include/variables.h | 4 +- include/z64.h | 22 +--- src/boot_O2/gfxprint.c | 188 +++++++++++++++++++++------------ src/boot_O2_g3/fault_drawer.c | 1 + src/code/sys_matrix.c | 2 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 4 +- tools/sizes/boot_functions.csv | 2 +- 11 files changed, 183 insertions(+), 120 deletions(-) create mode 100644 include/gfxprint.h diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 34ec8af31..fa27a5f11 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -3878,7 +3878,7 @@ _DW({ \ #define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, \ pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ cmt, maskt, shiftt, cms, masks, shifts); \ @@ -3893,7 +3893,7 @@ _DW({ \ gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ -} +}) /* Load fix rww 27jun95 */ /* The S at the end means odd lines are already word Swapped */ @@ -4246,7 +4246,7 @@ _DW({ \ #define gDPLoadMultiTile_4b(pkt, timg, tmem, rtile, fmt, width, height, \ uls, ult, lrs, lrt, pal, \ cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width)>>1), timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ @@ -4268,7 +4268,7 @@ _DW({ \ (ult)<words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \ - _g->words.w1 = (rgba); \ - } - -void GfxPrint_InitDlist(GfxPrint* this) { +void GfxPrint_Setup(GfxPrint* this) { s32 width = 16; s32 height = 256; s32 i; - gDPPipeSync(this->dlist++); - gDPSetOtherMode(this->dlist++, + gDPPipeSync(this->dList++); + gDPSetOtherMode(this->dList++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_IA16 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_DECALRGBA, G_CC_DECALRGBA); - gDPLoadTextureBlock_4b(this->dlist++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA); + gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dlist++, 64, 256, sGfxPrintFontTLUT); + gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPSetTileSize(this->dlist++, i * 2, 0, 0, 60, 1020); + gDPSetTileSize(this->dList++, i * 2, 0, 0, 60, 1020); } - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); - gDPLoadMultiTile_4b(this->dlist++, sGfxPrintUnkData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, + gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dlist++, 16, 320, sGfxPrintUnkTLUT); + gDPLoadTLUT(this->dList++, 16, 320, sGfxPrintRainbowTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, + gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD); - gDPSetTileSize(this->dlist++, i * 2 + 1, 0, 0, 4, 28); + gDPSetTileSize(this->dList++, i * 2 + 1, 0, 0, 4, 28); } } @@ -53,8 +53,8 @@ void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a) { this->color.g = g; this->color.b = b; this->color.a = a; - gDPPipeSync(this->dlist++); - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPPipeSync(this->dList++); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); } void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y) { @@ -71,108 +71,156 @@ void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) { this->baseY = y << 2; } -/* regalloc in the final gSPTextureRectangle */ -#ifdef NON_MATCHING void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) { u32 tile = (c & 0xFF) * 2; + u16 s = c & 4; + u16 t = c >> 3; - if (this->flag & GFXPRINT_UPDATE_MODE) { - this->flag &= ~GFXPRINT_UPDATE_MODE; + if (this->flags & GFXP_FLAG_UPDATE) { + this->flags &= ~GFXP_FLAG_UPDATE; - gDPPipeSync(this->dlist++); - if (this->flag & GFXPRINT_USE_RGBA16) { - gDPSetTextureLUT(this->dlist++, G_TT_RGBA16); - gDPSetCycleType(this->dlist++, G_CYC_2CYCLE); - gDPSetRenderMode(this->dlist++, G_RM_OPA_CI, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_INTERFERENCE, G_CC_PASS2); + gDPPipeSync(this->dList++); + if (this->flags & GFXP_FLAG_RAINBOW) { + gDPSetTextureLUT(this->dList++, G_TT_RGBA16); + gDPSetCycleType(this->dList++, G_CYC_2CYCLE); + gDPSetRenderMode(this->dList++, G_RM_OPA_CI, G_RM_XLU_SURF2); + gDPSetCombineMode(this->dList++, G_CC_INTERFERENCE, G_CC_PASS2); } else { - gDPSetTextureLUT(this->dlist++, G_TT_IA16); - gDPSetCycleType(this->dlist++, G_CYC_1CYCLE); - gDPSetRenderMode(this->dlist++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); + gDPSetTextureLUT(this->dList++, G_TT_IA16); + gDPSetCycleType(this->dList++, G_CYC_1CYCLE); + gDPSetRenderMode(this->dList++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(this->dList++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); } } - if (this->flag & GFXPRINT_FLAG4) { - gDPSetPrimColorMod(this->dlist++, 0, 0, 0); + if (this->flags & GFXP_FLAG_SHADOW) { + gDPSetColor(this->dList++, G_SETPRIMCOLOR, 0); - gSPTextureRectangle(this->dlist++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, - (c & 3) << 1, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1024, 1024); + gSPTextureRectangle(this->dList++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, + tile, s << 6, t << 8, 1 << 10, 1 << 10); - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); } - gSPTextureRectangle(this->dlist++, this->posX, this->posY, this->posX + 32, this->posY + 32, (u16)(tile & 7), - (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1024, 1024); + gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, tile, s << 6, t << 8, + 1 << 10, 1 << 10); this->posX += 32; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/gfxprint/GfxPrint_PrintCharImpl.s") -#endif -#pragma GLOBAL_ASM("asm/non_matchings/boot/gfxprint/GfxPrint_PrintChar.s") +void GfxPrint_PrintChar(GfxPrint* this, u8 c) { + if (c == ' ') { + this->posX += 32; + } else if (c > ' ' && c < 0x7F) { + GfxPrint_PrintCharImpl(this, c); + } else if (c >= 0xA0 && c < 0xE0) { + if (this->flags & GFXP_FLAG_HIRAGANA) { + if (c < 0xC0) { + c -= 0x20; + } else { + c += 0x20; + } + } + GfxPrint_PrintCharImpl(this, c); + } else { + switch (c) { + case '\0': + break; + case '\n': + this->posY += 32; + case '\r': + this->posX = this->baseX; + break; + case '\t': + do { + GfxPrint_PrintCharImpl(this, ' '); + } while ((this->posX - this->baseX) % 256); + break; + case GFXP_HIRAGANA_CHAR: + this->flags |= GFXP_FLAG_HIRAGANA; + break; + case GFXP_KATAKANA_CHAR: + this->flags &= ~GFXP_FLAG_HIRAGANA; + break; + case GFXP_RAINBOW_ON_CHAR: + this->flags |= GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_UPDATE; + break; + case GFXP_RAINBOW_OFF_CHAR: + this->flags &= ~GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_UPDATE; + break; + case GFXP_UNUSED_CHAR: + default: + break; + } + } +} void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount) { const char* str = (const char*)buffer; size_t count = charSize * charCount; - while (count) { + while (count != 0) { GfxPrint_PrintChar(this, *str++); count--; } } void GfxPrint_PrintString(GfxPrint* this, const char* str) { - while (*str) { - GfxPrint_PrintChar(this, *(str++)); + while (*str != '\0') { + GfxPrint_PrintChar(this, *str++); } } -GfxPrint* GfxPrint_Callback(GfxPrint* this, const char* str, size_t size) { +void* GfxPrint_Callback(void* arg, const char* str, size_t size) { + GfxPrint* this = arg; + GfxPrint_PrintStringWithSize(this, str, sizeof(char), size); + return this; } void GfxPrint_Init(GfxPrint* this) { - this->flag &= ~GFXPRINT_OPEN; + this->flags &= ~GFXP_FLAG_OPEN; this->callback = GfxPrint_Callback; - - this->dlist = NULL; + this->dList = NULL; this->posX = 0; this->posY = 0; this->baseX = 0; this->baseY = 0; this->color.rgba = 0; - this->flag &= ~GFXPRINT_FLAG1; - this->flag &= ~GFXPRINT_USE_RGBA16; - this->flag |= GFXPRINT_FLAG4; - this->flag |= GFXPRINT_UPDATE_MODE; + + this->flags &= ~GFXP_FLAG_HIRAGANA; + this->flags &= ~GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_SHADOW; + this->flags |= GFXP_FLAG_UPDATE; } void GfxPrint_Destroy(GfxPrint* this) { } -void GfxPrint_Open(GfxPrint* this, Gfx* dlist) { - if (!(this->flag & GFXPRINT_OPEN)) { - this->flag |= GFXPRINT_OPEN; - this->dlist = dlist; - GfxPrint_InitDlist(this); +void GfxPrint_Open(GfxPrint* this, Gfx* dList) { + if (!(this->flags & GFXP_FLAG_OPEN)) { + this->flags |= GFXP_FLAG_OPEN; + this->dList = dList; + GfxPrint_Setup(this); } } Gfx* GfxPrint_Close(GfxPrint* this) { Gfx* ret; - this->flag &= ~GFXPRINT_OPEN; - ret = this->dlist; - this->dlist = NULL; + this->flags &= ~GFXP_FLAG_OPEN; + ret = this->dList; + this->dList = NULL; + return ret; } s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { - return PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args); + return PrintUtils_VPrintf(&this->callback, fmt, args); } s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { diff --git a/src/boot_O2_g3/fault_drawer.c b/src/boot_O2_g3/fault_drawer.c index eacfc56d1..8efc930ec 100644 --- a/src/boot_O2_g3/fault_drawer.c +++ b/src/boot_O2_g3/fault_drawer.c @@ -41,6 +41,7 @@ FaultDrawer sFaultDrawerDefault = { NULL, // inputCallback }; +//! TODO: Needs to be extracted #pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/sFaultDrawerFont.s") void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) { diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index f2ed19c38..4e517c810 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -38,7 +38,7 @@ * Throughout this file, `mode` indicates whether to multiply the matrix on top of the stack by the new construction * (APPLY), or to just overwrite it (NEW). */ - +#include "prevent_bss_reordering.h" #include "global.h" /* data */ diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 637e1c229..7e2be3b0a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -137,7 +137,7 @@ 0x80085468:("StackCheck_GetState",), 0x800854E0:("StackCheck_CheckAll",), 0x80085538:("StackCheck_Check",), - 0x80085570:("GfxPrint_InitDlist",), + 0x80085570:("GfxPrint_Setup",), 0x800859BC:("GfxPrint_SetColor",), 0x80085A08:("GfxPrint_SetPosPx",), 0x80085A2C:("GfxPrint_SetPos",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 9529203e4..1223f31fa 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -32,8 +32,8 @@ 0x80096C40:("sStackInfoListStart","StackEntry*","",0x4), 0x80096C44:("sStackInfoListEnd","StackEntry*","",0x4), 0x80096C50:("sGfxPrintFontTLUT","u16","[64]",0x80), - 0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20), - 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), + 0x80096CD0:("sGfxPrintRainbowTLUT","u16","[16]",0x20), + 0x80096CF0:("sGfxPrintRainbowData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), 0x80097500:("sInitFuncs","void*","",0x4), 0x80097504:("sNew","char","[4]",0x4), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index a86be3b83..bbcf6d5de 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -134,7 +134,7 @@ asm/non_matchings/boot/stackcheck/StackCheck_Cleanup.s,StackCheck_Cleanup,0x8008 asm/non_matchings/boot/stackcheck/StackCheck_GetState.s,StackCheck_GetState,0x80085468,0x1E asm/non_matchings/boot/stackcheck/StackCheck_CheckAll.s,StackCheck_CheckAll,0x800854E0,0x16 asm/non_matchings/boot/stackcheck/StackCheck_Check.s,StackCheck_Check,0x80085538,0xE -asm/non_matchings/boot/gfxprint/GfxPrint_InitDlist.s,GfxPrint_InitDlist,0x80085570,0x113 +asm/non_matchings/boot/gfxprint/GfxPrint_Setup.s,GfxPrint_Setup,0x80085570,0x113 asm/non_matchings/boot/gfxprint/GfxPrint_SetColor.s,GfxPrint_SetColor,0x800859BC,0x13 asm/non_matchings/boot/gfxprint/GfxPrint_SetPosPx.s,GfxPrint_SetPosPx,0x80085A08,0x9 asm/non_matchings/boot/gfxprint/GfxPrint_SetPos.s,GfxPrint_SetPos,0x80085A2C,0xA From b3104f898b50a5679ebdcfdb1ef364f1e924c65f Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Sat, 18 Jun 2022 19:00:48 -0700 Subject: [PATCH 23/53] `Effect_Ss_Extra` (points that appear above targets in Swamp Archery Minigame) and `object_yabusame_point` (#822) * EffectExtra: start * EffectExtra: matched * EffectExtra: docs * EffectExtra: warnings * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update assets/xml/objects/object_yabusame_point.xml Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EffectExtra: fixes * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: Derek Hensley God damn it lenovo * Extra delete * EffectExtra: namefixer * EffectExtra: updated brief description Co-authored-by: Isghj8 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/object_yabusame_point.xml | 6 +- spec | 3 +- .../ovl_Effect_Ss_Extra/z_eff_ss_extra.c | 84 +++++++++++++++++-- 3 files changed, 81 insertions(+), 12 deletions(-) diff --git a/assets/xml/objects/object_yabusame_point.xml b/assets/xml/objects/object_yabusame_point.xml index 856d94cfe..a7a3cac85 100644 --- a/assets/xml/objects/object_yabusame_point.xml +++ b/assets/xml/objects/object_yabusame_point.xml @@ -1,6 +1,8 @@  - - + + + + diff --git a/spec b/spec index d0351563a..0d3ee9e29 100644 --- a/spec +++ b/spec @@ -1965,8 +1965,7 @@ beginseg name "ovl_Effect_Ss_Extra" compress include "build/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.o" - include "build/data/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra.data.o" - include "build/data/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index cd0359ae3..1de32d6ce 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -1,29 +1,97 @@ /* * File: z_eff_ss_extra.c * Overlay: ovl_Effect_Ss_Extra - * Description: + * Description: The floating points that pop-up in Swamp Bow Minigame + * i.e. 100 points for hitting the deku scrubs in the background */ #include "z_eff_ss_extra.h" +#include "objects/object_yabusame_point/object_yabusame_point.h" #define PARAMS ((EffectSsExtraInitParams*)initParamsx) -s32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 +static s16 sScores[] = { 30, 60, 100 }; + const EffectSsInit Effect_Ss_Extra_InitVars = { EFFECT_SS_EXTRA, EffectSsExtra_Init, }; -#endif +static TexturePtr sPointTextures[] = { gYabusamePoint30Tex, gYabusamePoint60Tex, gYabusamePoint100Tex }; -extern UNK_TYPE D_06000DC0; +#define rObjId regs[0] +#define rTimer regs[1] +#define rScoreIndex regs[2] +#define rScale regs[3] -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Init.s") +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + s32 pad; + EffectSsExtraInitParams* params = PARAMS; + s32 objIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Draw.s") + objIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_YABUSAME_POINT); + if ((objIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objIndex))) { + void* segBackup = gSegments[6]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Update.s") + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objIndex].segment); + + this->pos = params->pos; + this->velocity = params->velocity; + this->accel = params->accel; + this->draw = EffectSsExtra_Draw; + this->update = EffectSsExtra_Update; + this->life = 50; + this->rScoreIndex = params->scoreIdx; + this->rScale = params->scale; + this->rTimer = 5; + this->rObjId = objIndex; + + gSegments[6] = segBackup; + return 1; + } + return 0; +} + +void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + f32 scale; + void* storedSegment; + + scale = this->rScale / 100.0f; + storedSegment = globalCtx->objectCtx.status[this->rObjId].segment; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(storedSegment); + + gSPSegment(POLY_XLU_DISP++, 0x06, storedSegment); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sPointTextures[this->rScoreIndex])); + + gSPDisplayList(POLY_XLU_DISP++, &gYabusamePointDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->rTimer != 0) { + this->rTimer--; + } else { + this->velocity.y = 0.0f; + } + + if (this->rTimer == 1) { + globalCtx->interfaceCtx.unk_25C = sScores[this->rScoreIndex]; + } +} From e3c0c5c3fa79773ed5dc413fd38bac3b498dd30d Mon Sep 17 00:00:00 2001 From: Kristopher Early <1191258+MrPolymorph@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:08:42 +0100 Subject: [PATCH 24/53] Obj_Tokei_Turret OK (#820) * actor fully matched * named collision parameters] * fixed spec reloc.o * Addressing Review Comments! * Addressing Additional Review Comments * fixing enum names Co-authored-by: MrPolymorph <{ID}+{username}@users.noreply.github.com> --- assets/xml/objects/object_tokei_turret.xml | 27 ++++----- spec | 3 +- .../ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c | 58 +++++++++++++++---- .../ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h | 10 +++- undefined_syms.txt | 8 --- 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/assets/xml/objects/object_tokei_turret.xml b/assets/xml/objects/object_tokei_turret.xml index edca7c5c2..3ed158d83 100644 --- a/assets/xml/objects/object_tokei_turret.xml +++ b/assets/xml/objects/object_tokei_turret.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/spec b/spec index 0d3ee9e29..358e7362e 100644 --- a/spec +++ b/spec @@ -4211,8 +4211,7 @@ beginseg name "ovl_Obj_Tokei_Turret" compress include "build/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.o" - include "build/data/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret.data.o" - include "build/data/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c index 327183cfd..29ea1f8a8 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c @@ -5,6 +5,7 @@ */ #include "z_obj_tokei_turret.h" +#include "objects/object_tokei_turret/object_tokei_turret.h" #define FLAGS 0x00000000 @@ -15,7 +16,6 @@ void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx); void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Tokei_Turret_InitVars = { ACTOR_OBJ_TOKEI_TURRET, ACTORCAT_BG, @@ -28,23 +28,59 @@ const ActorInit Obj_Tokei_Turret_InitVars = { (ActorFunc)ObjTokeiTurret_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B91EC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjTokeiTurret_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjTokeiTurret* this = THIS; + s32 tier; -extern InitChainEntry D_80B91EC0[]; + tier = OBJ_TOKEI_TURRET_TIER_TYPE(thisx); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); -extern UNK_TYPE D_060026A0; -extern UNK_TYPE D_06002A88; + if ((tier == TURRET_TIER_BASE) || (tier == TURRET_TIER_TOP)) { + this->dyna.actor.uncullZoneDownward = this->dyna.actor.uncullZoneScale = 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Init.s") + if (tier == TURRET_TIER_BASE) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTownTurretBaseCol); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTownTurretPlatformCol); + } + } else { + this->dyna.actor.uncullZoneDownward = this->dyna.actor.uncullZoneScale = 1300.0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Destroy.s") +void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeiTurret* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Draw.s") +void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeiTurret* this = THIS; + Gfx* gfx; + + if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_TOP) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(gfx++, gClockTownTurretPlatformTopDL); + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_BASE) { + Gfx_DrawDListOpa(globalCtx, gClockTownTurretPlatformBaseDL); + } else { + Gfx_DrawDListOpa(globalCtx, gClockTownFlagsDL); + } +} diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h index 42cb6f5d7..7a2db071e 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h @@ -3,11 +3,17 @@ #include "global.h" +#define OBJ_TOKEI_TURRET_TIER_TYPE(thisx) ((thisx)->params & 3) + +typedef enum { + /* 0 */ TURRET_TIER_BASE, + /* 1 */ TURRET_TIER_TOP, +} TurretTierType; + struct ObjTokeiTurret; typedef struct ObjTokeiTurret { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjTokeiTurret; // size = 0x15C extern const ActorInit Obj_Tokei_Turret_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index f24e3b627..29dbf71be 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1627,14 +1627,6 @@ D_06001CB0 = 0x06001CB0; D_06001400 = 0x06001400; -// ovl_Obj_Tokei_Turret - -D_06002508 = 0x06002508; -D_060026A0 = 0x060026A0; -D_06002A88 = 0x06002A88; -D_06002D80 = 0x06002D80; -D_06003038 = 0x06003038; - // ovl_Obj_Toudai D_060023B0 = 0x060023B0; From dd8221c7981d40a1a92e86e196b5495012629f11 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:19:33 +0100 Subject: [PATCH 25/53] En_Time_Tag (#810) * En_Time_Tag * BSS * PR * PR --- include/z64.h | 8 +- include/z64player.h | 1 - spec | 3 +- .../actors/ovl_En_Time_Tag/z_en_time_tag.c | 268 ++++++++++++++++-- .../actors/ovl_En_Time_Tag/z_en_time_tag.h | 5 + 5 files changed, 261 insertions(+), 24 deletions(-) diff --git a/include/z64.h b/include/z64.h index 77f6a5ce0..a54ef333a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -794,12 +794,18 @@ typedef struct { /* 0x24 */ u32 flags; } PreRenderParams; // size = 0x28 +typedef struct { + /* 0x00 */ u8 unk00; + /* 0x01 */ u8 unk01; +} MsgCtx11F00; + typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; /* 0x11EF4 */ char unk_11EF4[0x4]; /* 0x11EF8 */ UNK_PTR unk11EF8; - /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x8]; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; + /* 0x11F00 */ MsgCtx11F00* unk11F00; /* 0x11F04 */ u16 currentTextId; /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; /* 0x11F0A */ u8 unk11F0A; diff --git a/include/z64player.h b/include/z64player.h index 4066e2baf..3a3d10dc9 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -188,7 +188,6 @@ typedef struct { typedef void (*PlayerFuncD58)(struct GlobalContext*, struct Player*); - typedef struct Player { /* 0x000 */ Actor actor; /* 0x144 */ s8 currentShield; diff --git a/spec b/spec index 358e7362e..dc4eaa6b5 100644 --- a/spec +++ b/spec @@ -3387,8 +3387,7 @@ beginseg name "ovl_En_Time_Tag" compress include "build/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.o" - include "build/data/ovl_En_Time_Tag/ovl_En_Time_Tag.data.o" - include "build/data/ovl_En_Time_Tag/ovl_En_Time_Tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Time_Tag/ovl_En_Time_Tag_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index cd0403c71..382bf2fdb 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -5,6 +5,7 @@ */ #include "z_en_time_tag.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) @@ -29,7 +30,6 @@ void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx); void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx); void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Time_Tag_InitVars = { ACTOR_EN_TIME_TAG, ACTORCAT_ITEMACTION, @@ -42,40 +42,268 @@ const ActorInit En_Time_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +void EnTimeTag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTimeTag* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Init.s") + this->actionFunc = func_80ACA840; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Destroy.s") + switch (ENTIMETAG_GET_E000(&this->actor)) { + case 4: + if ((gSaveContext.save.weekEventReg[8] & 0x40) || (CURRENT_DAY != 3)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.home.rot.x = 0; + this->actor.home.rot.y = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80AC9FD4.s") + case 2: + this->actionFunc = func_80ACA0A8; + this->actor.flags |= ACTOR_FLAG_2000000; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80AC9FE4.s") + case 1: + this->actionFunc = func_80ACA268; + this->actor.flags |= ACTOR_FLAG_2000000; + if (CHECK_QUEST_ITEM(QUEST_SONG_SOARING)) { + this->actor.textId = 0xC02; + return; + } + this->actor.textId = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA0A8.s") + case 3: + this->actionFunc = func_80ACA5F8; + this->actor.textId = 0; + this->actor.home.rot.x = 0; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA12C.s") +void EnTimeTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA184.s") +void func_80AC9FD4(EnTimeTag* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA208.s") +void func_80AC9FE4(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80AC9FD4; + gSaveContext.unk_3DD0[3] = 0; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[25] |= 2; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA268.s") +void func_80ACA0A8(EnTimeTag* this, GlobalContext* globalCtx) { + EnTimeTag* this2 = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA348.s") + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 4)) { + if (this->actor.cutscene != -1) { + this->actionFunc = func_80AC9FE4; + ActorCutscene_SetIntentToPlay(this2->actor.cutscene); + gSaveContext.unk_3DD0[3] = 0; + } + globalCtx->msgCtx.ocarinaMode = 4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA3C0.s") +void func_80ACA12C(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80ACA268; + this->actor.textId = 0xC02; + Item_Give(globalCtx, ITEM_SONG_SOARING); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA418.s") +void func_80ACA184(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actionFunc = func_80ACA12C; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA5F8.s") +void func_80ACA208(EnTimeTag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80ACA268; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA714.s") +void func_80ACA268(EnTimeTag* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.textId == 0) { + this->actionFunc = func_80ACA184; + } else { + this->actionFunc = func_80ACA208; + } + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + (Flags_GetSwitch(globalCtx, ENTIMETAG_GET_SWITCHFLAG(&this->actor)) || + CHECK_QUEST_ITEM(QUEST_SONG_SOARING))) { + this->actor.flags |= ACTOR_FLAG_1; + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA724.s") +void func_80ACA348(EnTimeTag* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.home.rot.x--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA7C4.s") + if (this->actor.home.rot.z != 0) { + func_80151938(globalCtx, 0x1230); + } else { + func_80151938(globalCtx, 0x122D); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA840.s") + this->actionFunc = func_80ACA418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Update.s") +void func_80ACA3C0(EnTimeTag* this, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.unk11F00->unk01 == 0) && (globalCtx->msgCtx.msgMode == 0x1B)) { + this->actor.home.rot.x = 5; + this->actionFunc = func_80ACA348; + globalCtx->msgCtx.unk11F10 = 0; + globalCtx->msgCtx.msgMode = 0; + } +} + +void func_80ACA418(EnTimeTag* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x101C: + case 0x101D: + case 0x101E: + case 0x122D: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x101F: + case 0x122A: + case 0x1230: + func_801477B4(globalCtx); + this->actionFunc = func_80ACA5F8; + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + break; + + case 0x122B: + func_80152434(globalCtx, 0x3F); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 0; + break; + + case 0x122E: + func_80152434(globalCtx, 0x40); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 1; + break; + } + } + break; + + case 2: + this->actionFunc = func_80ACA5F8; + break; + } + + if (this->actor.home.rot.x != 0) { + if (this->actor.cutscene == -1) { + this->actor.home.rot.x = 0; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actor.home.rot.x = 0; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80ACA5F8(EnTimeTag* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (ENTIMETAG_GET_SWITCHFLAG(&this->actor) == 1) { + Message_StartTextbox(globalCtx, 0x101C, &this->actor); + } else { + Message_StartTextbox(globalCtx, 0x122B, &this->actor); + } + this->actor.home.rot.x = 1; + } else { + Message_StartTextbox(globalCtx, 0x122A, &this->actor); + if (0) {} + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); + this->actor.home.rot.x = 0; + } + this->actionFunc = func_80ACA418; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80ACA714(EnTimeTag* this, GlobalContext* globalCtx) { +} + +void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENTIMETAG_GET_1F(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + if (!ENTIMETAG_GET_E000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_DOOR_OPEN); + } + this->actionFunc = func_80ACA714; + } +} + +void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[63] & 1) && !(gSaveContext.save.weekEventReg[63] & 2)) { + func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(globalCtx, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } +} + +void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx) { + s16 temp_ft4; + s16 temp_hi; + + if ((globalCtx->sceneNum != SCENE_YADOYA) || (INV_CONTENT(ITEM_ROOM_KEY) != ITEM_ROOM_KEY)) { + temp_ft4 = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F + temp_hi = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60; + if (gSaveContext.save.weekEventReg[63] & 1) { + if (gSaveContext.save.weekEventReg[63] & 2) { + this->actionFunc = func_80ACA7C4; + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y)) { + gSaveContext.save.weekEventReg[63] |= 2; + } + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y) && + !Play_InCsMode(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(globalCtx, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } + } +} + +void EnTimeTag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTimeTag* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h index 7c2a6c00c..531b0aa90 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h @@ -7,6 +7,11 @@ struct EnTimeTag; typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, GlobalContext*); +#define ENTIMETAG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENTIMETAG_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENTIMETAG_GET_1FE0(thisx) (((thisx)->params & 0x1FE0) >> 0x5) +#define ENTIMETAG_GET_E000(thisx) (((thisx)->params & 0xE000) >> 0xD) + typedef struct EnTimeTag { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTimeTagActionFunc actionFunc; From 98ba7557513725f9dba6de8afcc02388a9eac96e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:23:25 +0100 Subject: [PATCH 26/53] En_Horse_Link_Child (#806) * EnHorseLinkChild * PR * PR --- include/z64skin.h | 4 +- spec | 3 +- .../z_en_horse_link_child.c | 573 ++++++++++++++++-- .../z_en_horse_link_child.h | 14 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 551 insertions(+), 52 deletions(-) diff --git a/include/z64skin.h b/include/z64skin.h index adb2f9b0f..3d0969fb2 100644 --- a/include/z64skin.h +++ b/include/z64skin.h @@ -78,8 +78,8 @@ typedef struct { /* 0x04C */ SkelAnime skelAnime; } Skin; // size = 0x90 -typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*); -typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*); +typedef void (*SkinPostDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, Skin* skin); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, s32 limbIndex, Skin* skin); #define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) #define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) diff --git a/spec b/spec index dc4eaa6b5..54a782654 100644 --- a/spec +++ b/spec @@ -1169,8 +1169,7 @@ beginseg name "ovl_En_Horse_Link_Child" compress include "build/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.o" - include "build/data/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child.data.o" - include "build/data/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index da62a57e0..26295c6eb 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -5,6 +5,7 @@ */ #include "z_en_horse_link_child.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,7 +16,16 @@ void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808DEA0C(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DEB14(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DECA0(EnHorseLinkChild* this); +void func_808DED40(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DEFE8(EnHorseLinkChild* this); +void func_808DF194(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DF620(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DF788(EnHorseLinkChild* this); +void func_808DF838(EnHorseLinkChild* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Link_Child_InitVars = { ACTOR_EN_HORSE_LINK_CHILD, ACTORCAT_BG, @@ -28,77 +38,560 @@ const ActorInit En_Horse_Link_Child_InitVars = { (ActorFunc)EnHorseLinkChild_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808DFED4[1] = { +AnimationHeader* D_808DFEC0[] = { &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468 }; + +AnimationHeader* D_808DFEC8[] = { &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98 }; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 10 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808DFEF8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_808DFED4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808DFF08 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808DFF2C[] = { +s32 D_808DFF10[] = { 1, 19 }; + +f32 D_808DFF18[] = { 1.0f, 1.0f, 1.5f, 1.5f, 1.5f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), }; -#endif +EnHorseLinkChildUnkFunc D_808DFF30[] = { + func_808DEA0C, func_808DED40, func_808DEB14, func_808DF194, func_808DF838, func_808DF620, +}; -extern ColliderJntSphElementInit D_808DFED4[1]; -extern ColliderJntSphInit D_808DFEF8; -extern CollisionCheckInfoInit D_808DFF08; -extern InitChainEntry D_808DFF2C[]; +TexturePtr D_808DFF48[] = { object_horse_link_child_Tex_001D28, object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28 }; -extern UNK_TYPE D_06002F98; +s8 D_808DFF54[] = { 0, 1, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE5C0.s") +void func_808DE5C0(EnHorseLinkChild* this) { + if ((D_808DFF10[this->unk_1E8] < this->skin.skelAnime.curFrame) && + ((this->unk_1E8 != 0) || !(D_808DFF10[1] < this->skin.skelAnime.curFrame))) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + this->unk_1E8++; + if (this->unk_1E8 >= 2) { + this->unk_1E8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE660.s") +void func_808DE660(EnHorseLinkChild* this) { + if (this->unk_148 == 2) { + func_808DE5C0(this); + } else if (this->skin.skelAnime.curFrame == 0.0f) { + if ((this->unk_148 == 3) || (this->unk_148 == 4)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else if (this->unk_148 == 1) { + if (Rand_ZeroOne() > 0.5f) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE728.s") +f32 func_808DE728(EnHorseLinkChild* this) { + f32 phi_fv1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Init.s") + if (this->unk_148 == 2) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 2.0f); + } else if (this->unk_148 == 3) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 3.0f); + } else if (this->unk_148 == 4) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 5.0f); + } else { + phi_fv1 = D_808DFF18[this->unk_148]; + } + return phi_fv1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Destroy.s") +void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE9A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, 0.00648f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEA0C.s") + this->actor.gravity = -3.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEA54.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEB14.s") + this->unk_144 = 1; + this->actor.speedXZ = 0.0f; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DECA0.s") + Skin_Init(&globalCtx->state, &this->skin, &object_horse_link_child_Skel_00A480, + &object_horse_link_child_Anim_002F98); + this->unk_148 = 0; + Animation_PlayOnce(&this->skin.skelAnime, D_808DFEC0[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DED40.s") + Collider_InitCylinder(globalCtx, &this->colldierCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEFE8.s") + this->unk_1E8 = 0; + this->unk_1E4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF088.s") + if (gSaveContext.sceneSetupIndex >= 4) { + func_808DEFE8(this); + } else { + func_808DEFE8(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF194.s") + this->actor.home.rot.z = this->actor.world.rot.z = this->actor.shape.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF560.s") +void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF620.s") + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colldierCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF788.s") +void func_808DE9A8(EnHorseLinkChild* this) { + this->unk_144 = 0; + this->unk_148++; + if (this->unk_148 >= ARRAY_COUNT(D_808DFF18)) { + this->unk_148 = 0; + } + Animation_PlayOnce(&this->skin.skelAnime, D_808DFEC0[this->unk_148]); + this->skin.skelAnime.playSpeed = func_808DE728(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF838.s") +void func_808DEA0C(EnHorseLinkChild* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_808DE9A8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Update.s") +void func_808DEA54(EnHorseLinkChild* this, s32 arg1) { + this->unk_144 = 2; + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DFC3C.s") + if ((arg1 != 0) && (arg1 != 1)) { + arg1 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DFDC8.s") + if (arg1 != this->unk_148) { + this->unk_148 = arg1; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Draw.s") +void func_808DEB14(EnHorseLinkChild* this, GlobalContext* globalCtx) { + f32 sp44 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + s32 phi_v0; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if ((sp44 < 1000.0f) && (sp44 > 70.0f)) { + func_808DECA0(this); + return; + } + + if (this->unk_148 == 1) { + phi_v0 = 0; + } else { + phi_v0 = 1; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_808DECA0(EnHorseLinkChild* this) { + this->unk_144 = 1; + this->unk_148 = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DED40(EnHorseLinkChild* this, GlobalContext* globalCtx) { + f32 temp_fv0; + s16 temp_a0; + s32 phi_v0; + + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + temp_a0 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + if (temp_a0 > 0x12C) { + this->actor.world.rot.y += 0x12C; + } else if (temp_a0 < -0x12C) { + this->actor.world.rot.y -= 0x12C; + } else { + this->actor.world.rot.y += temp_a0; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + temp_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + if (temp_fv0 > 1000.0f) { + func_808DEA54(this, 0); + return; + } + + if ((temp_fv0 < 1000.0f) && (temp_fv0 >= 300.0f)) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if ((temp_fv0 < 300.0f) && (temp_fv0 >= 150.0f)) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else if ((temp_fv0 < 150.0f) && (temp_fv0 >= 70.0f)) { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + func_808DEA54(this, 1); + return; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_808DEFE8(EnHorseLinkChild* this) { + this->unk_144 = 3; + this->unk_148 = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DF088(EnHorseLinkChild* this, GlobalContext* globalCtx) { + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + s32 phi_v0; + s32 pad; + + if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) < 250.0f) { + sp32 = player->actor.shape.rot.y; + if (Actor_YawBetweenActors(&this->actor, &player->actor) > 0) { + phi_v0 = 1; + } else { + phi_v0 = -1; + } + sp32 += (phi_v0 << 0xE); + } else { + sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; + } + + if (sp32 > 0x12C) { + this->actor.world.rot.y += 0x12C; + } else if (sp32 < -0x12C) { + this->actor.world.rot.y += -0x12C; + } else { + this->actor.world.rot.y += sp32; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} + +void func_808DF194(EnHorseLinkChild* this, GlobalContext* globalCtx) { + Player* player; + f32 sp50; + s32 sp4C; + s32 sp48; + + func_808DF088(this, globalCtx); + + player = GET_PLAYER(globalCtx); + sp50 = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + sp48 = this->unk_148; + sp4C = SkelAnime_Update(&this->skin.skelAnime); + + if ((sp4C != 0) || (this->unk_148 == 1) || (this->unk_148 == 0)) { + if ((gSaveContext.save.weekEventReg[1] & 0x20)) { + f32 sp44 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); + s32 pad; + + if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) > 250.0f) { + if (sp44 >= 300.0f) { + sp48 = 4; + this->actor.speedXZ = 6.0f; + } else if ((sp44 < 300.0f) && (sp44 >= 150.0f)) { + sp48 = 3; + this->actor.speedXZ = 4.0f; + } else if ((sp44 < 150.0f) && (sp44 >= 70.0f)) { + sp48 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } else if (sp50 < 200.0f) { + sp48 = 4; + this->actor.speedXZ = 6.0f; + } else if (sp50 < 300.0f) { + sp48 = 3; + this->actor.speedXZ = 4.0f; + } else if (sp50 < 400.0f) { + sp48 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } + + if ((sp48 != this->unk_148) || (sp4C == 1)) { + this->unk_148 = sp48; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), + this->skin.skelAnime.curFrame, Animation_GetLastFrame(D_808DFEC0[this->unk_148]), + ANIMMODE_ONCE, 0.0f); + } +} + +void func_808DF560(EnHorseLinkChild* this) { + this->unk_144 = 5; + + if (Rand_ZeroOne() > 0.5f) { + this->unk_148 = 0; + } else { + this->unk_148 = 1; + } + + D_801BDAA4 = 0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); +} + +void func_808DF620(EnHorseLinkChild* this, GlobalContext* globalCtx) { + s16 sp36; + + if (D_801BDAA4 != 0) { + D_801BDAA4 = 0; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + func_808DF788(this); + return; + } + + this->actor.speedXZ = 0.0f; + sp36 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((Math_CosS(sp36) < 0.7071f) && (this->unk_148 == 2)) { + func_800F415C(&this->actor, &GET_PLAYER(globalCtx)->actor.world.pos, 0x12C); + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (Math_CosS(sp36) < 0.0f) { + this->unk_148 = 2; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], D_808DFF18[this->unk_148], 0.0f, + Animation_GetLastFrame(D_808DFEC8[0]), ANIMMODE_ONCE, -5.0f); + } else { + func_808DF560(this); + } + } +} + +void func_808DF788(EnHorseLinkChild* this) { + this->unk_1DC = 0; + this->unk_144 = 4; + this->unk_148 = 2; + this->unk_1E0 = 0; + this->actor.speedXZ = 2.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DF838(EnHorseLinkChild* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 phi_fv0; + s32 phi_v0; + + this->unk_1DC++; + if (this->unk_1DC > 300) { + this->unk_1E0 = 1; + } + + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + if (this->unk_1E0 == 0) { + func_800F415C(&this->actor, &player->actor.world.pos, 0x12C); + } else { + func_800F415C(&this->actor, &this->actor.home.pos, 0x12C); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->unk_1E0 == 0) { + phi_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + } else { + phi_fv0 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); + } + + if (this->unk_1E0 == 0) { + if (phi_fv0 >= 300.0f) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if (phi_fv0 >= 150.0f) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } + } else if (phi_fv0 >= 300.0f) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if (phi_fv0 >= 150.0f) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else if (phi_fv0 >= 70.0f) { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + func_808DF560(this); + return; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHorseLinkChild* this = THIS; + + D_808DFF30[this->unk_144](this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D); + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->unk_1E4 == 0)) { + this->unk_1E4++; + } else if (this->unk_1E4 > 0) { + this->unk_1E4++; + if (this->unk_1E4 >= 4) { + this->unk_1E4 = 0; + } + } + + Collider_UpdateCylinder(&this->actor, &this->colldierCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colldierCylinder.base); + + func_808DE660(this); +} + +void EnHorseLinkChild_PostSkinDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + Vec3f sp4C; + Vec3f sp40; + EnHorseLinkChild* this = THIS; + s32 i; + + for (i = 0; i < this->colliderJntSph.count; i++) { + sp4C.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + sp4C.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + sp4C.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, &sp4C, &sp40); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = sp40.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = sp40.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = sp40.z; + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); +} + +s32 EnHorseLinkChild_OverrideSkinDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + EnHorseLinkChild* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == OBJECT_HORSE_LINK_CHILD_LIMB_0D) { + u8 index = D_808DFF54[this->unk_1E4]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808DFF48[index])); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_80138258(&this->actor, globalCtx, &this->skin, EnHorseLinkChild_PostSkinDraw, + EnHorseLinkChild_OverrideSkinDraw, true); +} diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h index ecc816c52..0cdbdda9a 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h @@ -6,9 +6,21 @@ struct EnHorseLinkChild; +typedef void (*EnHorseLinkChildUnkFunc)(struct EnHorseLinkChild*, GlobalContext*); + typedef struct EnHorseLinkChild { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x158]; + /* 0x144 */ s32 unk_144; + /* 0x148 */ s32 unk_148; + /* 0x14C */ Skin skin; + /* 0x1DC */ s32 unk_1DC; + /* 0x1DC */ s32 unk_1E0; + /* 0x1E4 */ u8 unk_1E4; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ ColliderCylinder colldierCylinder; + /* 0x238 */ ColliderJntSph colliderJntSph; + /* 0x258 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x298 */ UNK_TYPE1 unk298[4]; } EnHorseLinkChild; // size = 0x29C extern const ActorInit En_Horse_Link_Child_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7e2be3b0a..dbe8f14a6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6492,8 +6492,8 @@ 0x808DF788:("func_808DF788",), 0x808DF838:("func_808DF838",), 0x808DFB14:("EnHorseLinkChild_Update",), - 0x808DFC3C:("func_808DFC3C",), - 0x808DFDC8:("func_808DFDC8",), + 0x808DFC3C:("EnHorseLinkChild_PostSkinDraw",), + 0x808DFDC8:("EnHorseLinkChild_OverrideSkinDraw",), 0x808DFE3C:("EnHorseLinkChild_Draw",), 0x808E01A0:("DoorAna_SetupAction",), 0x808E01AC:("DoorAna_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 29dbf71be..15bcad8c1 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1205,11 +1205,6 @@ D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Horse_Link_Child - -D_06002F98 = 0x06002F98; -D_0600A480 = 0x0600A480; - // ovl_En_Ik D_06000CE8 = 0x06000CE8; From 9bf84176d4dee29f4370f50228dcd1d9ee6d0107 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 18 Jun 2022 19:28:55 -0700 Subject: [PATCH 27/53] Load OK (#792) * Progress * cleanup * Fix comment * progress * OK * Review pt1 * Update comments * update comments some more * Renamings * Add headers and some parens cleanup * Remove zelda64 * PR review * bss * Explain each relocation type a bit in the header comment * Relocate_Addr macro * Split off into z64load.h * Adjust comment slightly based on OOT review * OverlayRelocationType -> MIPSRelocationType * Last bit of cleanup from OoT * format * Split off functions --- include/functions.h | 7 +- include/ultra64.h | 1 + include/ultra64/r4300.h | 367 ++++++++++++++++++++++++++++++++ include/variables.h | 4 +- include/z64.h | 9 - include/z64load.h | 31 +++ spec | 1 - src/boot_O2/loadfragment.c | 188 +++++++++++++++- src/boot_O2/loadfragment2.c | 194 +++++++++-------- src/code/z_DLF.c | 1 + src/code/z_actor.c | 1 + src/code/z_effect_soft_sprite.c | 1 + src/code/z_kaleido_manager.c | 1 + src/code/z_overlay.c | 1 + tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 4 +- 16 files changed, 699 insertions(+), 114 deletions(-) create mode 100644 include/ultra64/r4300.h create mode 100644 include/z64load.h diff --git a/include/functions.h b/include/functions.h index 737b0ff81..b60aa04fa 100644 --- a/include/functions.h +++ b/include/functions.h @@ -104,12 +104,7 @@ void FaultDrawer_SetInputCallback(FaultDrawerCallback callback); void FaultDrawer_Init(void); void func_80084940(void); void func_80084968(void); -void Load_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); -s32 Load_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 allocatedVRamAddr, u32 allocatedBytes); -void* Load_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart); -void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); -s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr); -void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd); + void PadUtils_Init(Input* input); void func_80085150(void); void PadUtils_ResetPressRel(Input* input); diff --git a/include/ultra64.h b/include/ultra64.h index 49323cc2b..6ffb26ff6 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -13,6 +13,7 @@ #include "ultra64/rcp.h" #include "ultra64/rdp.h" #include "ultra64/rsp.h" +#include "ultra64/r4300.h" #include "ultra64/vi.h" #endif diff --git a/include/ultra64/r4300.h b/include/ultra64/r4300.h new file mode 100644 index 000000000..30e8a9ea8 --- /dev/null +++ b/include/ultra64/r4300.h @@ -0,0 +1,367 @@ +#ifndef ULTRA64_R4300_H +#define ULTRA64_R4300_H + +#ifdef _LANGUAGE_C +#include "PR/ultratypes.h" +#define U32(x) ((u32)x) +#define C_REG(x) (x) +#else +#define U32(x) (x) +#define C_REG(x) $x +#endif + +// Segment base addresses and sizes +#define KUBASE 0 +#define KUSIZE 0x80000000 +#define K0BASE 0x80000000 +#define K0SIZE 0x20000000 +#define K1BASE 0xA0000000 +#define K1SIZE 0x20000000 +#define K2BASE 0xC0000000 +#define K2SIZE 0x20000000 + +// Exception vectors +#define SIZE_EXCVEC 0x80 // Size of an exc. vec +#define UT_VEC K0BASE // utlbmiss vector +#define R_VEC (K1BASE + 0x1FC00000) // reset vector +#define XUT_VEC (K0BASE + 0x80) // extended address tlbmiss +#define ECC_VEC (K0BASE + 0x100) // Ecc exception vector +#define E_VEC (K0BASE + 0x180) // Gen. exception vector + +// Address conversion macros +#define K0_TO_K1(x) (U32(x) | 0xA0000000) // kseg0 to kseg1 +#define K1_TO_K0(x) (U32(x) & 0x9FFFFFFF) // kseg1 to kseg0 +#define K0_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // kseg0 to physical +#define K1_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // kseg1 to physical +#define KDM_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // direct mapped to physical +#define PHYS_TO_K0(x) (U32(x) | 0x80000000) // physical to kseg0 +#define PHYS_TO_K1(x) (U32(x) | 0xA0000000) // physical to kseg1 + +// Address predicates +#define IS_KSEG0(x) (U32(x) >= K0BASE && U32(x) < K1BASE) +#define IS_KSEG1(x) (U32(x) >= K1BASE && U32(x) < K2BASE) +#define IS_KSEGDM(x) (U32(x) >= K0BASE && U32(x) < K2BASE) +#define IS_KSEG2(x) (U32(x) >= K2BASE && U32(x) < KPTE_SHDUBASE) +#define IS_KPTESEG(x) (U32(x) >= KPTE_SHDUBASE) +#define IS_KUSEG(x) (U32(x) < K0BASE) + +// TLB size constants +#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ + +#define TLBHI_VPN2MASK 0xFFFFE000 +#define TLBHI_VPN2SHIFT 13 +#define TLBHI_PIDMASK 0xFF +#define TLBHI_PIDSHIFT 0 +#define TLBHI_NPID 255 // 255 to fit in 8 bits + +#define TLBLO_PFNMASK 0x3FFFFFC0 +#define TLBLO_PFNSHIFT 6 +#define TLBLO_CACHMASK 0x38 // cache coherency algorithm +#define TLBLO_CACHSHIFT 3 +#define TLBLO_UNCACHED 0x10 // not cached +#define TLBLO_NONCOHRNT 0x18 // Cacheable non-coherent +#define TLBLO_EXLWR 0x28 // Exclusive write +#define TLBLO_D 0x4 // writeable +#define TLBLO_V 0x2 // valid bit +#define TLBLO_G 0x1 // global access bit + +#define TLBINX_PROBE 0x80000000 +#define TLBINX_INXMASK 0x3F +#define TLBINX_INXSHIFT 0 + +#define TLBRAND_RANDMASK 0x3F +#define TLBRAND_RANDSHIFT 0 + +#define TLBWIRED_WIREDMASK 0x3F + +#define TLBCTXT_BASEMASK 0xFF800000 +#define TLBCTXT_BASESHIFT 23 +#define TLBCTXT_BASEBITS 9 + +#define TLBCTXT_VPNMASK 0x7FFFF0 +#define TLBCTXT_VPNSHIFT 4 + +#define TLBPGMASK_4K 0x0 +#define TLBPGMASK_16K 0x6000 +#define TLBPGMASK_64K 0x1E000 + +/* + * Status register + */ +#define SR_CUMASK 0xF0000000 // coproc usable bits + +#define SR_CU3 0x80000000 // Coprocessor 3 usable +#define SR_CU2 0x40000000 // Coprocessor 2 usable +#define SR_CU1 0x20000000 // Coprocessor 1 usable +#define SR_CU0 0x10000000 // Coprocessor 0 usable +#define SR_RP 0x08000000 // Reduced power (quarter speed) +#define SR_FR 0x04000000 // MIPS III FP register mode +#define SR_RE 0x02000000 // Reverse endian +#define SR_ITS 0x01000000 // Instruction trace support +#define SR_BEV 0x00400000 // Use boot exception vectors +#define SR_TS 0x00200000 // TLB shutdown +#define SR_SR 0x00100000 // Soft reset occured +#define SR_CH 0x00040000 // Cache hit for last 'cache' op +#define SR_CE 0x00020000 // Create ECC +#define SR_DE 0x00010000 // ECC of parity does not cause error + +// Interrupt enable bits +// (NOTE: bits set to 1 enable the corresponding level interrupt) +#define SR_IMASK 0x0000FF00 // Interrupt mask +#define SR_IMASK8 0x00000000 // mask level 8 +#define SR_IMASK7 0x00008000 // mask level 7 +#define SR_IMASK6 0x0000C000 // mask level 6 +#define SR_IMASK5 0x0000E000 // mask level 5 +#define SR_IMASK4 0x0000F000 // mask level 4 +#define SR_IMASK3 0x0000F800 // mask level 3 +#define SR_IMASK2 0x0000FC00 // mask level 2 +#define SR_IMASK1 0x0000FE00 // mask level 1 +#define SR_IMASK0 0x0000FF00 // mask level 0 + +#define SR_IBIT8 0x00008000 // bit level 8 +#define SR_IBIT7 0x00004000 // bit level 7 +#define SR_IBIT6 0x00002000 // bit level 6 +#define SR_IBIT5 0x00001000 // bit level 5 +#define SR_IBIT4 0x00000800 // bit level 4 +#define SR_IBIT3 0x00000400 // bit level 3 +#define SR_IBIT2 0x00000200 // bit level 2 +#define SR_IBIT1 0x00000100 // bit level 1 + +#define SR_IMASKSHIFT 8 + +#define SR_KX 0x00000080 // extended-addr TLB vec in kernel +#define SR_SX 0x00000040 // xtended-addr TLB vec supervisor +#define SR_UX 0x00000020 // xtended-addr TLB vec in user mode +#define SR_KSU_MASK 0x00000018 // mode mask +#define SR_KSU_USR 0x00000010 // user mode +#define SR_KSU_SUP 0x00000008 // supervisor mode +#define SR_KSU_KER 0x00000000 // kernel mode +#define SR_ERL 0x00000004 // Error level, 1=>cache error +#define SR_EXL 0x00000002 // Exception level, 1=>exception +#define SR_IE 0x00000001 // interrupt enable, 1=>enable + +// Cause Register +#define CAUSE_BD 0x80000000 // Branch delay slot +#define CAUSE_CEMASK 0x30000000 // coprocessor error +#define CAUSE_CESHIFT 28 + +// Interrupt pending bits +#define CAUSE_IP8 0x00008000 // External level 8 pending - COMPARE +#define CAUSE_IP7 0x00004000 // External level 7 pending - INT4 +#define CAUSE_IP6 0x00002000 // External level 6 pending - INT3 +#define CAUSE_IP5 0x00001000 // External level 5 pending - INT2 +#define CAUSE_IP4 0x00000800 // External level 4 pending - INT1 +#define CAUSE_IP3 0x00000400 // External level 3 pending - INT0 +#define CAUSE_SW2 0x00000200 // Software level 2 pending +#define CAUSE_SW1 0x00000100 // Software level 1 pending + +#define CAUSE_IPMASK 0x0000FF00 // Pending interrupt mask +#define CAUSE_IPSHIFT 8 + +#define CAUSE_EXCMASK 0x0000007C // Cause code bits +#define CAUSE_EXCSHIFT 2 + +// Cause register exception codes + +#define EXC_CODE(x) ((x) << 2) + +// Hardware exception codes +#define EXC_INT EXC_CODE(0) // interrupt +#define EXC_MOD EXC_CODE(1) // TLB mod +#define EXC_RMISS EXC_CODE(2) // Read TLB Miss +#define EXC_WMISS EXC_CODE(3) // Write TLB Miss +#define EXC_RADE EXC_CODE(4) // Read Address Error +#define EXC_WADE EXC_CODE(5) // Write Address Error +#define EXC_IBE EXC_CODE(6) // Instruction Bus Error +#define EXC_DBE EXC_CODE(7) // Data Bus Error +#define EXC_SYSCALL EXC_CODE(8) // SYSCALL +#define EXC_BREAK EXC_CODE(9) // BREAKpoint +#define EXC_II EXC_CODE(10) // Illegal Instruction +#define EXC_CPU EXC_CODE(11) // CoProcessor Unusable +#define EXC_OV EXC_CODE(12) // OVerflow +#define EXC_TRAP EXC_CODE(13) // Trap exception +#define EXC_VCEI EXC_CODE(14) // Virt. Coherency on Inst. fetch +#define EXC_FPE EXC_CODE(15) // Floating Point Exception +#define EXC_WATCH EXC_CODE(23) // Watchpoint reference +#define EXC_VCED EXC_CODE(31) // Virt. Coherency on data read + +// C0_PRID Defines +#define C0_IMPMASK 0xFF00 +#define C0_IMPSHIFT 8 +#define C0_REVMASK 0xFF +#define C0_MAJREVMASK 0xF0 +#define C0_MAJREVSHIFT 4 +#define C0_MINREVMASK 0xF + +// Coprocessor 0 operations +#define C0_READI 0x1 // read ITLB entry addressed by C0_INDEX +#define C0_WRITEI 0x2 // write ITLB entry addressed by C0_INDEX +#define C0_WRITER 0x6 // write ITLB entry addressed by C0_RAND +#define C0_PROBE 0x8 // probe for ITLB entry addressed by TLBHI +#define C0_RFE 0x10 // restore for exception + +// 'cache' instruction definitions + +// Target cache +#define CACH_PI 0x0 // specifies primary inst. cache +#define CACH_PD 0x1 // primary data cache +#define CACH_SI 0x2 // secondary instruction cache +#define CACH_SD 0x3 // secondary data cache + +// Cache operations +#define C_IINV 0x0 // index invalidate (inst, 2nd inst) +#define C_IWBINV 0x0 // index writeback inval (d, sd) +#define C_ILT 0x4 // index load tag (all) +#define C_IST 0x8 // index store tag (all) +#define C_CDX 0xC // create dirty exclusive (d, sd) +#define C_HINV 0x10 // hit invalidate (all) +#define C_HWBINV 0x14 // hit writeback inv. (d, sd) +#define C_FILL 0x14 // fill (i) +#define C_HWB 0x18 // hit writeback (i, d, sd) +#define C_HSV 0x1C // hit set virt. (si, sd) + +// Cache size definitions +#define ICACHE_SIZE 0x4000 // 16K +#define ICACHE_LINESIZE 32 // 8 words +#define ICACHE_LINEMASK (ICACHE_LINESIZE - 1) + +#define DCACHE_SIZE 0x2000 // 8K +#define DCACHE_LINESIZE 16 // 4 words +#define DCACHE_LINEMASK (DCACHE_LINESIZE - 1) + +// C0_CONFIG register definitions +#define CONFIG_CM 0x80000000 // 1 == Master-Checker enabled +#define CONFIG_EC 0x70000000 // System Clock ratio +#define CONFIG_EC_1_1 0x6 // System Clock ratio 1 :1 +#define CONFIG_EC_3_2 0x7 // System Clock ratio 1.5 :1 +#define CONFIG_EC_2_1 0x0 // System Clock ratio 2 :1 +#define CONFIG_EC_3_1 0x1 // System Clock ratio 3 :1 +#define CONFIG_EP 0x0F000000 // Transmit Data Pattern +#define CONFIG_SB 0x00C00000 // Secondary cache block size + +#define CONFIG_SS 0x00200000 // Split scache: 0 == I&D combined +#define CONFIG_SW 0x00100000 // scache port: 0==128, 1==64 +#define CONFIG_EW 0x000C0000 // System Port width: 0==64, 1==32 +#define CONFIG_SC 0x00020000 // 0 -> 2nd cache present +#define CONFIG_SM 0x00010000 // 0 -> Dirty Shared Coherency enable +#define CONFIG_BE 0x00008000 // Endian-ness: 1 --> BE +#define CONFIG_EM 0x00004000 // 1 -> ECC mode, 0 -> parity +#define CONFIG_EB 0x00002000 // Block order:1->sequent,0->subblock + +#define CONFIG_IC 0x00000E00 // Primary Icache size +#define CONFIG_DC 0x000001C0 // Primary Dcache size +#define CONFIG_IB 0x00000020 // Icache block size +#define CONFIG_DB 0x00000010 // Dcache block size +#define CONFIG_CU 0x00000008 // Update on Store-conditional +#define CONFIG_K0 0x00000007 // K0SEG Coherency algorithm + +#define CONFIG_UNCACHED 0x00000002 // K0 is uncached +#define CONFIG_NONCOHRNT 0x00000003 +#define CONFIG_COHRNT_EXLWR 0x00000005 +#define CONFIG_SB_SHFT 22 // shift SB to bit position 0 +#define CONFIG_IC_SHFT 9 // shift IC to bit position 0 +#define CONFIG_DC_SHFT 6 // shift DC to bit position 0 +#define CONFIG_BE_SHFT 15 // shift BE to bit position 0 + +// C0_TAGLO definitions for setting/getting cache states and physaddr bits +#define SADDRMASK 0xFFFFE000 // 31..13 -> scache paddr bits 35..17 +#define SVINDEXMASK 0x00000380 // 9..7: prim virt index bits 14..12 +#define SSTATEMASK 0x00001C00 // bits 12..10 hold scache line state +#define SINVALID 0x00000000 // invalid --> 000 == state 0 +#define SCLEANEXCL 0x00001000 // clean exclusive --> 100 == state 4 +#define SDIRTYEXCL 0x00001400 // dirty exclusive --> 101 == state 5 +#define SECC_MASK 0x0000007F // low 7 bits are ecc for the tag +#define SADDR_SHIFT 4 // shift STagLo (31..13) to 35..17 + +#define PADDRMASK 0xFFFFFF00 // PTagLo31..8->prim paddr bits35..12 +#define PADDR_SHIFT 4 // roll bits 35..12 down to 31..8 +#define PSTATEMASK 0x00C0 // bits 7..6 hold primary line state +#define PINVALID 0x0000 // invalid --> 000 == state 0 +#define PCLEANEXCL 0x0080 // clean exclusive --> 10 == state 2 +#define PDIRTYEXCL 0x00C0 // dirty exclusive --> 11 == state 3 +#define PPARITY_MASK 0x0001 // low bit is parity bit (even). + +// C0_CACHE_ERR definitions. +#define CACHERR_ER 0x80000000 // 0: inst ref, 1: data ref +#define CACHERR_EC 0x40000000 // 0: primary, 1: secondary +#define CACHERR_ED 0x20000000 // 1: data error +#define CACHERR_ET 0x10000000 // 1: tag error +#define CACHERR_ES 0x08000000 // 1: external ref, e.g. snoo +#define CACHERR_EE 0x04000000 // error on SysAD bus +#define CACHERR_EB 0x02000000 // complicated, see spec. +#define CACHERR_EI 0x01000000 // complicated, see spec. +#define CACHERR_SIDX_MASK 0x003FFFF8 // secondary cache index +#define CACHERR_PIDX_MASK 0x00000007 // primary cache index +#define CACHERR_PIDX_SHIFT 12 // bits 2..0 are paddr14..12 + +/* + * R4000 family supports hardware watchpoints: + * C0_WATCHLO: + * bits 31..3 are bits 31..3 of physaddr to watch + * bit 2: reserved; must be written as 0. + * bit 1: when set causes a watchpoint trap on load accesses to paddr. + * bit 0: when set traps on stores to paddr; + * C0_WATCHHI + * bits 31..4 are reserved and must be written as zeros. + * bits 3..0 are bits 35..32 of the physaddr to watch + */ +#define WATCHLO_WTRAP 0x00000001 +#define WATCHLO_RTRAP 0x00000002 +#define WATCHLO_ADDRMASK 0xFFFFFFF8 +#define WATCHLO_VALIDMASK 0xFFFFFFFB +#define WATCHHI_VALIDMASK 0x0000000F + +// Coprocessor 0 registers +#define C0_INX C_REG(0) +#define C0_RAND C_REG(1) +#define C0_ENTRYLO0 C_REG(2) +#define C0_ENTRYLO1 C_REG(3) +#define C0_CONTEXT C_REG(4) +#define C0_PAGEMASK C_REG(5) // page mask +#define C0_WIRED C_REG(6) // # wired entries in tlb +#define C0_BADVADDR C_REG(8) +#define C0_COUNT C_REG(9) // free-running counter +#define C0_ENTRYHI C_REG(10) +#define C0_COMPARE C_REG(11) // counter comparison reg. +#define C0_SR C_REG(12) +#define C0_CAUSE C_REG(13) +#define C0_EPC C_REG(14) +#define C0_PRID C_REG(15) // revision identifier +#define C0_CONFIG C_REG(16) // hardware configuration +#define C0_LLADDR C_REG(17) // load linked address +#define C0_WATCHLO C_REG(18) // watchpoint +#define C0_WATCHHI C_REG(19) // watchpoint +#define C0_ECC C_REG(26) // S-cache ECC and primary parity +#define C0_CACHE_ERR C_REG(27) // cache error status +#define C0_TAGLO C_REG(28) // cache operations +#define C0_TAGHI C_REG(29) // cache operations +#define C0_ERROR_EPC C_REG(30) // ECC error prg. counter + +// floating-point status register +#define C1_FPCSR C_REG(31) + +#define FPCSR_FS 0x01000000 // flush denorm to zero +#define FPCSR_C 0x00800000 // condition bit +#define FPCSR_CE 0x00020000 // cause: unimplemented operation +#define FPCSR_CV 0x00010000 // cause: invalid operation +#define FPCSR_CZ 0x00008000 // cause: division by zero +#define FPCSR_CO 0x00004000 // cause: overflow +#define FPCSR_CU 0x00002000 // cause: underflow +#define FPCSR_CI 0x00001000 // cause: inexact operation +#define FPCSR_EV 0x00000800 // enable: invalid operation +#define FPCSR_EZ 0x00000400 // enable: division by zero +#define FPCSR_EO 0x00000200 // enable: overflow +#define FPCSR_EU 0x00000100 // enable: underflow +#define FPCSR_EI 0x00000080 // enable: inexact operation +#define FPCSR_FV 0x00000040 // flag: invalid operation +#define FPCSR_FZ 0x00000020 // flag: division by zero +#define FPCSR_FO 0x00000010 // flag: overflow +#define FPCSR_FU 0x00000008 // flag: underflow +#define FPCSR_FI 0x00000004 // flag: inexact operation +#define FPCSR_RM_MASK 0x00000003 // rounding mode mask +#define FPCSR_RM_RN 0x00000000 // round to nearest +#define FPCSR_RM_RZ 0x00000001 // round to zero +#define FPCSR_RM_RP 0x00000002 // round to positive infinity +#define FPCSR_RM_RM 0x00000003 // round to negative infinity + +#endif diff --git a/include/variables.h b/include/variables.h index c40ba1084..20b42dd71 100644 --- a/include/variables.h +++ b/include/variables.h @@ -35,8 +35,8 @@ extern const char* sCpuExceptions[18]; extern const char* sFpuExceptions[6]; extern FaultDrawer* sFaultDrawContext; extern FaultDrawer sFaultDrawerDefault; -// extern UNK_TYPE4 D_80096C20; -extern UNK_TYPE4 D_80096C30; +extern s32 gLoadLogSeverity; +extern s32 gLoad2LogSeverity; extern StackEntry* sStackInfoListStart; extern StackEntry* sStackInfoListEnd; // extern UNK_TYPE1 sGfxPrintFontTLUT; diff --git a/include/z64.h b/include/z64.h index a54ef333a..a0119f2f8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -290,15 +290,6 @@ typedef enum IRQ_TYPE { IRQ_PRENMI_4 = 0x2A1 } IRQ_TYPE; -typedef struct { - /* 0x00 */ u32 textSize; - /* 0x04 */ u32 dataSize; - /* 0x08 */ u32 rodataSize; - /* 0x0C */ u32 bssSize; - /* 0x10 */ u32 nRelocations; - /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; // size >= 0x18 - typedef struct { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; diff --git a/include/z64load.h b/include/z64load.h new file mode 100644 index 000000000..8570faf25 --- /dev/null +++ b/include/z64load.h @@ -0,0 +1,31 @@ +#ifndef Z64LOAD_H +#define Z64LOAD_H + +#include "PR/ultratypes.h" + +#define RELOCATE_ADDR(addr, vRamStart, allocu32) ((addr) - (vRamStart) + (allocu32)) + +#define RELOC_SECTION(reloc) ((reloc) >> 30) +#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) +#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) +#define RELOC_TYPE_SHIFT 24 + +/* MIPS Relocation Types */ +#define R_MIPS_32 2 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 + +typedef struct { + /* 0x00 */ u32 textSize; + /* 0x04 */ u32 dataSize; + /* 0x08 */ u32 rodataSize; + /* 0x0C */ u32 bssSize; + /* 0x10 */ u32 nRelocations; + /* 0x14 */ u32 relocations[1]; +} OverlayRelocationSection; // size >= 0x18 + +size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, void* allocatedVRamAddr); +void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd); + +#endif diff --git a/spec b/spec index 54a782654..cdf130b1d 100644 --- a/spec +++ b/spec @@ -29,7 +29,6 @@ beginseg include "build/src/boot_O2_g3/fault_drawer.o" include "build/src/boot_O2/boot_80084940.o" include "build/src/boot_O2/loadfragment.o" - include "build/data/boot/loadfragment.data.o" include "build/src/boot_O2/loadfragment2.o" include "build/src/boot_O2/padutils.o" include "build/src/boot_O2/stackcheck.o" diff --git a/src/boot_O2/loadfragment.c b/src/boot_O2/loadfragment.c index 968fb464a..17ed6b8ef 100644 --- a/src/boot_O2/loadfragment.c +++ b/src/boot_O2/loadfragment.c @@ -1,8 +1,190 @@ +/** + * @file loadfragment.c + * + * Functions used to process and relocate overlays + * + * @note: + * These are completly unused in favor of the functions in `loadfragment2.c`. + * + * The main difference between them seems to be the lack of vRamEnd arguments here. + * Instead they are calculated on the fly. + */ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_Relocate.s") +s32 gLoadLogSeverity = 2; -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_LoadOverlay.s") +void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) { + u32 sections[4]; + u32* relocDataP; + u32 reloc; + uintptr_t relocatedAddress; + u32 i; + u32* luiInstRef; + uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr; + u32* regValP; + u32* luiRefs[32]; + u32 luiVals[32]; + u32 isLoNeg; -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_AllocateAndLoad.s") + if (gLoadLogSeverity >= 3) {} + + sections[0] = 0; + sections[1] = allocu32; + sections[2] = allocu32 + ovl->textSize; + sections[3] = sections[2] + ovl->dataSize; + + for (i = 0; i < ovl->nRelocations; i++) { + reloc = ovl->relocations[i]; + relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc)); + + switch (RELOC_TYPE_MASK(reloc)) { + case R_MIPS_32 << RELOC_TYPE_SHIFT: + // Handles 32-bit address relocation, used for things such as jump tables and pointers in data. + // Just relocate the full address + + // Check address is valid for relocation + if ((*relocDataP & 0x0F000000) == 0) { + *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32); + } else if (gLoadLogSeverity >= 3) { + } + break; + + case R_MIPS_26 << RELOC_TYPE_SHIFT: + // Handles 26-bit address relocation, used for jumps and jals. + // Extract the address from the target field of the J-type MIPS instruction. + // Relocate the address and update the instruction. + + *relocDataP = + (*relocDataP & 0xFC000000) | + ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >> + 2); + break; + + case R_MIPS_HI16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 1. + // Store the reference to the LUI instruction (hi) using the `rt` register of the instruction. + // This will be updated later in the `R_MIPS_LO16` section. + + luiRefs[(*relocDataP >> 0x10) & 0x1F] = relocDataP; + luiVals[(*relocDataP >> 0x10) & 0x1F] = *relocDataP; + break; + + case R_MIPS_LO16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 2. + // Grab the stored LUI (hi) from the `R_MIPS_HI16` section using the `rs` register of the instruction. + // The full address is calculated, relocated, and then used to update both the LUI and lo instructions. + // If the lo part is negative, add 1 to the LUI value. + // Note: The lo instruction is assumed to have a signed immediate. + + luiInstRef = luiRefs[(*relocDataP >> 0x15) & 0x1F]; + regValP = &luiVals[(*relocDataP >> 0x15) & 0x1F]; + + // Check address is valid for relocation + if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { + relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32); + isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; + *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); + *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); + } else if (gLoadLogSeverity >= 3) { + } + break; + } + } +} + +size_t Load_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, void* allocatedVRamAddr, + size_t allocatedBytes) { + size_t size = vRomEnd - vRomStart; + void* end; + s32 pad; + OverlayRelocationSection* ovl; + + if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) {} + + end = (uintptr_t)allocatedVRamAddr + size; + DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); + + if (gLoadLogSeverity >= 3) {} + + if (allocatedBytes < ovl->bssSize + size) { + if (gLoadLogSeverity >= 3) {} + return 0; + } + + allocatedBytes = ovl->bssSize + size; + + if (gLoadLogSeverity >= 3) {} + + Load_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoadLogSeverity >= 3) {} + bzero(end, ovl->bssSize); + } + + osWritebackDCache(allocatedVRamAddr, allocatedBytes); + osInvalICache(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + return allocatedBytes; +} + +void* Load_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart) { + size_t size = vRomEnd - vRomStart; + void* end; + void* allocatedVRamAddr; + uintptr_t ovlOffset; + OverlayRelocationSection* ovl; + size_t allocatedBytes; + + if (gLoadLogSeverity >= 3) {} + + allocatedVRamAddr = SystemArena_MallocR(size); + end = (uintptr_t)allocatedVRamAddr + size; + + if (gLoadLogSeverity >= 3) {} + + DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + + if (gLoadLogSeverity >= 3) {} + + ovlOffset = (uintptr_t)end - 4; + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); + + if (1) {} + + allocatedBytes = ovl->bssSize + size; + + allocatedVRamAddr = SystemArena_Realloc(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + if (allocatedVRamAddr == NULL) { + if (gLoadLogSeverity >= 3) {} + return allocatedVRamAddr; + } + + end = (uintptr_t)allocatedVRamAddr + size; + ovl = (OverlayRelocationSection*)((uintptr_t)end - *(uintptr_t*)ovlOffset); + + if (gLoadLogSeverity >= 3) {} + + Load_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoadLogSeverity >= 3) {} + bzero(end, ovl->bssSize); + } + + osInvalICache(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + return allocatedVRamAddr; +} diff --git a/src/boot_O2/loadfragment2.c b/src/boot_O2/loadfragment2.c index c324b80d5..51b651c2b 100644 --- a/src/boot_O2/loadfragment2.c +++ b/src/boot_O2/loadfragment2.c @@ -1,120 +1,134 @@ +/** + * @file loadfragment2.c + * + * Functions used to process and relocate overlays + * + */ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -UNK_TYPE4 D_80096C30 = 2; +s32 gLoad2LogSeverity = 2; -#ifdef NON_MATCHING -// This needs lots of work. Mostly regalloc and getting the address of D_80096C30 placed in s5 at the beginning of the -// function -void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart) { - s32 sectionLocations[4]; - u32* regReferences[32]; - u32 regValues[32]; +void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) { + u32 sections[4]; + u32* relocDataP; + u32 reloc; + uintptr_t relocatedAddress; u32 i; - u32 relocatedAddress; - s32 signedOffset; - u32* lastInst; - u32* inst; - u32 relocation; - u32 relocationIndex; + u32* luiInstRef; + uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr; + u32* regValP; + u32* luiRefs[32]; + u32 luiVals[32]; + u32 isLoNeg; - sectionLocations[0] = 0; - sectionLocations[1] = allocatedVRamAddr; - sectionLocations[2] = overlayInfo->textSize + allocatedVRamAddr; - sectionLocations[3] = sectionLocations[2] + overlayInfo->dataSize; - for (i = 0, relocationIndex = 0; i < overlayInfo->nRelocations; relocationIndex++) { - relocation = overlayInfo->relocations[relocationIndex]; - i++; - inst = (u32*)(sectionLocations[relocation >> 0x1e] + (relocation & 0xffffff)); + if (gLoad2LogSeverity >= 3) {} - switch (relocation & 0x3f000000) { - case 0x2000000: - if ((*inst & 0xf000000) == 0) { - *inst = (*inst - vRamStart) + allocatedVRamAddr; + sections[0] = 0; + sections[1] = allocu32; + sections[2] = allocu32 + ovl->textSize; + sections[3] = sections[2] + ovl->dataSize; + + for (i = 0; i < ovl->nRelocations; i++) { + reloc = ovl->relocations[i]; + relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc)); + + switch (RELOC_TYPE_MASK(reloc)) { + case R_MIPS_32 << RELOC_TYPE_SHIFT: + // Handles 32-bit address relocation, used for things such as jump tables and pointers in data. + // Just relocate the full address + + // Check address is valid for relocation + if ((*relocDataP & 0x0F000000) == 0) { + *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32); + } else if (gLoad2LogSeverity >= 3) { } - /* - else { - if (D_80096C30 > 2) { - ; - } - } - */ break; - case 0x4000000: - *inst = - (*inst & 0xfc000000) | - ((((((*inst & 0x3ffffff) << 2 | 0x80000000) - vRamStart) + allocatedVRamAddr) & 0xfffffff) >> 2); + + case R_MIPS_26 << RELOC_TYPE_SHIFT: + // Handles 26-bit address relocation, used for jumps and jals. + // Extract the address from the target field of the J-type MIPS instruction. + // Relocate the address and update the instruction. + + *relocDataP = + (*relocDataP & 0xFC000000) | + ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >> + 2); break; - case 0x5000000: - regReferences[*inst >> 0x10 & 0x1f] = inst; - regValues[*inst >> 0x10 & 0x1f] = *inst; + + case R_MIPS_HI16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 1. + // Store the reference to the LUI instruction (hi) using the `rt` register of the instruction. + // This will be updated later in the `R_MIPS_LO16` section. + + luiRefs[(*relocDataP >> 0x10) & 0x1F] = relocDataP; + luiVals[(*relocDataP >> 0x10) & 0x1F] = *relocDataP; break; - case 0x6000000: - lastInst = regReferences[*inst >> 0x15 & 0x1f]; - signedOffset = (s16)*inst; - if (((signedOffset + *lastInst * 0x10000) & 0xf000000) == 0) { - relocatedAddress = - ((signedOffset + regValues[*inst >> 0x15 & 0x1f] * 0x10000) - vRamStart) + allocatedVRamAddr; - *lastInst = (((relocatedAddress >> 0x10) & 0xFFFF) + ((relocatedAddress & 0x8000) ? 1 : 0)) | - (*lastInst & 0xffff0000); - *inst = (*inst & 0xffff0000) | (relocatedAddress & 0xffff); + + case R_MIPS_LO16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 2. + // Grab the stored LUI (hi) from the `R_MIPS_HI16` section using the `rs` register of the instruction. + // The full address is calculated, relocated, and then used to update both the LUI and lo instructions. + // If the lo part is negative, add 1 to the LUI value. + // Note: The lo instruction is assumed to have a signed immediate. + + luiInstRef = luiRefs[(*relocDataP >> 0x15) & 0x1F]; + regValP = &luiVals[(*relocDataP >> 0x15) & 0x1F]; + + // Check address is valid for relocation + if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { + relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32); + isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; + *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); + *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); + } else if (gLoad2LogSeverity >= 3) { } break; } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_Relocate.s") -#endif -#ifdef NON_MATCHING -// Very minor stack stuff with a saved value -s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr) { - int nbytes; - u32 pad; - size_t size; +size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, + void* allocatedVRamAddr) { + s32 pad[2]; + s32 size = vRomEnd - vRomStart; void* end; - OverlayRelocationSection* overlayInfo; + OverlayRelocationSection* ovl; - size = vRomEnd - vRomStart; - - if (1) { - ; - } + if (gLoad2LogSeverity >= 3) {} + if (gLoad2LogSeverity >= 3) {} + end = (uintptr_t)allocatedVRamAddr + size; DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); - end = (void*)(allocatedVRamAddr + size); - overlayInfo = (OverlayRelocationSection*)((int)end - *(int*)((int)end + -4)); + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); - if (1) { - ; + if (gLoad2LogSeverity >= 3) {} + if (gLoad2LogSeverity >= 3) {} + + Load2_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoad2LogSeverity >= 3) {} + bzero(end, ovl->bssSize); } - Load2_Relocate(allocatedVRamAddr, overlayInfo, vRamStart); - - if (overlayInfo->bssSize != 0) { - bzero(end, overlayInfo->bssSize); - } - - nbytes = vRamEnd - vRamStart; - - osWritebackDCache((void*)allocatedVRamAddr, nbytes); - osInvalICache((void*)allocatedVRamAddr, nbytes); - return nbytes; -} -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_LoadOverlay.s") -#endif - -void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd) { - void* allocatedVRamAddr; - size_t size; - size = vRamEnd - vRamStart; - allocatedVRamAddr = SystemArena_MallocR(size); + + osWritebackDCache(allocatedVRamAddr, size); + osInvalICache(allocatedVRamAddr, size); + + if (gLoad2LogSeverity >= 3) {} + + return size; +} + +void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd) { + void* allocatedVRamAddr = SystemArena_MallocR(vRamEnd - vRamStart); + if (allocatedVRamAddr != NULL) { - Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, (u32)allocatedVRamAddr); + Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, allocatedVRamAddr); } return allocatedVRamAddr; diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index 4c57aca01..862463b76 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,5 +1,6 @@ #include "global.h" #include "system_malloc.h" +#include "z64load.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 9325d315c..bbabeafd5 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4,6 +4,7 @@ */ #include "global.h" +#include "z64load.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" #include "overlays/actors/ovl_En_Part/z_en_part.h" #include "overlays/actors/ovl_En_Box/z_en_box.h" diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index fd1d0212c..56eab9e8a 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" EffectSsInfo sEffectSsInfo = { NULL, 0, 0 }; diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 5e89f49e9..73656d65d 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" #define KALEIDO_OVERLAY(name) \ { \ diff --git a/src/code/z_overlay.c b/src/code/z_overlay.c index f635331c9..a358cefe6 100644 --- a/src/code/z_overlay.c +++ b/src/code/z_overlay.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_801651B0.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index dbe8f14a6..f037221be 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -114,7 +114,7 @@ 0x80084CD0:("Load_AllocateAndLoad",), 0x80084DB0:("Load2_Relocate",), 0x8008501C:("Load2_LoadOverlay",), - 0x800850C8:("Overlay_AllocateAndLoad",), + 0x800850C8:("Load2_AllocateAndLoad",), 0x80085130:("PadUtils_Init",), 0x80085150:("func_80085150",), 0x80085158:("PadUtils_ResetPressRel",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1223f31fa..e0bf5a65a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -27,8 +27,8 @@ 0x80096BC8:("sFpuExceptions","char*","[6]",0x18), 0x80096BE0:("sFaultDrawContext","FaultDrawer*","",0x4), 0x80096BE4:("sFaultDrawerDefault","FaultDrawer","",0x3c), - 0x80096C20:("D_80096C20","UNK_TYPE4","",0x4), - 0x80096C30:("D_80096C30","UNK_TYPE4","",0x4), + 0x80096C20:("gLoadLogSeverity","UNK_TYPE4","",0x4), + 0x80096C30:("gLoad2LogSeverity","UNK_TYPE4","",0x4), 0x80096C40:("sStackInfoListStart","StackEntry*","",0x4), 0x80096C44:("sStackInfoListEnd","StackEntry*","",0x4), 0x80096C50:("sGfxPrintFontTLUT","u16","[64]",0x80), From 5ae4ef87cd8b1bd94cdc63174bfe6bd3f8183723 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 18 Jun 2022 19:33:53 -0700 Subject: [PATCH 28/53] Sob1 Objects Documented (#814) * Start zora * Finish zora * BombShopkeeper with some cleanup * Goron and don gero mask * Small thing * format * PR comments * bombshopkeeper -> bomb_shopkeeper * gEffShockwaveDL --- assets/xml/objects/gameplay_keep.xml | 4 +- assets/xml/objects/object_mask_gero.xml | 19 +- assets/xml/objects/object_mastergolon.xml | 3 +- assets/xml/objects/object_masterzoora.xml | 3 +- assets/xml/objects/object_oF1d_map.xml | 230 ++++++++++-------- assets/xml/objects/object_rs.xml | 108 ++++---- assets/xml/objects/object_zo.xml | 112 +++++---- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 + src/overlays/actors/ovl_En_Fsn/z_en_fsn.h | 2 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 38 +-- src/overlays/actors/ovl_En_Go/z_en_go.c | 46 ++-- src/overlays/actors/ovl_En_Ossan/z_en_ossan.h | 3 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 19 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 16 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.h | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 176 +++++++------- src/overlays/actors/ovl_En_Sob1/z_en_sob1.h | 17 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 17 +- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 5 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 8 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 14 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 2 +- 23 files changed, 464 insertions(+), 384 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 6b624857f..d4a4ac277 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1001,8 +1001,8 @@ - - + + diff --git a/assets/xml/objects/object_mask_gero.xml b/assets/xml/objects/object_mask_gero.xml index b6acf6c17..b6f4a6117 100644 --- a/assets/xml/objects/object_mask_gero.xml +++ b/assets/xml/objects/object_mask_gero.xml @@ -1,13 +1,14 @@  + - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_mastergolon.xml b/assets/xml/objects/object_mastergolon.xml index ae481332c..35eb9d285 100644 --- a/assets/xml/objects/object_mastergolon.xml +++ b/assets/xml/objects/object_mastergolon.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_masterzoora.xml b/assets/xml/objects/object_masterzoora.xml index c4f8735d7..f21b99b50 100644 --- a/assets/xml/objects/object_masterzoora.xml +++ b/assets/xml/objects/object_masterzoora.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 6c3af0778..a55e9c9ea 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -1,108 +1,142 @@  + - - - - - - - + + + + + + + + + + + + + + - + - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index 01099db47..fe58a7555 100644 --- a/assets/xml/objects/object_rs.xml +++ b/assets/xml/objects/object_rs.xml @@ -1,53 +1,63 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index 8fc22ae46..d2a16cfac 100644 --- a/assets/xml/objects/object_zo.xml +++ b/assets/xml/objects/object_zo.xml @@ -1,28 +1,39 @@  + + - - - - - - + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + @@ -42,37 +53,44 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index bfc6102b0..9b089d836 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -843,7 +843,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 670bafff2..bfeca2143 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1410,6 +1410,8 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + + // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, FSN_LIMB_MAX + 1); if (ENFSN_IS_SHOP(&this->actor)) { diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 5fabf59ad..66cde7a2a 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -28,7 +28,7 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; + /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml /* 0x2F2 */ Vec3s morphTable[FSN_LIMB_MAX + 1]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index 79e5a3480..a2efb787a 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -126,14 +126,14 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -142,11 +142,11 @@ static AnimationInfoS sAnimations[] = { { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; u16 func_80BB16D0(EnGeg* this) { @@ -866,8 +866,8 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, &object_oF1d_map_Anim_012DE0, - this->jointTable, this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, &gGoronUnrollAnim, this->jointTable, this->morphTable, + GORON_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->colliderCylinder); Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); @@ -954,7 +954,7 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_004DB0); + gSPDisplayList(POLY_OPA_DISP++, gGoronDonGeroMaskDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1035,10 +1035,10 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi void func_80BB3BE0(EnGeg* this, GlobalContext* globalCtx) { static TexturePtr D_80BB4088[] = { - object_oF1d_map_Tex_010438, - object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, + gGoronEyeHalfTex, + gGoronEyeClosedTex, + gGoronEyeClosed2Tex, }; s32 pad; @@ -1072,7 +1072,7 @@ void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { Matrix_RotateXS(sp24, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 27c307777..659473e30 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -187,16 +187,16 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -249,7 +249,7 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_0031A0); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamMaterialDL); flag = true; } @@ -269,7 +269,7 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamModelDL); Matrix_Pop(); if (globalCtx->state.gfxCtx) {} @@ -325,7 +325,7 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!flag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); flag = true; } Matrix_Push(); @@ -344,7 +344,7 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); } @@ -516,9 +516,12 @@ void func_80A1203C(EnGo* this) { } void func_80A1213C(EnGo* this, GlobalContext* globalCtx) { - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0003D0, object_oF1d_map_DL_000458, 1); - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0008C0, object_oF1d_map_DL_000948, 2); - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_000D50, object_oF1d_map_DL_000DD8, 3); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronLargeSnowballFragmentMaterialDL, gGoronLargeSnowballFragmentModelDL, + 1); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronMediumSnowballFragmentMaterialDL, gGoronMediumSnowballFragmentModelDL, + 2); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronSmallSnowballFragmentMaterialDL, gGoronSmallSnowballFragmentModelDL, + 3); func_80A11144(this->unk_3F8, globalCtx); func_80A115B4(this->unk_3F8, globalCtx); } @@ -1459,8 +1462,8 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || SubS_IsObjectLoaded(this->unk_289, globalCtx)) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_3DC = -1; func_80A12C48(this, globalCtx, 2); @@ -1966,7 +1969,7 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? gGoronSnowballDL : gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -2059,8 +2062,7 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr D_80A1670C[] = { - object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex, gGoronEyeHalfTex, gGoronEyeClosed2Tex, }; EnGo* this = THIS; diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 58c638d8e..00ed6814a 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -6,7 +6,8 @@ #include "objects/object_ani/object_ani.h" #include "objects/object_fsn/object_fsn.h" -#define ENOSSAN_LIMB_MAX MAX(FSN_LIMB_MAX + 1, ANI_LIMB_MAX) +// Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml +#define ENOSSAN_LIMB_MAX MAX((s32)FSN_LIMB_MAX + 1, (s32)ANI_LIMB_MAX) struct EnOssan; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index c5f2954f9..43042ccd0 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -119,8 +119,8 @@ s32 D_80BF57E4[][4] = { }; AnimationInfoS D_80BF5914[] = { - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; TexturePtr D_80BF5934[] = { @@ -153,8 +153,7 @@ EffectTireMarkInit D_80BF59F0 = { }; TexturePtr D_80BF59F8[] = { - object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex, gGoronEyeHalfTex, gGoronEyeClosed2Tex, }; void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { @@ -170,8 +169,8 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 32; i++, ptr++) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!phi_fp) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, sizeof(Gfx) * 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); phi_fp = true; } @@ -193,7 +192,7 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = temp_f20 * 7.0f; gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF5934[idx])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); } @@ -728,8 +727,8 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.entranceIndex == 0xD010) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_334 = -1; func_80BF409C(this, 0); @@ -814,7 +813,7 @@ void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 3a29b5081..2d8eaa643 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -30,7 +30,7 @@ const ActorInit En_Rsn_InitVars = { (ActorFunc)EnRsn_Draw, }; -static AnimationInfo sAnimations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; +static AnimationInfo sAnimations[] = { { &gBombShopkeeperSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; void func_80C25D40(EnRsn* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); @@ -44,7 +44,7 @@ void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, NULL, NULL, 0); this->actor.flags &= ~ACTOR_FLAG_1; func_80C25D40(this); } @@ -67,20 +67,18 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRsn* this = THIS; - if (limbIndex == 14) { + if (limbIndex == BOMB_SHOPKEEPER_LIMB_RIGHT_HAND) { Matrix_RotateXS(this->unk1D8.y, MTXMODE_APPLY); } return false; } -static Vec3f D_80C26028 = { 0.0f, 0.0f, 0.0f }; - void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnRsn* this = THIS; - Vec3f sp18 = D_80C26028; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 14) { - Matrix_MultVec3f(&sp18, &this->actor.focus.pos); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_RIGHT_HAND) { + Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); } } @@ -89,7 +87,7 @@ void EnRsn_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRsn_OverrideLimbDraw, EnRsn_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h index b9a607a1c..926bc6d32 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h @@ -9,7 +9,7 @@ typedef void (*EnRsnActionFunc)(struct EnRsn*, GlobalContext*); typedef struct EnRsn { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x4C]; + /* 0x144 */ UNK_TYPE1 unk144[0x4C]; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnRsnActionFunc actionFunc; /* 0x1D8 */ Vec3s unk1D8; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 08c1a8aaf..a20556a31 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -5,11 +5,8 @@ */ #include "z_en_sob1.h" -#include "objects/object_rs/object_rs.h" -#include "objects/object_zo/object_zo.h" #include "objects/object_mastergolon/object_mastergolon.h" #include "objects/object_masterzoora/object_masterzoora.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -53,12 +50,18 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq); + +typedef enum { + /* 0 */ BOMB_SHOPKEEPER_ANIM_WALK, + /* 1 */ BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START, + /* 2 */ BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP +} BombShopkeeperAnimation; static AnimationInfoS sAnimationsBombShopkeeper[] = { - { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, - { &object_rs_Anim_008268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_rs_Anim_0087BC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gBombShopkeeperWalkAnim, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, + { &gBombShopkeeperSitAtCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gBombShopkeeperSitAtCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Sob1_InitVars = { @@ -153,10 +156,10 @@ static Vec3f sPosOffset[] = { { 0.0f, -4.0f, 0.0f }, }; -void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { +void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { f32 frameCount; - animations += idx; + animations += index; if (animations->frameCount < 0) { frameCount = Animation_GetLastFrame(animations->animation); } else { @@ -355,20 +358,20 @@ void EnSob1_SpawnShopItems(EnSob1* this, GlobalContext* globalCtx, ShopItem* sho s32 EnSob1_GetObjIndices(EnSob1* this, GlobalContext* globalCtx, s16* objIds) { if (objIds[1] != OBJECT_ID_MAX) { - this->objIndices[1] = Object_GetIndex(&globalCtx->objectCtx, objIds[1]); - if (this->objIndices[1] < 0) { + this->unusedObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[1]); + if (this->unusedObjIndex < 0) { return false; } } else { - this->objIndices[1] = -1; + this->unusedObjIndex = -1; } if (objIds[2] != OBJECT_ID_MAX) { - this->objIndices[2] = Object_GetIndex(&globalCtx->objectCtx, objIds[2]); - if (this->objIndices[2] < 0) { + this->shopkeeperAnimObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[2]); + if (this->shopkeeperAnimObjIndex < 0) { return false; } } else { - this->objIndices[2] = -1; + this->shopkeeperAnimObjIndex = -1; } return true; } @@ -398,8 +401,8 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { } objIds = sObjectIds[this->shopType]; - this->objIndices[0] = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); - if (this->objIndices[0] < 0) { + this->mainObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); + if (this->mainObjIndex < 0) { Actor_MarkForDeath(&this->actor); return; } @@ -423,7 +426,7 @@ void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -464,7 +467,7 @@ s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* inp s32 EnSob1_TestCancelOption(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -638,7 +641,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { s32 pad[2]; u8 talkState = Message_GetState(&globalCtx->msgCtx); - u8 cursorIdx; + u8 cursorIndex; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -661,9 +664,9 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { - cursorIdx = EnSob1_SetCursorIndexFromNeutral(this, 2); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnSob1_SetCursorIndexFromNeutral(this, 2); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnSob1_SetupAction(this, EnSob1_LookToShelf); func_8011552C(globalCtx, 6); this->stickRightPrompt.isEnabled = false; @@ -709,17 +712,17 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s32 pad; f32 distSq; s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; - s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; + s16 animLastFrame = Animation_GetLastFrame(&gBombShopkeeperWalkAnim) / (s16)this->skelAnime.playSpeed; Math_SmoothStepToS(&this->actor.world.rot.y, - EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), - 4, 1000, 1); + EnSob1_GetDistSqAndOrient(this->path, this->waypoint - 1, &this->actor.world.pos, &distSq), 4, + 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { this->actor.speedXZ = 0.0f; if (animLastFrame == curFrame) { - EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 1); + EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START); EnSob1_SetupAction(this, EnSob1_SetupIdle); } } @@ -729,8 +732,8 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - if (Animation_GetLastFrame(&object_rs_Anim_008268) == curFrame) { - EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 2); + if (Animation_GetLastFrame(&gBombShopkeeperSitAtCounterStartAnim) == curFrame) { + EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP); EnSob1_SetupAction(this, EnSob1_Idle); } EnSob1_Walking(this, globalCtx); @@ -750,13 +753,13 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } if (this->path != NULL) { Math_SmoothStepToS(&this->actor.world.rot.y, - EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), - 4, 1000, 1); + EnSob1_GetDistSqAndOrient(this->path, this->waypoint, &this->actor.world.pos, &distSq), 4, + 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { - this->pathPointsIdx++; - if ((this->path->count - 1) < this->pathPointsIdx) { + this->waypoint++; + if ((this->path->count - 1) < this->waypoint) { this->actor.speedXZ = 0.0f; EnSob1_SetupAction(this, EnSob1_EndWalk); } @@ -842,7 +845,7 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; EnSob1_UpdateCursorPos(globalCtx, this); EnSob1_SetupAction(this, EnSob1_BrowseShelf); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -850,7 +853,7 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { - u8 curTemp = this->cursorIdx; + u8 curTemp = this->cursorIndex; if (this->stickAccumX < 0) { if (curTemp != 2) { @@ -859,20 +862,20 @@ void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { EnSob1_SetupLookToShopkeeperFromShelf(globalCtx, this); } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } else if (this->stickAccumX > 0) { if (curTemp != 0) { curTemp--; } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } } s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; if (EnSob1_TestEndInteraction(this, globalCtx, input)) { return true; @@ -880,7 +883,7 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* if (EnSob1_TestItemSelected(globalCtx)) { if (!item->isOutOfStock) { this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + func_80151938(globalCtx, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -897,8 +900,8 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; - u8 prevCursorIdx = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnSob1_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -912,9 +915,9 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { func_8011552C(globalCtx, 6); if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { EnSob1_CursorLeftRight(globalCtx, this); - cursorIdx = this->cursorIdx; - if (cursorIdx != prevCursorIdx) { - func_80151938(globalCtx, this->items[cursorIdx]->actor.textId); + cursorIndex = this->cursorIndex; + if (cursorIndex != prevCursorIndex) { + func_80151938(globalCtx, this->items[cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -925,7 +928,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { Player* player = GET_PLAYER(globalCtx); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -945,7 +948,7 @@ void EnSob1_SetupCanBuy(GlobalContext* globalCtx, EnSob1* this, u16 textId) { } void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; EnGirlA* item2; switch (item->canBuyFunc(globalCtx, item)) { @@ -955,7 +958,7 @@ void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } func_8019F208(); - item2 = this->items[this->cursorIdx]; + item2 = this->items[this->cursorIndex]; item2->buyFanfareFunc(globalCtx, item2); EnSob1_SetupBuyItemWithFanfare(globalCtx, this); this->drawCursor = 0; @@ -1026,7 +1029,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); break; } } @@ -1037,7 +1040,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } } } @@ -1048,10 +1051,10 @@ void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(globalCtx, item); this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } } @@ -1060,7 +1063,7 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnSob1_SetupAction(this, EnSob1_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1086,7 +1089,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(globalCtx, item); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; @@ -1098,7 +1101,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_PositionSelectedItem(EnSob1* this) { Vec3f selectedItemPosition = sSelectedItemPositions[this->shopType]; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item; ShopItem* shopItem = &sShops[this->shopType][i]; Vec3f worldPos; @@ -1159,7 +1162,7 @@ void EnSob1_UpdateItemSelectedProperty(EnSob1* this) { this->drawCursor == 0) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -1247,14 +1250,14 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[pointIdx]; + points = &points[pointIndex]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -1283,33 +1286,34 @@ void EnSob1_WaitForBlink(EnSob1* this) { void EnSob1_Blink(EnSob1* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTextureIndexTemp; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTexIndex + 1; - if (eyeTextureIdxTemp > 2) { + eyeTextureIndexTemp = this->eyeTexIndex + 1; + if (eyeTextureIndexTemp > 2) { this->eyeTexIndex = 0; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; this->blinkFunc = EnSob1_WaitForBlink; } else { - this->eyeTexIndex = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTextureIndexTemp; this->blinkTimer = 1; } } void EnSob1_ChangeObject(EnSob1* this, GlobalContext* globalCtx) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); } s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[0])) { - if (this->objIndices[1] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[1])) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->mainObjIndex)) { + if (this->unusedObjIndex >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->unusedObjIndex)) { return false; } - if (this->objIndices[2] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[2])) { + if (this->shopkeeperAnimObjIndex >= 0 && + !Object_IsLoaded(&globalCtx->objectCtx, this->shopkeeperAnimObjIndex)) { return false; } return true; @@ -1318,27 +1322,28 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, + ZORA_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + Animation_Change(&this->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), + ANIMMODE_LOOP, 0.0f); this->actor.draw = EnSob1_ZoraShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + Animation_Change(&this->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), + ANIMMODE_LOOP, 0.0f); this->actor.draw = EnSob1_GoronShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, - this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, this->jointTable, + this->morphTable, BOMB_SHOPKEEPER_LIMB_MAX); this->actor.draw = EnSob1_BombShopkeeper_Draw; this->changeObjectFunc = NULL; this->skelAnime.playSpeed = 2.0f; @@ -1351,7 +1356,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_AreObjectsLoaded(this, globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10; - this->actor.objBankIndex = this->objIndices[0]; + this->actor.objBankIndex = this->mainObjIndex; Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; this->actor.world.pos.x += posOffset->x; @@ -1370,7 +1375,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->wasTalkedToWhileWalking = false; - this->pathPointsIdx = 0; + this->waypoint = 0; if (this->shopType == BOMB_SHOP) { this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); @@ -1385,7 +1390,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->stickAccumY = 0; this->stickAccumX = 0; - this->cursorIdx = 0; + this->cursorIndex = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; @@ -1575,7 +1580,7 @@ s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd Actor* thisx) { EnSob1* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { rot->x += this->headRot; } return false; @@ -1585,7 +1590,7 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd Actor* thisx) { EnSob1* this = THIS; - if (limbIndex == 15) { + if (limbIndex == BOMB_SHOPKEEPER_LIMB_HEAD) { Matrix_RotateXS(this->headRot, MTXMODE_APPLY); } return false; @@ -1594,8 +1599,8 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd void EnSob1_BombShopkeeper_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (limbIndex == 11) { - gSPDisplayList(POLY_OPA_DISP++, object_rs_DL_000970); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_LEFT_HAND) { + gSPDisplayList(POLY_OPA_DISP++, gBombShopkeeperBombDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1634,8 +1639,7 @@ void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { } void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038 }; + static TexturePtr sGoronShopkeeperEyeTextures[] = { gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex }; EnSob1* this = THIS; s32 pad; s32 i; @@ -1663,7 +1667,7 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSob1_BombShopkeeper_OverrideLimbDraw, EnSob1_BombShopkeeper_PostLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h index c1dfd3849..a854d4c3f 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -3,6 +3,11 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_rs/object_rs.h" +#include "objects/object_zo/object_zo.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" + +#define ENSOB1_LIMB_MAX MAX(MAX((s32)ZORA_LIMB_MAX, (s32)BOMB_SHOPKEEPER_LIMB_MAX), (s32)GORON_LIMB_MAX) struct EnSob1; @@ -27,13 +32,15 @@ typedef struct EnSob1 { /* 0x190 */ EnSob1ActionFunc changeObjectFunc; /* 0x194 */ ColliderCylinder collider; /* 0x1E0 */ Path* path; - /* 0x1E4 */ s32 pathPointsIdx; + /* 0x1E4 */ s32 waypoint; /* 0x1E8 */ s16 delayTimer; - /* 0x1EA */ s8 objIndices[3]; + /* 0x1EA */ s8 mainObjIndex; + /* 0x1EB */ s8 unusedObjIndex; + /* 0x1EC */ s8 shopkeeperAnimObjIndex; /* 0x1EE */ s16 headRot; /* 0x1F0 */ s16 headRotTarget; - /* 0x1F2 */ Vec3s jointTable[20]; - /* 0x26A */ Vec3s morphTable[20]; + /* 0x1F2 */ Vec3s jointTable[ENSOB1_LIMB_MAX]; + /* 0x26A */ Vec3s morphTable[ENSOB1_LIMB_MAX]; /* 0x2E2 */ s16 eyeTexIndex; /* 0x2E4 */ s16 blinkTimer; /* 0x2E8 */ EnSob1BlinkFunc blinkFunc; @@ -45,7 +52,7 @@ typedef struct EnSob1 { /* 0x31C */ f32 cursorAnimTween; /* 0x320 */ u8 cursorAnimState; /* 0x321 */ u8 drawCursor; - /* 0x322 */ u8 cursorIdx; + /* 0x322 */ u8 cursorIndex; /* 0x324 */ StickDirectionPrompt stickLeftPrompt; /* 0x35C */ StickDirectionPrompt stickRightPrompt; /* 0x394 */ f32 arrowAnimTween; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 2c5f76f2e..28c493497 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -5,7 +5,6 @@ */ #include "z_en_zo.h" -#include "objects/object_zo/object_zo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -257,7 +256,8 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, + ZORA_LIMB_MAX); EnZo_SetAnimation(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->collider); @@ -291,19 +291,20 @@ s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Gfx** gfx) { EnZo* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 8) { + if (limbIndex == ZORA_LIMB_TORSO) { Matrix_RotateXS(-this->upperBodyRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->upperBodyRot.x, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + if ((limbIndex == ZORA_LIMB_TORSO) || (limbIndex == ZORA_LIMB_LEFT_UPPER_ARM) || + (limbIndex == ZORA_LIMB_RIGHT_UPPER_ARM)) { rot->y += (s16)(Math_SinS(this->limbRotY[limbIndex]) * 200.0f); rot->z += (s16)(Math_CosS(this->limbRotZ[limbIndex]) * 200.0f); } @@ -318,13 +319,13 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (sBodyParts[limbIndex] >= 0) { Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } - if (limbIndex == 4) { + if (limbIndex == ZORA_LIMB_LEFT_FOOT) { Matrix_MultVec3f(&zeroVec, &this->leftFootPos); } - if (limbIndex == 7) { + if (limbIndex == ZORA_LIMB_RIGHT_FOOT) { Matrix_MultVec3f(&zeroVec, &this->rightFootPos); } } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index b5faef776..adf8b6bae 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -2,6 +2,7 @@ #define Z_EN_ZO_H #include "global.h" +#include "objects/object_zo/object_zo.h" struct EnZo; @@ -22,8 +23,8 @@ typedef struct EnZo { /* 0x01F0 */ Vec3f rightFootPos; /* 0x01FC */ u8 isLeftFootGrounded; /* 0x01FD */ u8 isRightFootGrounded; - /* 0x01FE */ Vec3s jointTable[20]; - /* 0x0276 */ Vec3s morphTable[20]; + /* 0x01FE */ Vec3s jointTable[ZORA_LIMB_MAX]; + /* 0x0276 */ Vec3s morphTable[ZORA_LIMB_MAX]; /* 0x02EE */ Vec3s turnTarget; /* 0x02F4 */ Vec3s headRot; /* 0x02FA */ Vec3s upperBodyRot; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 1cf8ad992..69deb43d6 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -87,7 +87,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); - Animation_PlayLoop(&this->skelAnime, &object_zo_Anim_00DE20); + Animation_PlayLoop(&this->skelAnime, &gZoraStandAnim); this->unk_2F0 = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -235,9 +235,9 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2) { static AnimationHeader* sAnimations[] = { - &object_zo_Anim_00DE20, &gZoraWalkAnim, &object_zo_Anim_00F4E8, &object_zo_Anim_00E400, - &object_zo_Anim_00FDF0, &object_zo_Anim_010B18, &object_zo_Anim_011424, &object_zo_Anim_00EDF0, - &object_zo_Anim_00DF54, &object_zo_Anim_00DF54, + &gZoraStandAnim, &gZoraWalkAnim, &gZoraSitAnim, &gZoraRunAnim, + &gZoraFixSpeakerStartAnim, &gZoraFixSpeakerLoopAnim, &gZoraFixSpeakerEndAnim, &gZoraBobHandAnim, + &gZoraListenAnim, &gZoraListenAnim, }; if ((arg1 >= 0) && (arg1 < 10)) { diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 2f1b4a1a4..c0751b078 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -188,7 +188,7 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { if (ptr->unk_00 == 1) { if (!flag) { gDPPipeSync(POLY_XLU_DISP++); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D220); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); if (1) {} flag = true; @@ -201,7 +201,7 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D288); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleModelDL); } } @@ -219,7 +219,7 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 3) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_0029F0); + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); @@ -233,7 +233,7 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002A50); + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleModelDL); } } @@ -251,7 +251,7 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002BA0); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); if (1) {} @@ -266,7 +266,7 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002C10); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashModelDL); } } @@ -333,7 +333,7 @@ void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -static AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; +static AnimationHeader* sAnimations[] = { &gZoraTreadingWaterAnim, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { if ((arg1 >= 0) && (arg1 < 3)) { diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 2f976f2cc..e81799873 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -721,7 +721,7 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } From af0123de1eb774aebb88b26e5d719b3406f51eb9 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 19 Jun 2022 03:38:10 +0100 Subject: [PATCH 29/53] `z_fcurve_data` OK, match last function in `z_fcurve_data_skelanime`, document SkelCurve system (#776) * Match SkelCurve_Update Co-authored-by: Kelebek1 <34639600+Kelebek1@users.noreply.github.com> * Match and document z_fcurve_data * Begin documenting SkelCurve * More documentation * Deformat header * Pluralise knotCount * Sort out jointTable * Rename frameCount * Format * More documentation * Cleanup on DemoEffect * Remove space on typedef * Format, couple of fixes in the header * Review * Oops * Fix EnBox, DemoTreLgt, use macros in EnTorch Co-authored-by: Kelebek1 <34639600+Kelebek1@users.noreply.github.com> --- include/functions.h | 8 - include/os_internal.h | 2 +- include/z64.h | 1 + include/z64animation.h | 50 ---- include/z64curve.h | 68 +++++ include/z64item.h | 6 +- include/z64math.h | 18 +- src/code/z_fcurve_data.c | 85 ++++++- src/code/z_fcurve_data_skelanime.c | 239 +++++++++++------- src/code/z_skelanime.c | 4 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 18 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 197 ++++++++------- .../actors/ovl_Demo_Effect/z_demo_effect.h | 31 ++- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 13 +- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h | 8 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 57 +++-- src/overlays/actors/ovl_En_Box/z_en_box.h | 11 +- src/overlays/actors/ovl_En_Torch/z_en_torch.c | 7 +- tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 5 +- 20 files changed, 505 insertions(+), 327 deletions(-) create mode 100644 include/z64curve.h diff --git a/include/functions.h b/include/functions.h index b60aa04fa..b802ee28a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1454,14 +1454,6 @@ s16 ActorCutscene_GetCurrentCamera(s16 index); s16 func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); -// void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -f32 func_800F2478(f32 target, TransformData* transData, s32 refIdx); -void SkelCurve_Clear(SkelAnimeCurve* skelCurve); -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx); -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire); void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor); diff --git a/include/os_internal.h b/include/os_internal.h index 3c6d4eee4..b4f98bffa 100644 --- a/include/os_internal.h +++ b/include/os_internal.h @@ -1,7 +1,7 @@ #ifndef _OS_INTERNAL_H_ #define _OS_INTERNAL_H_ -typedef struct { +typedef struct { /* 0x00 */ OSMesgQueue* queue; /* 0x04 */ OSMesg msg; } __osHwInt; // size = 0x08 diff --git a/include/z64.h b/include/z64.h index a0119f2f8..6331a456a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -30,6 +30,7 @@ #include "z64audio.h" #include "z64bgcheck.h" #include "z64collision_check.h" +#include "z64curve.h" #include "z64cutscene.h" #include "z64dma.h" #include "z64effect.h" diff --git a/include/z64animation.h b/include/z64animation.h index 58ddb34df..ced59e457 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -224,56 +224,6 @@ typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData extern u32 link_animetion_segment; -// fcurve_skelanime structs -typedef struct { - /* 0x0000 */ u16 unk00; // appears to be flags - /* 0x0002 */ s16 unk02; - /* 0x0004 */ s16 unk04; - /* 0x0006 */ s16 unk06; - /* 0x0008 */ f32 unk08; -} TransformData; // size = 0xC - -typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk0C; - /* 0x000E */ s16 unk10; -} TransformUpdateIndex; // size 0x10 - -typedef struct { - /* 0x0000 */ u8 firstChildIdx; - /* 0x0001 */ u8 nextLimbIdx; - /* 0x0004 */ Gfx* dList[2]; -} SkelCurveLimb; // size >= 0x8 - -typedef struct { - /* 0x0000 */ SkelCurveLimb** limbs; - /* 0x0004 */ u8 limbCount; -} SkelCurveLimbList; // size = 0x8 - -typedef struct { - /* 0x0000 */ Vec3s scale; - /* 0x0006 */ Vec3s rot; - /* 0x000C */ Vec3s pos; -} LimbTransform; // size = 0x12 - -typedef struct { - /* 0x0000 */ u8 limbCount; - /* 0x0004 */ SkelCurveLimb** limbList; - /* 0x0008 */ TransformUpdateIndex* transUpdIdx; - /* 0x000C */ f32 unk0C; // seems to be unused - /* 0x0010 */ f32 animFinalFrame; - /* 0x0014 */ f32 animSpeed; - /* 0x0018 */ f32 animCurFrame; - /* 0x001C */ LimbTransform* transforms; -} SkelAnimeCurve; // size = 0x20 - -typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, - struct Actor* actor); -typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, - struct Actor* actor); - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; diff --git a/include/z64curve.h b/include/z64curve.h new file mode 100644 index 000000000..2e6e539ba --- /dev/null +++ b/include/z64curve.h @@ -0,0 +1,68 @@ +#ifndef Z64_CURVE_H +#define Z64_CURVE_H + +#include "PR/ultratypes.h" +#include "z64math.h" + +struct GlobalContext; + +typedef struct { + /* 0x0 */ u16 flags; // Only the bottom two bits are used, although others are set in objects + /* 0x2 */ s16 abscissa; // knot input value + /* 0x4 */ s16 leftGradient; // left derivative at the point + /* 0x6 */ s16 rightGradient; // right derivative at the point + /* 0x8 */ f32 ordinate; // output value +} CurveInterpKnot; // size = 0xC + +typedef struct { + /* 0x0 */ u8* knotCounts; + /* 0x4 */ CurveInterpKnot* interpolationData; + /* 0x8 */ s16* constantData; + /* 0xC */ s16 unk_0C; // Set but not used, always 1 in objects + /* 0xE */ s16 frameCount; // Not used, inferred from use in objects +} CurveAnimationHeader; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 child; + /* 0x1 */ u8 sibling; + /* 0x4 */ Gfx* dList[2]; +} SkelCurveLimb; // size = 0xC + +typedef struct { + /* 0x0 */ SkelCurveLimb** limbs; + /* 0x4 */ u8 limbCount; +} CurveSkeletonHeader; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x04 */ SkelCurveLimb** skeleton; + /* 0x08 */ CurveAnimationHeader* animation; + /* 0x0C */ f32 unk_0C; // set but not used + /* 0x10 */ f32 endFrame; + /* 0x14 */ f32 playSpeed; + /* 0x18 */ f32 curFrame; + /* 0x1C */ s16 (*jointTable)[9]; +} SkelCurve; // size = 0x20 + +typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); +typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); + + + +f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount); + +void SkelCurve_Clear(SkelCurve* skelCurve); +s32 SkelCurve_Init(struct GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation); +void SkelCurve_Destroy(struct GlobalContext* globalCtx, SkelCurve* skelCurve); +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, f32 playSpeed); +s32 SkelCurve_Update(struct GlobalContext* globalCtx, SkelCurve* skelCurve); +void SkelCurve_Draw(Actor* actor, struct GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); + + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef CurveInterpKnot TransformData; +typedef CurveAnimationHeader TransformUpdateIndex; +typedef CurveSkeletonHeader SkelCurveLimbList; + +#endif // Z64_CURVE_H diff --git a/include/z64item.h b/include/z64item.h index 2281ded92..81fdbe066 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -280,7 +280,9 @@ typedef enum { /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, /* 0x11 */ GI_STRAY_FAIRY = 0x11, - /* 0x16 */ GI_BOMBS_10 = 0x16, + /* 0x14 */ GI_BOMBS_1 = 0x14, + /* 0x15 */ GI_BOMBS_5, + /* 0x16 */ GI_BOMBS_10, /* 0x19 */ GI_STICKS_1 = 0x19, /* 0x1A */ GI_BOMBCHUS_10, /* 0x1B */ GI_BOMB_BAG_20, @@ -298,6 +300,8 @@ typedef enum { /* 0x32 */ GI_SHIELD_HERO = 0x32, /* 0x33 */ GI_SHIELD_MIRROR, /* 0x35 */ GI_MAGIC_BEANS = 0x35, + /* 0x36 */ GI_BOMBCHUS_1, + /* 0x3A */ GI_BOMBCHUS_5 = 0x3A, /* 0x3C */ GI_KEY_SMALL = 0x3C, /* 0x3D */ GI_KEY_BOSS, /* 0x3E */ GI_MAP, diff --git a/include/z64math.h b/include/z64math.h index 33f05bb0a..0095e12ab 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -109,17 +109,19 @@ typedef struct { #define IS_ZERO(f) (fabsf(f) < 0.008f) -// Trig macros -#define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f) -#define RADF_TO_BINANG(radf) (s16)(radf * (0x8000 / M_PI)) -#define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI)) -#define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f)) +// Angle conversion macros +#define DEG_TO_BINANG(degrees) (s16)((degrees) * (0x8000 / 180.0f)) +#define DEGF_TO_BINANG(degreesf) (s16)((degreesf) * 182.04167f + .5f) +#define RADF_TO_BINANG(radf) (s16)((radf) * (0x8000 / M_PI)) +#define RADF_TO_DEGF(radf) ((radf) * (180.0f / M_PI)) +#define DEGF_TO_RADF(degf) ((degf) * (M_PI / 180.0f)) +#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) +#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) + +// Angle arithmetic macros #define BINANG_ROT180(angle) ((s16)(angle + 0x8000)) #define BINANG_SUB(a, b) ((s16)(a - b)) #define BINANG_ADD(a, b) ((s16)(a + b)) -#define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) -#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) // Vector macros #define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z)) diff --git a/src/code/z_fcurve_data.c b/src/code/z_fcurve_data.c index a0bf887e1..5c0aa066a 100644 --- a/src/code/z_fcurve_data.c +++ b/src/code/z_fcurve_data.c @@ -1,5 +1,86 @@ +/** + * @file z_fcurve_data.c + * @brief Interpolation functions for use with Curve SkelAnime + */ #include "global.h" +#include "z64curve.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F23E0.s") +#define FCURVE_INTERP_CUBIC 0 // Interpolate using a Hermite cubic spline +#define FCURVE_INTERP_NONE 1 // Return the value at the left endpoint instead of interpolating +#define FCURVE_INTERP_LINEAR 2 // Interpolate linearly -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F2478.s") +/** + * Hermite cubic spline interpolation between two endpoints, a,b. More information available at + * https://en.wikipedia.org/wiki/Cubic_Hermite_spline + * + * @param t interpolation parameter rescaled to lie in [0,1], (x-a)/(b-a) + * @param interval distance (b-a) between the endpoints + * @param y0 p(a) + * @param y1 p(b) + * @param m0 p'(a) + * @param m1 p'(b) + * @return f32 p(t), value of the cubic interpolating polynomial + */ +f32 Curve_CubicHermiteSpline(f32 t, f32 interval, f32 y0, f32 y1, f32 m0, f32 m1) { + f32 t2 = t * t; + f32 t3 = t2 * t; + f32 t3x2 = t3 * 2.0f; + f32 t2x3 = t2 * 3.0f; + + // Hermite basis cubics h_{ij} satisfy h_{ij}^{(j)}(i) = 1, the other three values being 0 + f32 h00 = t3x2 - t2x3 + 1.0f; // h_{00}(t) = 2t^3 - 3t^2 + 1 + f32 h01 = t2x3 - t3x2; // h_{01}(t) = 3t^2 - 2t^3 + f32 h10 = t3 - t2 * 2.0f + t; // h_{10}(t) = t^3 - 2t^2 + t + f32 h11 = t3 - t2; // h_{11}(t) = t^3 - t^2 + + f32 ret = h00 * y0; + + ret += h01 * y1; + ret += h10 * m0 * interval; + ret += h11 * m1 * interval; + + return ret; +} + +/** + * Interpolates based on an array of CurveInterpKnot. + * + * @param x point at which to interpolate. + * @param knots Beginning of CurveInterpKnot array to use. + * @param knotCount number of knots to read from the array. + * @return f32 interpolated value + */ +f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount) { + // If outside the entire interpolation interval, return the value at the near endpoint. + if (x <= knots[0].abscissa) { + return knots[0].ordinate; + } else if (x >= knots[knotCount - 1].abscissa) { + return knots[knotCount - 1].ordinate; + } else { + s32 cur; + + for (cur = 0;; cur++) { + s32 next = cur + 1; + + // Find the subinterval in which x lies + if (x < knots[next].abscissa) { + if (knots[cur].flags & FCURVE_INTERP_NONE) { + // No interpolation + return knots[cur].ordinate; + } else if (knots[cur].flags & FCURVE_INTERP_LINEAR) { + // Linear interpolation + return knots[cur].ordinate + + ((x - (f32)knots[cur].abscissa) / ((f32)knots[next].abscissa - (f32)knots[cur].abscissa)) * + (knots[next].ordinate - knots[cur].ordinate); + } else { + // Cubic interpolation + f32 diff = (f32)knots[next].abscissa - (f32)knots[cur].abscissa; + f32 t = (x - (f32)knots[cur].abscissa) / ((f32)knots[next].abscissa - (f32)knots[cur].abscissa); + + return Curve_CubicHermiteSpline(t, diff * (1.0f / 30.0f), knots[cur].ordinate, knots[next].ordinate, + knots[cur].rightGradient, knots[next].leftGradient); + } + } + } + } +} diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index c8eb927fa..b40a1c351 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -1,130 +1,187 @@ +/** + * @file z_fcurve_data_skelanime.c + * @brief Curve skeleton animation system + * + * A curve skeleton has a fixed number of limbs, each of which has 9 properties that may be changed by the animation: + * - 3 scales, + * - 3 rotations, + * - 3 positions + * (note the position is stored in the animations instead of being stored in the limbs like SkelAnime would). Otherwise + * the structure is similar to an ordinary SkelAnime-compatible skeleton. + * + * The animations are significantly more complex than SkelAnime. A curve animation consists of 4 parts: + * - a header (CurveAnimationHeader) + * - a list of counts, one for each of the 9 properties of each limb (u8) + * - a list of interpolation data (CurveInterpKnot). The length is the sum of the counts. + * - a list of constant data (s16[9]). The length is the number of 0s in counts. + * + * If the interpolation count for a property is 0, the value of the property is copied from the next number in the + * constant data; there are no gaps for nonzero interpolation count. + * If the interpolation count N for a property is larger than 0, the next N elements of the interpolation data array + * are used to interpolate the value of the property, using Curve_Interpolate. + * + * Curve limbs may use LOD: + * - lower detail draws only the first displaylist + * - higher detail draws both. + */ + #include "global.h" +#include "z64curve.h" -void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { +void SkelCurve_Clear(SkelCurve* skelCurve) { skelCurve->limbCount = 0; - skelCurve->limbList = NULL; - skelCurve->transUpdIdx = NULL; - skelCurve->animCurFrame = 0.0f; - skelCurve->animSpeed = 0.0f; - skelCurve->animFinalFrame = 0.0f; - skelCurve->unk0C = 0.0f; - skelCurve->transforms = NULL; + skelCurve->skeleton = NULL; + skelCurve->animation = NULL; + skelCurve->curFrame = 0.0f; + skelCurve->playSpeed = 0.0f; + skelCurve->endFrame = 0.0f; + skelCurve->unk_0C = 0.0f; + skelCurve->jointTable = NULL; } -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, - TransformUpdateIndex* transUpdIdx) { +/** + * Initialises the SkelCurve struct and mallocs the joint table. + * + * @return bool always true + */ +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, + CurveAnimationHeader* animation) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = Lib_SegmentedToVirtual(limbListSeg); + CurveSkeletonHeader* skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); - skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = Lib_SegmentedToVirtual(limbList->limbs); + skelCurve->limbCount = skeletonHeader->limbCount; + skelCurve->skeleton = Lib_SegmentedToVirtual(skeletonHeader->limbs); - skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount); + skelCurve->jointTable = ZeldaArena_Malloc(sizeof(*skelCurve->jointTable) * skelCurve->limbCount); - do { - skelCurve->animCurFrame = 0.0f; - } while (0); - return 1; + skelCurve->curFrame = 0.0f; + return true; } -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { - if (skelCurve->transforms != NULL) { - ZeldaArena_Free(skelCurve->transforms); +/** + * Frees the joint table. + */ +void SkelCurve_Destroy(GlobalContext* globalCtx, SkelCurve* skelCurve) { + if (skelCurve->jointTable != NULL) { + ZeldaArena_Free(skelCurve->jointTable); } } -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, - f32 animCurFrame, f32 animSpeed) { - skelCurve->unk0C = arg2 - skelCurve->animSpeed; - skelCurve->animFinalFrame = animFinalFrame; - skelCurve->animCurFrame = animCurFrame; - skelCurve->animSpeed = animSpeed; - skelCurve->transUpdIdx = transUpdIdx; +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, + f32 playSpeed) { + skelCurve->unk_0C = arg2 - skelCurve->playSpeed; + skelCurve->endFrame = endFrame; + skelCurve->curFrame = curFrame; + skelCurve->playSpeed = playSpeed; + skelCurve->animation = animation; } -#ifdef NON_MATCHING -/* Should be functionally equivalent, also migrating rodata makes it a lot cleaner */ -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { - s16* transforms; - u8* transformRefIdx; - TransformUpdateIndex* transformIndex; - u16* transformCopyValues; - s32 i; - s32 ret = 0; - s32 k; - TransformData* transData; - f32 transformValue; - s32 j; +typedef enum { + /* 0 */ SKELCURVE_VEC_TYPE_SCALE, + /* 1 */ SKELCURVE_VEC_TYPE_ROTATION, + /* 2 */ SKELCURVE_VEC_TYPE_POSIITON, + /* 3 */ SKELCURVE_VEC_TYPE_MAX +} SkelCurveVecType; - transformIndex = Lib_SegmentedToVirtual(skelCurve->transUpdIdx); - transformRefIdx = Lib_SegmentedToVirtual(transformIndex->refIndex); - transData = Lib_SegmentedToVirtual(transformIndex->transformData); - transformCopyValues = Lib_SegmentedToVirtual(transformIndex->copyValues); - transforms = (s16*)skelCurve->transforms; +#define SKELCURVE_SCALE_SCALE 1024.0f +#define SKELCURVE_SCALE_POSITION 100 - skelCurve->animCurFrame += skelCurve->animSpeed * (globalCtx->state.framerateDivisor * 0.5f); +/** + * The only animation updating function. + * + * @return bool true when the animation has finished. + */ +s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) { + s16* jointData; + u8* knotCounts; + CurveAnimationHeader* animation; + u16* constantData; + s32 curLimb; + s32 ret = false; + s32 coord; + CurveInterpKnot* startKnot; + s32 vecType; - if ((skelCurve->animSpeed >= 0.0f && skelCurve->animCurFrame > skelCurve->animFinalFrame) || - (skelCurve->animSpeed < 0.0f && skelCurve->animCurFrame < skelCurve->animFinalFrame)) { - skelCurve->animCurFrame = skelCurve->animFinalFrame; - ret = 1; + animation = Lib_SegmentedToVirtual(skelCurve->animation); + knotCounts = Lib_SegmentedToVirtual(animation->knotCounts); + startKnot = Lib_SegmentedToVirtual(animation->interpolationData); + constantData = Lib_SegmentedToVirtual(animation->constantData); + jointData = *skelCurve->jointTable; + + skelCurve->curFrame += skelCurve->playSpeed * ((s32)globalCtx->state.framerateDivisor * 0.5f); + + if (((skelCurve->playSpeed >= 0.0f) && (skelCurve->curFrame > skelCurve->endFrame)) || + ((skelCurve->playSpeed < 0.0f) && (skelCurve->curFrame < skelCurve->endFrame))) { + skelCurve->curFrame = skelCurve->endFrame; + ret = true; } - for (i = 0; i < skelCurve->limbCount; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++, transformRefIdx++, transforms++) { - if (*transformRefIdx == 0) { - transformValue = *transformCopyValues; - *transforms = transformValue; - transformCopyValues++; + for (curLimb = 0; curLimb < skelCurve->limbCount; curLimb++) { + + // scale/rotation/position + for (vecType = SKELCURVE_VEC_TYPE_SCALE; vecType < SKELCURVE_VEC_TYPE_MAX; vecType++) { + + // x/y/z + for (coord = 0; coord < 3; coord++) { + f32 transformValue; + + if (*knotCounts == 0) { + transformValue = *constantData; + *jointData = transformValue; + constantData++; } else { - transformValue = func_800F2478(skelCurve->animCurFrame, transData, *transformRefIdx); - transData += *transformRefIdx; - if (j == 0) { - *transforms = transformValue * 1024.0f; - } else if (j == 1) { - *transforms = transformValue * (32768.0f / 180.0f); - } else { - *transforms = transformValue * 100.0f; + transformValue = Curve_Interpolate(skelCurve->curFrame, startKnot, *knotCounts); + startKnot += *knotCounts; + if (vecType == SKELCURVE_VEC_TYPE_SCALE) { + // Rescaling allows for more refined scaling using an s16 + *jointData = transformValue * SKELCURVE_SCALE_SCALE; + } else if (vecType == SKELCURVE_VEC_TYPE_ROTATION) { + // Convert value from degrees to a binary angle + *jointData = DEG_TO_BINANG(transformValue); + } else { // SKELCURVE_VEC_TYPE_POSIITON + // Model to world scale conversion + *jointData = transformValue * SKELCURVE_SCALE_POSITION; } } + knotCounts++; + jointData++; } } } return ret; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/SkelCurve_Update.s") -#endif -void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, +/** + * Recursively draws limbs with appropriate properties. + */ +void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); + SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->skeleton[limbIndex]); OPEN_DISPS(globalCtx->state.gfxCtx); Matrix_Push(); - if (overrideLimbDraw == NULL || - (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { + if ((overrideLimbDraw == NULL) || + ((overrideLimbDraw != NULL) && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { Vec3f scale; Vec3s rot; Vec3f pos; Gfx* dList; - Vec3s* transform = (Vec3s*)&skelCurve->transforms[limbIndex]; + s16* jointData = skelCurve->jointTable[limbIndex]; - scale.x = transform->x / 1024.0f; - scale.y = transform->y / 1024.0f; - scale.z = transform->z / 1024.0f; - transform++; - rot.x = transform->x; - rot.y = transform->y; - rot.z = transform->z; - transform++; - pos.x = transform->x; - pos.y = transform->y; - pos.z = transform->z; + scale.x = jointData[0] / SKELCURVE_SCALE_SCALE; + scale.y = jointData[1] / SKELCURVE_SCALE_SCALE; + scale.z = jointData[2] / SKELCURVE_SCALE_SCALE; + jointData += 3; + rot.x = jointData[0]; + rot.y = jointData[1]; + rot.z = jointData[2]; + jointData += 3; + pos.x = jointData[0]; + pos.y = jointData[1]; + pos.z = jointData[2]; Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); @@ -160,22 +217,22 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* postLimbDraw(globalCtx, skelCurve, limbIndex, thisx); } - if (limb->firstChildIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + if (limb->child != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } Matrix_Pop(); - if (limb->nextLimbIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + if (limb->sibling != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - if (skelCurve->transforms != NULL) { + if (skelCurve->jointTable != NULL) { SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 0a3334bc8..4c77b3669 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -627,9 +627,7 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount for (i = 0; i < limbCount; i++) { // Debug prints here, this is needed to prevent loop unrolling - if (0) { - if (0) {}; - } + if ((frameTable == NULL) || (jointIndices == NULL) || (dynamicData == NULL)) {} frameTable->x = jointIndices->x >= staticIndexMax ? dynamicData[jointIndices->x] : frameData[jointIndices->x]; frameTable->y = jointIndices->y >= staticIndexMax ? dynamicData[jointIndices->y] : frameData[jointIndices->y]; frameTable->z = jointIndices->z >= staticIndexMax ? dynamicData[jointIndices->z] : frameData[jointIndices->z]; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 12d59b530..bad5f7383 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -32,15 +32,15 @@ void func_809DD2F8(GlobalContext* globalCtx); void func_809DD934(Boss02* this, GlobalContext* globalCtx); void func_809DEAC4(Boss02* this, GlobalContext* globalCtx); -static u8 D_809E0420; -static u8 D_809E0421; -static u8 D_809E0422; -static Boss02* D_809E0424; -static Boss02* D_809E0428; -static Boss02* D_809E042C; -static u8 D_809E0430; -static DoorWarp1* D_809E0434; -static Boss02Effects D_809E0438[150]; +u8 D_809E0420; +u8 D_809E0421; +u8 D_809E0422; +Boss02* D_809E0424; +Boss02* D_809E0428; +Boss02* D_809E042C; +u8 D_809E0430; +DoorWarp1* D_809E0434; +Boss02Effects D_809E0438[150]; static DamageTable sDamageTable1 = { /* Deku Nut */ DMG_ENTRY(0, 0x0), diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 48ef3cd3d..01e8852fc 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -38,59 +38,64 @@ const ActorInit Demo_Effect_InitVars = { }; void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { - static s16 D_808CE2C0[] = { + static s16 sEffectTypeObjects[] = { OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, }; s32 pad; DemoEffect* this = THIS; - s32 sp3C = DEMOEFFECT_GET_FF(&this->actor); - s32 phi_v1; + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + s32 objectIndex; s32 pad2; - Color_RGB8 sp24[] = { + Color_RGB8 colors[] = { { 200, 200, 0 }, { 255, 40, 100 }, { 50, 255, 0 }, { 0, 0, 255 }, { 255, 255, 80 }, }; - if (D_808CE2C0[sp3C] == 1) { - phi_v1 = 0; + if (sEffectTypeObjects[type] == GAMEPLAY_KEEP) { + objectIndex = 0; } else { - phi_v1 = Object_GetIndex(&globalCtx->objectCtx, D_808CE2C0[sp3C]); + objectIndex = Object_GetIndex(&globalCtx->objectCtx, sEffectTypeObjects[type]); } - if (phi_v1 >= 0) { - this->unk_164 = phi_v1; + if (objectIndex < 0) { + // assert on debug + } else { + this->initObjectIndex = objectIndex; } Actor_SetScale(&this->actor, 0.2f); - switch (sp3C) { - case 0: - case 1: + switch (type) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: this->actor.flags |= ACTOR_FLAG_2000000; - case 2: - case 3: - this->unk_174 = func_808CDFF8; - this->unk_170 = func_808CD998; - this->unk_168[0] = 0; - this->unk_168[1] = 100; - this->unk_168[2] = 255; + case DEMO_EFFECT_TYPE_2: + case DEMO_EFFECT_TYPE_3: + this->initDrawFunc = func_808CDFF8; + this->initActionFunc = func_808CD998; + this->envXluColor[0] = 0; + this->envXluColor[1] = 100; + this->envXluColor[2] = 255; SkelCurve_Clear(&this->skelCurve); - this->unk_16C = 0; + this->timer = 0; break; - case 4: - case 5: - case 6: - case 7: - case 8: - this->unk_168[0] = sp24[sp3C - 4].r; - this->unk_168[1] = sp24[sp3C - 4].g; - this->unk_168[2] = sp24[sp3C - 4].b; + case DEMO_EFFECT_TYPE_4: + case DEMO_EFFECT_TYPE_5: + case DEMO_EFFECT_TYPE_6: + case DEMO_EFFECT_TYPE_7: + case DEMO_EFFECT_TYPE_8: + this->envXluColor[0] = colors[type - 4].r; + this->envXluColor[1] = colors[type - 4].g; + this->envXluColor[2] = colors[type - 4].b; Actor_SetScale(&this->actor, 0.0f); - this->unk_174 = func_808CE078; - this->unk_170 = func_808CDDE0; - this->unk_16C = 0; + this->initDrawFunc = func_808CE078; + this->initActionFunc = func_808CDDE0; + this->timer = 0; + break; + + default: break; } @@ -98,33 +103,32 @@ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808CD940; } -u8 D_808CE2D4[] = { - 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0, -}; - void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { DemoEffect* this = THIS; - switch (DEMOEFFECT_GET_FF(&this->actor)) { - case 0: - case 1: - case 2: - case 3: + switch (DEMO_EFFECT_GET_TYPE(&this->actor)) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: + case DEMO_EFFECT_TYPE_2: + case DEMO_EFFECT_TYPE_3: SkelCurve_Destroy(globalCtx, &this->skelCurve); break; + + default: + break; } } void func_808CD940(DemoEffect* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_164)) { - this->actor.objBankIndex = this->unk_164; - this->actor.draw = this->unk_174; - this->actionFunc = this->unk_170; + if (Object_IsLoaded(&globalCtx->objectCtx, this->initObjectIndex)) { + this->actor.objBankIndex = this->initObjectIndex; + this->actor.draw = this->initDrawFunc; + this->actionFunc = this->initActionFunc; } } void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { - s32 sp34 = DEMOEFFECT_GET_FF(&this->actor); + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); if (SkelCurve_Init(globalCtx, &this->skelCurve, &object_efc_tw_Skel_0012E8, &object_efc_tw_CurveAnim_000050)) {} @@ -132,20 +136,20 @@ void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { SkelCurve_Update(globalCtx, &this->skelCurve); this->actionFunc = func_808CDCEC; - switch (sp34) { - case 0: + switch (type) { + case DEMO_EFFECT_TYPE_0: Actor_SetScale(&this->actor, 0.16800001f); break; - case 1: + case DEMO_EFFECT_TYPE_1: Actor_SetScale(&this->actor, 0.08400001f); break; - case 2: + case DEMO_EFFECT_TYPE_2: Actor_SetScale(&this->actor, 0.16800001f); break; - case 3: + case DEMO_EFFECT_TYPE_3: Actor_SetScale(&this->actor, 0.28f); break; @@ -155,53 +159,57 @@ void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { } } -void func_808CDAD0(f32 arg0) { +void func_808CDAD0(f32 alphaScale) { + static u8 sAlphaTypes[] = { 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0 }; + Vtx* vtx = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); s32 i; - Vtx* temp_v0 = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); - u8 sp24[3]; + u8 alphas[3]; - sp24[0] = 0; - sp24[1] = (s8)(202.0f * arg0); - sp24[2] = (s8)(255.0f * arg0); + alphas[0] = 0; + alphas[1] = (s32)(202.0f * alphaScale); + alphas[2] = (s32)(255.0f * alphaScale); - for (i = 0; i < ARRAY_COUNT(D_808CE2D4); i++) { - if (D_808CE2D4[i] != 0) { - temp_v0[i].v.cn[3] = sp24[D_808CE2D4[i]]; + for (i = 0; i < ARRAY_COUNT(sAlphaTypes); i++) { + if (sAlphaTypes[i] != 0) { + vtx[i].v.cn[3] = alphas[sAlphaTypes[i]]; } } } void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx) { - s32 params = DEMOEFFECT_GET_FF(&this->actor); - f32 temp_f0; - f32 temp_f12; + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + f32 scale; + f32 alphaScale; - this->unk_16C++; - if (this->unk_16C <= 100) { - temp_f12 = (100 - this->unk_16C) * 0.01f; - temp_f0 = temp_f12 * 0.14f; + this->timer++; + if (this->timer <= 100) { + alphaScale = (100 - this->timer) * 0.01f; + scale = alphaScale * 0.14f; - switch (params) { - case 0: - temp_f0 *= 1.2f; + switch (type) { + case DEMO_EFFECT_TYPE_0: + scale *= 1.2f; break; - case 1: - temp_f0 *= 0.6f; + case DEMO_EFFECT_TYPE_1: + scale *= 0.6f; break; - case 2: - temp_f0 *= 1.2f; + case DEMO_EFFECT_TYPE_2: + scale *= 1.2f; break; - case 3: - temp_f0 *= 2.0f; + case DEMO_EFFECT_TYPE_3: + scale *= 2.0f; + break; + + default: break; } - this->actor.scale.x = temp_f0; - this->actor.scale.z = temp_f0; - func_808CDAD0(temp_f12); + this->actor.scale.x = scale; + this->actor.scale.z = scale; + func_808CDAD0(alphaScale); func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); } else { func_808CDAD0(1.0f); @@ -215,14 +223,14 @@ void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx) { if (SkelCurve_Update(globalCtx, &this->skelCurve)) { SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 60.0f, 59.0f, 0.0f); this->actionFunc = func_808CDBDC; - this->unk_16C = 0; + this->timer = 0; } } void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->actor.scale.x - 0.02f); - this->unk_16C++; + this->timer++; if (this->actor.scale.x < 0.02f) { Actor_MarkForDeath(&this->actor); } @@ -231,8 +239,8 @@ void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, (this->actor.scale.x * 0.5f) + 0.2f); - this->unk_16C++; - if (this->unk_16C >= 3) { + this->timer++; + if (this->timer >= 3) { this->actionFunc = func_808CDD70; } } @@ -243,29 +251,28 @@ void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } -s32 func_808CDE78(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { +s32 func_808CDE78(GlobalContext* globalCtx, SkelCurve* skelCurve, s32 limbIndex, Actor* thisx) { s32 pad; DemoEffect* this = THIS; - u32 sp4C = globalCtx->gameplayFrames; + u32 frames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (sp4C * 6) % 1024, 255 - ((sp4C * 16) % 256), 0x100, 0x40, - 1, (sp4C * 4) % 512, 127 - ((sp4C * 12) % 128), 0x80, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (frames * 6) % 1024, 255 - ((frames * 16) % 256), 0x100, + 0x40, 1, (frames * 4) % 512, 127 - ((frames * 12) % 128), 0x80, 0x20)); CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 0) { - LimbTransform* transform = skelCuve->transforms; + s16* transform = skelCurve->jointTable[0]; - transform->scale.x = 0x400; - transform->scale.y = 0x400; - transform->scale.z = transform->scale.x; + transform[2] = transform[0] = 1024; + transform[1] = 1024; } return true; @@ -288,24 +295,24 @@ void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; DemoEffect* this = THIS; - s16 sp46 = (this->unk_16C * 0x400) & 0xFFFF; + s16 zRot = (this->timer * 0x400) & 0xFFFF; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); Matrix_Push(); - Matrix_RotateZS(sp46, MTXMODE_APPLY); + Matrix_RotateZS(zRot, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); Matrix_Pop(); - Matrix_RotateZS(sp46 * -1, MTXMODE_APPLY); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h index 8216708c5..775bfcb0f 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -2,24 +2,35 @@ #define Z_DEMO_EFFECT_H #include "global.h" +#include "z64curve.h" struct DemoEffect; typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); -typedef void (*DemoEffectUnkFunc)(struct DemoEffect*, GlobalContext*); -typedef void (*DemoEffectUnkFunc2)(Actor*, GlobalContext*); -#define DEMOEFFECT_GET_FF(thisx) ((thisx)->params & 0xFF) +#define DEMO_EFFECT_GET_TYPE(thisx) ((thisx)->params & 0xFF) + +typedef enum { + /* 0 */ DEMO_EFFECT_TYPE_0, + /* 1 */ DEMO_EFFECT_TYPE_1, + /* 2 */ DEMO_EFFECT_TYPE_2, + /* 3 */ DEMO_EFFECT_TYPE_3, + /* 4 */ DEMO_EFFECT_TYPE_4, + /* 5 */ DEMO_EFFECT_TYPE_5, + /* 6 */ DEMO_EFFECT_TYPE_6, + /* 7 */ DEMO_EFFECT_TYPE_7, + /* 8 */ DEMO_EFFECT_TYPE_8 +} DemoEffectType; typedef struct DemoEffect { /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnimeCurve skelCurve; - /* 0x0164 */ u8 unk_164; - /* 0x0165 */ UNK_TYPE1 unk_165[3]; - /* 0x0168 */ u8 unk_168[3]; - /* 0x016C */ s16 unk_16C; - /* 0x0170 */ DemoEffectUnkFunc unk_170; - /* 0x0174 */ DemoEffectUnkFunc2 unk_174; + /* 0x0144 */ SkelCurve skelCurve; + /* 0x0164 */ u8 initObjectIndex; + /* 0x0165 */ u8 primXluColor[3]; + /* 0x0168 */ u8 envXluColor[3]; + /* 0x016C */ s16 timer; + /* 0x0170 */ DemoEffectActionFunc initActionFunc; + /* 0x0174 */ ActorFunc initDrawFunc; /* 0x0178 */ DemoEffectActionFunc actionFunc; } DemoEffect; // size = 0x17C diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 6d921c4c6..d76de38a3 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -52,6 +52,11 @@ static TransformUpdateIndex* sBoxLightAnimations[] = { &gBoxLightChildCurveAnim, }; +typedef enum { + /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed + /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE +} DemoTreLgtAction; + static DemoTreLgtActionFunc sActionFuncs[] = { DemoTreLgt_Wait, DemoTreLgt_Animate, @@ -101,7 +106,7 @@ void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 fra } void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx) { - f32 curFrame = this->skelCurve.animCurFrame; + f32 curFrame = this->skelCurve.curFrame; if (curFrame < D_808E1490[this->animationType].unk4) { this->colorAlpha1 = 255; @@ -136,7 +141,7 @@ void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { sActionFuncs[this->action](this, globalCtx); } -s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { +s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, Actor* thisx) { s32 pad; DemoTreLgt* this = THIS; @@ -148,8 +153,8 @@ s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCu if (limbIndex == OBJECT_BOX_LIGHT_LIMB_01) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha1); - } else if (limbIndex == OBJECT_BOX_LIGHT_LIMB_13 || limbIndex == OBJECT_BOX_LIGHT_LIMB_07 || - limbIndex == OBJECT_BOX_LIGHT_LIMB_04 || limbIndex == OBJECT_BOX_LIGHT_LIMB_10) { + } else if ((limbIndex == OBJECT_BOX_LIGHT_LIMB_13) || (limbIndex == OBJECT_BOX_LIGHT_LIMB_07) || + (limbIndex == OBJECT_BOX_LIGHT_LIMB_04) || (limbIndex == OBJECT_BOX_LIGHT_LIMB_10)) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha2); } diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h index 08677b803..27f6d09b1 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h @@ -2,6 +2,7 @@ #define Z_DEMO_TRE_LGT_H #include "global.h" +#include "z64curve.h" struct DemoTreLgt; @@ -9,7 +10,7 @@ typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt* this, GlobalContext* glo typedef struct DemoTreLgt { /* 0x000 */ Actor actor; - /* 0x144 */ SkelAnimeCurve skelCurve; + /* 0x144 */ SkelCurve skelCurve; /* 0x164 */ s32 action; /* 0x168 */ u32 colorAlpha1; /* 0x16C */ u32 colorAlpha2; @@ -17,11 +18,6 @@ typedef struct DemoTreLgt { /* 0x174 */ s32 animationType; } DemoTreLgt; // size = 0x178 -typedef enum { - /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed - /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE -} DemoTreLgtAction; - extern const ActorInit Demo_Tre_Lgt_InitVars; #endif // Z_DEMO_TRE_LGT_H diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 1259df33e..2b01b6e05 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -126,7 +126,7 @@ void func_80867C8C(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { for (i = 0; i < temp_s6; i++) { f32 temp_f0 = (f32)i / temp_s6; s16 temp_s0 = ((f32)arg0->unk_18 - arg0->unk_1C) * temp_f0 + arg0->unk_1C; - f32 temp_f24 = 1.0f - (temp_s0 * 0.011764706f); + f32 temp_f24 = 1.0f - (temp_s0 * (1 / 85.0f)); f32 temp_f26 = Rand_ZeroOne() * 0.03f * temp_f0 * temp_f24; f32 temp_f28; f32 temp_f30 = Math_SinS(temp_s0 * 0x9A6) * 45.0f + arg0->pos.x; @@ -186,9 +186,9 @@ void EnBox_ClipToGround(EnBox* this, GlobalContext* globalCtx) { } void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { - s16 cutsceneIdx; - EnBox* this = (EnBox*)thisx; s32 pad; + EnBox* this = THIS; + s16 cutsceneIdx; CollisionHeader* colHeader; f32 animFrame; f32 animFrameEnd; @@ -227,7 +227,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { EnBox_SetupAction(this, EnBox_Open); this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; animFrame = animFrameEnd; - } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL) && + } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL)) && !Flags_GetSwitch(globalCtx, this->switchFlag)) { func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); if (Rand_ZeroOne() < 0.5f) { @@ -238,7 +238,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0; this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= ACTOR_FLAG_10; - } else if ((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR || this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR) && + } else if (((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR) || (this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR)) && !Flags_GetClear(globalCtx, this->dyna.actor.room)) { EnBox_SetupAction(this, EnBox_AppearOnRoomClear); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); @@ -250,9 +250,9 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0; this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= ACTOR_FLAG_10; - } else if (this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY || this->type == ENBOX_TYPE_BIG_SONG_SUNS) { + } else if ((this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY) || (this->type == ENBOX_TYPE_BIG_SONG_SUNS)) { - } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) && + } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG)) && !Flags_GetSwitch(globalCtx, this->switchFlag)) { EnBox_SetupAction(this, EnBox_AppearSwitchFlag); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); @@ -265,7 +265,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= ACTOR_FLAG_10; } else { - if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { this->dyna.actor.flags |= ACTOR_FLAG_80; } EnBox_SetupAction(this, EnBox_WaitOpen); @@ -273,7 +273,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; } - if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + if ((this->getItem == GI_STRAY_FAIRY) && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { this->dyna.actor.flags |= ACTOR_FLAG_10; } @@ -307,7 +307,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; + EnBox* this = THIS; DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } @@ -414,7 +414,7 @@ void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { } void func_80868AFC(EnBox* this, GlobalContext* globalCtx) { - if (func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0 || this->unk_1A0 != 0) { + if ((func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0) || (this->unk_1A0 != 0)) { EnBox_SetupAction(this, func_80868B74); this->unk_1A0 = 0; func_80867FBC(&this->unk_1F4, globalCtx, (this->movementFlags & ENBOX_MOVE_0x80) != 0); @@ -433,7 +433,7 @@ void func_80868B74(EnBox* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y += 1.25f; } this->unk_1A0++; - if (this->cutsceneIdxA != -1 && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { + if ((this->cutsceneIdxA != -1) && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { if (this->unk_1A0 == 2) { func_800B724C(globalCtx, &this->dyna.actor, 4); } else if (this->unk_1A0 == 22) { @@ -461,8 +461,8 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { this->alpha = 255; this->movementFlags |= ENBOX_MOVE_IMMOBILE; - if (this->unk_1EC != 0 && (this->cutsceneIdxB < 0 || ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB || - ActorCutscene_GetCurrentIndex() == -1)) { + if ((this->unk_1EC != 0) && ((this->cutsceneIdxB < 0) || (ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB) || + (ActorCutscene_GetCurrentIndex() == -1))) { if (this->unk_1EC < 0) { animHeader = &gBoxChestOpenAnim; playbackSpeed = 1.5f; @@ -489,7 +489,7 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { if (this->getItem == GI_STRAY_FAIRY) { this->movementFlags |= ENBOX_MOVE_0x20; } else { - if (this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) { + if ((this->getItem == GI_HEART_PIECE) || (this->getItem == GI_BOTTLE)) { Flags_SetCollectible(globalCtx, this->collectableFlag); } Flags_SetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)); @@ -499,14 +499,14 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > -50.0f && offset.z < 0.0f && fabsf(offset.y) < 10.0f && fabsf(offset.x) < 20.0f && Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { - if ((this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) && + if (((this->getItem == GI_HEART_PIECE) || (this->getItem == GI_BOTTLE)) && Flags_GetCollectible(globalCtx, this->collectableFlag)) { this->getItem = GI_RECOVERY_HEART; } - if (this->getItem == GI_MASK_CAPTAIN && INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + if ((this->getItem == GI_MASK_CAPTAIN) && (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN)) { this->getItem = GI_RECOVERY_HEART; } - if (this->getItem == GI_MASK_GIANT && INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + if ((this->getItem == GI_MASK_GIANT) && (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT)) { this->getItem = GI_RECOVERY_HEART; } Actor_PickUpNearby(&this->dyna.actor, globalCtx, -this->getItem); @@ -568,7 +568,7 @@ void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { } if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &waterSurface, &waterBox, &bgId) && - this->dyna.actor.floorHeight < waterSurface) { + (this->dyna.actor.floorHeight < waterSurface)) { EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); } } @@ -598,13 +598,13 @@ void EnBox_SpawnIceSmoke(EnBox* this, GlobalContext* globalCtx) { } void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; + EnBox* this = THIS; if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; EnBox_ClipToGround(this, globalCtx); } - if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + if ((this->getItem == GI_STRAY_FAIRY) && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { globalCtx->actorCtx.unk5 |= 8; } this->actionFunc(this, globalCtx); @@ -616,8 +616,8 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); } Actor_SetFocus(&this->dyna.actor, 40.0f); - if (this->getItem == GI_ICE_TRAP && this->actionFunc == EnBox_Open && this->skelAnime.curFrame > 45.0f && - this->iceSmokeTimer < 100) { + if ((this->getItem == GI_ICE_TRAP) && (this->actionFunc == EnBox_Open) && (this->skelAnime.curFrame > 45.0f) && + (this->iceSmokeTimer < 100)) { EnBox_SpawnIceSmoke(this, globalCtx); } if (this->unk_1F4.unk_0C != NULL) { @@ -626,8 +626,8 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { - EnBox* this = THIS; s32 pad; + EnBox* this = THIS; if (limbIndex == OBJECT_BOX_CHEST_LIMB_01) { gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -688,16 +688,17 @@ Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { } void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; s32 pad; + EnBox* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); if (this->unk_1F4.unk_10 != NULL) { this->unk_1F4.unk_10(&this->unk_1F4, globalCtx); } - if ((this->alpha == 255 && this->type != ENBOX_TYPE_BIG_INVISIBLE && this->type != ENBOX_TYPE_SMALL_INVISIBLE) || + if (((this->alpha == 255) && (this->type != ENBOX_TYPE_BIG_INVISIBLE) && + (this->type != ENBOX_TYPE_SMALL_INVISIBLE)) || (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && - (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE))) { + ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)))) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_SetRenderMode1(globalCtx->state.gfxCtx)); @@ -708,7 +709,7 @@ void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode3(globalCtx->state.gfxCtx)); } else { gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode2(globalCtx->state.gfxCtx)); diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.h b/src/overlays/actors/ovl_En_Box/z_en_box.h index 02d9d95f9..6d7da31a5 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -36,6 +36,13 @@ typedef enum { /* 12 */ ENBOX_TYPE_SMALL_SWITCH_FLAG // small, appear on switch flag set } EnBoxType; +#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) +#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) +#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) +// Codegen in EnTorch_Init() requires leaving out the & 0x7F for `item` +#define ENBOX_PARAMS(type, item, chestFlag) ((((type) & 0xF) << 12) | ((item) << 5) | ((chestFlag) & 0x1F)) + typedef struct EnBox { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ SkelAnime skelAnime; @@ -61,9 +68,5 @@ typedef struct EnBox { extern const ActorInit En_Box_InitVars; -#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) -#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) -#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) -#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) #endif // Z_EN_BOX_H diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index fc06cff18..7ca536b6a 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -5,6 +5,7 @@ */ #include "z_en_torch.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" #define FLAGS 0x00000000 @@ -17,7 +18,9 @@ const ActorInit En_Torch_InitVars = { (ActorFunc)EnTorch_Init, (ActorFunc)NULL, (ActorFunc)NULL, (ActorFunc)NULL, }; -static u8 sChestContents[] = { 0x02, 0x04, 0x05, 0x06, 0x36, 0x3A, 0x14, 0x14 }; +static u8 sChestContents[] = { + GI_RUPEE_BLUE, GI_RUPEE_RED, GI_RUPEE_PURPLE, GI_RUPEE_SILVER, GI_BOMBCHUS_1, GI_BOMBCHUS_5, GI_BOMBS_1, GI_BOMBS_1, +}; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { EnTorch* this = THIS; @@ -25,6 +28,6 @@ void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, - (sChestContents[(returnData >> 0x5) & 0x7] << 0x5) | 0x5000 | (returnData & 0x1F)); + ENBOX_PARAMS(ENBOX_TYPE_SMALL, sChestContents[(returnData >> 0x5) & 0x7], returnData)); Actor_MarkForDeath(&this->actor); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f037221be..4307c8e37 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1661,8 +1661,8 @@ 0x800F21CC:("func_800F21CC",), 0x800F22C4:("func_800F22C4",), 0x800F23C4:("ActorCutscene_SetReturnCamera",), - 0x800F23E0:("func_800F23E0",), - 0x800F2478:("func_800F2478",), + 0x800F23E0:("Curve_CubicHermiteSpline",), + 0x800F2478:("Curve_Interpolate",), 0x800F2620:("SkelCurve_Clear",), 0x800F2650:("SkelCurve_Init",), 0x800F26C0:("SkelCurve_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index e0bf5a65a..336b844df 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -6826,9 +6826,8 @@ 0x808CD5E8:("D_808CD5E8","f32","",0x4), 0x808CE290:("Demo_Effect_InitVars","UNK_TYPE1","",0x1), 0x808CE2B0:("D_808CE2B0","UNK_TYPE4","",0x4), - 0x808CE2C0:("D_808CE2C0","UNK_TYPE1","",0x1), - 0x808CE2D4:("D_808CE2D4","UNK_TYPE1","",0x1), - 0x808CE2D5:("D_808CE2D5","UNK_TYPE1","",0x1), + 0x808CE2C0:("sEffectTypeObjects","s16","",0x12), + 0x808CE2D4:("sAlphaTypes","u8","",0x15), 0x808CE2F0:("jtbl_808CE2F0","UNK_PTR","",0x4), 0x808CE314:("D_808CE314","f32","",0x4), 0x808CE318:("D_808CE318","f32","",0x4), From 56c517dc0741be9c033e204b564528c46562c730 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:45:09 +0100 Subject: [PATCH 30/53] Obj_Toge (#815) * Obj_Toge * Wat * One more thing * PR * PR * a Co-authored-by: EllipticEllipsis --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c | 281 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h | 23 +- undefined_syms.txt | 4 - 5 files changed, 277 insertions(+), 36 deletions(-) diff --git a/include/functions.h b/include/functions.h index b802ee28a..92db30a01 100644 --- a/include/functions.h +++ b/include/functions.h @@ -563,7 +563,7 @@ void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); // void EffectSsEnIce_SpawnFlyingVec3f(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, Color_RGBA8* pzParm4, Color_RGBA8* param_5, UNK_TYPE4 param_6); -// void func_800B2B44(void); +void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3); // void func_800B2B7C(void); void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); // void EffectSsFireTail_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); diff --git a/spec b/spec index cdf130b1d..f6fb137b2 100644 --- a/spec +++ b/spec @@ -2213,8 +2213,7 @@ beginseg name "ovl_Obj_Toge" compress include "build/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.o" - include "build/data/ovl_Obj_Toge/ovl_Obj_Toge.data.o" - include "build/data/ovl_Obj_Toge/ovl_Obj_Toge.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Toge/ovl_Obj_Toge_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index 0471b6bd7..f8425b40a 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -5,6 +5,7 @@ */ #include "z_obj_toge.h" +#include "objects/object_trap/object_trap.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,11 +16,13 @@ void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx); void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A4744(ObjToge* this); void func_809A477C(ObjToge* this, GlobalContext* globalCtx); +void func_809A4804(ObjToge* this); void func_809A481C(ObjToge* this, GlobalContext* globalCtx); +void func_809A488C(ObjToge* this); void func_809A48AC(ObjToge* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Toge_InitVars = { ACTOR_OBJ_TOGE, ACTORCAT_PROP, @@ -32,52 +35,280 @@ const ActorInit Obj_Toge_InitVars = { (ActorFunc)ObjToge_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A4CB0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4D14[] = { +f32 D_809A4CDC[] = { 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, 16.0f }; + +s16 D_809A4CFC[] = { 0, 10, 20, 30, 40, 50, 60, 70 }; + +f32 D_809A4D0C[] = { 1.0f, 2.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(terminalVelocity, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 150, ICHAIN_STOP), }; -#endif +void func_809A41C0(ObjToge* this, GlobalContext* globalCtx) { + Vec3f sp1C = this->actor.world.pos; -extern ColliderCylinderInit D_809A4CB0; -extern InitChainEntry D_809A4D14[]; + sp1C.y += 10.0f; + sp1C.z += 10.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); -extern UNK_TYPE D_06001400; + sp1C.x += 10.0f; + sp1C.z -= 20.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A41C0.s") + sp1C.x -= 20.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A42A0.s") +void func_809A42A0(ObjToge* this, GlobalContext* globalCtx) { + Vec3f sp54; + s32 i; + s16 phi_s0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A43A8.s") + sp54.y = this->actor.world.pos.y + 15.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A43EC.s") + for (i = 0, phi_s0 = 0; i < 5; i++, phi_s0 += 0x3333) { + sp54.x = (Math_SinS(phi_s0) * 15.0f) + this->actor.world.pos.x; + sp54.z = (Math_CosS(phi_s0) * 15.0f) + this->actor.world.pos.z; + func_800B2B44(globalCtx, &this->actor, &sp54, (Rand_ZeroOne() * 0.6f) + 2.8f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Init.s") +void func_809A43A8(ObjToge* this, GlobalContext* globalCtx) { + if (!OBJTOGE_GET_4000(&this->actor)) { + func_809A41C0(this, globalCtx); + } else { + func_809A42A0(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Destroy.s") +s32 func_809A43EC(ObjToge* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_fv1 = player->actor.world.pos.x - this->unk_1B8; + f32 temp_fa0 = player->actor.world.pos.z - this->unk_1BC; + f32 temp = -(this->unk_1CC * temp_fa0) + (temp_fv1 * this->unk_1C8); + f32 temp2 = (this->unk_1CC * temp_fv1) + (temp_fa0 * this->unk_1C8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A4744.s") + return fabsf(temp) <= this->unk_1C0 && fabsf(temp2) <= this->unk_1C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A477C.s") +void ObjToge_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjToge* this = THIS; + Path* path; + Vec3s* sp40; + s16 sp3E; + s32 sp38 = OBJTOGE_GET_4000(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A4804.s") + Actor_ProcessInitChain(thisx, sInitChain); + Actor_SetScale(thisx, D_809A4D0C[sp38] * 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A481C.s") + sp3E = thisx->home.rot.z; + thisx->home.rot.z = thisx->world.rot.z = thisx->shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A488C.s") + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A48AC.s") + if (OBJTOGE_GET_PATH(thisx) == 0xFF) { + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Update.s") + path = &globalCtx->setupPathList[OBJTOGE_GET_PATH(thisx)]; + if (path->count != 2) { + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Draw.s") + sp40 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->unk_198[0], &sp40[0]); + Math_Vec3s_ToVec3f(&this->unk_198[1], &sp40[1]); + Math_Vec3f_Copy(&thisx->world.pos, &this->unk_198[0]); + thisx->world.rot.y = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); + this->unk_194 = 0; + thisx->speedXZ = 0.0f; + + if (sp3E > 0) { + s16 sp36; + + this->unk_1B4 = true; + this->unk_1B8 = (this->unk_198[0].x + this->unk_198[1].x) * 0.5f; + this->unk_1BC = (this->unk_198[0].z + this->unk_198[1].z) * 0.5f; + + sp36 = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); + this->unk_1C8 = Math_CosS(sp36); + this->unk_1CC = Math_SinS(sp36); + this->unk_1C0 = sp3E * 7.5f; + this->unk_1C4 = Math3D_Distance(&this->unk_198[0], &this->unk_198[1]) * 0.5f; + } else { + this->unk_1B4 = false; + } + + Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); + thisx->colChkInfo.mass = MASS_IMMOVABLE; + + if (sp38 == 1) { + this->collider.dim.radius = 60; + this->collider.dim.height = 40; + } + + if (this->unk_1B4) { + func_809A4804(this); + } else { + func_809A4744(this); + } +} + +void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjToge* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_809A4744(ObjToge* this) { + this->actionFunc = func_809A477C; + this->unk_1B0 = 0; + this->unk_1B2 = D_809A4CFC[OBJTOGE_GET_3800(&this->actor)]; +} + +void func_809A477C(ObjToge* this, GlobalContext* globalCtx) { + if (this->unk_1B2 > 0) { + this->unk_1B2--; + } + + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || (this->unk_1B2 <= 0)) { + this->unk_1B0 += 200; + } + + if (!this->unk_1B4) { + this->actor.shape.rot.y += this->unk_1B0; + } +} + +void func_809A4804(ObjToge* this) { + this->actionFunc = func_809A481C; + this->unk_1B0 = 0; +} + +void func_809A481C(ObjToge* this, GlobalContext* globalCtx) { + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || func_809A43EC(this, globalCtx)) { + this->unk_1B0 += 200; + } + this->actor.shape.rot.y += this->unk_1B0; +} + +void func_809A488C(ObjToge* this) { + this->actor.speedXZ = 1.0f; + this->actionFunc = func_809A48AC; +} + +void func_809A48AC(ObjToge* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = this->unk_194 ^ 1; + + if (this->unk_1B4 && (this->unk_194 == 1)) { + Math_StepToF(&this->actor.speedXZ, 2.0f, 0.4f); + } else { + Math_StepToF(&this->actor.speedXZ, D_809A4CDC[OBJTOGE_GET_700(&this->actor)], 1.5f); + this->actor.shape.rot.y += 0x1770; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, D_809A4D0C[OBJTOGE_GET_4000(&this->actor)] * 30.0f, 0.0f, + 0x81); + + if (this->actor.bgCheckFlags & 8) { + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); + this->unk_194 = sp30; + if (this->unk_1B4 && (this->unk_194 == 0)) { + func_809A4804(this); + } else { + func_809A4744(this); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + } else { + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[sp30]) - this->actor.world.rot.y; + + yaw = ABS_ALT(yaw); + if ((yaw > 0x4000) || (yaw == -0x8000)) { + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); + this->unk_194 = sp30; + if (this->unk_1B4 && (this->unk_194 == 0)) { + func_809A4804(this); + } else { + func_809A4744(this); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + } + } +} + +void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjToge* this = THIS; + ColliderCylinder* collider = &this->collider; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + func_809A43A8(this, globalCtx); + Actor_SetColorFilter(&this->actor, 0, 250, 0, 250); + } + collider->base.acFlags &= ~AC_HIT; + } + + if (this->actor.colorFilterTimer == 0) { + if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + func_800B8DD4(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f, 4); + } + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->actor.xzDistToPlayer < 1000.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + if ((this->actor.flags & ACTOR_FLAG_40) || (this->actor.xzDistToPlayer < 300.0f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); + } else { + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + } +} + +void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjToge* this = THIS; + + func_800B8050(&this->actor, globalCtx, 1); + Gfx_DrawDListOpa(globalCtx, object_trap_DL_001400); +} diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h index c67e0b97f..3908b2c7e 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h @@ -7,11 +7,26 @@ struct ObjToge; typedef void (*ObjTogeActionFunc)(struct ObjToge*, GlobalContext*); +#define OBJTOGE_GET_PATH(thisx) ((thisx)->params & 0xFF) +#define OBJTOGE_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJTOGE_GET_3800(thisx) (((thisx)->params >> 0xB) & 7) +#define OBJTOGE_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + typedef struct ObjToge { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ ObjTogeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x3C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjTogeActionFunc actionFunc; + /* 0x194 */ s32 unk_194; + /* 0x198 */ Vec3f unk_198[2]; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s16 unk_1B2; + /* 0x1B4 */ u8 unk_1B4; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ f32 unk_1C8; + /* 0x1CC */ f32 unk_1CC; } ObjToge; // size = 0x1D0 extern const ActorInit Obj_Toge_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 15bcad8c1..b0a275ace 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1618,10 +1618,6 @@ D_06001100 = 0x06001100; D_06001140 = 0x06001140; D_06001CB0 = 0x06001CB0; -// ovl_Obj_Toge - -D_06001400 = 0x06001400; - // ovl_Obj_Toudai D_060023B0 = 0x060023B0; From 7ca70d496dfdcab4a4132eb1e02887d7a1715637 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 19 Jun 2022 04:14:55 +0100 Subject: [PATCH 31/53] Change `Rand_Next` to `u32`, document `rand.c` a bit more (#819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change Rand_Next to u32, document rand.c a bit more * Clean up the quotes a bit, add another note * Format * — -> - * Review * Remove unnecessary casts * Remove quote, reformat the comments * Fix new files * Make docs a bit more consistent and specific * Format --- include/functions.h | 2 +- src/boot_O2/rand.c | 60 +++++++++++-------- src/code/sys_math_atan.c | 48 +++++++-------- src/code/z_actor.c | 2 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 6 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 4 +- .../z_bg_dblue_waterfall.c | 2 +- .../z_bg_hakugin_bombwall.c | 16 ++--- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 14 ++--- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 4 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 20 +++---- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 4 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 25 ++++---- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 8 +-- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 10 ++-- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 20 +++---- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 6 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 2 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 4 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 12 ++-- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 54 ++++++++--------- .../actors/ovl_En_Minislime/z_en_minislime.c | 12 ++-- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 8 +-- .../actors/ovl_En_Peehat/z_en_peehat.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 8 +-- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 2 +- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 4 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 36 +++++------ .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 12 ++-- .../actors/ovl_Obj_Grass/z_obj_grass.c | 10 ++-- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 2 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 2 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 4 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 6 +- .../actors/ovl_Obj_Kibako2/z_obj_kibako2.c | 2 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 10 ++-- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 10 ++-- 43 files changed, 239 insertions(+), 228 deletions(-) diff --git a/include/functions.h b/include/functions.h index 92db30a01..7e01d5afe 100644 --- a/include/functions.h +++ b/include/functions.h @@ -171,7 +171,7 @@ f64 func_80086D6C(f64 param_1); s32 func_80086D8C(f32 param_1); s32 func_80086DAC(f64 param_1); -s32 Rand_Next(void); +u32 Rand_Next(void); void Rand_Seed(u32 seed); f32 Rand_ZeroOne(void); f32 Rand_Centered(void); diff --git a/src/boot_O2/rand.c b/src/boot_O2/rand.c index de603590e..2db64e9d5 100644 --- a/src/boot_O2/rand.c +++ b/src/boot_O2/rand.c @@ -1,33 +1,39 @@ #include "global.h" -// The latest generated random number, used to generate the next number in the sequence. +//! The latest generated random number, used to generate the next number in the sequence. static u32 sRandInt = 1; -// Space to store a value to be re-interpreted as a float. -// This can't be static because it is used in z_kankyo +//! Space to store a value to be re-interpreted as a float. +//! This can't be static because it is used in z_kankyo. u32 sRandFloat; +//! These values are recommended by the algorithms book *Numerical Recipes in C. The Art of Scientific Computing*, 2nd +//! Edition, 1992, ISBN 0-521-43108-5. (p. 284): +//! > This is about as good as any 32-bit linear congruential generator, entirely adequate for many uses. #define RAND_MULTIPLIER 1664525 #define RAND_INCREMENT 1013904223 /** - * Gets the next integer in the sequence of pseudo-random numbers. + * Generates the next pseudo-random integer. */ -s32 Rand_Next(void) { - return sRandInt = (sRandInt * 1664525) + 1013904223; +u32 Rand_Next(void) { + return sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Seeds the pseudo-random number generator by providing a starting value. + * Seeds the internal pseudo-random number generator with a provided starting value. */ void Rand_Seed(u32 seed) { sRandInt = seed; } /** - * Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating - * the next integer and masking it to an IEEE-754 compliant floating-point number - * between 1.0f and 2.0f, returning the result subtract 1.0f. + * Returns a pseudo-random float between 0.0f and 1.0f from the internal PRNG. + * + * @note Works by generating the next integer, masking it to an IEEE-754 compliant float between 1.0f and 2.0f, and + * subtracting 1.0f. + * + * @remark This is also recommended by Numerical Recipes, pp. 284-5. */ f32 Rand_ZeroOne(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -36,8 +42,7 @@ f32 Rand_ZeroOne(void) { } /** - * Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same - * manner in which Rand_ZeroOne generates its result. + * Returns a pseudo-random float between -0.5f and 0.5f in the same way as Rand_ZeroOne(). */ f32 Rand_Centered(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -45,40 +50,47 @@ f32 Rand_Centered(void) { return *((f32*)&sRandFloat) - 1.5f; } +//! All functions below are unused variants of the above four, that use a provided random number variable instead of the +//! internal `sRandInt` + /** - * Seeds a pseudo-random number at rndNum with a provided seed. + * Seeds a provided pseudo-random number with a provided starting value. + * + * @see Rand_Seed */ void Rand_Seed_Variable(u32* rndNum, u32 seed) { *rndNum = seed; } /** - * Generates the next pseudo-random integer from the provided rndNum. + * Generates the next pseudo-random number from the provided rndNum. + * + * @see Rand_Next */ u32 Rand_Next_Variable(u32* rndNum) { return *rndNum = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Generates the next pseudo-random floating-point number between 0.0f and - * 1.0f from the provided rndNum. + * Generates the next pseudo-random float between 0.0f and 1.0f from the provided rndNum. + * + * @see Rand_ZeroOne */ f32 Rand_ZeroOne_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.0f; } /** - * Generates the next pseudo-random floating-point number between -0.5f and - * 0.5f from the provided rndNum. + * Generates the next pseudo-random float between -0.5f and 0.5f from the provided rndNum. + * + * @see Rand_ZeroOne, Rand_Centered */ f32 Rand_Centered_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.5f; } diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 09f355d64..d68e1e293 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -77,57 +77,57 @@ u16 sATan2Tbl[] = { 0x1FF6, 0x1FFB, 0x2000, }; -u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent) { - return sATan2Tbl[(s32)((opposite / adjacent) * 0x400)]; +u16 Math_GetAtan2Tbl(f32 y, f32 x) { + return sATan2Tbl[(s32)((y / x) * 0x400)]; } -s16 Math_Atan2S(f32 opposite, f32 adjacent) { +s16 Math_Atan2S(f32 y, f32 x) { s32 angle; - if (opposite == 0.0f) { - if (adjacent >= 0.0f) { + if (y == 0.0f) { + if (x >= 0.0f) { angle = 0; } else { angle = 0x8000; } - } else if (adjacent == 0.0f) { - if (opposite >= 0.0f) { + } else if (x == 0.0f) { + if (y >= 0.0f) { angle = 0x4000; } else { angle = 0xC000; } - } else if (opposite >= 0.0f) { - if (adjacent >= 0.0f) { - if (opposite <= adjacent) { - angle = Math_GetAtan2Tbl(opposite, adjacent); + } else if (y >= 0.0f) { + if (x >= 0.0f) { + if (y <= x) { + angle = Math_GetAtan2Tbl(y, x); } else { - angle = 0x4000 - Math_GetAtan2Tbl(adjacent, opposite); + angle = 0x4000 - Math_GetAtan2Tbl(x, y); } } else { - if (-adjacent < opposite) { - angle = Math_GetAtan2Tbl(-adjacent, opposite) + 0x4000; + if (-x < y) { + angle = Math_GetAtan2Tbl(-x, y) + 0x4000; } else { - angle = 0x8000 - Math_GetAtan2Tbl(opposite, -adjacent); + angle = 0x8000 - Math_GetAtan2Tbl(y, -x); } } - } else if (adjacent < 0.0f) { - if (-opposite <= -adjacent) { - angle = Math_GetAtan2Tbl(-opposite, -adjacent) + 0x8000; + } else if (x < 0.0f) { + if (-y <= -x) { + angle = Math_GetAtan2Tbl(-y, -x) + 0x8000; } else { - angle = 0xC000 - Math_GetAtan2Tbl(-adjacent, -opposite); + angle = 0xC000 - Math_GetAtan2Tbl(-x, -y); } } else { - if (adjacent < -opposite) { - angle = Math_GetAtan2Tbl(adjacent, -opposite) + 0xC000; + if (x < -y) { + angle = Math_GetAtan2Tbl(x, -y) + 0xC000; } else { - angle = -Math_GetAtan2Tbl(-opposite, adjacent); + angle = -Math_GetAtan2Tbl(-y, x); } } return angle; } -f32 Math_Atan2F(f32 opposite, f32 adjacent) { - return Math_Atan2S(opposite, adjacent) * (M_PI / 0x8000); +f32 Math_Atan2F(f32 y, f32 x) { + return Math_Atan2S(y, x) * (M_PI / 0x8000); } s16 Math_FAtan2F(f32 adjacent, f32 opposite) { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index bbabeafd5..4e1e641de 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4782,7 +4782,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos yaw = Actor_YawToPoint(actor, limbPos); for (j = 0; j < effectsPerLimb; j++) { - randomYaw = (Rand_Next() >> 0x13) + yaw; + randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; velocity.z = Rand_ZeroFloat(5.0f); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 6ac390ce5..2bcc31b5b 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -78,7 +78,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { - if ((u32)Rand_Next() >= 0x40000000) { + if (Rand_Next() >= 0x40000000) { splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = sExitSplashOffsets[i].y; splashOffset.z = sExitSplashOffsets[i].z; @@ -86,7 +86,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 340); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 340); } } } @@ -104,7 +104,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 280); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280); } } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 0c5b92496..da3943141 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -276,7 +276,7 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } @@ -285,7 +285,7 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } sp60.z = (temp_f20 * arg2) + arg1->z; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index fcec4ebb3..a9777972d 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -295,7 +295,7 @@ void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (this->unk_1A7 <= 0) { this->unk_1A7 = 16; } else { - this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + this->unk_1A7 -= (s8)(Rand_Next() >> 0x1F); } if (this->unk_1A7 >= 6) { diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 20d68e7a4..1103c6d81 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -138,7 +138,7 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { for (i = 0; i < 6; i++) { temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { - spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + spD8.x = D_80ABD020[j] + (s32)(Rand_Next() >> 0x1C); spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp; spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; @@ -159,11 +159,11 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { phi_s0 = 64; } - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 |= 1; phi_s1 = 1; func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + (Rand_Next() >> 0x1B) + 70, (Rand_Next() >> 0x1A) + 60); } else { phi_s1 = 0; } @@ -224,7 +224,7 @@ void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { if ((i & 1) == 0) { func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + (Rand_Next() >> 0x1B) + 60, (Rand_Next() >> 0x1A) + 50); } } } @@ -269,8 +269,8 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spC0.y += this->dyna.actor.world.pos.y; spC0.z += this->dyna.actor.world.pos.z; - func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } @@ -303,8 +303,8 @@ void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB8.x = spAC.x * -0.095f; spB8.z = spAC.z * -0.095f; - func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index a7f20b7b4..f0831055f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -343,9 +343,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU temp_f0 = spAC.z; unkStruct2->unk_10.z = ((Rand_ZeroOne() * 60.0f - 30.0f) + temp_f28 * 50.0f) * temp_f22 + temp_f0 * temp_f20; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.02f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x3FFF) - 0x1FFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; @@ -359,7 +359,7 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; spA0.z = Math_CosS(val) * temp_f20 + spB8.z; func_800B0E48(globalCtx, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, - (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); + ((s32)Rand_Next() >> 0x1A) + 0x82, ((s32)Rand_Next() >> 0x1A) + 0x6E); } unkStruct1Temp = func_80A9B32C(unkStruct, unkStruct1); @@ -386,9 +386,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU unkStruct2->unk_10.y = 0.0f; unkStruct2->unk_10.z = Rand_ZeroOne() + temp_f28 * 7.0f; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.075f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 71f1d2b6a..ccf8e2d43 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -47,7 +47,7 @@ void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &thisx->floorPoly, &bgId, &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; - this->dyna.actor.world.rot.y = Rand_Next() >> 0x10; + this->dyna.actor.world.rot.y = (s32)Rand_Next() >> 0x10; this->actionFunc = BgLotus_Wait; } @@ -82,7 +82,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { if (this->timer2 == 0) { this->timer2 = 96; - this->dyna.actor.world.rot.y += (s16)(Rand_Next() >> 0x12); + this->dyna.actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x12); } } diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index f48976cd6..65d582eb3 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -241,7 +241,7 @@ void EnBb_SetupFlyIdle(EnBb* this) { if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { - this->targetYRotation += (s16)(Rand_Next() >> 0x11); + this->targetYRotation += (s16)((s32)Rand_Next() >> 0x11); } this->collider.base.atFlags |= AT_ON; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index acf465f83..4c4261a4c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -505,7 +505,7 @@ void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); - s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; + s16 randomYaw = ((s32)Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); @@ -565,7 +565,7 @@ void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { } if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk208, 0x200) && (Rand_ZeroOne() < 0.075f)) { - this->unk208 += (s16)((((u32)Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->unk208 += (s16)(((Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } this->actor.world.rot.y = this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 1a507b5b6..0e3c9b20a 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2089,9 +2089,9 @@ void EnBigslime_SetupIdleLookAround(EnBigslime* this) { this->idleTimer = 60; this->actor.speedXZ = 0.0f; if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } this->actionFunc = EnBigslime_IdleLookAround; } @@ -2111,9 +2111,9 @@ void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } } @@ -2700,9 +2700,9 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; iceShardEffect->isActive = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; @@ -2742,9 +2742,9 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { iceShardEffect->isActive = false; } - iceShardEffect->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 914ee2bca..c31b534a1 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -449,7 +449,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f20; Math_Vec3f_Copy(&sp68, &this->limbPos[0]); - sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; + sp66 = ((s32)Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -482,7 +482,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp62 = this->unk_334 * 25.0f; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp66 = ((u32)Rand_Next() >> 0x13) + this->actor.shape.rot.y; + sp66 = (Rand_Next() >> 0x13) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 42ff95aba..32ce1988f 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -226,15 +226,15 @@ void EnFamos_SetupAttackDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; + randVelDirection = (s32)Rand_Next() >> 0x10; randOffset = Rand_S16Offset(0x1800, 0x2800); randFloat = Rand_ZeroFloat(5.0f) + 5.0f; rock->velocity.x = randFloat * Math_CosS(randOffset) * Math_SinS(randVelDirection); rock->velocity.y = Math_SinS(randOffset) * randFloat + 3.0f; rock->velocity.z = randFloat * Math_CosS(randOffset) * Math_CosS(randVelDirection); - rock->rotation.x = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; rock->pos.x = (Math_SinS(randVelDirection) * 20.0f) + this->actor.world.pos.x; rock->pos.y = this->actor.floorHeight; rock->pos.z = (Math_CosS(randVelDirection) * 20.0f) + this->actor.world.pos.z; @@ -255,15 +255,15 @@ void EnFamos_SetupDeathDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; - randSmaller = (u32)Rand_Next() >> 0x12; + randVelDirection = (s32)Rand_Next() >> 0x10; + randSmaller = Rand_Next() >> 0x12; randFloat = Rand_ZeroFloat(6.0f) + 7.0f; rock->velocity.x = randFloat * Math_CosS(randSmaller) * Math_SinS(randVelDirection); rock->velocity.y = Math_SinS(randSmaller) * randFloat + 4.5f; rock->velocity.z = randFloat * Math_CosS(randSmaller) * Math_CosS(randVelDirection); - rock->rotation.x = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; rock->pos.x = Math_SinS(randVelDirection) * 20.0f + this->actor.world.pos.x; rock->pos.y = randPlusMinusPoint5Scaled(60.0f) + (this->actor.world.pos.y + 40.0f); rock->pos.z = Math_CosS(randVelDirection) * 20.0f + this->actor.world.pos.z; @@ -735,10 +735,9 @@ void EnFamos_UpdateDebrisPosRot(EnFamos* this) { for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { rock->velocity.y -= 1.0f; Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); - // all casts seem required - rock->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - rock->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - rock->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + rock->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 6c9f813fd..d456f48ed 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -210,8 +210,8 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->actor.colChkInfo.mass = this->unk_25C * 30.0f; - this->unk_244 = (u32)Rand_Next() >> 0x10; - this->unk_246 = (u32)Rand_Next() >> 0x10; + this->unk_244 = Rand_Next() >> 0x10; + this->unk_246 = Rand_Next() >> 0x10; if (sp36 == ENFISH_0) { this->actor.flags |= ACTOR_FLAG_10; @@ -707,12 +707,12 @@ void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ *= 0.5f; } - if (!((u32)Rand_Next() >> 0x1B) || ((this->actor.bgCheckFlags & 8) && !((u32)Rand_Next() >> 0x1E)) || + if (((Rand_Next() >> 0x1B) == 0) || ((this->actor.bgCheckFlags & 8) && ((Rand_Next() >> 0x1E) == 0)) || !(this->actor.bgCheckFlags & 0x20)) { temp_f0 = Rand_ZeroOne(); sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; sp30 = Rand_ZeroOne() * sp3C->home.rot.z; - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; this->actor.home.pos.x = (Math_SinS(sp2E) * sp34) + sp3C->world.pos.x; this->actor.home.pos.y = sp3C->world.pos.y + sp30; this->actor.home.pos.z = (Math_CosS(sp2E) * sp34) + sp3C->world.pos.z; diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 4591eab65..7fe1d6e58 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -201,7 +201,7 @@ void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { s32 phi_s2; s32 i; - this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_308 = Rand_Next() % ARRAY_COUNT(this->unk_1B8); this->unk_302 = 1; this->dyna.actor.gravity = -1.0f; this->dyna.actor.velocity.y = Rand_ZeroOne(); diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index f17a75f6a..e4b822546 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -599,7 +599,7 @@ void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { temp = 0x10000 / sp80; for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { - temp_s3 = (u32)Rand_Next() >> 0x10; + temp_s3 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s3); temp_f22 = Math_CosS(temp_s3); @@ -701,7 +701,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { phi_s1 = D_80942E0C[sp120][0]; phi_s3 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -779,7 +779,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB phi_s7 = arg2[0]; phi_fp = -0x190; spC8 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -856,7 +856,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA if ((i & 3) == 1) { phi_s1 = arg2[1]; phi_s2 = -0x154; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -864,7 +864,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } else { phi_s1 = arg2[0]; phi_s2 = -0x190; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index d8551103d..63da6c329 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -102,7 +102,7 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); sp2C = Rand_S16Offset(0x1000, 0x3000); - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; sp28 = Rand_ZeroFloat(5.0f) + 10.0f; gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); @@ -120,9 +120,9 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; gohtParticle->unk_1A = 0; } - gohtParticle->unk_1C.x = Rand_Next() >> 0x10; - gohtParticle->unk_1C.y = Rand_Next() >> 0x10; - gohtParticle->unk_1C.z = Rand_Next() >> 0x10; + gohtParticle->unk_1C.x = (s32)Rand_Next() >> 0x10; + gohtParticle->unk_1C.y = (s32)Rand_Next() >> 0x10; + gohtParticle->unk_1C.z = (s32)Rand_Next() >> 0x10; gohtParticle->unk_18 = 0x28; return; } @@ -189,10 +189,10 @@ void func_80B220A8(EnHakurock* this) { this->actor.speedXZ = Rand_ZeroFloat(3.5f) + 2.5f; this->actor.velocity.y = Rand_ZeroFloat(4.5f) + 18.0f; Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 15.0f) * 0.001f); - this->actor.world.rot.y = (Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; - this->actor.shape.rot.x = Rand_Next() >> 0x10; - this->actor.shape.rot.y = Rand_Next() >> 0x10; - this->actor.shape.rot.z = Rand_Next() >> 0x10; + this->actor.world.rot.y = ((s32)Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->collider.dim.radius = (this->actor.scale.x * 2500.0f); this->collider.dim.yShift = -this->collider.dim.radius; this->collider.dim.height = this->collider.dim.radius * 2; @@ -222,8 +222,8 @@ void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { s16 angle; this->actor.draw = EnHakurock_Draw; - angle = (Rand_Next() >> 0x13) + player->actor.shape.rot.y; - this->actor.shape.rot.y = Rand_Next() >> 0x10; + angle = ((s32)Rand_Next() >> 0x13) + player->actor.shape.rot.y; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; this->actor.world.pos.x = (Math_SinS(angle) * 600.0f) + player->actor.world.pos.x; this->actor.world.pos.y = player->actor.world.pos.y + 700.0f; this->actor.world.pos.z = (Math_CosS(angle) * 600.0f) + player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 2eace7815..4c9dcc0e8 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2656,7 +2656,7 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer > 0) { temp_v1_3 = this->actionTimer & 0x1F; if ((temp_v1_3 == 0) && (Rand_ZeroOne() < 0.3f)) { - temp_v1_3 = Rand_Next() % 4; + temp_v1_3 = (s32)Rand_Next() % 4; if (temp_v1_3 != this->rand) { this->rand = temp_v1_3; if (this->rand == 0) { diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 9b60a41dd..6f29acf4a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -203,8 +203,8 @@ void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { spC4.y += (Rand_ZeroOne() * 7.0f) + 6.0f; spC4.z += (Rand_ZeroOne() - 0.5f) * 11.0f; - EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, (Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], - 3, 10, 40, -1, temp, phi_s4); + EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, ((s32)Rand_Next() > 0) ? 65 : 33, 30, 5, 0, + D_8095F74C[i], 3, 10, 40, -1, temp, phi_s4); } } @@ -389,7 +389,7 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Actor_SetScale(&this->actor, D_8095F6B8[sp34]); diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index c16fa4147..9e00b09e4 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -313,7 +313,7 @@ void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { s32 rand; if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { - rand = (u32)Rand_Next() % 3; + rand = Rand_Next() % 3; this->unk_2FC = 0; if (rand < this->unk_218) { diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index d2a1f9902..ab3e8531f 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -230,7 +230,7 @@ void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { - this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } this->unk_29E--; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 92053374a..5b32a556b 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -600,8 +600,8 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 1); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 4); this->unk_290 = 0; this->unk_284++; } else if (this->unk_290 == 120) { diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 1767f3c86..fb20fcd67 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -381,7 +381,7 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + this->actor.shape.rot.y = (Rand_Next() >> 0x10); this->actor.home.rot.y = this->actor.shape.rot.y; this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -401,11 +401,11 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { EnKusa_SetupWaitObject(this); if (D_809366B4) { - D_80936CD8 = ((u32)Rand_Next() >> 0x10); - D_80936CDA = ((u32)Rand_Next() >> 0x10); - D_80936CDC = ((u32)Rand_Next() >> 0x10); - D_80936CDE = ((u32)Rand_Next() >> 0x10); - D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_80936CD8 = Rand_Next() >> 0x10; + D_80936CDA = Rand_Next() >> 0x10; + D_80936CDC = Rand_Next() >> 0x10; + D_80936CDE = Rand_Next() >> 0x10; + D_80936CE0 = Rand_Next() >> 0x10; D_809366B4 = false; EnKusa_Sway(); kusaGameplayFrames = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 6ba532cef..8852319df 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -102,7 +102,7 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = this->unk_194; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { @@ -117,8 +117,8 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = &this->unk_194[i]; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, - this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, - (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, + 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { (*ptr)->actor.room = this->actor.room; @@ -741,7 +741,7 @@ void func_80A5CD0C(EnKusa2* this) { s32 pad; for (i = 0; i < 2; i++) { - temp_s0 = (u32)Rand_Next() & 0xFFFF; + temp_s0 = Rand_Next() & 0xFFFF; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -756,13 +756,13 @@ void func_80A5CD0C(EnKusa2* this) { spA8.y += this->actor.world.pos.y; spA8.z += this->actor.world.pos.z; - sp94.x = (u32)Rand_Next() & 0xFFFF; - sp94.y = (u32)Rand_Next() & 0xFFFF; - sp94.z = (u32)Rand_Next() & 0xFFFF; + sp94.x = Rand_Next() & 0xFFFF; + sp94.y = Rand_Next() & 0xFFFF; + sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.4f) + 0.02f, &spA8, &sp9C, &sp94, &sp8C); } @@ -779,7 +779,7 @@ void func_80A5CF44(EnKusa2* this) { s32 phi_s2; for (i = 0, phi_s2 = 0; i < 8; i++, phi_s2 += 0x2000) { - temp_s0 = ((u32)Rand_Next() % 0x2000) + phi_s2; + temp_s0 = (Rand_Next() % 0x2000) + phi_s2; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -798,9 +798,9 @@ void func_80A5CF44(EnKusa2* this) { sp94.y = Rand_Next() & 0xFFFF; sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.45f) + 0.04f, &spA8, &sp9C, &sp94, &sp8C); } @@ -819,7 +819,7 @@ void func_80A5D178(EnKusa2* this) { s32 pad; for (i = 0; i < 8; i++) { - temp_s0 = (u32)Rand_Next(); + temp_s0 = Rand_Next(); temp_f22 = Math_SinS(temp_s0); temp_f20 = Math_CosS(temp_s0); temp_f24 = (Rand_ZeroOne() * 40.0f) + 10.0f; @@ -836,12 +836,12 @@ void func_80A5D178(EnKusa2* this) { spB0.y += this->actor.world.pos.y; spB0.z += this->actor.world.pos.z; - sp9C.x = (u32)Rand_Next() & 0xFFFF; - sp9C.y = (u32)Rand_Next() & 0xFFFF; - sp9C.z = (u32)Rand_Next() & 0xFFFF; + sp9C.x = Rand_Next() & 0xFFFF; + sp9C.y = Rand_Next() & 0xFFFF; + sp9C.z = Rand_Next() & 0xFFFF; sp94.x = Rand_S16Offset(-12000, 24000); - sp94.y = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp94.y = (Rand_Next() % 0x4000) - 0x1FFF; sp94.z = Rand_S16Offset(-12000, 24000); func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.38f) + 0.02f, &spB0, &spA4, &sp9C, &sp94); } @@ -868,11 +868,11 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { D_80A5EAEC = 0; D_80A60900 = globalCtx->gameplayFrames; func_80A5CAD4(&D_80A5F1C0); - D_80A60B08 = (u32)Rand_Next() >> 0x10; - D_80A60B0A = (u32)Rand_Next() >> 0x10; - D_80A60B0C = (u32)Rand_Next() >> 0x10; - D_80A60B0E = (u32)Rand_Next() >> 0x10; - D_80A60B10 = (u32)Rand_Next() >> 0x10; + D_80A60B08 = Rand_Next() >> 0x10; + D_80A60B0A = Rand_Next() >> 0x10; + D_80A60B0C = Rand_Next() >> 0x10; + D_80A60B0E = Rand_Next() >> 0x10; + D_80A60B10 = Rand_Next() >> 0x10; func_80A5B508(); } func_80A5D5E0(this); @@ -1048,14 +1048,14 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { sp30.y = this->actor.world.pos.y + 20.0f; sp30.z = this->actor.world.pos.z; - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } this->unk_1D0--; if (this->unk_1D0 <= 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); - this->unk_1D0 = ((u32)Rand_Next() >> 0x1D) + 14; + this->unk_1D0 = (Rand_Next() >> 0x1D) + 14; } this->actor.floorHeight = @@ -1152,7 +1152,7 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { func_80A5BF38(this, 4); func_80A5BF84(this, globalCtx); - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 4efc18714..68f587ba3 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -192,9 +192,9 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { iceShardEffect->pos.y = this->actor.world.pos.y + (((iceShardEffect->vel.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->vel.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; iceShardEffect->isActive = true; Math_Vec3f_ScaleAndStore(&iceShardEffect->vel, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->vel); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; @@ -276,8 +276,8 @@ void EnMinislime_SetupBreakFromBigslime(EnMinislime* this) { this->actor.gravity = -1.0f; this->frozenScale = 0.1f; this->actor.world.rot.x = Rand_S16Offset(0x800, 0x800); - this->actor.shape.rot.x = (s16)(Rand_Next() >> 0x10); - this->actor.shape.rot.z = (s16)(Rand_Next() >> 0x10); + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->actor.scale.x = 0.15f; this->actor.scale.y = 0.075f; this->actor.scale.z = 0.15f; @@ -437,7 +437,7 @@ void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); } else { - this->actor.world.rot.y += (s16)(Rand_Next() >> 19); + this->actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x13); } } this->idleTimer = 20; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 4afae5793..e08969c6b 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -618,7 +618,7 @@ void func_80A69ADC(Actor* thisx) { if (Rand_ZeroOne() < this->unk_358) { this->unk_366 = (sp44 >= 0.0f) ? 2000 : -2000; } else { - this->unk_366 = (Rand_Next() > 0) ? 2000 : -2000; + this->unk_366 = ((s32)Rand_Next() > 0) ? 2000 : -2000; } this->unk_366 += (s16)(((Rand_ZeroOne() * (1.0f - this->unk_358)) - 0.5f) * 0x400); } else { @@ -634,7 +634,7 @@ void func_80A69CE0(Actor* thisx) { this->unk_360 = Rand_ZeroOne() * 1500.0f; this->unk_364 = 0; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { this->unk_366 = 2000; } else { this->unk_366 = -2000; @@ -770,7 +770,7 @@ void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp3C != 0) { func_80A69F5C(&this->actor, globalCtx); - this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = Rand_Next() >> 0x10; func_80A6AE14(this); } else { func_80A6A300(this); @@ -1034,7 +1034,7 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && - (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { + (this->actor.depthInWater < 30.0f) && ((s32)(Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 708bae3ef..4f65a541c 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -249,7 +249,7 @@ void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 ar static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; Vec3f sp44; - s16 sp42 = Rand_Next() >> 0x10; + s16 sp42 = (s32)Rand_Next() >> 0x10; s32 temp_v1; sp44.y = this->actor.floorHeight; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 6d3a118f4..c98c279ce 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -478,7 +478,7 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 22.5f)) { - this->unk_3D4 = (u32)Rand_Next() % 0x7D0; + this->unk_3D4 = Rand_Next() % 0x7D0; } this->actor.shape.rot.x = Math_SinS(this->unk_3D4 * sp26) * 20000.0f; diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index ef0ad1b57..2b579bf8d 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -319,7 +319,7 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* g for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1800, 0x2800); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = Rand_Next() >> 0x10; speed = Rand_ZeroFloat(3.0f) + 8.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); @@ -406,9 +406,9 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 8) { this->snowPileTargetRotY = this->actor.wallYaw; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { - this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } else if (Rand_ZeroOne() < 0.02f) { - this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->snowPileTargetRotY += (s16)(((Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } } @@ -746,7 +746,7 @@ void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1000, 0x3000); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = (Rand_Next() >> 0x10); speed = Rand_ZeroFloat(2.0f) + 4.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index faeb3163e..f64250240 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -196,7 +196,7 @@ void func_80C10984(EnThiefbird* this, s32 arg1) { ptr->unk_0C.z = randPlusMinusPoint5Scaled(5.0f); ptr->unk_1C = Rand_ZeroFloat(1000.0f); ptr->unk_18 = (Rand_ZeroFloat(20.0f) + 40.0f) * 0.0001f; - ptr->unk_1E = Rand_Next() >> 0x10; + ptr->unk_1E = (s32)Rand_Next() >> 0x10; arg1--; if (arg1 == 0) { break; diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 55304d195..8cf2039b4 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -193,7 +193,7 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp34 == OBJBOMBIWA_100_0) { if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } func_80939594(this, globalCtx); } @@ -387,7 +387,7 @@ void func_8093A080(ObjBombiwa* this) { ptr->unk_10 = i + 3.0f; ptr->unk_14.x = phi_s2; - ptr->unk_14.y = (u32)Rand_Next() >> 0x10; + ptr->unk_14.y = Rand_Next() >> 0x10; ptr->unk_14.z = 0; ptr->unk_1A = 0; } diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index c6eef8626..22df1af73 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -263,13 +263,13 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x11) - 0x3FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x11) - 0x3FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_29 = 0; ptr2->unk_28 = 40; @@ -307,13 +307,13 @@ void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; @@ -356,13 +356,13 @@ void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; ptr2->unk_18 = (Rand_ZeroOne() * 0.07f) + 0.003f; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 57964559d..d03912b14 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -399,7 +399,7 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Collider_InitJntSph(globalCtx, &this->collider); @@ -415,11 +415,11 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A1C818(this); if (D_80A1D404) { - D_80A1DA38 = (u32)Rand_Next() >> 0x10; - D_80A1DA3A = (u32)Rand_Next() >> 0x10; - D_80A1DA3C = (u32)Rand_Next() >> 0x10; - D_80A1DA3E = (u32)Rand_Next() >> 0x10; - D_80A1DA40 = (u32)Rand_Next() >> 0x10; + D_80A1DA38 = Rand_Next() >> 0x10; + D_80A1DA3A = Rand_Next() >> 0x10; + D_80A1DA3C = Rand_Next() >> 0x10; + D_80A1DA3E = Rand_Next() >> 0x10; + D_80A1DA40 = Rand_Next() >> 0x10; D_80A1D404 = false; func_80A1B3D0(); D_80A1D830 = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 51f2febc7..705325429 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -146,11 +146,11 @@ void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { } this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_3288 = (u32)Rand_Next() >> 0x10; - this->unk_328A = (u32)Rand_Next() >> 0x10; - this->unk_328C = (u32)Rand_Next() >> 0x10; - this->unk_328E = (u32)Rand_Next() >> 0x10; - this->unk_3290 = (u32)Rand_Next() >> 0x10; + this->unk_3288 = Rand_Next() >> 0x10; + this->unk_328A = Rand_Next() >> 0x10; + this->unk_328C = Rand_Next() >> 0x10; + this->unk_328E = Rand_Next() >> 0x10; + this->unk_3290 = Rand_Next() >> 0x10; } void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index d3199e8d8..c6dac659e 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -389,7 +389,7 @@ void func_80B15264(ObjHakaisi* this) { Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); Matrix_MultVec3f(&D_80B15600, &this->unk_184); this->dyna.actor.gravity = -1.0f; - this->unk_19C = Rand_Next() >> 0x12; + this->unk_19C = (s32)Rand_Next() >> 0x12; this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; this->dyna.actor.velocity.z = Math_CosS(sp32) * 4.0f; this->dyna.actor.velocity.y = 7.0f; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 10d8891ef..7b8377cee 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -170,7 +170,7 @@ void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.home.rot.y = this->actor.shape.rot.y; } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 3fc7f84b1..c31eeb151 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -463,7 +463,7 @@ void func_80A54E10(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); ptr->unk_24 = 0; @@ -558,7 +558,7 @@ void func_80A55310(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index a4db0d04e..1a6d96c73 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -106,8 +106,8 @@ void func_80A2311C(Vec3f* arg0, Vec3f* arg1, s16 arg2) { void func_80A2319C(ObjIceblock* this, f32 arg1) { s32 i; - s16 temp_s1 = (u32)Rand_Next() >> 0x10; - s16 temp_s2 = (u32)Rand_Next() >> 0x10; + s16 temp_s1 = Rand_Next() >> 0x10; + s16 temp_s2 = Rand_Next() >> 0x10; ObjIceBlockUnkStruct* ptr; for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { @@ -1364,7 +1364,7 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; - ptr->unk_14 = (u32)Rand_Next() >> 0x10; + ptr->unk_14 = Rand_Next() >> 0x10; func_80A24B74(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index c0e5d8b4b..194989ad5 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -121,7 +121,7 @@ void ObjKibako2_SpawnSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ContainsSkulltula(this, globalCtx)) { actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); - yRotation = ((u32)Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; + yRotation = (Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; skulltula = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, yRotation, 0, actorSpawnParam); diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 3979479f6..b3464d744 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -205,7 +205,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { gravity = -400; phi_s4 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -245,7 +245,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { temp_f26 = this->unk_20C * 60.0f; for (i = 0, phi_s6 = 0; i < 16; i++, phi_s6 += 0x1000) { - temp_s0 = (u32)Rand_Next() >> 0x10; + temp_s0 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s0); temp_f22 = Math_CosS(temp_s0); @@ -368,7 +368,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -377,7 +377,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -474,7 +474,7 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y += 20.0f * phi_f20; this->actor.uncullZoneScale = 150.0f * phi_f20; this->actor.uncullZoneDownward = 300.0f * phi_f20; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->unk_20C = phi_f20; if (sp34) { diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 5356e2e88..3737a5426 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -145,7 +145,7 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; - if (((u32)Rand_Next() >> 0x1E) == 0) { + if ((Rand_Next() >> 0x1E) == 0) { phi_s1 = 0x20; } else { phi_s1 = 0x40; @@ -234,7 +234,7 @@ void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { f32 temp_f2; s32 i; - D_80B3A938 += (s16)((u32)Rand_Next() >> 0x11); + D_80B3A938 += (s16)(Rand_Next() >> 0x11); for (i = 0; i < 2; i++) { D_80B3A938 += 0x8000; @@ -319,7 +319,7 @@ void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitJntSph(globalCtx, &this->collider); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; ActorShape_Init(&this->actor.shape, 200.0f, NULL, 12.5f); this->actor.shape.shadowAlpha = 130; Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -480,7 +480,7 @@ void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x40) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } - } else if ((((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) && + } else if ((((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) && (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { func_80B395EC(&this->actor, globalCtx); } @@ -567,7 +567,7 @@ void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - if (((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) { + if (((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) { func_80B395C4(globalCtx, &this->actor.home.pos); } From 9831e5e063da421a5dc86b9438c7d59f9f17706a Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:05:12 -0700 Subject: [PATCH 32/53] Effect Kfire OK (#837) * OK * Small change * Matrix renames * else if --- spec | 3 +- .../ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c | 92 +++++++++++++++++-- 2 files changed, 87 insertions(+), 8 deletions(-) diff --git a/spec b/spec index f6fb137b2..fc536a6a4 100644 --- a/spec +++ b/spec @@ -1908,8 +1908,7 @@ beginseg name "ovl_Effect_Ss_K_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.o" - include "build/data/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire.data.o" - include "build/data/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c index b477545c2..e93210b89 100644 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c @@ -5,23 +5,103 @@ */ #include "z_eff_ss_k_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rAlpha regs[0] +#define rScroll regs[2] +#define rType regs[3] +#define rYScale regs[4] +#define rXZScale regs[5] +#define rScaleMax regs[6] #define PARAMS ((EffectSsKFireInitParams*)initParamsx) -s32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_K_Fire_InitVars = { EFFECT_SS_K_FIRE, EffectSsKFire_Init, }; -#endif +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsKFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = 100; + this->rScaleMax = initParams->scaleMax; + this->rAlpha = 255; + this->rScroll = Rand_ZeroFloat(5.0f) - 25; + this->rType = initParams->type; + this->draw = EffectSsKFire_Draw; + this->update = EffectSsKFire_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Update.s") +void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 xzScale; + f32 yScale; + + xzScale = this->rXZScale / 10000.0f; + yScale = this->rYScale / 10000.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(xzScale, yScale, xzScale, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + globalCtx->state.frames * this->rScroll, 0x20, 0x80)); + + if (this->rType >= 100) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + } + + gDPPipeSync(POLY_XLU_DISP++); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + if ((index % 2) != 0) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->rXZScale < this->rScaleMax) { + this->rXZScale += 4; + this->rYScale += 4; + + if (this->rXZScale > this->rScaleMax) { + this->rXZScale = this->rScaleMax; + + if (this->rType != 3) { + this->rYScale = this->rScaleMax; + } + } + } else if (this->rAlpha > 0) { + this->rAlpha -= 10; + if (this->rAlpha <= 0) { + this->rAlpha = 0; + this->life = 0; + } + } + + if (this->rType == 3) { + this->rYScale++; + } +} From 1a37ef95d1807ea40cb9e236f08152c29c999435 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:10:21 -0700 Subject: [PATCH 33/53] Effect Icesmoke OK (#838) * Ok * Name DL and tex * Matrix renames --- assets/xml/objects/gameplay_keep.xml | 4 +- spec | 3 +- .../z_eff_ss_ice_smoke.c | 66 +++++++++++++++++-- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index d4a4ac277..969954b32 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1114,8 +1114,8 @@ - - + + diff --git a/spec b/spec index fc536a6a4..3ca89286a 100644 --- a/spec +++ b/spec @@ -2152,8 +2152,7 @@ beginseg name "ovl_Effect_Ss_Ice_Smoke" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.o" - include "build/data/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke.data.o" - include "build/data/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c index 71be8c0d6..4571bb790 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c @@ -1,27 +1,79 @@ /* * File: z_eff_ss_ice_smoke.c * Overlay: ovl_Effect_Ss_Ice_Smoke - * Description: + * Description: Ice Smoke */ #include "z_eff_ss_ice_smoke.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rAlpha regs[0] +#define rScale regs[1] +#define rScrollX regs[2] +#define rScrollY regs[3] #define PARAMS ((EffectSsIceSmokeInitParams*)initParamsx) -s32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { EFFECT_SS_ICE_SMOKE, EffectSsIceSmoke_Init, }; -#endif +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIceSmokeInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Init.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->rAlpha = 0; + this->rScale = ABS_ALT(initParams->scale); + if (initParams->scale < 0) { + this->rScrollX = 1; + this->rScrollY = 2; + } else { + this->rScrollX = 3; + this->rScrollY = 15; + } + this->life = 50; + this->draw = EffectSsIceSmoke_Draw; + this->update = EffectSsIceSmoke_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Update.s") +void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, this->rAlpha); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->rScrollX * this->life, this->rScrollY * this->life, + 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + scale = this->rScale * 0.0001f; + Matrix_Scale(scale, scale, 1.0f, MTXMODE_APPLY); + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffIceSmokeDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->life < 10) { + Math_StepToS(&this->rAlpha, 0, 10); + } else if (this->rAlpha < 100) { + this->rAlpha += 10; + } +} From 689ef2fe0b919f21cc557373bb2a3a662fb5e028 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:18:54 -0700 Subject: [PATCH 34/53] Effect Icepiece OK (#839) * OK * Final cleanup * format * PR plus forgot to rename Matrix_RotateY --- assets/xml/objects/gameplay_keep.xml | 2 +- spec | 3 +- .../z_eff_ss_ice_piece.c | 71 +++++++++++++++++-- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 969954b32..e1a35f83b 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1110,7 +1110,7 @@ - + diff --git a/spec b/spec index 3ca89286a..4991f66a7 100644 --- a/spec +++ b/spec @@ -1930,8 +1930,7 @@ beginseg name "ovl_Effect_Ss_Ice_Piece" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.data.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c index 5bd800a20..0fa12d248 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c @@ -1,27 +1,84 @@ /* * File: z_eff_ss_ice_piece.c * Overlay: ovl_Effect_Ss_Ice_Piece - * Description: + * Description: Ice Shards */ #include "z_eff_ss_ice_piece.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rLifespan regs[0] +#define rYaw regs[1] +#define rPitch regs[2] +#define rRotSpeed regs[3] +#define rScale regs[4] #define PARAMS ((EffectSsIcePieceInitParams*)initParamsx) -s32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; -#endif +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIcePieceInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Init.s") + this->pos = initParams->pos; + this->vec = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->draw = EffectSsIcePiece_Draw; + this->update = EffectSsIcePiece_Update; + this->rLifespan = initParams->life; + this->rScale = initParams->scale * 100.0f; + this->rYaw = Math_FAtan2F(initParams->velocity.z, initParams->velocity.x); + this->rPitch = 0; + this->rRotSpeed = + ((fabsf(initParams->velocity.x) + fabsf(initParams->velocity.y)) * 100.0f) * (Rand_ZeroFloat(1.0f) + 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Update.s") +void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + f32 scale = this->rScale * 0.01f; + u32 frames = globalCtx->state.frames; + f32 alpha; + + OPEN_DISPS(gfxCtx); + + if ((this->rLifespan > 0) && (this->life < (this->rLifespan >> 1))) { + alpha = (this->life * 2.0f) / this->rLifespan; + alpha *= 255.0f; + } else { + alpha = 255.0f; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (s32)alpha & 0xFF); + func_800BCC68(&this->pos, globalCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames % 256, 0x20, 0x10, 1, 0, (2 * frames) % 256, 0x40, + 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragmentDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rPitch += this->rRotSpeed; + this->velocity.x *= 0.85f; + this->velocity.y *= 0.85f; + this->velocity.z *= 0.85f; +} From 67345d9be5119b4ceb69d796aa980acb25d1cab1 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:28:48 -0300 Subject: [PATCH 35/53] z_bg_astr_bombwall decompiled (#841) * z_bg_astr_bombwall decompiled * review fixes * formatting * pr review fixes * PR review fixes * PR review fixes Co-authored-by: SonicDcer --- include/PR/gbi.h | 1 + spec | 3 +- .../ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c | 199 +++++++++++++++--- .../ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h | 15 +- undefined_syms.txt | 7 - 5 files changed, 179 insertions(+), 46 deletions(-) diff --git a/include/PR/gbi.h b/include/PR/gbi.h index fa27a5f11..f7b249af8 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -284,6 +284,7 @@ #define G_TEXTURE_GEN 0x00040000 #define G_TEXTURE_GEN_LINEAR 0x00080000 #define G_LOD 0x00100000 /* NOT IMPLEMENTED */ +#define G_LIGHTING_POSITIONAL 0x00400000 #if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) # define G_CLIPPING 0x00800000 #else diff --git a/spec b/spec index 4991f66a7..1e34c3bf2 100644 --- a/spec +++ b/spec @@ -5002,8 +5002,7 @@ beginseg name "ovl_Bg_Astr_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.o" - include "build/data/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall.data.o" - include "build/data/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c index f2608b583..1e4a9b3d0 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_astr_bombwall.h" +#include "objects/object_astr_obj/object_astr_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,13 @@ void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgAstrBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C0A378(BgAstrBombwall* this); +void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Astr_Bombwall_InitVars = { ACTOR_BG_ASTR_BOMBWALL, ACTORCAT_BG, @@ -28,59 +35,191 @@ const ActorInit Bg_Astr_Bombwall_InitVars = { (ActorFunc)BgAstrBombwall_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80C0A620[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 0.0f, 3.0f }, { 70.0f, 0.0f, 3.0f }, { -70.0f, 200.0f, 3.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 0.0f, 3.0f }, { 70.0f, 200.0f, 3.0f }, { -70.0f, 200.0f, 3.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80C0A698 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80C0A620, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C0A6A8[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -#endif +void BgAstrBombwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot, ColliderTris* collider) { + s32 i; + s32 j; + Vec3f sp54[3]; -extern ColliderTrisElementInit D_80C0A620[2]; -extern ColliderTrisInit D_80C0A698; -extern InitChainEntry D_80C0A6A8[]; + Matrix_RotateYS(rot->y, MTXMODE_NEW); + Matrix_RotateXS(rot->x, MTXMODE_APPLY); + Matrix_RotateZS(rot->z, MTXMODE_APPLY); -extern UNK_TYPE D_06002178; -extern UNK_TYPE D_06002380; -extern UNK_TYPE D_06002498; + for (i = 0; i < init->count; i++) { + for (j = 0; j < 3; j++) { // https://decomp.me/scratch/JrEnl + Matrix_MultVec3f(&(init->elements + i)->dim.vtx[j], &sp54[j]); //! FAKE MATCH: + Math_Vec3f_Sum(&sp54[j], pos, &sp54[j]); + } + Collider_SetTrisVertices(collider, i, &sp54[0], &sp54[1], &sp54[2]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C09ED0.s") +void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_astr_obj_Colheader_002498); + Collider_InitTris(globalCtx, &this->collider); + if (Flags_GetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + BgAstrBombwall_InitCollider(&sTrisInit, &this->dyna.actor.world.pos, &this->dyna.actor.shape.rot, &this->collider); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + func_80C0A378(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Destroy.s") +void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A120.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A378.s") +void func_80C0A120(BgAstrBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f vec; + Vec3f pos; + s16 var_v0; + Vec3f velocity; + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A38C.s") + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + for (i = 0; i < 30; i++) { + vec.x = Rand_Centered() * 140.0f; + vec.y = Rand_ZeroOne() * 200.0f; + vec.z = 0.0f; + Matrix_MultVec3f(&vec, &pos); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &pos, &pos); + func_800BBFB0(globalCtx, &pos, 50.0f, 2, Rand_ZeroOne() * 120.0f + 20.0f, Rand_ZeroOne() * 240.0f + 20.0f, 0); + velocity.x = Rand_ZeroOne() * 2.5f; + velocity.y = (Rand_ZeroOne() * 2.5f) + 1.0f; + velocity.z = Rand_ZeroOne() * 2.5f; + rand = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A400.s") + if (rand < 0.2f) { + var_v0 = 0x60; + } else if (rand < 0.6f) { + var_v0 = 0x40; + } else { + var_v0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -260, var_v0, 20, 0, 0, 10, 0, 0, 50, -1, + OBJECT_ASTR_OBJ, object_astr_obj_DL_002178); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A418.s") +void func_80C0A378(BgAstrBombwall* this) { + this->actionFunc = func_80C0A38C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A458.s") +void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Flags_SetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + func_80C0A400(this, globalCtx); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A4BC.s") +void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80C0A418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Update.s") +void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + func_80C0A458(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Draw.s") +void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80C0A120(this, globalCtx); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80C0A4BC; +} + +void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx) { +} + +void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgAstrBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgAstrBombwall_Draw(Actor* thixs, GlobalContext* globalCtx) { + { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(&opa[0], &sSetupDL[25 * 6]); + gSPMatrix(&opa[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSetGeometryMode(&opa[2], G_LIGHTING_POSITIONAL); + gSPDisplayList(&opa[3], object_astr_obj_DL_002380); + POLY_OPA_DISP = &opa[4]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + { + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + xlu = POLY_XLU_DISP; + gSPDisplayList(&xlu[0], &sSetupDL[25 * 6]); + gSPMatrix(&xlu[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSetGeometryMode(&xlu[2], G_LIGHTING_POSITIONAL); + gSPDisplayList(&xlu[3], object_astr_obj_DL_0022E0); + POLY_XLU_DISP = &xlu[4]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h index 89b891f9b..413f14cdd 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h @@ -5,15 +5,16 @@ struct BgAstrBombwall; +#define BGASTRBOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, GlobalContext*); - typedef struct BgAstrBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgAstrBombwallActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xDC]; -} BgAstrBombwall; // size = 0x23C - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgAstrBombwallActionFunc actionFunc; + /* 0x160 */ ColliderTris collider; + /* 0x180 */ ColliderTrisElement colliderElements[2]; + /* 0x238 */ s16 cutscenes[1]; +} BgAstrBombwall; extern const ActorInit Bg_Astr_Bombwall_InitVars; #endif // Z_BG_ASTR_BOMBWALL_H diff --git a/undefined_syms.txt b/undefined_syms.txt index b0a275ace..2cc3b09a5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -540,13 +540,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// ovl_Bg_Astr_Bombwall - -D_06002178 = 0x06002178; -D_060022E0 = 0x060022E0; -D_06002380 = 0x06002380; -D_06002498 = 0x06002498; - // ovl_Bg_Botihasira D_06000638 = 0x06000638; From ab7625db65e66c4a3b67233dce8a664b410a5761 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Sun, 19 Jun 2022 15:36:07 -0700 Subject: [PATCH 36/53] `DmZl` OK and some docs of `object_zl4` (Child Zelda used in one cutscene) (#834) * DmZl: start * DmZl: progress * DmZl4: progress * DmZl: OK * DmZl: data integrated * DmZl: object docs * DmZl: more object docs * DmZl: more docs * DmZl: Some Zl4 animations * ObjectZl4: docs * DmZl: formater pass * DmZl: more docs * DmZl: docs * DmZl: params documentation * Apply suggestions from code review Co-authored-by: Derek Hensley * DmZl: requested changes, minor fixes, formater pass * Update src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c Co-authored-by: Tom Overton * Update assets/xml/objects/object_zl4.xml Co-authored-by: Tom Overton * DmZl: some requested changes * DmZl: Change Eye Texture names for accuracy, formatter pass * DmZl: Eye texture indexes specified * DmZl: fixed struct variable names * DmZl: some requested changes * DmZl: removed comment * DmZl: change to unused index * DmZl: changed some xml comments * DmZl: requested changes 1 * Update src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c Co-authored-by: Derek Hensley * DmZl: fixing issues, formatter pass * DmZl: moved switch case * DmZl: fixed object reference, wrong file * Update src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c Co-authored-by: EllipticEllipsis * Update assets/xml/objects/object_zl4.xml Co-authored-by: EllipticEllipsis * DmZl: mouth and eye state comments Co-authored-by: Isghj8 Co-authored-by: Derek Hensley Co-authored-by: Tom Overton Co-authored-by: EllipticEllipsis --- assets/xml/objects/object_zl4.xml | 281 ++++++++++++++---------- spec | 3 +- src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c | 273 +++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h | 20 +- tools/disasm/functions.txt | 12 +- 5 files changed, 440 insertions(+), 149 deletions(-) diff --git a/assets/xml/objects/object_zl4.xml b/assets/xml/objects/object_zl4.xml index dafdef8cd..65596c370 100644 --- a/assets/xml/objects/object_zl4.xml +++ b/assets/xml/objects/object_zl4.xml @@ -1,125 +1,164 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 1e34c3bf2..d43222b06 100644 --- a/spec +++ b/spec @@ -2704,8 +2704,7 @@ beginseg name "ovl_Dm_Zl" compress include "build/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.o" - include "build/data/ovl_Dm_Zl/ovl_Dm_Zl.data.o" - include "build/data/ovl_Dm_Zl/ovl_Dm_Zl.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Zl/ovl_Dm_Zl_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c index fc9d21b3d..a4c285233 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -1,7 +1,7 @@ /* * File: z_dm_zl.c * Overlay: ovl_Dm_Zl - * Description: Child Zelda (Cutscenes) + * Description: Child Zelda (Re-learning Song of Time cutscene) */ #include "z_dm_zl.h" @@ -15,9 +15,8 @@ void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmZl_Update(Actor* thisx, GlobalContext* globalCtx); void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A382FC(DmZl* this, GlobalContext* globalCtx); +void DmZl_DoNothing(DmZl* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Zl_InitVars = { ACTOR_DM_ZL, ACTORCAT_ITEMACTION, @@ -30,27 +29,269 @@ const ActorInit Dm_Zl_InitVars = { (ActorFunc)DmZl_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gDmZl4FacingAwayHandsOverEmblemLoop, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4TurningAround2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4HandsOverEmblemLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4GivingItemStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4GivingItemLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4RaisingOcarinaToPlayAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4PlayingOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, +}; -extern UNK_TYPE D_0600DE08; -extern UNK_TYPE D_0600E038; +typedef enum { + /* 0 */ ZELDA_ANIM_FACING_AWAY, + /* 1 */ ZELDA_ANIM_TURNING_TOWARD_PLAYER, + /* 2 */ ZELDA_ANIM_FACING_PLAYER, + /* 3 */ ZELDA_ANIM_GIVING_OCARINA_START, + /* 4 */ ZELDA_ANIM_GIVING_OCARINA, + /* 5 */ ZELDA_ANIM_PLAYING_OCARINA_START, + /* 6 */ ZELDA_ANIM_PLAYING_OCARINA, + /* 7 */ ZELDA_ANIM_MAX, +} DmZlAnimations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38190.s") +static TexturePtr sMouthTextures[] = { + gZl4MouthNeutralTex, + gZl4MouthOpenSmilingTex, + gZl4MouthFrowningTex, + gZl4MouthOpenTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Init.s") +typedef enum { + /* 0 */ ZELDA_MOUTH_NEUTRAL, + /* 1 */ ZELDA_MOUTH_SMILING, + /* 2 */ ZELDA_MOUTH_FROWNING, + /* 3 */ ZELDA_MOUTH_OPEN, +} DmZlMouthTextures; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Destroy.s") +static TexturePtr sEyeTextures[] = { + gDmZl4EyeOpenNormalTex, + gDmZl4EyeHalfTex, + gDmZl4EyeClosedTex, + gDmZl4EyeWideTex, + gDmZl4EyeHappyTex, + gDmZl4EyeOpenLookingLeftTex, + gDmZl4EyeOpenLookingRightTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A382FC.s") +typedef enum { + /* 0 */ ZELDA_EYE_OPEN_NORMAL, + /* 1 */ ZELDA_EYE_BLINKING, + /* 2 */ ZELDA_EYE_CLOSED, + /* 3 */ ZELDA_EYE_WIDE, + /* 4 */ ZELDA_EYE_HAPPY, + /* 5 */ ZELDA_EYE_OPEN_LOOKING_LEFT, + /* 6 */ ZELDA_EYE_OPEN_LOOKING_RIGHT, +} DmZlEyeTextures; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3830C.s") +// Unused in MM +typedef enum { + /* 0 */ ZELDA_EYE_STATE_NORMAL, + /* 1 */ ZELDA_EYE_STATE_CLOSED, + /* 2 */ ZELDA_EYE_STATE_LOOKING_LEFT, + /* 3 */ ZELDA_EYE_STATE_LOOKING_RIGHT, + /* 4 */ ZELDA_EYE_STATE_WIDE, + /* 5 */ ZELDA_EYE_STATE_HAPPY, + /* 6 */ ZELDA_EYE_STATE_CLOSED2, +} DmZlEyeStates; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38468.s") +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmZl_ChangeAnimation(SkelAnime* skelAnime, AnimationInfo animation[], u16 unusedExtraOffset) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Update.s") + animation += unusedExtraOffset; + endFrame = (animation->frameCount < 0.0f) ? Animation_GetLastFrame(animation->animation) : animation->frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3862C.s") + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, endFrame, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38648.s") +void DmZl_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmZl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Draw.s") + this->animationIndex = ZELDA_ANIM_FACING_AWAY; + this->unk_2BA = 0; + this->actor.targetArrowOffset = 1000.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + // these three set to NULL should mean they are dynamically allocated + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZl4Skeleton, NULL, NULL, NULL, 0); + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = DmZl_DoNothing; +} + +void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmZl_DoNothing(DmZl* this, GlobalContext* globalCtx) { +} + +void DmZl_UpdateCutscene(DmZl* this, GlobalContext* globalCtx) { + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 0x66)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x66); + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + s16 nextAnimationIndex = ZELDA_ANIM_FACING_AWAY; + + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + default: + case 1: + break; + case 2: + nextAnimationIndex = ZELDA_ANIM_TURNING_TOWARD_PLAYER; + break; + case 3: + nextAnimationIndex = ZELDA_ANIM_GIVING_OCARINA_START; + break; + case 4: + nextAnimationIndex = ZELDA_ANIM_PLAYING_OCARINA_START; + break; + } + + if (nextAnimationIndex != this->animationIndex) { + this->animationIndex = nextAnimationIndex; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + actionIndex = this->animationIndex; + + if ((actionIndex == ZELDA_ANIM_TURNING_TOWARD_PLAYER) || (actionIndex == ZELDA_ANIM_GIVING_OCARINA_START) || + (actionIndex == ZELDA_ANIM_PLAYING_OCARINA_START)) { + // these animations don't loop at the end, they lead into the next animation + this->animationIndex++; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } +} + +/** + * Updates the eye blinking and state, and mouth textures. + */ +void DmZl_UpdateFace(DmZl* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else { + this->blinkTimer = 0; + } + + if (this->blinkTimer < 3) { + this->eyeTextureIndexRight = this->blinkTimer; + this->eyeTextureIndexLeft = this->blinkTimer; + } + + // nextEyeState is never changed by this actor in MM, only ZELDA_EYE_STATE_NORMAL used. + switch (this->nextEyeState) { + case ZELDA_EYE_STATE_NORMAL: + if (this->blinkTimer == 0) { + this->blinkTimer = Rand_S16Offset(30, 30); + } + break; + case ZELDA_EYE_STATE_CLOSED: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } + break; + case ZELDA_EYE_STATE_LOOKING_LEFT: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = ZELDA_EYE_OPEN_LOOKING_LEFT; + this->eyeTextureIndexRight = ZELDA_EYE_OPEN_LOOKING_RIGHT; + } + break; + case ZELDA_EYE_STATE_LOOKING_RIGHT: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = ZELDA_EYE_OPEN_LOOKING_RIGHT; + this->eyeTextureIndexRight = ZELDA_EYE_OPEN_LOOKING_LEFT; + } + break; + case ZELDA_EYE_STATE_WIDE: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_WIDE; + } + break; + case ZELDA_EYE_STATE_HAPPY: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_HAPPY; + } + break; + case ZELDA_EYE_STATE_CLOSED2: + if (this->blinkTimer >= 3) { + this->blinkTimer = 0; + } + break; + } + + // nextMouthState is never changed by this actor in MM, only ZELDA_MOUTH_NEUTRAL used. + switch (this->nextMouthState) { + default: + this->mouthTextureIndex = ZELDA_MOUTH_NEUTRAL; + break; + case ZELDA_MOUTH_SMILING: + this->mouthTextureIndex = ZELDA_MOUTH_SMILING; + break; + case ZELDA_MOUTH_FROWNING: + this->mouthTextureIndex = ZELDA_MOUTH_FROWNING; + break; + case ZELDA_MOUTH_OPEN: + this->mouthTextureIndex = ZELDA_MOUTH_OPEN; + break; + } + + if (this->animationIndex == ZELDA_ANIM_PLAYING_OCARINA) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } +} + +void DmZl_Update(Actor* thisx, GlobalContext* globalCtx) { + DmZl* this = THIS; + + DmZl_UpdateFace(this); + SkelAnime_Update(&this->skelAnime); + DmZl_UpdateCutscene(this, globalCtx); + this->actionFunc(this, globalCtx); +} + +s32 DmZl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmZl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmZl* this = THIS; + + if (limbIndex == ZL4_LIMB_RIGHT_HAND) { + if ((this->animationIndex >= ZELDA_ANIM_GIVING_OCARINA_START) && + (this->animationIndex <= ZELDA_ANIM_PLAYING_OCARINA)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gDmZl4OcarinaDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmZl* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIndexRight])); + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIndexLeft])); + + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sMouthTextures[this->mouthTextureIndex])); + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmZl_OverrideLimbDraw, DmZl_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h index c3b985850..ec3e44296 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h @@ -2,16 +2,28 @@ #define Z_DM_ZL_H #include "global.h" +#include "objects/object_zl4/object_zl4.h" struct DmZl; typedef void (*DmZlActionFunc)(struct DmZl*, GlobalContext*); typedef struct DmZl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; - /* 0x0260 */ DmZlActionFunc actionFunc; - /* 0x0264 */ char unk_264[0x70]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[ZL4_LIMB_MAX]; // these tables are not referenced directly, loaded dynamically + /* 0x1F4 */ Vec3s morphTable[ZL4_LIMB_MAX]; + /* 0x260 */ DmZlActionFunc actionFunc; + /* 0x264 */ ColliderCylinder collider; // unused, assumed to be here based on OoT documentation + /* 0x2B0 */ s16 animationIndex; + /* 0x2B2 */ u8 eyeTextureIndexLeft; + /* 0x2B3 */ u8 eyeTextureIndexRight; + /* 0x2B4 */ u8 mouthTextureIndex; + /* 0x2B5 */ u8 nextEyeState; // used to control eye state, but not set by our actor, outside of actor? + /* 0x2B6 */ u8 nextMouthState; // used to control mouth state, but not set by our actor, outside of actor? + /* 0x2B8 */ s16 blinkTimer; + /* 0x2BA */ s16 unk_2BA; // set but not used by this actor. + /* 0x2BC */ UNK_TYPE1 pad2BC[0x18]; // unused by DmZl } DmZl; // size = 0x2D4 extern const ActorInit Dm_Zl_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4307c8e37..e59790cf3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10244,15 +10244,15 @@ 0x80A37EE0:("ObjShutter_Destroy",), 0x80A37EF0:("ObjShutter_Update",), 0x80A3803C:("ObjShutter_Draw",), - 0x80A38190:("func_80A38190",), + 0x80A38190:("DmZl_ChangeAnimation",), 0x80A3822C:("DmZl_Init",), 0x80A382EC:("DmZl_Destroy",), - 0x80A382FC:("func_80A382FC",), - 0x80A3830C:("func_80A3830C",), - 0x80A38468:("func_80A38468",), + 0x80A382FC:("DmZl_DoNothing",), + 0x80A3830C:("DmZl_UpdateCutscene",), + 0x80A38468:("DmZl_UpdateFace",), 0x80A385D4:("DmZl_Update",), - 0x80A3862C:("func_80A3862C",), - 0x80A38648:("func_80A38648",), + 0x80A3862C:("DmZl_OverrideLimbDraw",), + 0x80A38648:("DmZl_PostLimbDraw",), 0x80A3869C:("DmZl_Draw",), 0x80A389A0:("func_80A389A0",), 0x80A38A68:("func_80A38A68",), From 3997776e5bf24d8cefaa0013eee6e5cee4c6d4a3 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:45:00 -0300 Subject: [PATCH 37/53] obj_boat decompiled (#842) * obj_boat decompiled * PR review fixes * pr review fixes * PR Review fixes * PR review fixes * final cleanup Co-authored-by: SonicDcer --- spec | 3 +- src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c | 161 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h | 16 +- undefined_syms.txt | 5 - 4 files changed, 161 insertions(+), 24 deletions(-) diff --git a/spec b/spec index d43222b06..5fd1d01e9 100644 --- a/spec +++ b/spec @@ -4284,8 +4284,7 @@ beginseg name "ovl_Obj_Boat" compress include "build/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.o" - include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.data.o" - include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Boat/ovl_Obj_Boat_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 880d72b3f..bda85a450 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -5,6 +5,7 @@ */ #include "z_obj_boat.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,8 @@ void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx); void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B9B428(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Boat_InitVars = { ACTOR_OBJ_BOAT, ACTORCAT_BG, @@ -28,31 +30,162 @@ const ActorInit Obj_Boat_InitVars = { (ActorFunc)ObjBoat_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9B680[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -#endif +s16 func_80B9AF50(ObjBoat* this, Vec3f* arg0) { + s16 yaw; + Vec3s* temp = &this->unk_164[(s32)this->unk_15C]; -extern InitChainEntry D_80B9B680[]; + Math_Vec3s_ToVec3f(arg0, &temp[this->unk_15D]); + yaw = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg0); -extern UNK_TYPE D_06007630; -extern UNK_TYPE D_06009A88; + return ((this->unk_15D > 0) ? yaw : (yaw + 0x8000)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9AF50.s") +void ObjBoat_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + Path* path; + ObjBoat* this = THIS; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kaizoku_obj_Colheader_009A88); + if (thisx->params < 0) { + this->dyna.actor.update = func_80B9B428; + } else { + path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(thisx)]; + this->unk_163 = path->count - 1; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + this->unk_15D = 1; + this->dyna.actor.world.pos.x = this->unk_164[this->unk_15C].x; + this->dyna.actor.world.pos.z = this->unk_164[this->unk_15C].z; + this->dyna.actor.shape.rot.y = func_80B9AF50(this, &sp24); + this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; + this->unk_15D = -this->unk_15D; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Destroy.s") +void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBoat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B124.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Update.s") +void func_80B9B124(ObjBoat* this) { + this->unk_160 += 1000; + this->dyna.actor.world.pos.y = Math_SinS(this->unk_160) + this->dyna.actor.home.pos.y; + this->dyna.actor.shape.rot.x = Math_SinS(this->unk_160) * 100.0f; + this->dyna.actor.shape.rot.z = Math_SinS(this->unk_160 * 2) * 50.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B428.s") +void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBoat* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 temp = DynaPolyActor_IsInRidingMovingState(&this->dyna); + f32 sp3C = 0.0f; + s16 sp3A = this->dyna.actor.shape.rot.y; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Draw.s") + if ((temp != 0) || ((DynaPolyActor_IsInRidingFallingState(&this->dyna)))) { + if ((this->unk_15F == 0) && (OBJBOAT_GET_4000(thisx) || ((temp != 0) && (this->unk_15C == this->unk_15E)))) { + this->unk_15D = -this->unk_15D; + if (this->unk_15D > 0) { + this->unk_15E = this->unk_163; + } else { + this->unk_15E = 0; + } + this->unk_15F = 60; + } + } else if (this->dyna.actor.speedXZ == 0.0f) { + if (this->unk_15F != 0) { + this->unk_15F--; + } + } + if (this->unk_15C != this->unk_15E) { + sp3A = func_80B9AF50(this, &sp2C); + if (Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp2C) < 200.0f) { + this->unk_15C += this->unk_15D; + if (this->unk_15C == this->unk_15E) { + if (OBJBOAT_GET_4000(thisx)) { + this->unk_15C = 0; + } else if (this->dyna.actor.speedXZ == 0.0f) { + this->unk_15C = 0; + this->unk_15D = -1; + } + } + } else { + sp3C = this->unk_15D * (OBJBOAT_GET_4000(thisx) ? 5.0f : 3.0f); + } + } + if (player->csMode != 0x1A) { + Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, sp3A, (s16)(s32)(fabsf(this->dyna.actor.speedXZ) * 40.0f)); + this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; + Math_StepToF(&this->dyna.actor.speedXZ, sp3C, 0.05f); + Actor_MoveWithGravity(&this->dyna.actor); + if (this->dyna.actor.speedXZ != 0.0f) { + func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); + } + } + func_80B9B124(this); +} + +void func_80B9B428(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjBoat* this = THIS; + + if (Cutscene_CheckActorAction(globalCtx, 511)) { + CsCmdActorAction* actionIndex = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 511)]; + if (this->unk_15F != actionIndex->action) { + this->dyna.actor.shape.rot.x = actionIndex->urot.x; + if (actionIndex->action != 1) { + Path* path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(&this->dyna.actor)]; + + if (actionIndex->action == 3) { + path = &globalCtx->setupPathList[path->unk1]; + } + this->unk_163 = path->count; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->unk_164); + this->dyna.actor.speedXZ = actionIndex->urot.z * (45.0f / 0x2000); + this->unk_164++; + this->unk_15C = 1; + } + this->unk_15F = actionIndex->action; + } else { + if (actionIndex->action != 1) { + Vec3f vec; + f32 step; + + Math_Vec3s_ToVec3f(&vec, this->unk_164); + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &vec, this->dyna.actor.speedXZ); + if ((this->unk_15C < this->unk_163) && (step < this->dyna.actor.speedXZ)) { + this->unk_164++; + this->unk_15C++; + } + } + if (actionIndex->action != 3) { + func_80B9B124(this); + if (actionIndex->action == 2) { + func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); + } + } else { + this->dyna.actor.shape.rot.y += 0x7D0; + this->dyna.actor.shape.rot.x += 0x3E8; + this->dyna.actor.shape.rot.z += 0x1F4; + } + } + } +} + +void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBoat* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_kaizoku_obj_DL_007630); +} diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h index 988dd6a2b..110b89dde 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -3,12 +3,22 @@ #include "global.h" +#define OBJBOAT_GET_PATH(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJBOAT_GET_4000(thisx) ((thisx)->params & 0x4000) + struct ObjBoat; typedef struct ObjBoat { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x24]; -} ObjBoat; // size = 0x168 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk_15C; + /* 0x15D */ s8 unk_15D; + /* 0x15E */ u8 unk_15E; + /* 0x15F */ u8 unk_15F; + /* 0x160 */ s16 unk_160; + /* 0x162 */ UNK_TYPE1 pad_162; + /* 0x163 */ u8 unk_163; + /* 0x164 */ Vec3s* unk_164; +} ObjBoat; extern const ActorInit Obj_Boat_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 2cc3b09a5..b78891090 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1552,11 +1552,6 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Boat - -D_06007630 = 0x06007630; -D_06009A88 = 0x06009A88; - // ovl_Obj_Chikuwa D_06000D10 = 0x06000D10; From aea2e67f79323b3f942e10e919c860aa8bfc66fa Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:52:45 -0300 Subject: [PATCH 38/53] z_en_sc_ruppe decompiled (#843) * z_en_sc_ruppe decompiled * PR Review fixes * PR Review fixes * PR review fixes * pr review fixes * pr review fixes * Ruppe -> Rupee Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c | 164 ++++++++++++++++-- .../actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h | 16 +- 3 files changed, 163 insertions(+), 20 deletions(-) diff --git a/spec b/spec index 5fd1d01e9..74362de6b 100644 --- a/spec +++ b/spec @@ -4627,8 +4627,7 @@ beginseg name "ovl_En_Sc_Ruppe" compress include "build/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.o" - include "build/data/ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe.data.o" - include "build/data/ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe.reloc.o" + include "build/src/overlays/actors//ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index 357d41ba7..f568b1c41 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -5,6 +5,7 @@ */ #include "z_en_sc_ruppe.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,10 +16,13 @@ void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx); void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx); void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx); -#if 0 +typedef struct { + /* 0x0 */ TexturePtr tex; + /* 0x4 */ s16 amount; +} RuppeInfo; + const ActorInit En_Sc_Ruppe_InitVars = { ACTOR_EN_SC_RUPPE, ACTORCAT_NPC, @@ -31,29 +35,157 @@ const ActorInit En_Sc_Ruppe_InitVars = { (ActorFunc)EnScRuppe_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD6E40 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +RuppeInfo sRupeeInfo[] = { + { gameplay_keep_Tex_061FC0, 1 }, // Green rupee + { gameplay_keep_Tex_061FE0, 5 }, // Blue rupee + { gameplay_keep_Tex_062000, 20 }, // Red rupee + { gameplay_keep_Tex_062040, 200 }, // Orange rupee + { gameplay_keep_Tex_062020, 50 }, // Purple rupee + { gameplay_keep_Tex_062060, 10 }, // (unused) +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnScRuppe_UpdateCollision(EnScRuppe* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 0.0f, 4); +} -extern ColliderCylinderInit D_80BD6E40; +s32 func_80BD697C(s16 ruppeIndex) { + switch (ruppeIndex) { + case RUPEE_GREEN: + if (gSaveContext.save.weekEventReg[53] & 4) { + gSaveContext.save.weekEventReg[53] &= (u8)~4; + return true; + } + break; + case RUPEE_BLUE: + if (gSaveContext.save.weekEventReg[53] & 0x80) { + gSaveContext.save.weekEventReg[53] &= (u8)~0x80; + return true; + } + break; + case RUPEE_RED: + if (gSaveContext.save.weekEventReg[54] & 1) { + gSaveContext.save.weekEventReg[54] &= (u8)~1; + return true; + } + break; + case RUPEE_ORANGE: + if (gSaveContext.save.weekEventReg[54] & 2) { + gSaveContext.save.weekEventReg[54] &= (u8)~2; + return true; + } + break; + case RUPEE_PURPLE: + if (gSaveContext.save.weekEventReg[54] & 4) { + gSaveContext.save.weekEventReg[54] &= (u8)~4; + return true; + } + break; + case RUPEE_UNUSED: + if ((gSaveContext.save.weekEventReg[54] & 8)) { + gSaveContext.save.weekEventReg[54] &= (u8)~8; + return true; + } + break; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6910.s") +void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->ruppeDisplayTime = 0; + this->actor.gravity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + func_801159EC(sRupeeInfo[this->ruppeIndex].amount); + this->actionFunc = func_80BD6B18; + } + this->actor.shape.rot.y += 0x1F4; + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD697C.s") +void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6A8C.s") + if (this->ruppeDisplayTime > 30) { + if (func_80BD697C(this->ruppeIndex)) { + Actor_MarkForDeath(&this->actor); + } + } else { + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6B18.s") + this->ruppeDisplayTime++; + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y += 40.0f; + scale = (30.0f - this->ruppeDisplayTime) * 0.001f; + Actor_SetScale(&this->actor, scale); + } + this->actor.shape.rot.y += 0x3E8; + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Init.s") +void EnScRuppe_Init(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Destroy.s") + Collider_InitCylinder(globalCtx, collider); + Collider_InitAndSetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.03f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + this->ruppeIndex = SCRUPPE_GET_TYPE(thisx); + if ((this->ruppeIndex < RUPEE_GREEN) || (this->ruppeIndex >= RUPEE_UNUSED)) { + this->ruppeIndex = RUPEE_GREEN; + } + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80BD6A8C; + this->actor.gravity = -0.5f; + this->actor.shape.yOffset = 700.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Update.s") +void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Draw.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; + + this->actionFunc(this, globalCtx); + EnScRuppe_UpdateCollision(this, globalCtx); +} + +void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32* pad; + EnScRuppe* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeInfo[this->ruppeIndex].tex)); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h index ad9aa6915..13140be43 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h @@ -3,17 +3,29 @@ #include "global.h" +#define SCRUPPE_GET_TYPE(thisx) ((thisx)->params & 0x1F) + struct EnScRuppe; typedef void (*EnScRuppeActionFunc)(struct EnScRuppe*, GlobalContext*); typedef struct EnScRuppe { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnScRuppeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x4]; + /* 0x194 */ s16 ruppeDisplayTime; + /* 0x196 */ s16 ruppeIndex; } EnScRuppe; // size = 0x198 +typedef enum { + /* 0 */ RUPEE_GREEN, + /* 1 */ RUPEE_BLUE, + /* 2 */ RUPEE_RED, + /* 3 */ RUPEE_ORANGE, + /* 4 */ RUPEE_PURPLE, + /* 5 */ RUPEE_UNUSED, +} RupeeType; + extern const ActorInit En_Sc_Ruppe_InitVars; #endif // Z_EN_SC_RUPPE_H From 9e6bc5db8b664176f8e61ad955638e860a7cd400 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:00:03 -0300 Subject: [PATCH 39/53] ovl_en_hata decompiled (#844) * z_en_hara progress * ovl_En_Hata Decompiled * PR review fixes * pr review fixes * PR review fixes * format * PR review fixes Co-authored-by: SonicDcer --- spec | 3 +- src/overlays/actors/ovl_En_Hata/z_en_hata.c | 76 ++++++++++++++++++--- src/overlays/actors/ovl_En_Hata/z_en_hata.h | 13 +++- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 6 -- 5 files changed, 79 insertions(+), 21 deletions(-) diff --git a/spec b/spec index 74362de6b..86ed09a52 100644 --- a/spec +++ b/spec @@ -877,8 +877,7 @@ beginseg name "ovl_En_Hata" compress include "build/src/overlays/actors/ovl_En_Hata/z_en_hata.o" - include "build/data/ovl_En_Hata/ovl_En_Hata.data.o" - include "build/data/ovl_En_Hata/ovl_En_Hata.reloc.o" + include "build/src/overlays/actors/ovl_En_Hata/ovl_En_Hata_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index 10c8df4e7..1d7914d5a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -5,6 +5,7 @@ */ #include "z_en_hata.h" +#include "objects/object_hata/object_hata.h" #define FLAGS 0x00000000 @@ -12,10 +13,9 @@ void EnHata_Init(Actor* thisx, GlobalContext* globalCtx); void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHata_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2); void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hata_InitVars = { ACTOR_EN_HATA, ACTORCAT_PROP, @@ -28,16 +28,74 @@ const ActorInit En_Hata_InitVars = { (ActorFunc)EnHata_Draw, }; -#endif +void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; + s32 rand; + f32 endFrame; -extern UNK_TYPE D_06002FD0; + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hata_Skel_002FD0, NULL, this->jointTable, this->morphTable, + OBJECT_HATA_LIMB_MAX); + endFrame = Animation_GetLastFrame(&object_hata_Anim_000444); + Animation_Change(&this->skelAnime, &object_hata_Anim_000444, 1.0f, 0.0f, endFrame, ANIMMODE_LOOP, 0.0f); + rand = Rand_ZeroFloat(endFrame); + this->skelAnime.curFrame = rand; + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hata_Colheader_0000C0); + Actor_SetScale(&this->dyna.actor, 0.013f); + this->dyna.actor.uncullZoneScale = 500.0f; + this->dyna.actor.uncullZoneDownward = 500.0f; + this->dyna.actor.uncullZoneForward = 2200.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Init.s") +void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Update.s") +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHata* this = THIS; + Vec3f sp34; + f32 phi_fv0; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/func_8089EC68.s") + phi_fv0 = CLAMP(globalCtx->envCtx.windSpeed / 120.0f, 0.0f, 1.0f); + this->skelAnime.playSpeed = 2.75f * phi_fv0; + this->skelAnime.playSpeed += 1.0f + Rand_ZeroFloat(1.25f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Draw.s") + sp34.x = globalCtx->envCtx.windDir.x; + sp34.y = globalCtx->envCtx.windDir.y + ((1.0f - phi_fv0) * 240.0f); + sp34.y = CLAMP(sp34.y, -118.0f, 118.0f); + sp34.z = globalCtx->envCtx.windDir.z; + + phi_fv0 = CLAMP(phi_fv0, 0.1f, 0.4f); + Math_ApproachF(&this->unk_2A4.x, sp34.x, phi_fv0, 1000.0f); + Math_ApproachF(&this->unk_2A4.y, sp34.y, phi_fv0, 1000.0f); + Math_ApproachF(&this->unk_2A4.z, sp34.z, phi_fv0, 1000.0f); + + sp34 = this->unk_2A4; + this->unk_29C = Math_Vec3f_Pitch(&gZeroVec3f, &sp34); + this->unk_29C = -this->unk_29C; + this->unk_2A0 = Math_Vec3f_Yaw(&gZeroVec3f, &sp34); + this->unk_2A0 += -0x4000; + SkelAnime_Update(&this->skelAnime); +} + +s32 EnHata_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHata* this = THIS; + + if ((limbIndex == OBJECT_HATA_LIMB_04) || (limbIndex == OBJECT_HATA_LIMB_0D)) { + rot->y += this->unk_29C; + rot->z += this->unk_2A0; + } + return false; +} + +void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHata_OverrideLimbDraw, NULL, + &this->dyna.actor); +} diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.h b/src/overlays/actors/ovl_En_Hata/z_en_hata.h index f80403933..fc96f302a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.h +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.h @@ -2,13 +2,20 @@ #define Z_EN_HATA_H #include "global.h" +#include "objects/object_hata/object_hata.h" struct EnHata; typedef struct EnHata { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x16C]; -} EnHata; // size = 0x2B0 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[OBJECT_HATA_LIMB_MAX]; + /* 0x21E */ Vec3s morphTable[OBJECT_HATA_LIMB_MAX]; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ UNK_TYPE1 pad_29E[2]; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A4 */ Vec3f unk_2A4; +} EnHata; /* size = 0x2B0 */ extern const ActorInit En_Hata_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e59790cf3..52f48248c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5605,7 +5605,7 @@ 0x8089E8E0:("EnHata_Init",), 0x8089E9DC:("EnHata_Destroy",), 0x8089EA10:("EnHata_Update",), - 0x8089EC68:("func_8089EC68",), + 0x8089EC68:("EnHata_OverrideLimbDraw",), 0x8089ECBC:("EnHata_Draw",), 0x8089ED90:("EnZl1_Init",), 0x8089EDA0:("EnZl1_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index b78891090..10fb6a39a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1186,12 +1186,6 @@ D_0600A808 = 0x0600A808; D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Hata - -D_060000C0 = 0x060000C0; -D_06000444 = 0x06000444; -D_06002FD0 = 0x06002FD0; - // ovl_En_Hgo D_0600B644 = 0x0600B644; From 1ce5d136774c08d250c4b6fad473022630a334d2 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:07:13 -0300 Subject: [PATCH 40/53] z_dm_opstage decompiled (#845) * z_dm_opstage progress * z_dm_opstage decompiled * pr review fixes * pr review fixes * pr review fixes * params var removal * macro tunning + params removal * final (hopefully) * prototype was unnecessary * pr review changes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_Dm_Opstage/z_dm_opstage.c | 106 +++++++++++++++--- .../actors/ovl_Dm_Opstage/z_dm_opstage.h | 19 +++- undefined_syms.txt | 12 -- 4 files changed, 105 insertions(+), 35 deletions(-) diff --git a/spec b/spec index 86ed09a52..402f593c7 100644 --- a/spec +++ b/spec @@ -3133,8 +3133,7 @@ beginseg name "ovl_Dm_Opstage" compress include "build/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.o" - include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.data.o" - include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Opstage/ovl_Dm_Opstage_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index ef81bc467..565c14ea3 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -5,6 +5,7 @@ */ #include "z_dm_opstage.h" +#include "objects/object_keikoku_demo/object_keikoku_demo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,11 +16,8 @@ void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx); void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A9FA58(DmOpstage* this, GlobalContext* globalCtx); +void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx); -void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc); - -#if 0 const ActorInit Dm_Opstage_InitVars = { ACTOR_DM_OPSTAGE, ACTORCAT_ITEMACTION, @@ -32,26 +30,102 @@ const ActorInit Dm_Opstage_InitVars = { (ActorFunc)DmOpstage_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A9FD30[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP), }; -#endif +void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80A9FD30[]; +void DmOpstage_Init(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -extern UNK_TYPE D_06000978; -extern UNK_TYPE D_06001C98; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DmOpstage_SetupAction(this, DmOpstage_FollowCutsceneScript); + Actor_SetScale(&this->dyna.actor, 0.1f); + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_keikoku_demo_Colheader_001C98); + } + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) { + this->pos.x = this->dyna.actor.world.pos.x; + this->pos.y = this->dyna.actor.world.pos.y; + this->pos.z = this->dyna.actor.world.pos.z; + this->dyna.actor.world.pos.x = 0.0f; + this->dyna.actor.world.pos.y = 0.0f; + this->dyna.actor.world.pos.z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_SetupAction.s") +void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Init.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Destroy.s") +void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx) { + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/func_80A9FA58.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + if (Cutscene_CheckActorAction(globalCtx, 0x73)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x73); + if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { + this->dyna.actor.scale.x = 0.075f; + this->dyna.actor.scale.z = 0.3f; + } else { + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.z = 0.1f; + } + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, globalCtx, actionIndex); + } + } else if (Cutscene_CheckActorAction(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)) { + Cutscene_ActorTranslateAndYaw( + &this->dyna.actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Update.s") +void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Draw.s") + this->actionFunc(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && + (globalCtx->csCtx.frames == 480)) { + func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); + } +} + +void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; + + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) { + Matrix_Translate(this->dyna.actor.world.pos.x + this->pos.x, this->dyna.actor.world.pos.y + this->pos.y, + this->dyna.actor.world.pos.z + this->pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + } + switch (DMOPSTAGE_GET_TYPE(&this->dyna.actor)) { + case DM_OPSTAGE_TYPE_FLOOR: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_000978); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_000970); + break; + + case DM_OPSTAGE_TYPE_TREE1: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_002878); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_002870); + break; + + case DM_OPSTAGE_TYPE_TREE2: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003068); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003060); + break; + + case DM_OPSTAGE_TYPE_TREE3: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003728); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003720); + break; + } +} diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h index b0d0637e6..96fa6d31b 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -3,17 +3,26 @@ #include "global.h" +#define DMOPSTAGE_GET_TYPE(thisx) (((thisx)->params & 0xFF)) +#define DMOPSTAGE_GET_08(thisx) (((thisx)->params >> 8) & 0xFF) + struct DmOpstage; typedef void (*DmOpstageActionFunc)(struct DmOpstage*, GlobalContext*); - typedef struct DmOpstage { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ DmOpstageActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 pad_15C[0x44]; + /* 0x1A0 */ DmOpstageActionFunc actionFunc; + /* 0x1A4 */ Vec3f pos; } DmOpstage; // size = 0x1B0 +typedef enum { + /* 0 */ DM_OPSTAGE_TYPE_FLOOR, + /* 1 */ DM_OPSTAGE_TYPE_TREE1, + /* 2 */ DM_OPSTAGE_TYPE_TREE2, + /* 3 */ DM_OPSTAGE_TYPE_TREE3, +} DmOpStageTypes; + extern const ActorInit Dm_Opstage_InitVars; #endif // Z_DM_OPSTAGE_H diff --git a/undefined_syms.txt b/undefined_syms.txt index 10fb6a39a..be8e81289 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -881,18 +881,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Opstage - -D_06000970 = 0x06000970; -D_06000978 = 0x06000978; -D_06001C98 = 0x06001C98; -D_06002870 = 0x06002870; -D_06002878 = 0x06002878; -D_06003060 = 0x06003060; -D_06003068 = 0x06003068; -D_06003720 = 0x06003720; -D_06003728 = 0x06003728; - // ovl_Dm_Tsg D_06002D30 = 0x06002D30; From f0c1e17fd002fab26ccdbb5041fda67d05c3fa44 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:13:25 -0300 Subject: [PATCH 41/53] ovl_Dm_Bal decompiled (#846) * All functions match, data import problem present * * importing succeed * final clean up * fixed warnings * pr fixes * pr review fixes * PR review fix * pr review fixes * fixes Co-authored-by: SonicDcer --- spec | 3 +- src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c | 177 ++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h | 19 ++- tools/disasm/functions.txt | 4 +- 4 files changed, 178 insertions(+), 25 deletions(-) diff --git a/spec b/spec index 402f593c7..8cba55b21 100644 --- a/spec +++ b/spec @@ -5162,8 +5162,7 @@ beginseg name "ovl_Dm_Bal" compress include "build/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.o" - include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.data.o" - include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Bal/ovl_Dm_Bal_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index aa4abb91d..93845cc5c 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -15,9 +15,9 @@ void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmBal_Update(Actor* thisx, GlobalContext* globalCtx); void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C1EAC4(DmBal* this); void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Bal_InitVars = { ACTOR_DM_BAL, ACTORCAT_NPC, @@ -30,31 +30,176 @@ const ActorInit Dm_Bal_InitVars = { (ActorFunc)DmBal_Draw, }; -#endif +static AnimationInfo D_80C1F170[] = { + { &object_bal_Anim_0005FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_bal_Anim_00A7DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_bal_Anim_00B1E8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00B604, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00C498, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00C498, 1.0f, 23.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00D530, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000C78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, + { &object_bal_Anim_00CB78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, + { &object_bal_Anim_001804, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, +}; -extern UNK_TYPE D_060005FC; -extern UNK_TYPE D_06001804; +void DmBal_Init(Actor* thisx, GlobalContext* globalCtx) { + DmBal* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Init.s") + this->actor.targetMode = 1; + this->actor.uncullZoneForward = 3000.0f; + Actor_SetScale(&this->actor, 0.02f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bal_Skel_00A6D0, &object_bal_Anim_0005FC, this->jointTable, + this->morphTable, OBJECT_BAL_LIMB_MAX); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->timer = 60; + this->eyeIndex = 0; + this->unk_336 = 0; + func_80C1EAC4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Destroy.s") +void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAC4.s") +void func_80C1EAC4(DmBal* this) { + this->actionFunc = func_80C1EAD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAD8.s") +void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAE8.s") +void func_80C1EAE8(DmBal* this, GlobalContext* globalCtx) { + static u16 D_80C1F2C0 = 0x63; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EC60.s") + if (Cutscene_CheckActorAction(globalCtx, 0x238)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x238); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED0C.s") + if (D_80C1F2C0 != globalCtx->csCtx.actorActions[actionIndex]->action) { + D_80C1F2C0 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_336 = 0; + this->eyeIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 0); + break; + case 2: + this->unk_336 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 12); + break; + case 3: + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 13); + break; + } + } else if (D_80C1F2C0 == 3) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->unk_336 = 1; + } else if (Animation_OnFrame(&this->skelAnime, 29.0f)) { + this->unk_336 = 0; + this->eyeIndex = 0; + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.home.pos = this->actor.world.pos; + } else { + this->unk_336 = 0; + this->eyeIndex = 0; + D_80C1F2C0 = 0x63; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED64.s") +void func_80C1EC60(DmBal* this, GlobalContext* globalCtx) { + f32 temp_fv1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Update.s") + this->unk_338 += 0x320; + this->unk_33A += 0x3E8; + this->scale.y = this->scale.z = Math_CosS(this->unk_338) * 0.1f + 1.0f; + temp_fv1_2 = (Math_SinS(this->unk_338) * 0.1f) + 1.0f; + this->scale.x = SQ(temp_fv1_2); + this->actor.world.pos.y = this->actor.home.pos.y + (Math_SinS(this->unk_338) * 25.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EF80.s") +void func_80C1ED0C(DmBal* this) { + if (this->unk_336 == 1) { + this->eyeIndex = 1; + } else if (this->timer >= 4) { + this->timer--; + } else if (this->timer != 0) { + this->eyeIndex = 1; + this->timer--; + } else { + this->eyeIndex = 0; + this->timer = 60; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1F060.s") +void func_80C1ED64(DmBal* this, GlobalContext* globalCtx, Vec3f* arg2, Vec3f* arg3, f32 arg4) { + Actor* paper = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PAPER, arg2->x, arg2->y, arg2->z, 0, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Draw.s") + if (paper != NULL) { + paper->velocity = *arg3; + paper->gravity = arg4; + } +} + +Vec3f D_80C1F2C4 = { 0.0f, 9.0f, 0.0f }; + +void DmBal_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmBal* this = THIS; + Vec3f sp3C; + Vec3f sp30; + + if (Animation_OnFrame(&this->skelAnime, 29.0f) && (this->skelAnime.animation == &object_bal_Anim_001804)) { + sp3C = this->actor.world.pos; + sp30 = D_80C1F2C4; + sp3C.x += 7.0f * Math_SinS(this->actor.shape.rot.y); + sp3C.y += 2.5f; + sp3C.z += 7.0f * Math_CosS(this->actor.shape.rot.y); + sp30.x = Math_SinS(this->actor.shape.rot.y) * 5.0f; + sp30.z = Math_CosS(this->actor.shape.rot.y) * 5.0f; + func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.4f); + func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.5f); + } + this->actionFunc(this, globalCtx); + func_80C1EAE8(this, globalCtx); + func_80C1EC60(this, globalCtx); + func_80C1ED0C(this); + SkelAnime_Update(&this->skelAnime); +} + +s32 DmBal_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + DmBal* this = THIS; + Vec3s rots; + + if (limbIndex == 6) { + rots.x = Math_SinS(this->unk_33A) * 3640.0f; + rots.z = Math_CosS(this->unk_33A) * 3640.0f; + Matrix_RotateZYX(rots.x, 0, rots.z, MTXMODE_APPLY); + Matrix_Scale(this->scale.x, this->scale.y, this->scale.z, MTXMODE_APPLY); + Matrix_RotateZS(-rots.z, MTXMODE_APPLY); + Matrix_RotateXS(-rots.x, MTXMODE_APPLY); + } + return false; +} + +void DmBal_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 }; + +void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmBal* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmBal_OverrideLimbDraw, DmBal_PostLimbDraw, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h index 19c481ab6..1a09abb1b 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h @@ -2,17 +2,26 @@ #define Z_DM_BAL_H #include "global.h" +#include "objects/object_bal/object_bal.h" struct DmBal; typedef void (*DmBalActionFunc)(struct DmBal*, GlobalContext*); typedef struct DmBal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmBalActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1B0]; -} DmBal; // size = 0x33C + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmBalActionFunc actionFunc; + /* 0x18C */ Vec3f scale; + /* 0x198 */ s32 eyeIndex; + /* 0x262 */ Vec3s jointTable[OBJECT_BAL_LIMB_MAX]; + /* 0x19C */ Vec3s morphTable[OBJECT_BAL_LIMB_MAX]; + /* 0x328 */ UNK_TYPE1 pad_328[12]; + /* 0x334 */ s16 timer; + /* 0x336 */ s16 unk_336; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; +} DmBal; /* size = 0x33C */ extern const ActorInit Dm_Bal_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 52f48248c..87d94e6ea 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16997,8 +16997,8 @@ 0x80C1ED0C:("func_80C1ED0C",), 0x80C1ED64:("func_80C1ED64",), 0x80C1EDE4:("DmBal_Update",), - 0x80C1EF80:("func_80C1EF80",), - 0x80C1F060:("func_80C1F060",), + 0x80C1EF80:("DmBal_OverrideLimbDraw",), + 0x80C1F060:("DmBal_PostLimbDraw",), 0x80C1F078:("DmBal_Draw",), 0x80C1F3D0:("EnPaper_Init",), 0x80C1F45C:("EnPaper_Destroy",), From 8d6b4d68ad5a821c13124cb072bddb6cd46a6503 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:18:03 -0300 Subject: [PATCH 42/53] ovl_Bg_Keikoku_Saku decompiled (#847) * ovl_Bg_Keikoku_Saku decompiled * reloc change * BGKEIKOKUSAKU_GET_SWITCHFLAG name fix * pr review fixes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c | 76 ++++++++++++++++--- .../ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h | 13 ++-- undefined_syms.txt | 5 -- 4 files changed, 73 insertions(+), 24 deletions(-) diff --git a/spec b/spec index 8cba55b21..6740d7e1e 100644 --- a/spec +++ b/spec @@ -2891,8 +2891,7 @@ beginseg name "ovl_Bg_Keikoku_Saku" compress include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.o" - include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.data.o" - include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c index 0e7488a9a..24f18bb2f 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c @@ -5,6 +5,7 @@ */ #include "z_bg_keikoku_saku.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,10 @@ void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx); +void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx); +void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx); + const ActorInit Bg_Keikoku_Saku_InitVars = { ACTOR_BG_KEIKOKU_SAKU, ACTORCAT_ITEMACTION, @@ -28,21 +32,71 @@ const ActorInit Bg_Keikoku_Saku_InitVars = { (ActorFunc)BgKeikokuSaku_Draw, }; -#endif +void BgKeikokuSaku_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgKeikokuSaku* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_06001640; -extern UNK_TYPE D_06002300; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_keikoku_obj_Colheader_002300, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->switchFlag = BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx); + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.world.pos.z = 2659.0f; + } else { + this->actionFunc = func_80A5389C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Init.s") +void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A5389C.s") +void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->actionFunc = func_80A538E0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A538E0.s") +void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + this->dyna.actor.world.pos.z -= 2.0f + BREG(8); + if (this->dyna.actor.world.pos.z < (BREG(9) + 2660.0f)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + this->timer = 30; + this->actionFunc = func_80A53994; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A53994.s") +void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->actionFunc = func_80A5389C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Update.s") +void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Draw.s") + if (this->timer) { + this->timer--; + } + this->dyna.actor.world.pos.x = BREG(5) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = BREG(6) + this->dyna.actor.home.pos.y; + this->dyna.actor.world.pos.z = BREG(7) + this->dyna.actor.home.pos.z; + this->dyna.actor.scale.x = (BREG(10) / 1000.0f) + 0.1f; + this->dyna.actor.scale.y = (BREG(11) / 1000.0f) + 0.1f; + this->dyna.actor.scale.z = (BREG(12) / 1000.0f) + 0.1f; + this->actionFunc(this, globalCtx); +} + +void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_001640); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h index 6092edcb4..8fa663460 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h @@ -3,17 +3,18 @@ #include "global.h" +#define BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + struct BgKeikokuSaku; typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, GlobalContext*); typedef struct BgKeikokuSaku { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgKeikokuSakuActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; -} BgKeikokuSaku; // size = 0x164 - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKeikokuSakuActionFunc actionFunc; + /* 0x160 */ s16 switchFlag; + /* 0x162 */ s16 timer; +} BgKeikokuSaku; // Size = 0x164 extern const ActorInit Bg_Keikoku_Saku_InitVars; #endif // Z_BG_KEIKOKU_SAKU_H diff --git a/undefined_syms.txt b/undefined_syms.txt index be8e81289..64a46e14c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -644,11 +644,6 @@ D_06012700 = 0x06012700; D_06012728 = 0x06012728; D_06012788 = 0x06012788; -// ovl_Bg_Keikoku_Saku - -D_06001640 = 0x06001640; -D_06002300 = 0x06002300; - // ovl_Bg_Kin2_Bombwall D_06000128 = 0x06000128; From 2c10d510228e77368fd80efc92e5743d0416591a Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:21:44 -0300 Subject: [PATCH 43/53] ovl_Bg_Ikninside OK (#848) * ovl_Bg_Ikninside decompiled * PR review fixes * pr review fixes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_Bg_Ikninside/z_bg_ikninside.c | 132 +++++++++++++++--- .../actors/ovl_Bg_Ikninside/z_bg_ikninside.h | 12 +- undefined_syms.txt | 5 - 4 files changed, 124 insertions(+), 28 deletions(-) diff --git a/spec b/spec index 6740d7e1e..e407bad50 100644 --- a/spec +++ b/spec @@ -4936,8 +4936,7 @@ beginseg name "ovl_Bg_Ikninside" compress include "build/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.o" - include "build/data/ovl_Bg_Ikninside/ovl_Bg_Ikninside.data.o" - include "build/data/ovl_Bg_Ikninside/ovl_Bg_Ikninside.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikninside/ovl_Bg_Ikninside_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index a09bcba87..2c2244425 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikninside.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,8 @@ void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C072D0(BgIkninside* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikninside_InitVars = { ACTOR_BG_IKNINSIDE, ACTORCAT_BG, @@ -28,30 +30,128 @@ const ActorInit Bg_Ikninside_InitVars = { (ActorFunc)BgIkninside_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C076A8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x80000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static Gfx* D_80C076A0[] = { object_ikninside_obj_DL_00A748, object_ikninside_obj_DL_00A5A8 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x80000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 32, 32, 0, { 0, 0, 0 } }, }; -#endif +void BgIkninside_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; + CollisionHeader* colHeader = NULL; + s32 pad; -extern ColliderCylinderInit D_80C076A8; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->actionFunc = func_80C072D0; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_ikninside_obj_Colheader_00DE48, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (Flags_GetSwitch(globalCtx, DMIKNINSIDE_GET_SWITCH(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -extern UNK_TYPE D_0600CC78; -extern UNK_TYPE D_0600DE48; +void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Init.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Destroy.s") +void func_80C07220(BgIkninside* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07220.s") +void func_80C07230(BgIkninside* this, GlobalContext* globalCtx) { + if (this->dyna.actor.cutscene == -1) { + this->actionFunc = func_80C07220; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->actionFunc = func_80C07220; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07230.s") +static Vec3f D_80C076D4 = { 0.0f, -1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C072D0.s") +void func_80C072D0(BgIkninside* this, GlobalContext* globalCtx) { + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Update.s") + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.info.acHitInfo != NULL) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000)) { + for (i = 0; i < 20; i++) { + altitude = Rand_S16Offset(0x1800, 0x2800); + azimuth = (u32)Rand_Next() >> 0x10; + speed = Rand_ZeroFloat(3.0f) + 8.0f; + velocity.x = speed * Math_CosS(altitude) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude) + Rand_ZeroFloat(5.0f); + velocity.z = speed * Math_CosS(altitude) * Math_CosS(azimuth); + pos.x = Rand_ZeroFloat(10.0f) * velocity.x + this->dyna.actor.world.pos.x; + pos.y = Rand_ZeroFloat(1.0f) * velocity.y + this->dyna.actor.world.pos.y; + pos.z = Rand_ZeroFloat(10.0f) * velocity.z + this->dyna.actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &D_80C076D4, 0, 30, OBJECT_IKNINSIDE_OBJ, 25, + D_80C076A0[i & 1]); + } + Flags_SetSwitch(globalCtx, DMIKNINSIDE_GET_SWITCH(&this->dyna.actor)); + this->actionFunc = func_80C07230; + this->dyna.actor.draw = NULL; + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + this->timer = 20; + } + } + if (this->timer > 0) { + if ((this->timer % 2) != 0) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 1.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } + this->timer--; + } else { + this->timer = 0; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Draw.s") +void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_ikninside_obj_DL_00CC78); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h index a9253f419..954b15b0c 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h @@ -5,14 +5,16 @@ struct BgIkninside; +#define DMIKNINSIDE_GET_SWITCH(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef void (*BgIkninsideActionFunc)(struct BgIkninside*, GlobalContext*); typedef struct BgIkninside { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; - /* 0x01AC */ BgIkninsideActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ UNK_TYPE1 pad_1A8[2]; + /* 0x1AA */ s16 timer; + /* 0x1AC */ BgIkninsideActionFunc actionFunc; } BgIkninside; // size = 0x1B0 -extern const ActorInit Bg_Ikninside_InitVars; - #endif // Z_BG_IKNINSIDE_H diff --git a/undefined_syms.txt b/undefined_syms.txt index 64a46e14c..403905235 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -626,11 +626,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Ikninside - -D_0600CC78 = 0x0600CC78; -D_0600DE48 = 0x0600DE48; - // ovl_Bg_Iknv_Doukutu D_0600DB60 = 0x0600DB60; From 064b3e5493ba554ff3b97732ea4190b5df633c73 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:31:01 -0300 Subject: [PATCH 44/53] ovl_Obj_Rotlift decompiled (#850) * ovl_Obj_Rotlift decompiled * fixes * fixes 2 * format * PR review fixes * PR review fixes * PR review fixes * PR review fixes * PR review fixes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_Obj_Rotlift/z_obj_rotlift.c | 113 ++++++++++++++++-- .../actors/ovl_Obj_Rotlift/z_obj_rotlift.h | 9 +- 3 files changed, 110 insertions(+), 15 deletions(-) diff --git a/spec b/spec index e407bad50..6dc4c4285 100644 --- a/spec +++ b/spec @@ -4229,8 +4229,7 @@ beginseg name "ovl_Obj_Rotlift" compress include "build/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.o" - include "build/data/ovl_Obj_Rotlift/ovl_Obj_Rotlift.data.o" - include "build/data/ovl_Obj_Rotlift/ovl_Obj_Rotlift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Rotlift/ovl_Obj_Rotlift_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index 6163c753c..b17827e0a 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -5,17 +5,25 @@ */ #include "z_obj_rotlift.h" +#include "objects/object_rotlift/object_rotlift.h" #define FLAGS 0x00000000 #define THIS ((ObjRotlift*)thisx) -void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx2); void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx); void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this); + +typedef struct ModelInfo { + /* 0x0 */ Gfx* dList; + /* 0x4 */ AnimatedMaterial* animMat; + /* 0x8 */ CollisionHeader* colHeader; +} ModelInfo; // size = 0xC + const ActorInit Obj_Rotlift_InitVars = { ACTOR_OBJ_ROTLIFT, ACTORCAT_BG, @@ -28,24 +36,107 @@ const ActorInit Obj_Rotlift_InitVars = { (ActorFunc)ObjRotlift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B96178[] = { +struct ModelInfo sModelInfo[] = { + { + object_rotlift_DL_000400, + object_rotlift_Matanimheader_001F98, + &object_rotlift_Colheader_002190, + }, + { + object_rotlift_DL_002CE0, + object_rotlift_Matanimheader_004A08, + &object_rotlift_Colheader_004DF0, + }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this) { + ObjEtcetera** dekuFlower = this->dekuFlowers; + ObjEtcetera* curDekuFlower; + f32 posOffset = 300.0f; + s32 i; -extern InitChainEntry D_80B96178[]; + for (i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlower++) { + curDekuFlower = *dekuFlower; + if (curDekuFlower->dyna.actor.update == NULL) { + *dekuFlower = NULL; + } else { + curDekuFlower->dyna.actor.world.pos.x = + this->dyna.actor.world.pos.x + posOffset * Math_SinS(this->dyna.actor.shape.rot.y); + curDekuFlower->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y + 380.0f * this->dyna.actor.scale.y; + curDekuFlower->dyna.actor.world.pos.z = + this->dyna.actor.world.pos.z + posOffset * Math_CosS(this->dyna.actor.shape.rot.y); + curDekuFlower->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y; + } + posOffset -= 600.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/func_80B95E20.s") +void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjRotlift* this = THIS; + s32 type = OBJROTLIFT_GET_TYPE(&this->dyna.actor); + s32 dekuFlowerType; + s32 i; + ModelInfo* modelInfo; + ObjEtcetera** dekuFlowers; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + if (type == 0) { + for (dekuFlowers = this->dekuFlowers, i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlowers++) { + if (!OBJROTLIFT_GET_4000(thisx) || (i != 0)) { + dekuFlowerType = 0; + } else { + dekuFlowerType = 0x100; + } + *dekuFlowers = (ObjEtcetera*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, dekuFlowerType); + } + ObjRotlift_MoveDekuFlowers(this); + } + DynaPolyActor_Init(&this->dyna, 3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Destroy.s") + modelInfo = &sModelInfo[type]; + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, modelInfo->colHeader); + modelInfo->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Update.s") +void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjRotlift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Draw.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjRotlift* this = THIS; + s16 angShift; + s32 angVelocity; + + if (OBJROTLIFT_GET_TYPE(&this->dyna.actor) == 0) { + ObjRotlift_MoveDekuFlowers(this); + } + if (thisx->params >= 0) { + angVelocity = -0xC8; + } else { + angVelocity = 0xC8; + } + angShift = angVelocity; + this->dyna.actor.shape.rot.y += angShift; +} + +void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjRotlift* this = THIS; + ModelInfo* modelInfo = &sModelInfo[OBJROTLIFT_GET_TYPE(&this->dyna.actor)]; + + AnimatedMat_Draw(globalCtx, modelInfo->animMat); + Gfx_DrawDListOpa(globalCtx, modelInfo->dList); +} diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h index a58a6b621..cc627a295 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h @@ -3,11 +3,16 @@ #include "global.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" + +#define OBJROTLIFT_GET_TYPE(thisx) ((thisx)->params & 1) +#define OBJROTLIFT_GET_4000(thisx) ((thisx)->params & 0x4000) + struct ObjRotlift; typedef struct ObjRotlift { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x20]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjEtcetera* dekuFlowers[2]; } ObjRotlift; // size = 0x164 extern const ActorInit Obj_Rotlift_InitVars; From a039a2f34a65ec9b85763664b30981f715563558 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 19 Jun 2022 16:38:51 -0700 Subject: [PATCH 45/53] BgIkanaDharma (punchable pillar segments in STT) OK (#851) * Bg_Ikana_Dharma decompiled * Bg_Ikana_Dharma more stuff * remove & from function pointers * use THIS macro * use THIS macro * return -> else * GET_PLAYER * slightly better match (this2 only used once) * fix warnings; name variables * better match in BgIkanaDharma_Init; more param macros * Rebase to latest master and some minor cleanup * More cleanup * Document object * Respond to isghj5's review * Respond to Elliptic's review * Better pack macro * Respond to hensldm's review Co-authored-by: immibis --- assets/xml/objects/object_ikana_obj.xml | 6 +- spec | 4 +- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 232 ++++++++++++++++-- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h | 11 +- tools/disasm/functions.txt | 14 +- undefined_syms.txt | 5 - 6 files changed, 228 insertions(+), 44 deletions(-) diff --git a/assets/xml/objects/object_ikana_obj.xml b/assets/xml/objects/object_ikana_obj.xml index 66398991b..6040495ab 100644 --- a/assets/xml/objects/object_ikana_obj.xml +++ b/assets/xml/objects/object_ikana_obj.xml @@ -9,8 +9,8 @@ - - + + @@ -38,7 +38,7 @@ - + diff --git a/spec b/spec index 6dc4c4285..ac6a462aa 100644 --- a/spec +++ b/spec @@ -4802,9 +4802,7 @@ beginseg name "ovl_Bg_Ikana_Dharma" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.data.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.bss.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 2fb508c79..6048a8c9c 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_dharma.h" +#include "assets/objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,13 @@ void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this); +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, GlobalContext* globalCtx); +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this); +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, GlobalContext* globalCtx); +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this); +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Dharma_InitVars = { ACTOR_BG_IKANA_DHARMA, ACTORCAT_BG, @@ -28,47 +35,226 @@ const ActorInit Bg_Ikana_Dharma_InitVars = { (ActorFunc)BgIkanaDharma_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BECAD0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000100, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000100, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 98, 10, 25, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BECAFC[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 320, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 320, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1100, ICHAIN_STOP), }; -#endif +static BgIkanaDharma* sFirstHitBgIkanaDharma; -extern ColliderCylinderInit D_80BECAD0; -extern InitChainEntry D_80BECAFC[]; +void BgIkanaDharma_SpawnEffects(BgIkanaDharma* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + s32 i; + f32 initialRadius = this->dyna.actor.scale.x * 200.0f; + f32 initialY = this->dyna.actor.scale.y * 50.0f; -extern UNK_TYPE D_060008C8; -extern UNK_TYPE D_06000C50; + for (i = 0; i < 4; i++) { + f32 speed = (Rand_ZeroOne() * 5.0f) + 5.0f; + s16 angle = ((u32)Rand_Next() >> 0x12) + this->dyna.actor.world.rot.y + 0x6000; + f32 dirX = Math_SinS(angle); + f32 dirZ = Math_CosS(angle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC240.s") + pos.x = (dirX * initialRadius) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y + initialY; + pos.z = (dirZ * initialRadius) + this->dyna.actor.world.pos.z; + velocity.x = speed * dirX; + velocity.y = Rand_ZeroOne() + 0.5f; + velocity.z = speed * dirZ; + accel.x = velocity.x * -0.05f; + accel.y = -0.15f; + accel.z = velocity.z * -0.05f; + EffectSsKirakira_SpawnSmallYellow(globalCtx, &pos, &velocity, &accel); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Init.s") +void BgIkanaDharma_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Destroy.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.x = 0.3f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.3f; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gStoneTowerTemplePunchablePillarCol); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + if (!BGIKANADHARMA_IS_CHILD(&this->dyna.actor)) { + f32 segmentY = this->dyna.actor.world.pos.y; + s32 numSegments = BGIKANADHARMA_NUM_SEGMENTS(&this->dyna.actor); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC5C4.s") + for (i = 0; i < numSegments; i++) { + segmentY += 60.0f; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_DHARMA, + this->dyna.actor.world.pos.x, segmentY, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, + this->dyna.actor.shape.rot.z, BGIKANADHARMA_PARAMS(0, true, 0), + this->dyna.actor.cutscene, this->dyna.actor.unk20, NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC5E0.s") + this->dyna.actor.bgCheckFlags |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC758.s") + BgIkanaDharma_SetupWaitForHit(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC790.s") +void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC7EC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); + if (sFirstHitBgIkanaDharma == this) { + sFirstHitBgIkanaDharma = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC808.s") +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this) { + this->actionFunc = BgIkanaDharma_WaitForHit; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Update.s") +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, GlobalContext* globalCtx) { + s32 wasHit = (this->collider.base.acFlags & AC_HIT) != 0; + Player* player = GET_PLAYER(globalCtx); + BgIkanaDharma* this2 = this; + s32 tempAngle1; + s32 tempAngle2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Draw.s") + if (wasHit) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (wasHit && sFirstHitBgIkanaDharma == NULL) { + sFirstHitBgIkanaDharma = this2; + Flags_SetSwitch(globalCtx, BGIKANADHARMA_GET_SWITCHFLAG(&this->dyna.actor)); + tempAngle1 = BINANG_ADD(this->dyna.actor.yawTowardsPlayer, 0x8000); + tempAngle2 = (BINANG_SUB(player->actor.shape.rot.y, tempAngle1) >> 1); + this->dyna.actor.world.rot.y = tempAngle1 + tempAngle2 + 0xF000; + this->dyna.actor.speedXZ = 20.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DARUMA_VANISH); + BgIkanaDharma_SetupStartCutscene(this); + } else if ((this->dyna.actor.flags & ACTOR_FLAG_40) == ACTOR_FLAG_40 && sFirstHitBgIkanaDharma == NULL && + this->dyna.actor.xzDistToPlayer < 420.0f) { + tempAngle1 = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y); + tempAngle1 = ABS_ALT(tempAngle1); + + if (tempAngle1 > 0x4000) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgIkanaDharma_StartCutscene; +} + +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + BgIkanaDharma_SetupWaitForCutsceneToEnd(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this) { + this->cutsceneFramesRemaining = 10; + this->actionFunc = BgIkanaDharma_WaitForCutsceneToEnd; +} + +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, GlobalContext* globalCtx) { + if (this->cutsceneFramesRemaining > 0) { + this->cutsceneFramesRemaining--; + + if (this->cutsceneFramesRemaining == 0) { + if (sFirstHitBgIkanaDharma == this) { + sFirstHitBgIkanaDharma = NULL; + } + + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } + + if (Math_StepToF(&this->dyna.actor.scale.y, 0.0f, 1.0f / 300.0f) != 0) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + this->dyna.actor.scale.x = this->dyna.actor.scale.y * 3.0f; + this->dyna.actor.scale.z = this->dyna.actor.scale.y * 3.0f; + BgIkanaDharma_SpawnEffects(this, globalCtx); + } +} + +void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; + + this->actionFunc(this, globalCtx); + if (this->actionFunc == BgIkanaDharma_WaitForHit) { + DynaPolyActor* actorBelow; + s32 pad[2]; + + func_800B4AEC(globalCtx, &this->dyna.actor, 30.0f); + actorBelow = DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId); + if (actorBelow == NULL) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + if (this->dyna.actor.bgCheckFlags & 2) { + s16 quake = Quake_Add(globalCtx->cameraPtrs[globalCtx->activeCamera], 3); + + Quake_SetSpeed(quake, 21536); + Quake_SetQuakeValues(quake, 4, 0, 0, 0); + Quake_SetCountdown(quake, 12); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + if (actorBelow->actor.id == ACTOR_BG_IKANA_DHARMA) { + this->dyna.actor.world.pos.y = actorBelow->actor.world.pos.y + 60.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; + } + + this->dyna.actor.velocity.y = 0.0f; + } + } else { + f32 wallCheckRadius = this->dyna.actor.scale.x * 300.0f; + wallCheckRadius = CLAMP_MIN(wallCheckRadius, 2.0f); + + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, wallCheckRadius, 0.0f, 5); + } + + Actor_SetFocus(&this->dyna.actor, 40.0f); +} + +void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; + + Gfx_DrawDListOpa(globalCtx, gStoneTowerTemplePunchablePillarDL); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h index ddd81e7d8..bf769a1a1 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h @@ -3,15 +3,20 @@ #include "global.h" +#define BGIKANADHARMA_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define BGIKANADHARMA_IS_CHILD(thisx) (((thisx)->params >> 5) & 1) +#define BGIKANADHARMA_NUM_SEGMENTS(thisx) ((thisx)->params & 0xF) +#define BGIKANADHARMA_PARAMS(switchFlag, isChild, numSegments) (((switchFlag & 0x7F) << 8) | ((isChild & 1) << 5) | (numSegments & 0xF)) + struct BgIkanaDharma; typedef void (*BgIkanaDharmaActionFunc)(struct BgIkanaDharma*, GlobalContext*); typedef struct BgIkanaDharma { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ BgIkanaDharmaActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x01AC */ s8 cutsceneFramesRemaining; } BgIkanaDharma; // size = 0x1B0 extern const ActorInit Bg_Ikana_Dharma_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 87d94e6ea..2c74907d5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16220,15 +16220,15 @@ 0x80BEC080:("EffLastday_Update",), 0x80BEC0A4:("func_80BEC0A4",), 0x80BEC0DC:("EffLastday_Draw",), - 0x80BEC240:("func_80BEC240",), + 0x80BEC240:("BgIkanaDharma_SpawnEffects",), 0x80BEC3F4:("BgIkanaDharma_Init",), 0x80BEC560:("BgIkanaDharma_Destroy",), - 0x80BEC5C4:("func_80BEC5C4",), - 0x80BEC5E0:("func_80BEC5E0",), - 0x80BEC758:("func_80BEC758",), - 0x80BEC790:("func_80BEC790",), - 0x80BEC7EC:("func_80BEC7EC",), - 0x80BEC808:("func_80BEC808",), + 0x80BEC5C4:("BgIkanaDharma_SetupWaitForHit",), + 0x80BEC5E0:("BgIkanaDharma_WaitForHit",), + 0x80BEC758:("BgIkanaDharma_SetupStartCutscene",), + 0x80BEC790:("BgIkanaDharma_StartCutscene",), + 0x80BEC7EC:("BgIkanaDharma_SetupWaitForCutsceneToEnd",), + 0x80BEC808:("BgIkanaDharma_WaitForCutsceneToEnd",), 0x80BEC8C0:("BgIkanaDharma_Update",), 0x80BECA80:("BgIkanaDharma_Draw",), 0x80BECBE0:("func_80BECBE0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 403905235..f2f9c6af1 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -612,11 +612,6 @@ D_06000C90 = 0x06000C90; D_06000288 = 0x06000288; -// ovl_Bg_Ikana_Dharma - -D_060008C8 = 0x060008C8; -D_06000C50 = 0x06000C50; - // ovl_Bg_Ikana_Mirror D_060014B0 = 0x060014B0; From d318b1f2854e98e2510812dd09e7c84b14f17622 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 16:49:20 -0700 Subject: [PATCH 46/53] SubS Time Paths (Finale) (#823) * Merge in sub_s_models * Update subs DL names * Unused Weight pathing * Function headers for weightpathing * TimePathing WIP * Timepathing, still unsure about unk184 * Move subs functions from functions.h to z64subs.h * Add fake comment * Some cleanup and renames * Renames/cleanup of actors that use timepath * Cleanup * More cleanup * Rename unk stuff * Merge in upstream/master * TimeElapsed -> elapsedTime * Fix * Final cleanup * Fix waypoint comments * Review pt. 1 * Add clarifying comment to SubS_TimePathing_FillWeightArray * format.sh * Fix order comments * weightArray -> knots * Review pt 1 * Review pt 2 * Update src/code/z_sub_s.c Co-authored-by: EllipticEllipsis * Update src/code/z_sub_s.c Co-authored-by: EllipticEllipsis Co-authored-by: Maide <34639600+Kelebek1@users.noreply.github.com> Co-authored-by: Tom Overton Co-authored-by: EllipticEllipsis --- assets/xml/code/sub_s.xml | 4 +- include/functions.h | 56 +-- include/z64subs.h | 115 ++++- src/code/z_sub_s.c | 470 +++++++++++++++++- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 68 +-- .../actors/ovl_Bg_Ingate/z_bg_ingate.h | 16 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 66 +-- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 16 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 107 ++-- src/overlays/actors/ovl_En_Gm/z_en_gm.h | 16 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 110 ++-- src/overlays/actors/ovl_En_Ig/z_en_ig.h | 16 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 115 ++--- src/overlays/actors/ovl_En_Pm/z_en_pm.h | 16 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 160 +++--- .../actors/ovl_En_Suttari/z_en_suttari.h | 17 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 105 ++-- src/overlays/actors/ovl_En_Tk/z_en_tk.h | 16 +- tools/disasm/functions.txt | 18 +- tools/disasm/variables.txt | 7 +- tools/sizes/code_functions.csv | 18 +- 21 files changed, 1004 insertions(+), 528 deletions(-) diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml index 03329f0c5..76db7e32c 100644 --- a/assets/xml/code/sub_s.xml +++ b/assets/xml/code/sub_s.xml @@ -1,6 +1,6 @@ - - + + diff --git a/include/functions.h b/include/functions.h index 7e01d5afe..372f4d5fc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2392,61 +2392,7 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); -Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 SubS_InCsMode(GlobalContext* globalCtx); -s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); -void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); -void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); -s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); -void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); -void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); -s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); -void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); -Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); -s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); -s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); -Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); -s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); -s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); -void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); -void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); -void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); -s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); -s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); -s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); -s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); -s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); -s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); -Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); -s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); -u8 SubS_GetPathCount(Path* paths, s32 index); -void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); -s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); -void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); -void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); -s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); -s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); -void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); -s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); -Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); -s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); -s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); diff --git a/include/z64subs.h b/include/z64subs.h index 3b13d2add..b39842195 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -8,6 +8,8 @@ extern Vec3f gOneVec3f; +#define SUBS_TIME_PATHING_ORDER 3 + typedef enum { /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, /* 1 */ SUBS_CUTSCENE_NORMAL, @@ -23,6 +25,20 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define SUBS_SHADOW_TEX_HEIGHT 64 #define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) +typedef struct TurnOptions { + /* 0x0 */ u16 rotMax; // binary angles + /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 + /* 0x4 */ u16 rotStepMin; // degrees + /* 0x6 */ u16 rotStepMax; // degrees +} TurnOptions; // size = 0x8 + +typedef struct TurnOptionsSet { + /* 0x00 */ TurnOptions headRotX; + /* 0x08 */ TurnOptions headRotY; + /* 0x10 */ TurnOptions torsoRotX; + /* 0x18 */ TurnOptions torsoRotY; +} TurnOptionsSet; // size = 0x20 + #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) #define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) @@ -38,20 +54,6 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define ACTOR_PATHING_REACHED_END \ (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) -typedef struct TurnOptions { - /* 0x0 */ u16 rotMax; // binary angles - /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 - /* 0x4 */ u16 rotStepMin; // degrees - /* 0x6 */ u16 rotStepMax; // degrees -} TurnOptions; // size = 0x8 - -typedef struct TurnOptionsSet { - /* 0x00 */ TurnOptions headRotX; - /* 0x08 */ TurnOptions headRotY; - /* 0x10 */ TurnOptions torsoRotX; - /* 0x18 */ TurnOptions torsoRotY; -} TurnOptionsSet; // size = 0x20 - struct ActorPathing; typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); @@ -80,4 +82,89 @@ typedef struct ActorPathing { /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again } ActorPathing; // size = 0x6C +struct EnDoor* SubS_FindDoor(struct GlobalContext* globalCtx, s32 switchFlag); + +Gfx* SubS_DrawTransformFlexLimb(struct GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SubS_DrawTransformFlex(struct GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); + +s32 SubS_InCsMode(struct GlobalContext* globalCtx); + +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); + +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); + +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints); +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, s32 order, f32 knots[]); +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]); +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], f32 knots[]); +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, f32 knots[], Vec3f* targetPos, s32 timeSpeed); +void SubS_TimePathing_ComputeInitialY(struct GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos); + +Path* SubS_GetAdditionalPath(struct GlobalContext* globalCtx, u8 pathIndex, s32 max); + +Actor* SubS_FindNearestActor(Actor* actor, struct GlobalContext* globalCtx, u8 actorCategory, s16 actorId); + +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); + +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); + +Path* SubS_GetDayDependentPath(struct GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); + +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction); +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart); + +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); + +s32 func_8013C964(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); + +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); + +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); + +Path* SubS_GetPathByIndex(struct GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); + +s8 SubS_IsObjectLoaded(s8 index, struct GlobalContext* globalCtx); +s8 SubS_GetObjectIndex(s16 id, struct GlobalContext* globalCtx); + +Actor* SubS_FindActor(struct GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); + +s32 SubS_FillLimbRotTables(struct GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); + +s32 SubS_IsFloorAbove(struct GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); + +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex); + +void SubS_ActorPathing_Init(struct GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(struct GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(struct GlobalContext* globalCtx, ActorPathing* actorPath); + +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); + +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); + +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); + +Actor* SubS_FindActorCustom(struct GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); + +s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); + +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + #endif diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 3e5443bc6..d5b4f33b2 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -178,8 +178,7 @@ s32 SubS_InCsMode(GlobalContext* globalCtx) { * @param[in] stepRot boolean, step towards newRot instead of setting directly * @param[in] overrideRot boolean, override newRot with the specified input. * - * Note: - * If overrideRot is true, the rotation will automatically step instead of setting directly + * @note if overrideRot is true, the rotation will automatically step instead of setting directly */ s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { Vec3f newPos; @@ -214,17 +213,273 @@ void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { *flags = (*flags & ~unsetBits) | setBits; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") +/** + * Fills the knot array to be used with time paths + * + * The default knot array just pads with `order` duplicate knots of the first knot at the front and of the last knot + * at the end. + * + * @param[out] knots an array of values that are used to compute the progress and the individual weights + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] numPoints the number of points to fill, generally the path count + order + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints) { + s32 i; + f32 val = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B010.s") + for (i = 0; i < numPoints; i++) { + if ((i >= order) && (i < (numPoints - order + 1))) { + val += 1.0f; + } + knots[i] = val; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B0C8.s") +typedef enum { + /* 0 */ SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR, + /* 1 */ SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH, + /* 2 */ SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END +} SUBS_TIME_PATHING_PROGRESS_STATUS; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B350.s") +/** + * Computes the progress to be used with time paths + * + * @param[out] progress the progress along the path, used to compute the weights + * @param[in] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in] pathCount the path count + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] knots see SubS_TimePathing_FillKnots() + * + * @return see SUBS_TIME_PATHING_PROGRESS_STATUS + */ +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, + s32 order, f32 knots[]) { + s32 i; + s32 j; + s32 k; + f32 waypointTimeInv; // The fraction of a waypoint a single unit of time contains -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B6B0.s") + *progress = 0.0f; + if ((waypointTime <= 0) || (elapsedTime < 0)) { + return SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") + // When using the knots from SubS_TimePathing_FillKnots() these nested loops seem to simplify to + // *progress = (f32)elapsedTime / (f32)waypointTime; + waypointTimeInv = 1.0f / waypointTime; + k = 0; + for (i = order - 1; i < pathCount; i++) { + for (j = 0; j < waypointTime; j++) { + if (k == elapsedTime) { + break; + } + *progress += (knots[i + 1] - knots[i]) * waypointTimeInv; + k++; + } + } + + return (elapsedTime == totalTime) ? SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END + : SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH; +} + +/** + * Computes the interpolation weights to be used with time paths + * + * Seems to use some kind of B-Spline interpolation algorithm + * + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] waypoint the current waypoint + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] weights how much to weight each point considered + */ +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]) { + f32 weightsTemp[10][11]; + s32 i; + s32 j; + s32 k; + + for (i = 0; i < order; i++) { + for (j = 0; j < order + 1; j++) { + weightsTemp[i][j] = 0.0f; + } + } + + weightsTemp[0][order - 1] = 1.0f; + + for (i = 1; i < order; i++) { + for (j = waypoint - i, k = (order - 1) - i; j <= waypoint; j++, k++) { + if (knots[j + i] != knots[j]) { + weightsTemp[i][k] = ((progress - knots[j]) / (knots[j + i] - knots[j])) * weightsTemp[i - 1][k]; + } else { + weightsTemp[i][k] = 0.0f; + } + + if (knots[j + i + 1] != knots[j + 1]) { + weightsTemp[i][k] += + ((knots[j + i + 1] - progress) / (knots[j + i + 1] - knots[j + 1])) * weightsTemp[i - 1][k + 1]; + } + } + } + for (j = 0; j < order; j++) { + weights[j] = weightsTemp[order - 1][j]; + } +} + +/** + * Computes the X and Z component of the position to move to in time based paths + * + * @param[out] x computed x position + * @param[out] z computed z position + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] waypoint the current waypoint + * @param[in] points the path's points + * @param[in] knots see SubS_TimePathing_FillKnots() + */ +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], + f32 knots[]) { + f32 xPos; + f32 zPos; + f32 weights[11]; + f32 weightedX; + f32 weightedZ; + f32 weightedTotal; + s32 i; + + SubS_TimePathing_ComputeWeights(order, progress, waypoint, knots, weights); + weightedTotal = 0.0f; + weightedZ = 0.0f; + weightedX = 0.0f; + + for (i = 0; i < order; i++) { + xPos = points[waypoint - order + i + 1].x; + zPos = points[waypoint - order + i + 1].z; + + weightedX += weights[i] * xPos; + weightedZ += weights[i] * zPos; + weightedTotal += weights[i]; + } + *x = weightedX / weightedTotal; + *z = weightedZ / weightedTotal; +} + +/** + * Updates a time based path that an actor follows by: + * - Computing the X and Z components of the next point to move to + * - Updating the waypoint + * - Updating the time + * + * @param[in] path + * @param[out] progress see SubS_TimePathing_ComputeProgress() + * @param[in,out] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in,out] waypoint the current waypoint, this and the previous two points will be used to compute the targetPos + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] targetPos the computed position to move to + * @param[in] timeSpeed how fast time moves + * + * @return s32 returns true when the end has been reached. + * + * @note This system/function makes a couple of assumptions about the order used: + * 1. the order is assumed to be 3, see SUBS_TIME_PATHING_ORDER + * 2. even if SUBS_TIME_PATHING_ORDER is updated, the order can only be a max of 10 + */ +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, + f32 knots[], Vec3f* targetPos, s32 timeSpeed) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 state; + f32 endX; + f32 endZ; + s32 reachedEnd = false; + + if (*waypoint >= path->count) { + state = SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END; + } else { + state = SubS_TimePathing_ComputeProgress(progress, *elapsedTime, waypointTime, totalTime, path->count, + SUBS_TIME_PATHING_ORDER, knots); + } + + switch (state) { + case SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH: + reachedEnd = false; + SubS_TimePathing_ComputeTargetPosXZ(&targetPos->x, &targetPos->z, *progress, SUBS_TIME_PATHING_ORDER, + *waypoint, points, knots); + break; + case SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END: + endX = points[path->count - 1].x; + endZ = points[path->count - 1].z; + targetPos->x = endX * 1; + targetPos->z = endZ * 1; + reachedEnd = true; + break; + } + + *elapsedTime += timeSpeed; + if (*elapsedTime >= totalTime) { + *elapsedTime = totalTime; + } else if (*elapsedTime < 0) { + *elapsedTime = 0; + } + *waypoint = (*elapsedTime / waypointTime) + (SUBS_TIME_PATHING_ORDER - 1); + + return reachedEnd; +} + +/** + * Computes the initial Y component of a time based path + * + * @param[in] globalCtx + * @param[in] path + * @param[in] waypoint the current waypoint, this and the previous two points will be used to compute the target pos + * @param[out] targetPos the computed position to move to, only the Y component has meaning + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 i = waypoint - (SUBS_TIME_PATHING_ORDER - 1); + s16 max; + s16 min; + s32 isSetup; + CollisionPoly* outPoly = NULL; + s32 bgId = 0; + + max = 0; + min = 0; + isSetup = false; + for (; i <= waypoint; i++) { + if (isSetup) { + if (max < points[i].y) { + max = points[i].y; + } + if (points[i].y < min) { + min = points[i].y; + } + } else { + max = min = points[i].y; + } + isSetup = true; + } + max += 30; + min -= 30; + posA = *targetPos; + posB = *targetPos; + posA.y = max; + posB.y = min; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, + &bgId)) { + targetPos->y = posResult.y; + } +} Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { Path* path; @@ -362,9 +617,189 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s return path; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") +/** + * Computes the point to move toward using a weight based algorithm that considers 4 points along the path + * + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to compute the point + * @param point the point computed + * @param progress the main weight value used to compute the weights for the points considered + * @param direction the direciton along the path to move, 1 for forwards, anything else for backwards + * + * @note only computes X and Z components of the point + */ +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction) { + s32 i; + f32 weight0; + f32 weight1; + f32 weight2; + f32 weight3; + s32 lastPoint; + s32 secondLastPoint; + s32 secondPoint; + s32 firstPoint; + f32 xPoints[4]; + f32 zPoints[4]; + f32 oneMinusProgress; + f32 squared; + f32 cubed; + Vec3s* points; + s32 count = path->count; + s32 pointIndex; + s32 tmp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") + if (path == NULL) { + return false; + } + if (direction == 1) { + if (waypoint <= 2) { + pointIndex = 2; + } else { + pointIndex = (waypoint == 3) ? 3 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex--) { + if (pointIndex <= 0) { + pointIndex = 0; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = count - 1; + secondLastPoint = count - 2; + secondPoint = 3; + firstPoint = 2; + } else { + if (waypoint >= count - 3) { + pointIndex = count - 3; + } else { + tmp = waypoint + 4; + pointIndex = (count == tmp) ? count - 4 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex++) { + if (pointIndex >= path->count) { + pointIndex = path->count - 1; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = 0; + secondLastPoint = 1; + secondPoint = count - 4; + firstPoint = count - 3; + } + if (waypoint == lastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress; + weight1 = (1.75f * cubed) - (4.5f * squared) + (3.0f * progress); + weight2 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight3 = (1.0f / 6.0f) * cubed; + } else if (waypoint == secondLastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress * ((void)0, 0.25f); //! FAKE: + weight1 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * progress) + (7.0f / 12.0f); + weight2 = (-0.5f * cubed) + (0.5f * squared) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed * (1.0f / 6.0f); + } else if (waypoint == secondPoint) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = (-0.5f * cubed) + (0.5f * squared) + (0.5f * oneMinusProgress) + (1.0f / 6.0f); + weight2 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * oneMinusProgress) + (7.0f / 12.0f); + weight3 = progress * progress * progress * 0.25f; + } else if (((direction == 1) && (firstPoint >= waypoint)) || ((direction != 1) && (waypoint >= firstPoint))) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight2 = (1.75f * cubed) - (4.5f * squared) + (3.0f * oneMinusProgress); + weight3 = progress * progress * progress; + } else { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = squared * progress; + weight0 = oneMinusProgress * oneMinusProgress; + weight0 = oneMinusProgress * weight0 / 6.0f; + weight1 = (cubed * 0.5f) - squared + (2.0f / 3.0f); + weight2 = (cubed / -2.0f) + (squared * 0.5f) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed / 6.0f; + } + point->x = (weight0 * xPoints[0]) + (weight1 * xPoints[1]) + (weight2 * xPoints[2]) + (weight3 * xPoints[3]); + point->z = (weight0 * zPoints[0]) + (weight1 * zPoints[1]) + (weight2 * zPoints[2]) + (weight3 * zPoints[3]); + + return true; +} + +// WeightPathing System is completely unused +/** + * Moves an actor based on a weight based algorithm that takes into account 4 points along the path + * + * @param actor + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to move forward + * @param progress the progress towards a given waypoint, used to compute the weights + * @param direction the direction along the path to move, 1 for forwards, anything else for backwards + * @param returnStart boolean, true if the actor should wrap back to start when reaching the end + * + * @return s32 true if actor reached the end of the path in this iteration, false otherwise + */ +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart) { + Vec3f worldPos = actor->world.pos; + Vec3f velocity = actor->velocity; + Vec3f point; + f32 dist; + + if (((direction != 1) && (*waypoint >= (path->count - 2))) || ((direction == 1) && (*waypoint < 2))) { + return false; + } + while (true) { + if (!SubS_WeightPathing_ComputePoint(path, *waypoint, &point, *progress, direction) || + ((s32)(actor->speedXZ * 10000.0f) == 0)) { + return false; + } + dist = Math_Vec3f_DistXZ(&actor->world.pos, &point); + actor->world.rot.y = Math_Vec3f_Yaw(&actor->world.pos, &point); + Actor_MoveWithGravity(actor); + if (Math_Vec3f_DistXZ(&actor->world.pos, &point) < dist) { + break; + } + *progress += 0.1f; + if (*progress >= 1.1f) { + if (direction != 1) { + (*waypoint)++; + if (*waypoint >= (path->count - 2)) { + if (returnStart) { + *waypoint = 0; + } else { + return true; + } + } + } else { + (*waypoint)--; + if (*waypoint < 2) { + if (returnStart) { + *waypoint = path->count - 2; + } else { + return true; + } + } + } + *progress = 0.0f; + } + actor->world.pos = worldPos; + actor->velocity = velocity; + } + return false; +} s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { Vec3s* point; @@ -557,10 +992,10 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gShadowDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowMaterialDL); gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); - gSPDisplayList(POLY_OPA_DISP++, gShadowVtxDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowModelDL); CLOSE_DISPS(gfxCtx); } @@ -617,9 +1052,7 @@ s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards * @param[in,out] headRot the computed head rotation * @param[in,out] torsoRot the computed torso rotation - * @param[in] options various options to adjust how the actor turns, see `SubS_ComputeTurnToPointRot and - * TurnOptions/TurnOptionsSet` - * + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTurnToPointRot() */ s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options) { @@ -781,8 +1214,8 @@ s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f return false; } -u8 SubS_GetPathCount(Path* paths, s32 index) { - Path* path = &paths[index]; +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) { + Path* path = &paths[pathIndex]; return path->count; } @@ -1004,8 +1437,7 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { * @param[in] rot the angles to rotate with, uses just the x and y components * @param[out] plane the computed plane * - * Notes: - * The unit input vector is expected to already be normalized (only uses are with the z unit vector) + * @note the unit input vector is expected to already be normalized (only uses are with the z unit vector) * */ void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 11936a9d2..1cda3dc8c 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -73,45 +73,47 @@ void func_80953B40(BgIngate* this) { s32 temp; if (!(gSaveContext.eventInf[3] & 0x20)) { - this->unk180 = 0xFA0; - this->unk168 = 4; + this->timePathTotalTime = 4 * 1000; + this->timePathTimeSpeed = 4; } else { - this->unk180 = 0x7D0; - this->unk168 = 1; + this->timePathTotalTime = 1 * 2000; + this->timePathTimeSpeed = 1; } - temp = this->unk164->count - 2; - this->unk184 = this->unk180 / temp; - this->unk188 = 2; - this->unk18C = 0; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; + this->timePathWaypoint = SUBS_TIME_PATHING_ORDER - 1; + this->timePathElapsedTime = 0; this->unk160 &= ~0x1; this->unk160 &= ~0x2; } s32 func_80953BEC(BgIngate* this) { - f32 sp74[265]; + f32 knots[265]; Vec3f sp68; Vec3f sp5C; - Vec3f unkVec; + Vec3f timePathTargetPos; s16 yaw; - func_8013AF00(sp74, 3, this->unk164->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk160 & 1)) { - unkVec = gZeroVec3f; - func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &unkVec, this->unk168); + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); this->unk160 |= 1; } else { - unkVec = this->unk170; + timePathTargetPos = this->timePathTargetPos; } - this->dyna.actor.world.pos.x = unkVec.x; - this->dyna.actor.world.pos.z = unkVec.z; - this->unk170 = gZeroVec3f; - if (func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &this->unk170, this->unk168) != 0) { + this->dyna.actor.world.pos.x = timePathTargetPos.x; + this->dyna.actor.world.pos.z = timePathTargetPos.z; + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk160 |= 2; } else { sp68 = this->dyna.actor.world.pos; - sp5C = this->unk170; + sp5C = this->timePathTargetPos; yaw = Math_Vec3f_Yaw(&sp68, &sp5C); this->dyna.actor.world.rot.y = yaw; this->dyna.actor.shape.rot.y = yaw; @@ -164,7 +166,7 @@ void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; func_80953DA8(this, globalCtx); - if (this->unk164 != NULL) { + if (this->timePath != NULL) { func_80953B40(this); } this->unk16E = -1; @@ -188,7 +190,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { if (this->unk160 & 2) { - if (this->unk164->unk1 != 0xFF) { + if (this->timePath->unk1 != 0xFF) { func_80953E38(globalCtx); func_800B7298(globalCtx, &this->dyna.actor, 7); this->dyna.actor.textId = 0x9E4; @@ -205,7 +207,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { } this->actionFunc = func_809542A0; } - } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->unk164 != NULL)) { + } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->timePath != NULL)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); func_80953BEC(this); } @@ -259,9 +261,9 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { void func_80954340(BgIngate* this, GlobalContext* globalCtx) { if (!DECR(this->unk16A)) { - if (this->unk164 != NULL) { + if (this->timePath != NULL) { func_800B7298(globalCtx, &this->dyna.actor, 6); - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; func_80953F14(this, globalCtx); func_800FE484(); } @@ -285,8 +287,8 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { func_800FE498(); func_8019F208(); } else { - if (this->unk164 != NULL) { - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + if (this->timePath != NULL) { + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; } func_80953F14(this, globalCtx); gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -327,7 +329,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -349,9 +351,9 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != NULL) { - sp38 = Lib_SegmentedToVirtual(this->unk164->points); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->timePath != NULL) { + sp38 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); Math_Vec3s_ToVec3f(&sp20, &sp38[1]); this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&sp2C, &sp20); @@ -360,7 +362,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h index 08d062e6c..81b7bec9b 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -13,17 +13,17 @@ typedef struct BgIngate { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgIngateActionFunc actionFunc; /* 0x160 */ u16 unk160; - /* 0x164 */ Path* unk164; - /* 0x168 */ s16 unk168; + /* 0x164 */ Path* timePath; + /* 0x168 */ s16 timePathTimeSpeed; /* 0x16A */ s16 unk16A; /* 0x16C */ s16 unk16C; /* 0x16E */ s16 unk16E; - /* 0x170 */ Vec3f unk170; - /* 0x17C */ f32 unk17C; - /* 0x180 */ s32 unk180; - /* 0x184 */ s32 unk184; - /* 0x188 */ s32 unk188; - /* 0x18C */ s32 unk18C; + /* 0x170 */ Vec3f timePathTargetPos; + /* 0x17C */ f32 timePathProgress; + /* 0x180 */ s32 timePathTotalTime; + /* 0x184 */ s32 timePathWaypointTime; + /* 0x188 */ s32 timePathWaypoint; + /* 0x18C */ s32 timePathElapsedTime; } BgIngate; // size = 0x190 extern const ActorInit Bg_Ingate_InitVars; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index e6dd15a32..c10741fdf 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -319,35 +319,35 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { - u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); + u16 sp26 = SCHEDULE_TIME_NOW; u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); if (D_80BAA4A8[arg2->result] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); } - if (this->unk_410 == NULL) { + if (this->timePath == NULL) { return false; } - if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { + if ((this->unk_434 != 0) && (this->timePathTimeSpeed >= 0)) { temp = sp26; } else { temp = arg2->time0; } if (arg2->time1 < temp) { - this->unk_424 = (temp - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (temp - arg2->time1) + 0xFFFF; } else { - this->unk_424 = arg2->time1 - temp; + this->timePathTotalTime = arg2->time1 - temp; } - this->unk_430 = sp26 - temp; - temp = this->unk_410->count - 2; - this->unk_428 = this->unk_424 / temp; + this->timePathElapsedTime = sp26 - temp; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; this->unk_438 = 0; - this->unk_42C = (this->unk_430 / this->unk_428) + 2; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_43C = 0; return true; } @@ -372,52 +372,54 @@ s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) } s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_410->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk_438 == 0) { - sp58 = gZeroVec3f; + timePathTargetPos = gZeroVec3f; - func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &sp58, this->unk_436); - func_8013B878(globalCtx, this->unk_410, this->unk_42C, &sp58); - this->actor.world.pos.y = sp58.y; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_438 = 1; } else { - sp58 = this->unk_414; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_430; - sp50 = this->unk_42C; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_414 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &this->unk_414, this->unk_436)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_43C = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_414; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_430 = sp54; - this->unk_42C = sp50; - this->unk_414 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return false; @@ -598,7 +600,7 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index 6a21168b6..51a986bf0 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -43,15 +43,15 @@ typedef struct EnBaba { /* 0x0406 */ UNK_TYPE1 unk406[4]; /* 0x040A */ u16 unk_40A; /* 0x040C */ s32 unk_40C; - /* 0x0410 */ Path* unk_410; - /* 0x0414 */ Vec3f unk_414; - /* 0x0420 */ f32 unk_420; - /* 0x0424 */ s32 unk_424; - /* 0x0428 */ s32 unk_428; - /* 0x042C */ s32 unk_42C; - /* 0x0430 */ s32 unk_430; + /* 0x0410 */ Path* timePath; + /* 0x0414 */ Vec3f timePathTargetPos; + /* 0x0420 */ f32 timePathProgress; + /* 0x0424 */ s32 timePathTotalTime; + /* 0x0428 */ s32 timePathWaypointTime; + /* 0x042C */ s32 timePathWaypoint; + /* 0x0430 */ s32 timePathElapsedTime; /* 0x0434 */ u8 unk_434; - /* 0x0436 */ s16 unk_436; + /* 0x0436 */ s16 timePathTimeSpeed; /* 0x0438 */ s32 unk_438; /* 0x043C */ s32 unk_43C; } EnBaba; // size = 0x440 diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 07699e7de..8e43a095a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -979,18 +979,18 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -1010,16 +1010,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; door = func_8094DF90(globalCtx, arg2->result); if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_278, &sp40); @@ -1053,32 +1053,33 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != NULL) { - if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { + if (this->timePath != NULL) { + if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; SubS_UpdateFlags(&this->unk_3A4, 3, 7); @@ -1154,16 +1155,16 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); if (this->unk_258 == 0) { @@ -1444,7 +1445,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { f32 temp_f0; door = func_8094DF90(globalCtx, this->unk_258); - if (!SubS_InCsMode(globalCtx) && (this->unk_3C4 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1459,7 +1460,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3BA * temp_f0; Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3BA += this->unk_3C4; + this->unk_3BA += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1469,51 +1470,53 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { } s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { - f32 sp7C[0x109]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad2; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3A4 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_3C4); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3A4 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_3C4)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3A4 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1576,7 +1579,7 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index 63b6b8f57..1dd161757 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -18,13 +18,13 @@ typedef struct EnGm { /* 0x018C */ EnGmUnkFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 0x0234 */ Path* timePath; + /* 0x0238 */ Vec3f timePathTargetPos; + /* 0x0244 */ f32 timePathProgress; + /* 0x0248 */ s32 timePathTotalTime; + /* 0x024C */ s32 timePathWaypointTime; + /* 0x0250 */ s32 timePathWaypoint; + /* 0x0254 */ s32 timePathElapsedTime; /* 0x0258 */ u8 unk_258; /* 0x0259 */ u8 unk_259; /* 0x025C */ s32 unk_25C; @@ -54,7 +54,7 @@ typedef struct EnGm { /* 0x03BE */ s16 unk_3BE; /* 0x03C0 */ s16 unk_3C0; /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; + /* 0x03C4 */ s16 timePathTimeSpeed; /* 0x03C6 */ s16 unk_3C6; /* 0x03C8 */ s16 unk_3C8; /* 0x03CA */ s16 unk_3CA; diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index e687b770d..f15f15d59 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -506,17 +506,17 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s3 s32 sp24 = false; sp2C = func_80BF1150(this, globalCtx, arg3, arg4); - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_274 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_274->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_274->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -549,16 +549,16 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; door = func_80BF1200(globalCtx, arg2->result); if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_274 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_274->points); + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_2B0, &sp40); @@ -588,39 +588,39 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 temp_t8; + s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } - if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { - this->unk_274 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_274 != NULL) { - temp_t8 = this->scheduleResult; - if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { + if (this->timePath != NULL) { + if ((this->scheduleResult < 10) && (this->scheduleResult != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_294 = sp2E - phi_v1; + this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = (this->unk_274->count - 2) & 0xFFFF; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->unk_28C = this->unk_288 / phi_v1; - this->unk_290 = (this->unk_294 / this->unk_28C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; @@ -641,16 +641,16 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } - if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_274->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_274->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); @@ -733,7 +733,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { f32 temp; s32 pad; - if (!SubS_InCsMode(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -747,7 +747,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3E2 * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_2B0, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3E2 += this->unk_3EC; + this->unk_3E2 += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -756,50 +756,52 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_274->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3D0 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &sp58, this->unk_3EC); - func_8013B878(globalCtx, this->unk_274, this->unk_290, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3D0 |= 8; } else { - sp58 = this->unk_278; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_294; - sp50 = this->unk_290; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_278 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &this->unk_278, this->unk_3EC)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3D0 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_278; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_294 = sp54; - this->unk_290 = sp50; - this->unk_278 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -873,7 +875,7 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.h b/src/overlays/actors/ovl_En_Ig/z_en_ig.h index 21abb08ac..9acf34ae9 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -19,13 +19,13 @@ typedef struct EnIg { /* 0x0190 */ MtxF unk_190; /* 0x01D0 */ ColliderCylinder collider1; /* 0x021C */ ColliderSphere collider2; - /* 0x0274 */ Path* unk_274; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ f32 unk_284; - /* 0x0288 */ s32 unk_288; - /* 0x028C */ s32 unk_28C; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ s32 unk_294; + /* 0x0274 */ Path* timePath; + /* 0x0278 */ Vec3f timePathTargetPos; + /* 0x0284 */ f32 timePathProgress; + /* 0x0288 */ s32 timePathTotalTime; + /* 0x028C */ s32 timePathWaypointTime; + /* 0x0290 */ s32 timePathWaypoint; + /* 0x0294 */ s32 timePathElapsedTime; /* 0x0298 */ u8 scheduleResult; /* 0x029C */ s32* unk_29C; /* 0x02A0 */ s32 unk_2A0; @@ -50,7 +50,7 @@ typedef struct EnIg { /* 0x03E6 */ s16 unk_3E6; /* 0x03E8 */ s16 unk_3E8; /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; + /* 0x03EC */ s16 timePathTimeSpeed; /* 0x03EE */ s16 unk_3EE; /* 0x03F0 */ s16 unk_3F0; /* 0x03F2 */ s16 unk_3F2; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index bc41461d9..43fb03da4 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1207,17 +1207,17 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -1238,15 +1238,15 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s16 temp; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; door = func_80AF7D60(globalCtx, arg2->result); if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != 0) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + if (this->timePath != 0) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_26C, &sp40); @@ -1283,33 +1283,34 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != 0) { - if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { + if (this->timePath != 0) { + if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { @@ -1364,13 +1365,13 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp30[0]); Math_Vec3s_ToVec3f(&sp34, &sp30[1]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); @@ -1416,16 +1417,16 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } - this->unk_234 = NULL; + this->timePath = NULL; phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); @@ -1703,7 +1704,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Vec3f* sp28; f32 temp; - if (!SubS_InCsMode(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1717,7 +1718,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_36E * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_36E += this->unk_374; + this->unk_36E += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } @@ -1726,52 +1727,54 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { } s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54; s32 sp50; sp50 = 0; sp54 = 0; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_356 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_374); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_356 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_374)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_356 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); @@ -1989,7 +1992,7 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { u16 sp3C = 0; ScheduleResult sp2C; - this->unk_374 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { time = gSaveContext.save.time - D_801F4E78; sp3C = gSaveContext.save.time; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.h b/src/overlays/actors/ovl_En_Pm/z_en_pm.h index 6d545373b..7a8c2be77 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -16,13 +16,13 @@ typedef struct EnPm { /* 0x018C */ EnPmFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 0x0234 */ Path* timePath; + /* 0x0238 */ Vec3f timePathTargetPos; + /* 0x0244 */ f32 timePathProgress; + /* 0x0248 */ s32 timePathTotalTime; + /* 0x024C */ s32 timePathWaypointTime; + /* 0x0250 */ s32 timePathWaypoint; + /* 0x0254 */ s32 timePathElapsedTime; /* 0x0258 */ u8 unk_258; /* 0x025C */ UNK_TYPE* unk_25C; /* 0x0260 */ s8 unk_260; @@ -44,7 +44,7 @@ typedef struct EnPm { /* 0x036E */ s16 unk_36E; /* 0x0370 */ s16 unk_370; /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; + /* 0x0374 */ s16 timePathTimeSpeed; /* 0x0376 */ s16 unk_376; /* 0x0378 */ s16 unk_378; /* 0x037C */ EnPmFunc unk_37C; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 4a7e56682..21b0dd9a2 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -673,68 +673,66 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; + s32 sp1C = D_80BAE8F8[scheduleResult->result]; u16 phi_a0; if (sp1C >= 0) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } - if (this->unk404 == NULL) { + if (this->timePath == NULL) { return 0; } - if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { + if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->timePathTimeSpeed >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->time0; + phi_a0 = scheduleResult->time0; } - if (unkStruct->time1 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; + if (scheduleResult->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleResult->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->time1 - phi_a0; + this->timePathTotalTime = scheduleResult->time1 - phi_a0; } - this->unk424 = sp26 - phi_a0; - phi_a0 = this->unk404->count - 2; + this->timePathElapsedTime = sp26 - phi_a0; + phi_a0 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); this->unk42C = 0; - this->unk41C = this->unk418 / phi_a0; - this->unk420 = (this->unk424 / this->unk41C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_a0; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk430 = 0; return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 pad; EnDoor* sp48; - u8 sp47; - u16 sp44; + u8 sp47 = ENSUTTARI_GET_PATH(&this->actor); + u16 sp44 = SCHEDULE_TIME_NOW; Vec3f sp38; Vec3f sp2C; Vec3s* sp28; - UNK_TYPE sp24; + s32 sp24; - sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = SCHEDULE_TIME_NOW; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->result]; + sp24 = D_80BAE8F8[scheduleResult->result]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } - if ((sp48 == NULL) || (this->unk404 == NULL)) { + if ((sp48 == NULL) || (this->timePath == NULL)) { return 0; } - sp28 = Lib_SegmentedToVirtual(this->unk404->points); + sp28 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->time0; - this->unk436 = unkStruct->time1 - unkStruct->time0; - if (unkStruct->result != 10 && unkStruct->result != 11) { + this->unk434 = sp44 - scheduleResult->time0; + this->unk436 = scheduleResult->time1 - scheduleResult->time0; + if (scheduleResult->result != 10 && scheduleResult->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -744,15 +742,15 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 ret; - switch (unkStruct->result) { + switch (scheduleResult->result) { case 15: case 14: case 13: case 12: - ret = func_80BABC48(this, globalCtx, unkStruct); + ret = func_80BABC48(this, globalCtx, scheduleResult); break; case 11: case 10: @@ -760,7 +758,7 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk case 8: case 7: case 6: - ret = func_80BABDD8(this, globalCtx, unkStruct); + ret = func_80BABDD8(this, globalCtx, scheduleResult); break; case 5: case 4: @@ -777,45 +775,47 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk } s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk404->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk42C == 0) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &sp58, this->unk42A); - func_8013B878(globalCtx, this->unk404, this->unk420, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk42C = 1; } else { - sp58 = this->unk408; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk424; - sp50 = this->unk420; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk408 = gZeroVec3f; - if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &this->unk408, this->unk42A)) { + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk430 = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk408; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk424 = sp54; - this->unk420 = sp50; - this->unk408 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return 0; } @@ -837,7 +837,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { sp3C.z = this->unk434 * tmp; Lib_Vec3f_TranslateAndRotateY(&this->unk438, this->actor.world.rot.y, &sp3C, &sp30); this->actor.world.pos = sp30; - this->unk434 += this->unk42A; + this->unk434 += this->timePathTimeSpeed; return 0; } @@ -1099,17 +1099,17 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { @@ -1123,17 +1123,17 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); @@ -1244,7 +1244,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1252,22 +1252,22 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleResult.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1279,7 +1279,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1290,21 +1290,21 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.result != 9)) { + if ((this->flags1 & 0x20) && (scheduleResult.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 2fbdff53b..1fefc6f23 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -39,16 +39,15 @@ typedef struct EnSuttari { /* 0x3F4 */ s16 unk3F4; /* 0x3F6 */ s16 unk3F6; /* 0x3F8 */ Vec3f unk3F8; - /* 0x404 */ Path* unk404; - /* 0x408 */ Vec3f unk408; - /* 0x414 */ f32 unk414; - /* 0x418 */ s32 unk418; - /* 0x41C */ s32 unk41C; - /* 0x420 */ s32 unk420; - /* 0x424 */ s32 unk424; + /* 0x404 */ Path* timePath; + /* 0x408 */ Vec3f timePathTargetPos; + /* 0x414 */ f32 timePathProgress; + /* 0x418 */ s32 timePathTotalTime; + /* 0x41C */ s32 timePathWaypointTime; + /* 0x420 */ s32 timePathWaypoint; + /* 0x424 */ s32 timePathElapsedTime; /* 0x428 */ u8 unk428; - /* 0x429 */ UNK_TYPE1 unk_429[0x1]; - /* 0x42A */ s16 unk42A; + /* 0x42A */ s16 timePathTimeSpeed; /* 0x42C */ s32 unk42C; /* 0x430 */ s32 unk430; /* 0x434 */ s16 unk434; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 4f61ac43f..4dcea5b0d 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -343,7 +343,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC += (REG(15) * sp44) - temp2; temp3 = this->unk_2DC; - this->unk_3D0 = temp2 + temp3; + this->timePathTimeSpeed = temp2 + temp3; this->unk_2DC -= temp3; this->unk_2E0 += REG(15); @@ -384,88 +384,89 @@ void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { EnDoor* door; - f32 spA0[265]; + f32 knots[265]; Vec3f sp94; Vec3f sp88; - Vec3f sp7C; + Vec3f timePathTargetPos; s32 sp78; s32 sp74; - Actor* door2; - Actor* door1; - s32 pad2[1]; + s32 pad; - func_8013AF00(spA0, 3, this->unk_3C8->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3CE & 4)) { - sp7C = gZeroVec3f; - func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &sp7C, this->unk_3D0); - func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); - this->actor.world.pos.y = sp7C.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; } else { - sp7C = this->unk_3D4; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp7C.x; - this->actor.world.pos.z = sp7C.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (!(this->unk_3CE & 4)) { Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); this->unk_3CE |= 4; } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - sp78 = this->unk_3F0; - sp74 = this->unk_3EC; - sp7C = this->actor.world.pos; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + sp78 = this->timePathElapsedTime; + sp74 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_3D4 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &this->unk_3D4, this->unk_3D0)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3CE |= 8; } else { sp94 = this->actor.world.pos; - sp88 = this->unk_3D4; + sp88 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - this->unk_3F0 = sp78; - this->unk_3EC = sp74; - this->unk_3D4 = sp7C; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + this->timePathElapsedTime = sp78; + this->timePathWaypoint = sp74; + this->timePathTargetPos = timePathTargetPos; } door = NULL; if (!(this->unk_2CA & 0xC00)) { - door1 = NULL; - label: + Actor* doorIter = NULL; + do { - door1 = SubS_FindActor(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door1 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { - if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= - 0x2000) { + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &doorIter->world.pos), + this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - door = (EnDoor*)door1; + door = (EnDoor*)doorIter; break; } } - door1 = door1->next; + doorIter = doorIter->next; } - } while (door1 != NULL); + } while (doorIter != NULL); } else { - door2 = NULL; + Actor* doorIter = NULL; + do { - door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door2 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { - door = (EnDoor*)door2; + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 160.0f) { + door = (EnDoor*)doorIter; break; } - door2 = door2->next; + doorIter = doorIter->next; } - } while (door2 != NULL); + } while (doorIter != NULL); } if ((door != NULL) && (this->unk_2CA & 0x400)) { @@ -507,22 +508,22 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 phi_a1; s32 idx = arg2->result - 1; - this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); - if (this->unk_3C8 == 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); + if (this->timePath == NULL) { return false; } - if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { + if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->timePathTimeSpeed >= 0)) { phi_a1 = sp1E; } else { phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->time1 - phi_a1; - this->unk_3F0 = sp1E - phi_a1; - phi_a1 = this->unk_3C8->count - 2; - this->unk_3E8 = this->unk_3E4 / phi_a1; - this->unk_3EC = (this->unk_3F0 / this->unk_3E8) + 2; + this->timePathTotalTime = arg2->time1 - phi_a1; + this->timePathElapsedTime = sp1E - phi_a1; + phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_a1; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3CE &= ~4; this->unk_3CE &= ~8; return true; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 119ae2b2b..ade05d6be 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -51,16 +51,16 @@ typedef struct EnTk { /* 0x0324 */ Vec3f unk_324[6]; /* 0x036C */ s32 unk_36C; /* 0x0370 */ UNK_TYPE1 unk370[0x58]; - /* 0x03C8 */ Path* unk_3C8; + /* 0x03C8 */ Path* timePath; /* 0x03CC */ u8 unk_3CC; /* 0x03CE */ u16 unk_3CE; - /* 0x03D0 */ s32 unk_3D0; - /* 0x03D4 */ Vec3f unk_3D4; - /* 0x03E0 */ f32 unk_3E0; - /* 0x03E4 */ s32 unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ s32 unk_3F0; + /* 0x03D0 */ s32 timePathTimeSpeed; + /* 0x03D4 */ Vec3f timePathTargetPos; + /* 0x03E0 */ f32 timePathProgress; + /* 0x03E4 */ s32 timePathTotalTime; + /* 0x03E8 */ s32 timePathWaypointTime; + /* 0x03EC */ s32 timePathWaypoint; + /* 0x03F0 */ s32 timePathElapsedTime; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2c74907d5..6c0b5d2d7 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2661,19 +2661,19 @@ 0x8013AD6C:("SubS_InCsMode",), 0x8013AD9C:("SubS_UpdateLimb",), 0x8013AED4:("SubS_UpdateFlags",), - 0x8013AF00:("func_8013AF00",), - 0x8013B010:("func_8013B010",), - 0x8013B0C8:("func_8013B0C8",), - 0x8013B350:("func_8013B350",), - 0x8013B6B0:("func_8013B6B0",), - 0x8013B878:("func_8013B878",), + 0x8013AF00:("SubS_TimePathing_FillKnots",), + 0x8013B010:("SubS_TimePathing_ComputeProgress",), + 0x8013B0C8:("SubS_TimePathing_ComputeWeights",), + 0x8013B350:("SubS_TimePathing_ComputeTargetPosXZ",), + 0x8013B6B0:("SubS_TimePathing_Update",), + 0x8013B878:("SubS_TimePathing_ComputeInitialY",), 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), 0x8013BD40:("SubS_HasReachedPoint",), 0x8013BEDC:("SubS_GetDayDependentPath",), - 0x8013C068:("func_8013C068",), - 0x8013C624:("func_8013C624",), + 0x8013C068:("SubS_WeightPathing_ComputePoint",), + 0x8013C624:("SubS_WeightPathing_Move",), 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), 0x8013CC2C:("SubS_FillShadowTex",), @@ -2693,7 +2693,7 @@ 0x8013D9C8:("SubS_FillLimbRotTables",), 0x8013DB90:("SubS_IsFloorAbove",), 0x8013DC40:("SubS_CopyPointFromPathList",), - 0x8013DCCC:("SubS_GetPathCount",), + 0x8013DCCC:("SubS_GetPathCountFromPathList",), 0x8013DCE0:("SubS_ActorPathing_Init",), 0x8013DE04:("SubS_ActorPathing_Update",), 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 336b844df..602916a8e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1971,8 +1971,8 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), - 0x801C5D80:("gShadowVtxDL","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowMaterialDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowModelDL","UNK_TYPE1","",0x1), 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), @@ -15954,8 +15954,7 @@ 0x80BD68A0:("D_80BD68A0","UNK_TYPE1","",0x1), 0x80BD68A4:("D_80BD68A4","UNK_TYPE1","",0x1), 0x80BD6DF0:("En_Sc_Ruppe_InitVars","UNK_TYPE1","",0x1), - 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x1), - 0x80BD6E14:("D_80BD6E14","UNK_TYPE1","",0x1), + 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x30), 0x80BD6E40:("D_80BD6E40","UNK_TYPE1","",0x1), 0x80BD6E70:("jtbl_80BD6E70","UNK_PTR","",0x4), 0x80BD6E88:("D_80BD6E88","f32","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index bb57bb8a8..b3e5db147 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2175,19 +2175,19 @@ asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0 asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/SubS_UpdateLimb.s,SubS_UpdateLimb,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB -asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 -asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E -asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 -asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 -asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 -asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF +asm/non_matchings/code/z_sub_s/SubS_TimePathing_FillKnots.s,SubS_TimePathing_FillKnots,0x8013AF00,0x44 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeProgress.s,SubS_TimePathing_ComputeProgress,0x8013B010,0x2E +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeWeights.s,SubS_TimePathing_ComputeWeights,0x8013B0C8,0xA2 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeTargetPosXZ.s,SubS_TimePathing_ComputeTargetPosXZ,0x8013B350,0xD8 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_Update.s,SubS_TimePathing_Update,0x8013B6B0,0x72 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeInitialY.s,SubS_TimePathing_ComputeInitialY,0x8013B878,0xAF asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 -asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F -asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_ComputePoint.s,SubS_WeightPathing_ComputePoint,0x8013C068,0x16F +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_Move.s,SubS_WeightPathing_Move,0x8013C624,0xA5 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E @@ -2207,7 +2207,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_GetPathCountFromPathList.s,SubS_GetPathCountFromPathList,0x8013DCCC,0x5 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 From 9682995b04f93732c1ae143f66d2933b29dfd5b5 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 16:57:23 -0700 Subject: [PATCH 47/53] Controller Macros Update (#852) * macros * Format, I will remember 1 day --- include/macros.h | 8 +++--- src/code/flg_set.c | 2 +- src/code/z_kaleido_setup.c | 2 +- src/code/z_message.c | 6 ++--- .../actors/ovl_Arms_Hook/z_arms_hook.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 +-- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 10 ++++---- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 22 ++++++++-------- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 18 ++++++------- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 25 ++++++++++--------- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 21 ++++++++-------- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 4 +-- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 23 +++++++++-------- src/overlays/gamestates/ovl_select/z_select.c | 2 +- 16 files changed, 79 insertions(+), 74 deletions(-) diff --git a/include/macros.h b/include/macros.h index bb7315b3d..ddf3dcc87 100644 --- a/include/macros.h +++ b/include/macros.h @@ -111,10 +111,10 @@ #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) -#define CONTROLLER1(globalCtx) (&(globalCtx)->state.input[0]) -#define CONTROLLER2(globalCtx) (&(globalCtx)->state.input[1]) -#define CONTROLLER3(globalCtx) (&(globalCtx)->state.input[2]) -#define CONTROLLER4(globalCtx) (&(globalCtx)->state.input[3]) +#define CONTROLLER1(gameState) (&(gameState)->input[0]) +#define CONTROLLER2(gameState) (&(gameState)->input[1]) +#define CONTROLLER3(gameState) (&(gameState)->input[2]) +#define CONTROLLER4(gameState) (&(gameState)->input[3]) #define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) #define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 53be7b68d..715d3756f 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -135,7 +135,7 @@ static s32 sTimer = 0; void FlagSet_Update(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); /* Intra-byte navigation */ diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 5a234ea44..5ed36d551 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -60,7 +60,7 @@ void func_800F4A10(GlobalContext* globalCtx) { } void KaleidoSetup_Update(GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); MessageContext* msgCtx = &globalCtx->msgCtx; Player* player = GET_PLAYER(globalCtx); PauseContext* pauseCtx = &globalCtx->pauseCtx; diff --git a/src/code/z_message.c b/src/code/z_message.c index 2a90f38ca..d8e2d5c8a 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -67,7 +67,7 @@ void func_80147564(GlobalContext* globalCtx) { s32 Message_ShouldAdvance(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; - Input* controller = CONTROLLER1(globalCtx); + Input* controller = CONTROLLER1(&globalCtx->state); if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { @@ -86,7 +86,7 @@ s32 Message_ShouldAdvance(GlobalContext* globalCtx) { s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; - Input* controller = CONTROLLER1(globalCtx); + Input* controller = CONTROLLER1(&globalCtx->state); if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { return CHECK_BTN_ALL(controller->press.button, BTN_A); @@ -117,7 +117,7 @@ void func_801477B4(GlobalContext* globalCtx) { void func_80148B98(GlobalContext* globalCtx, u8 arg1) { static s16 held = 0; MessageContext* msgCtx = &globalCtx->msgCtx; - Input* curInput = CONTROLLER1(globalCtx); + Input* curInput = CONTROLLER1(&globalCtx->state); if ((curInput->rel.stick_y > 29) && held == 0) { held = 1; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 16aa93bd9..18d5792d6 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -271,7 +271,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); } } else { - if (CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + if (CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { s32 pad; this->timer = 1; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index bad5f7383..900ca2a7d 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1664,7 +1664,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 1: if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; @@ -1713,7 +1713,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 10: if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 1959ba26b..9691940d1 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -848,7 +848,7 @@ void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); f32 jawZRotTarget; f32 xDiff; f32 yDiff; diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 668033cd6..dfd978d10 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1923,7 +1923,7 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { f32 spC8; f32 spC4; f32 spC0; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); Player* player = GET_PLAYER(globalCtx); s32 pad; @@ -2075,7 +2075,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Vec3f spA8; Vec3f sp9C; Vec3f sp90; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); D_809171FE++; @@ -2864,7 +2864,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { EnFishing* this = THIS; GlobalContext* globalCtx = globalCtx2; Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); f32 spD8; f32 phi_f0; f32 phi_f2; @@ -5052,7 +5052,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 lureDistXZ; Camera* camera; Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5621,7 +5621,7 @@ TexturePtr sFishingOwnerEyeTexs[] = { void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFishing* this = THIS; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index bfeca2143..233c0fe61 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -127,11 +127,11 @@ s32 EnFsn_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { @@ -483,8 +483,8 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, GlobalContext* globalCtx, Input* in } void EnFsn_UpdateJoystickInputState(EnFsn* this, GlobalContext* globalCtx) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -882,7 +882,8 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1108,7 +1109,7 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { EnFsn_UpdateCursorPos(this, globalCtx); if (talkstate == 5) { func_8011552C(globalCtx, 6); - if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnFsn_CursorLeftRight(this); if (this->cursorIdx != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); @@ -1210,7 +1211,8 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnFsn_HandleCanPlayerBuyItem(this, globalCtx); @@ -1330,7 +1332,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 907ba619b..ae1022413 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -235,9 +235,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.fileNum != 0xFEDC) { if (this->state == MAG_STATE_INITIAL) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { if (!EnvFlags_Get(globalCtx, 4)) { play_sound(NA_SE_SY_PIECE_OF_HEART); @@ -378,9 +378,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { EnMag_UpdateDisplayEffectColors(&this->actor); if (sInputDelayTimer == 0) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { if (globalCtx->sceneLoadFlag != 0x14) { Audio_SetCutsceneFlag(false); D_801BB12C++; @@ -427,9 +427,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { // Appear fully immediately if called during fade-in states. if ((this->state > MAG_STATE_INITIAL) && (this->state < MAG_STATE_CALLED)) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { play_sound(NA_SE_SY_PIECE_OF_HEART); this->state = MAG_STATE_CALLED; } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index ff85b7625..be1def264 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -199,11 +199,11 @@ s32 EnOssan_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } void EnOssan_CheckValidSpawn(EnOssan* this) { @@ -453,8 +453,8 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_UpdateJoystickInputState(GlobalContext* globalCtx, EnOssan* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; this->moveHorizontal = this->moveVertical = false; @@ -574,7 +574,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { } else if (this->flags & END_INTERACTION) { this->flags &= ~END_INTERACTION; EnOssan_EndInteraction(globalCtx, this); - } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnOssan_StartShopping(globalCtx, this); } else { return; @@ -631,7 +631,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } else { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && + if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); @@ -854,7 +854,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { EnOssan_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { if (this->moveHorizontal) { if (this->stickAccumX > 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); @@ -912,7 +912,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { EnOssan_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { if (this->moveHorizontal != 0) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); @@ -1053,7 +1053,8 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnOssan_HandleCanBuyItem(globalCtx, this); @@ -1124,7 +1125,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index a20556a31..ef47146b9 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -177,11 +177,11 @@ s32 EnSob1_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { @@ -555,8 +555,8 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_UpdateJoystickInputState(GlobalContext* globalCtx, EnSob1* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -611,7 +611,7 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { } } if ((talkState == 5) && Message_ShouldAdvance(globalCtx) && - !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); } else { @@ -661,7 +661,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } else { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { cursorIndex = EnSob1_SetCursorIndexFromNeutral(this, 2); @@ -913,7 +913,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { EnSob1_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { EnSob1_CursorLeftRight(globalCtx, this); cursorIndex = this->cursorIndex; if (cursorIndex != prevCursorIndex) { @@ -1021,7 +1021,8 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnSob1_HandleCanBuyItem(globalCtx, this); diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index 66ee6080e..6f52cfed7 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -564,7 +564,7 @@ void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_159 = 1; } - input = CONTROLLER3(globalCtx); + input = CONTROLLER3(&globalCtx->state); if (CHECK_BTN_ALL(input->press.button, BTN_L)) { this->unk_158 = 1; } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 2efb3eb6b..5cca94ff0 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -407,7 +407,7 @@ void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { } void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); s16 temp_s0; Player* player = GET_PLAYER(globalCtx); Camera* sp78; @@ -628,7 +628,7 @@ void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { } void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); Player* player = GET_PLAYER(globalCtx); Camera* camera; s32 pad; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 470f4908a..17094ac7f 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -114,11 +114,11 @@ s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } void EnTrt_SpawnShopItems(EnTrt* this, GlobalContext* globalCtx, ShopItem* shopItem) { @@ -257,8 +257,8 @@ void EnTrt_StartShopping(GlobalContext* globalCtx, EnTrt* this) { } void EnTrt_UpdateJoystickInputState(GlobalContext* globalCtx, EnTrt* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -314,7 +314,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { } if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { play_sound(NA_SE_SY_MESSAGE_PASS); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnTrt_StartShopping(globalCtx, this); } } @@ -520,7 +520,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); @@ -622,7 +622,7 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { EnTrt_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { EnTrt_CursorLeftRight(globalCtx, this); if (this->cursorIdx != prevCursorIdx) { func_80151938(globalCtx, EnTrt_GetItemTextId(this)); @@ -707,7 +707,8 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnTrt_HandleCanBuyItem(globalCtx, this); @@ -1098,7 +1099,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 53dbc266f..ea650803e 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -357,7 +357,7 @@ static SceneSelectEntry sScenes[] = { void Select_UpdateMenu(SelectContext* this) { s32 playerForm; - Input* controller1 = CONTROLLER1(this); + Input* controller1 = CONTROLLER1(&this->state); s32 stickY; s32 pad[2]; s16 i; From 6d371502e1fcc7777035fd977df518bb0e3aab1c Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 19 Jun 2022 17:11:47 -0700 Subject: [PATCH 48/53] Actor effect cleanup (#828) * Change "particle" to "effect" in most actors * Undo accidental comment change * Effect count defines * Make struct names consistent * Fix minislime * Change particle to effect in Demo_Kankyo * Some tiny things I missed --- include/z64.h | 2 +- .../actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c | 6 +- .../actors/ovl_Boss_Hakugin/z_boss_hakugin.h | 8 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 413 +++++++++--------- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.h | 8 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 110 +++-- src/overlays/actors/ovl_En_Baguo/z_en_baguo.h | 14 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 32 +- .../actors/ovl_En_Bigslime/z_en_bigslime.h | 6 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 98 ++--- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 8 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 71 ++- src/overlays/actors/ovl_En_Dai/z_en_dai.h | 8 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 64 +-- .../actors/ovl_En_Daiku2/z_en_daiku2.h | 8 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 88 ++-- src/overlays/actors/ovl_En_Dnb/z_en_dnb.h | 6 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 62 +-- .../actors/ovl_En_Encount2/z_en_encount2.h | 12 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 95 ++-- src/overlays/actors/ovl_En_Fall/z_en_fall.h | 2 +- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 40 +- .../actors/ovl_En_Minislime/z_en_minislime.c | 22 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 117 +++-- src/overlays/actors/ovl_En_Raf/z_en_raf.h | 14 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 6 +- tools/disasm/functions.txt | 30 +- 27 files changed, 673 insertions(+), 677 deletions(-) diff --git a/include/z64.h b/include/z64.h index 6331a456a..a7895b186 100644 --- a/include/z64.h +++ b/include/z64.h @@ -705,7 +705,7 @@ typedef struct { /* 0xEC */ u8 unk_EC; /* 0xED */ u8 unk_ED; /* 0xEE */ u8 unk_EE[4]; - /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo particle count + /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo effect count /* 0xFA */ u8 unk_FA[4]; } EnvironmentContext; // size = 0x100 diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index d064a3cb4..aae5930ed 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -20,7 +20,7 @@ void func_80B40100(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B400C8(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx); void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx); -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx); +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx); const ActorInit Bg_Goron_Oyu_InitVars = { @@ -108,7 +108,7 @@ void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx) { } } -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, GlobalContext* globalCtx) { s16 scale; Vec3f pos1; Vec3f pos2; @@ -178,7 +178,7 @@ void BgGoronOyu_Update(Actor* thisx, GlobalContext* globalCtx) { BgGoronOyu* this = THIS; this->actionFunc(this, globalCtx); - BgGoronOyu_SpawnParticles(this, globalCtx); + BgGoronOyu_SpawnEffects(this, globalCtx); } void BgGoronOyu_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h index 3b5882692..3aa7d122a 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -7,21 +7,23 @@ struct BossHakugin; typedef void (*BossHakuginActionFunc)(struct BossHakugin*, GlobalContext*); -typedef struct BossHakuginParticle { +typedef struct BossHakuginEffect { /* 0x00 */ Vec3f unk_0; /* 0x0C */ Vec3f unk_C; /* 0x18 */ s16 unk_18; /* 0x1A */ s16 unk_1A; /* 0x1C */ Vec3s unk_1C; /* 0x24 */ f32 unk_24; -} BossHakuginParticle; // size = 0x28 +} BossHakuginEffect; // size = 0x28 + +#define BOSS_HAKUGIN_EFFECT_COUNT 180 typedef struct BossHakugin { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_0144[0x44]; /* 0x0188 */ BossHakuginActionFunc actionFunc; /* 0x018C */ char unk_018C[0x86C]; - /* 0x09F8 */ BossHakuginParticle unk_9F8[180]; + /* 0x09F8 */ BossHakuginEffect unk_9F8[BOSS_HAKUGIN_EFFECT_COUNT]; /* 0x2618 */ char unk_2618[0x11F8]; } BossHakugin; // size = 0x3810 diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 2c676abbf..179d480de 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -1,7 +1,7 @@ /* * File: z_demo_kankyo.c * Overlay: ovl_Demo_Kankyo - * Description: Background Lost Woods/Giant's Chamber/Moon Particles + * Description: Background Lost Woods/Giant's Chamber/Moon Effects */ #include "z_demo_kankyo.h" @@ -44,7 +44,7 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa s32 pad; s32 i; f32 randSkyfishParticleNum; - f32 repositionLimit; // Distance from posCenter when particles are relocated. Always set to 130.0f + f32 repositionLimit; // Distance from posCenter when effects are relocated. Always set to 130.0f f32 eyeToAtNormX; f32 eyeToAtNormY; f32 eyeToAtNormZ; @@ -61,13 +61,13 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa } else { Actor_MarkForDeath(&this->actor); } - } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { globalCtx->envCtx.unk_F2[3] += 16; } // note: DemoKankyo can crash if placed in an area that snows (ObjectKankyo) - // because they both use unk_F2 as a particle counter, - // causing DemoKankyo to write beyond its particle array boundry + // because they both use unk_F2 as an effect counter, + // causing DemoKankyo to write beyond its efffect array boundry // this crash can occur if the two actors are in different scenes connected by an exit // e.g. if you add DemoKankyo to GoronShrine, you will crash entering/leaving through door for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { @@ -81,53 +81,53 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa eyeToAtNormY = eyeToAt.y / eyeToAtMag; eyeToAtNormZ = eyeToAt.z / eyeToAtMag; - switch (this->particles[i].state) { + switch (this->effects[i].state) { case DEMO_KANKYO_STATE_INIT: - this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); - this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); - this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); + this->effects[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); + this->effects[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); - this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->particles[i].posOffset.y = 30.0f; - this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->effects[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->effects[i].posOffset.y = 30.0f; + this->effects[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; - this->particles[i].alpha = 0; - this->particles[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 - this->particles[i].scale = 0.1f; + this->effects[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->effects[i].alpha = 0; + this->effects[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 + this->effects[i].scale = 0.1f; // speedClock is angles in radians, // should have used Rand_ZeroOne() * 2 * M_PI // however, due to properties of sine waves, this is effectively still random - this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; - this->particles[i].pad50 = 0; - this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + this->effects[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->effects[i].pad50 = 0; + this->effects[i].state += DEMO_KANKYO_STATE_SINGLE; break; case DEMO_KANKYO_STATE_SINGLE: case DEMO_KANKYO_STATE_SKYFISH: - this->particles[i].alphaClock++; + this->effects[i].alphaClock++; posCenterX = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); posCenterY = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); posCenterZ = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); - this->particles[i].posOffsetPrev.x = this->particles[i].posOffset.x; - this->particles[i].posOffsetPrev.y = this->particles[i].posOffset.y; - this->particles[i].posOffsetPrev.z = this->particles[i].posOffset.z; + this->effects[i].posOffsetPrev.x = this->effects[i].posOffset.x; + this->effects[i].posOffsetPrev.y = this->effects[i].posOffset.y; + this->effects[i].posOffsetPrev.z = this->effects[i].posOffset.z; - if (this->particles[i].state == DEMO_KANKYO_STATE_SINGLE) { + if (this->effects[i].state == DEMO_KANKYO_STATE_SINGLE) { - // The first 32 particles will become skyfish particles + // The first 32 effects will become skyfish particles // This block is also init code and only runs once if (i < 32) { if (Rand_ZeroOne() < 0.5f) { - this->particles[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; + this->effects[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; } else { - this->particles[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); + this->effects[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); } - this->particles[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; - this->particles[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; + this->effects[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; + this->effects[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; // Only the 31st particle matters as sLostWoodsSkyFishParticleNum will be overwritten // every particle until the last skyfish particle is initialized @@ -145,147 +145,134 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa if ((i & sLostWoodsSkyFishParticleNum) == 0) { // Head particle - this->particles[i].posOffset.y = 0.0f; + this->effects[i].posOffset.y = 0.0f; } - this->particles[i].state = DEMO_KANKYO_STATE_SKYFISH; - this->particles[i].speedTarget = 0.0f; + this->effects[i].state = DEMO_KANKYO_STATE_SKYFISH; + this->effects[i].speedTarget = 0.0f; } - Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + Math_SmoothStepToF(&this->effects[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].speedTarget, 0.5f, 0.2f, 0.02f); + this->effects[i].posOffset.x += sinf(this->effects[i].speedClock.x) * this->effects[i].speed; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y) * this->effects[i].speed; + this->effects[i].posOffset.z += sinf(this->effects[i].speedClock.z) * this->effects[i].speed; switch ((i >> 1) & 3) { case 0: - this->particles[i].speedClock.x += 0.008f; - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.015f; + this->effects[i].speedClock.x += 0.008f; + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.015f; break; case 1: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.005f * Rand_ZeroOne(); break; case 2: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.004f * Rand_ZeroOne(); break; case 3: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.05f * Rand_ZeroOne(); break; } - } else if (this->particles[i].state == DEMO_KANKYO_STATE_SKYFISH) { + } else if (this->effects[i].state == DEMO_KANKYO_STATE_SKYFISH) { if ((i & sLostWoodsSkyFishParticleNum) == 0) { // Head particle - Math_SmoothStepToF(&this->particles[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, + Math_SmoothStepToF(&this->effects[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->effects[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->effects[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posOffset.x, - Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax, + Math_SmoothStepToF(&this->effects[i].posOffset.x, + Math_SinS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posOffset.z, - Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax, + Math_SmoothStepToF(&this->effects[i].posOffset.z, + Math_CosS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); - this->particles[i].LostWoodsSkyFishSpeedXZClock += this->particles[i].LostWoodsSkyFishSpeedXZ; - this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y); - this->particles[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation - this->particles[i].speedClock.y += this->particles[i].LostWoodsSkyFishSpeedY; - this->particles[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation + this->effects[i].LostWoodsSkyFishSpeedXZClock += this->effects[i].LostWoodsSkyFishSpeedXZ; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y); + this->effects[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation + this->effects[i].speedClock.y += this->effects[i].LostWoodsSkyFishSpeedY; + this->effects[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation - this->particles[i].posOffset.x = - Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax; - this->particles[i].posOffset.z = - Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax; + this->effects[i].posOffset.x = + Math_SinS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax; + this->effects[i].posOffset.z = + Math_CosS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax; } else { // Tail Particles - Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); // Unused calculation, speed only used in posOffset calculations, // but posOffset gets overwritten for tail particles immediately below - Math_SmoothStepToF(&this->particles[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); + Math_SmoothStepToF(&this->effects[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); // particles in the skyfish's tail are moved to the previous position of the particle directly // in front - this->particles[i].posOffset.x = - this->particles[i - 1].posOffsetPrev.x + - (this->particles[i - 1].posBase.x - this->particles[i].posBase.x); - this->particles[i].posOffset.y = - this->particles[i - 1].posOffsetPrev.y + - (this->particles[i - 1].posBase.y - this->particles[i].posBase.y); - this->particles[i].posOffset.z = - this->particles[i - 1].posOffsetPrev.z + - (this->particles[i - 1].posBase.z - this->particles[i].posBase.z); + this->effects[i].posOffset.x = this->effects[i - 1].posOffsetPrev.x + + (this->effects[i - 1].posBase.x - this->effects[i].posBase.x); + this->effects[i].posOffset.y = this->effects[i - 1].posOffsetPrev.y + + (this->effects[i - 1].posBase.y - this->effects[i].posBase.y); + this->effects[i].posOffset.z = this->effects[i - 1].posOffsetPrev.z + + (this->effects[i - 1].posBase.z - this->effects[i].posBase.z); } } - if ((this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) && - ((((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) > - repositionLimit) || - (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < - -repositionLimit) || - (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > - repositionLimit) || - (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < - -repositionLimit) || - (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > - repositionLimit) || - (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < - -repositionLimit))) { - if (((this->particles[i].posOffset.x + this->particles[i].posBase.x) - posCenterX) > - repositionLimit) { - this->particles[i].posOffset.x = 0.0f; - this->particles[i].posBase.x = posCenterX - repositionLimit; + if ((this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) && + ((((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) > repositionLimit) || + (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) < -repositionLimit) || + (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) > repositionLimit) || + (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) < -repositionLimit) || + (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) > repositionLimit) || + (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) < -repositionLimit))) { + if (((this->effects[i].posOffset.x + this->effects[i].posBase.x) - posCenterX) > repositionLimit) { + this->effects[i].posOffset.x = 0.0f; + this->effects[i].posBase.x = posCenterX - repositionLimit; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < - -repositionLimit) { - this->particles[i].posOffset.x = 0.0f; - this->particles[i].posBase.x = posCenterX + repositionLimit; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) < -repositionLimit) { + this->effects[i].posOffset.x = 0.0f; + this->effects[i].posBase.x = posCenterX + repositionLimit; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > 50.0f) { - this->particles[i].posOffset.y = 0.0f; - this->particles[i].posBase.y = posCenterY - 50.0f; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) > 50.0f) { + this->effects[i].posOffset.y = 0.0f; + this->effects[i].posBase.y = posCenterY - 50.0f; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < -50.0f) { - this->particles[i].posOffset.y = 0.0f; - this->particles[i].posBase.y = posCenterY + 50.0f; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) < -50.0f) { + this->effects[i].posOffset.y = 0.0f; + this->effects[i].posBase.y = posCenterY + 50.0f; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > - repositionLimit) { - this->particles[i].posOffset.z = 0.0f; - this->particles[i].posBase.z = posCenterZ - repositionLimit; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) > repositionLimit) { + this->effects[i].posOffset.z = 0.0f; + this->effects[i].posBase.z = posCenterZ - repositionLimit; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < - -repositionLimit) { - this->particles[i].posOffset.z = 0.0f; - this->particles[i].posBase.z = posCenterZ + repositionLimit; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) < -repositionLimit) { + this->effects[i].posOffset.z = 0.0f; + this->effects[i].posBase.z = posCenterZ + repositionLimit; } } break; case DEMO_KANKYO_STATE_DISABLED: - this->particles[i].state = DEMO_KANKYO_STATE_INIT; + this->effects[i].state = DEMO_KANKYO_STATE_INIT; break; } } @@ -317,7 +304,7 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx s32 pad1; Vec3f worldPos; - if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { globalCtx->envCtx.unk_F2[3] += 16; } @@ -332,38 +319,38 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx halfScreenHeight = SCREEN_HEIGHT / 2; for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - switch (this->particles[i].state) { + switch (this->effects[i].state) { case DEMO_KANKYO_STATE_INIT: - this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); - this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); - this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); + this->effects[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); + this->effects[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); - this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; - this->particles[i].alpha = 0; - this->particles[i].alphaClock = (Rand_ZeroOne() * 65535); - this->particles[i].scale = 0.2f; + this->effects[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->effects[i].alpha = 0; + this->effects[i].alphaClock = (Rand_ZeroOne() * 65535); + this->effects[i].scale = 0.2f; // speedClock is angles in radians, // should have used Rand_ZeroOne() * 2 * M_PI // however, due to properties of sine waves, this is effectively still random - this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.z = Rand_ZeroOne() * 360.0f; - this->particles[i].pad50 = 0; - this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + this->effects[i].pad50 = 0; + this->effects[i].state += DEMO_KANKYO_STATE_SINGLE; break; case DEMO_KANKYO_STATE_SINGLE: case DEMO_KANKYO_STATE_SKYFISH: - this->particles[i].alphaClock++; + this->effects[i].alphaClock++; if (this->actor.params == DEMO_KANKYO_TYPE_MOON) { // this function gets reused for giants too - this->particles[i].posBase.y = + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight) + (SCREEN_HEIGHT / 3); } @@ -371,76 +358,76 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx newEye.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); newEye.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); - Math_SmoothStepToF(&this->particles[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); + Math_SmoothStepToF(&this->effects[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->effects[i].posOffset.x += sinf(this->effects[i].speedClock.x) * this->effects[i].speed; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y) * this->effects[i].speed; + this->effects[i].posOffset.z += sinf(this->effects[i].speedClock.z) * this->effects[i].speed; switch ((i >> 1) & 3) { case 0: - this->particles[i].speedClock.x += 0.008f; - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.015f; + this->effects[i].speedClock.x += 0.008f; + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.015f; break; case 1: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.005f * Rand_ZeroOne(); break; case 2: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.004f * Rand_ZeroOne(); break; case 3: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.05f * Rand_ZeroOne(); break; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) > halfScreenHeight) { - this->particles[i].posBase.x = newEye.x - halfScreenHeight; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - newEye.x) > halfScreenHeight) { + this->effects[i].posBase.x = newEye.x - halfScreenHeight; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) < -halfScreenHeight) { - this->particles[i].posBase.x = newEye.x + halfScreenHeight; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - newEye.x) < -halfScreenHeight) { + this->effects[i].posBase.x = newEye.x + halfScreenHeight; } - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; randZeroOne = Math_Vec3f_DistXZ(&worldPos, &globalCtx->view.eye) / 200.0f; randZeroOne = CLAMP(randZeroOne, 0.0f, 1.0f); halfScreenWidth = 100.0f + randZeroOne + 60.0f; // range 160 to 161...? thats about half screen width - // I think this code is shifting the particles 1 frame -> half screen at a time to keep it in-view - if (halfScreenWidth < ((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y)) { - this->particles[i].posBase.y = newEye.y - halfScreenWidth; + // I think this code is shifting the effects 1 frame -> half screen at a time to keep it in-view + if (halfScreenWidth < ((this->effects[i].posBase.y + this->effects[i].posOffset.y) - newEye.y)) { + this->effects[i].posBase.y = newEye.y - halfScreenWidth; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y) < -halfScreenWidth) { - this->particles[i].posBase.y = newEye.y + halfScreenWidth; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - newEye.y) < -halfScreenWidth) { + this->effects[i].posBase.y = newEye.y + halfScreenWidth; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) > halfScreenHeight) { - this->particles[i].posBase.z = newEye.z - halfScreenHeight; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - newEye.z) > halfScreenHeight) { + this->effects[i].posBase.z = newEye.z - halfScreenHeight; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) < -halfScreenHeight) { - this->particles[i].posBase.z = newEye.z + halfScreenHeight; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - newEye.z) < -halfScreenHeight) { + this->effects[i].posBase.z = newEye.z + halfScreenHeight; } break; case DEMO_KANKYO_STATE_DISABLED: - this->particles[i].state = DEMO_KANKYO_STATE_INIT; + this->effects[i].state = DEMO_KANKYO_STATE_INIT; break; } } @@ -454,7 +441,7 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { // This must be a single line to match, possibly a macro? // clang-format off - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { this->particles[i].state = DEMO_KANKYO_STATE_INIT; } + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { this->effects[i].state = DEMO_KANKYO_STATE_INIT; } // clang-format on if (1) {}; @@ -524,9 +511,9 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT @@ -534,52 +521,52 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); - scaleAlpha = this->particles[i].alpha / 50.0f; + scaleAlpha = this->effects[i].alpha / 50.0f; if (scaleAlpha > 1.0f) { scaleAlpha = 1.0f; } - Matrix_Scale(this->particles[i].scale * scaleAlpha, this->particles[i].scale * scaleAlpha, - this->particles[i].scale * scaleAlpha, MTXMODE_APPLY); + Matrix_Scale(this->effects[i].scale * scaleAlpha, this->effects[i].scale * scaleAlpha, + this->effects[i].scale * scaleAlpha, MTXMODE_APPLY); // adjust transparency of this particle if (i < 32) { // Skyfish particles - if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if (this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) { // still initializing - if (this->particles[i].alpha > 0) { // NOT DECR - this->particles[i].alpha--; + if (this->effects[i].alpha > 0) { // NOT DECR + this->effects[i].alpha--; } - } else if (this->particles[i].alpha < 100) { - this->particles[i].alpha++; + } else if (this->effects[i].alpha < 100) { + this->effects[i].alpha++; } - } else if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { - if ((this->particles[i].alphaClock & 31) < 16) { - if (this->particles[i].alpha < 235) { - this->particles[i].alpha += 20; + } else if (this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if ((this->effects[i].alphaClock & 31) < 16) { + if (this->effects[i].alpha < 235) { + this->effects[i].alpha += 20; } - } else if (this->particles[i].alpha > 20) { - this->particles[i].alpha -= 20; + } else if (this->effects[i].alpha > 20) { + this->effects[i].alpha -= 20; } - } else if ((this->particles[i].alphaClock & 15) < 8) { - if (this->particles[i].alpha < 255) { - this->particles[i].alpha += 100; + } else if ((this->effects[i].alphaClock & 15) < 8) { + if (this->effects[i].alpha < 255) { + this->effects[i].alpha += 100; } - } else if (this->particles[i].alpha > 10) { - this->particles[i].alpha -= 10; + } else if (this->effects[i].alpha > 10) { + this->effects[i].alpha -= 10; } gDPPipeSync(POLY_XLU_DISP++); switch (i & 1) { case 0: // gold particles - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->effects[i].alpha); break; case 1: // silver particles - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->effects[i].alpha); break; } @@ -613,42 +600,42 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(gfxCtx); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT - // checking if particle is on screen + // checking if effect is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); - alphaScale = this->particles[i].alpha / 50.0f; + alphaScale = this->effects[i].alpha / 50.0f; if (alphaScale > 1.0f) { alphaScale = 1.0f; } - Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, - this->particles[i].scale * alphaScale, MTXMODE_APPLY); + Matrix_Scale(this->effects[i].scale * alphaScale, this->effects[i].scale * alphaScale, + this->effects[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { - this->particles[i].alpha = 255.0f * alphaScale; + this->effects[i].alpha = 255.0f * alphaScale; } else { - this->particles[i].alpha = 160.0f * alphaScale; + this->effects[i].alpha = 160.0f * alphaScale; } gDPPipeSync(POLY_XLU_DISP++); switch (i & 1) { // half/half slightly different shades of yellow/tan case 0: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->effects[i].alpha); break; case 1: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->effects[i].alpha); break; } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h index d70616ed6..e614117ee 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -18,18 +18,18 @@ typedef struct { /* 0x03C */ u16 alphaClock; /* 0x03E */ u16 LostWoodsSkyFishSpeedXZClock; /* 0x040 */ u8 alpha; - /* 0x044 */ f32 scale; // size of the particle + /* 0x044 */ f32 scale; // size of the effect /* 0x048 */ u16 LostWoodsSkyFishSpeedXZ; // the x-z speed (angular velocity) the lost woods skyfish oscillates around player. pos or neg 200-400 /* 0x04A */ u16 LostWoodsSkyFishPosOffsetMax; // The x-z range the lost woods skyfish oscillates around player. random value between 15-65 /* 0x04C */ f32 LostWoodsSkyFishSpeedY; // the y speed (angular velocity) the lost woods skyfish oscillates around player. /* 0x050 */ u16 pad50; // unused, always assigned to 0, nothing else in this actor uses it -} DemoKankyoParticle; // size = 0x54 +} DemoKankyoEffect; // size = 0x54 -#define DEMOKANKYO_PARTICLE_COUNT 64 +#define DEMOKANKYO_EFFECT_COUNT 64 typedef struct DemoKankyo { /* 0x0000 */ Actor actor; - /* 0x0144 */ DemoKankyoParticle particles[DEMOKANKYO_PARTICLE_COUNT]; + /* 0x0144 */ DemoKankyoEffect effects[DEMOKANKYO_EFFECT_COUNT]; /* 0x1644 */ DemoKankyoActionFunc actionFunc; /* 0x1648 */ s32 objectId; /* 0x164C */ u8 isSafeToDrawGiants; diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 88fc11072..66ba49919 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -22,10 +22,9 @@ void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx); void EnBaguo_SetupRetreatUnderground(EnBaguo* this); void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx); void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx); -void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer); -void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx); -void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnBaguo_UpdateEffects(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_DrawEffects(EnBaguo* this, GlobalContext* globalCtx); typedef enum { /* 0x0 */ NEJIRON_ACTION_INACTIVE, // The Nejiron is either underground or emerging from underground @@ -311,7 +310,7 @@ void EnBaguo_PostDetonation(EnBaguo* this, GlobalContext* globalCtx) { void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; s32 i; // In order to match, this variable must act as both a boolean to check if @@ -335,15 +334,15 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->actor.shape.shadowScale = 0.0f; - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - acceleration.x = (Rand_ZeroOne() - 0.5f) * 8.0f; - acceleration.y = -1.0f; - acceleration.z = (Rand_ZeroOne() - 0.5f) * 8.0f; + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + accel.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + accel.y = -1.0f; + accel.z = (Rand_ZeroOne() - 0.5f) * 8.0f; velocity.x = (Rand_ZeroOne() - 0.5f) * 14.0f; velocity.y = Rand_ZeroOne() * 30.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 14.0f; - EnBaguo_InitializeParticle(this, &this->actor.focus.pos, &velocity, &acceleration, - (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); + EnBaguo_InitializeEffect(this, &this->actor.focus.pos, &velocity, &accel, + (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); } Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -368,7 +367,7 @@ void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; Actor_SetFocus(&this->actor, 30.0f); - EnBaguo_UpdateParticles(this, globalCtx); + EnBaguo_UpdateEffects(this, globalCtx); EnBaguo_CheckForDetonation(this, globalCtx); this->actionFunc(this, globalCtx); @@ -432,77 +431,76 @@ void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - EnBaguo_DrawRockParticles(this, globalCtx); + EnBaguo_DrawEffects(this, globalCtx); } -void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer) { +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { s16 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isVisible) { - particle->isVisible = true; - particle->position = *position; - particle->velocity = *velocity; - particle->acceleration = *acceleration; - particle->scale = scale; - particle->timer = timer; - particle->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = timer; + effect->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); return; } } } -void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_UpdateEffects(EnBaguo* this, GlobalContext* globalCtx) { s32 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - particle->position.x += particle->velocity.x; - particle->position.y += particle->velocity.y; - particle->position.z += particle->velocity.z; - particle->rotation.x += 0xBB8; - particle->rotation.y += 0xBB8; - particle->rotation.z += 0xBB8; - particle->velocity.x += particle->acceleration.x; - particle->velocity.y += particle->acceleration.y; - particle->velocity.z += particle->acceleration.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->rotation.x += 0xBB8; + effect->rotation.y += 0xBB8; + effect->rotation.z += 0xBB8; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; - if (particle->position.y < (this->actor.world.pos.y - 10.0f)) { - Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); - if (particle->scale <= 0.0001f) { - particle->timer = 0; + if (effect->pos.y < (this->actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&effect->scale, 0.2f, 0.001f); + if (effect->scale <= 0.0001f) { + effect->timer = 0; } } - if (particle->timer != 0) { - particle->timer--; + if (effect->timer != 0) { + effect->timer--; } else { - particle->isVisible = false; + effect->isEnabled = false; } } } } -void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_DrawEffects(EnBaguo* this, GlobalContext* globalCtx) { s16 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateXS(effect->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rotation.z, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 255, 255, 255, 255); diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h index 133e68b3d..553a77f48 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h @@ -12,15 +12,17 @@ typedef void (*EnBaguoActionFunc)(struct EnBaguo*, GlobalContext*); * When a Nejiron explodes, rock particles fly out from where it exploded. * This struct governs how these rock particles behave. */ -typedef struct NejironParticle { - /* 0x00 */ u8 isVisible; - /* 0x04 */ Vec3f position; +typedef struct NejironEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Vec3s rotation; /* 0x30 */ f32 scale; /* 0x34 */ s16 timer; -} NejironParticle; // size = 0x38 +} NejironEffect; // size = 0x38 + +#define EN_BAGUO_EFFECT_COUNT 30 typedef struct EnBaguo { /* 0x000 */ Actor actor; @@ -39,7 +41,7 @@ typedef struct EnBaguo { /* 0x1D0 */ Vec3f targetRotation; /* 0x1DC */ ColliderJntSph collider; /* 0x1FC */ ColliderJntSphElement colliderElements[1]; - /* 0x23C */ NejironParticle particles[30]; + /* 0x23C */ NejironEffect effects[EN_BAGUO_EFFECT_COUNT]; } EnBaguo; // size = 0x8CC extern const ActorInit En_Baguo_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 0e3c9b20a..c546ba780 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2700,10 +2700,10 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; - iceShardEffect->isActive = true; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; vtxX = targetVtx->n.ob[0]; @@ -2715,9 +2715,9 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { xzDist = Math_CosS(randPitch) * randFloat; } - iceShardEffect->vel.x = targetVtx->n.ob[0] * xzDist; - iceShardEffect->vel.y = Math_SinS(randPitch) * randFloat; - iceShardEffect->vel.z = targetVtx->n.ob[2] * xzDist; + iceShardEffect->velocity.x = targetVtx->n.ob[0] * xzDist; + iceShardEffect->velocity.y = Math_SinS(randPitch) * randFloat; + iceShardEffect->velocity.z = targetVtx->n.ob[2] * xzDist; iceShardEffect->scale = 0.001f * (Rand_ZeroFloat(6.0f) + 2.0f); } } @@ -2736,15 +2736,15 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { // Update ice shards for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { - iceShardEffect->vel.y += -1.0f; - Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->vel, &iceShardEffect->pos); + if (iceShardEffect->isEnabled > false) { + iceShardEffect->velocity.y += -1.0f; + Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->velocity, &iceShardEffect->pos); if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { - iceShardEffect->isActive = false; + iceShardEffect->isEnabled = false; } - iceShardEffect->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rot.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rot.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rot.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } @@ -3143,9 +3143,9 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { + if (iceShardEffect->isEnabled > false) { Matrix_SetTranslateRotateYXZ(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + &iceShardEffect->rot); Matrix_Scale(iceShardEffect->scale, iceShardEffect->scale, iceShardEffect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index 579ec5d50..1005ccff5 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -42,9 +42,9 @@ typedef struct { typedef struct { /* 0x00 */ Vec3f pos; - /* 0x0C */ Vec3f vel; - /* 0x18 */ s16 isActive; - /* 0x1A */ Vec3s rotation; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ s16 isEnabled; + /* 0x1A */ Vec3s rot; /* 0x20 */ f32 scale; } EnBigslimeIceShardEffect; // size = 0x24 diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 9b089d836..dd20b9a25 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -114,7 +114,7 @@ static TexturePtr sWaterSplashTextures[] = { * Creates a debris effect. * Debris effects are spawned by an explosion. */ -void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, +void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, f32 rotationZ) { EnClearTagEffect* effect = this->effect; s16 i; @@ -124,9 +124,9 @@ void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* vel if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_DEBRIS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale; @@ -149,7 +149,7 @@ void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* vel * Creates a smoke effect. * Smoke effects are spawned by an explosion. */ -void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) { +void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* pos, f32 scale) { s16 i; EnClearTagEffect* effect = this->effect; @@ -159,9 +159,9 @@ void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SMOKE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = scale; effect->maxScale = 2.0f * scale; @@ -185,7 +185,7 @@ void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) * Creates an isolated smoke effect without an explosion. * Smoke effects are spawned directly. */ -void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) { +void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* pos, f32 scale) { s16 i; EnClearTagEffect* effect = this->effect; @@ -195,9 +195,9 @@ void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_ISOLATED_SMOKE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = scale; effect->maxScale = 2.0f * scale; @@ -229,7 +229,7 @@ void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 * Flash effects are spawned by an explosion or a pop. * Flash effects have two components: 1) a billboard flash, and 2) a light effect on the ground. */ -void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, f32 floorHeight) { +void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* pos, f32 scale, f32 floorHeight) { EnClearTagEffect* effect = this->effect; s16 i; @@ -238,9 +238,9 @@ void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_FLASH; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = 0.0f; effect->maxScale = scale * 3.0f; @@ -259,7 +259,7 @@ void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, * Creates a light ray effect. * Light ray effects are spawned by an explosion or pop. */ -void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, +void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, f32 maxScaleTarget, s16 alphaDecrementSpeed) { EnClearTagEffect* effect = this->effect; s16 i; @@ -271,9 +271,9 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale / 1000.0f; effect->maxScale = 1.0f; @@ -303,8 +303,8 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v * Creates an isolated light ray effect without an explosion or pop. * Light ray effects are spawned directly. */ -void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, - f32 scale, f32 maxScaleTarget, s16 colorIndex, s16 alphaDecrementSpeed) { +void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, + f32 maxScaleTarget, s16 colorIndex, s16 alphaDecrementSpeed) { EnClearTagEffect* effect = this->effect; s16 i; @@ -313,9 +313,9 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale / 1000.0f; effect->maxScale = 1.0f; @@ -345,7 +345,7 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, * Creates a shockwave effect * This effect uses concentric ring floor shadows that travel radially outward along the floor poly */ -void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 maxScale, s16 actionTimer) { +void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* pos, f32 maxScale, s16 actionTimer) { EnClearTagEffect* effect = this->effect; s16 i; @@ -354,9 +354,9 @@ void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 max if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_SHOCKWAVE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->maxScale = maxScale; effect->scale = 0.0f; @@ -374,7 +374,7 @@ void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 max * Creates a splash effect * This effect is used when EnClearTag is spawned above a waterbox */ -void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effectsTimer) { +void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* pos, s16 effectsTimer) { s16 i; EnClearTagEffect* effect = this->effect; @@ -385,9 +385,9 @@ void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effect effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SPLASH; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = 0.0f; effect->maxScale = 0.0f; @@ -645,13 +645,13 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { effect->actionTimer++; // Perform effect physics. - effect->position.x += effect->velocity.x; - originalYPosition = effect->position.y; - effect->position.y += effect->velocity.y; - effect->position.z += effect->velocity.z; - effect->velocity.x += effect->acceleration.x; - effect->velocity.y += effect->acceleration.y; - effect->velocity.z += effect->acceleration.z; + effect->pos.x += effect->velocity.x; + originalYPosition = effect->pos.y; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; if (effect->type == CLEAR_TAG_EFFECT_DEBRIS) { // Clamp the velocity to -5.0 @@ -661,12 +661,12 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { // While the effect is falling check if it has hit the ground. if (effect->velocity.y < 0.0f) { - sphereCenter = effect->position; + sphereCenter = effect->pos; sphereCenter.y += 5.0f; // Check if the debris has hit the ground. if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sphereCenter, 11.0f)) { - effect->position.y = originalYPosition; + effect->pos.y = originalYPosition; // Bounce the debris effect. if (effect->bounces <= 0) { @@ -675,14 +675,13 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { effect->effectsTimer = Rand_ZeroFloat(20.0f) + 25.0f; } else { // The Debris effect is done bouncing. Set its velocity and acceleration to 0. - effect->velocity.x = effect->velocity.z = effect->acceleration.y = effect->velocity.y = - 0.0f; + effect->velocity.x = effect->velocity.z = effect->accel.y = effect->velocity.y = 0.0f; } } } // Rotate the debris effect. - if (effect->acceleration.y != 0.0f) { + if (effect->accel.y != 0.0f) { effect->rotationY += 0.5f; effect->rotationX += 0.35f; } @@ -821,7 +820,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); @@ -839,7 +838,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)effect->primColor.a); - func_800C0094(this->actor.floorPoly, effect->position.x, effect->position.y, effect->position.z, &mtxF); + func_800C0094(this->actor.floorPoly, effect->pos.x, effect->pos.y, effect->pos.z, &mtxF); Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -863,8 +862,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the ground flash effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)(effect->primColor.a * 0.7f)); - func_800C0094(this->actor.floorPoly, effect->position.x, this->actor.floorHeight, effect->position.z, - &mtxF); + func_800C0094(this->actor.floorPoly, effect->pos.x, this->actor.floorHeight, effect->pos.z, &mtxF); Matrix_Put(&mtxF); Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -893,7 +891,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->smokeScaleX * effect->scale, effect->smokeScaleY * effect->scale, 1.0f, MTXMODE_APPLY); Matrix_Translate(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); @@ -919,7 +917,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -941,7 +939,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the flash billboard effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)effect->primColor.a); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -966,7 +964,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the light ray effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)effect->primColor.r, (u8)effect->primColor.g, (u8)effect->primColor.b, (u8)effect->primColor.a); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); Matrix_RotateZF(effect->rotationZ, MTXMODE_APPLY); @@ -998,12 +996,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { * returns true if point is within the xz boundaries of an active water box, else false * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ - ySurface = effect->position.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->position.x + vec.x, - effect->position.z + vec.z, &ySurface, &waterBox)) { - if ((effect->position.y - ySurface) < 200.0f) { + ySurface = effect->pos.y; + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->pos.x + vec.x, effect->pos.z + vec.z, + &ySurface, &waterBox)) { + if ((effect->pos.y - ySurface) < 200.0f) { // Draw the splash effect. - Matrix_Translate(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x + vec.x, ySurface, effect->pos.z + vec.z, MTXMODE_NEW); Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index a2d188cba..c14cc36fd 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -8,9 +8,9 @@ struct EnClearTag; typedef struct EnClearTagEffect { /* 0x00 */ u8 type; /* 0x01 */ u8 actionTimer; - /* 0x04 */ Vec3f position; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Color_RGBAf primColor; /* 0x38 */ Color_RGBAf envColor; /* 0x48 */ s16 bounces; @@ -27,9 +27,11 @@ typedef struct EnClearTagEffect { /* 0x6C */ f32 smokeScaleX; } EnClearTagEffect; // size = 0x70 +#define EN_CLEAR_TAG_EFFECT_COUNT 103 + typedef struct EnClearTag { /* 0x0000 */ Actor actor; - /* 0x0144 */ EnClearTagEffect effect[103]; + /* 0x0144 */ EnClearTagEffect effect[EN_CLEAR_TAG_EFFECT_COUNT]; /* 0x2E54 */ u8 cameraState; /* 0x2E56 */ s16 activeTimer; // Actor Marked for Death when timer runs out /* 0x2E58 */ UNK_TYPE1 unk2E58[0xC]; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 184a8b81b..9d7304ec4 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -33,28 +33,27 @@ const ActorInit En_Dai_InitVars = { static Vec3f D_80B3FBF0 = { 1.0f, 1.0f, 1.0f }; -EnDaiParticle* func_80B3DFF0(EnDaiParticle* particle, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, - s32 arg6) { +EnDaiEffect* func_80B3DFF0(EnDaiEffect* effect, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; - for (i = 0; i < 32; i++, particle++) { - if (!particle->isEnabled) { - particle->isEnabled = true; - particle->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); - particle->unk_02 = particle->unk_01; - particle->unk_10 = arg1; - particle->unk_1C = arg2; - particle->unk_28 = arg3; - particle->unk_34 = arg4; - particle->unk_38 = arg5; - return particle; + for (i = 0; i < EN_DAI_EFFECT_COUNT; i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + effect->unk_02 = effect->unk_01; + effect->unk_10 = arg1; + effect->unk_1C = arg2; + effect->unk_28 = arg3; + effect->unk_34 = arg4; + effect->unk_38 = arg5; + return effect; } } return NULL; } -void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { +void func_80B3E168(EnDaiEffect* effect, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; s32 pad; s32 isDisplayListSet = false; @@ -65,8 +64,8 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < 32; i++, particle++) { - if (particle->isEnabled == true) { + for (i = 0; i < EN_DAI_EFFECT_COUNT; i++, effect++) { + if (effect->isEnabled == true) { gDPPipeSync(POLY_XLU_DISP++); if (!isDisplayListSet) { @@ -76,18 +75,18 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { Matrix_Push(); - alpha = (particle->unk_02 / (f32)particle->unk_01); + alpha = (effect->unk_02 / (f32)effect->unk_01); alpha *= 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (particle->unk_02 + (i * 3)) * 3, - (particle->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (effect->unk_02 + (i * 3)) * 3, + (effect->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_Translate(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); + Matrix_Translate(effect->unk_10.x, effect->unk_10.y, effect->unk_10.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(particle->unk_34, particle->unk_34, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->unk_34, effect->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -101,23 +100,23 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { } s32 func_80B3E460(EnDai* this) { - EnDaiParticle* particle = &this->particles[0]; + EnDaiEffect* effect = this->effects; s32 i; s32 count; - for (i = 0, count = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled && particle->unk_02) { - particle->unk_10.x += particle->unk_28.x; - particle->unk_02--; - particle->unk_10.y += particle->unk_28.y; - particle->unk_10.z += particle->unk_28.z; - particle->unk_28.x += particle->unk_1C.x; - particle->unk_28.y += particle->unk_1C.y; - particle->unk_28.z += particle->unk_1C.z; - particle->unk_34 += particle->unk_38; + for (i = 0, count = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled && effect->unk_02) { + effect->unk_10.x += effect->unk_28.x; + effect->unk_02--; + effect->unk_10.y += effect->unk_28.y; + effect->unk_10.z += effect->unk_28.z; + effect->unk_28.x += effect->unk_1C.x; + effect->unk_28.y += effect->unk_1C.y; + effect->unk_28.z += effect->unk_1C.z; + effect->unk_34 += effect->unk_38; count++; - } else if (particle->isEnabled) { - particle->isEnabled = false; + } else if (effect->isEnabled) { + effect->isEnabled = false; } } @@ -125,7 +124,7 @@ s32 func_80B3E460(EnDai* this) { } s32 func_80B3E5B4(EnDai* this, GlobalContext* globalCtx) { - func_80B3E168(this->particles, globalCtx); + func_80B3E168(this->effects, globalCtx); return 0; } @@ -325,7 +324,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { sp5C.y = -40.0f; Lib_Vec3f_TranslateAndRotateY(&this->unk_1E4, this->unk_1D4, &sp50, &sp74); - func_80B3DFF0(this->particles, sp74, sp68, sp5C, 0.03f, 0.04f, 0x10); + func_80B3DFF0(this->effects, sp74, sp68, sp5C, 0.03f, 0.04f, 0x10); } return 0; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.h b/src/overlays/actors/ovl_En_Dai/z_en_dai.h index 758cd1bc4..4c7e167b9 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.h +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.h @@ -7,7 +7,7 @@ struct EnDai; typedef void (*EnDaiActionFunc)(struct EnDai*, GlobalContext*); -typedef struct EnDaiParticle { +typedef struct EnDaiEffect { /* 0x00 */ u8 isEnabled; /* 0x01 */ u8 unk_01; /* 0x02 */ u8 unk_02; @@ -17,7 +17,9 @@ typedef struct EnDaiParticle { /* 0x28 */ Vec3f unk_28; /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; -} EnDaiParticle; // size = 0x3C +} EnDaiEffect; // size = 0x3C + +#define EN_DAI_EFFECT_COUNT 32 typedef struct EnDai { /* 0x000 */ Actor actor; @@ -39,7 +41,7 @@ typedef struct EnDai { /* 0x1FC */ Vec3f unk_1FC; /* 0x208 */ Vec3s jointTable[19]; /* 0x27A */ Vec3s morphTable[19]; - /* 0x2EC */ EnDaiParticle particles[32]; + /* 0x2EC */ EnDaiEffect effects[EN_DAI_EFFECT_COUNT]; /* 0xA6C */ s32 unk_A6C; /* 0xA70 */ s32 unk_A70; } EnDai; // size = 0xA74 diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 167c11835..a8d4df8e6 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -493,19 +493,19 @@ void EnDaiku2_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5) { s16 i; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isEnabled) { - particle->isEnabled = true; - particle->unk_04 = *arg1; - particle->unk_10 = *arg2; - particle->unk_1C = *arg3; - particle->unk_30 = arg4; - particle->unk_34 = arg5; - particle->unk_28.x = randPlusMinusPoint5Scaled(30000.0f); - particle->unk_28.y = randPlusMinusPoint5Scaled(30000.0f); - particle->unk_28.z = randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->unk_04 = *arg1; + effect->unk_10 = *arg2; + effect->unk_1C = *arg3; + effect->unk_30 = arg4; + effect->unk_34 = arg5; + effect->unk_28.x = randPlusMinusPoint5Scaled(30000.0f); + effect->unk_28.y = randPlusMinusPoint5Scaled(30000.0f); + effect->unk_28.z = randPlusMinusPoint5Scaled(30000.0f); break; } } @@ -513,20 +513,20 @@ void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 ar void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { s32 i; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled) { - particle->unk_04.x += particle->unk_10.x; - particle->unk_28.x += 0x100; - particle->unk_28.z += 0x130; - particle->unk_04.y += particle->unk_10.y; - particle->unk_04.z += particle->unk_10.z; - particle->unk_10.y += particle->unk_1C.y; - if (particle->unk_34 != 0) { - particle->unk_34 -= 1; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->unk_04.x += effect->unk_10.x; + effect->unk_28.x += 0x100; + effect->unk_28.z += 0x130; + effect->unk_04.y += effect->unk_10.y; + effect->unk_04.z += effect->unk_10.z; + effect->unk_10.y += effect->unk_1C.y; + if (effect->unk_34 != 0) { + effect->unk_34 -= 1; } else { - particle->isEnabled = false; + effect->isEnabled = false; } } } @@ -535,7 +535,7 @@ void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { s32 i; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; s32 objectIdx; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -547,14 +547,14 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIdx].segment); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { Matrix_Push(); - Matrix_Translate(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - Matrix_RotateXS(particle->unk_28.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->unk_28.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->unk_28.z, MTXMODE_APPLY); - Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); + Matrix_Translate(effect->unk_04.x, effect->unk_04.y, effect->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(effect->unk_28.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->unk_28.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->unk_28.z, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_0009E0); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h index 5baadf2f0..3a0cc5ca3 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h @@ -17,7 +17,7 @@ enum { /* 127 */ ENDAIKU2_GET_7F_127 = 127, }; -typedef struct EnDaiku2Particle { +typedef struct EnDaiku2Effect { /* 0x00 */ u8 isEnabled; /* 0x04 */ Vec3f unk_04; /* 0x10 */ Vec3f unk_10; @@ -25,7 +25,9 @@ typedef struct EnDaiku2Particle { /* 0x28 */ Vec3s unk_28; /* 0x30 */ f32 unk_30; /* 0x34 */ s16 unk_34; -} EnDaiku2Particle; // size = 0x38 +} EnDaiku2Effect; // size = 0x38 + +#define EN_DAIKU2_EFFECT_COUNT 50 typedef struct EnDaiku2 { /* 0x000 */ Actor actor; @@ -47,7 +49,7 @@ typedef struct EnDaiku2 { /* 0x284 */ f32 unk_284; /* 0x288 */ s16 unk_288; /* 0x28A */ s16 unk_28A; - /* 0x28C */ EnDaiku2Particle particles[50]; + /* 0x28C */ EnDaiku2Effect effects[EN_DAIKU2_EFFECT_COUNT]; /* 0xD7C */ ColliderCylinder collider; } EnDaiku2; // size = 0xDC8 diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 914e0f355..50970a4be 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -33,50 +33,50 @@ const ActorInit En_Dnb_InitVars = { (ActorFunc)EnDnb_Draw, }; -void func_80A4FDD0(EnDnbParticle* particle, EnDnb* this, s16* alloc, s32 idx) { +void func_80A4FDD0(EnDnbEffect* effect, EnDnb* this, s16* alloc, s32 idx) { Vec3f sp1C; s32 idx2 = idx * 3; sp1C.x = alloc[idx2 + 0] + this->dyna.actor.world.pos.x; sp1C.y = alloc[idx2 + 1] + this->dyna.actor.world.pos.y; sp1C.z = alloc[idx2 + 2] + this->dyna.actor.world.pos.z; - particle->unk_00 = sp1C; - particle->unk_0C = sp1C; - particle->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); - particle->unk_18 = gZeroVec3s; + effect->unk_00 = sp1C; + effect->unk_0C = sp1C; + effect->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); + effect->unk_18 = gZeroVec3s; } -s32 func_80A4FEBC(EnDnbParticle* particle, f32 arg1) { +s32 func_80A4FEBC(EnDnbEffect* effect, f32 arg1) { s32 ret = false; - if ((DECR(particle->unk_26) == 0) && (arg1 < particle->unk_0C.y)) { - Math_ApproachF(&particle->unk_30, 1.0f, 0.4f, 1.0f); - particle->unk_2C += particle->unk_34; - particle->unk_0C.x += particle->unk_30 * Math_SinS(particle->unk_24); - particle->unk_0C.z += particle->unk_30 * Math_CosS(particle->unk_24); - particle->unk_0C.y += particle->unk_2C; - if (particle->unk_0C.y <= arg1) { - particle->unk_0C.y = arg1; + if ((DECR(effect->unk_26) == 0) && (arg1 < effect->unk_0C.y)) { + Math_ApproachF(&effect->unk_30, 1.0f, 0.4f, 1.0f); + effect->unk_2C += effect->unk_34; + effect->unk_0C.x += effect->unk_30 * Math_SinS(effect->unk_24); + effect->unk_0C.z += effect->unk_30 * Math_CosS(effect->unk_24); + effect->unk_0C.y += effect->unk_2C; + if (effect->unk_0C.y <= arg1) { + effect->unk_0C.y = arg1; } - particle->unk_18.x += particle->unk_1E.x; - particle->unk_18.y += particle->unk_1E.y; - particle->unk_18.z += particle->unk_1E.z; + effect->unk_18.x += effect->unk_1E.x; + effect->unk_18.y += effect->unk_1E.y; + effect->unk_18.z += effect->unk_1E.z; ret = true; } return ret; } -void func_80A4FFE8(EnDnbParticle* particle, s16 arg1) { - particle->unk_0C = particle->unk_00; - particle->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_18 = gZeroVec3s; - particle->unk_30 = 40.0f; - particle->unk_2C = 0.0f; - particle->unk_26 = arg1; - particle->unk_34 = (Rand_ZeroOne() * -2.0f) - 2.0f; +void func_80A4FFE8(EnDnbEffect* effect, s16 arg1) { + effect->unk_0C = effect->unk_00; + effect->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_18 = gZeroVec3s; + effect->unk_30 = 40.0f; + effect->unk_2C = 0.0f; + effect->unk_26 = arg1; + effect->unk_34 = (Rand_ZeroOne() * -2.0f) - 2.0f; } s32 func_80A500F8(EnDnb* this) { @@ -108,8 +108,8 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FDD0(&this->particles[i], this, alloc, i); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FDD0(&this->effects[i], this, alloc, i); } Actor_SetScale(&this->dyna.actor, 1.0f); @@ -126,8 +126,8 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { s32 i; if (this->unk_0D30 == 0) { - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FFE8(&this->particles[i], ((53 - i) / 18) * 4); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FFE8(&this->effects[i], ((53 - i) / 18) * 4); } for (i = 0; i < ARRAY_COUNT(this->unk_0D38); i++) { @@ -141,8 +141,8 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A500F8(this); } - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FEBC(&this->particles[i], this->dyna.actor.world.pos.y); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FEBC(&this->effects[i], this->dyna.actor.world.pos.y); } this->unk_0D30--; @@ -158,13 +158,12 @@ void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { Matrix_Push(); - Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Translate(this->effects[i].unk_0C.x, this->effects[i].unk_0C.y, this->effects[i].unk_0C.z, MTXMODE_NEW); + Matrix_RotateXS(this->effects[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->effects[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->effects[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gfx[i]); @@ -183,13 +182,12 @@ void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { Matrix_Push(); - Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Translate(this->effects[i].unk_0C.x, this->effects[i].unk_0C.y, this->effects[i].unk_0C.z, MTXMODE_NEW); + Matrix_RotateXS(this->effects[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->effects[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->effects[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gfx[i]); diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h index d5ec9554a..17ee19abe 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h @@ -16,7 +16,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; -} EnDnbParticle; // size = 0x38 +} EnDnbEffect; // size = 0x38 typedef struct { /* 0x00 */ u8 isEnabled; @@ -29,10 +29,12 @@ typedef struct { /* 0x24 */ f32 unk_24; } EnDnbUnkStruct; // size = 0x28 +#define EN_DNB_EFFECT_COUNT 54 + typedef struct EnDnb { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ UNK_TYPE1 unk_015C[0x4]; - /* 0x0160 */ EnDnbParticle particles[54]; + /* 0x0160 */ EnDnbEffect effects[EN_DNB_EFFECT_COUNT]; /* 0x0D30 */ s16 unk_0D30; /* 0x0D32 */ s16 unk_0D32; /* 0x0D34 */ s16 unk_0D34; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index ea7ee7aa4..62d33b0ea 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -21,9 +21,9 @@ void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_SetIdle(EnEncount2* this); -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay); -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay); +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_DrawEffects(EnEncount2* this, GlobalContext* globalCtx); const ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, @@ -166,8 +166,8 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, curPos.x, curPos.y, curPos.z, 255, 255, 200, CLEAR_TAG_LARGE_EXPLOSION); - for (i = 0; i < ARRAY_COUNT(this->particles) / 2; ++i) { - EnEncount2_InitParticles(this, &curPos, 10); + for (i = 0; i < ARRAY_COUNT(this->effects) / 2; ++i) { + EnEncount2_InitEffects(this, &curPos, 10); } Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); @@ -195,7 +195,7 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->dyna.actor, this->scale); this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->dyna.actor); - EnEncount2_UpdateParticles(this, globalCtx); + EnEncount2_UpdateEffects(this, globalCtx); if (!this->isPopped) { Collider_UpdateSpheresElement(&this->collider, 0, &this->dyna.actor); @@ -210,16 +210,16 @@ void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000A00); Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000D78); } - EnEncount2_DrawParticles(this, globalCtx); + EnEncount2_DrawEffects(this, globalCtx); } -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { +void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { s16 i; - EnEncount2Particle* sPtr = this->particles; + EnEncount2Effect* sPtr = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (!sPtr->enabled) { - sPtr->enabled = true; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (!sPtr->isEnabled) { + sPtr->isEnabled = true; sPtr->pos = *pos; sPtr->alphaFadeDelay = fadeDelay; sPtr->alpha = 0xFF; @@ -228,9 +228,9 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { sPtr->accel.y = (Rand_ZeroOne() - 0.5f) * 10.0f; sPtr->accel.z = (Rand_ZeroOne() - 0.5f) * 10.0f; - sPtr->vel.x = Rand_ZeroOne() - 0.5f; - sPtr->vel.y = Rand_ZeroOne() - 0.5f; - sPtr->vel.z = Rand_ZeroOne() - 0.5f; + sPtr->velocity.x = Rand_ZeroOne() - 0.5f; + sPtr->velocity.y = Rand_ZeroOne() - 0.5f; + sPtr->velocity.z = Rand_ZeroOne() - 0.5f; sPtr->scale = (Rand_ZeroFloat(1.0f) * 0.5f) + 2.0f; return; @@ -238,42 +238,42 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { } } -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx) { s32 i; - EnEncount2Particle* sPtr = this->particles; + EnEncount2Effect* sPtr = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (sPtr->enabled) { - sPtr->pos.x += sPtr->vel.x; - sPtr->pos.y += sPtr->vel.y; - sPtr->pos.z += sPtr->vel.z; - sPtr->vel.x += sPtr->accel.x; - sPtr->vel.y += sPtr->accel.y; - sPtr->vel.z += sPtr->accel.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { + sPtr->pos.x += sPtr->velocity.x; + sPtr->pos.y += sPtr->velocity.y; + sPtr->pos.z += sPtr->velocity.z; + sPtr->velocity.x += sPtr->accel.x; + sPtr->velocity.y += sPtr->accel.y; + sPtr->velocity.z += sPtr->accel.z; if (sPtr->alphaFadeDelay != 0) { sPtr->alphaFadeDelay--; } else { sPtr->alpha -= 10; if (sPtr->alpha < 10) { - sPtr->enabled = 0; + sPtr->isEnabled = 0; } } } } } -void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_DrawEffects(EnEncount2* this, GlobalContext* globalCtx) { s16 i; - EnEncount2Particle* sPtr; + EnEncount2Effect* sPtr; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); - sPtr = this->particles; + sPtr = this->effects; func_8012C28C(gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (sPtr->enabled) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { Matrix_Translate(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index f2ce8832f..a95c1e014 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -7,16 +7,18 @@ struct EnEncount2; typedef void (*EnEncount2ActionFunc)(struct EnEncount2*, GlobalContext*); -typedef struct EnEncount2Particle{ - /* 0x00 */ u8 enabled; +typedef struct EnEncount2Effect{ + /* 0x00 */ u8 isEnabled; /* 0x04 */ Vec3f pos; /* 0x10 */ UNK_TYPE4 unk10; /* 0x14 */ s16 alpha; /* 0x16 */ s16 alphaFadeDelay; // frame count before alpha fade starts - /* 0x18 */ Vec3f vel; + /* 0x18 */ Vec3f velocity; /* 0x24 */ Vec3f accel; /* 0x30 */ f32 scale; -} EnEncount2Particle; // size = 0x34 +} EnEncount2Effect; // size = 0x34 + +#define EN_ENCOUNT2_EFFECT_COUNT 200 typedef struct EnEncount2 { /* 0x0000 */ DynaPolyActor dyna; @@ -28,7 +30,7 @@ typedef struct EnEncount2 { /* 0x016C */ f32 oscillationAngle; /* 0x0170 */ ColliderJntSph collider; /* 0x0190 */ ColliderJntSphElement colElement; - /* 0x01D0 */ EnEncount2Particle particles[200]; + /* 0x01D0 */ EnEncount2Effect effects[EN_ENCOUNT2_EFFECT_COUNT]; } EnEncount2; // size = 0x2A70 #define GET_ENCOUNT2_SWITCH_FLAG(actor) ((s16)(((Actor*)actor)->params & 0x7F)) diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index b84eb3d74..d426b7c59 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -56,9 +56,11 @@ typedef struct { Vec3f pos; Vec3f velocity; Vec3s rot; -} EnFallDebrisParticle; +} EnFallDebrisEffect; -EnFallDebrisParticle debrisParticles[50]; +#define EN_FALL_DEBRIS_EFFECT_COUNT 50 + +EnFallDebrisEffect debrisEffects[EN_FALL_DEBRIS_EFFECT_COUNT]; const ActorInit En_Fall_InitVars = { ACTOR_EN_FALL, @@ -115,13 +117,13 @@ void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) } } -void EnFall_RisingDebris_ResetParticles(EnFall* this) { +void EnFall_RisingDebris_ResetEffects(EnFall* this) { s32 i; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - debrisParticles[i].modelIndex = 3; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + debrisEffects[i].modelIndex = 3; } - this->activeDebrisParticleCount = 0; + this->activeDebrisEffectCount = 0; } void EnFall_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -252,7 +254,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.update = EnFall_RisingDebris_Update; this->actor.draw = EnFall_RisingDebris_Draw; this->scale = 1.0f; - EnFall_RisingDebris_ResetParticles(this); + EnFall_RisingDebris_ResetEffects(this); Actor_SetScale(&this->actor, 1.0f); this->actor.shape.rot.x = 0; break; @@ -631,47 +633,47 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->scale * 1.74f); } -void EnFall_RisingDebris_UpdateParticles(EnFall* this) { +void EnFall_RisingDebris_UpdateEffects(EnFall* this) { s32 i; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex < 3) { - debrisParticles[i].pos.x += debrisParticles[i].velocity.x; - debrisParticles[i].pos.y += debrisParticles[i].velocity.y; - debrisParticles[i].pos.z += debrisParticles[i].velocity.z; - debrisParticles[i].rot.x += 0x64; - debrisParticles[i].rot.y += 0xC8; - debrisParticles[i].rot.z += 0x12C; - if ((this->actor.world.pos.y + 3000.0f) < debrisParticles[i].pos.y) { - debrisParticles[i].modelIndex = 3; - this->activeDebrisParticleCount--; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex < 3) { + debrisEffects[i].pos.x += debrisEffects[i].velocity.x; + debrisEffects[i].pos.y += debrisEffects[i].velocity.y; + debrisEffects[i].pos.z += debrisEffects[i].velocity.z; + debrisEffects[i].rot.x += 0x64; + debrisEffects[i].rot.y += 0xC8; + debrisEffects[i].rot.z += 0x12C; + if ((this->actor.world.pos.y + 3000.0f) < debrisEffects[i].pos.y) { + debrisEffects[i].modelIndex = 3; + this->activeDebrisEffectCount--; } } } } -s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { +s32 EnFall_RisingDebris_InitializeEffect(EnFall* this) { s16 angle; s32 i; f32 scale; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex >= 3) { - debrisParticles[i].modelIndex = (s32)Rand_ZeroFloat(3.0f); - debrisParticles[i].pos.x = this->actor.world.pos.x; - debrisParticles[i].pos.y = this->actor.world.pos.y; - debrisParticles[i].pos.z = this->actor.world.pos.z; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex >= 3) { + debrisEffects[i].modelIndex = (s32)Rand_ZeroFloat(3.0f); + debrisEffects[i].pos.x = this->actor.world.pos.x; + debrisEffects[i].pos.y = this->actor.world.pos.y; + debrisEffects[i].pos.z = this->actor.world.pos.z; angle = randPlusMinusPoint5Scaled(0x10000); scale = (1.0f - (Rand_ZeroFloat(1.0f) * Rand_ZeroFloat(1.0f))) * 3000.0f; - debrisParticles[i].pos.x += Math_SinS(angle) * scale; - debrisParticles[i].pos.z += Math_CosS(angle) * scale; - debrisParticles[i].velocity.x = 0.0f; - debrisParticles[i].velocity.z = 0.0f; - debrisParticles[i].velocity.y = 80.0f; - debrisParticles[i].rot.x = randPlusMinusPoint5Scaled(0x10000); - debrisParticles[i].rot.y = randPlusMinusPoint5Scaled(0x10000); - debrisParticles[i].rot.z = randPlusMinusPoint5Scaled(0x10000); - this->activeDebrisParticleCount++; + debrisEffects[i].pos.x += Math_SinS(angle) * scale; + debrisEffects[i].pos.z += Math_CosS(angle) * scale; + debrisEffects[i].velocity.x = 0.0f; + debrisEffects[i].velocity.z = 0.0f; + debrisEffects[i].velocity.y = 80.0f; + debrisEffects[i].rot.x = randPlusMinusPoint5Scaled(0x10000); + debrisEffects[i].rot.y = randPlusMinusPoint5Scaled(0x10000); + debrisEffects[i].rot.z = randPlusMinusPoint5Scaled(0x10000); + this->activeDebrisEffectCount++; return true; } } @@ -685,14 +687,14 @@ void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { if (Cutscene_CheckActorAction(globalCtx, 451)) { if (Cutscene_CheckActorAction(globalCtx, 451) && globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 451)]->action == 2) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); - } else if (this->activeDebrisParticleCount != 0) { - EnFall_RisingDebris_ResetParticles(this); + EnFall_RisingDebris_UpdateEffects(this); + EnFall_RisingDebris_InitializeEffect(this); + } else if (this->activeDebrisEffectCount != 0) { + EnFall_RisingDebris_ResetEffects(this); } } else if (thisx->home.rot.x != 0) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); + EnFall_RisingDebris_UpdateEffects(this); + EnFall_RisingDebris_InitializeEffect(this); } } @@ -868,15 +870,14 @@ void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex < 3) { - Matrix_Translate(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, MTXMODE_NEW); + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex < 3) { + Matrix_Translate(debrisEffects[i].pos.x, debrisEffects[i].pos.y, debrisEffects[i].pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_RotateZYX(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, - MTXMODE_APPLY); + Matrix_RotateZYX(debrisEffects[i].rot.x, debrisEffects[i].rot.y, debrisEffects[i].rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisParticles[i].modelIndex]); + gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisEffects[i].modelIndex]); } } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.h b/src/overlays/actors/ovl_En_Fall/z_en_fall.h index 620c0590a..308b8ba9b 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.h +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.h @@ -40,7 +40,7 @@ typedef struct EnFall { /* 0x154 */ u16 flags; /* 0x158 */ union { s32 fireballAlpha; - s32 activeDebrisParticleCount; + s32 activeDebrisEffectCount; }; /* 0x15C */ union { s16 fireballYTexScroll1; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 63da6c329..8feabc0c7 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -94,36 +94,36 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { s32 i; for (i = 0; i < ARRAY_COUNT(parent->unk_9F8); i++) { - BossHakuginParticle* gohtParticle = &parent->unk_9F8[i]; - if (gohtParticle->unk_18 < 0) { + BossHakuginEffect* gohtEffect = &parent->unk_9F8[i]; + if (gohtEffect->unk_18 < 0) { s16 sp2E; s16 sp2C; f32 sp28; - Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); + Math_Vec3f_Copy(&gohtEffect->unk_0, arg1); sp2C = Rand_S16Offset(0x1000, 0x3000); sp2E = Rand_Next() >> 0x10; sp28 = Rand_ZeroFloat(5.0f) + 10.0f; - gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); - gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); - gohtParticle->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); + gohtEffect->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); + gohtEffect->unk_C.y = (Math_SinS(sp2C) * sp28); + gohtEffect->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); if ((arg2 == 1) || (arg2 == 3)) { - gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); - gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.x) + arg1->x; - gohtParticle->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.y) + arg1->y; - gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.z) + arg1->z; - gohtParticle->unk_1A = 1; + gohtEffect->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); + gohtEffect->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtEffect->unk_C.x) + arg1->x; + gohtEffect->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.y) + arg1->y; + gohtEffect->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtEffect->unk_C.z) + arg1->z; + gohtEffect->unk_1A = 1; } else { - gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); - gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.x) + arg1->x; - gohtParticle->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtParticle->unk_C.y) + arg1->y; - gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; - gohtParticle->unk_1A = 0; + gohtEffect->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); + gohtEffect->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.x) + arg1->x; + gohtEffect->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtEffect->unk_C.y) + arg1->y; + gohtEffect->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.z) + arg1->z; + gohtEffect->unk_1A = 0; } - gohtParticle->unk_1C.x = (s32)Rand_Next() >> 0x10; - gohtParticle->unk_1C.y = (s32)Rand_Next() >> 0x10; - gohtParticle->unk_1C.z = (s32)Rand_Next() >> 0x10; - gohtParticle->unk_18 = 0x28; + gohtEffect->unk_1C.x = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_1C.y = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_1C.z = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_18 = 0x28; return; } } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 68f587ba3..2ffb3d0ba 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -185,18 +185,18 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { for (; i < i_end; i++) { iceShardEffect = &bigslime->iceShardEffect[i]; vecSph.pitch = Rand_S16Offset(0x1000, 0x3000); - iceShardEffect->vel.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); - iceShardEffect->vel.y = Math_SinS(vecSph.pitch); - iceShardEffect->vel.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); - iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->vel.x; + iceShardEffect->velocity.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); + iceShardEffect->velocity.y = Math_SinS(vecSph.pitch); + iceShardEffect->velocity.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); + iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->velocity.x; iceShardEffect->pos.y = - this->actor.world.pos.y + (((iceShardEffect->vel.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); - iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->vel.z; - iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; - iceShardEffect->isActive = true; - Math_Vec3f_ScaleAndStore(&iceShardEffect->vel, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->vel); + this->actor.world.pos.y + (((iceShardEffect->velocity.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); + iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->velocity.z; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; + Math_Vec3f_ScaleAndStore(&iceShardEffect->velocity, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->velocity); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; vecSph.yaw += 0x1999; } diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index fb3b1070e..225feec70 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -30,9 +30,9 @@ void EnRaf_SetupDissolve(EnRaf* this); void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx); void EnRaf_SetupDormant(EnRaf* this); void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, s16 timer); -void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnRaf_UpdateEffects(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_DrawEffects(EnRaf* this, GlobalContext* globalCtx); typedef enum { /* 0 */ EN_RAF_ANIMATION_IDLE, @@ -494,11 +494,11 @@ void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { } /** - * Creates an explosion effect/sound and spawns particles. + * Creates an explosion effect/sound and spawns effects. */ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; Vec3f explosionPos; s32 i; s32 pad; @@ -516,14 +516,14 @@ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; for (i = 0; i < BREG(57) + 30; i++) { - acceleration.x = (Rand_ZeroOne() - 0.5f) * 0.5f; - acceleration.y = -0.3f; - acceleration.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + accel.x = (Rand_ZeroOne() - 0.5f) * 0.5f; + accel.y = -0.3f; + accel.z = (Rand_ZeroOne() - 0.5f) * 0.5f; velocity.x = Rand_ZeroOne() - 0.5f; velocity.y = Rand_ZeroOne() * 10.0f; velocity.z = Rand_ZeroOne() - 0.5f; - EnRaf_InitializeParticle(this, &this->dyna.actor.world.pos, &velocity, &acceleration, - (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + EnRaf_InitializeEffect(this, &this->dyna.actor.world.pos, &velocity, &accel, + (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); } for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { @@ -742,7 +742,7 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); if (this->action == EN_RAF_ACTION_EXPLODE) { - EnRaf_UpdateParticles(this, globalCtx); + EnRaf_UpdateEffects(this, globalCtx); } for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { @@ -875,84 +875,83 @@ void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); if (this->action == EN_RAF_ACTION_EXPLODE) { - EnRaf_DrawParticles(this, globalCtx); + EnRaf_DrawEffects(this, globalCtx); } } -void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer) { +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { s16 i; - EnRafParticle* particle = this->particles; + EnRafEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isVisible) { - particle->isVisible = true; - particle->position = *position; - particle->velocity = *velocity; - particle->acceleration = *acceleration; - particle->scale = scale; - particle->timer = timer; - particle->rotation.x = randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.y = randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.z = randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = timer; + effect->rotation.x = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = randPlusMinusPoint5Scaled(30000.0f); return; } } } -void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_UpdateEffects(EnRaf* this, GlobalContext* globalCtx) { s32 i; - EnRafParticle* particle = this->particles; + EnRafEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - particle->position.x += particle->velocity.x; - particle->position.y += particle->velocity.y; - particle->position.z += particle->velocity.z; - particle->rotation.x += 0xBB8; - particle->rotation.y += 0xBB8; - particle->rotation.z += 0xBB8; - particle->velocity.x += particle->acceleration.x; - particle->velocity.y += particle->acceleration.y; - particle->velocity.z += particle->acceleration.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->rotation.x += 0xBB8; + effect->rotation.y += 0xBB8; + effect->rotation.z += 0xBB8; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { - if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { - EffectSsGSplash_Spawn(globalCtx, &particle->position, NULL, NULL, 0, particle->scale * 200000.0f); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &particle->position, 50, NA_SE_EV_BOMB_DROP_WATER); - particle->isVisible = false; + if (effect->pos.y < (this->dyna.actor.world.pos.y - 10.0f)) { + EffectSsGSplash_Spawn(globalCtx, &effect->pos, NULL, NULL, 0, effect->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &effect->pos, 50, NA_SE_EV_BOMB_DROP_WATER); + effect->isEnabled = false; } - } else if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { - Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); - if (particle->scale <= 0.0001f) { - particle->timer = 0; + } else if (effect->pos.y < (this->dyna.actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&effect->scale, 0.2f, 0.001f); + if (effect->scale <= 0.0001f) { + effect->timer = 0; } } - if (particle->timer != 0) { - particle->timer--; + if (effect->timer != 0) { + effect->timer--; } else { - particle->isVisible = false; + effect->isEnabled = false; } } } } -void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_DrawEffects(EnRaf* this, GlobalContext* globalCtx) { s16 i; - EnRafParticle* particle = this->particles; + EnRafEffect* effect = this->effects; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); - Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + Matrix_RotateXS(effect->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rotation.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.h b/src/overlays/actors/ovl_En_Raf/z_en_raf.h index f63924402..2fc92fb2b 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -11,7 +11,7 @@ typedef enum { /* 0 */ EN_RAF_TYPE_NORMAL, /* 1 */ EN_RAF_TYPE_DORMANT, // Spawns without trap, so it can't eat bombs/player - /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and particles won't produce splashes + /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and effects won't produce splashes } EnRafType; struct EnRaf; @@ -19,14 +19,16 @@ struct EnRaf; typedef void (*EnRafActionFunc)(struct EnRaf*, GlobalContext*); typedef struct { - /* 0x00 */ u8 isVisible; - /* 0x04 */ Vec3f position; + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Vec3s rotation; /* 0x30 */ f32 scale; /* 0x34 */ s16 timer; -} EnRafParticle; // size = 0x38 +} EnRafEffect; // size = 0x38 + +#define EN_RAF_EFFECT_COUNT 31 typedef struct EnRaf { /* 0x000 */ DynaPolyActor dyna; @@ -59,7 +61,7 @@ typedef struct EnRaf { /* 0x3CC */ s16 petalClearPixelSecondPassIndex; /* 0x3CE */ s16 teethClearPixelSecondPassIndex; /* 0x3D0 */ ColliderCylinder collider; - /* 0x41C */ EnRafParticle particles[31]; + /* 0x41C */ EnRafEffect effects[EN_RAF_EFFECT_COUNT]; } EnRaf; // size = 0xAE4 extern const ActorInit En_Raf_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index c90e5d8f8..832000b0c 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -66,7 +66,7 @@ static InitChainEntry sInitChain[] = { void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_CreateSmashEffects(ObjChan* this, GlobalContext* globalCtx); void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); @@ -305,7 +305,7 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { } } if (potBreaks) { - ObjChan_CreateSmashParticles(this, globalCtx); + ObjChan_CreateSmashEffects(this, globalCtx); ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); @@ -321,7 +321,7 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { } } -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_CreateSmashEffects(ObjChan* this, GlobalContext* globalCtx) { s16 new_var = 0; s32 phi_s0; Vec3f spDC; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6c0b5d2d7..6477dd98c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6523,9 +6523,9 @@ 0x808E18A8:("EnEncount2_Die",), 0x808E18F8:("EnEncount2_Update",), 0x808E19C4:("EnEncount2_Draw",), - 0x808E1A24:("EnEncount2_InitParticles",), - 0x808E1B4C:("EnEncount2_UpdateParticles",), - 0x808E1C9C:("EnEncount2_DrawParticles",), + 0x808E1A24:("EnEncount2_InitEffects",), + 0x808E1B4C:("EnEncount2_UpdateEffects",), + 0x808E1C9C:("EnEncount2_DrawEffects",), 0x808E1FE0:("EnFireRock_Init",), 0x808E1FF0:("EnFireRock_Destroy",), 0x808E2000:("EnFireRock_Update",), @@ -9769,9 +9769,9 @@ 0x80A181B4:("EnRaf_Update",), 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("EnRaf_InitializeParticle",), - 0x80A18B8C:("EnRaf_UpdateParticles",), - 0x80A18DA0:("EnRaf_DrawParticles",), + 0x80A18A90:("EnRaf_InitializeEffect",), + 0x80A18B8C:("EnRaf_UpdateEffects",), + 0x80A18DA0:("EnRaf_DrawEffects",), 0x80A19740:("ObjFunen_Init",), 0x80A19778:("ObjFunen_Draw",), 0x80A19910:("ObjRaillift_UpdatePosition",), @@ -10308,9 +10308,9 @@ 0x80A3BC88:("EnBaguo_Update",), 0x80A3BE24:("EnBaguo_PostLimbDraw",), 0x80A3BE60:("EnBaguo_DrawBody",), - 0x80A3BF0C:("EnBaguo_InitializeParticle",), - 0x80A3C008:("EnBaguo_UpdateParticles",), - 0x80A3C17C:("EnBaguo_DrawRockParticles",), + 0x80A3BF0C:("EnBaguo_InitializeEffect",), + 0x80A3C008:("EnBaguo_UpdateEffects",), + 0x80A3C17C:("EnBaguo_DrawEffects",), 0x80A3C4E0:("func_80A3C4E0",), 0x80A3C560:("func_80A3C560",), 0x80A3C658:("func_80A3C658",), @@ -10908,7 +10908,7 @@ 0x80A6B3F8:("EnMushi2_Update",), 0x80A6B8D0:("EnMushi2_Draw",), 0x80A6BF90:("EnFall_Moon_AdjustScaleAndPosition",), - 0x80A6C1DC:("EnFall_RisingDebris_ResetParticles",), + 0x80A6C1DC:("EnFall_RisingDebris_ResetEffects",), 0x80A6C22C:("EnFall_Init",), 0x80A6C39C:("EnFall_Destroy",), 0x80A6C3AC:("EnFall_MoonsTear_GetTerminaFieldMoon",), @@ -10925,8 +10925,8 @@ 0x80A6D0DC:("EnFall_Update",), 0x80A6D100:("EnFall_FireBall_SetPerVertexAlpha",), 0x80A6D220:("EnFall_FireBall_Update",), - 0x80A6D444:("EnFall_RisingDebris_UpdateParticles",), - 0x80A6D504:("EnFall_RisingDebris_InitializeParticles",), + 0x80A6D444:("EnFall_RisingDebris_UpdateEffects",), + 0x80A6D504:("EnFall_RisingDebris_InitializeEffect",), 0x80A6D698:("EnFall_RisingDebris_Update",), 0x80A6D75C:("EnFall_FireRing_Update",), 0x80A6D88C:("EnFall_Moon_Draw",), @@ -13669,8 +13669,8 @@ 0x80B40100:("func_80B40100",), 0x80B40160:("func_80B40160",), 0x80B401F8:("func_80B401F8",), - 0x80B40308:("func_80B40308",), - 0x80B40394:("func_80B40394",), + 0x80B40308:("BgGoronOyu_UpdateWaterBoxInfo",), + 0x80B40394:("BgGoronOyu_SpawnEffects",), 0x80B4056C:("BgGoronOyu_Init",), 0x80B40628:("BgGoronOyu_Destroy",), 0x80B4065C:("BgGoronOyu_Update",), @@ -15380,7 +15380,7 @@ 0x80BB9F24:("ObjChan_ChandelierAction",), 0x80BBA2FC:("ObjChan_InitPot",), 0x80BBA314:("ObjChan_PotAction",), - 0x80BBA488:("ObjChan_CreateSmashParticles",), + 0x80BBA488:("ObjChan_CreateSmashEffects",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), 0x80BBA894:("ObjChan_DrawPot",), From 37d3934e2c6866185b3ba76bad40224336a7a1f9 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 17:16:30 -0700 Subject: [PATCH 49/53] Code_800E8EA0 Docs (#832) * Start * Add notes from OOT * D_801D0D50 -> gDbgCamEnabled * Rotation Functions * Text function * RotateBack -> RotateForward * Flags functions * Document rotation func returns * Remove comment from play * Rename play function, add notes about Flags, add notes about focus * Update notes a little * Update src/code/code_800E8EA0.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Fix apostrophes * Bring over OoT changes * TurnTo -> Track in SubS systesm * format and remove OoT specific comment * Remove old comments * namefixer Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- docs/tutorial/documenting.md | 4 +- docs/tutorial/other_functions.md | 12 +- include/functions.h | 22 +-- include/variables.h | 2 +- include/z64subs.h | 22 +-- include/z_en_hy_code.h | 4 +- src/code/code_800E8EA0.c | 153 +++++++++++------- src/code/z_actor.c | 2 +- src/code/z_demo.c | 2 +- src/code/z_play.c | 6 +- src/code/z_sub_s.c | 49 +++--- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 16 +- .../actors/ovl_En_Aob_01/z_en_aob_01.h | 2 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 10 +- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 2 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 14 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 6 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 14 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 2 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 2 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 4 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 4 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 2 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 108 ++++++------- src/overlays/actors/ovl_En_In/z_en_in.h | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 3 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 2 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 2 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 6 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 2 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 2 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 10 +- .../actors/ovl_En_Suttari/z_en_suttari.h | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 3 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 10 +- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 2 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 2 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 2 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 2 +- tools/disasm/functions.txt | 26 +-- tools/disasm/variables.txt | 2 +- tools/namefixer.py | 4 + tools/sizes/code_functions.csv | 26 +-- 57 files changed, 323 insertions(+), 279 deletions(-) diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 7e8435da9..e31a31969 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -216,7 +216,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } @@ -287,7 +287,7 @@ That's probably as much as we can do on functions for now. Next let's think abou - data/bss - intrafunction/stack variables -and this is roughly the order of preference for naming them (although not necessarily the logical order to determine what they do). This actor is quite limited in the last category: only `sp30` is unnamed at the moment. Even though `func_800E9250` is decomped, the purpose of the argument in which `sp30` is placed is not clear (and, indeed, is not named), so it's probably best to leave it unnamed for now. (With greater experience, you might analyse `func_800E9250` to work out what this argument is for, but let's not worry about that for now.) +and this is roughly the order of preference for naming them (although not necessarily the logical order to determine what they do). This actor is quite limited in the last category: only `sp30` is unnamed at the moment. Even though `Actor_TrackPlayer` is decomped, the purpose of the argument in which `sp30` is placed is not clear (and, indeed, is not named), so it's probably best to leave it unnamed for now. (With greater experience, you might analyse `Actor_TrackPlayer` to work out what this argument is for, but let's not worry about that for now.) As for the struct, there are two unnamed variables at the moment: ```C diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 796939dd8..f9a189d6b 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -422,7 +422,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { ? sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); + Actor_TrackPlayer(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); func_80C100DC(this); } ``` @@ -440,13 +440,13 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { ? sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); + Actor_TrackPlayer(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); func_80C100DC(this); } ``` -Now, our problem is `func_800E9250`. The arguments all look terrible! Indeed, if we look at the actual function in `src/code/code_800E8EA0.c` (found by searching), we find that it should be +Now, our problem is `Actor_TrackPlayer`. The arguments all look terrible! Indeed, if we look at the actual function in `src/code/code_800E8EA0.c` (found by searching), we find that it should be ```C -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) ``` So mips2c has made a bit of a mess here: - the third argument should be a `Vec3s`. Hence `this + 0x2AE` is a `Vec3s*`, and so `this->unk_2AE` is a `Vec3s` @@ -460,7 +460,7 @@ void EnRecepgirl_Update(EnRecepgirl *this, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` @@ -490,7 +490,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` diff --git a/include/functions.h b/include/functions.h index 372f4d5fc..30453cf8d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1353,15 +1353,15 @@ void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* v); void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos); s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId); -s32 nop_800E8ED0(UNK_TYPE4 param_1); -void nop_800E8EE0(UNK_TYPE4 param_1); -s32 nop_800E8EEC(UNK_TYPE4 param_1); -void nop_800E8EFC(UNK_TYPE4 param_1); -s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2); -s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); -s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); +void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId); +s32 Flags_GetEventChkInf(s32 flag); +void Flags_SetEventChkInf(s32 flag); +s32 Flags_GetInfTable(s32 flag); +void Flags_SetInfTable(s32 flag); +s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot); +s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot); +s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusPosYAdj); +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos); void SaveContext_Init(void); void GameInfo_Init(void); // void DebugDisplay_Init(void); @@ -2392,8 +2392,8 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); - // void func_8013EC10(void); + void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); void func_8013ED9C(void); @@ -2678,7 +2678,7 @@ s32 func_80169FFC(GameState* gameState); s32 FrameAdvance_IsEnabled(GameState* gameState); s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos); -s32 func_8016A168(void); +s32 Play_IsDebugCamEnabled(void); void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); void Play_Init(GameState* gameState); diff --git a/include/variables.h b/include/variables.h index 20b42dd71..cbe125ad5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1503,7 +1503,7 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; extern const TransitionInit TransitionFade_InitVars; // extern UNK_TYPE1 D_801D0D00; extern const TransitionInit TransitionCircle_InitVars; -extern UNK_TYPE4 D_801D0D50; +extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; // extern UNK_TYPE2 D_801D0D58; // extern UNK_TYPE2 D_801D0D5C; diff --git a/include/z64subs.h b/include/z64subs.h index b39842195..96e0366bf 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -25,19 +25,19 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define SUBS_SHADOW_TEX_HEIGHT 64 #define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) -typedef struct TurnOptions { +typedef struct TrackOptions { /* 0x0 */ u16 rotMax; // binary angles /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 /* 0x4 */ u16 rotStepMin; // degrees /* 0x6 */ u16 rotStepMax; // degrees -} TurnOptions; // size = 0x8 +} TrackOptions; // size = 0x8 -typedef struct TurnOptionsSet { - /* 0x00 */ TurnOptions headRotX; - /* 0x08 */ TurnOptions headRotY; - /* 0x10 */ TurnOptions torsoRotX; - /* 0x18 */ TurnOptions torsoRotY; -} TurnOptionsSet; // size = 0x20 +typedef struct TrackOptionsSet { + /* 0x00 */ TrackOptions headRotX; + /* 0x08 */ TrackOptions headRotY; + /* 0x10 */ TrackOptions torsoRotX; + /* 0x18 */ TrackOptions torsoRotY; +} TrackOptionsSet; // size = 0x20 #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) @@ -121,8 +121,8 @@ void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); +s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TrackPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); @@ -165,6 +165,6 @@ s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f3 s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data); s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); +s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); #endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index a0f9bcdd4..7c67226cf 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -57,10 +57,10 @@ typedef struct EnHy { /* 0x205 */ u8 isRightFootOnGround; /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; - /* 0x2C6 */ Vec3s turnTarget; + /* 0x2C6 */ Vec3s trackTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmpTurnTarget; + /* 0x2D8 */ Vec3s tmptrackTarget; /* 0x2DE */ Vec3s tmpHeadRot; /* 0x2E4 */ Vec3s tmpTorsoRot; /* 0x2EA */ s16 limbRotTableY[16]; diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index d95f53269..6fb787451 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -1,107 +1,148 @@ #include "global.h" -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId) { +void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId) { func_80151938(globalCtx, textId); actor->textId = textId; } -s32 nop_800E8ED0(UNK_TYPE4 param_1) { - return 0; +/** + * EventCheckInf does not exist, so this always returns false + */ +s32 Flags_GetEventChkInf(s32 flag) { + return false; } -void nop_800E8EE0(UNK_TYPE4 param_1) { +/** + * EventCheckInf does not exist, so this does nothing + */ +void Flags_SetEventChkInf(s32 flag) { } -s32 nop_800E8EEC(UNK_TYPE4 param_1) { - return 0; +/** + * InfTable does not exist, so this always returns false + */ +s32 Flags_GetInfTable(s32 flag) { + return false; } -void nop_800E8EFC(UNK_TYPE4 param_1) { +/** + * InfTable does not exist, so this does nothing + */ +void Flags_SetInfTable(s32 flag) { } -s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2) { - Math_SmoothStepToS(¶m_1->y, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_1->x, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_2->y, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_2->x, 0, 6, 6200, 100); - return 1; +s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot) { + Math_SmoothStepToS(&headRot->y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&headRot->x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&torsoRot->y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&torsoRot->x, 0, 6, 0x1838, 0x64); + return true; } -s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4) { +s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot) { s16 targetPitch; s16 targetYaw; - s16 yawDiffFromTarget; + s16 yawDiff; - targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, param_2); - targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, param_2) - actor->world.rot.y; + targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, target); + targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, target) - actor->world.rot.y; - Math_SmoothStepToS(¶m_3->x, targetPitch, 6, 2000, 1); - param_3->x = CLAMP(param_3->x, -6000, 6000); + Math_SmoothStepToS(&headRot->x, targetPitch, 6, 0x7D0, 1); + headRot->x = CLAMP(headRot->x, -0x1770, 0x1770); - yawDiffFromTarget = Math_SmoothStepToS(¶m_3->y, targetYaw, 6, 2000, 1); - param_3->y = CLAMP(param_3->y, -8000, 8000); + yawDiff = Math_SmoothStepToS(&headRot->y, targetYaw, 6, 0x7D0, 1); + headRot->y = CLAMP(headRot->y, -0x1F40, 0x1F40); - if (yawDiffFromTarget != 0) { - if (ABS_ALT(param_3->y) < 8000) { - return 0; - } + if ((yawDiff != 0) && (ABS_ALT(headRot->y) < 0x1F40)) { + return false; } - Math_SmoothStepToS(¶m_4->y, targetYaw - param_3->y, 4, 2000, 1); - param_4->y = CLAMP(param_4->y, -12000, 12000); + Math_SmoothStepToS(&torsoRot->y, targetYaw - headRot->y, 4, 0x7D0, 1); + torsoRot->y = CLAMP(torsoRot->y, -0x2EE0, 0x2EE0); - return 1; + return true; } -s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5) { +/** + * Same as Actor_TrackPlayer, except use the actor's world position as the focus point, with the height + * specified. + * + * @param play + * @param actor + * @param headRot the computed actor's head's rotation step + * @param torsoRot the computed actor's torso's rotation step + * @param focusHeight the height of the focus point relative to their world position + * + * @return true if rotated towards player, false if rotations were stepped back to zero. + * + * @note same note as Actor_TrackPlayer + */ +s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, + f32 focusHeight) { Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; + s16 yaw; + Vec3f target; actor->focus.pos = actor->world.pos; - actor->focus.pos.y += param_5; + actor->focus.pos.y += focusHeight; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); - if (sVar3 >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) { + yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (yaw >= 0x4300) { + Actor_TrackNone(headRot, torsoRot); + return false; } } - if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) { - local_14 = globalCtx->view.eye; + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { + target = globalCtx->view.eye; } else { - local_14 = player->actor.focus.pos; + target = player->actor.focus.pos; } - func_800E8FA4(actor, &local_14, param_3, param_4); + Actor_TrackPoint(actor, &target, headRot, torsoRot); - return 1; + return true; } -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) { +/** + * Computes the necessary HeadRot and TorsoRot steps to be added to the normal rotation to smoothly turn an actors's + * head and torso towards the player if within a certain yaw, else smoothly returns the rotations back to zero. + * Also sets the focus position with the specified point. + * + * @param play + * @param actor + * @param headRot the computed actor's head's rotation step + * @param torsoRot the computed actor's torso's rotation step + * @param focusPos the point to set as the actor's focus position + * + * @return true if rotated towards player, false if rotations were stepped back to zero. + * + * @note if in a cutscene or debug camera is enabled, the computed rotation will instead turn towards the view eye no + * matter the yaw. + */ +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) { Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; + s16 yaw; + Vec3f target; - actor->focus.pos = param_5; + actor->focus.pos = focusPos; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); - if (sVar3 >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) { + yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (yaw >= 0x4300) { + Actor_TrackNone(headRot, torsoRot); + return false; } } - if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) { - local_14 = globalCtx->view.eye; + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { + target = globalCtx->view.eye; } else { - local_14 = player->actor.focus.pos; + target = player->actor.focus.pos; } - func_800E8FA4(actor, &local_14, param_3, param_4); + Actor_TrackPoint(actor, &target, headRot, torsoRot); - return 1; + return true; } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 4e1e641de..ddc22949b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4281,7 +4281,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { Player* player = GET_PLAYER(globalCtx); f32 phi_f2; - if ((globalCtx->csCtx.state != 0) || (D_801D0D50 != 0)) { + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; } else { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 01ed87e70..67a4d5608 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -917,7 +917,7 @@ s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) { bcopy(cmd, &sp1C, sizeof(s32)); cmd += sizeof(s32); - if (func_8016A168() == 0) { + if (!Play_IsDebugCamEnabled()) { func_80161998(cmd, &sCutsceneCameraInfo); } return sp1C + sizeof(s32); diff --git a/src/code/z_play.c b/src/code/z_play.c index aa360934e..7d13ee8ee 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -309,10 +309,8 @@ s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { } } -// z_demo and EnTest4 -// This data appears to be a boolean. It is only set by Play_Init. -s32 func_8016A168(void) { - return D_801D0D50; +s32 Play_IsDebugCamEnabled(void) { + return gDbgCamEnabled; } // A mapping from playerActorCsIds to sGlobalCamDataSettings indices. diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index d5b4f33b2..4968185d0 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -1010,7 +1010,7 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { * @param[in] stepMin the minimun step in degrees * @param[in] stepMax the maximum step in degrees */ -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { +s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { s16 prevRot = *rot; f32 step; f32 prevRotStep; @@ -1046,42 +1046,42 @@ s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f /** * Computes the necessary HeadRot and TorsoRot to smoothly turn an actors's head and torso to a point * - * @param[in] point the point to turn to + * @param[in] target the point to turn to * @param[in] focusPos the actor's focus postion * @param[in] shapeRot the actor's shape rotation - * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards + * @param[in,out] trackTarget the intermediate target step that headRot and torsoRot step towards * @param[in,out] headRot the computed head rotation * @param[in,out] torsoRot the computed torso rotation - * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTurnToPointRot() + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTrackPointRot() */ -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, - TurnOptionsSet* options) { +s32 SubS_TrackPoint(Vec3f* target, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trackTarget, Vec3s* headRot, + Vec3s* torsoRot, TrackOptionsSet* options) { s16 pitch; s16 yaw; s16 pad; s16 targetY; - f32 diffX = point->x - focusPos->x; + f32 diffX = target->x - focusPos->x; s16 targetX; - f32 diffZ = point->z - focusPos->z; + f32 diffZ = target->z - focusPos->z; yaw = Math_FAtan2F(diffZ, diffX); - pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), point->y - focusPos->y); - Math_SmoothStepToS(&turnTarget->x, pitch, 4, 0x2710, 0); - Math_SmoothStepToS(&turnTarget->y, yaw, 4, 0x2710, 0); + pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), target->y - focusPos->y); + Math_SmoothStepToS(&trackTarget->x, pitch, 4, 0x2710, 0); + Math_SmoothStepToS(&trackTarget->y, yaw, 4, 0x2710, 0); targetX = - SubS_ComputeTurnToPointRot(&headRot->x, options->headRotX.rotMax, turnTarget->x, options->headRotX.slowness, - options->headRotX.rotStepMin, options->headRotX.rotStepMax); + SubS_ComputeTrackPointRot(&headRot->x, options->headRotX.rotMax, trackTarget->x, options->headRotX.slowness, + options->headRotX.rotStepMin, options->headRotX.rotStepMax); //! @bug: torsoRotX uses headRotX slowness - SubS_ComputeTurnToPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, - options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); + SubS_ComputeTrackPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, + options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); - targetY = turnTarget->y - shapeRot->y; - SubS_ComputeTurnToPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, - options->headRotY.rotStepMin, options->headRotY.rotStepMax); - SubS_ComputeTurnToPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, - options->torsoRotY.slowness, options->torsoRotY.rotStepMin, - options->torsoRotY.rotStepMax); + targetY = trackTarget->y - shapeRot->y; + SubS_ComputeTrackPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, + options->headRotY.rotStepMin, options->headRotY.rotStepMax); + SubS_ComputeTrackPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, + options->torsoRotY.slowness, options->torsoRotY.rotStepMin, + options->torsoRotY.rotStepMax); return true; } @@ -1438,7 +1438,6 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { * @param[out] plane the computed plane * * @note the unit input vector is expected to already be normalized (only uses are with the z unit vector) - * */ void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { f32 sin; @@ -1561,9 +1560,9 @@ s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang * @param[in] torsoZRotStepMax the max torso's Z rotation step * @param[in] torsoXRotStepMax the max torso's X rotation step */ -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, - s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, - u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { +s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, + s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, + u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { s16 yaw = Math_Vec3f_Yaw(worldPos, yawTarget) - shapeYRot; s16 pad; s16 pad2; diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 098d91be4..2f03bec06 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -292,7 +292,7 @@ void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); this->actionFunc(this, globalCtx); if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); this->chestRot.x = this->chestRot.y = this->chestRot.z = 0; } else { Math_SmoothStepToS(&this->headRot.x, 0, 0x6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 1d74c45ae..3fc7566a5 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -462,7 +462,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { } void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { - static TurnOptionsSet sTurnOptions = { + static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -476,11 +476,11 @@ void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); @@ -505,7 +505,7 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->turnTarget; + this->unk_2E6 = this->trackTarget; this->unk_2EC = this->headRot; this->unk_2F2 = this->torsoRot; func_809C16DC(this, globalCtx); @@ -756,7 +756,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { - this->turnTarget = this->unk_2E6; + this->trackTarget = this->unk_2E6; this->headRot = this->unk_2EC; this->torsoRot = this->unk_2F2; this->actor.parent = NULL; @@ -827,7 +827,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { - this->turnTarget = this->unk_2E6; + this->trackTarget = this->unk_2E6; this->headRot = this->unk_2EC; this->torsoRot = this->unk_2F2; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index d4ed3e71e..3f8558744 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -21,7 +21,7 @@ typedef struct EnAob01 { /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; - /* 0x2D4 */ Vec3s turnTarget; + /* 0x2D4 */ Vec3s trackTarget; /* 0x2DA */ Vec3s headRot; /* 0x2E0 */ Vec3s torsoRot; /* 0x2E6 */ Vec3s unk_2E6; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index c10741fdf..b0c32be57 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -121,7 +121,7 @@ static u8 D_80BAA488[] = { s32 D_80BAA4A8[] = { -1, -1, 0 }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -300,11 +300,11 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index 51a986bf0..f95020f95 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -32,7 +32,7 @@ typedef struct EnBaba { /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; /* 0x0206 */ Vec3s jointTable[18]; /* 0x0272 */ Vec3s morphTable[18]; - /* 0x02DE */ Vec3s turnTarget; + /* 0x02DE */ Vec3s trackTarget; /* 0x02E4 */ Vec3s headRot; /* 0x02EA */ Vec3s torsoRot; /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index f2c70dac8..2f932023a 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -97,7 +97,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -113,11 +113,11 @@ void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, - &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.trackTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -134,7 +134,7 @@ s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpTurnTarget = this->enHy.turnTarget; + this->enHy.tmptrackTarget = this->enHy.trackTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -197,7 +197,7 @@ void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->turnTarget = this->tmpTurnTarget; + this->trackTarget = this->tmptrackTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index c60971034..3524343d8 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -78,9 +78,9 @@ void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&pitchTarget, &player->actor.world.pos); pitchTarget.y = player->bodyPartsPos[7].y + 3.0f; - SubS_TurnToPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, - &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, - &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); + SubS_TrackPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, + &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, + &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 1a35e8e50..3d96cd494 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -89,7 +89,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -105,11 +105,11 @@ void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, - &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.trackTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -126,7 +126,7 @@ s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpTurnTarget = this->enHy.turnTarget; + this->enHy.tmptrackTarget = this->enHy.trackTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -187,7 +187,7 @@ void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->turnTarget = this->tmpTurnTarget; + this->trackTarget = this->tmptrackTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 233c0fe61..8cd9d31b8 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1449,7 +1449,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); SubS_FillLimbRotTables(globalCtx, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); EnFsn_Blink(this); if (ENFSN_IS_SHOP(&this->actor) && EnFsn_HasItemsToSell()) { diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 41783a1b7..2aadee0ca 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -974,7 +974,7 @@ void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->unk_26C & 0x100)) { func_80B0F5E0(this, globalCtx); } - func_800E9250(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); } s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index 2683e1296..8aa0666d5 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -730,7 +730,7 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { } func_80B35634(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); func_80B351A4(this); } diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index 46f0b657c..03f50e7aa 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -439,7 +439,7 @@ void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithoutGravity(&this->actor); SkelAnime_Update(&this->skelAnime); func_80B3B8A4(this); - func_800E9250(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { func_800B9010(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index 300987214..32b063b86 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -612,9 +612,9 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { void EnGinkoMan_FacePlayer(EnGinkoMan* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->skelAnime.animation != &object_boj_Anim_004A7C) { - func_800E9250(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb15Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb15Rot, &this->limb8Rot); } } diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index ae9dd8553..ec367af9b 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -1082,7 +1082,7 @@ void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.save.weekEventReg[22] & 4))) { func_80B507A0(this, globalCtx); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); if (ENGK_GET_F(&this->actor) == ENGK_F_1) { func_80B5123C(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index a16e0d94a..813800efb 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -315,7 +315,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD0B8C(EnHgo* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); if (this->unk_30E > 2) { this->unk_30E--; } else if (this->unk_30E == 2) { @@ -337,7 +337,7 @@ void EnHgo_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); if (func_80BD0898(this, globalCtx)) { - func_800E8F08(&this->unk_300, &this->unk_306); + Actor_TrackNone(&this->unk_300, &this->unk_306); } else if (this->actionFunc != func_80BD0410) { if (this->actionFunc != func_80BD0434) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index c3d577e7a..01db67792 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -218,7 +218,7 @@ void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 useViewEye = D_801D0D50 || globalCtx->csCtx.state != 0; + s32 useViewEye = gDbgCamEnabled || globalCtx->csCtx.state != 0; Vec3f transformedPlayerPos; f32 enHollTop; f32 playerDistFromCentralPlane; diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index 1e9fdfbf9..60eb90c50 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -297,7 +297,7 @@ void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); } else if (this->stateFlags & 1) { - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->headRot.x, 0x3200, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index ef4db6f9e..7d8848fd4 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -139,7 +139,7 @@ static AnimationInfoS sAnimations[] = { { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -240,11 +240,11 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); @@ -585,15 +585,15 @@ s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext } else if (this->unk4AC & 8) { func_808F4108(this, globalCtx, 0x3475); } else { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(globalCtx, &this->actor, 0x3473); } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(globalCtx, &this->actor, 0x3472); } return 0; } @@ -608,13 +608,13 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext func_801159EC(-fee); if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3474); + Actor_ContinueText(globalCtx, &this->actor, 0x3474); } else { func_808F4108(this, globalCtx, 0x3474); } } else { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); } else { func_808F4108(this, globalCtx, 0x3475); } @@ -622,14 +622,14 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext } else { play_sound(NA_SE_SY_ERROR); if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(globalCtx, &this->actor, 0x3473); } else { func_808F4108(this, globalCtx, 0x3473); } } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(globalCtx, &this->actor, 0x3472); } return 0; } @@ -649,7 +649,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x34AF: - func_800E8EA0(globalCtx, &this->actor, 0x34B0); + Actor_ContinueText(globalCtx, &this->actor, 0x34B0); ret = false; break; case 0x34A9: @@ -670,11 +670,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x34AD: - func_800E8EA0(globalCtx, &this->actor, 0x34AE); + Actor_ContinueText(globalCtx, &this->actor, 0x34AE); ret = false; break; case 0x34B1: - func_800E8EA0(globalCtx, &this->actor, 0x34B2); + Actor_ContinueText(globalCtx, &this->actor, 0x34B2); ret = false; break; default: @@ -686,11 +686,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3458: gSaveContext.save.weekEventReg[15] |= 8; - func_800E8EA0(globalCtx, &this->actor, 0x3459); + Actor_ContinueText(globalCtx, &this->actor, 0x3459); ret = false; break; case 0x3459: - func_800E8EA0(globalCtx, &this->actor, 0x345A); + Actor_ContinueText(globalCtx, &this->actor, 0x345A); ret = false; break; case 0x345A: @@ -702,15 +702,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x345C: - func_800E8EA0(globalCtx, &this->actor, 0x345D); + Actor_ContinueText(globalCtx, &this->actor, 0x345D); ret = false; break; case 0x345D: - func_800E8EA0(globalCtx, &this->actor, 0x345E); + Actor_ContinueText(globalCtx, &this->actor, 0x345E); ret = false; break; case 0x345E: - func_800E8EA0(globalCtx, &this->actor, 0x345F); + Actor_ContinueText(globalCtx, &this->actor, 0x345F); ret = false; break; case 0x345F: @@ -718,11 +718,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x3460: - func_800E8EA0(globalCtx, &this->actor, 0x3461); + Actor_ContinueText(globalCtx, &this->actor, 0x3461); ret = false; break; case 0x3461: - func_800E8EA0(globalCtx, &this->actor, 0x3462); + Actor_ContinueText(globalCtx, &this->actor, 0x3462); ret = false; break; case 0x3462: @@ -735,15 +735,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3463: gSaveContext.save.weekEventReg[15] |= 0x10; - func_800E8EA0(globalCtx, &this->actor, 0x3464); + Actor_ContinueText(globalCtx, &this->actor, 0x3464); ret = false; break; case 0x3464: - func_800E8EA0(globalCtx, &this->actor, 0x3465); + Actor_ContinueText(globalCtx, &this->actor, 0x3465); ret = false; break; case 0x3465: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(globalCtx, &this->actor, 0x3466); ret = false; break; case 0x3466: @@ -756,17 +756,17 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(globalCtx, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(globalCtx, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3467); + Actor_ContinueText(globalCtx, &this->actor, 0x3467); ret = false; } break; @@ -777,11 +777,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x346B: - func_800E8EA0(globalCtx, &this->actor, 0x346C); + Actor_ContinueText(globalCtx, &this->actor, 0x346C); ret = false; break; case 0x346C: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(globalCtx, &this->actor, 0x3466); ret = false; break; case 0x346A: @@ -797,11 +797,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3470: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3483: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3471: @@ -872,7 +872,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3476: - func_800E8EA0(globalCtx, &this->actor, 0x3477); + Actor_ContinueText(globalCtx, &this->actor, 0x3477); func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); ret = false; @@ -886,7 +886,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x347E); + Actor_ContinueText(globalCtx, &this->actor, 0x347E); ret = false; } else { gSaveContext.save.weekEventReg[56] |= 8; @@ -901,12 +901,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x347F); + Actor_ContinueText(globalCtx, &this->actor, 0x347F); ret = false; } break; case 0x347F: - func_800E8EA0(globalCtx, &this->actor, 0x3480); + Actor_ContinueText(globalCtx, &this->actor, 0x3480); ret = false; break; case 0x3480: @@ -944,12 +944,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 4: switch (textId) { case 0x3486: - func_800E8EA0(globalCtx, &this->actor, 0x3487); + Actor_ContinueText(globalCtx, &this->actor, 0x3487); gSaveContext.save.weekEventReg[16] |= 1; ret = false; break; case 0x3487: - func_800E8EA0(globalCtx, &this->actor, 0x3488); + Actor_ContinueText(globalCtx, &this->actor, 0x3488); ret = false; break; case 0x3488: @@ -963,11 +963,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x348B: - func_800E8EA0(globalCtx, &this->actor, 0x348C); + Actor_ContinueText(globalCtx, &this->actor, 0x348C); ret = false; break; case 0x348C: - func_800E8EA0(globalCtx, &this->actor, 0x348D); + Actor_ContinueText(globalCtx, &this->actor, 0x348D); ret = false; break; case 0x348D: @@ -985,17 +985,17 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x348E: case 0x34B3: - func_800E8EA0(globalCtx, &this->actor, 0x348F); + Actor_ContinueText(globalCtx, &this->actor, 0x348F); gSaveContext.save.weekEventReg[16] |= 2; ret = false; break; case 0x3493: - func_800E8EA0(globalCtx, &this->actor, 0x3494); + Actor_ContinueText(globalCtx, &this->actor, 0x3494); ret = false; break; case 0x348F: case 0x3494: - func_800E8EA0(globalCtx, &this->actor, 0x3490); + Actor_ContinueText(globalCtx, &this->actor, 0x3490); ret = false; break; case 0x3490: @@ -1008,17 +1008,17 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(globalCtx, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(globalCtx, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3491); + Actor_ContinueText(globalCtx, &this->actor, 0x3491); ret = false; } break; @@ -1062,7 +1062,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x3474: - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); ret = false; break; case 0x3475: @@ -1077,7 +1077,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x34A1); + Actor_ContinueText(globalCtx, &this->actor, 0x34A1); ret = false; } else { gSaveContext.save.weekEventReg[56] |= 8; @@ -1105,12 +1105,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x34A2); + Actor_ContinueText(globalCtx, &this->actor, 0x34A2); ret = false; } break; case 0x34A2: - func_800E8EA0(globalCtx, &this->actor, 0x34A3); + Actor_ContinueText(globalCtx, &this->actor, 0x34A3); ret = false; break; case 0x34A3: @@ -1119,13 +1119,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x3499: - func_800E8EA0(globalCtx, &this->actor, 0x349A); + Actor_ContinueText(globalCtx, &this->actor, 0x349A); func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); ret = false; break; case 0x349A: - func_800E8EA0(globalCtx, &this->actor, 0x349B); + Actor_ContinueText(globalCtx, &this->actor, 0x349B); ret = false; break; case 0x349B: @@ -1134,7 +1134,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x349C); + Actor_ContinueText(globalCtx, &this->actor, 0x349C); ret = false; } break; @@ -1154,7 +1154,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3498: case 0x34A6: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3471: diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index ae339ecaa..e0667e0c2 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,7 +36,7 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ Vec3s turnTarget; + /* 0x352 */ Vec3s trackTarget; /* 0x358 */ Vec3s headRot; /* 0x35E */ Vec3s torsoRot; /* 0x364 */ char unk364[0x12]; diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 8f2408495..5c7d0d4fe 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -992,7 +992,8 @@ void EnJg_Update(Actor* thisx, GlobalContext* globalCtx) { EnJg_SpawnBreath(this, globalCtx); } - func_800E9250(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, + this->actor.focus.pos); } this->actionFunc(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 9e00b09e4..4d9f9b82f 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -586,7 +586,7 @@ void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { } void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); if (DECR(this->unk_2FA) == 0) { this->unk_2FA = Rand_S16Offset(60, 60); diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index 5b32a556b..fac169b9d 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -741,7 +741,7 @@ void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); func_80B279AC(this, globalCtx); func_80B27880(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index cc184cfed..dec6be3f8 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -1090,7 +1090,7 @@ void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx) { sp30.z = 0; sp30.y = 0; sp30.x = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2CC.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2CC.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index b0e468ab2..0071673b4 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -451,7 +451,7 @@ void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { - func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 6ee806d2e..58f915f30 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -517,7 +517,7 @@ void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->unk_2B0 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); } Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 90cd6785f..a214bd72f 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -846,7 +846,7 @@ void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } } - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); } s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index be1def264..95c75b24b 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1554,7 +1554,7 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { EnOssan_UpdateItemSelectedProperty(this); EnOssan_UpdateStickDirectionPromptAnim(this); EnOssan_UpdateCursorAnim(this); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); this->actionFunc(this, globalCtx); Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index e17cba0e2..7ca549ca4 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -511,9 +511,9 @@ void func_80BD94E0(EnPamera* this, GlobalContext* globalCtx) { if ((this->actionFunc != func_80BD8B70) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD909C) && (this->actionFunc != func_80BD8D1C) && ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ == 3.0f))) { - func_800E9250(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb9Rot, &this->limb8Rot); } } @@ -856,7 +856,7 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[61] & 4)) { gSaveContext.save.weekEventReg[61] |= 4; } - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb9Rot, &this->limb8Rot); } else { func_80BD94E0(this, globalCtx); if (this->actionFunc == func_80BD994C) { diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 13ab86f52..94f697601 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -178,7 +178,7 @@ void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); EnRecepgirl_UpdateEyes(this); } diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 2d8eaa643..3681deadd 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -61,7 +61,7 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); } s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 6d89bef7b..58a4f1c59 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -635,7 +635,7 @@ void func_80B680A8(Actor* thisx, GlobalContext* globalCtx) { if (func_80B6703C(this, globalCtx) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { sp38.x = sp38.y = sp38.z = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_294.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_294.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 21b0dd9a2..6290bde81 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -120,7 +120,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -530,11 +530,11 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 1fefc6f23..5418f182e 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,7 +27,7 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ Vec3s turnTarget; + /* 0x2D6 */ Vec3s trackTarget; /* 0x2DC */ Vec3s headRot; /* 0x2E2 */ Vec3s torsoRot; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 6ea613a6b..b5509e6c8 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1225,7 +1225,7 @@ void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a52c9391d..9b78916c4 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -777,7 +777,8 @@ void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { - func_800E9250(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, + this->actor.focus.pos); func_800B8614(&this->actor, globalCtx, 100.0f); } else { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 729a82a70..bfe6a5b55 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -370,7 +370,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && - (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { + (globalCtx->roomCtx.unk31 == 0) && (!Play_IsDebugCamEnabled())) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; s16 temp_a3; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 1a357dcd8..02023b4ef 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -568,7 +568,7 @@ void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->unk_220 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_222.x, 0, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->unk_222.y, 0, 6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 28c493497..31fb3a853 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -173,7 +173,7 @@ void EnZo_UpdateCollider(EnZo* this, GlobalContext* globalCtx) { } void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { - static TurnOptionsSet sTurnOptions = { + static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -187,11 +187,11 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->upperBodyRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->upperBodyRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 1000, 1); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index adf8b6bae..fcc753ba5 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -25,7 +25,7 @@ typedef struct EnZo { /* 0x01FD */ u8 isRightFootGrounded; /* 0x01FE */ Vec3s jointTable[ZORA_LIMB_MAX]; /* 0x0276 */ Vec3s morphTable[ZORA_LIMB_MAX]; - /* 0x02EE */ Vec3s turnTarget; + /* 0x02EE */ Vec3s trackTarget; /* 0x02F4 */ Vec3s headRot; /* 0x02FA */ Vec3s upperBodyRot; /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 24b03ab5f..33e26e7e5 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -726,7 +726,7 @@ void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_2F4 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 69deb43d6..ca197eb12 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1324,7 +1324,7 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (!(this->unk_2F2 & 8)) { if (!(this->unk_2F2 & 4) && func_80B96DF0(this, globalCtx)) { - func_800E9250(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2C4.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 4bb5f2a5a..5979178f1 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -482,7 +482,7 @@ void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_320 & 1) && func_80BD15A4(this, globalCtx)) { - func_800E9250(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); } else { if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { Math_SmoothStepToS(&this->unk_2F0.x, -0x1B58, 6, 0x1838, 0x64); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6477dd98c..997a062fe 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1509,15 +1509,15 @@ 0x800E86C0:("CollisionCheck_SpawnShieldParticlesMetal2",), 0x800E86E0:("CollisionCheck_SpawnShieldParticlesWood",), 0x800E8784:("CollisionCheck_CylSideVsLineSeg",), - 0x800E8EA0:("func_800E8EA0",), - 0x800E8ED0:("nop_800E8ED0",), - 0x800E8EE0:("nop_800E8EE0",), - 0x800E8EEC:("nop_800E8EEC",), - 0x800E8EFC:("nop_800E8EFC",), - 0x800E8F08:("func_800E8F08",), - 0x800E8FA4:("func_800E8FA4",), - 0x800E9138:("func_800E9138",), - 0x800E9250:("func_800E9250",), + 0x800E8EA0:("Actor_ContinueText",), + 0x800E8ED0:("Flags_GetEventChkInf",), + 0x800E8EE0:("Flags_SetEventChkInf",), + 0x800E8EEC:("Flags_GetInfTable",), + 0x800E8EFC:("Flags_SetInfTable",), + 0x800E8F08:("Actor_TrackNone",), + 0x800E8FA4:("Actor_TrackPoint",), + 0x800E9138:("Actor_TrackPlayerSetFocusHeight",), + 0x800E9250:("Actor_TrackPlayer",), 0x800E9360:("SaveContext_Init",), 0x800E93E0:("GameInfo_Init",), 0x800E9470:("DebugDisplay_Init",), @@ -2679,8 +2679,8 @@ 0x8013CC2C:("SubS_FillShadowTex",), 0x8013CD64:("SubS_GenShadowTex",), 0x8013CF04:("SubS_DrawShadowTex",), - 0x8013D0E0:("SubS_ComputeTurnToPointRot",), - 0x8013D2E0:("SubS_TurnToPoint",), + 0x8013D0E0:("SubS_ComputeTrackPointRot",), + 0x8013D2E0:("SubS_TrackPoint",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), 0x8013D648:("SubS_GetPathByIndex",), 0x8013D68C:("SubS_CopyPointFromPath",), @@ -2709,7 +2709,7 @@ 0x8013E748:("func_8013E748",), 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("SubS_TurnToPointStep",), + 0x8013E950:("SubS_TrackPointStep",), 0x8013EC10:("func_8013EC10",), 0x8013EC44:("func_8013EC44",), 0x8013ECE0:("func_8013ECE0",), @@ -3036,7 +3036,7 @@ 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), 0x8016A0AC:("Play_IsUnderwater",), - 0x8016A168:("func_8016A168",), + 0x8016A168:("Play_IsDebugCamEnabled",), 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), 0x8016A268:("func_8016A268",), 0x8016A2C8:("Play_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 602916a8e..d643adfcb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2171,7 +2171,7 @@ 0x801D0CD8:("TransitionFade_InitVars","UNK_PTR","",0x4), 0x801D0D00:("D_801D0D00","UNK_TYPE1","",0x1), 0x801D0D28:("TransitionCircle_InitVars","UNK_PTR","",0x4), - 0x801D0D50:("D_801D0D50","UNK_TYPE4","",0x4), + 0x801D0D50:("gDbgCamEnabled","UNK_TYPE4","",0x4), 0x801D0D54:("D_801D0D54","UNK_TYPE1","",0x1), 0x801D0D58:("D_801D0D58","UNK_TYPE2","",0x2), 0x801D0D5C:("D_801D0D5C","UNK_TYPE2","",0x2), diff --git a/tools/namefixer.py b/tools/namefixer.py index 1d6c89a7b..b273b05ca 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -540,6 +540,10 @@ wordReplace = { "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + "func_800E8F08": "Actor_TrackNone", + "func_800E8FA4": "Actor_TrackPoint", + "func_800E9250": "Actor_TrackPlayer", + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index b3e5db147..03717a020 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1023,15 +1023,15 @@ asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesMeta asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesMetal2.s,CollisionCheck_SpawnShieldParticlesMetal2,0x800E86C0,0x8 asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesWood.s,CollisionCheck_SpawnShieldParticlesWood,0x800E86E0,0x29 asm/non_matchings/code/z_collision_check/CollisionCheck_CylSideVsLineSeg.s,CollisionCheck_CylSideVsLineSeg,0x800E8784,0x1C7 -asm/non_matchings/code/code_800E8EA0/func_800E8EA0.s,func_800E8EA0,0x800E8EA0,0xC -asm/non_matchings/code/code_800E8EA0/nop_800E8ED0.s,nop_800E8ED0,0x800E8ED0,0x4 -asm/non_matchings/code/code_800E8EA0/nop_800E8EE0.s,nop_800E8EE0,0x800E8EE0,0x3 -asm/non_matchings/code/code_800E8EA0/nop_800E8EEC.s,nop_800E8EEC,0x800E8EEC,0x4 -asm/non_matchings/code/code_800E8EA0/nop_800E8EFC.s,nop_800E8EFC,0x800E8EFC,0x3 -asm/non_matchings/code/code_800E8EA0/func_800E8F08.s,func_800E8F08,0x800E8F08,0x27 -asm/non_matchings/code/code_800E8EA0/func_800E8FA4.s,func_800E8FA4,0x800E8FA4,0x65 -asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x46 -asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 +asm/non_matchings/code/code_800E8EA0/Actor_ContinueText.s,Actor_ContinueText,0x800E8EA0,0xC +asm/non_matchings/code/code_800E8EA0/Flags_GetEventChkInf.s,Flags_GetEventChkInf,0x800E8ED0,0x4 +asm/non_matchings/code/code_800E8EA0/Flags_SetEventChkInf.s,Flags_SetEventChkInf,0x800E8EE0,0x3 +asm/non_matchings/code/code_800E8EA0/Flags_GetInfTable.s,Flags_GetInfTable,0x800E8EEC,0x4 +asm/non_matchings/code/code_800E8EA0/Flags_SetInfTable.s,Flags_SetInfTable,0x800E8EFC,0x3 +asm/non_matchings/code/code_800E8EA0/Actor_TrackNone.s,Actor_TrackNone,0x800E8F08,0x27 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPoint.s,Actor_TrackPoint,0x800E8FA4,0x65 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayerSetFocusHeight.s,Actor_TrackPlayerSetFocusHeight,0x800E9138,0x46 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayer.s,Actor_TrackPlayer,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 @@ -2193,8 +2193,8 @@ asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 -asm/non_matchings/code/z_sub_s/SubS_ComputeTurnToPointRot.s,SubS_ComputeTurnToPointRot,0x8013D0E0,0x80 -asm/non_matchings/code/z_sub_s/SubS_TurnToPoint.s,SubS_TurnToPoint,0x8013D2E0,0xC2 +asm/non_matchings/code/z_sub_s/SubS_ComputeTrackPointRot.s,SubS_ComputeTrackPointRot,0x8013D0E0,0x80 +asm/non_matchings/code/z_sub_s/SubS_TrackPoint.s,SubS_TrackPoint,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 @@ -2223,7 +2223,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x801 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 -asm/non_matchings/code/z_sub_s/SubS_TurnToPointStep.s,SubS_TurnToPointStep,0x8013E950,0xB0 +asm/non_matchings/code/z_sub_s/SubS_TrackPointStep.s,SubS_TrackPointStep,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD asm/non_matchings/code/code_8013EC10/func_8013EC44.s,func_8013EC44,0x8013EC44,0x27 asm/non_matchings/code/code_8013EC10/func_8013ECE0.s,func_8013ECE0,0x8013ECE0,0x2F @@ -2550,7 +2550,7 @@ asm/non_matchings/code/z_play/func_80169FFC.s,func_80169FFC,0x80169FFC,0x8 asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s,FrameAdvance_IsEnabled,0x8016A01C,0x4 asm/non_matchings/code/z_play/func_8016A02C.s,func_8016A02C,0x8016A02C,0x20 asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F -asm/non_matchings/code/z_play/func_8016A168.s,func_8016A168,0x8016A168,0x4 +asm/non_matchings/code/z_play/Play_IsDebugCamEnabled.s,Play_IsDebugCamEnabled,0x8016A168,0x4 asm/non_matchings/code/z_play/func_8016A178.s,func_8016A178,0x8016A178,0x3C asm/non_matchings/code/z_play/func_8016A268.s,func_8016A268,0x8016A268,0x18 asm/non_matchings/code/z_play/Play_Init.s,Play_Init,0x8016A2C8,0x252 From c6963e27d098f8837130e83805f847a03ffe46f5 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 20 Jun 2022 13:26:48 -0300 Subject: [PATCH 50/53] ovl_Item_Etcetera decompiled (#849) * ovl_Item_Etcetera decompiled * PR review fixes * PR Review Fixes * pr review fixes * pr review fixes * pr review fixes * final * merge Co-authored-by: SonicDcer --- include/z64item.h | 10 +- spec | 3 +- .../ovl_Item_Etcetera/z_item_etcetera.c | 115 +++++++++++++++--- .../ovl_Item_Etcetera/z_item_etcetera.h | 30 ++++- 4 files changed, 138 insertions(+), 20 deletions(-) diff --git a/include/z64item.h b/include/z64item.h index 81fdbe066..43c538a3f 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -295,6 +295,7 @@ typedef enum { /* 0x22 */ GI_QUIVER_30, /* 0x23 */ GI_QUIVER_40, /* 0x24 */ GI_QUIVER_50, + /* 0x25 */ GI_25 = 0x25, /* 0x28 */ GI_NUTS_1 = 0x28, /* 0x2A */ GI_NUTS_10 = 0x2A, /* 0x32 */ GI_SHIELD_HERO = 0x32, @@ -364,13 +365,15 @@ typedef enum { typedef enum { /* 0x00 */ GID_BOTTLE, - /* 0x02 */ GID_02 = 0x02, + /* 0x01 */ GID_01, + /* 0x02 */ GID_02, /* 0x03 */ GID_03, /* 0x0A */ GID_COMPASS = 0x0A, /* 0x0E */ GID_0E = 0x0E, /* 0x0F */ GID_0F, /* 0x10 */ GID_MASK_ALL_NIGHT = 0x10, /* 0x11 */ GID_NUTS, + /* 0x13 */ GID_13 = 0x13, /* 0x17 */ GID_BOMB_BAG_20 = 0x17, /* 0x18 */ GID_BOMB_BAG_30, /* 0x19 */ GID_BOMB_BAG_40, @@ -392,6 +395,11 @@ typedef enum { /* 0x3E */ GID_3E = 0x3E, /* 0x44 */ GID_44 = 0x44, /* 0x45 */ GID_45, + /* 0x47 */ GID_47 = 0x47, + /* 0x4F */ GID_4F = 0x4F, + /* 0x50 */ GID_50, + /* 0x51 */ GID_51, + /* 0x53 */ GID_53 = 0x53, /* 0x55 */ GID_SWORD_KOKIRI = 0x55, /* 0x66 */ GID_SWORD_RAZOR = 0x66, /* 0x67 */ GID_SWORD_GILDED, diff --git a/spec b/spec index ac6a462aa..053c436df 100644 --- a/spec +++ b/spec @@ -1334,8 +1334,7 @@ beginseg name "ovl_Item_Etcetera" compress include "build/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.o" - include "build/data/ovl_Item_Etcetera/ovl_Item_Etcetera.data.o" - include "build/data/ovl_Item_Etcetera/ovl_Item_Etcetera.reloc.o" + include "build/src/overlays/actors/ovl_Item_Etcetera/ovl_Item_Etcetera_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index 82b29e716..2eb920207 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -14,11 +14,12 @@ void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx); void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx); void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx); -void func_80920044(ItemEtcetera* this, GlobalContext* globalCtx); +void ItemEtcetera_WaitForObject(ItemEtcetera* this, GlobalContext* globalCtx); +void func_8092009C(ItemEtcetera* this, GlobalContext* globalCtx); +void func_809200F8(ItemEtcetera* this, GlobalContext* globalCtx); +void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx); +void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx); -void ItemEtcetera_SetupAction(ItemEtcetera* this, ItemEtceteraActionFunc actionFunc); - -#if 0 const ActorInit Item_Etcetera_InitVars = { ACTOR_ITEM_ETCETERA, ACTORCAT_PROP, @@ -31,22 +32,108 @@ const ActorInit Item_Etcetera_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sObjectIds[] = { + OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, OBJECT_GI_BOTTLE, + OBJECT_GI_BOTTLE, OBJECT_GI_KEY, OBJECT_GI_M_ARROW, OBJECT_GI_RUPY, OBJECT_GI_RUPY, + OBJECT_GI_RUPY, OBJECT_GI_RUPY, OBJECT_GI_HEARTS, OBJECT_GI_KEY, +}; +static s16 sDrawItemIndices[] = { + GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_BOTTLE, GID_01, + GID_47, GID_4F, GID_50, GID_51, GID_53, GID_13, GID_01, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_SetupAction.s") +static s16 sGetItemIds[] = { + GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_BOTTLE, GI_KEY_SMALL, + GI_25, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, GI_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_Init.s") +void ItemEtcetera_SetupAction(ItemEtcetera* this, ItemEtceteraActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_Destroy.s") +void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ItemEtcetera* this = THIS; + s32 type = ITEMETCETERA_GET_FF(&this->actor); + s32 objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sObjectIds[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_80920044.s") + if (objBankIndex < 0) { + // assert on debug + } else { + this->objIndex = objBankIndex; + } + this->giDrawId = sDrawItemIndices[type]; + this->itemID = sGetItemIds[type]; + this->futureActionFunc = func_8092009C; + this->drawFunc = ItemEtcetera_Draw; + Actor_SetScale(&this->actor, 0.25f); + ItemEtcetera_SetupAction(this, ItemEtcetera_WaitForObject); + switch (type) { + case ITEM_ETC_ARROW_FIRE: + Actor_SetScale(&this->actor, 0.5f); + this->actor.draw = NULL; + this->actor.shape.yOffset = 50.0f; + break; + case ITEM_ETC_RUPEE_GREEN_CHEST_GAME: + case ITEM_ETC_RUPEE_BLUE_CHEST_GAME: + case ITEM_ETC_RUPEE_RED_CHEST_GAME: + case ITEM_ETC_RUPEE_PURPLE_CHEST_GAME: + case ITEM_ETC_HEART_PIECE_CHEST_GAME: + case ITEM_ETC_KEY_SMALL_CHEST_GAME: + Actor_SetScale(&this->actor, 0.5f); + this->futureActionFunc = func_809200F8; + this->drawFunc = ItemEtcetera_DrawThroughLens; + this->actor.world.pos.y += 15.0f; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_8092009C.s") +void ItemEtcetera_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_809200F8.s") +void ItemEtcetera_WaitForObject(ItemEtcetera* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + this->actor.objBankIndex = this->objIndex; + this->actor.draw = this->drawFunc; + this->actionFunc = this->futureActionFunc; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/ItemEtcetera_Update.s") +void func_8092009C(ItemEtcetera* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + Actor_MarkForDeath(&this->actor); + } else { + Actor_PickUp(&this->actor, globalCtx, this->itemID, 30.0f, 50.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_80920164.s") +void func_809200F8(ItemEtcetera* this, GlobalContext* globalCtx) { + if (Flags_GetTreasure(globalCtx, ITEMETCETERA_GET_TREASUREFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_809201BC.s") +void ItemEtcetera_Update(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + func_800B8050(&this->actor, globalCtx, 0); + func_800B8118(&this->actor, globalCtx, 0); + GetItem_Draw(globalCtx, this->giDrawId); + } +} + +void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx) { + ItemEtcetera* this = THIS; + + func_800B8050(&this->actor, globalCtx, 0); + func_800B8118(&this->actor, globalCtx, 0); + GetItem_Draw(globalCtx, this->giDrawId); +} diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h index 88d08a54d..16b476d96 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -5,12 +5,36 @@ struct ItemEtcetera; +#define ITEMETCETERA_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ITEMETCETERA_GET_TREASUREFLAG(thisx) (((thisx)->params >> 8) & 0x1F) + typedef void (*ItemEtceteraActionFunc)(struct ItemEtcetera*, GlobalContext*); +typedef enum { + /* 0x00 */ ITEM_ETC_BOTTLE_1, + /* 0x01 */ ITEM_ETC_BOTTLE_2, + /* 0x02 */ ITEM_ETC_BOTTLE_3, + /* 0x03 */ ITEM_ETC_BOTTLE_4, + /* 0x04 */ ITEM_ETC_BOTTLE_5, + /* 0x05 */ ITEM_ETC_BOTTLE_6, + /* 0x06 */ ITEM_ETC_KEY_SMALL, + /* 0x07 */ ITEM_ETC_ARROW_FIRE, + /* 0x08 */ ITEM_ETC_RUPEE_GREEN_CHEST_GAME, + /* 0x09 */ ITEM_ETC_RUPEE_BLUE_CHEST_GAME, + /* 0x0A */ ITEM_ETC_RUPEE_RED_CHEST_GAME, + /* 0x0B */ ITEM_ETC_RUPEE_PURPLE_CHEST_GAME, + /* 0x0C */ ITEM_ETC_HEART_PIECE_CHEST_GAME, + /* 0x0D */ ITEM_ETC_KEY_SMALL_CHEST_GAME +} ItemEtceteraType; + typedef struct ItemEtcetera { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x10]; - /* 0x0154 */ ItemEtceteraActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ItemEtceteraActionFunc futureActionFunc; + /* 0x148 */ s16 giDrawId; + /* 0x14A */ s16 itemID; + /* 0x14C */ u8 objIndex; + /* 0x150 */ ActorFunc drawFunc; + /* 0x154 */ ItemEtceteraActionFunc actionFunc; } ItemEtcetera; // size = 0x158 extern const ActorInit Item_Etcetera_InitVars; From 361d8573e908f3469b3c03631753fad921022818 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Mon, 20 Jun 2022 15:44:12 -0400 Subject: [PATCH 51/53] z_obj_tsubo OK (#784) * 4 unattempts left * z_obj_tsubo OK * name some functions * implement suggestions * implement EllipticEllipsis changes * implement more suggestions --- include/functions.h | 2 +- spec | 3 +- src/code/z_en_item00.c | 4 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 6 +- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 2 +- .../actors/ovl_Obj_Kibako2/z_obj_kibako2.c | 4 +- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 664 ++++++++++++++++-- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.h | 27 +- tools/disasm/functions.txt | 20 +- 10 files changed, 670 insertions(+), 64 deletions(-) diff --git a/include/functions.h b/include/functions.h index 30453cf8d..84be91ee7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -450,7 +450,7 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 para void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params); s32 func_800A8150(s32 index); s32 func_800A817C(s32 index); -s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2); +s32 Item_CanDropBigFairy(GlobalContext* globalCtx, s32 index, s32 collectibleFlag); void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2); void EffectBlure_AddSpace(EffectBlure* this); void EffectBlure_Init1(void* thisx, void* initParamsx); diff --git a/spec b/spec index 053c436df..a7e9ba36c 100644 --- a/spec +++ b/spec @@ -1369,8 +1369,7 @@ beginseg name "ovl_Obj_Tsubo" compress include "build/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.o" - include "build/data/ovl_Obj_Tsubo/ovl_Obj_Tsubo.data.o" - include "build/data/ovl_Obj_Tsubo/ovl_Obj_Tsubo.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Tsubo/ovl_Obj_Tsubo_reloc.o" endseg beginseg diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 6b01753cc..7ba6134fb 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -1185,6 +1185,6 @@ s32 func_800A817C(s32 index) { return D_801AE214[index]; } -s32 func_800A81A4(GlobalContext* globalCtx, s32 a1, s32 a2) { - return (func_800A8150(a1) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, a2)); +s32 Item_CanDropBigFairy(GlobalContext* globalCtx, s32 index, s32 collectibleFlag) { + return (func_800A8150(index) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, collectibleFlag)); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 0188b323c..ed320dadd 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -487,7 +487,7 @@ void func_808D9894(EnSw* this, Vec3f* vec) { s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { s32 ret = false; - s32 param = ENSW_GET_3FC(&this->actor) & 0xFF; + s32 param = ENSW_GET_3FC(&this->actor); if (ENSW_GET_3(&this->actor)) { if ((param != 0x3F) && Flags_GetTreasure(globalCtx, param)) { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index b74062705..4d8e52955 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -7,8 +7,10 @@ struct EnSw; typedef void (*EnSwActionFunc)(struct EnSw*, GlobalContext*); -#define ENSW_GET_3(thisx) (((thisx)->params & 3) & 0xFF) -#define ENSW_GET_3FC(thisx) (((thisx)->params & 0x3FC) >> 2) +#define ENSW_GETS_3(params) ((params & 3) & 0xFF) +#define ENSW_GET_3(thisx) (ENSW_GETS_3((thisx)->params)) +#define ENSW_GETS_3FC(params) (((params & 0x3FC) >> 2) & 0xFF) +#define ENSW_GET_3FC(thisx) (ENSW_GETS_3FC((thisx)->params)) #define ENSW_GET_FF00(thisx) ((((thisx)->params & 0xFF00) >> 8) & 0xFF) typedef struct EnSw { diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 737f9ef46..7c674b0c6 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -341,7 +341,7 @@ void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); - if ((sp2C == 0) && func_800A81A4(globalCtx, OBJCOMB_GET_3F(&this->actor), OBJCOMB_GET_7F00(&this->actor))) { + if ((sp2C == 0) && Item_CanDropBigFairy(globalCtx, OBJCOMB_GET_3F(&this->actor), OBJCOMB_GET_7F00(&this->actor))) { this->unk_1B7 = 1; this->actor.flags |= ACTOR_FLAG_10; } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index 194989ad5..455905193 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -158,8 +158,8 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.world.rot.x = 0; this->dyna.actor.shape.rot.x = 0; if (contents == CONTENTS_COLLECTIBLE) { - if (func_800A81A4(globalCtx, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), - KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { + if (Item_CanDropBigFairy(globalCtx, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), + KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { this->unk_1AC = 1; this->dyna.actor.flags |= ACTOR_FLAG_10; } diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index af00e5c64..3f7dc4274 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -5,6 +5,10 @@ */ #include "z_obj_tsubo.h" +#include "overlays/actors/ovl_En_Sw/z_en_sw.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_tsubo/object_tsubo.h" +#include "objects/object_racetsubo/object_racetsubo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_4000000) @@ -13,14 +17,30 @@ void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx); void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_Draw(Actor* thisx, GlobalContext* globalCtx); +void ObjTsubo_PotBreak1(ObjTsubo* this, GlobalContext* globalCtx); +void ObjTsubo_RacePotBreak1(ObjTsubo* this, GlobalContext* globalCtx); +void ObjTsubo_PotBreak2(ObjTsubo* this, GlobalContext* globalCtx2); +void ObjTsubo_RacePotBreak2(ObjTsubo* this, GlobalContext* globalCtx2); +void ObjTsubo_PotBreak3(ObjTsubo* this, GlobalContext* globalCtx2); +void ObjTsubo_RacePotBreak3(ObjTsubo* this, GlobalContext* globalCtx2); +void func_80928914(ObjTsubo* this); void func_80928928(ObjTsubo* this, GlobalContext* globalCtx); +void func_809289B4(ObjTsubo* this); void func_809289E4(ObjTsubo* this, GlobalContext* globalCtx); +void func_80928D6C(ObjTsubo* this); void func_80928D80(ObjTsubo* this, GlobalContext* globalCtx); +void func_80928E74(ObjTsubo* this); void func_80928F18(ObjTsubo* this, GlobalContext* globalCtx); +void func_809291DC(ObjTsubo* this); void func_8092926C(ObjTsubo* this, GlobalContext* globalCtx); -#if 0 +s16 D_80929500 = 0; +s16 D_80929504 = 0; +s16 D_80929508 = 0; +s16 D_8092950C = 0; + const ActorInit Obj_Tsubo_InitVars = { ACTOR_OBJ_TSUBO, ACTORCAT_PROP, @@ -33,79 +53,639 @@ const ActorInit Obj_Tsubo_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809295B0 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +typedef struct { + /* 0x00 */ s16 objId; + /* 0x04 */ f32 scale; + /* 0x08 */ Gfx* modelDL; + /* 0x0C */ Gfx* shardDL; + /* 0x10 */ s16 radius; + /* 0x12 */ s16 height; + /* 0x14 */ ObjTsuboUnkFunc breakPot1; + /* 0x18 */ ObjTsuboUnkFunc breakPot2; + /* 0x1C */ ObjTsuboUnkFunc breakPot3; + +} ObjTsuboData; + +ObjTsuboData sPotTypeData[4] = { + { GAMEPLAY_DANGEON_KEEP, 0.197f, gameplay_dangeon_keep_DL_017EA0, gameplay_dangeon_keep_DL_018090, 12, 32, + ObjTsubo_PotBreak1, ObjTsubo_PotBreak2, ObjTsubo_PotBreak3 }, + { OBJECT_RACETSUBO, 0.29549998f, object_racetsubo_DL_000278, object_racetsubo_DL_001610, 18, 45, + ObjTsubo_RacePotBreak1, ObjTsubo_RacePotBreak2, ObjTsubo_RacePotBreak3 }, + { OBJECT_TSUBO, 0.197f, object_tsubo_DL_0017C0, object_tsubo_DL_001960, 12, 32, ObjTsubo_PotBreak1, + ObjTsubo_PotBreak2, ObjTsubo_PotBreak3 }, + { GAMEPLAY_DANGEON_KEEP, 0.197f, gameplay_dangeon_keep_DL_017EA0, gameplay_dangeon_keep_DL_018090, 12, 32, + ObjTsubo_PotBreak1, ObjTsubo_PotBreak2, ObjTsubo_PotBreak3 }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 12, 30, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809295DC[] = { - 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), +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_STOP), }; -#endif +s32 func_809275C0(ObjTsubo* this, GlobalContext* globalCtx) { + s32 chestFlag = -1; + s32 skulltulaParams = (OBJ_TSUBO_P001F(&this->actor) << 2) | 0xFF01; -extern ColliderCylinderInit D_809295B0; -extern InitChainEntry D_809295DC[]; + if (ENSW_GETS_3(skulltulaParams)) { + chestFlag = ENSW_GETS_3FC(skulltulaParams); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809275C0.s") + return (chestFlag < 0) == true || !Flags_GetTreasure(globalCtx, chestFlag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092762C.s") +void func_8092762C(ObjTsubo* this, GlobalContext* globalCtx) { + if (!OBJ_TSUBO_P0010(&this->actor) && (OBJ_TSUBO_ZROT(&this->actor) != 2)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, OBJ_TSUBO_P000F(&this->actor) << 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927690.s") +void func_80927690(ObjTsubo* this, GlobalContext* globalCtx) { + s32 itemDrop; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927714.s") + if (!this->unk_197 && (OBJ_TSUBO_ZROT(&this->actor) != 2)) { + itemDrop = func_800A8150(OBJ_TSUBO_P003F(&this->actor)); + if (itemDrop > ITEM00_NO_DROP) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, (OBJ_TSUBO_PFE00(&this->actor) << 8) | itemDrop); + this->unk_197 = true; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092776C.s") +void ObjTsubo_SpawnBoes(ObjTsubo* this, GlobalContext* globalCtx, s32 arg2) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MKK, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927818.s") +void ObjTsubo_SpawnGoldSkulltula(ObjTsubo* this, GlobalContext* globalCtx, s32 arg2) { + Actor* child; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927864.s") + if (func_809275C0(this, globalCtx)) { + params = (OBJ_TSUBO_P001F(&this->actor) << 2) | 0xFF01; + child = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, params); + if (child != NULL) { + child->parent = &this->actor; + child->velocity.y = 0.0f; + child->speedXZ = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092788C.s") +void func_80927818(ObjTsubo* this, GlobalContext* globalCtx, s32 arg2) { + if (OBJ_TSUBO_ZROT(&this->actor) == 1) { + ObjTsubo_SpawnBoes(this, globalCtx, arg2); + } else if (OBJ_TSUBO_ZROT(&this->actor) == 2) { + ObjTsubo_SpawnGoldSkulltula(this, globalCtx, arg2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/ObjTsubo_Init.s") +s32 ObjTsubo_IsSceneNotGohtOrTwinmold(ObjTsubo* this, GlobalContext* globalCtx) { + return (globalCtx->sceneNum != SCENE_HAKUGIN_BS) && (globalCtx->sceneNum != SCENE_INISIE_BS); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/ObjTsubo_Destroy.s") +void func_8092788C(ObjTsubo* this, GlobalContext* globalCtx) { + if (!this->unk_197 && (globalCtx->roomCtx.currRoom.num != this->homeRoom)) { + this->unk_197 = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927A78.s") +void ObjTsubo_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjTsubo* this = (ObjTsubo*)thisx; + s32 pad; + s32 type = OBJ_TSUBO_GET_TYPE(&this->actor); + s32 pad2; + s32 sp2C = OBJ_TSUBO_ZROT(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927D2C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, sPotTypeData[type].scale); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + Collider_InitCylinder(globalCtx, &this->cylinderCollider); + Collider_SetCylinder(globalCtx, &this->cylinderCollider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); + this->cylinderCollider.dim.radius = sPotTypeData[type].radius; + this->cylinderCollider.dim.height = sPotTypeData[type].height; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, sPotTypeData[type].objId); + if (this->objBankIndex < 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.shape.shadowScale = 1.8f; + this->homeRoom = this->actor.room; + if ((type != OBJ_TSUBO_TYPE_3) && (sp2C != 2)) { + if (Item_CanDropBigFairy(globalCtx, OBJ_TSUBO_P003F(&this->actor), OBJ_TSUBO_PFE00(&this->actor))) { + this->unk_198 = true; + } + } + if ((type == OBJ_TSUBO_TYPE_3) || (sp2C != 2) || !func_809275C0(this, globalCtx)) { + this->unk_19A = -1; + } + func_80928914(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927FCC.s") +void ObjTsubo_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = (GlobalContext*)globalCtx2; + ObjTsubo* this = (ObjTsubo*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809282F0.s") + Collider_DestroyCylinder(globalCtx, &this->cylinderCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092860C.s") +void ObjTsubo_PotBreak1(ObjTsubo* this, GlobalContext* globalCtx) { + s16 rot; + s32 i; + s32 phi_s0; + s32 pad; + Vec3f pos; + Vec3f vel; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + f32 randf; + f32 sin; + f32 cos; + f32 scale; + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928904.s") + for (i = 0, rot = 0; i < 18; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 8.0f; + pos.y = Rand_ZeroOne() * 12.0f + 2.0f; + pos.z = cos * 8.0f; + vel.x = pos.x * 0.23f; + vel.y = Rand_ZeroOne() * 5.0f + 2.5f; + vel.z = pos.z * 0.23f; + Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); + randf = Rand_ZeroOne(); + if (randf < 0.2f) { + phi_s0 = 0x60; + } else if (randf < 0.6f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + scale = Rand_ZeroOne() * 110.0f + 15.0f; + EffectSsKakera_Spawn(globalCtx, &pos, &vel, &this->actor.world.pos, -260, phi_s0, 20, 0, 0, scale, 0, 0, 50, -1, + typeData->objId, typeData->shardDL); + } + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 10, 80, true); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928914.s") +void ObjTsubo_RacePotBreak1(ObjTsubo* this, GlobalContext* globalCtx) { + s16 rot; + s32 phi_s0; + s32 i; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + Vec3f pos; + Vec3f vel; + f32 randf; + f32 sin; + f32 cos; + f32 scale; + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928928.s") + for (i = 0, rot = 0; i < 20; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 10.0f; + pos.y = Rand_ZeroOne() * 20.0f + 2.0f; + pos.z = cos * 10.0f; + vel.x = pos.x * 0.3f; + vel.y = Rand_ZeroOne() * 10.0f + 2.0f; + vel.z = pos.z * 0.3f; + Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); + randf = Rand_ZeroOne(); + if (randf < 0.2f) { + phi_s0 = 0xE0; + } else if (randf < 0.6f) { + phi_s0 = 0xC0; + } else { + phi_s0 = 0xA0; + } + scale = Rand_ZeroOne() * 160.0f + 15.0f; + EffectSsKakera_Spawn(globalCtx, &pos, &vel, &this->actor.world.pos, -340, phi_s0, 20, 0, 0, scale, 0, 0, 50, -1, + typeData->objId, typeData->shardDL); + } + func_800BBFB0(globalCtx, &this->actor.world.pos, 50.0f, 2, 40, 50, true); + func_800BBFB0(globalCtx, &this->actor.world.pos, 50.0f, 2, 20, 80, true); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809289B4.s") +void ObjTsubo_PotBreak2(ObjTsubo* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = (GlobalContext*)globalCtx2; + s16 rot; + s32 i; + s32 phi_s0; + Vec3f pos; + Vec3f vel; + Vec3f* worldPos = &this->actor.world.pos; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + f32 sin; + f32 cos; + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809289E4.s") + pos.y = worldPos->y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928D6C.s") + for (rot = 0, i = 0; i < 5; i++, rot += 0x10000 / 5) { + pos.x = Math_SinS((s32)(Rand_ZeroOne() * 6000) + rot) * 15.0f + worldPos->x; + pos.z = Math_CosS((s32)(Rand_ZeroOne() * 6000) + rot) * 15.0f + worldPos->z; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 350); + } + pos.x = worldPos->x; + pos.z = worldPos->z; + EffectSsGRipple_Spawn(globalCtx, &pos, 200, 600, 0); + for (i = 0, rot = 0; i < 13; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 8.0f; + pos.y = (Rand_ZeroOne() * 5.0f) + 2.0f; + pos.z = cos * 8.0f; + vel.x = pos.x * 0.2f; + vel.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + vel.z = pos.z * 0.2f; + Math_Vec3f_Sum(&pos, worldPos, &pos); + if (Rand_ZeroOne() < .2f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + scale = Rand_ZeroOne() * 105.0f + 10.0f; + EffectSsKakera_Spawn(globalCtx, &pos, &vel, worldPos, -170, phi_s0, 50, 5, 0, scale, 0, 0, 70, -1, + typeData->objId, typeData->shardDL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928D80.s") +void ObjTsubo_RacePotBreak2(ObjTsubo* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = (GlobalContext*)globalCtx2; + s32 pad; + s16 rot; + s32 i; + Vec3f pos; + Vec3f vel; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + Vec3f* worldPos = &this->actor.world.pos; + f32 sin; + f32 cos; + s32 phi_s0; + s16 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928E74.s") + pos.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928F18.s") + for (rot = 0, i = 0; i < 5; i++, rot += 0x10000 / 5) { + pos.x = Math_SinS((s32)(Rand_ZeroOne() * 6000) + rot) * 30.0f + worldPos->x; + pos.z = Math_CosS((s32)(Rand_ZeroOne() * 6000) + rot) * 30.0f + worldPos->z; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 0, 350); + } + pos.x = worldPos->x; + pos.z = worldPos->z; + EffectSsGRipple_Spawn(globalCtx, &pos, 300, 700, 0); + for (i = 0, rot = 0; i < 15; rot += 0x4E20, i++) { + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * 10.0f; + pos.y = (Rand_ZeroOne() * 15.0f) + 2.0f; + pos.z = cos * 10.0f; + vel.x = pos.x * 0.3f; + vel.y = (Rand_ZeroOne() * 4.0f) + 2.0f; + vel.z = pos.z * 0.3f; + Math_Vec3f_Sum(&pos, worldPos, &pos); + if (Rand_ZeroOne() < 0.2f) { + phi_s0 = 0xC0; + } else { + phi_s0 = 0xA0; + } + scale = (Rand_ZeroOne() * 150.0f) + 10.0f; + EffectSsKakera_Spawn(globalCtx, &pos, &vel, worldPos, -170, phi_s0, 50, 5, 0, scale, 0, 0, 70, -1, + typeData->objId, typeData->shardDL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809291DC.s") +void ObjTsubo_PotBreak3(ObjTsubo* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = (GlobalContext*)globalCtx2; + s32 i; + s16 rot; + s32 phi_s0; + Vec3f pos; + Vec3f vel; + ObjTsuboData* typeData = &sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)]; + f32 randf; + f32 temp_f20; + f32 cos; + f32 sin; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_8092926C.s") + for (i = 0, rot = 0; i < 13; i++, rot += 0x4E20) { + randf = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(randf)) * 4.8f + 3.2f; + if (this) {} + sin = Math_SinS(rot); + cos = Math_CosS(rot); + pos.x = sin * temp_f20; + pos.y = (Rand_ZeroOne() * 15.0f) + 2.0f; + pos.z = cos * temp_f20; + vel.x = pos.x * 0.4f; + vel.y = (Rand_ZeroOne() * 4.0f) + 4.0f; + vel.z = pos.z * 0.4f; + Math_Vec3f_Sum(&pos, &this->actor.world.pos, &pos); + if (Rand_ZeroOne() < 0.2f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &pos, &vel, &this->actor.world.pos, -170, phi_s0, 50, 3, 0, + (Rand_ZeroOne() * 105.0f) + 10.0f, 0, 0, 70, -1, typeData->objId, typeData->shardDL); + } + for (i = 0; i < 7; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 20.0f, 30.0f, 40.0f, (Rand_ZeroOne() * 0.06f) + 0.09f); + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 10.0f, 10.0f, 10.0f, (Rand_ZeroOne() * 0.08f) + 0.09f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/ObjTsubo_Update.s") +void ObjTsubo_RacePotBreak3(ObjTsubo* this, GlobalContext* globalCtx2) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809294B0.s") +void func_80928914(ObjTsubo* this) { + this->actionFunc = func_80928928; +} + +void func_80928928(ObjTsubo* this, GlobalContext* globalCtx) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) { + this->actor.objBankIndex = this->objBankIndex; + func_809289B4(this); + } +} + +void func_809289B4(ObjTsubo* this) { + this->actor.draw = ObjTsubo_Draw; + this->actor.flags |= ACTOR_FLAG_10; + this->unk_195 = false; + this->actionFunc = func_809289E4; +} + +void func_809289E4(ObjTsubo* this, GlobalContext* globalCtx) { + ObjTsuboData* typeData; + s32 pad; + s32 type = OBJ_TSUBO_GET_TYPE(&this->actor); + s32 pad2; + s32 acHit = (this->cylinderCollider.base.acFlags & AC_HIT) != 0; + + if (acHit) { + this->cylinderCollider.base.acFlags &= ~AC_HIT; + } + if (this->cylinderCollider.base.ocFlags1 & OC1_HIT) { + this->cylinderCollider.base.ocFlags1 &= ~OC1_HIT; + } + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; + if ((type != OBJ_TSUBO_TYPE_3) && func_800A817C(OBJ_TSUBO_P003F(&this->actor))) { + func_80927690(this, globalCtx); + } + func_80927818(this, globalCtx, 0); + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the collider + func_800B8E58((Player*)&this->actor, NA_SE_PL_PULL_UP_POT); + func_80928D6C(this); + } else if ((this->unk_19B != 0) || + (acHit && (this->cylinderCollider.info.acHitInfo->toucher.dmgFlags & 0x058BFFBC))) { + typeData = &sPotTypeData[type]; + this->unk_19B = 0; + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f)) { + typeData->breakPot3(this, globalCtx); + } else { + typeData->breakPot1(this, globalCtx); + } + if (type == OBJ_TSUBO_TYPE_3) { + func_8092762C(this, globalCtx); + } else { + func_80927690(this, globalCtx); + } + func_80927818(this, globalCtx, 1); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + if (ObjTsubo_IsSceneNotGohtOrTwinmold(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + } else { + func_809291DC(this); + } + } else { + if (!this->unk_195) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if ((this->actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL)) { + this->unk_195 = true; + this->actor.flags &= ~ACTOR_FLAG_10; + } + } + if ((this->actor.xzDistToPlayer < 800.0f) || (gSaveContext.save.entranceIndex == 0xD010)) { + Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->cylinderCollider.base); + if (this->actor.xzDistToPlayer < 150.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cylinderCollider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + s16 yawDiff = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); + + if (absYawDiff > DEGF_TO_BINANG(120.0f)) { + Actor_PickUp(&this->actor, globalCtx, 0, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80928D6C(ObjTsubo* this) { + this->actionFunc = func_80928D80; +} + +void func_80928D80(ObjTsubo* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + s32 bgId; + + func_8092788C(this, globalCtx); + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + Actor_MoveWithGravity(&this->actor); + this->actor.flags &= ~ACTOR_FLAG_4000000; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); + func_80928E74(this); + } else { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 20.0f; + pos.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); + } +} + +void func_80928E74(ObjTsubo* this) { + this->unk_194 = 80; + this->actor.colChkInfo.mass = 180; + D_80929500 = (Rand_ZeroOne() - 0.78f) * 4500.0f; + D_80929508 = (Rand_ZeroOne() - 0.5f) * 2000.0f; + D_80929504 = 0; + D_8092950C = 0; + this->actionFunc = func_80928F18; +} + +void func_80928F18(ObjTsubo* this, GlobalContext* globalCtx) { + s32 pad; + ObjTsuboData* typeData; + s32 type = OBJ_TSUBO_GET_TYPE(&this->actor); + s32 pad2; + s32 atHit = (this->cylinderCollider.base.atFlags & AT_HIT) != 0; + + if (atHit) { + this->cylinderCollider.base.atFlags &= ~AT_HIT; + } + func_8092788C(this, globalCtx); + + if (this->unk_194 > 0) { + this->unk_194--; + } + typeData = &sPotTypeData[type]; + if ((this->actor.bgCheckFlags & 0xB) || atHit || (this->unk_194 <= 0)) { + typeData->breakPot1(this, globalCtx); + if (type == OBJ_TSUBO_TYPE_3) { + func_8092762C(this, globalCtx); + } else { + func_80927690(this, globalCtx); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + if (ObjTsubo_IsSceneNotGohtOrTwinmold(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + } else { + func_809291DC(this); + } + } else if (this->actor.bgCheckFlags & 0x40) { + typeData->breakPot2(this, globalCtx); + if (type == OBJ_TSUBO_TYPE_3) { + func_8092762C(this, globalCtx); + } else { + func_80927690(this, globalCtx); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_POT_BROKEN); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + if (ObjTsubo_IsSceneNotGohtOrTwinmold(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + } else { + func_809291DC(this); + } + } else { + Actor_MoveWithGravity(&this->actor); + Math_StepToS(&D_80929504, D_80929500, 150); + Math_StepToS(&D_8092950C, D_80929508, 150); + this->actor.shape.rot.x += D_80929504; + this->actor.shape.rot.y += D_8092950C; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->cylinderCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->cylinderCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->cylinderCollider.base); + } +} + +void func_809291DC(ObjTsubo* this) { + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + this->unk_197 = false; + this->actor.shape.rot.x = this->actor.home.rot.x; + this->actor.world.rot.x = this->actor.home.rot.x; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.home.rot.y; + this->actor.world.rot.y = this->actor.home.rot.y; + Actor_SetScale(&this->actor, 0.0f); + this->unk_194 = 127; + this->actionFunc = func_8092926C; +} + +void func_8092926C(ObjTsubo* this, GlobalContext* globalCtx) { + f32 scale; + + if (this->unk_194 > 0) { + this->unk_194--; + if (this->unk_194 == 0) { + this->actor.draw = ObjTsubo_Draw; + } + } else { + scale = sPotTypeData[OBJ_TSUBO_GET_TYPE(&this->actor)].scale; + if (Math_StepToF(&this->actor.scale.x, scale, scale * 0.1f)) { + this->actor.flags |= ACTOR_FLAG_4000000; + func_809289B4(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + } +} + +void ObjTsubo_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjTsubo* this = (ObjTsubo*)thisx; + + this->actionFunc(this, globalCtx); + if (this->actor.draw == NULL) { + this->actor.shape.shadowDraw = NULL; + } else if (this->actor.projectedPos.z < 811.0f) { + if (this->actor.projectedPos.z > 300.0f) { + this->actor.shape.shadowAlpha = (811 - (s32)this->actor.projectedPos.z) >> 1; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -10.0f) { + this->actor.shape.shadowAlpha = 255; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } + if (!this->unk_197) { + if (this->unk_198) { + globalCtx->actorCtx.unk5 |= 8; + this->actor.flags |= ACTOR_FLAG_10; + } + if (this->unk_19A >= 0) { + if (this->unk_19A == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk_19A = Rand_S16Offset(40, 80); + } else { + this->unk_19A = 8; + } + } else { + this->unk_19A--; + } + } + } +} + +void ObjTsubo_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = (GlobalContext*)globalCtx2; + + Gfx_DrawDListOpa(globalCtx, sPotTypeData[OBJ_TSUBO_GET_TYPE(thisx)].modelDL); +} diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h index d3a188e41..01d4bb82f 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h @@ -7,12 +7,37 @@ struct ObjTsubo; typedef void (*ObjTsuboActionFunc)(struct ObjTsubo*, GlobalContext*); +typedef void (*ObjTsuboUnkFunc)(struct ObjTsubo*, GlobalContext*); + +#define OBJ_TSUBO_P000F(thisx) ((thisx)->params & 0x0F) +#define OBJ_TSUBO_P001F(thisx) ((thisx)->params & 0x1F) +#define OBJ_TSUBO_P003F(thisx) ((thisx)->params & 0x3F) +#define OBJ_TSUBO_P0010(thisx) (((thisx)->params >> 4) & 1) +#define OBJ_TSUBO_GET_TYPE(thisx) (((thisx)->params >> 7) & 3) +#define OBJ_TSUBO_PFE00(thisx) (((thisx)->params >> 9) & 0x7F) //item collectable flag? +#define OBJ_TSUBO_ZROT(thisx) ((thisx)->home.rot.z) + typedef struct ObjTsubo { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjTsuboActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x54]; + /* 0x0148 */ ColliderCylinder cylinderCollider; + /* 0x0194 */ s8 unk_194; + /* 0x0195 */ s8 unk_195; + /* 0x0196 */ s8 homeRoom; + /* 0x0197 */ s8 unk_197; + /* 0x0198 */ s8 unk_198; + /* 0x0199 */ s8 objBankIndex; + /* 0x019A */ s8 unk_19A; + /* 0x019B */ u8 unk_19B; } ObjTsubo; // size = 0x19C extern const ActorInit Obj_Tsubo_InitVars; +typedef enum { + /* 0 */ OBJ_TSUBO_TYPE_0, + /* 1 */ OBJ_TSUBO_TYPE_1, + /* 2 */ OBJ_TSUBO_TYPE_2, + /* 3 */ OBJ_TSUBO_TYPE_3 +} ObjTsuboType; + #endif // Z_OBJ_TSUBO_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 997a062fe..ce9fdca47 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -510,7 +510,7 @@ 0x800A7D28:("Item_DropCollectibleRandom",), 0x800A8150:("func_800A8150",), 0x800A817C:("func_800A817C",), - 0x800A81A4:("func_800A81A4",), + 0x800A81A4:("Item_CanDropBigFairy",), 0x800A81F0:("EffectBlure_AddVertex",), 0x800A8514:("EffectBlure_AddSpace",), 0x800A8558:("EffectBlure_InitElements",), @@ -7047,19 +7047,19 @@ 0x809275C0:("func_809275C0",), 0x8092762C:("func_8092762C",), 0x80927690:("func_80927690",), - 0x80927714:("func_80927714",), - 0x8092776C:("func_8092776C",), + 0x80927714:("ObjTsubo_SpawnEnMkk",), + 0x8092776C:("ObjTsubo_SpawnEnSw",), 0x80927818:("func_80927818",), 0x80927864:("func_80927864",), 0x8092788C:("func_8092788C",), 0x809278C0:("ObjTsubo_Init",), 0x80927A4C:("ObjTsubo_Destroy",), - 0x80927A78:("func_80927A78",), - 0x80927D2C:("func_80927D2C",), - 0x80927FCC:("func_80927FCC",), - 0x809282F0:("func_809282F0",), - 0x8092860C:("func_8092860C",), - 0x80928904:("func_80928904",), + 0x80927A78:("func_PotBreak1",), + 0x80927D2C:("func_RacePotBreak1",), + 0x80927FCC:("func_PotBreak2",), + 0x809282F0:("func_RacePotBreak2",), + 0x8092860C:("func_PotBreak3",), + 0x80928904:("func_RacePotBreak3",), 0x80928914:("func_80928914",), 0x80928928:("func_80928928",), 0x809289B4:("func_809289B4",), @@ -7071,7 +7071,7 @@ 0x809291DC:("func_809291DC",), 0x8092926C:("func_8092926C",), 0x8092932C:("ObjTsubo_Update",), - 0x809294B0:("func_809294B0",), + 0x809294B0:("ObjTsubo_Draw",), 0x80929910:("EnIk_Init",), 0x80929A98:("EnIk_Destroy",), 0x80929AF8:("func_80929AF8",), From 53fc438d819281e2f6011dd2ca5497804e9fcea8 Mon Sep 17 00:00:00 2001 From: TrulyNaN <52424023+TrulyNaN@users.noreply.github.com> Date: Mon, 20 Jun 2022 15:57:09 -0400 Subject: [PATCH 52/53] Merge z_bg_kin2 bombwall (#840) * 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 * 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. * 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. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Co-authored-by: EllipticEllipsis * Fixed BgKin2Bombwall_SpawnEffects after the Rand_Next() type update. * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Rand_Next() update. Co-authored-by: EllipticEllipsis * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Rand_Next() update. Co-authored-by: EllipticEllipsis * Adding Co-authors Co-authored-by EllipticEllipsis 73679967+EllipticEllipsis@users.noreply.github.com Co-authored-by Derek-Hensley hensley.derek58@gmail.com Co-authored-by Maide eeeedddccc@hotmail.co.uk Co-authored-by Tom-Overton tom.overton@outlook.com Co-authored-by Fig02 fig02srl@gmail.com Co-authored-by Parker-Burnett burnettparker@gmail.com Co-authored-by isghj5 isghj5@gmail.com * Adding Co-authors Co-authored-by EllipticEllipsis 73679967+EllipticEllipsis@users.noreply.github.com Co-authored-by Derek-Hensley hensley.derek58@gmail.com Co-authored-by Maide eeeedddccc@hotmail.co.uk Co-authored-by Tom-Overton tom.overton@outlook.com Co-authored-by Fig02 fig02srl@gmail.com Co-authored-by Parker-Burnett burnettparker@gmail.com Co-authored-by isghj5 isghj5@gmail.com * Adding Co-authors Co-authored-by EllipticEllipsis 73679967+EllipticEllipsis@users.noreply.github.com Co-authored-by Derek-Hensley hensley.derek58@gmail.com Co-authored-by Maide eeeedddccc@hotmail.co.uk Co-authored-by Tom-Overton tom.overton@outlook.com Co-authored-by Fig02 fig02srl@gmail.com Co-authored-by Parker-Burnett burnettparker@gmail.com Co-authored-by isghj5 isghj5@gmail.com * Adding Co-authors Co-authored-by EllipticEllipsis 73679967+EllipticEllipsis@users.noreply.github.com Co-authored-by Derek-Hensley hensley.derek58@gmail.com Co-authored-by Maide eeeedddccc@hotmail.co.uk Co-authored-by Tom-Overton tom.overton@outlook.com Co-authored-by Fig02 fig02srl@gmail.com Co-authored-by Parker-Burnett burnettparker@gmail.com Co-authored-by isghj5 isghj5@gmail.com * Adding Co-authors Co-authored-by EllipticEllipsis 73679967+EllipticEllipsis@users.noreply.github.com Co-authored-by Derek-Hensley hensley.derek58@gmail.com Co-authored-by Maide eeeedddccc@hotmail.co.uk Co-authored-by Tom-Overton tom.overton@outlook.com Co-authored-by Fig02 fig02srl@gmail.com Co-authored-by Parker-Burnett burnettparker@gmail.com Co-authored-by isghj5 isghj5@gmail.com * Adding Co-authors Co-authored-by: EllipticEllipsis 73679967+EllipticEllipsis@users.noreply.github.com Co-authored-by: Derek-Hensley hensley.derek58@gmail.com Co-authored-by: Maide eeeedddccc@hotmail.co.uk Co-authored-by: Tom-Overton tom.overton@outlook.com Co-authored-by: Fig02 fig02srl@gmail.com Co-authored-by: Parker-Burnett burnettparker@gmail.com Co-authored-by: isghj5 isghj5@gmail.com * Adding Co-authors Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Derek-Hensley Co-authored-by: Maide Co-authored-by: Tom-Overton Co-authored-by: Fig02 Co-authored-by: Parker-Burnett Co-authored-by: isghj5 * Update src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c Co-authored-by: EllipticEllipsis 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: Maide Co-authored-by: Tom-Overton Co-authored-by: Fig02 Co-authored-by: Parker-Burnett Co-authored-by: isghj5 --- assets/xml/objects/object_kin2_obj.xml | 40 ++-- spec | 3 +- .../ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c | 201 +++++++++++++++--- .../ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h | 12 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 2 +- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c | 4 +- tools/disasm/functions.txt | 16 +- 7 files changed, 212 insertions(+), 66 deletions(-) diff --git a/assets/xml/objects/object_kin2_obj.xml b/assets/xml/objects/object_kin2_obj.xml index 93e55786c..e0ae09106 100644 --- a/assets/xml/objects/object_kin2_obj.xml +++ b/assets/xml/objects/object_kin2_obj.xml @@ -1,34 +1,34 @@  - - - - + + + + - + - - + + - - + + - + - - - - - - - - - - + + + + + + + + + + diff --git a/spec b/spec index a7e9ba36c..102e2f923 100644 --- a/spec +++ b/spec @@ -4059,8 +4059,7 @@ beginseg name "ovl_Bg_Kin2_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.o" - include "build/data/ovl_Bg_Kin2_Bombwall/ovl_Bg_Kin2_Bombwall.data.o" - include "build/data/ovl_Bg_Kin2_Bombwall/ovl_Bg_Kin2_Bombwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Bombwall/ovl_Bg_Kin2_Bombwall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c index 5630bdd8f..510b76fe8 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c @@ -3,8 +3,8 @@ * Overlay: ovl_Bg_Kin2_Bombwall * Description: Ocean Spider House - Bombable Wall */ - #include "z_bg_kin2_bombwall.h" +#include "objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_10000000) @@ -15,8 +15,14 @@ void BgKin2Bombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKin2Bombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgKin2Bombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -const ActorInit Bg_Kin2_Bombwall_InitVars = { +void BgKin2Bombwall_SetupWait(BgKin2Bombwall* this); +void BgKin2Bombwall_Wait(BgKin2Bombwall* this, GlobalContext* globalCtx); +void BgKin2Bombwall_SetupPlayCutscene(BgKin2Bombwall* this); +void BgKin2Bombwall_PlayCutscene(BgKin2Bombwall* this, GlobalContext* globalCtx); +void BgKin2Bombwall_SetupEndCutscene(BgKin2Bombwall* this); +void BgKin2Bombwall_EndCutscene(BgKin2Bombwall* this, GlobalContext* globalCtx); + +ActorInit Bg_Kin2_Bombwall_InitVars = { ACTOR_BG_KIN2_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -28,50 +34,191 @@ const ActorInit Bg_Kin2_Bombwall_InitVars = { (ActorFunc)BgKin2Bombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B6E6F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 60, 60, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B6E748[] = { +s32 BgKin2Bombwall_IsHitFromNearby(BgKin2Bombwall* this, GlobalContext* globalCtx) { + Actor* bombwallCollider; + + if (this->collider.base.acFlags & AC_HIT) { + bombwallCollider = this->collider.base.ac; + // Distance check required to only react to sufficiently close explosions. + if ((bombwallCollider != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &bombwallCollider->world.pos) < 6400.0f)) { + return true; + } + } + return false; +} + +static Color_RGBA8 sPrimColor = { 210, 210, 210, 255 }; +static Color_RGBA8 sEnvColor = { 140, 140, 140, 255 }; +static Vec3f sDustAccel = { 0.0f, 0.33f, 0.0f }; +static s8 sRandomYOffsets[] = { -60, -34, -8, 18, 44 }; +static s16 sScales[] = { 25, 23, 21, 19, 17, 15, 13, 10 }; // Scales for random explosion debris. + +void BgKin2Bombwall_SpawnEffects(BgKin2Bombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f spD8; + Vec3f spCC; + s32 j; + s32 k; + f32 temp_a0; + s32 pad; + s16 phi_s0; + s16 phi_s1; + + Matrix_RotateYS(this->dyna.actor.shape.rot.y, 0); + + for (i = 0, k = 0; i < 6; i++) { + temp_a0 = (i + 1) * 15.f; + for (j = 0; j < ARRAY_COUNT(sRandomYOffsets); j++) { + k++; + k &= 7; + + spD8.x = sRandomYOffsets[j] + (s32)(Rand_Next() >> 0x1C); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp_a0; + spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spCC.x = (2.0f * (Rand_ZeroOne() - 0.5f)) + (spD8.x * (6.0f / 325.0f)); + spCC.y = (Rand_ZeroOne() * 7.0f) + 4.0f; + spCC.z = spD8.z * 0.3f; + + Matrix_MultVec3f(&spD8, &pos); + Matrix_MultVec3f(&spCC, &velocity); + + pos.x += this->dyna.actor.world.pos.x; + pos.y += this->dyna.actor.world.pos.y; + pos.z += this->dyna.actor.world.pos.z; + + if (Rand_Next() % 4 == 0) { + phi_s0 = 0x20; + } else { + phi_s0 = 0x40; + } + + if (k < 2 || (s32)Rand_Next() > 0) { + phi_s0 |= 1; + phi_s1 = 1; + func_800B0E48(globalCtx, &pos, &gZeroVec3f, &sDustAccel, &sPrimColor, &sEnvColor, + (Rand_Next() >> 0x1B) + 70, + (Rand_Next() >> 0x1A) + 60); // for dust spawn + } else { + phi_s1 = 0; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -550, phi_s0, 30, 0, 0, sScales[k], phi_s1, 0, 50, + -1, OBJECT_KIN2_OBJ, gOceanSpiderHouseBombableWallDebrisDL); + } + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -#endif +void BgKin2Bombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Bombwall* this = THIS; + ColliderCylinder* bombwallCollider; -extern ColliderCylinderInit D_80B6E6F0; -extern InitChainEntry D_80B6E748[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + bombwallCollider = &this->collider; + Collider_InitCylinder(globalCtx, bombwallCollider); + if (Flags_GetSwitch(globalCtx, BG_KIN2_BOMBWALL_SWITCH_FLAG(this))) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gOceanSpiderHouseBombableWallCol); + Collider_SetCylinder(globalCtx, bombwallCollider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, bombwallCollider); + Actor_SetFocus(&this->dyna.actor, 60.0f); + BgKin2Bombwall_SetupWait(this); + } +} -extern UNK_TYPE D_06000128; -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06000490; +void BgKin2Bombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E020.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E090.s") +void BgKin2Bombwall_SetupWait(BgKin2Bombwall* this) { + this->actionFunc = BgKin2Bombwall_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Init.s") +void BgKin2Bombwall_Wait(BgKin2Bombwall* this, GlobalContext* globalCtx) { + if (BgKin2Bombwall_IsHitFromNearby(this, globalCtx)) { + this->collider.base.acFlags &= ~AC_HIT; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + BgKin2Bombwall_SetupPlayCutscene(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Destroy.s") +void BgKin2Bombwall_SetupPlayCutscene(BgKin2Bombwall* this) { + this->actionFunc = BgKin2Bombwall_PlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E4B8.s") +void BgKin2Bombwall_PlayCutscene(BgKin2Bombwall* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + Flags_SetSwitch(globalCtx, BG_KIN2_BOMBWALL_SWITCH_FLAG(this)); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + BgKin2Bombwall_SpawnEffects(this, globalCtx); + BgKin2Bombwall_SetupEndCutscene(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E4CC.s") + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E544.s") +void BgKin2Bombwall_SetupEndCutscene(BgKin2Bombwall* this) { + this->timer = 40; + this->actionFunc = BgKin2Bombwall_EndCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E558.s") +void BgKin2Bombwall_EndCutscene(BgKin2Bombwall* this, GlobalContext* globalCtx) { + this->timer--; + if (this->timer <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E5F8.s") +void BgKin2Bombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E614.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Update.s") +void BgKin2Bombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Draw.s") + Gfx_DrawDListOpa(globalCtx, gOceanSpiderHouseBombableWallDL); + Gfx_DrawDListXlu(globalCtx, gOceanSpiderHouseBombableWallCrackDL); +} diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h index 25ebd0362..c4d76c860 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.h @@ -1,6 +1,8 @@ #ifndef Z_BG_KIN2_BOMBWALL_H #define Z_BG_KIN2_BOMBWALL_H +#define BG_KIN2_BOMBWALL_SWITCH_FLAG(thisx) (thisx->dyna.actor.params & 0x7F) + #include "global.h" struct BgKin2Bombwall; @@ -8,12 +10,10 @@ struct BgKin2Bombwall; typedef void (*BgKin2BombwallActionFunc)(struct BgKin2Bombwall*, GlobalContext*); typedef struct BgKin2Bombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgKin2BombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgKin2BombwallActionFunc actionFunc; + /* 0x1AC */ s8 timer; } BgKin2Bombwall; // size = 0x1B0 -extern const ActorInit Bg_Kin2_Bombwall_InitVars; - #endif // Z_BG_KIN2_BOMBWALL_H 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 37d176f5a..ae1563122 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 @@ -270,5 +270,5 @@ void BgKin2Fence_Update(Actor* thisx, GlobalContext* globalCtx) { } void BgKin2Fence_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, object_kin2_obj_DL_000828); + Gfx_DrawDListOpa(globalCtx, gOceanSpiderHouseFireplaceGrateDL); } diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index 499fb034a..72828611b 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -51,9 +51,9 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -CollisionHeader* D_80B70780[] = { &object_kin2_obj_Colheader_001328, &object_kin2_obj_Colheader_000F80 }; +CollisionHeader* D_80B70780[] = { &gOceanSpiderHouseChestOfDrawersCol, &gOceanSpiderHouseBookshelfCol }; -Gfx* D_80B70788[] = { object_kin2_obj_DL_0010F8, object_kin2_obj_DL_000CA8 }; +Gfx* D_80B70788[] = { gOceanSpiderHouseChestOfDrawersDL, gOceanSpiderHouseBookshelfDL }; s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { s32 temp_v1 = BGKIN2SHELF_GET_1(&this->dyna.actor); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ce9fdca47..7b3b9a12d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14294,16 +14294,16 @@ 0x80B6DEA8:("func_80B6DEA8",), 0x80B6DEB8:("BgHakaCurtain_Update",), 0x80B6DF44:("BgHakaCurtain_Draw",), - 0x80B6E020:("func_80B6E020",), - 0x80B6E090:("func_80B6E090",), + 0x80B6E020:("BgKin2Bombwall_IsHitFromNearby",), + 0x80B6E090:("BgKin2Bombwall_SpawnEffects",), 0x80B6E3AC:("BgKin2Bombwall_Init",), 0x80B6E470:("BgKin2Bombwall_Destroy",), - 0x80B6E4B8:("func_80B6E4B8",), - 0x80B6E4CC:("func_80B6E4CC",), - 0x80B6E544:("func_80B6E544",), - 0x80B6E558:("func_80B6E558",), - 0x80B6E5F8:("func_80B6E5F8",), - 0x80B6E614:("func_80B6E614",), + 0x80B6E4B8:("BgKin2Bombwall_SetupWait",), + 0x80B6E4CC:("BgKin2Bombwall_Wait",), + 0x80B6E544:("BgKin2Bombwall_SetupPlayCutscene",), + 0x80B6E558:("BgKin2Bombwall_PlayCutscene",), + 0x80B6E5F8:("BgKin2Bombwall_SetupEndCutscene",), + 0x80B6E614:("BgKin2Bombwall_EndCutscene",), 0x80B6E664:("BgKin2Bombwall_Update",), 0x80B6E688:("BgKin2Bombwall_Draw",), 0x80B6E820:("BgKin2Fence_CheckHitMask",), From f77c4770f7ae50b522d9183b79abe60070f6895b Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 20 Jun 2022 17:35:37 -0300 Subject: [PATCH 53/53] ovl_Obj_Y2lift decompiled (#856) * ovl_Obj_Y2lift decompiled * format * pr review fixes * clean up Co-authored-by: SonicDcer --- assets/xml/objects/object_kaizoku_obj.xml | 4 +- spec | 3 +- .../actors/ovl_Obj_Y2lift/z_obj_y2lift.c | 65 +++++++++++++++---- .../actors/ovl_Obj_Y2lift/z_obj_y2lift.h | 7 +- undefined_syms.txt | 5 -- 5 files changed, 62 insertions(+), 22 deletions(-) diff --git a/assets/xml/objects/object_kaizoku_obj.xml b/assets/xml/objects/object_kaizoku_obj.xml index 8dd96770a..6a7457e1c 100644 --- a/assets/xml/objects/object_kaizoku_obj.xml +++ b/assets/xml/objects/object_kaizoku_obj.xml @@ -2,8 +2,8 @@ - - + + diff --git a/spec b/spec index 102e2f923..fb2204cc1 100644 --- a/spec +++ b/spec @@ -4261,8 +4261,7 @@ beginseg name "ovl_Obj_Y2lift" compress include "build/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.o" - include "build/data/ovl_Obj_Y2lift/ovl_Obj_Y2lift.data.o" - include "build/data/ovl_Obj_Y2lift/ovl_Obj_Y2lift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Y2lift/ovl_Obj_Y2lift_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 7e9f6cb29..14bad806c 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -5,6 +5,7 @@ */ #include "z_obj_y2lift.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,6 @@ void ObjY2lift_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjY2lift_Update(Actor* thisx, GlobalContext* globalCtx); void ObjY2lift_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Y2lift_InitVars = { ACTOR_OBJ_Y2LIFT, ACTORCAT_BG, @@ -28,25 +28,68 @@ const ActorInit Obj_Y2lift_InitVars = { (ActorFunc)ObjY2lift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9A940[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjY2lift_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjY2lift* this = THIS; -extern InitChainEntry D_80B9A940[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gPirateLiftPlatformCol); +} -extern UNK_TYPE D_06001680; -extern UNK_TYPE D_060019B0; +void ObjY2lift_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjY2lift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Init.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Destroy.s") +void ObjY2lift_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjY2lift* this = THIS; + f32 temp_fv0 = this->dyna.actor.world.pos.y; + f32 targetVelocityY = 0.0f; + s32 temp_v0 = DynaPolyActor_IsInRidingMovingState(&this->dyna); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Update.s") + if (temp_v0 || DynaPolyActor_IsInRidingFallingState(&this->dyna)) { + if (!this->unk15D) { + this->unk15D = true; + this->unk15F = 12; + } else if (this->unk15F == 0 && temp_v0) { + this->unk15C = 16; + } + } else { + this->unk15D = false; + } + if (DECR(this->unk15C) != 0) { + temp_fv0 = this->dyna.actor.home.pos.y + 180.0f; + targetVelocityY = 2.0f; + } else if (!temp_v0 && this->dyna.actor.velocity.y <= 0.0f) { + temp_fv0 = this->dyna.actor.home.pos.y; + targetVelocityY = -2.0f; + } + Math_StepToF(&this->dyna.actor.velocity.y, targetVelocityY, 0.1f); + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + if (((this->dyna.actor.world.pos.y - temp_fv0) * targetVelocityY) >= 0.0f) { + this->dyna.actor.world.pos.y = temp_fv0; + this->dyna.actor.velocity.y = 0.0f; + if (!this->unk15E) { + this->unk15E = true; + this->unk15F = 12; + } + } else { + this->unk15E = false; + func_800B9010(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + } + if (DECR(this->unk15F) != 0) { + this->dyna.actor.shape.yOffset = (2.0f * (this->unk15F & 1)) * this->unk15F; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2lift/ObjY2lift_Draw.s") +void ObjY2lift_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gPirateLiftPlatformDL); +} diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h index 27bd6d968..a26d305ae 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h @@ -6,8 +6,11 @@ struct ObjY2lift; typedef struct ObjY2lift { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk15C; + /* 0x15D */ u8 unk15D; + /* 0x15E */ u8 unk15E; + /* 0x15F */ u8 unk15F; } ObjY2lift; // size = 0x160 extern const ActorInit Obj_Y2lift_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index f2f9c6af1..ebbdb298d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1591,11 +1591,6 @@ D_06000098 = 0x06000098; D_06000838 = 0x06000838; D_060022AC = 0x060022AC; -// ovl_Obj_Y2lift - -D_06001680 = 0x06001680; -D_060019B0 = 0x060019B0; - // ovl_player_actor D_06008860 = 0x06008860;