From 8ba8780bb55d8e9eb4ce216612cf3347f8e303cd Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Wed, 25 May 2022 16:59:36 -0700 Subject: [PATCH 01/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] `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/16] 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/16] `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/16] 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/16] `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