From 1921997a60dcef250d228322585198ac609a8a22 Mon Sep 17 00:00:00 2001 From: Elliptic Ellipsis Date: Sat, 25 Sep 2021 15:03:48 +0100 Subject: [PATCH 001/130] Add Tharo's documentation comments --- src/libultra/voice/voicecheckword.c | 1 + src/libultra/voice/voicecleardictionary.c | 1 + src/libultra/voice/voicecontrolgain.c | 1 + src/libultra/voice/voicegetreaddata.c | 1 + src/libultra/voice/voiceinit.c | 1 + src/libultra/voice/voicemaskdictionary.c | 1 + src/libultra/voice/voicesetword.c | 1 + src/libultra/voice/voicestartreaddata.c | 1 + src/libultra/voice/voicestopread.c | 1 + 9 files changed, 9 insertions(+) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 8b5ac0dfb..4da8d5a00 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -1,3 +1,4 @@ #include "global.h" +// Checks whether or not a word can be registered in the dictionary #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckword/osVoiceCheckWord.s") diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 29766bb2a..d6278d3fa 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -1,3 +1,4 @@ #include "global.h" +// Initializes Voice Recognition System word registration dictionary #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecleardictionary/osVoiceClearDictionary.s") diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index 9dc541cc5..d4020e605 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -1,3 +1,4 @@ #include "global.h" +// Adjusts the input gain of the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontrolgain/osVoiceControlGain.s") diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 5940a1f8b..c0987c151 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -1,3 +1,4 @@ #include "global.h" +// Gets voice recognition result from the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicegetreaddata/osVoiceGetReadData.s") diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 920bc4818..69fd1e36e 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -1,3 +1,4 @@ #include "global.h" +// Initializes Voice Recognition System control structure and hardware #pragma GLOBAL_ASM("asm/non_matchings/boot/voiceinit/osVoiceInit.s") diff --git a/src/libultra/voice/voicemaskdictionary.c b/src/libultra/voice/voicemaskdictionary.c index 3de841de3..e82a27b81 100644 --- a/src/libultra/voice/voicemaskdictionary.c +++ b/src/libultra/voice/voicemaskdictionary.c @@ -1,3 +1,4 @@ #include "global.h" +// Mask words registered in the voice recognition system #pragma GLOBAL_ASM("asm/non_matchings/boot/voicemaskdictionary/osVoiceMaskDictionary.s") diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index e50f26874..dbc1a6df6 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -1,3 +1,4 @@ #include "global.h" +// Registers words to the Voice Recognition System dictionary #pragma GLOBAL_ASM("asm/non_matchings/boot/voicesetword/osVoiceSetWord.s") diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index e7105a7d4..118cc3f60 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -1,3 +1,4 @@ #include "global.h" +// Start voice recognition by the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicestartreaddata/osVoiceStartReadData.s") diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index f032fc40e..16ecddef8 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -1,3 +1,4 @@ #include "global.h" +// Forcibly stops voice recognition processing by the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicestopread/osVoiceStopReadData.s") From 831fa5485a95cdb71981efbb075029e753b8882f Mon Sep 17 00:00:00 2001 From: Maide Date: Tue, 28 Sep 2021 21:01:36 +0100 Subject: [PATCH 002/130] Obj_Mine --- include/functions.h | 2 +- spec | 6 +- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 1058 ++++++++++++++++- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 60 +- 4 files changed, 1061 insertions(+), 65 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2b92417a8..f3c1be135 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3284,7 +3284,7 @@ void func_80179B34(float fParm1, f32 fParm2, f32 fParm5, f32 fParm6, f32 param_5 // void func_80179D74(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); void Math3D_ScaleAndAdd(Vec3f* a, Vec3f* b, f32 scale, Vec3f* dst); void Math3D_Lerp(Vec3f* a, Vec3f* b, f32 t, Vec3f* dst); -s32 Math3D_Parallel(Vec3f* a, Vec3f* b); +f32 Math3D_Parallel(Vec3f* a, Vec3f* b); s32 Math3D_AngleBetweenVectors(Vec3f* a, Vec3f* b, f32* angle); void func_80179F64(Vec3f* param_1, Vec3f* param_2, Vec3f* param_3); s32 Math3D_XZBoundCheck(f32 xMin, f32 xMax, f32 zMin, f32 zMax, f32 x, f32 z); diff --git a/spec b/spec index a42617d9a..acf39407e 100644 --- a/spec +++ b/spec @@ -3229,9 +3229,11 @@ beginseg name "ovl_Obj_Mine" compress include "build/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.o" - include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.data.o" - include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Mine/ovl_Obj_Mine_reloc.o" +#else include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index a1f127eaa..a1a35a780 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -1,4 +1,11 @@ +/* + * File: z_obj_mine.c + * Overlay: ovl_Obj_Mine + * Description: Spike metal Mine + */ + #include "z_obj_mine.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" #define FLAGS 0x00000000 @@ -9,7 +16,30 @@ void ObjMine_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMine_Update(Actor* thisx, GlobalContext* globalCtx); void ObjMine_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A82F84(ObjMine* this); +void func_80A82F98(ObjMine* this, GlobalContext* globalCtx); +void func_80A82FA8(ObjMine* this); +void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx); +void func_80A83258(ObjMine* this, GlobalContext* globalCtx); +void func_80A832BC(ObjMine* this); +void func_80A832D0(ObjMine* this, GlobalContext* globalCtx); +void func_80A83A74(ObjMine* this); +void func_80A83A88(ObjMine* this, GlobalContext* globalCtx); +void func_80A83B14(ObjMine* this); +void func_80A83B28(ObjMine* this, GlobalContext* globalCtx); +void func_80A83CEC(ObjMine* this); +void func_80A83D00(ObjMine* this, GlobalContext* globalCtx); +void func_80A83E7C(Actor* thisx, GlobalContext* globalCtx); +void func_80A83FBC(Actor* thisx, GlobalContext* globalCtx); +void func_80A84088(Actor* thisx, GlobalContext* globalCtx); +void func_80A84338(Actor* thisx, GlobalContext* globalCtx); + +extern Gfx D_06000030[]; +extern Gfx D_06002068[]; +extern Gfx D_06002188[]; + +static s32 D_80A849D0[0xC0]; + const ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, ACTORCAT_PROP, @@ -22,127 +52,1035 @@ const ActorInit Obj_Mine_InitVars = { (ActorFunc)ObjMine_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A84570[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x01CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A84594 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A84570, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A845E8[] = { +static f32 D_80A845A4[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, +}; + +static Vec3f D_80A845C4 = { 1.0f, 0.0f, 0.0f }; + +static Vec3f D_80A845D0[] = { + { 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1300, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; +void func_80A811D0(ObjMine* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->unk_1B4[arg1]); +} + +s32 func_80A8120C(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); + + if (temp_f0 < 0.001f) { + return false; + } + + arg1->x = arg0->x * (1.0f / temp_f0); + arg1->y = arg0->y * (1.0f / temp_f0); + arg1->z = arg0->z * (1.0f / temp_f0); + return true; +} + +s32 func_80A81288(Vec3f* arg0, Vec3f* arg1, f32* arg2, f32* arg3) { + f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); + + if (temp_f0 < 0.001f) { + return false; + } + + arg1->x = arg0->x * (1.0f / temp_f0); + arg1->y = arg0->y * (1.0f / temp_f0); + arg1->z = arg0->z * (1.0f / temp_f0); + *arg2 = temp_f0; + *arg3 = 1.0f / temp_f0; + + return true; +} + +void func_80A8131C(ObjMine* this, GlobalContext* globalCtx) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } +} + +void func_80A81384(ObjMine* this, GlobalContext* globalCtx) { + f32 x = this->collider.elements[0].dim.worldSphere.center.x; + f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; + f32 z = this->collider.elements[0].dim.worldSphere.center.z; + + EnBom* bom = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); + + if (bom != NULL) { + bom->timer = 0; + } +} + +s32 func_80A8140C(ObjMine* this) { + if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + return true; + } + + if ((this->collider.base.ocFlags1 & OC2_UNK1)) { + Actor* mine = this->collider.base.oc; + + if ((mine->id == ACTOR_OBJ_MINE) && (mine->room == this->actor.room)) { + return true; + } + } + + return false; +} + +void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { + s32 pad2[3]; + Vec3f sp40; + s16 sp3E; + s16 pad; + Actor* temp_s0 = this->collider.base.ac; + + Math_Vec3s_ToVec3f(&sp40, &this->collider.elements[0].dim.worldSphere.center); + sp3E = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp40); + + if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { + *arg1 = temp_s0->shape.rot.y; + *arg2 = temp_s0->shape.rot.y - sp3E; + } else { + Vec3f sp2C; + Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + + Math_Vec3s_ToVec3f(&sp2C, hitPos); + *arg1 = Actor_YawBetweenActors(temp_s0, &this->actor); + *arg2 = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp2C) - sp3E; + } +} + +#ifdef NON_MATCHING +// stack, 1 var needs to go without changing code gen +void func_80A81544(ObjMine* this, Vec3f* arg1) { + ColliderJntSphElement* element = &this->collider.elements[0]; + Vec3s* sphere = &element->dim.worldSphere.center; + Actor* temp_v1 = this->collider.base.ac; + + if ((element->info.acHitInfo->toucher.dmgFlags & 0x13820)) { + SysMatrix_StatePush(); + Matrix_RotateY(temp_v1->shape.rot.y, MTXMODE_NEW); + SysMatrix_InsertXRotation_s(temp_v1->shape.rot.x, MTXMODE_APPLY); + SysMatrix_GetStateTranslationAndScaledZ(1.0f, arg1); + SysMatrix_StatePop(); + } else { + Vec3f sp20; + + sp20.x = sphere->x - temp_v1->world.pos.x; + sp20.y = sphere->y - temp_v1->world.pos.y; + sp20.z = sphere->z - temp_v1->world.pos.z; + if (!func_80A8120C(&sp20, arg1)) { + Math_Vec3f_Copy(arg1, D_80A845D0); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") #endif -extern ColliderJntSphElementInit D_80A84570[1]; -extern ColliderJntSphInit D_80A84594; -extern InitChainEntry D_80A845E8[]; +void func_80A81640(ObjMine* this) { +} -extern UNK_TYPE D_06000030; -extern UNK_TYPE D_06002068; +void func_80A8164C(Vec3f* arg0) { + MtxF* matrix = SysMatrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A811D0.s") + matrix->mf[3][0] = arg0->x; + matrix->mf[3][1] = arg0->y; + matrix->mf[3][2] = arg0->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8120C.s") +void func_80A81684(ObjMineUnkStruct* arg0) { + MtxF* matrix = SysMatrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81288.s") + matrix->mf[0][0] = arg0->unk_00.x; + matrix->mf[0][1] = arg0->unk_00.y; + matrix->mf[0][2] = arg0->unk_00.z; + matrix->mf[0][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8131C.s") + matrix->mf[1][0] = arg0->unk_0C.x; + matrix->mf[1][1] = arg0->unk_0C.y; + matrix->mf[1][2] = arg0->unk_0C.z; + matrix->mf[1][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81384.s") + matrix->mf[2][0] = arg0->unk_18.x; + matrix->mf[2][1] = arg0->unk_18.y; + matrix->mf[2][2] = arg0->unk_18.z; + matrix->mf[2][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8140C.s") + matrix->mf[3][0] = 0.0f; + matrix->mf[3][1] = 0.0f; + matrix->mf[3][2] = 0.0f; + matrix->mf[3][3] = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8146C.s") +s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { + Vec3f sp3C; + Vec3f sp30; + Vec3f sp24; + f32 sp20 = Math3D_Parallel(arg0, arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") + if (cos_rad(arg2) <= sp20) { + Math_Vec3f_Copy(arg0, arg1); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81640.s") + SysMatrix_StatePush(); + Math_Vec3f_Copy(&sp30, arg0); + Math3D_CrossProduct(arg0, arg1, &sp3C); + if (func_80A8120C(&sp3C, &sp24)) { + SysMatrix_InsertRotationAroundUnitVector_s(arg2 * 10430.378f, &sp24, MTXMODE_NEW); + SysMatrix_MultiplyVector3fByState(&sp30, arg0); + } else { + SysMatrix_SetStateXRotation(arg2); + SysMatrix_MultiplyVector3fByState(&sp30, arg0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8164C.s") + SysMatrix_StatePop(); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81684.s") +void func_80A81818(ObjMine* this) { + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81714.s") +void func_80A81868(ObjMine* this, s32 arg1) { + s32 i; + ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct3* unkStruct; + f32 arg = arg1; + f32 temp_f12 = this->actor.home.rot.z * 5.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81818.s") + ptr->unk_00.x = 1.0f; + ptr->unk_0C.y = 1.0f; + ptr->unk_18.z = 1.0f; + ptr->unk_24.y = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81868.s") + if (arg1 > 0) { + ptr->unk_40 = -sqrtf(0.001984f / arg); + ptr->unk_44 = (0.00031746097f * arg) + 0.95f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A819A4.s") + ptr->unk_58 = 0.0002f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81A00.s") + for (i = 0, unkStruct = &ptr->unk_60[0]; i < arg1; i++, unkStruct++) { + unkStruct->unk_00 = 0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81AA4.s") + if (temp_f12 < 0.0f) { + ptr->unk_5C = -1.0f; + } else if (temp_f12 <= 21.0f) { + ptr->unk_5C = 0.0f; + } else { + ptr->unk_5C = SQ(temp_f12 - 20.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81B14.s") +void func_80A819A4(ObjMine* this, s32 arg1) { + SysMatrix_InsertTranslation(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); + Collider_UpdateSpheres(0, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81B7C.s") +void func_80A81A00(ObjMine* this) { + ObjMineUnkStruct* ptr = &this->unk_1B8; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81D70.s") + sp28.x = -ptr->unk_30; + sp28.y = 1.0f; + sp28.z = -ptr->unk_34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81DEC.s") + func_80A8120C(&sp28, &ptr->unk_0C); + Math3D_CrossProduct(&D_80A845C4, &ptr->unk_0C, &sp28); + func_80A8120C(&sp28, &ptr->unk_18); + Math3D_CrossProduct(&ptr->unk_0C, &ptr->unk_18, &sp28); + func_80A8120C(&sp28, &ptr->unk_00); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81E7C.s") +void func_80A81AA4(ObjMine* this) { + s32 params = this->actor.params & 0x3F; + f32 temp_f0 = -((params * 12.0f) + 10.0f); + + this->actor.world.pos.x = (this->unk_1B8.unk_0C.x * temp_f0) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->unk_1B8.unk_0C.y * temp_f0) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->unk_1B8.unk_0C.z * temp_f0) + this->actor.home.pos.z; +} + +void func_80A81B14(ObjMine* this) { + s32 params = this->actor.params & 0x3F; + f32 temp_f0 = 1.0f / ((params * 12.0f) + 10.0f); + f32 x = this->actor.world.pos.x - this->actor.home.pos.x; + f32 z = this->actor.world.pos.z - this->actor.home.pos.z; + + this->unk_1B8.unk_30 = x * temp_f0; + this->unk_1B8.unk_34 = z * temp_f0; +} + +void func_80A81B7C(ObjMine* this, s32 arg1) { + ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct2* unkStruct; + s32 i; + f32 sp58 = this->actor.home.rot.z * 5.0f; + f32 temp_f24; + f32 temp_f26; + + ptr->unk_00.x = 0.9f; + ptr->unk_18.y = 0.003f; + + *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; + ptr->unk_24.x = -0.0002f; + ptr->unk_30 = -0.0002f; + + temp_f26 = ptr->unk_18.y * 6.0f; + temp_f24 = this->actor.home.pos.y; + + unkStruct = (ObjMineUnkStruct2*)&ptr->unk_44; + for (i = 0; i < arg1; i++, unkStruct++) { + temp_f24 += 12.0f; + unkStruct->unk_00.x = 1.0f; + unkStruct->unk_0C.y = 1.0f; + unkStruct->unk_18.z = 1.0f; + unkStruct->unk_24.x = this->actor.home.pos.x; + unkStruct->unk_24.y = temp_f24; + unkStruct->unk_24.z = this->actor.home.pos.z; + unkStruct->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; + unkStruct->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; + unkStruct->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; + } + + ptr->unk_24.y = temp_f24; + ptr->unk_24.z = temp_f24 * 0.97f; + temp_f24 = temp_f24 - 18.0f; + + if (ptr->unk_24.z < temp_f24) { + ptr->unk_24.z = temp_f24; + } + + if (sp58 < 0.0f) { + ptr->unk_34 = -1.0f; + } else if (sp58 <= 37.0f) { + ptr->unk_34 = 0.0f; + } else { + ptr->unk_34 = SQ(sp58 - 36.0f); + } +} + +void func_80A81D70(ObjMine* this, s32 arg1) { + SysMatrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, + this->actor.home.pos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); +} + +void func_80A81DEC(ObjMine* this) { + s32 pad[2]; + s32 temp_v0 = this->actor.params & 0x3F; + NextUnkStruct* temp_v1 = &((NextUnkStruct*)&this->unk_1B8)[temp_v0]; + + if (temp_v0 == 0) { + this->actor.world.pos.y = (this->actor.home.pos.y + 12.0f) + 10.0f; + } else { + Vec3f sp1C; + + Math_Vec3f_ScaleAndStore(&temp_v1->unk_08, 10.0f, &sp1C); + Math_Vec3f_Sum(&temp_v1->unk_20, &sp1C, &this->actor.world.pos); + } +} + +void func_80A81E7C(ObjMine* this, GlobalContext* globalCtx) { + ObjMineUnkStruct* temp_v1 = &this->unk_1B8; + s32 pad; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + CollisionPoly* sp48; + u32 sp44; + f32 sp40; + f32 sp3C; + + *(s8*)(&temp_v1->unk_40) = 0; + if (temp_v1->unk_34 > -0.000001f) { + if (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + this->actor.world.pos.x, this->actor.world.pos.z)) { + sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; + sp58.y = 0.0f; + sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; + if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { + sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); + sp70.y = this->actor.world.pos.y; + sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); + sp7C.x = this->actor.home.pos.x; + sp7C.y = this->actor.world.pos.y; + sp7C.z = this->actor.home.pos.z; + if (func_800C55C4(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { + *(s8*)(&temp_v1->unk_40) = 1; + temp_v1->unk_38 = sp4C.x * -0.2f; + temp_v1->unk_3C = sp4C.z * -0.2f; + } + } + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A828A8.s") +void func_80A828A8(ObjMine* this) { + s32 pad; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + s32 spC4 = this->actor.params & 0x3F; + s32 i = 0; + s32 phi_s5; + Vec3f* phi_s3 = NULL; + ObjMineUnkStruct* sp70 = &this->unk_1B8; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + Vec3f sp84; + ObjMineUnkStruct2* temp_s0 = (ObjMineUnkStruct2*)&sp70->unk_44; + f32 sp7C; + f32 sp78; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82C28.s") + sp84.x = this->actor.home.pos.x; + sp84.y = this->actor.home.pos.y + 6.0f; + sp84.z = this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Init.s") + for (; i < spC4; i++, temp_s0++) { + phi_s5 = false; + temp_s0->unk_30.x += temp_s0->unk_3C.x; + temp_s0->unk_30.y += temp_s0->unk_3C.y; + temp_s0->unk_30.z += temp_s0->unk_3C.z; + Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00.x); + Math_Vec3f_Copy(&sp90, &temp_s0->unk_24); + temp_s0->unk_24.x += temp_s0->unk_30.x; + temp_s0->unk_24.y += temp_s0->unk_30.y; + temp_s0->unk_24.z += temp_s0->unk_30.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Destroy.s") + if ((temp_s0->unk_24.y <= this->actor.home.pos.y) && (temp_s0->unk_30.y < 0.0f)) { + temp_s0->unk_30.y *= 0.1f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82F84.s") + Math_Vec3f_Diff(&temp_s0->unk_24, &sp84, &spA8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82F98.s") + if (func_80A81288(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { + Math_Vec3f_Copy(&spD4, &temp_s0->unk_0C); + func_80A81714(&spD4, &sp9C, 0.10471976f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82FA8.s") + Math3D_CrossProduct((phi_s3 == NULL) ? &D_80A845C4 : phi_s3, &spD4, &spA8); + if (func_80A8120C(&spA8, &spE0)) { + Math3D_CrossProduct(&spD4, &spE0, &spA8); + if (func_80A8120C(&spA8, &spC8)) { + phi_s5 = true; + } + } + } + + if (phi_s5) { + Math_Vec3f_Copy(&temp_s0->unk_00, &spC8); + Math_Vec3f_Copy(&temp_s0->unk_0C, &spD4); + Math_Vec3f_Copy(&temp_s0->unk_18, &spE0); + } else { + sp7C = 4.0f; + } + + if (sp7C >= 6.0f) { + temp_s0->unk_24.x = (temp_s0->unk_0C.x * 6.0f) + sp84.x; + temp_s0->unk_24.y = (temp_s0->unk_0C.y * 6.0f) + sp84.y; + temp_s0->unk_24.z = (temp_s0->unk_0C.z * 6.0f) + sp84.z; + } else { + temp_s0->unk_24.x = (temp_s0->unk_0C.x * sp7C) + sp84.x; + temp_s0->unk_24.y = (temp_s0->unk_0C.y * sp7C) + sp84.y; + temp_s0->unk_24.z = (temp_s0->unk_0C.z * sp7C) + sp84.z; + } + + sp84.x = temp_s0->unk_24.x + (temp_s0->unk_0C.x * 6.0f); + sp84.y = temp_s0->unk_24.y + (temp_s0->unk_0C.y * 6.0f); + sp84.z = temp_s0->unk_24.z + (temp_s0->unk_0C.z * 6.0f); + + phi_s3 = &temp_s0->unk_00; + } +} + +void func_80A81FFC(ObjMine* this); + +void func_80A82C28(ObjMine* this, GlobalContext* globalCtx) { + func_80A81E7C(this, globalCtx); + func_80A81FFC(this); + func_80A828A8(this); +} + +void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + s32 pad; + s32 sp44 = this->actor.params & 0xFF; + Path* path; + s32 sp3C; + s32 sp38 = (this->actor.params >> 0xC) & 3; + s32 sp34; + + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + + if (sp38 == 0) { + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 45.0f); + this->actor.shape.shadowAlpha = 140; + this->unk_1A8 = D_80A845A4[(this->actor.params >> 8) & 7]; + if (sp44 == 0xFF) { + func_80A82F84(this); + } else { + path = &globalCtx->setupPathList[sp44]; + this->unk_1B0 = 0; + this->unk_1AC = path->count - 1; + this->unk_1B4 = (Vec3s*)Lib_SegmentedToVirtual(path->points); + func_80A811D0(this, this->unk_1B0); + func_80A82FA8(this); + } + SysMatrix_SetStateRotationAndTranslation(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); + this->actor.floorHeight = + func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &this->actor.world.pos); + } else { + sp34 = this->actor.params & 0x3F; + this->actor.update = func_80A83E7C; + this->actor.uncullZoneScale = (sp34 * 21.0f) + 150.0f; + this->actor.uncullZoneDownward = (sp34 * 21.0f) + 150.0f; + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 45.0f); + this->actor.shape.shadowAlpha = 0x8C; + + if (sp38 == 1) { + this->actor.draw = func_80A84088; + func_80A81868(this, sp34); + this->actor.world.pos.y = (-10.0f - (sp34 * 12.0f)) + this->actor.home.pos.y; + func_80A819A4(this, sp34); + func_800B4AEC(globalCtx, &this->actor, 0.0f); + if (sp34 == 0) { + func_80A83A74(this); + } else { + func_80A832BC(this); + } + } else { + this->actor.draw = func_80A84338; + func_80A81B7C(this, sp34); + this->actor.world.pos.y = (sp34 * 12.0f) + 10.0f + this->actor.home.pos.y; + func_80A81D70(this, sp34); + if (sp34 == 0) { + func_80A83CEC(this); + } else { + func_80A83B14(this); + } + } + } +} + +void ObjMine_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80A82F84(ObjMine* this) { + this->actionFunc = func_80A82F98; +} + +void func_80A82F98(ObjMine* this, GlobalContext* globalCtx) { +} + +void func_80A82FA8(ObjMine* this) { + this->actor.flags |= 0x10; + this->actionFunc = func_80A82FC8; +} + +#ifdef NON_MATCHING +// stack +void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx) { + f32 phi_f0; + Vec3f spA0; + f32 sp9C; + s32 pad; + f32 phi_f12; + s32 sp90; + Vec3f sp84; + Vec3f sp78; + MtxF sp38; + + Math_Vec3s_ToVec3f(&spA0, &this->unk_1B4[this->unk_1B0 + 1]); + Math_Vec3f_Diff(&spA0, &this->actor.world.pos, &this->actor.velocity); + + sp9C = Math3D_Vec3fMagnitude(&this->actor.velocity); + if ((sp9C < (this->unk_1A8 * 8.0f)) && (this->unk_1A8 > 2.0f)) { + phi_f0 = ((this->unk_1A8 - 2.0f) * 0.1f) + 2.0f; + phi_f12 = this->unk_1A8 * 0.03f; + } else { + phi_f0 = this->unk_1A8; + phi_f12 = this->unk_1A8 * 0.16f; + } + + Math_StepToF(&this->actor.speedXZ, phi_f0, phi_f12); + + if ((this->actor.speedXZ + 0.05f) < sp9C) { + Math_Vec3f_Scale(&this->actor.velocity, this->actor.speedXZ / sp9C); + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + } else { + this->actor.speedXZ *= 0.4f; + this->unk_1B0++; + if (this->unk_1B0 >= this->unk_1AC) { + this->unk_1B0 = 0; + } + func_80A811D0(this, this->unk_1B0); + } + + this->actor.floorHeight = + func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp90, &this->actor, &this->actor.world.pos); + + if (this->actor.flags & 0x40) { + Math3D_CrossProduct(&D_80A845D0[0], &this->actor.velocity, &sp78); + if (func_80A8120C(&sp78, &sp84)) { + SysMatrix_InsertRotationAroundUnitVector_f(this->actor.speedXZ * 0.03125f, &sp84, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + SysMatrix_CopyCurrentState(&sp38); + func_8018219C(&sp38, &this->actor.shape.rot, 0); + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82FC8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83214.s") +void func_80A83214(ObjMine* this) { + this->actor.flags |= 0x10; + this->actor.draw = func_80A83FBC; + this->actor.shape.shadowDraw = NULL; + this->actor.scale.x = 0.02f; + this->actor.scale.y = 0.02f; + this->actor.scale.z = 0.02f; + this->actionFunc = func_80A83258; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83258.s") +void func_80A83258(ObjMine* this, GlobalContext* globalCtx) { + this->actor.scale.x *= 1.8f; + if (this->actor.scale.x > 0.17495999f) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A832BC.s") +void func_80A832BC(ObjMine* this) { + this->actionFunc = func_80A832D0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A832D0.s") +void func_80A832D0(ObjMine* this, GlobalContext* globalCtx) { + s32 pad; + s32 spA0 = this->actor.params & 0x3F; + ObjMineUnkStruct* unkStruct = &this->unk_1B8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83A74.s") + Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_0C); + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + } else { + ObjMineUnkStruct3* temp; + s32 i; + f32 sp90; + f32 sp8C; + f32 sp88; + s16 sp86; + s16 sp84; + s32 pad2; + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83A88.s") + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + unkStruct->unk_48 = 0.04f; + func_80A8146C(this, &unkStruct->unk_4C, &sp84); + sp8C = Math_SinS(sp84) * 150.0f; + sp88 = sp8C; + sp8C = -(sp8C / spA0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83B14.s") + for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { + temp->unk_02 += (s16)sp88; + temp->unk_02 = CLAMP(temp->unk_02, -800, 800); + sp88 -= sp8C; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83B28.s") + if (unkStruct->unk_48 > 0.0001f) { + sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; + sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; + unkStruct->unk_38 += sp90; + unkStruct->unk_3C += sp8C; + Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83CEC.s") + if ((u32)Rand_Next() >> 0x1B == 0) { + unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; + unkStruct->unk_54 = (u32)Rand_Next() >> 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83D00.s") + sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; + sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; + unkStruct->unk_38 += sp90; + unkStruct->unk_3C += sp8C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Update.s") + unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; + unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83E7C.s") + unkStruct->unk_38 *= unkStruct->unk_44; + unkStruct->unk_3C *= unkStruct->unk_44; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Draw.s") + unkStruct->unk_30 += unkStruct->unk_38; + unkStruct->unk_34 += unkStruct->unk_3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83FBC.s") + unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); + unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A84088.s") + func_80A81A00(this); + func_80A81AA4(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A84338.s") + if ((unkStruct->unk_5C > -0.000001f) && + (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z))) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 0.0f, 1); + + if (this->actor.bgCheckFlags & 8) { + if (this->actor.wallPoly != NULL) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + sp4C.x = unkStruct->unk_38; + sp4C.y = 0.0f; + sp4C.z = unkStruct->unk_3C; + if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { + sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + func_80179F64(&sp70, &sp58, &sp64); + sp48 *= 0.5f; + unkStruct->unk_38 = sp64.x * sp48; + unkStruct->unk_3C = sp64.z * sp48; + } else { + unkStruct->unk_38 *= -0.1f; + unkStruct->unk_3C *= -0.1f; + } + func_80A81B14(this); + func_80A81A00(this); + func_80A81AA4(this); + } + } + } + + for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { + sp86 = temp->unk_00 - 0x4000; + sp88 = ((Rand_ZeroOne() * 30.0f) - 15.0f) + (temp->unk_02 + (sp86 * -0.05f)); + sp88 *= 0.995f; + temp->unk_02 = sp88; + temp->unk_00 += temp->unk_02; + } + + func_800B4AEC(globalCtx, &this->actor, 0.0f); + func_80A81818(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80A83A74(ObjMine* this) { + this->actionFunc = func_80A83A88; +} + +void func_80A83A88(ObjMine* this, GlobalContext* globalCtx) { + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80A83B14(ObjMine* this) { + this->actionFunc = func_80A83B28; +} + +void func_80A83B28(ObjMine* this, GlobalContext* globalCtx) { + ObjMineUnkStruct* ptr; + s16 rand; + + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + return; + } + + ptr = &this->unk_1B8; + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + func_80A81544(this, (Vec3f*)&ptr->unk_00.y); + ptr->unk_0C.y = 7.0f; + Math_Vec3f_Scale((Vec3f*)&ptr->unk_00.y, 7.0f); + } + + if (ptr->unk_0C.y > 0.0001f) { + ptr->unk_0C.y = Math_Vec3f_StepTo((Vec3f*)&ptr->unk_00.y, &D_801D15B0, 2.8f); + } + + ptr->unk_00.x = 0.9f; + ptr->unk_24.x = -0.0002f; + ptr->unk_30 = -0.0002f; + ptr->unk_18.y = 0.003f; + if (!((u32)Rand_Next() >> 0x1B)) { + rand = (u32)Rand_Next() >> 0x10; + ptr->unk_0C.z = Math_SinS(rand) * 1.8f * ptr->unk_18.y; + ptr->unk_18.x = Math_CosS(rand) * 0.2f * ptr->unk_18.y; + *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; + } + + func_80A82C28(this, globalCtx); + func_80A81DEC(this); + func_80A81818(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80A83CEC(ObjMine* this) { + this->actionFunc = func_80A83D00; +} + +void func_80A83D00(ObjMine* this, GlobalContext* globalCtx) { + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjMine_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjMine* this = THIS; + + if ((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.acFlags & AC_HIT)) { + func_80A8131C(this, globalCtx); + func_80A83214(this); + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + if ((this->actor.flags & 0x40) && (this->actionFunc != func_80A83258)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80A83E7C(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjMine_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjMine* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actionFunc == func_80A82FC8) { + Collider_UpdateSpheres(0, &this->collider); + } + + func_800B8050(&this->actor, globalCtx, 1); + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, D_06002068); + gSPDisplayList(POLY_OPA_DISP++, D_06002188); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A83FBC(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800B8118(&this->actor, globalCtx, 1); + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 75); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_06002068); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + s32 temp_s5 = this->actor.params & 0x3F; + ObjMineUnkStruct3* temp; + ObjMineUnkStruct* ptr = &this->unk_1B8; + s32 pad; + s32 i; + Vec3f sp94; + Vec3f sp88; + Gfx* gfx; + + func_800B8050(&this->actor, globalCtx, 1); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + + func_80A81684(ptr); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (temp_s5 != 0) { + Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -6.0f, &sp88); + sp94.x = this->actor.home.pos.x - sp88.x; + sp94.y = (this->actor.home.pos.y - 6.0f) - sp88.y; + sp94.z = this->actor.home.pos.z - sp88.z; + Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -12.0f, &sp88); + + for (i = 0, temp = &ptr->unk_60[0]; i < temp_s5; i++, temp++) { + Matrix_RotateY(temp->unk_00, MTXMODE_APPLY); + sp94.x += sp88.x; + sp94.y += sp88.y; + sp94.z += sp88.z; + func_80A8164C(&sp94); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + } + } + + SysMatrix_InsertXRotation_s(0x2000, MTXMODE_APPLY); + func_80A8164C(&this->actor.world.pos); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(gfx++); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(gfx++, 0, 0, 0, 255); + gSPDisplayList(gfx++, D_06002068); + gSPDisplayList(gfx++, D_06002188); + + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A84338(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + s32 temp_s7 = this->actor.params & 0x3F; + s32 i; + Gfx* gfx; + ObjMineUnkStruct2* temp; + s32 pad[2]; + + func_800B8050(&this->actor, globalCtx, 1); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + + for (i = 0, temp = (ObjMineUnkStruct2*)((u8*)this + 0x1FC); i < temp_s7; i++, temp++) { + func_80A81684((ObjMineUnkStruct*)temp); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); + if ((i & 1) == 0) { + Matrix_RotateY(0x4000, 1); + } + func_80A8164C(&temp->unk_24); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + } + + SysMatrix_InsertXRotation_s(0x2000, 1); + func_80A8164C(&this->actor.world.pos); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(gfx++); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(gfx++, 0, 0, 0, 255); + gSPDisplayList(gfx++, D_06002068); + gSPDisplayList(gfx++, D_06002188); + + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 4b7f8ee3d..af2772fda 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,11 +7,67 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, GlobalContext*); +// definitely fake +typedef struct { + char unk_00[0x8]; + Vec3f unk_08; + char unk_14[0xC]; + Vec3f unk_20; + char unk_2C[0x1C]; +} NextUnkStruct; // size = 0x48 + +// maybe fake +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; +} ObjMineUnkStruct3; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + ///* 0x24 */ char unk_24[0x3C]; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; + /* 0x40 */ f32 unk_40; + /* 0x44 */ f32 unk_44; + /* 0x48 */ f32 unk_48; + /* 0x4C */ s16 unk_4C; + /* 0x50 */ f32 unk_50; + /* 0x54 */ s16 unk_54; + /* 0x58 */ f32 unk_58; + /* 0x5C */ f32 unk_5C; + /* 0x60 */ ObjMineUnkStruct3 unk_60[1]; +} ObjMineUnkStruct; // size = ?? 0x44??? 48 array??? + +// probably fake +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0c */ Vec3f unk_0C; + ///* 0x10 */ f32 unk_10; + ///* 0x14 */ char unk_14[0x4]; + /* 0x18 */ Vec3f unk_18; + ///* 0x1C */ char unk_1C[0x4]; + ///* 0x20 */ f32 unk_20; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ Vec3f unk_30; + /* 0x3C */ Vec3f unk_3C; +} ObjMineUnkStruct2; // size = 0x48??? + typedef struct ObjMine { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjMineActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0x120C]; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ s32 unk_1AC; + /* 0x01B0 */ s32 unk_1B0; + /* 0x01B4 */ Vec3s* unk_1B4; + /* 0x01B8 */ ObjMineUnkStruct unk_1B8; // array?? + /* 0x021C */ char unk_21C[0x1198]; } ObjMine; // size = 0x13B4 extern const ActorInit Obj_Mine_InitVars; From d70906fee7bcb51433bac4df78b660ee7559d974 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 16:29:33 +1100 Subject: [PATCH 003/130] Voice progress --- include/functions.h | 14 +++++----- include/os.h | 10 +++++++ src/libultra/voice/voicecheckresult.c | 20 +++++++++++++- src/libultra/voice/voicecleardictionary.c | 31 +++++++++++++++++++++- src/libultra/voice/voicecrc.c | 32 ++++++++++++++++++++++- 5 files changed, 97 insertions(+), 10 deletions(-) diff --git a/include/functions.h b/include/functions.h index 367d784ae..fab8136ba 100644 --- a/include/functions.h +++ b/include/functions.h @@ -355,11 +355,11 @@ void guLookAtHiliteF(float mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 twidth, s32 theight); s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap); void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); -// void osVoiceClearDictionary(void); +s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words); void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -// void __osVoiceContRead2(void); -// void __osVoiceContDataCrc(void); +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, s32, u8 dst[2]); +u8 __osVoiceContDataCrc(u8* data, u32 arg1); const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); void* memcpy(void* __dest, const void* __src, size_t __n); @@ -388,7 +388,7 @@ OSTime osGetTime(void); void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); -// void osVoiceInit(void); +s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel); // void __osContChannelReset(void); // void __osVoiceSetADConverter(void); s32 osAiSetFrequency(u32 frequency); @@ -418,7 +418,7 @@ f32 __cosf(f32 __x); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); void osSetTime(OSTime ticks); -// void osVoiceStopReadData(void); +s32 osVoiceStopReadData(OSVoiceHandle* hd); void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount); s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern); // void __osPfsRequestData(void); @@ -473,11 +473,11 @@ float __ll_to_f(long long l); double __ull_to_d(unsigned long long l); float __ull_to_f(unsigned long long l); // void osVoiceCheckWord(void); -// void osVoiceControlGain(void); +s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital); // void osVoiceStartReadData(void); void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); -// void __osVoiceContWrite4(void); +// s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); // void __osSetHWIntrRoutine(void); u32 __osGetWatchLo(void); diff --git a/include/os.h b/include/os.h index 50f3b10c4..cdfa49c91 100644 --- a/include/os.h +++ b/include/os.h @@ -131,4 +131,14 @@ typedef struct { /* 0xC */ u8 status; } OSVoiceHandle; // size = 0x10 +typedef struct { + /* 0x00 */ u16 warning; /* Warning */ + /* 0x02 */ u16 answer_num; /* Candidate number (0~5) */ + /* 0x04 */ u16 voice_level; /* Voice input level */ + /* 0x06 */ u16 voice_sn; /* Relative voice level */ + /* 0x08 */ u16 voice_time; /* Voice input time */ + /* 0x0A */ u16 answer[5]; /* Candidate word number */ + /* 0x14 */ u16 distance[5]; /* Distance value */ +} OSVoiceData; // size = 0x20 + #endif diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index 44fb69be5..bd4060a37 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -1,3 +1,21 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckresult/__osVoiceCheckResult.s") +s32 __osVoiceCheckResult(OSVoiceHandle* handle, u8* status) { + s32 phi_v1; + u8 sp20[2]; + + if (phi_v1 = __osVoiceGetStatus(handle->mq, handle->port, status), phi_v1 == 0) { + if (*status & 1) { + phi_v1 = 0xF; + } else if (phi_v1 = __osVoiceContRead2(handle->mq, handle->port, 0, sp20), phi_v1 == 0) { + handle->status = sp20[0] & 7; + + if (sp20[0] & 0x40) { + phi_v1 = 0xF; + } else { + phi_v1 = sp20[1] << 8; + } + } + } + return phi_v1; +} diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index d6278d3fa..4de1eef59 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -1,4 +1,33 @@ #include "global.h" // Initializes Voice Recognition System word registration dictionary -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecleardictionary/osVoiceClearDictionary.s") +s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { + u8* registration_word; + u8 status; + s32 sp24; + s32 temp_v0; + + temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (temp_v0 != 0) { + return temp_v0; + } + + registration_word = &sp24; + if (status & 2) { + return 0xF; + } + + sp24 = 0x2000000; + registration_word[2] = words; + + temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); + if (temp_v0 != 0) { + return temp_v0; + } + + temp_v0 = __osVoiceCheckResult(hd, &status); + if ((temp_v0 & 0xFF00) != 0) { + temp_v0 = 5; + } + return temp_v0; +} diff --git a/src/libultra/voice/voicecrc.c b/src/libultra/voice/voicecrc.c index cc23e89dd..e1530fcb8 100644 --- a/src/libultra/voice/voicecrc.c +++ b/src/libultra/voice/voicecrc.c @@ -1,3 +1,33 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecrc/__osVoiceContDataCrc.s") +u8 __osVoiceContDataCrc(u8* data, u32 arg1) { + u32 bit; + u32 byte; + u32 ret = 0; + + for (byte = arg1; byte > 0; byte--) { + for (bit = 0x80; bit > 0; bit >>= 1) { + ret <<= 1; + if (*data & bit) { + if (ret & 0x100) { + ret ^= 0x84; + } else { + ret++; + } + } else if (ret & 0x100) { + ret ^= 0x85; + } + } + data++; + } + + do { + ret <<= 1; + if (ret & 0x100) { + ret ^= 0x85; + } + byte++; + } while (byte < 8); + + return ret; +} From 357ee948bb6f43f80ad988e2e306b71f47db673f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:32:28 +1100 Subject: [PATCH 004/130] Match osVoiceControlGain --- include/functions.h | 4 +-- src/libultra/voice/voicecontrolgain.c | 37 ++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index fab8136ba..431376e1e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -390,7 +390,7 @@ void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel); // void __osContChannelReset(void); -// void __osVoiceSetADConverter(void); +s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2, OSVoiceHandle* hd); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); // void __osVoiceContWrite20(void); @@ -477,7 +477,7 @@ s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital); // void osVoiceStartReadData(void); void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); -// s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); +s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); // void __osSetHWIntrRoutine(void); u32 __osGetWatchLo(void); diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index d4020e605..cfca63fbb 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -1,4 +1,39 @@ #include "global.h" +extern u8 D_80098180[]; + // Adjusts the input gain of the Voice Recognition System -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontrolgain/osVoiceControlGain.s") +s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { + s32 ret; + u8 phi_a2; + + + if (analog == 0) { + phi_a2 = 0x18; + } else { + phi_a2 = 0x98; + } + + ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (ret != 0) { + return ret; + } + + if (!((digital < 8) && (digital >= 0))){ + goto dummy; + } + + phi_a2 = D_80098180[digital] + 2; + + if (0) { + dummy: + return 5; + } + + ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (ret != 0) { + return ret; + } + + return ret; +} From 6cbf9734a7dbfb8997a79033fbca7565642d8117 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:43:53 +1100 Subject: [PATCH 005/130] Match osVoiceStartReadData --- include/functions.h | 6 ++--- src/libultra/voice/voicecheckresult.c | 8 +++--- src/libultra/voice/voicestartreaddata.c | 33 ++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/include/functions.h b/include/functions.h index 431376e1e..b0b68959d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -280,7 +280,7 @@ void __osDispatchThread(void); void __osCleanupThread(void); void __osDequeueThread(OSThread** param_1, OSThread* param_2); void osDestroyThread(OSThread* puParm1); -// void __osVoiceCheckResult(void); +s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status); void bzero(void* begin, s32 length); // void osSetRumble(void); // void osSetUpMempakWrite(void); @@ -473,8 +473,8 @@ float __ll_to_f(long long l); double __ull_to_d(unsigned long long l); float __ull_to_f(unsigned long long l); // void osVoiceCheckWord(void); -s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital); -// void osVoiceStartReadData(void); +s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); +s32 osVoiceStartReadData(OSVoiceHandle* hd); void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index bd4060a37..a20c88461 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -1,14 +1,14 @@ #include "global.h" -s32 __osVoiceCheckResult(OSVoiceHandle* handle, u8* status) { +s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { s32 phi_v1; u8 sp20[2]; - if (phi_v1 = __osVoiceGetStatus(handle->mq, handle->port, status), phi_v1 == 0) { + if (phi_v1 = __osVoiceGetStatus(hd->mq, hd->port, status), phi_v1 == 0) { if (*status & 1) { phi_v1 = 0xF; - } else if (phi_v1 = __osVoiceContRead2(handle->mq, handle->port, 0, sp20), phi_v1 == 0) { - handle->status = sp20[0] & 7; + } else if (phi_v1 = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), phi_v1 == 0) { + hd->status = sp20[0] & 7; if (sp20[0] & 0x40) { phi_v1 = 0xF; diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 118cc3f60..809ee805e 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -1,4 +1,35 @@ #include "global.h" // Start voice recognition by the Voice Recognition System -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicestartreaddata/osVoiceStartReadData.s") +s32 osVoiceStartReadData(OSVoiceHandle* hd) { + s32 temp_v0; + u8 sp2B; + s32 sp24; + + temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); + if (temp_v0 != 0) { + return temp_v0; + } + + if ((sp2B & 2) != 0) { + return 0xF; + } + + if (hd->mode != 0) { + return 5; + } + + sp24 = 0x5000000; + temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + + if (temp_v0 == 0) { + temp_v0 = __osVoiceCheckResult(hd, &sp2B); + if ((temp_v0 & 0xFF00) != 0) { + temp_v0 = 5; + } else { + hd->mode = 1; + } + } + + return temp_v0; +} From d1225a5634892d15e770e6aa1fc6c4852c1afdc0 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:45:24 +1100 Subject: [PATCH 006/130] Cleanup --- src/libultra/voice/voicestartreaddata.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 809ee805e..e0e696749 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -2,13 +2,13 @@ // Start voice recognition by the Voice Recognition System s32 osVoiceStartReadData(OSVoiceHandle* hd) { - s32 temp_v0; + s32 ret; u8 sp2B; s32 sp24; - temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); - if (temp_v0 != 0) { - return temp_v0; + ret = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); + if (ret != 0) { + return ret; } if ((sp2B & 2) != 0) { @@ -20,16 +20,17 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } sp24 = 0x5000000; - temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + ret = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); - if (temp_v0 == 0) { - temp_v0 = __osVoiceCheckResult(hd, &sp2B); - if ((temp_v0 & 0xFF00) != 0) { - temp_v0 = 5; + if (ret == 0) { + ret = __osVoiceCheckResult(hd, &sp2B); + + if ((ret & 0xFF00) != 0) { + ret = 5; } else { hd->mode = 1; } } - return temp_v0; + return ret; } From 3c76274078fb3226d8b2327f080eeceebf08f403 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 7 Nov 2021 21:24:58 +1100 Subject: [PATCH 007/130] Add docs from n64devkit --- include/functions.h | 8 ++++---- include/os.h | 17 ++++++++++++++++ src/libultra/voice/voicecheckresult.c | 14 ++++++------- src/libultra/voice/voicecleardictionary.c | 23 +++++++++++----------- src/libultra/voice/voicecontrolgain.c | 16 +++++++-------- src/libultra/voice/voicestartreaddata.c | 24 +++++++++++------------ 6 files changed, 60 insertions(+), 42 deletions(-) diff --git a/include/functions.h b/include/functions.h index d915a3e7d..23c537f0b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -245,7 +245,7 @@ void osStopThread(OSThread* t); s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags); OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); -// void osVoiceSetWord(void); +s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word); // void guScale(void); f32 __sinf(f32 __x); s16 sins(u16 x); @@ -287,7 +287,7 @@ void osCreateThread(OSThread* t, OSId id, void* entry, void* arg, void* sp, OSPr s32 osContStartReadData(OSMesgQueue* mq); void osContGetReadData(OSContPad* data); void __osPackReadData(void); -// void osVoiceGetReadData(void); +s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result); uintptr_t osVirtualToPhysical(void* vaddr); u32 __osGetSR(void); void __osSetSR(u32 value); @@ -452,7 +452,7 @@ void viMgrMain(OSDevMgr* iParm1); __OSViContext* __osViGetCurrentContext(void); void osWritebackDCacheAll(void); OSThread* __osGetCurrFaultedThread(void); -// void osVoiceMaskDictionary(void); +s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size); void guMtxF2L(float mf[4][4], Mtx* m); void osStartThread(OSThread* param_1); void osViSetYScale(f32 value); @@ -465,7 +465,7 @@ double __ll_to_d(long long l); float __ll_to_f(long long l); double __ull_to_d(unsigned long long l); float __ull_to_f(unsigned long long l); -// void osVoiceCheckWord(void); +s32 osVoiceCheckWord(u8* word); s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); s32 osVoiceStartReadData(OSVoiceHandle* hd); void* osViGetCurrentFramebuffer(void); diff --git a/include/os.h b/include/os.h index 47a419d6b..1a4712bff 100644 --- a/include/os.h +++ b/include/os.h @@ -122,6 +122,23 @@ typedef struct { /* 0xC */ u32* text_end; } OSProf; // size = 0x10 +#define VOICE_STATUS_READY 0 /* stop/end */ +#define VOICE_STATUS_START 1 /* Voice Undetected (no voice input) */ +#define VOICE_STATUS_CANCEL 3 /* Cancel (cancel extraneous noise) */ +#define VOICE_STATUS_BUSY 5 /* Detected/Detecting (voice being input, recognition processing under way) */ +#define VOICE_STATUS_END 7 /* End recognition processing (enable execution of Get Recognition Results command) */ + +#define VOICE_WARN_TOO_SMALL 0x400 /* Voice level is too low (100 < Voice Level < 150) */ +#define VOICE_WARN_TOO_LARGE 0x800 /* Voice level is too high (Voice Level > 3500) */ +#define VOICE_WARN_NOT_FIT 0x4000 /* No words match recognition word (No. 1 Candidate Distance Value > 1600) */ +#define VOICE_WARN_TOO_NOISY 0x8000 /* Too much ambient noise (Relative Voice Level =< 400) */ + +// #define CONT_ERR_NO_CONTROLLER +// #define CONT_ERR_DEVICE +// #define CONT_ERR_CONTRFAIL +// #define CONT_ERR_VOICE_NO_RESPONSE +// #define CONT_ERR_INVALID + typedef struct { /* 0x0 */ OSMesgQueue* mq; /* 0x4 */ s32 port; /* Controller port */ diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index a20c88461..97af48094 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -1,21 +1,21 @@ #include "global.h" s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { - s32 phi_v1; + s32 errorCode; u8 sp20[2]; - if (phi_v1 = __osVoiceGetStatus(hd->mq, hd->port, status), phi_v1 == 0) { + if (errorCode = __osVoiceGetStatus(hd->mq, hd->port, status), errorCode == 0) { if (*status & 1) { - phi_v1 = 0xF; - } else if (phi_v1 = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), phi_v1 == 0) { + errorCode = 0xF; + } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), errorCode == 0) { hd->status = sp20[0] & 7; if (sp20[0] & 0x40) { - phi_v1 = 0xF; + errorCode = 0xF; } else { - phi_v1 = sp20[1] << 8; + errorCode = sp20[1] << 8; } } } - return phi_v1; + return errorCode; } diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 4de1eef59..92114809d 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -5,11 +5,11 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { u8* registration_word; u8 status; s32 sp24; - s32 temp_v0; + s32 errorCode; - temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &status); - if (temp_v0 != 0) { - return temp_v0; + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (errorCode != 0) { + return errorCode; } registration_word = &sp24; @@ -20,14 +20,15 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { sp24 = 0x2000000; registration_word[2] = words; - temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); - if (temp_v0 != 0) { - return temp_v0; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); + if (errorCode != 0) { + return errorCode; } - temp_v0 = __osVoiceCheckResult(hd, &status); - if ((temp_v0 & 0xFF00) != 0) { - temp_v0 = 5; + errorCode = __osVoiceCheckResult(hd, &status); + if ((errorCode & 0xFF00) != 0) { + errorCode = 5; } - return temp_v0; + + return errorCode; } diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index cfca63fbb..b0a66284a 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -4,7 +4,7 @@ extern u8 D_80098180[]; // Adjusts the input gain of the Voice Recognition System s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { - s32 ret; + s32 errorCode; u8 phi_a2; @@ -14,9 +14,9 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { phi_a2 = 0x98; } - ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); - if (ret != 0) { - return ret; + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (errorCode != 0) { + return errorCode; } if (!((digital < 8) && (digital >= 0))){ @@ -30,10 +30,10 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { return 5; } - ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); - if (ret != 0) { - return ret; + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (errorCode != 0) { + return errorCode; } - return ret; + return errorCode; } diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index e0e696749..88c77dc2c 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -2,16 +2,16 @@ // Start voice recognition by the Voice Recognition System s32 osVoiceStartReadData(OSVoiceHandle* hd) { - s32 ret; - u8 sp2B; + s32 errorCode; + u8 status; s32 sp24; - ret = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); - if (ret != 0) { - return ret; + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (errorCode != 0) { + return errorCode; } - if ((sp2B & 2) != 0) { + if (status & 2) { return 0xF; } @@ -20,17 +20,17 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } sp24 = 0x5000000; - ret = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); - if (ret == 0) { - ret = __osVoiceCheckResult(hd, &sp2B); + if (errorCode == 0) { + errorCode = __osVoiceCheckResult(hd, &status); - if ((ret & 0xFF00) != 0) { - ret = 5; + if (errorCode & 0xFF00) { + errorCode = 5; } else { hd->mode = 1; } } - return ret; + return errorCode; } From 11a86e2246aa4ca9161f0bc5fad5beffb341d187 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 7 Nov 2021 23:04:02 +1100 Subject: [PATCH 008/130] WIP on osVoiceGetReadData --- include/functions.h | 2 +- include/os.h | 5 +- include/variables.h | 2 +- src/libultra/voice/voicegetreaddata.c | 117 ++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 23c537f0b..0fff4f8f4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -363,7 +363,7 @@ void __osTimerServicesInit(void); void __osTimerInterrupt(void); void __osSetTimerIntr(OSTime tim); OSTime __osInsertTimer(OSTimer* t); -// void __osVoiceContRead36(void); +s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, s32, u8*); s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); // void guMtxIdent(void); diff --git a/include/os.h b/include/os.h index 1a4712bff..d168d352e 100644 --- a/include/os.h +++ b/include/os.h @@ -135,9 +135,12 @@ typedef struct { // #define CONT_ERR_NO_CONTROLLER // #define CONT_ERR_DEVICE +// #define CONT_ERR_NOT_READY // #define CONT_ERR_CONTRFAIL // #define CONT_ERR_VOICE_NO_RESPONSE -// #define CONT_ERR_INVALID +// #define CONT_ERR_INVALID +// #define CONT_ERR_VOICE_WORD +// #define CONT_ERR_VOICE_MEMORY typedef struct { /* 0x0 */ OSMesgQueue* mq; diff --git a/include/variables.h b/include/variables.h index 6b5fbe620..55fe64c49 100644 --- a/include/variables.h +++ b/include/variables.h @@ -329,7 +329,7 @@ extern OSTask tmp_task; extern OSMesg siAccessBuf[1]; extern OSMesgQueue __osSiAccessQueue; -extern UNK_TYPE1 D_8009CF60; +extern u8 D_8009CF60; // extern UNK_TYPE4 D_8009CF70; extern OSThread __osThreadSave; extern OSPiHandle D_8009D130; diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index c0987c151..0bba3bac0 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -1,4 +1,121 @@ #include "global.h" // Gets voice recognition result from the Voice Recognition System +#ifdef NON_EQUIVALENT +s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { + s32 errorCode; + u8 new_var; + u8 temp_t9; + u8 sp38[40]; + s32 i; + + switch (hd->mode) { + case 1: + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (sp38[39] & 1) { + return 0xC; + } + + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + temp_t9 = sp38[0] & 7; + hd->status = temp_t9; + D_8009CF60 = temp_t9; + if ((temp_t9 != 0) && (temp_t9 != 7)) { + return 0xC; + } + case 2: + hd->mode = 2; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (0) {} + if (sp38[39] & 2) { + return 0xF; + } + + sp38[1] = 0x600; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + case 3: + hd->mode = 3; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (sp38[39] & 1) { + return 0xF; + } + + errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + result->warning = (sp38[5] << 8) + sp38[4]; + result->answer_num = sp38[6]; + result->voice_level = (sp38[9] << 8) + sp38[8]; + result->voice_sn = (sp38[11] << 8) + sp38[10]; + result->voice_time = (sp38[13] << 8) + sp38[12]; + + new_var = 4; + for (i = 0; i < 5; i++) { + result->answer[i] = (sp38[15 + new_var*i] << 8) + sp38[14 + new_var*i]; + result->distance[i] = (sp38[17 + new_var*i] << 8) + sp38[16 + new_var*i]; + } + + if (result->answer[0] == 0x7FFF) { + result->answer_num = 0; + } + + hd->status = sp38[34] & 7; + if ((D_8009CF60 == 0) || (hd->status == 0)) { + break; + } + case 4: + hd->mode = 4; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (sp38[39] & 1) { + return 0xF; + } + + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + hd->status = sp38[0] & 7; + if ((sp38[0] & 7) != 0) { + return 0xF; + } + + break; + default: + return 5; + } + hd->mode = 0; + return errorCode; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/boot/voicegetreaddata/osVoiceGetReadData.s") +#endif From 09a43268561c3206fd6e7929704d3825481a3fdb Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 7 Nov 2021 23:05:47 +1100 Subject: [PATCH 009/130] Add comment --- src/libultra/voice/voicegetreaddata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 0bba3bac0..c202ad27d 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -44,7 +44,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { return 0xF; } - sp38[1] = 0x600; + sp38[0] = 0x600; // Not reading in correctly since 0x600 is out-of-range for u8 errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, sp38); if (errorCode != 0) { return errorCode; From 5aa43d1c2985a6dec47672024c67a4cc9d14d621 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 00:27:05 +1100 Subject: [PATCH 010/130] Match voiceinit.c --- include/functions.h | 4 +- src/libultra/voice/voicecontrolgain.c | 4 +- src/libultra/voice/voiceinit.c | 57 ++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0fff4f8f4..5bfe48049 100644 --- a/include/functions.h +++ b/include/functions.h @@ -382,8 +382,8 @@ void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel); -// void __osContChannelReset(void); -s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2, OSVoiceHandle* hd); +s32 __osContChannelReset(OSMesgQueue* mq, s32 count); +s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); // void __osVoiceContWrite20(void); diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index b0a66284a..251dc1144 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -14,7 +14,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { phi_a2 = 0x98; } - errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); if (errorCode != 0) { return errorCode; } @@ -30,7 +30,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { return 5; } - errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 69fd1e36e..50dab4fdc 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -1,4 +1,59 @@ #include "global.h" +extern u8 D_80097FA0; +extern u8 D_80097FA5; + // Initializes Voice Recognition System control structure and hardware -#pragma GLOBAL_ASM("asm/non_matchings/boot/voiceinit/osVoiceInit.s") +s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { + s32 errorCode; + u8* phi_s0; + u8 sp37 = 0; + s32 sp30; + s32 pad; + + hd->port = channel; + hd->mq = siMessageQ; + hd->mode = 0; + + errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + if (errorCode != 0) { + return errorCode; + } + + if (__osContChannelReset(siMessageQ, channel) != 0) { + return 4; + } + + for (phi_s0 = &D_80097FA0;;) { + errorCode = __osVoiceSetADConverter(siMessageQ, channel, *phi_s0); + + phi_s0++; + if (errorCode != 0) { + return errorCode; + } + + if (phi_s0 == &D_80097FA5) { + errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + if (errorCode != 0) { + return errorCode; + } + if ((sp37 & 2) != 0) { + return 0xF; + } + + sp30 = 0x100; + errorCode = __osVoiceContWrite4(siMessageQ, channel, 0, &sp30); + if (errorCode != 0) { + return errorCode; + } + + errorCode = __osVoiceCheckResult(hd, &sp37); + if (errorCode & 0xFF00) { + errorCode = 5; + } + + return errorCode; + } + } +} + From 23d3f1980eab2f755e887826be61224525f360da Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 00:31:03 +1100 Subject: [PATCH 011/130] Remove CONT_ERR, already present in controller.h --- include/os.h | 9 --------- src/libultra/voice/voiceinit.c | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/include/os.h b/include/os.h index d168d352e..82e1ac013 100644 --- a/include/os.h +++ b/include/os.h @@ -133,15 +133,6 @@ typedef struct { #define VOICE_WARN_NOT_FIT 0x4000 /* No words match recognition word (No. 1 Candidate Distance Value > 1600) */ #define VOICE_WARN_TOO_NOISY 0x8000 /* Too much ambient noise (Relative Voice Level =< 400) */ -// #define CONT_ERR_NO_CONTROLLER -// #define CONT_ERR_DEVICE -// #define CONT_ERR_NOT_READY -// #define CONT_ERR_CONTRFAIL -// #define CONT_ERR_VOICE_NO_RESPONSE -// #define CONT_ERR_INVALID -// #define CONT_ERR_VOICE_WORD -// #define CONT_ERR_VOICE_MEMORY - typedef struct { /* 0x0 */ OSMesgQueue* mq; /* 0x4 */ s32 port; /* Controller port */ diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 50dab4fdc..54e13fa4c 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -37,7 +37,7 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { if (errorCode != 0) { return errorCode; } - if ((sp37 & 2) != 0) { + if (sp37 & 2) { return 0xF; } From b0c4073267b8a97b8fdf09a44287c64ad6e71fb9 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 01:03:04 +1100 Subject: [PATCH 012/130] Really close to matching osVoiceStopReadData --- src/libultra/voice/voicestopread.c | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 16ecddef8..d7dad3291 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -1,4 +1,52 @@ #include "global.h" // Forcibly stops voice recognition processing by the Voice Recognition System +#ifdef NON_EQUIVALENT +s32 osVoiceStopReadData(OSVoiceHandle* hd) { + s32 i; + s32 errorCode; + u8 sp3F; + s32 sp38; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp3F); + if (errorCode != 0) { + return errorCode; + } + + if (sp3F & 2) { + return 0xF; + } + + if (hd->mode == 0) { + return 5; + } + + sp38 = 0x700; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp38); + + if (errorCode == 0) { + for (i = 0; i < 20; i++) { + errorCode = __osVoiceCheckResult(hd, &sp3F); + if (errorCode & 0xFF00) { + if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) { + if (hd) {} + errorCode = 0; + hd->mode = 0; + } else { + errorCode = 5; + } + } else { + hd->mode = 0; + } + + if (errorCode != 0xF) { + break; + } + } + } + + return errorCode; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/boot/voicestopread/osVoiceStopReadData.s") +#endif From 1647f42c3dc36cf2eef2cd1f75dcd678a306c025 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 19:13:20 +1100 Subject: [PATCH 013/130] Progress on voicecheckword --- src/libultra/voice/voicecheckword.c | 101 ++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 4da8d5a00..78b835579 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -1,4 +1,105 @@ #include "global.h" // Checks whether or not a word can be registered in the dictionary +#ifdef NON_EQUIVALENT +s32 osVoiceCheckWord(u8* word) { + s32 i; + s32 errorCode = 0; + u16 currentWord; // currentLetter? currentSyllable? + u16 new_var; + + for (i = 0; word[i] != 0; i += 2) { + new_var = word[i]; // Fake? But helps? + currentWord = word[i + 1] + (new_var << 8); + if (((currentWord != 0x815B) && (currentWord < 0x829F)) || + ((currentWord >= 0x82F2) && (currentWord < 0x8340)) || (currentWord == 0x837F) || (currentWord >= 0x8397)) { + errorCode = 0xE; + } else if ((i == 0) && ((currentWord == 0x815B) || (currentWord == 0x82F1) || (currentWord == 0x82C1) || + (currentWord == 0x82EC) || (currentWord == 0x8393) || (currentWord == 0x8362) || + (currentWord == 0x838E) || (currentWord == 0x8395) || (currentWord == 0x8396))) { + errorCode = 0xE; + } else if (((currentWord == 0x829F) || (currentWord == 0x8340)) && (currentWord != 0x82D3) && + (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A1) || (currentWord == 0x8342)) && (currentWord != 0x82A4) && + (currentWord != 0x82C4) && (currentWord != 0x82C5) && (currentWord != 0x82D3) && + (currentWord != 0x8345) && (currentWord != 0x8365) && (currentWord != 0x8366) && + (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A3) || (currentWord == 0x8344)) && (currentWord != 0x82C6) && + (currentWord != 0x82C7) && (currentWord != 0x82D3) && (currentWord != 0x8367) && + (currentWord != 0x8368) && (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A5) || (currentWord == 0x8346)) && (currentWord != 0x82A4) && + (currentWord != 0x82B5) && (currentWord != 0x82B6) && (currentWord != 0x82BF) && + (currentWord != 0x82C0) && (currentWord != 0x82C2) && (currentWord != 0x82D3) && + (currentWord != 0x8345) && (currentWord != 0x8356) && (currentWord != 0x8357) && + (currentWord != 0x8360) && (currentWord != 0x8361) && (currentWord != 0x8363) && + (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A7) || (currentWord == 0x8348)) && (currentWord != 0x82A4) && + (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8374) && + (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82E1) || (currentWord == 0x82E3) || (currentWord == 0x82E5) || + (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387)) && + (currentWord != 0x82AB) && (currentWord != 0x82B5) && (currentWord != 0x82BF) && + (currentWord != 0x82C9) && (currentWord != 0x82D0) && (currentWord != 0x82DD) && + (currentWord != 0x82E8) && (currentWord != 0x82AC) && (currentWord != 0x82B6) && + (currentWord != 0x82C0) && (currentWord != 0x82D1) && (currentWord != 0x82D2) && + (currentWord != 0x834C) && (currentWord != 0x8356) && (currentWord != 0x8360) && + (currentWord != 0x836A) && (currentWord != 0x8371) && (currentWord != 0x837E) && + (currentWord != 0x838A) && (currentWord != 0x834D) && (currentWord != 0x8357) && + (currentWord != 0x8361) && (currentWord != 0x8372) && (currentWord != 0x8373) && + (currentWord != 0x8394)) { + errorCode = 0xE; + } else if ((currentWord == 0x815B) && ((currentWord == 0x82F1) || (currentWord == 0x82C1) || + (currentWord == 0x8393) || (currentWord == 0x8362))) { + errorCode = 0xE; + } else if (((currentWord == 0x82F1) || (currentWord == 0x8393)) && + ((currentWord == 0x82F1) || (currentWord == 0x8393))) { + errorCode = 0xE; + } else if (((currentWord == 0x82C1) || (currentWord == 0x8362)) && + ((currentWord == 0x815B) || (currentWord == 0x82A0) || (currentWord == 0x82A2) || + (currentWord == 0x82A4) || (currentWord == 0x82A6) || (currentWord == 0x82A8) || + (currentWord == 0x82C8) || (currentWord == 0x82C9) || (currentWord == 0x82CA) || + (currentWord == 0x82CB) || (currentWord == 0x82CC) || (currentWord == 0x82DC) || + (currentWord == 0x82DD) || (currentWord == 0x82DE) || (currentWord == 0x82DF) || + (currentWord == 0x82E0) || (currentWord == 0x82E2) || (currentWord == 0x82E4) || + (currentWord == 0x82E6) || (currentWord == 0x82E7) || (currentWord == 0x82E8) || + (currentWord == 0x82E9) || (currentWord == 0x82EA) || (currentWord == 0x82EB) || + (currentWord == 0x82ED) || (currentWord == 0x82EE) || (currentWord == 0x82EF) || + (currentWord == 0x82F0) || (currentWord == 0x82F1) || (currentWord == 0x829F) || + (currentWord == 0x82A1) || (currentWord == 0x82A3) || (currentWord == 0x82A5) || + (currentWord == 0x82A7) || (currentWord == 0x82E1) || (currentWord == 0x82E3) || + (currentWord == 0x82E5) || (currentWord == 0x82C1) || (currentWord == 0x82EC) || + (currentWord == 0x8341) || (currentWord == 0x8343) || (currentWord == 0x8345) || + (currentWord == 0x8347) || (currentWord == 0x8349) || (currentWord == 0x8369) || + (currentWord == 0x836A) || (currentWord == 0x836B) || (currentWord == 0x836C) || + (currentWord == 0x836D) || (currentWord == 0x837D) || (currentWord == 0x837E) || + (currentWord == 0x8380) || (currentWord == 0x8381) || (currentWord == 0x8382) || + (currentWord == 0x8384) || (currentWord == 0x8386) || (currentWord == 0x8388) || + (currentWord == 0x8389) || (currentWord == 0x838A) || (currentWord == 0x838B) || + (currentWord == 0x838C) || (currentWord == 0x838D) || (currentWord == 0x838F) || + (currentWord == 0x8390) || (currentWord == 0x8391) || (currentWord == 0x8392) || + (currentWord == 0x8393) || (currentWord == 0x8340) || (currentWord == 0x8342) || + (currentWord == 0x8344) || (currentWord == 0x8346) || (currentWord == 0x8348) || + (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387) || + (currentWord == 0x8362) || (currentWord == 0x838E))) { + errorCode = 0xE; + } + + if (errorCode != 0) { + return errorCode; + } + } + + if ((currentWord == 0x82C1) || (currentWord == 0x8362)) { + errorCode = 0xE; + } + + return errorCode; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckword/osVoiceCheckWord.s") +#endif From 5459a9e781791eea6138ac79a22ff3a49b5aa62a Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 00:06:50 +1100 Subject: [PATCH 014/130] Match osVoiceSetWord --- include/functions.h | 2 +- src/libultra/voice/voicesetword.c | 58 ++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index 5bfe48049..f05849d92 100644 --- a/include/functions.h +++ b/include/functions.h @@ -386,7 +386,7 @@ s32 __osContChannelReset(OSMesgQueue* mq, s32 count); s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); -// void __osVoiceContWrite20(void); +s32 __osVoiceContWrite20(OSMesgQueue*, s32, u8, u8*); u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); OSThread* __osGetActiveQueue(void); diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index dbc1a6df6..83cf97516 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -1,4 +1,60 @@ #include "global.h" // Registers words to the Voice Recognition System dictionary -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicesetword/osVoiceSetWord.s") +s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { + s32 i; + s32 sp50; + s32 errorCode; + u8 sp4B; + u8 sp20[0x28]; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp4B); + if (errorCode != 0) { + return errorCode; + } + + if (sp4B & 2) { + return 0xF; + } + + sp50 = 0; + + while (word[sp50] != 0) { + sp50 += 2; + } + + bzero(&sp20, 0x28); + + for (i = 0; i < sp50; i += 2) { + sp20[0x27 - sp50 + i] = word[i]; + sp20[0x27 - sp50 + i - 1] = word[i + 1]; + } + + sp20[0x27 - i - 5] = 3; + + if (sp50 >= 0xF) { + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20); + if (errorCode != 0) { + return errorCode; + } + } + + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20[0x14]); + if (errorCode != 0) { + return errorCode; + } + + errorCode = __osVoiceCheckResult(hd, &sp4B); + + if (errorCode != 0) { + if (errorCode & 0x100) { + errorCode = 0xD; + } else if (errorCode & 0x200) { + errorCode = 0xE; + } else if (errorCode & 0xFF00) { + errorCode = 5; + } + } + + return errorCode; +} From 6775824c4d71e407dcf98d4a096711a30db32cb9 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 10:50:33 +1100 Subject: [PATCH 015/130] Add error codes --- src/libultra/voice/voicecheckresult.c | 4 ++-- src/libultra/voice/voicecheckword.c | 24 ++++++++++---------- src/libultra/voice/voicecleardictionary.c | 6 ++--- src/libultra/voice/voicecontrolgain.c | 2 +- src/libultra/voice/voicegetreaddata.c | 14 ++++++------ src/libultra/voice/voicegetstatus.c | 27 ++++++++++++----------- src/libultra/voice/voiceinit.c | 16 +++++++------- src/libultra/voice/voicesetword.c | 16 +++++++------- src/libultra/voice/voicestartreaddata.c | 6 ++--- src/libultra/voice/voicestopread.c | 8 +++---- 10 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index 97af48094..907376734 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -6,12 +6,12 @@ s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { if (errorCode = __osVoiceGetStatus(hd->mq, hd->port, status), errorCode == 0) { if (*status & 1) { - errorCode = 0xF; + errorCode = CONT_ERR_VOICE_NO_RESPONSE; } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), errorCode == 0) { hd->status = sp20[0] & 7; if (sp20[0] & 0x40) { - errorCode = 0xF; + errorCode = CONT_ERR_VOICE_NO_RESPONSE; } else { errorCode = sp20[1] << 8; } diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 78b835579..f7c640760 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -13,34 +13,34 @@ s32 osVoiceCheckWord(u8* word) { currentWord = word[i + 1] + (new_var << 8); if (((currentWord != 0x815B) && (currentWord < 0x829F)) || ((currentWord >= 0x82F2) && (currentWord < 0x8340)) || (currentWord == 0x837F) || (currentWord >= 0x8397)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if ((i == 0) && ((currentWord == 0x815B) || (currentWord == 0x82F1) || (currentWord == 0x82C1) || (currentWord == 0x82EC) || (currentWord == 0x8393) || (currentWord == 0x8362) || (currentWord == 0x838E) || (currentWord == 0x8395) || (currentWord == 0x8396))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x829F) || (currentWord == 0x8340)) && (currentWord != 0x82D3) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A1) || (currentWord == 0x8342)) && (currentWord != 0x82A4) && (currentWord != 0x82C4) && (currentWord != 0x82C5) && (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8365) && (currentWord != 0x8366) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A3) || (currentWord == 0x8344)) && (currentWord != 0x82C6) && (currentWord != 0x82C7) && (currentWord != 0x82D3) && (currentWord != 0x8367) && (currentWord != 0x8368) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A5) || (currentWord == 0x8346)) && (currentWord != 0x82A4) && (currentWord != 0x82B5) && (currentWord != 0x82B6) && (currentWord != 0x82BF) && (currentWord != 0x82C0) && (currentWord != 0x82C2) && (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8356) && (currentWord != 0x8357) && (currentWord != 0x8360) && (currentWord != 0x8361) && (currentWord != 0x8363) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A7) || (currentWord == 0x8348)) && (currentWord != 0x82A4) && (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82E1) || (currentWord == 0x82E3) || (currentWord == 0x82E5) || (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387)) && (currentWord != 0x82AB) && (currentWord != 0x82B5) && (currentWord != 0x82BF) && @@ -52,13 +52,13 @@ s32 osVoiceCheckWord(u8* word) { (currentWord != 0x838A) && (currentWord != 0x834D) && (currentWord != 0x8357) && (currentWord != 0x8361) && (currentWord != 0x8372) && (currentWord != 0x8373) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if ((currentWord == 0x815B) && ((currentWord == 0x82F1) || (currentWord == 0x82C1) || (currentWord == 0x8393) || (currentWord == 0x8362))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82F1) || (currentWord == 0x8393)) && ((currentWord == 0x82F1) || (currentWord == 0x8393))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82C1) || (currentWord == 0x8362)) && ((currentWord == 0x815B) || (currentWord == 0x82A0) || (currentWord == 0x82A2) || (currentWord == 0x82A4) || (currentWord == 0x82A6) || (currentWord == 0x82A8) || @@ -86,7 +86,7 @@ s32 osVoiceCheckWord(u8* word) { (currentWord == 0x8344) || (currentWord == 0x8346) || (currentWord == 0x8348) || (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387) || (currentWord == 0x8362) || (currentWord == 0x838E))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } if (errorCode != 0) { @@ -95,7 +95,7 @@ s32 osVoiceCheckWord(u8* word) { } if ((currentWord == 0x82C1) || (currentWord == 0x8362)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } return errorCode; diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 92114809d..9bb490a97 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -14,7 +14,7 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { registration_word = &sp24; if (status & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } sp24 = 0x2000000; @@ -26,8 +26,8 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { } errorCode = __osVoiceCheckResult(hd, &status); - if ((errorCode & 0xFF00) != 0) { - errorCode = 5; + if (errorCode & 0xFF00) { + errorCode = CONT_ERR_INVALID; } return errorCode; diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index 251dc1144..eb896bb72 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -27,7 +27,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { if (0) { dummy: - return 5; + return CONT_ERR_INVALID; } errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index c202ad27d..e94202aca 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -17,7 +17,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (sp38[39] & 1) { - return 0xC; + return CONT_ERR_NOT_READY; } errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); @@ -29,7 +29,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { hd->status = temp_t9; D_8009CF60 = temp_t9; if ((temp_t9 != 0) && (temp_t9 != 7)) { - return 0xC; + return CONT_ERR_NOT_READY; } case 2: hd->mode = 2; @@ -41,7 +41,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { if (0) {} if (sp38[39] & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } sp38[0] = 0x600; // Not reading in correctly since 0x600 is out-of-range for u8 @@ -59,7 +59,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (sp38[39] & 1) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, sp38); @@ -96,7 +96,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (sp38[39] & 1) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); @@ -106,12 +106,12 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { hd->status = sp38[0] & 7; if ((sp38[0] & 7) != 0) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } break; default: - return 5; + return CONT_ERR_INVALID; } hd->mode = 0; return errorCode; diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index 1711eb56d..7946b4904 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -3,7 +3,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { __OSContRequestHeaderAligned header; - s32 ret = 0; + s32 errorCode = 0; s32 i; u8* ptr = (u8*)&__osContPifRam; s32 var = 2; @@ -11,7 +11,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { __osSiGetAccess(); do { - if (ret != CONT_ERR_CONTRFAIL) { + if (errorCode != CONT_ERR_CONTRFAIL) { __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; for (i = 0; i < port; i++, *ptr++ = 0) { @@ -25,34 +25,35 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { *ptr = CONT_CMD_END; __osContLastCmd = CONT_CMD_END; - ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam); + errorCode = __osSiRawStartDma(OS_WRITE, &__osContPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - ret = __osSiRawStartDma(OS_READ, &__osContPifRam); + errorCode = __osSiRawStartDma(OS_READ, &__osContPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ptr = (u8*)&__osContPifRam + port; header = *((__OSContRequestHeaderAligned*)ptr); - ret = (u8)((header.rxsize & 0xC0) >> 4); + errorCode = (u8)((header.rxsize & 0xC0) >> 4); *status = header.status; - if (ret == 0) { + if (errorCode == 0) { if (header.typeh == 0 && header.typel == 1) { if (header.status & 4) { - ret = CONT_ERR_CONTRFAIL; + errorCode = CONT_ERR_CONTRFAIL; } } else { - ret = CONT_ERR_DEVICE; + errorCode = CONT_ERR_DEVICE; } - } else if (ret & CONT_NO_RESPONSE_ERROR) { - ret = CONT_ERR_NO_CONTROLLER; + } else if (errorCode & CONT_NO_RESPONSE_ERROR) { + errorCode = CONT_ERR_NO_CONTROLLER; } else { - ret = CONT_ERR_CONTRFAIL; + errorCode = CONT_ERR_CONTRFAIL; } - } while ((ret == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); __osSiRelAccess(); - return (ret); + + return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 54e13fa4c..7cc4f817a 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -7,7 +7,7 @@ extern u8 D_80097FA5; s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { s32 errorCode; u8* phi_s0; - u8 sp37 = 0; + u8 status = 0; s32 sp30; s32 pad; @@ -15,13 +15,13 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { hd->mq = siMessageQ; hd->mode = 0; - errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + errorCode = __osVoiceGetStatus(siMessageQ, channel, &status); if (errorCode != 0) { return errorCode; } if (__osContChannelReset(siMessageQ, channel) != 0) { - return 4; + return CONT_ERR_CONTRFAIL; } for (phi_s0 = &D_80097FA0;;) { @@ -33,12 +33,12 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { } if (phi_s0 == &D_80097FA5) { - errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + errorCode = __osVoiceGetStatus(siMessageQ, channel, &status); if (errorCode != 0) { return errorCode; } - if (sp37 & 2) { - return 0xF; + if (status & 2) { + return CONT_ERR_VOICE_NO_RESPONSE; } sp30 = 0x100; @@ -47,9 +47,9 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { return errorCode; } - errorCode = __osVoiceCheckResult(hd, &sp37); + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } return errorCode; diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index 83cf97516..3c927740c 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -5,16 +5,16 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { s32 i; s32 sp50; s32 errorCode; - u8 sp4B; + u8 status; u8 sp20[0x28]; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp4B); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { return errorCode; } - if (sp4B & 2) { - return 0xF; + if (status & 2) { + return CONT_ERR_VOICE_NO_RESPONSE; } sp50 = 0; @@ -44,15 +44,15 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { return errorCode; } - errorCode = __osVoiceCheckResult(hd, &sp4B); + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode != 0) { if (errorCode & 0x100) { - errorCode = 0xD; + errorCode = CONT_ERR_VOICE_MEMORY; } else if (errorCode & 0x200) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (errorCode & 0xFF00) { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } } diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 88c77dc2c..5e65d3ce4 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -12,11 +12,11 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } if (status & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } if (hd->mode != 0) { - return 5; + return CONT_ERR_INVALID; } sp24 = 0x5000000; @@ -26,7 +26,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } else { hd->mode = 1; } diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index d7dad3291..4c9a1dc88 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -14,11 +14,11 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { } if (sp3F & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } if (hd->mode == 0) { - return 5; + return CONT_ERR_INVALID; } sp38 = 0x700; @@ -33,13 +33,13 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { errorCode = 0; hd->mode = 0; } else { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } } else { hd->mode = 0; } - if (errorCode != 0xF) { + if (errorCode != CONT_ERR_VOICE_NO_RESPONSE) { break; } } From e8deb9eb8e4a5ff14e03d7cca1b9cf04de050dfe Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 23:28:03 +1100 Subject: [PATCH 016/130] Matched __osVoiceContRead2... Somehow... --- include/functions.h | 2 +- src/libultra/voice/voicecontread2.c | 68 ++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index a2a42e6d3..ab8384a06 100644 --- a/include/functions.h +++ b/include/functions.h @@ -351,7 +351,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words); void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, s32, u8 dst[2]); +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16, u8 dst[2]); u8 __osVoiceContDataCrc(u8* data, u32 arg1); const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index 38350ee5f..8e70d4dee 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -1,3 +1,69 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontread2/__osVoiceContRead2.s") +extern s32 D_80097FB0; + +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { + u8* ptr; + u8 sp63; + s32 errorCode; + s32 var = 2; + s32 i; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xB) || (port != D_80097FB0)) { + __osContLastCmd = 0xB; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = 1; + + ptr[0] = 0xFF; + ptr[1] = 3; + ptr[2] = 3; + ptr[3] = 0xB; + ptr[8] = 0xFF; + ptr[9] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[8] != __osVoiceContDataCrc(&ptr[6], 2)) { + errorCode = __osVoiceGetStatus(mq, port, &sp63); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } else { + bcopy(&ptr[6], dst, 2); + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} + From 7b95bd11d14025d1a420e1cdcb7184b4b93b9ae7 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 23:34:44 +1100 Subject: [PATCH 017/130] Add small amount of docs --- src/libultra/io/contreaddata.c | 4 ++-- src/libultra/io/controller.c | 4 ++-- src/libultra/io/motor.c | 2 +- src/libultra/voice/voicecontread2.c | 10 +++++----- src/libultra/voice/voicegetstatus.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 035663486..8fb925876 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -43,11 +43,11 @@ void __osPackReadData() { int i; ptr = (u8*)__osContPifRam.ramarray; - for (i = 0; i < 0xF; i++) { + for (i = 0; i < ARRAY_COUNT(__osContPifRam.ramarray); i++) { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; readformat.dummy = 255; readformat.txsize = 1; readformat.rxsize = 4; diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index 21e376d58..548d3e257 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -74,11 +74,11 @@ void __osPackRequestData(u8 cmd) { __OSContRequesFormat requestformat; int i; - for (i = 0; i < 0xF; i++) { + for (i = 0; i < ARRAY_COUNT(__osContPifRam.ramarray); i++) { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; ptr = (u8*)__osContPifRam.ramarray; requestformat.dummy = 255; requestformat.txsize = 1; diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index 4c0bfb67a..9db4bdb4c 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -20,7 +20,7 @@ s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { } __osSiGetAccess(); - osPifBuffers[pfs->channel].pifstatus = 1; + osPifBuffers[pfs->channel].pifstatus = CONT_CMD_READ_BUTTON; buf += pfs->channel; for (i = 0; i < BLOCKSIZE; i++) { ((__OSContRamReadFormat*)buf)->data[i] = vibrate; diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index 8e70d4dee..e1d260372 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -4,9 +4,9 @@ extern s32 D_80097FB0; s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { u8* ptr; - u8 sp63; + u8 status; s32 errorCode; - s32 var = 2; + s32 retryCount = 2; s32 i; __osSiGetAccess(); @@ -23,7 +23,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { ; } - __osPfsPifRam.pifstatus = 1; + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; ptr[0] = 0xFF; ptr[1] = 3; @@ -47,7 +47,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { if (errorCode == 0) { if (ptr[8] != __osVoiceContDataCrc(&ptr[6], 2)) { - errorCode = __osVoiceGetStatus(mq, port, &sp63); + errorCode = __osVoiceGetStatus(mq, port, &status); if (errorCode != 0) { break; } @@ -60,7 +60,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { errorCode = CONT_ERR_NO_CONTROLLER; } - } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); __osSiRelAccess(); diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index 7946b4904..e11dcb954 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -6,7 +6,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { s32 errorCode = 0; s32 i; u8* ptr = (u8*)&__osContPifRam; - s32 var = 2; + s32 retryCount = 2; __osSiGetAccess(); @@ -51,7 +51,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { } else { errorCode = CONT_ERR_CONTRFAIL; } - } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); __osSiRelAccess(); From 905584f8430bb57e3f026fad294d58f6cd82d554 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 23:47:36 +1100 Subject: [PATCH 018/130] __osVoiceContRead36 was basically identical from __osVoiceContRead2 --- include/functions.h | 4 +- src/libultra/voice/voicecontread2.c | 2 +- src/libultra/voice/voicecontread36.c | 67 +++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/include/functions.h b/include/functions.h index ab8384a06..0043a3544 100644 --- a/include/functions.h +++ b/include/functions.h @@ -351,7 +351,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words); void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16, u8 dst[2]); +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]); u8 __osVoiceContDataCrc(u8* data, u32 arg1); const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); @@ -363,7 +363,7 @@ void __osTimerServicesInit(void); void __osTimerInterrupt(void); void __osSetTimerIntr(OSTime tim); OSTime __osInsertTimer(OSTimer* t); -s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, s32, u8*); +s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]); s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); // void guMtxIdent(void); diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index e1d260372..64ac40605 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -2,7 +2,7 @@ extern s32 D_80097FB0; -s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { u8* ptr; u8 status; s32 errorCode; diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index 38f3fe2f0..081b9a534 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -1,3 +1,68 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontread36/__osVoiceContRead36.s") +extern s32 D_80097FB0; + +s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { + u8* ptr; + u8 status; + s32 errorCode; + s32 retryCount = 2; + s32 i; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 9) || (port != D_80097FB0)) { + __osContLastCmd = 9; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 0xFF; + ptr[1] = 3; + ptr[2] = 0x25; + ptr[3] = 9; + ptr[0x2A] = 0xFF; + ptr[0x2B] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[0x2A] != __osVoiceContDataCrc(&ptr[6], 36)) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } else { + bcopy(&ptr[6], dst, 36); + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} From 1329f3aeaa71452c56ea222e26f32c0899d6188e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 00:03:48 +1100 Subject: [PATCH 019/130] docs, but maybe a little carried away --- include/variables.h | 2 +- src/boot_O2_g3/fault.c | 2 +- src/boot_O2_g3/idle.c | 2 +- src/boot_O2_g3/irqmgr.c | 10 +++++----- src/boot_O2_g3/z_std_dma.c | 4 ++-- src/code/z_vr_box.c | 6 +++--- src/libultra/io/contquery.c | 4 ++-- src/libultra/io/contreaddata.c | 6 +++--- src/libultra/io/controller.c | 8 ++++---- src/libultra/io/contsetch.c | 2 +- src/libultra/io/epidma.c | 4 ++-- src/libultra/io/piacs.c | 2 +- src/libultra/io/siacs.c | 6 +++--- src/libultra/os/seteventmesg.c | 2 +- src/libultra/os/timerintr.c | 2 +- src/libultra/voice/voicecontread2.c | 2 -- src/libultra/voice/voicecontread36.c | 2 -- 17 files changed, 31 insertions(+), 35 deletions(-) diff --git a/include/variables.h b/include/variables.h index 55fe64c49..d3ecb8bb1 100644 --- a/include/variables.h +++ b/include/variables.h @@ -78,7 +78,7 @@ extern float D_80097F90; // extern UNK_TYPE1 D_80097FA0; // extern UNK_TYPE1 D_80097FA4; // extern UNK_TYPE1 D_80097FA5; -// extern UNK_TYPE4 D_80097FB0; +extern s32 D_80097FB0; extern OSViMode osViModeNtscLan1; extern OSViMode osViModeMpalLan1; extern __OSViContext D_80098060[2]; diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index b32b5aa98..175fbbef7 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -802,7 +802,7 @@ void Fault_ThreadEntry(void* arg) { osSetEventMesg(12, &sFaultContext->queue, (OSMesg)2); while (1) { do { - osRecvMesg(&sFaultContext->queue, &msg, 1); + osRecvMesg(&sFaultContext->queue, &msg, OS_MESG_BLOCK); if (msg == (OSMesg)1) { sFaultContext->msgId = 1; diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 4be8a1094..4f9146530 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -62,7 +62,7 @@ void Idle_InitCodeAndMemory(void) { SEGMENT_ROM_END(code) - SEGMENT_ROM_START(code), 0, &queue, 0); Idle_InitScreen(); Idle_InitMemory(); - osRecvMesg(&queue, NULL, 1); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); sDmaMgrDmaBuffSize = oldSize; diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index 3f4ca04ae..696d114c4 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -17,10 +17,10 @@ void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* param_2, OSMesgQueue* param_ osSetIntMask(saveMask); if (irqmgr->prenmiStage > 0) { - osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, 0); + osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK); } if (irqmgr->prenmiStage > 1) { - osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, 0); + osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); } } @@ -54,7 +54,7 @@ void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg) { IrqMgrClient* iter = irqmgr->callbacks; while (iter != NULL) { - osSendMesg(iter->queue, msg, 0); + osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK); iter = iter->next; } } @@ -64,7 +64,7 @@ void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg) { while (iter != NULL) { if (iter->queue->validCount < iter->queue->msgCount) { - osSendMesg(iter->queue, msg, 0); + osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK); } iter = iter->next; } @@ -130,7 +130,7 @@ void IrqMgr_ThreadEntry(IrqMgr* irqmgr) { ; } - osRecvMesg(&irqmgr->irqQueue, (OSMesg*)&interrupt, 1); + osRecvMesg(&irqmgr->irqQueue, (OSMesg*)&interrupt, OS_MESG_BLOCK); switch (interrupt) { case 0x29A: IrqMgr_HandleRetrace(irqmgr); diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 2903b488f..55fdbce7a 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -31,7 +31,7 @@ s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { goto END; } - osRecvMesg(&queue, NULL, 1); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); size -= buffSize; rom = rom + buffSize; ram = (u8*)ram + buffSize; @@ -47,7 +47,7 @@ s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { goto END; } - osRecvMesg(&queue, NULL, 1); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); osInvalDCache(ram, size); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 9e949beac..724bc5971 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -103,7 +103,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); } - osRecvMesg(&skyboxCtx->loadQueue, NULL, 1); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); if (globalCtx->envCtx.unk_11 == 0) { @@ -120,7 +120,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); } - osRecvMesg(&skyboxCtx->loadQueue, NULL, 1); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); size = SEGMENT_ROM_SIZE(d2_fine_pal_static); @@ -129,7 +129,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy DmaMgr_SendRequestImpl(&skyboxCtx->unk1C8, skyboxCtx->skyboxPaletteStaticSegment, SEGMENT_ROM_START(d2_fine_pal_static), size, 0, &skyboxCtx->loadQueue, NULL); - osRecvMesg(&skyboxCtx->loadQueue, NULL, 1); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); } } diff --git a/src/libultra/io/contquery.c b/src/libultra/io/contquery.c index 5c351241a..cfdf9449f 100644 --- a/src/libultra/io/contquery.c +++ b/src/libultra/io/contquery.c @@ -7,11 +7,11 @@ s32 osContStartQuery(OSMesgQueue* mq) { if (__osContLastCmd != 0) { __osPackRequestData(0); - __osSiRawStartDma(1, &__osContPifRam); + __osSiRawStartDma(OS_WRITE, &__osContPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - ret = __osSiRawStartDma(0, &__osContPifRam); + ret = __osSiRawStartDma(OS_READ, &__osContPifRam); __osContLastCmd = 0; diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 8fb925876..d2a5762f9 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -8,11 +8,11 @@ s32 osContStartReadData(OSMesgQueue* mq) { if (__osContLastCmd != 1) { __osPackReadData(); - __osSiRawStartDma(1, &__osContPifRam); - osRecvMesg(mq, NULL, 1); + __osSiRawStartDma(OS_WRITE, &__osContPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - ret = __osSiRawStartDma(0, &__osContPifRam); + ret = __osSiRawStartDma(OS_READ, &__osContPifRam); __osContLastCmd = 1; __osSiRelAccess(); diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index 548d3e257..e3064718f 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -34,11 +34,11 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) { __osPackRequestData(0); - ret = __osSiRawStartDma(1, &__osContPifRam); - osRecvMesg(mq, &dummy, 1); + ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam); + osRecvMesg(mq, &dummy, OS_MESG_BLOCK); - ret = __osSiRawStartDma(0, &__osContPifRam); - osRecvMesg(mq, &dummy, 1); + ret = __osSiRawStartDma(OS_READ, &__osContPifRam); + osRecvMesg(mq, &dummy, OS_MESG_BLOCK); __osContGetInitData(bitpattern, data); __osContLastCmd = 0; diff --git a/src/libultra/io/contsetch.c b/src/libultra/io/contsetch.c index bd1c96698..654d78e2a 100644 --- a/src/libultra/io/contsetch.c +++ b/src/libultra/io/contsetch.c @@ -8,7 +8,7 @@ s32 osContSetCh(u8 ch) { } else { __osMaxControllers = ch; } - __osContLastCmd = -2; + __osContLastCmd = CONT_CMD_END; __osSiRelAccess(); return 0; diff --git a/src/libultra/io/epidma.c b/src/libultra/io/epidma.c index d3e0e36d2..0b8c847d6 100644 --- a/src/libultra/io/epidma.c +++ b/src/libultra/io/epidma.c @@ -16,9 +16,9 @@ s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { } if (mb->hdr.pri == 1) { - result = osJamMesg(osPiGetCmdQueue(), mb, 0); + result = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); } else { - result = osSendMesg(osPiGetCmdQueue(), mb, 0); + result = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); } return result; } diff --git a/src/libultra/io/piacs.c b/src/libultra/io/piacs.c index 8e6f830c0..9689aaf67 100644 --- a/src/libultra/io/piacs.c +++ b/src/libultra/io/piacs.c @@ -8,7 +8,7 @@ OSMesgQueue __osPiAccessQueue; void __osPiCreateAccessQueue(void) { __osPiAccessQueueEnabled = 1; osCreateMesgQueue(&__osPiAccessQueue, D_8009E3F0, 1); - osSendMesg(&__osPiAccessQueue, NULL, 0); + osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osPiGetAccess(void) { diff --git a/src/libultra/io/siacs.c b/src/libultra/io/siacs.c index 590f048ad..5bddc63c8 100644 --- a/src/libultra/io/siacs.c +++ b/src/libultra/io/siacs.c @@ -8,7 +8,7 @@ OSMesgQueue __osSiAccessQueue; void __osSiCreateAccessQueue() { __osSiAccessQueueEnabled = 1; osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, 1); - osSendMesg(&__osSiAccessQueue, NULL, 0); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osSiGetAccess(void) { @@ -16,9 +16,9 @@ void __osSiGetAccess(void) { if (!__osSiAccessQueueEnabled) { __osSiCreateAccessQueue(); } - osRecvMesg(&__osSiAccessQueue, &dummyMesg, 1); + osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK); } void __osSiRelAccess(void) { - osSendMesg(&__osSiAccessQueue, NULL, 0); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } diff --git a/src/libultra/os/seteventmesg.c b/src/libultra/os/seteventmesg.c index 723d1dafc..8be2ff9e2 100644 --- a/src/libultra/os/seteventmesg.c +++ b/src/libultra/os/seteventmesg.c @@ -17,7 +17,7 @@ void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m) { if (e == 14) { if (__osShutdown != 0 && D_80097F10 == 0) { - osSendMesg(mq, m, 0); + osSendMesg(mq, m, OS_MESG_NOBLOCK); } D_80097F10 = 1; } diff --git a/src/libultra/os/timerintr.c b/src/libultra/os/timerintr.c index 4c0083139..87f7129df 100644 --- a/src/libultra/os/timerintr.c +++ b/src/libultra/os/timerintr.c @@ -49,7 +49,7 @@ void __osTimerInterrupt(void) { t->next = NULL; t->prev = NULL; if (t->mq != NULL) { - osSendMesg(t->mq, t->msg, 0); + osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK); } if (t->interval != 0) { t->value = t->interval; diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index 64ac40605..b3a3a7fbc 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -1,7 +1,5 @@ #include "global.h" -extern s32 D_80097FB0; - s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { u8* ptr; u8 status; diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index 081b9a534..a3b330428 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -1,7 +1,5 @@ #include "global.h" -extern s32 D_80097FB0; - s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { u8* ptr; u8 status; From 83453f6cd31172185714e7cd5b2f09b3a81d5f6f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 00:21:29 +1100 Subject: [PATCH 020/130] Match __osVoiceContWrite4, Write is very similar to Read --- include/functions.h | 2 +- src/libultra/voice/voicecontread2.c | 4 +- src/libultra/voice/voicecontread36.c | 4 +- src/libultra/voice/voicecontwrite4.c | 67 +++++++++++++++++++++++++++- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0043a3544..87e3ba2be 100644 --- a/include/functions.h +++ b/include/functions.h @@ -470,7 +470,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); s32 osVoiceStartReadData(OSVoiceHandle* hd); u32* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* pc); -s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); u32 __osGetWatchLo(void); diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index b3a3a7fbc..ce52e2be0 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -1,9 +1,9 @@ #include "global.h" s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { - u8* ptr; - u8 status; s32 errorCode; + u8 status; + u8* ptr; s32 retryCount = 2; s32 i; diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index a3b330428..66067d239 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -1,9 +1,9 @@ #include "global.h" s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { - u8* ptr; - u8 status; s32 errorCode; + u8 status; + u8* ptr; s32 retryCount = 2; s32 i; diff --git a/src/libultra/voice/voicecontwrite4.c b/src/libultra/voice/voicecontwrite4.c index c28e2d762..09158c043 100644 --- a/src/libultra/voice/voicecontwrite4.c +++ b/src/libultra/voice/voicecontwrite4.c @@ -1,3 +1,68 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontwrite4/__osVoiceContWrite4.s") +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]) { + s32 errorCode; + u8 status; + u8* ptr; + s32 retryCount = 2; + s32 i; + u8 temp_s2; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xC) || (port != D_80097FB0)) { + __osContLastCmd = 0xC; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 0xFF; + ptr[1] = 7; + ptr[2] = 1; + ptr[3] = 0xC; + ptr[0xA] = 0xFF; + ptr[0xB] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + bcopy(dst, &ptr[6], 4); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + temp_s2 = __osVoiceContDataCrc(dst, 4); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[0xA] != (0, temp_s2)) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} From d9f034bc0e6f2e3fc499497bd39a2e21659f4395 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 00:27:16 +1100 Subject: [PATCH 021/130] Match __osVoiceContWrite20 from __osVoiceContWrite4, ez --- include/functions.h | 4 +- src/libultra/voice/voicecontwrite20.c | 67 ++++++++++++++++++++++++++- src/libultra/voice/voicecontwrite4.c | 4 +- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/include/functions.h b/include/functions.h index 87e3ba2be..2ed3bf63c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -386,7 +386,7 @@ s32 __osContChannelReset(OSMesgQueue* mq, s32 count); s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); -s32 __osVoiceContWrite20(OSMesgQueue*, s32, u8, u8*); +s32 __osVoiceContWrite20(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[20]); u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); OSThread* __osGetActiveQueue(void); @@ -470,7 +470,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); s32 osVoiceStartReadData(OSVoiceHandle* hd); u32* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* pc); -s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]); +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[4]); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); u32 __osGetWatchLo(void); diff --git a/src/libultra/voice/voicecontwrite20.c b/src/libultra/voice/voicecontwrite20.c index 5ca3560ed..9eba371c6 100644 --- a/src/libultra/voice/voicecontwrite20.c +++ b/src/libultra/voice/voicecontwrite20.c @@ -1,3 +1,68 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontwrite20/__osVoiceContWrite20.s") +s32 __osVoiceContWrite20(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[20]) { + s32 errorCode; + u8 status; + u8* ptr; + s32 retryCount = 2; + s32 i; + u8 temp_s2; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xA) || (port != D_80097FB0)) { + __osContLastCmd = 0xA; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 0xFF; + ptr[1] = 0x17; + ptr[2] = 1; + ptr[3] = 0xA; + ptr[0x1A] = 0xFF; + ptr[0x1B] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + bcopy(dst, &ptr[6], 20); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + temp_s2 = __osVoiceContDataCrc(dst, 20); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[0x1A] != ((void)0, temp_s2)) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} diff --git a/src/libultra/voice/voicecontwrite4.c b/src/libultra/voice/voicecontwrite4.c index 09158c043..8e1af6bd8 100644 --- a/src/libultra/voice/voicecontwrite4.c +++ b/src/libultra/voice/voicecontwrite4.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]) { +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[4]) { s32 errorCode; u8 status; u8* ptr; @@ -48,7 +48,7 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]) { errorCode = (ptr[2] & 0xC0) >> 4; if (errorCode == 0) { - if (ptr[0xA] != (0, temp_s2)) { + if (ptr[0xA] != ((void)0, temp_s2)) { errorCode = __osVoiceGetStatus(mq, port, &status); if (errorCode != 0) { break; From 16d91f5b710f2ba1507730d4974727d2e36bb9e2 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 11:56:25 +1100 Subject: [PATCH 022/130] Some docs --- src/libultra/voice/voicecheckresult.c | 10 ++++---- src/libultra/voice/voicecleardictionary.c | 31 +++++++++++++++++------ src/libultra/voice/voiceinit.c | 15 ++++++++--- src/libultra/voice/voicesetword.c | 14 +++++----- src/libultra/voice/voicestartreaddata.c | 15 ++++++++--- 5 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index 907376734..0d306884d 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -2,18 +2,18 @@ s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { s32 errorCode; - u8 sp20[2]; + u8 data[2]; if (errorCode = __osVoiceGetStatus(hd->mq, hd->port, status), errorCode == 0) { if (*status & 1) { errorCode = CONT_ERR_VOICE_NO_RESPONSE; - } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), errorCode == 0) { - hd->status = sp20[0] & 7; + } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, data), errorCode == 0) { + hd->status = data[0] & 7; - if (sp20[0] & 0x40) { + if (data[0] & 0x40) { errorCode = CONT_ERR_VOICE_NO_RESPONSE; } else { - errorCode = sp20[1] << 8; + errorCode = data[1] << 8; } } } diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 9bb490a97..719c7f0dc 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -1,10 +1,18 @@ #include "global.h" -// Initializes Voice Recognition System word registration dictionary -s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { - u8* registration_word; +/** + * Initializes Voice Recognition System word registration dictionary. + * + * The dictionary is initialized so that the specified "numWords" can be + * registered in the dictionary. 1-255 words can be registered in the dictionary. + * + * Words cannot be registered with the osVoiceSetWord before the dictionary + * is initialized with the osVoiceClearDictionary function + */ +s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords) { + u8* data; // u8 data[4]; u8 status; - s32 sp24; + u32 data32; // data[4] as u32 s32 errorCode; errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); @@ -12,15 +20,22 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { return errorCode; } - registration_word = &sp24; + data = (u8*)&data32; + if (status & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } - sp24 = 0x2000000; - registration_word[2] = words; + /** + * data[0] = 2 + * data[1] = 0 + * data[2] = numWords + * data[3] = 0 + */ + data32 = 0x2000000; + data[2] = numWords; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, data); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 7cc4f817a..8a1aeac11 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -8,7 +8,10 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { s32 errorCode; u8* phi_s0; u8 status = 0; - s32 sp30; + union { + s32 data32; + u8 data[4]; + } u; s32 pad; hd->port = channel; @@ -41,8 +44,14 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { return CONT_ERR_VOICE_NO_RESPONSE; } - sp30 = 0x100; - errorCode = __osVoiceContWrite4(siMessageQ, channel, 0, &sp30); + /** + * data[0] = 0 + * data[1] = 0 + * data[2] = 1 + * data[3] = 0 + */ + u.data32 = 0x100; + errorCode = __osVoiceContWrite4(siMessageQ, channel, 0, u.data); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index 3c927740c..a5ef50348 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -6,7 +6,7 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { s32 sp50; s32 errorCode; u8 status; - u8 sp20[0x28]; + u8 data[40]; errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { @@ -23,23 +23,23 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { sp50 += 2; } - bzero(&sp20, 0x28); + bzero(&data, 40); for (i = 0; i < sp50; i += 2) { - sp20[0x27 - sp50 + i] = word[i]; - sp20[0x27 - sp50 + i - 1] = word[i + 1]; + data[39 - sp50 + i] = word[i]; + data[39 - sp50 + i - 1] = word[i + 1]; } - sp20[0x27 - i - 5] = 3; + data[39 - i - 5] = 3; if (sp50 >= 0xF) { - errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20); + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data[0]); if (errorCode != 0) { return errorCode; } } - errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20[0x14]); + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data[20]); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 5e65d3ce4..07032ba67 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -4,7 +4,10 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { s32 errorCode; u8 status; - s32 sp24; + union { + s32 data32; + u8 data[4]; + } u; errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { @@ -19,8 +22,14 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { return CONT_ERR_INVALID; } - sp24 = 0x5000000; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + /** + * data[0] = 5 + * data[1] = 0 + * data[2] = 0 + * data[3] = 0 + */ + u.data32 = 0x5000000; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); if (errorCode == 0) { errorCode = __osVoiceCheckResult(hd, &status); From be44a62f0a0bbf8efa14024de859d064cae98f05 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 13:22:01 +1100 Subject: [PATCH 023/130] Improve osVoiceGetReadData --- src/libultra/voice/voicegetreaddata.c | 67 ++++++++++++++++----------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index e94202aca..03f21e506 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -6,26 +6,29 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { s32 errorCode; u8 new_var; u8 temp_t9; - u8 sp38[40]; + union { + u8 sp38[40]; + u32 sp38_32[10]; + } u; s32 i; switch (hd->mode) { case 1: - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (sp38[39] & 1) { + if (u.sp38[39] & 1) { return CONT_ERR_NOT_READY; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } - temp_t9 = sp38[0] & 7; + temp_t9 = u.sp38[0] & 7; hd->status = temp_t9; D_8009CF60 = temp_t9; if ((temp_t9 != 0) && (temp_t9 != 7)) { @@ -34,18 +37,17 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 2: hd->mode = 2; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (0) {} - if (sp38[39] & 2) { + if (u.sp38[39] & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } - sp38[0] = 0x600; // Not reading in correctly since 0x600 is out-of-range for u8 - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, sp38); + u.sp38_32[0] = 0x600; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } @@ -53,59 +55,72 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 3: hd->mode = 3; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (sp38[39] & 1) { + if (u.sp38[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, sp38); + errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } - result->warning = (sp38[5] << 8) + sp38[4]; - result->answer_num = sp38[6]; - result->voice_level = (sp38[9] << 8) + sp38[8]; - result->voice_sn = (sp38[11] << 8) + sp38[10]; - result->voice_time = (sp38[13] << 8) + sp38[12]; + result->warning = u.sp38[4] + (u.sp38[5] << 8); + result->answer_num = u.sp38[6]; + result->voice_level = u.sp38[8] + (u.sp38[9] << 8); + result->voice_sn = u.sp38[10] + (u.sp38[11] << 8); + result->voice_time = u.sp38[12] + (u.sp38[13] << 8); + // Issue here with for-loop unrolling new_var = 4; for (i = 0; i < 5; i++) { - result->answer[i] = (sp38[15 + new_var*i] << 8) + sp38[14 + new_var*i]; - result->distance[i] = (sp38[17 + new_var*i] << 8) + sp38[16 + new_var*i]; + result->answer[i] = u.sp38[14 + new_var*i] + (u.sp38[15 + new_var*i] << 8); + result->distance[i] = u.sp38[16 + new_var*i] + (u.sp38[17 + new_var*i] << 8); } + + // result->answer[0] = u.sp38[14] + (u.sp38[15] << 8); + // result->distance[0] = u.sp38[16] + (u.sp38[17] << 8); + // result->answer[1] = u.sp38[18] + (u.sp38[19] << 8); + // result->distance[1] = u.sp38[20] + (u.sp38[21] << 8); + // result->answer[2] = u.sp38[22] + (u.sp38[23] << 8); + // result->distance[2] = u.sp38[24] + (u.sp38[25] << 8); + // result->answer[3] = u.sp38[26] + (u.sp38[27] << 8); + // result->distance[3] = u.sp38[28] + (u.sp38[29] << 8); + // result->answer[4] = u.sp38[30] + (u.sp38[31] << 8); + // result->distance[4] = u.sp38[32] + (u.sp38[33] << 8); if (result->answer[0] == 0x7FFF) { result->answer_num = 0; } - hd->status = sp38[34] & 7; + // Issue here with regalloc + hd->status = u.sp38[34] & 7; if ((D_8009CF60 == 0) || (hd->status == 0)) { break; } case 4: hd->mode = 4; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (sp38[39] & 1) { + if (u.sp38[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } - hd->status = sp38[0] & 7; - if ((sp38[0] & 7) != 0) { + hd->status = u.sp38[0] & 7; + if (u.sp38[0] & 7) { return CONT_ERR_VOICE_NO_RESPONSE; } From 26cd8f9387d401a652d032fac4543e020a644722 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 14:01:29 +1100 Subject: [PATCH 024/130] Match osVoiceCheckWord --- src/libultra/voice/voicecheckword.c | 147 ++++++++++++++-------------- 1 file changed, 73 insertions(+), 74 deletions(-) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index f7c640760..84f8985ab 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -1,105 +1,104 @@ #include "global.h" // Checks whether or not a word can be registered in the dictionary -#ifdef NON_EQUIVALENT s32 osVoiceCheckWord(u8* word) { s32 i; s32 errorCode = 0; - u16 currentWord; // currentLetter? currentSyllable? - u16 new_var; + u16 currentSyllable; + u16 prevSyllable = 0; for (i = 0; word[i] != 0; i += 2) { - new_var = word[i]; // Fake? But helps? - currentWord = word[i + 1] + (new_var << 8); - if (((currentWord != 0x815B) && (currentWord < 0x829F)) || - ((currentWord >= 0x82F2) && (currentWord < 0x8340)) || (currentWord == 0x837F) || (currentWord >= 0x8397)) { + currentSyllable = (word[i] << 8) + word[i + 1]; + if (((currentSyllable != 0x815B) && (currentSyllable < 0x829F)) || + ((currentSyllable >= 0x82F2) && (currentSyllable < 0x8340)) || (currentSyllable == 0x837F) || + (currentSyllable >= 0x8397)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((i == 0) && ((currentWord == 0x815B) || (currentWord == 0x82F1) || (currentWord == 0x82C1) || - (currentWord == 0x82EC) || (currentWord == 0x8393) || (currentWord == 0x8362) || - (currentWord == 0x838E) || (currentWord == 0x8395) || (currentWord == 0x8396))) { + } else if ((i == 0) && + ((currentSyllable == 0x815B) || (currentSyllable == 0x82F1) || (currentSyllable == 0x82C1) || + (currentSyllable == 0x82EC) || (currentSyllable == 0x8393) || (currentSyllable == 0x8362) || + (currentSyllable == 0x838E) || (currentSyllable == 0x8395) || (currentSyllable == 0x8396))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x829F) || (currentWord == 0x8340)) && (currentWord != 0x82D3) && - (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x829F) || (currentSyllable == 0x8340)) && (prevSyllable != 0x82D3) && + (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A1) || (currentWord == 0x8342)) && (currentWord != 0x82A4) && - (currentWord != 0x82C4) && (currentWord != 0x82C5) && (currentWord != 0x82D3) && - (currentWord != 0x8345) && (currentWord != 0x8365) && (currentWord != 0x8366) && - (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A1) || (currentSyllable == 0x8342)) && (prevSyllable != 0x82A4) && + (prevSyllable != 0x82C4) && (prevSyllable != 0x82C5) && (prevSyllable != 0x82D3) && + (prevSyllable != 0x8345) && (prevSyllable != 0x8365) && (prevSyllable != 0x8366) && + (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A3) || (currentWord == 0x8344)) && (currentWord != 0x82C6) && - (currentWord != 0x82C7) && (currentWord != 0x82D3) && (currentWord != 0x8367) && - (currentWord != 0x8368) && (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A3) || (currentSyllable == 0x8344)) && (prevSyllable != 0x82C6) && + (prevSyllable != 0x82C7) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8367) && + (prevSyllable != 0x8368) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A5) || (currentWord == 0x8346)) && (currentWord != 0x82A4) && - (currentWord != 0x82B5) && (currentWord != 0x82B6) && (currentWord != 0x82BF) && - (currentWord != 0x82C0) && (currentWord != 0x82C2) && (currentWord != 0x82D3) && - (currentWord != 0x8345) && (currentWord != 0x8356) && (currentWord != 0x8357) && - (currentWord != 0x8360) && (currentWord != 0x8361) && (currentWord != 0x8363) && - (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A5) || (currentSyllable == 0x8346)) && (prevSyllable != 0x82A4) && + (prevSyllable != 0x82B5) && (prevSyllable != 0x82B6) && (prevSyllable != 0x82BF) && + (prevSyllable != 0x82C0) && (prevSyllable != 0x82C2) && (prevSyllable != 0x82D3) && + (prevSyllable != 0x8345) && (prevSyllable != 0x8356) && (prevSyllable != 0x8357) && + (prevSyllable != 0x8360) && (prevSyllable != 0x8361) && (prevSyllable != 0x8363) && + (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A7) || (currentWord == 0x8348)) && (currentWord != 0x82A4) && - (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8374) && - (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A7) || (currentSyllable == 0x8348)) && (prevSyllable != 0x82A4) && + (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8374) && + (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82E1) || (currentWord == 0x82E3) || (currentWord == 0x82E5) || - (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387)) && - (currentWord != 0x82AB) && (currentWord != 0x82B5) && (currentWord != 0x82BF) && - (currentWord != 0x82C9) && (currentWord != 0x82D0) && (currentWord != 0x82DD) && - (currentWord != 0x82E8) && (currentWord != 0x82AC) && (currentWord != 0x82B6) && - (currentWord != 0x82C0) && (currentWord != 0x82D1) && (currentWord != 0x82D2) && - (currentWord != 0x834C) && (currentWord != 0x8356) && (currentWord != 0x8360) && - (currentWord != 0x836A) && (currentWord != 0x8371) && (currentWord != 0x837E) && - (currentWord != 0x838A) && (currentWord != 0x834D) && (currentWord != 0x8357) && - (currentWord != 0x8361) && (currentWord != 0x8372) && (currentWord != 0x8373) && - (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || (currentSyllable == 0x82E5) || + (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387)) && + (prevSyllable != 0x82AB) && (prevSyllable != 0x82B5) && (prevSyllable != 0x82BF) && + (prevSyllable != 0x82C9) && (prevSyllable != 0x82D0) && (prevSyllable != 0x82DD) && + (prevSyllable != 0x82E8) && (prevSyllable != 0x82AC) && (prevSyllable != 0x82B6) && + (prevSyllable != 0x82C0) && (prevSyllable != 0x82D1) && (prevSyllable != 0x82D2) && + (prevSyllable != 0x834C) && (prevSyllable != 0x8356) && (prevSyllable != 0x8360) && + (prevSyllable != 0x836A) && (prevSyllable != 0x8371) && (prevSyllable != 0x837E) && + (prevSyllable != 0x838A) && (prevSyllable != 0x834D) && (prevSyllable != 0x8357) && + (prevSyllable != 0x8361) && (prevSyllable != 0x8372) && (prevSyllable != 0x8373) && + (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((currentWord == 0x815B) && ((currentWord == 0x82F1) || (currentWord == 0x82C1) || - (currentWord == 0x8393) || (currentWord == 0x8362))) { + } else if ((currentSyllable == 0x815B) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x82C1) || + (prevSyllable == 0x8393) || (prevSyllable == 0x8362))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82F1) || (currentWord == 0x8393)) && - ((currentWord == 0x82F1) || (currentWord == 0x8393))) { + } else if (((currentSyllable == 0x82F1) || (currentSyllable == 0x8393)) && + ((prevSyllable == 0x82F1) || (prevSyllable == 0x8393))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82C1) || (currentWord == 0x8362)) && - ((currentWord == 0x815B) || (currentWord == 0x82A0) || (currentWord == 0x82A2) || - (currentWord == 0x82A4) || (currentWord == 0x82A6) || (currentWord == 0x82A8) || - (currentWord == 0x82C8) || (currentWord == 0x82C9) || (currentWord == 0x82CA) || - (currentWord == 0x82CB) || (currentWord == 0x82CC) || (currentWord == 0x82DC) || - (currentWord == 0x82DD) || (currentWord == 0x82DE) || (currentWord == 0x82DF) || - (currentWord == 0x82E0) || (currentWord == 0x82E2) || (currentWord == 0x82E4) || - (currentWord == 0x82E6) || (currentWord == 0x82E7) || (currentWord == 0x82E8) || - (currentWord == 0x82E9) || (currentWord == 0x82EA) || (currentWord == 0x82EB) || - (currentWord == 0x82ED) || (currentWord == 0x82EE) || (currentWord == 0x82EF) || - (currentWord == 0x82F0) || (currentWord == 0x82F1) || (currentWord == 0x829F) || - (currentWord == 0x82A1) || (currentWord == 0x82A3) || (currentWord == 0x82A5) || - (currentWord == 0x82A7) || (currentWord == 0x82E1) || (currentWord == 0x82E3) || - (currentWord == 0x82E5) || (currentWord == 0x82C1) || (currentWord == 0x82EC) || - (currentWord == 0x8341) || (currentWord == 0x8343) || (currentWord == 0x8345) || - (currentWord == 0x8347) || (currentWord == 0x8349) || (currentWord == 0x8369) || - (currentWord == 0x836A) || (currentWord == 0x836B) || (currentWord == 0x836C) || - (currentWord == 0x836D) || (currentWord == 0x837D) || (currentWord == 0x837E) || - (currentWord == 0x8380) || (currentWord == 0x8381) || (currentWord == 0x8382) || - (currentWord == 0x8384) || (currentWord == 0x8386) || (currentWord == 0x8388) || - (currentWord == 0x8389) || (currentWord == 0x838A) || (currentWord == 0x838B) || - (currentWord == 0x838C) || (currentWord == 0x838D) || (currentWord == 0x838F) || - (currentWord == 0x8390) || (currentWord == 0x8391) || (currentWord == 0x8392) || - (currentWord == 0x8393) || (currentWord == 0x8340) || (currentWord == 0x8342) || - (currentWord == 0x8344) || (currentWord == 0x8346) || (currentWord == 0x8348) || - (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387) || - (currentWord == 0x8362) || (currentWord == 0x838E))) { + } else if (((prevSyllable == 0x82C1) || (prevSyllable == 0x8362)) && + ((currentSyllable == 0x815B) || (currentSyllable == 0x82A0) || (currentSyllable == 0x82A2) || + (currentSyllable == 0x82A4) || (currentSyllable == 0x82A6) || (currentSyllable == 0x82A8) || + (currentSyllable == 0x82C8) || (currentSyllable == 0x82C9) || (currentSyllable == 0x82CA) || + (currentSyllable == 0x82CB) || (currentSyllable == 0x82CC) || (currentSyllable == 0x82DC) || + (currentSyllable == 0x82DD) || (currentSyllable == 0x82DE) || (currentSyllable == 0x82DF) || + (currentSyllable == 0x82E0) || (currentSyllable == 0x82E2) || (currentSyllable == 0x82E4) || + (currentSyllable == 0x82E6) || (currentSyllable == 0x82E7) || (currentSyllable == 0x82E8) || + (currentSyllable == 0x82E9) || (currentSyllable == 0x82EA) || (currentSyllable == 0x82EB) || + (currentSyllable == 0x82ED) || (currentSyllable == 0x82EE) || (currentSyllable == 0x82EF) || + (currentSyllable == 0x82F0) || (currentSyllable == 0x82F1) || (currentSyllable == 0x829F) || + (currentSyllable == 0x82A1) || (currentSyllable == 0x82A3) || (currentSyllable == 0x82A5) || + (currentSyllable == 0x82A7) || (currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || + (currentSyllable == 0x82E5) || (currentSyllable == 0x82C1) || (currentSyllable == 0x82EC) || + (currentSyllable == 0x8341) || (currentSyllable == 0x8343) || (currentSyllable == 0x8345) || + (currentSyllable == 0x8347) || (currentSyllable == 0x8349) || (currentSyllable == 0x8369) || + (currentSyllable == 0x836A) || (currentSyllable == 0x836B) || (currentSyllable == 0x836C) || + (currentSyllable == 0x836D) || (currentSyllable == 0x837D) || (currentSyllable == 0x837E) || + (currentSyllable == 0x8380) || (currentSyllable == 0x8381) || (currentSyllable == 0x8382) || + (currentSyllable == 0x8384) || (currentSyllable == 0x8386) || (currentSyllable == 0x8388) || + (currentSyllable == 0x8389) || (currentSyllable == 0x838A) || (currentSyllable == 0x838B) || + (currentSyllable == 0x838C) || (currentSyllable == 0x838D) || (currentSyllable == 0x838F) || + (currentSyllable == 0x8390) || (currentSyllable == 0x8391) || (currentSyllable == 0x8392) || + (currentSyllable == 0x8393) || (currentSyllable == 0x8340) || (currentSyllable == 0x8342) || + (currentSyllable == 0x8344) || (currentSyllable == 0x8346) || (currentSyllable == 0x8348) || + (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387) || + (currentSyllable == 0x8362) || (currentSyllable == 0x838E))) { errorCode = CONT_ERR_VOICE_WORD; } if (errorCode != 0) { return errorCode; } + + prevSyllable = currentSyllable; } - if ((currentWord == 0x82C1) || (currentWord == 0x8362)) { + if ((currentSyllable == 0x82C1) || (currentSyllable == 0x8362)) { errorCode = CONT_ERR_VOICE_WORD; } return errorCode; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckword/osVoiceCheckWord.s") -#endif From 6bfbbddb1a3624226e4e7230bf2406b5603020f9 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 14:04:48 +1100 Subject: [PATCH 025/130] currentSyllable -> currSyllable --- src/libultra/voice/voicecheckword.c | 93 ++++++++++++++--------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 84f8985ab..b6694ac7f 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -4,45 +4,44 @@ s32 osVoiceCheckWord(u8* word) { s32 i; s32 errorCode = 0; - u16 currentSyllable; + u16 currSyllable; u16 prevSyllable = 0; for (i = 0; word[i] != 0; i += 2) { - currentSyllable = (word[i] << 8) + word[i + 1]; - if (((currentSyllable != 0x815B) && (currentSyllable < 0x829F)) || - ((currentSyllable >= 0x82F2) && (currentSyllable < 0x8340)) || (currentSyllable == 0x837F) || - (currentSyllable >= 0x8397)) { + currSyllable = (word[i] << 8) + word[i + 1]; + if (((currSyllable != 0x815B) && (currSyllable < 0x829F)) || + ((currSyllable >= 0x82F2) && (currSyllable < 0x8340)) || (currSyllable == 0x837F) || + (currSyllable >= 0x8397)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((i == 0) && - ((currentSyllable == 0x815B) || (currentSyllable == 0x82F1) || (currentSyllable == 0x82C1) || - (currentSyllable == 0x82EC) || (currentSyllable == 0x8393) || (currentSyllable == 0x8362) || - (currentSyllable == 0x838E) || (currentSyllable == 0x8395) || (currentSyllable == 0x8396))) { + } else if ((i == 0) && ((currSyllable == 0x815B) || (currSyllable == 0x82F1) || (currSyllable == 0x82C1) || + (currSyllable == 0x82EC) || (currSyllable == 0x8393) || (currSyllable == 0x8362) || + (currSyllable == 0x838E) || (currSyllable == 0x8395) || (currSyllable == 0x8396))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x829F) || (currentSyllable == 0x8340)) && (prevSyllable != 0x82D3) && + } else if (((currSyllable == 0x829F) || (currSyllable == 0x8340)) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A1) || (currentSyllable == 0x8342)) && (prevSyllable != 0x82A4) && + } else if (((currSyllable == 0x82A1) || (currSyllable == 0x8342)) && (prevSyllable != 0x82A4) && (prevSyllable != 0x82C4) && (prevSyllable != 0x82C5) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8365) && (prevSyllable != 0x8366) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A3) || (currentSyllable == 0x8344)) && (prevSyllable != 0x82C6) && + } else if (((currSyllable == 0x82A3) || (currSyllable == 0x8344)) && (prevSyllable != 0x82C6) && (prevSyllable != 0x82C7) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8367) && (prevSyllable != 0x8368) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A5) || (currentSyllable == 0x8346)) && (prevSyllable != 0x82A4) && + } else if (((currSyllable == 0x82A5) || (currSyllable == 0x8346)) && (prevSyllable != 0x82A4) && (prevSyllable != 0x82B5) && (prevSyllable != 0x82B6) && (prevSyllable != 0x82BF) && (prevSyllable != 0x82C0) && (prevSyllable != 0x82C2) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8356) && (prevSyllable != 0x8357) && (prevSyllable != 0x8360) && (prevSyllable != 0x8361) && (prevSyllable != 0x8363) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A7) || (currentSyllable == 0x8348)) && (prevSyllable != 0x82A4) && + } else if (((currSyllable == 0x82A7) || (currSyllable == 0x8348)) && (prevSyllable != 0x82A4) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || (currentSyllable == 0x82E5) || - (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387)) && + } else if (((currSyllable == 0x82E1) || (currSyllable == 0x82E3) || (currSyllable == 0x82E5) || + (currSyllable == 0x8383) || (currSyllable == 0x8385) || (currSyllable == 0x8387)) && (prevSyllable != 0x82AB) && (prevSyllable != 0x82B5) && (prevSyllable != 0x82BF) && (prevSyllable != 0x82C9) && (prevSyllable != 0x82D0) && (prevSyllable != 0x82DD) && (prevSyllable != 0x82E8) && (prevSyllable != 0x82AC) && (prevSyllable != 0x82B6) && @@ -53,39 +52,39 @@ s32 osVoiceCheckWord(u8* word) { (prevSyllable != 0x8361) && (prevSyllable != 0x8372) && (prevSyllable != 0x8373) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((currentSyllable == 0x815B) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x82C1) || - (prevSyllable == 0x8393) || (prevSyllable == 0x8362))) { + } else if ((currSyllable == 0x815B) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x82C1) || + (prevSyllable == 0x8393) || (prevSyllable == 0x8362))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82F1) || (currentSyllable == 0x8393)) && + } else if (((currSyllable == 0x82F1) || (currSyllable == 0x8393)) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x8393))) { errorCode = CONT_ERR_VOICE_WORD; } else if (((prevSyllable == 0x82C1) || (prevSyllable == 0x8362)) && - ((currentSyllable == 0x815B) || (currentSyllable == 0x82A0) || (currentSyllable == 0x82A2) || - (currentSyllable == 0x82A4) || (currentSyllable == 0x82A6) || (currentSyllable == 0x82A8) || - (currentSyllable == 0x82C8) || (currentSyllable == 0x82C9) || (currentSyllable == 0x82CA) || - (currentSyllable == 0x82CB) || (currentSyllable == 0x82CC) || (currentSyllable == 0x82DC) || - (currentSyllable == 0x82DD) || (currentSyllable == 0x82DE) || (currentSyllable == 0x82DF) || - (currentSyllable == 0x82E0) || (currentSyllable == 0x82E2) || (currentSyllable == 0x82E4) || - (currentSyllable == 0x82E6) || (currentSyllable == 0x82E7) || (currentSyllable == 0x82E8) || - (currentSyllable == 0x82E9) || (currentSyllable == 0x82EA) || (currentSyllable == 0x82EB) || - (currentSyllable == 0x82ED) || (currentSyllable == 0x82EE) || (currentSyllable == 0x82EF) || - (currentSyllable == 0x82F0) || (currentSyllable == 0x82F1) || (currentSyllable == 0x829F) || - (currentSyllable == 0x82A1) || (currentSyllable == 0x82A3) || (currentSyllable == 0x82A5) || - (currentSyllable == 0x82A7) || (currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || - (currentSyllable == 0x82E5) || (currentSyllable == 0x82C1) || (currentSyllable == 0x82EC) || - (currentSyllable == 0x8341) || (currentSyllable == 0x8343) || (currentSyllable == 0x8345) || - (currentSyllable == 0x8347) || (currentSyllable == 0x8349) || (currentSyllable == 0x8369) || - (currentSyllable == 0x836A) || (currentSyllable == 0x836B) || (currentSyllable == 0x836C) || - (currentSyllable == 0x836D) || (currentSyllable == 0x837D) || (currentSyllable == 0x837E) || - (currentSyllable == 0x8380) || (currentSyllable == 0x8381) || (currentSyllable == 0x8382) || - (currentSyllable == 0x8384) || (currentSyllable == 0x8386) || (currentSyllable == 0x8388) || - (currentSyllable == 0x8389) || (currentSyllable == 0x838A) || (currentSyllable == 0x838B) || - (currentSyllable == 0x838C) || (currentSyllable == 0x838D) || (currentSyllable == 0x838F) || - (currentSyllable == 0x8390) || (currentSyllable == 0x8391) || (currentSyllable == 0x8392) || - (currentSyllable == 0x8393) || (currentSyllable == 0x8340) || (currentSyllable == 0x8342) || - (currentSyllable == 0x8344) || (currentSyllable == 0x8346) || (currentSyllable == 0x8348) || - (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387) || - (currentSyllable == 0x8362) || (currentSyllable == 0x838E))) { + ((currSyllable == 0x815B) || (currSyllable == 0x82A0) || (currSyllable == 0x82A2) || + (currSyllable == 0x82A4) || (currSyllable == 0x82A6) || (currSyllable == 0x82A8) || + (currSyllable == 0x82C8) || (currSyllable == 0x82C9) || (currSyllable == 0x82CA) || + (currSyllable == 0x82CB) || (currSyllable == 0x82CC) || (currSyllable == 0x82DC) || + (currSyllable == 0x82DD) || (currSyllable == 0x82DE) || (currSyllable == 0x82DF) || + (currSyllable == 0x82E0) || (currSyllable == 0x82E2) || (currSyllable == 0x82E4) || + (currSyllable == 0x82E6) || (currSyllable == 0x82E7) || (currSyllable == 0x82E8) || + (currSyllable == 0x82E9) || (currSyllable == 0x82EA) || (currSyllable == 0x82EB) || + (currSyllable == 0x82ED) || (currSyllable == 0x82EE) || (currSyllable == 0x82EF) || + (currSyllable == 0x82F0) || (currSyllable == 0x82F1) || (currSyllable == 0x829F) || + (currSyllable == 0x82A1) || (currSyllable == 0x82A3) || (currSyllable == 0x82A5) || + (currSyllable == 0x82A7) || (currSyllable == 0x82E1) || (currSyllable == 0x82E3) || + (currSyllable == 0x82E5) || (currSyllable == 0x82C1) || (currSyllable == 0x82EC) || + (currSyllable == 0x8341) || (currSyllable == 0x8343) || (currSyllable == 0x8345) || + (currSyllable == 0x8347) || (currSyllable == 0x8349) || (currSyllable == 0x8369) || + (currSyllable == 0x836A) || (currSyllable == 0x836B) || (currSyllable == 0x836C) || + (currSyllable == 0x836D) || (currSyllable == 0x837D) || (currSyllable == 0x837E) || + (currSyllable == 0x8380) || (currSyllable == 0x8381) || (currSyllable == 0x8382) || + (currSyllable == 0x8384) || (currSyllable == 0x8386) || (currSyllable == 0x8388) || + (currSyllable == 0x8389) || (currSyllable == 0x838A) || (currSyllable == 0x838B) || + (currSyllable == 0x838C) || (currSyllable == 0x838D) || (currSyllable == 0x838F) || + (currSyllable == 0x8390) || (currSyllable == 0x8391) || (currSyllable == 0x8392) || + (currSyllable == 0x8393) || (currSyllable == 0x8340) || (currSyllable == 0x8342) || + (currSyllable == 0x8344) || (currSyllable == 0x8346) || (currSyllable == 0x8348) || + (currSyllable == 0x8383) || (currSyllable == 0x8385) || (currSyllable == 0x8387) || + (currSyllable == 0x8362) || (currSyllable == 0x838E))) { errorCode = CONT_ERR_VOICE_WORD; } @@ -93,10 +92,10 @@ s32 osVoiceCheckWord(u8* word) { return errorCode; } - prevSyllable = currentSyllable; + prevSyllable = currSyllable; } - if ((currentSyllable == 0x82C1) || (currentSyllable == 0x8362)) { + if ((currSyllable == 0x82C1) || (currSyllable == 0x8362)) { errorCode = CONT_ERR_VOICE_WORD; } From 46c5a5a141532634631f8fc72d0cb5b2e832e3bb Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 19:42:39 +1100 Subject: [PATCH 026/130] Match osVoiceMaskDictionary --- src/libultra/voice/voicemaskdictionary.c | 47 +++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/libultra/voice/voicemaskdictionary.c b/src/libultra/voice/voicemaskdictionary.c index e82a27b81..21c01b8a5 100644 --- a/src/libultra/voice/voicemaskdictionary.c +++ b/src/libultra/voice/voicemaskdictionary.c @@ -1,4 +1,49 @@ #include "global.h" // Mask words registered in the voice recognition system -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicemaskdictionary/osVoiceMaskDictionary.s") +s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size) { + s32 errorCode; + s32 i; + s32 sp3C; + u8 status; + u8 data[20]; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (errorCode != 0) { + return errorCode; + } + + if (status & 2) { + return CONT_ERR_VOICE_NO_RESPONSE; + } + + if (size & 1) { + sp3C = size + 1; + } else { + sp3C = size; + } + + bzero(&data, 20); + + data[18 - sp3C] = 4; + + for (i = 0; i < sp3C; i += 2) { + data[i + 20 - sp3C] = maskPattern[i]; + data[i + 21 - sp3C] = maskPattern[i+1]; + } + + if (size & 1) { + data[19] = 0; + } + + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data); + if (errorCode == 0) { + errorCode = __osVoiceCheckResult(hd, &status); + if (errorCode & 0xFF00) { + errorCode = CONT_ERR_INVALID; + } + } + + return errorCode; +} + From a74c2605e656b4b00128463572e2efc0b5c399dd Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 19:55:32 +1100 Subject: [PATCH 027/130] Match __osVoiceSetADConverter --- src/libultra/voice/voicesetadconverter.c | 65 +++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/libultra/voice/voicesetadconverter.c b/src/libultra/voice/voicesetadconverter.c index c1b8fa002..fdfe49ecf 100644 --- a/src/libultra/voice/voicesetadconverter.c +++ b/src/libultra/voice/voicesetadconverter.c @@ -1,3 +1,66 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicesetadconverter/__osVoiceSetADConverter.s") +s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2) { + s32 errorCode; + u8* ptr; + s32 retryCount = 2; + u8 status; + u16 sp48; + s32 i; + + __osSiGetAccess(); + + sp48 = arg2 * 8; + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xD) || (port != D_80097FB0)) { + __osContLastCmd = 0xD; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 3; + ptr[1] = 1; + ptr[2] = 0xD; + ptr[5] = 0; + ptr[6] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[3] = arg2; + ptr[4] = __osContAddressCrc(sp48); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[1] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[5] & 1) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} From b7858effd5c4f1e729f6bd08ade1b2b536fbaddc Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 22:09:52 +1100 Subject: [PATCH 028/130] Meme matched osVoiceStopReadData --- src/libultra/voice/voicestopread.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 4c9a1dc88..a5d9456e1 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -1,10 +1,9 @@ #include "global.h" // Forcibly stops voice recognition processing by the Voice Recognition System -#ifdef NON_EQUIVALENT s32 osVoiceStopReadData(OSVoiceHandle* hd) { - s32 i; s32 errorCode; + s32 i; u8 sp3F; s32 sp38; @@ -25,28 +24,24 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp38); if (errorCode == 0) { - for (i = 0; i < 20; i++) { + i = 0; + do { errorCode = __osVoiceCheckResult(hd, &sp3F); if (errorCode & 0xFF00) { if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) { - if (hd) {} errorCode = 0; hd->mode = 0; } else { - errorCode = CONT_ERR_INVALID; + errorCode = 5; } } else { hd->mode = 0; } - - if (errorCode != CONT_ERR_VOICE_NO_RESPONSE) { - break; - } - } + i++; + } while ((errorCode == 15) && (i < 20)); } + if (i) {} + return errorCode; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicestopread/osVoiceStopReadData.s") -#endif From 5ca6f07f1898662af69a3b1dcc304b4ca3b04ffc Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 22:12:45 +1100 Subject: [PATCH 029/130] small cleanup --- src/libultra/voice/voiceinit.c | 2 +- src/libultra/voice/voicestartreaddata.c | 2 +- src/libultra/voice/voicestopread.c | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 8a1aeac11..0cd5aba2b 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -9,7 +9,7 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { u8* phi_s0; u8 status = 0; union { - s32 data32; + u32 data32; u8 data[4]; } u; s32 pad; diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 07032ba67..e3f6854bf 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -5,7 +5,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { s32 errorCode; u8 status; union { - s32 data32; + u32 data32; u8 data[4]; } u; diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index a5d9456e1..85fc02130 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -4,15 +4,18 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { s32 errorCode; s32 i; - u8 sp3F; - s32 sp38; + u8 status; + union { + u32 data32; + u8 data[4]; + } u; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp3F); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { return errorCode; } - if (sp3F & 2) { + if (status & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } @@ -20,13 +23,19 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { return CONT_ERR_INVALID; } - sp38 = 0x700; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp38); + /** + * data[0] = 0 + * data[1] = 0 + * data[2] = 7 + * data[3] = 0 + */ + u.data32 = 0x700; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); if (errorCode == 0) { i = 0; do { - errorCode = __osVoiceCheckResult(hd, &sp3F); + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) { errorCode = 0; From 9b94fe096456459d6d84e187b04f63ed907ae39c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 22:14:26 +1100 Subject: [PATCH 030/130] Missed macros --- src/libultra/voice/voicestopread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 85fc02130..8254c0083 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -41,13 +41,13 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { errorCode = 0; hd->mode = 0; } else { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } } else { hd->mode = 0; } i++; - } while ((errorCode == 15) && (i < 20)); + } while ((errorCode == CONT_ERR_VOICE_NO_RESPONSE) && (i < 20)); } if (i) {} From d9cdd69205239e6b5c2d42a85a0fb7ff2cce105c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 00:46:58 +1100 Subject: [PATCH 031/130] osVoiceGetReadData Meme Match --- src/libultra/voice/voicegetreaddata.c | 30 +++++++-------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 03f21e506..25a7f3026 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -1,11 +1,10 @@ #include "global.h" // Gets voice recognition result from the Voice Recognition System -#ifdef NON_EQUIVALENT s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { s32 errorCode; - u8 new_var; u8 temp_t9; + u8 new_var2; union { u8 sp38[40]; u32 sp38_32[10]; @@ -75,31 +74,19 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { result->voice_sn = u.sp38[10] + (u.sp38[11] << 8); result->voice_time = u.sp38[12] + (u.sp38[13] << 8); - // Issue here with for-loop unrolling - new_var = 4; for (i = 0; i < 5; i++) { - result->answer[i] = u.sp38[14 + new_var*i] + (u.sp38[15 + new_var*i] << 8); - result->distance[i] = u.sp38[16 + new_var*i] + (u.sp38[17 + new_var*i] << 8); + result->answer[i] = u.sp38[14 + 4 * (i ^ 0)] + (u.sp38[15 + 4 * (i ^ 0)] << 8); + result->distance[i] = u.sp38[16 + 4 * (i ^ 0)] + (u.sp38[17 + 4 * (i ^ 0)] << 8); } - - // result->answer[0] = u.sp38[14] + (u.sp38[15] << 8); - // result->distance[0] = u.sp38[16] + (u.sp38[17] << 8); - // result->answer[1] = u.sp38[18] + (u.sp38[19] << 8); - // result->distance[1] = u.sp38[20] + (u.sp38[21] << 8); - // result->answer[2] = u.sp38[22] + (u.sp38[23] << 8); - // result->distance[2] = u.sp38[24] + (u.sp38[25] << 8); - // result->answer[3] = u.sp38[26] + (u.sp38[27] << 8); - // result->distance[3] = u.sp38[28] + (u.sp38[29] << 8); - // result->answer[4] = u.sp38[30] + (u.sp38[31] << 8); - // result->distance[4] = u.sp38[32] + (u.sp38[33] << 8); if (result->answer[0] == 0x7FFF) { result->answer_num = 0; } - // Issue here with regalloc - hd->status = u.sp38[34] & 7; - if ((D_8009CF60 == 0) || (hd->status == 0)) { + new_var2 = D_8009CF60; + temp_t9 = u.sp38[34] ^ 0; + hd->status = temp_t9 & 7; + if ((new_var2 == 0) || (hd->status == 0)) { break; } case 4: @@ -131,6 +118,3 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { hd->mode = 0; return errorCode; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicegetreaddata/osVoiceGetReadData.s") -#endif From 28ba1090fff4ea43df30a7768e793015eb3fab9e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 00:53:08 +1100 Subject: [PATCH 032/130] Small clean-up --- src/libultra/voice/voicegetreaddata.c | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 25a7f3026..40d7b5b0b 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -6,28 +6,28 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { u8 temp_t9; u8 new_var2; union { - u8 sp38[40]; - u32 sp38_32[10]; + u8 data[40]; + u32 data32[10]; } u; s32 i; switch (hd->mode) { case 1: - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 1) { + if (u.data[39] & 1) { return CONT_ERR_NOT_READY; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } - temp_t9 = u.sp38[0] & 7; + temp_t9 = u.data[0] & 7; hd->status = temp_t9; D_8009CF60 = temp_t9; if ((temp_t9 != 0) && (temp_t9 != 7)) { @@ -36,17 +36,17 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 2: hd->mode = 2; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 2) { + if (u.data[39] & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } - u.sp38_32[0] = 0x600; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.sp38); + u.data32[0] = 0x600; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } @@ -54,29 +54,29 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 3: hd->mode = 3; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 1) { + if (u.data[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, u.sp38); + errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } - result->warning = u.sp38[4] + (u.sp38[5] << 8); - result->answer_num = u.sp38[6]; - result->voice_level = u.sp38[8] + (u.sp38[9] << 8); - result->voice_sn = u.sp38[10] + (u.sp38[11] << 8); - result->voice_time = u.sp38[12] + (u.sp38[13] << 8); + result->warning = u.data[4] + (u.data[5] << 8); + result->answer_num = u.data[6]; + result->voice_level = u.data[8] + (u.data[9] << 8); + result->voice_sn = u.data[10] + (u.data[11] << 8); + result->voice_time = u.data[12] + (u.data[13] << 8); for (i = 0; i < 5; i++) { - result->answer[i] = u.sp38[14 + 4 * (i ^ 0)] + (u.sp38[15 + 4 * (i ^ 0)] << 8); - result->distance[i] = u.sp38[16 + 4 * (i ^ 0)] + (u.sp38[17 + 4 * (i ^ 0)] << 8); + result->answer[i] = u.data[14 + 4 * (i ^ 0)] + (u.data[15 + 4 * (i ^ 0)] << 8); + result->distance[i] = u.data[16 + 4 * (i ^ 0)] + (u.data[17 + 4 * (i ^ 0)] << 8); } if (result->answer[0] == 0x7FFF) { @@ -84,7 +84,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } new_var2 = D_8009CF60; - temp_t9 = u.sp38[34] ^ 0; + temp_t9 = u.data[34] ^ 0; hd->status = temp_t9 & 7; if ((new_var2 == 0) || (hd->status == 0)) { break; @@ -92,22 +92,22 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 4: hd->mode = 4; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 1) { + if (u.data[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } - hd->status = u.sp38[0] & 7; - if (u.sp38[0] & 7) { + hd->status = u.data[0] & 7; + if (u.data[0] & 7) { return CONT_ERR_VOICE_NO_RESPONSE; } From d5958dd7d8d51c25c74c8859e3e3391f893bab64 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 00:59:13 +1100 Subject: [PATCH 033/130] format --- src/libultra/voice/voicecleardictionary.c | 6 +++--- src/libultra/voice/voicecontread2.c | 3 +-- src/libultra/voice/voicecontread36.c | 2 +- src/libultra/voice/voicecontrolgain.c | 9 ++++----- src/libultra/voice/voicecontwrite20.c | 2 +- src/libultra/voice/voicecontwrite4.c | 2 +- src/libultra/voice/voicegetstatus.c | 2 +- src/libultra/voice/voiceinit.c | 7 +++---- src/libultra/voice/voicemaskdictionary.c | 3 +-- src/libultra/voice/voicesetadconverter.c | 2 +- src/libultra/voice/voicesetword.c | 2 +- src/libultra/voice/voicestartreaddata.c | 2 +- src/libultra/voice/voicestopread.c | 2 +- 13 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 719c7f0dc..bb93a2302 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -2,11 +2,11 @@ /** * Initializes Voice Recognition System word registration dictionary. - * + * * The dictionary is initialized so that the specified "numWords" can be * registered in the dictionary. 1-255 words can be registered in the dictionary. - * - * Words cannot be registered with the osVoiceSetWord before the dictionary + * + * Words cannot be registered with the osVoiceSetWord before the dictionary * is initialized with the osVoiceClearDictionary function */ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords) { diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index ce52e2be0..d0056a0ab 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -35,7 +35,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { ptr[4] = arg2 >> 3; ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); __osSiRawStartDma(OS_READ, &__osPfsPifRam); @@ -64,4 +64,3 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { return errorCode; } - diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index 66067d239..f11e20d26 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -35,7 +35,7 @@ s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { ptr[4] = arg2 >> 3; ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); __osSiRawStartDma(OS_READ, &__osPfsPifRam); diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index eb896bb72..1f2e73aac 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -7,7 +7,6 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { s32 errorCode; u8 phi_a2; - if (analog == 0) { phi_a2 = 0x18; } else { @@ -18,22 +17,22 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { if (errorCode != 0) { return errorCode; } - - if (!((digital < 8) && (digital >= 0))){ + + if (!((digital < 8) && (digital >= 0))) { goto dummy; } phi_a2 = D_80098180[digital] + 2; if (0) { - dummy: + dummy: return CONT_ERR_INVALID; } errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); if (errorCode != 0) { return errorCode; - } + } return errorCode; } diff --git a/src/libultra/voice/voicecontwrite20.c b/src/libultra/voice/voicecontwrite20.c index 9eba371c6..2d43c9f26 100644 --- a/src/libultra/voice/voicecontwrite20.c +++ b/src/libultra/voice/voicecontwrite20.c @@ -38,7 +38,7 @@ s32 __osVoiceContWrite20(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[20]) { ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); bcopy(dst, &ptr[6], 20); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); temp_s2 = __osVoiceContDataCrc(dst, 20); osRecvMesg(mq, NULL, OS_MESG_BLOCK); diff --git a/src/libultra/voice/voicecontwrite4.c b/src/libultra/voice/voicecontwrite4.c index 8e1af6bd8..eac29d27c 100644 --- a/src/libultra/voice/voicecontwrite4.c +++ b/src/libultra/voice/voicecontwrite4.c @@ -38,7 +38,7 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[4]) { ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); bcopy(dst, &ptr[6], 4); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); temp_s2 = __osVoiceContDataCrc(dst, 4); osRecvMesg(mq, NULL, OS_MESG_BLOCK); diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index e11dcb954..b305cad19 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -54,6 +54,6 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); __osSiRelAccess(); - + return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 0cd5aba2b..6936070d5 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -17,7 +17,7 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { hd->port = channel; hd->mq = siMessageQ; hd->mode = 0; - + errorCode = __osVoiceGetStatus(siMessageQ, channel, &status); if (errorCode != 0) { return errorCode; @@ -55,14 +55,13 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { if (errorCode != 0) { return errorCode; } - + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { errorCode = CONT_ERR_INVALID; } - + return errorCode; } } } - diff --git a/src/libultra/voice/voicemaskdictionary.c b/src/libultra/voice/voicemaskdictionary.c index 21c01b8a5..e0e67c792 100644 --- a/src/libultra/voice/voicemaskdictionary.c +++ b/src/libultra/voice/voicemaskdictionary.c @@ -29,7 +29,7 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size) { for (i = 0; i < sp3C; i += 2) { data[i + 20 - sp3C] = maskPattern[i]; - data[i + 21 - sp3C] = maskPattern[i+1]; + data[i + 21 - sp3C] = maskPattern[i + 1]; } if (size & 1) { @@ -46,4 +46,3 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size) { return errorCode; } - diff --git a/src/libultra/voice/voicesetadconverter.c b/src/libultra/voice/voicesetadconverter.c index fdfe49ecf..4dccec20f 100644 --- a/src/libultra/voice/voicesetadconverter.c +++ b/src/libultra/voice/voicesetadconverter.c @@ -37,7 +37,7 @@ s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2) { ptr[3] = arg2; ptr[4] = __osContAddressCrc(sp48); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); __osSiRawStartDma(OS_READ, &__osPfsPifRam); diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index a5ef50348..377d80a47 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -37,7 +37,7 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { if (errorCode != 0) { return errorCode; } - } + } errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data[20]); if (errorCode != 0) { diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index e3f6854bf..927edf223 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -33,7 +33,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { if (errorCode == 0) { errorCode = __osVoiceCheckResult(hd, &status); - + if (errorCode & 0xFF00) { errorCode = CONT_ERR_INVALID; } else { diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 8254c0083..0b126622c 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -31,7 +31,7 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { */ u.data32 = 0x700; errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); - + if (errorCode == 0) { i = 0; do { From 158dede3f68891fcf1643af65a9e77b242931432 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 13:47:50 +1100 Subject: [PATCH 034/130] Properly split voice files from code --- spec | 1 + src/code/code_8019AF00.c | 16 ---------------- src/code/code_801A4EB0.c | 17 +++++++++++++++++ tools/disasm/files.txt | 1 + 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 src/code/code_801A4EB0.c diff --git a/spec b/spec index f3cd6c8ba..c54036abb 100644 --- a/spec +++ b/spec @@ -658,6 +658,7 @@ beginseg include "build/src/code/code_8019AF00.o" include "build/data/code/code_8019AF00.bss.o" include "build/data/code/code_801D55B0.data.o" + include "build/src/code/code_801A4EB0.o" include "build/src/code/code_801A51F0.o" include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" diff --git a/src/code/code_8019AF00.c b/src/code/code_8019AF00.c index 8f0d129ad..227384d0a 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/code_8019AF00.c @@ -411,19 +411,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DF4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4E64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4FD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A50C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5100.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A510C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5118.s") diff --git a/src/code/code_801A4EB0.c b/src/code/code_801A4EB0.c new file mode 100644 index 000000000..d3461c8f5 --- /dev/null +++ b/src/code/code_801A4EB0.c @@ -0,0 +1,17 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index b9a7a0dfd..15debf9f5 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -488,6 +488,7 @@ 0x8019AEB0 : "[PADDING]", 0x8019AEC0 : "code_8019AEC0", 0x8019AF00 : "code_8019AF00", + 0x801A4EB0 : "code_801A4EB0", 0x801A51F0 : "code_801A51F0", 0x801A5BC0 : "[PADDING]", 0x801A5BD0 : "code_801A5BD0", From 98ea63ce9fc3e15ae1376fb28df76360baee4267 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 13:54:59 +1100 Subject: [PATCH 035/130] Use proper flags for voice files --- Makefile | 3 +++ spec | 4 ++-- src/code/{ => audio}/code_801A4EB0.c | 0 src/code/{ => audio}/code_801A51F0.c | 0 4 files changed, 5 insertions(+), 2 deletions(-) rename src/code/{ => audio}/code_801A4EB0.c (100%) rename src/code/{ => audio}/code_801A51F0.c (100%) diff --git a/Makefile b/Makefile index b202b95c0..470d835d4 100644 --- a/Makefile +++ b/Makefile @@ -156,6 +156,8 @@ build/src/libultra/rmon/%.o: OPTFLAGS := -O2 build/src/libultra/flash/%.o: OPTFLAGS := -g build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 +build/src/code/audio/%.o: OPTFLAGS := -O2 + # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv build/src/boot_O2_g3/fault_drawer.o: CFLAGS += -trapuv @@ -172,6 +174,7 @@ build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $( build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- diff --git a/spec b/spec index c54036abb..36da46954 100644 --- a/spec +++ b/spec @@ -658,8 +658,8 @@ beginseg include "build/src/code/code_8019AF00.o" include "build/data/code/code_8019AF00.bss.o" include "build/data/code/code_801D55B0.data.o" - include "build/src/code/code_801A4EB0.o" - include "build/src/code/code_801A51F0.o" + include "build/src/code/audio/code_801A4EB0.o" + include "build/src/code/audio/code_801A51F0.o" include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" pad_text diff --git a/src/code/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c similarity index 100% rename from src/code/code_801A4EB0.c rename to src/code/audio/code_801A4EB0.c diff --git a/src/code/code_801A51F0.c b/src/code/audio/code_801A51F0.c similarity index 100% rename from src/code/code_801A51F0.c rename to src/code/audio/code_801A51F0.c From b640bac998439d58fcaf55e1480efbfbf24c208b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:01:05 +1100 Subject: [PATCH 036/130] Add basic docs for func_801A5AF0 --- include/functions.h | 2 +- src/code/audio/code_801A51F0.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2ed3bf63c..4b9982a63 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3980,7 +3980,7 @@ void func_801A4D00(void); // void func_801A5080(void); // void func_801A5100(void); // void func_801A5118(void); -UNK_TYPE func_801A51F0(UNK_TYPE arg0); +s32 func_801A51F0(s32 errorCode); // void func_801A5228(void); // void func_801A5390(void); // void func_801A53E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 6a40bf23a..10c47ffa7 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,16 +1,26 @@ #include "global.h" +/* +char D_801E0EC0[] = "Error %d\n" +char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n" +char D_801E0EF0[] = "NAI_VRS:dict error! (%d-%d %s)\n" +char D_801E0F10[] = "NAI_VRS:Ina_SetVruGain Error!\n" +char D_801E0F30[] = "NAI_VRS:mask on %d\n" +char D_801E0F48[] = "NAI_VRS:mask off %d\n" +char D_801E0F60[] = "NAI_VRS:answer No.:%d Dist:%d Warn:%04X Level:%5d SN:%5d (Num:%d)\n" +char D_801E0FA4[] = "NAI_VRS:error !! (ANS_MAX:%d DIST:%d WARNING:%04X LEVEL:%5d SN:%5d)\n" +*/ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/D_801E0EC0.s") -UNK_TYPE func_801A51F0(UNK_TYPE arg0) { - switch (arg0) { - case 1: - case 4: - case 5: - case 11: - case 13: - case 14: - case 15: +s32 func_801A51F0(s32 errorCode) { + switch (errorCode) { + case CONT_ERR_NO_CONTROLLER: + case CONT_ERR_CONTRFAIL: + case CONT_ERR_INVALID: + case CONT_ERR_DEVICE: + case CONT_ERR_VOICE_MEMORY: + case CONT_ERR_VOICE_WORD: + case CONT_ERR_VOICE_NO_RESPONSE: return -1; default: return 0; From 133cb7a74c17bc3c709d7ace464ad397f0afb39e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:11:58 +1100 Subject: [PATCH 037/130] Import Voice Data --- spec | 1 - src/code/audio/code_801A51F0.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spec b/spec index 36da46954..8ba7c36ea 100644 --- a/spec +++ b/spec @@ -660,7 +660,6 @@ beginseg include "build/data/code/code_801D55B0.data.o" include "build/src/code/audio/code_801A4EB0.o" include "build/src/code/audio/code_801A51F0.o" - include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" pad_text include "build/src/code/code_801A5BD0.o" diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 10c47ffa7..76200ac90 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,5 +1,17 @@ #include "global.h" +char D_801D8E50[] = + "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" + "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" + "PE\0HO\0BO\0PO\0MA\0MI\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + +char D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" + "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" + "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " + "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + /* char D_801E0EC0[] = "Error %d\n" char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n" From e42e0c607c9697e4ecce53205b9b60e3b0db8482 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:26:20 +1100 Subject: [PATCH 038/130] Update matching functions in code_801A51F0 from audio WIP --- include/variables.h | 6 +-- src/code/audio/code_801A51F0.c | 75 ++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/include/variables.h b/include/variables.h index d3ecb8bb1..ea39ac82d 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1821,9 +1821,9 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8BD0; // extern UNK_TYPE4 D_801D8BD4; // extern UNK_TYPE1 D_801D8BE0; -// extern UNK_TYPE1 D_801D8E3C; +extern u8 D_801D8E3C; // extern UNK_TYPE4 D_801D8E40; -// extern UNK_TYPE2 D_801D8E44; +extern u16 D_801D8E44; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; @@ -3625,7 +3625,7 @@ extern OSMesg D_801FD034; // extern UNK_TYPE1 D_801FD5C4; // extern UNK_TYPE1 D_801FD5C8; // extern UNK_TYPE1 D_801FD5E8; -// extern UNK_TYPE1 D_801FD608; +extern u8 D_801FD608[]; // extern UNK_TYPE1 D_801FD610; // extern UNK_TYPE1 D_801FD710; // extern UNK_TYPE1 D_801FD8C0; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 76200ac90..20ae5b8e3 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,5 +1,23 @@ #include "global.h" +// padmgr functions +s32 func_80175008(); +void func_8017506C(s32); + +typedef struct { + /* 0x00 */ u8* unk_00; + /* 0x04 */ u8 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ u16 unk_0C; + /* 0x0E */ u16 unk_0E; + /* 0x10 */ u16 unk_10; + /* 0x12 */ u16 unk_12; + /* 0x14 */ u16 unk_14; +} OSVoiceUnk; // size = 0x18 + +extern OSVoiceUnk D_801FD5A0; +extern OSVoiceHandle D_801FD5B8; + char D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" @@ -41,17 +59,58 @@ s32 func_801A51F0(s32 errorCode) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5228.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5390.s") +s32 func_801A5390(void) { + s32 temp_t6; + s32 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A53DC.s") + temp_t6 = D_801FD5A0.unk_08; + D_801FD5A0.unk_08 = 0; + sp18 = func_80175008(); + osVoiceStartReadData(&D_801FD5B8); + func_8017506C(sp18); + return temp_t6; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A53E8.s") +s32 func_801A53DC(void) { + return D_801FD5A0.unk_00; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A541C.s") +void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { + D_801FD5A0.unk_0C = arg0; + D_801FD5A0.unk_0E = arg1; + D_801FD5A0.unk_10 = arg2; + D_801FD5A0.unk_12 = arg3; + D_801FD5A0.unk_14 = arg4; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5488.s") +void func_801A541C(s32 analog, s32 digital) { + s32 sp1C; + s32 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54C4.s") + if (D_801FD5A0.unk_00 != 0) { + sp18 = func_80175008(); + sp1C = osVoiceControlGain(&D_801FD5B8, analog, digital); + func_8017506C(sp18); + if (sp1C != 0) { + func_801A51F0(sp1C); + } + } +} + +s32 func_801A5488(u8* word) { + s32 sp1C; + s32 sp18; + s32 temp_v0; + + sp18 = func_80175008(); + sp1C = osVoiceCheckWord(word); + func_8017506C(sp18); + return sp1C; +} + +UNK_PTR func_801A54C4(void) { + return &D_801FD608; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54D0.s") @@ -59,6 +118,8 @@ s32 func_801A51F0(s32 errorCode) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A10.s") +void func_801A5A10(void) { + D_801FD5A0.unk_00 = 0; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A1C.s") From d8bc20f1097ace6dc12f90dde65de00f48c3693b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:29:32 +1100 Subject: [PATCH 039/130] Update matching functions in code_801A4EB0 from audio WIP --- src/code/audio/code_801A4EB0.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index d3461c8f5..441a70472 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,17 +1,33 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") +void func_801A5680(u16 arg0); +void func_801A54D0(u16 arg0); + +void func_801A4EB0(void) { +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") +void func_801A5080(u16 arg0) { + if ((D_801D8E3C != 0) && (arg0 < 6)) { + func_801A5680(arg0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") +void func_801A50C0(u16 arg0) { + if ((D_801D8E3C != 0) && (arg0 < 6)) { + func_801A54D0(arg0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") +u16 func_801A5100(void) { + return D_801D8E44; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") +u8 func_801A510C(void) { + return D_801D8E3C; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") From eecc39d5c723a10f6695eee2c18cb849e36b2361 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 16:07:59 +1100 Subject: [PATCH 040/130] Match func_801A5A1C --- src/code/audio/code_801A51F0.c | 44 +++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 20ae5b8e3..91a827bfa 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -17,14 +17,15 @@ typedef struct { extern OSVoiceUnk D_801FD5A0; extern OSVoiceHandle D_801FD5B8; +extern u8 D_801FD610[]; -char D_801D8E50[] = +s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" "PE\0HO\0BO\0PO\0MA\0MI\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; -char D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" +s8 D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" @@ -122,4 +123,41 @@ void func_801A5A10(void) { D_801FD5A0.unk_00 = 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A1C.s") +u8* func_801A5A1C(s8* arg0) { + u8* new_var1; + u8 i; + u8 j; + u8 temp_t6; + u8 temp_t8; + u8* new_var2; + u8 len = strlen(arg0); + + for (j = 0, i = 0; i < len; i += 2) { + + temp_t8 = arg0[i]; + temp_t6 = arg0[i + 1]; + + new_var1 = &temp_t8; + new_var2 = &temp_t6; + + if (temp_t8 == 0x83) { + D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40)]; + D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40) + 1]; + } else if (temp_t8 == 0x82) { + D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F)]; + D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F) + 1]; + } else if (temp_t8 == 0x81 && temp_t6 == 0x5B) { + D_801FD610[j++] = 0x2D; + D_801FD610[j++] = 0x2D; + } else { + D_801FD610[j++] = 0x20; + D_801FD610[j++] = 0x20; + } + } + + D_801FD610[i] = 0; + + return D_801FD610; + +} + From 8a9e49a8896dc120447765ad9527cc270f02a80c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 16:26:50 +1100 Subject: [PATCH 041/130] Match func_801A5228 --- src/code/audio/code_801A51F0.c | 55 ++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 91a827bfa..7dd3a523a 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -4,6 +4,9 @@ s32 func_80175008(); void func_8017506C(s32); +// internal voice functions +u8* func_801A5A1C(s8* arg0); + typedef struct { /* 0x00 */ u8* unk_00; /* 0x04 */ u8 unk_04; @@ -58,7 +61,49 @@ s32 func_801A51F0(s32 errorCode) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5228.s") +s32 func_801A5228(u8* arg0) { + s32 temp_s2; + s32 errorCode; + u8 temp_s1; + u8 i; + u32 indexTemp; + s32 index; + + D_801FD5A0.unk_04 = 0; + D_801FD5A0.unk_08 = 0; + D_801FD5A0.unk_0C = 1000; + D_801FD5A0.unk_0E = 5; + D_801FD5A0.unk_10 = 0; + D_801FD5A0.unk_00 = arg0; + + temp_s1 = arg0[600]; + temp_s2 = func_80175008(); + errorCode = osVoiceClearDictionary(&D_801FD5B8, temp_s1); + func_8017506C(temp_s2); + + if (errorCode != 0) { + return errorCode; + } + + for (i = 0; i < (((temp_s1 - 1) / 8) + 1); i++) { + D_801FD608[i] = 0; + + } + + for (i = 0; i < temp_s1; i++) { + temp_s2 = func_80175008(); + indexTemp = i; + index = indexTemp * 30; + errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); + func_8017506C(temp_s2); + + if (func_801A51F0(errorCode) != 0) { + func_801A5A1C(&arg0[index]); + } + } + + return errorCode; +} s32 func_801A5390(void) { s32 temp_t6; @@ -124,12 +169,12 @@ void func_801A5A10(void) { } u8* func_801A5A1C(s8* arg0) { - u8* new_var1; + u8* indexTemp1; u8 i; u8 j; u8 temp_t6; u8 temp_t8; - u8* new_var2; + u8* index; u8 len = strlen(arg0); for (j = 0, i = 0; i < len; i += 2) { @@ -137,8 +182,8 @@ u8* func_801A5A1C(s8* arg0) { temp_t8 = arg0[i]; temp_t6 = arg0[i + 1]; - new_var1 = &temp_t8; - new_var2 = &temp_t6; + indexTemp1 = &temp_t8; + index = &temp_t6; if (temp_t8 == 0x83) { D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40)]; From aafe1b4e153972568c68ae0e0e8158e6c9c2367d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 17:02:28 +1100 Subject: [PATCH 042/130] Match func_801A54D0 --- src/code/audio/code_801A51F0.c | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 7dd3a523a..23a3e03e8 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -21,6 +21,7 @@ typedef struct { extern OSVoiceUnk D_801FD5A0; extern OSVoiceHandle D_801FD5B8; extern u8 D_801FD610[]; +extern s8 D_801FD5A4; s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" @@ -158,7 +159,51 @@ UNK_PTR func_801A54C4(void) { return &D_801FD608; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54D0.s") +s32 func_801A54D0(u16 arg0) { + s32 errorCode; + u8 phi_t0; + u8 sp22; + u8 i; + s32 sp1C; + + phi_t0 = true; + if (D_801FD5A0.unk_00 != 0) { + sp22 = D_801FD5A0.unk_00[0x258]; + } else { + sp22 = 0x14; + phi_t0 = false; + } + + if (arg0 == 0xFFFF) { + for (i = 0; i < sp22; i++) { + D_801FD608[i / 8] |= 1 << (i % 8); + } + } else { + if (D_801FD608[arg0 / 8] & (1 << (arg0 % 8))) { + phi_t0 = false; + } else { + D_801FD608[arg0 / 8] |= (1 << (arg0 % 8)); + } + } + + if (phi_t0) { + sp1C = func_80175008(); + errorCode = osVoiceStopReadData(&D_801FD5B8); + func_8017506C(sp1C); + + if ((errorCode == 0) || (D_801FD5A4 == 0)) { + sp1C = func_80175008(); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + func_8017506C(sp1C); + } + + D_801FD5A4 = 0; + } + + return errorCode; +} + + #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5680.s") From b1cfaaff8b914101b0b52a9e14f4eeb937c9a971 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 17:13:14 +1100 Subject: [PATCH 043/130] Doc padmgr functions used --- include/functions.h | 4 +-- src/code/audio/code_801A51F0.c | 52 ++++++++++++++++++---------------- src/code/padmgr.c | 4 +-- tools/disasm/functions.txt | 4 +-- tools/sizes/code_functions.csv | 4 +-- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/include/functions.h b/include/functions.h index 4b9982a63..72b802e34 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3191,9 +3191,9 @@ u32 Padmgr_GetControllerBitmask(void); // void func_80174F7C(void); // void func_80174F9C(void); // OSMesgQueue* Padmgr_GetEventCallback(void); -// void func_80175008(void); +OSMesgQueue* PadMgr_LockSerialMesgQueue(); void Padmgr_SetEventCallback(OSMesg pvParm1); -// void func_8017506C(void); +void PadMgr_UnlockSerialMesgQueue(OSMesgQueue* msgQ); // void Padmgr_Lock(void); // void Padmgr_Unlock(void); // void func_801750FC(void); diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 23a3e03e8..bcbf50bd7 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,9 +1,5 @@ #include "global.h" -// padmgr functions -s32 func_80175008(); -void func_8017506C(s32); - // internal voice functions u8* func_801A5A1C(s8* arg0); @@ -63,7 +59,7 @@ s32 func_801A51F0(s32 errorCode) { } s32 func_801A5228(u8* arg0) { - s32 temp_s2; + OSMesgQueue* msgQ; s32 errorCode; u8 temp_s1; u8 i; @@ -78,9 +74,10 @@ s32 func_801A5228(u8* arg0) { D_801FD5A0.unk_00 = arg0; temp_s1 = arg0[600]; - temp_s2 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceClearDictionary(&D_801FD5B8, temp_s1); - func_8017506C(temp_s2); + PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { return errorCode; @@ -92,11 +89,12 @@ s32 func_801A5228(u8* arg0) { } for (i = 0; i < temp_s1; i++) { - temp_s2 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); indexTemp = i; index = indexTemp * 30; errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); - func_8017506C(temp_s2); + PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) != 0) { func_801A5A1C(&arg0[index]); @@ -108,13 +106,15 @@ s32 func_801A5228(u8* arg0) { s32 func_801A5390(void) { s32 temp_t6; - s32 sp18; + OSMesgQueue* msgQ; temp_t6 = D_801FD5A0.unk_08; D_801FD5A0.unk_08 = 0; - sp18 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStartReadData(&D_801FD5B8); - func_8017506C(sp18); + PadMgr_UnlockSerialMesgQueue(msgQ); + return temp_t6; } @@ -132,12 +132,14 @@ void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { void func_801A541C(s32 analog, s32 digital) { s32 sp1C; - s32 sp18; + OSMesgQueue* msgQ; if (D_801FD5A0.unk_00 != 0) { - sp18 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); sp1C = osVoiceControlGain(&D_801FD5B8, analog, digital); - func_8017506C(sp18); + PadMgr_UnlockSerialMesgQueue(msgQ); + if (sp1C != 0) { func_801A51F0(sp1C); } @@ -146,12 +148,13 @@ void func_801A541C(s32 analog, s32 digital) { s32 func_801A5488(u8* word) { s32 sp1C; - s32 sp18; + OSMesgQueue* msgQ; s32 temp_v0; - sp18 = func_80175008(); + msgQ = PadMgr_LockSerialMesgQueue(); sp1C = osVoiceCheckWord(word); - func_8017506C(sp18); + PadMgr_UnlockSerialMesgQueue(msgQ); + return sp1C; } @@ -164,7 +167,7 @@ s32 func_801A54D0(u16 arg0) { u8 phi_t0; u8 sp22; u8 i; - s32 sp1C; + OSMesgQueue* msgQ; phi_t0 = true; if (D_801FD5A0.unk_00 != 0) { @@ -187,16 +190,17 @@ s32 func_801A54D0(u16 arg0) { } if (phi_t0) { - sp1C = func_80175008(); + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStopReadData(&D_801FD5B8); - func_8017506C(sp1C); + PadMgr_UnlockSerialMesgQueue(msgQ); if ((errorCode == 0) || (D_801FD5A4 == 0)) { - sp1C = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); - func_8017506C(sp1C); + PadMgr_UnlockSerialMesgQueue(msgQ); } - + D_801FD5A4 = 0; } diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 0d539126a..dbe85053c 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -13,11 +13,11 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetEventCallback.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175008.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_LockSerialMesgQueue.s") #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_SetEventCallback.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017506C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_UnlockSerialMesgQueue.s") #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Lock.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b6ec70b65..548615ba9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3170,9 +3170,9 @@ 0x80174F7C:("func_80174F7C",), 0x80174F9C:("func_80174F9C",), 0x80174FD4:("Padmgr_GetEventCallback",), - 0x80175008:("func_80175008",), + 0x80175008:("PadMgr_LockSerialMesgQueue",), 0x8017503C:("Padmgr_SetEventCallback",), - 0x8017506C:("func_8017506C",), + 0x8017506C:("PadMgr_UnlockSerialMesgQueue",), 0x8017509C:("Padmgr_Lock",), 0x801750CC:("Padmgr_Unlock",), 0x801750FC:("func_801750FC",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9737ede4d..f6020f817 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2684,9 +2684,9 @@ asm/non_matchings/code/padmgr/func_80174F44.s,func_80174F44,0x80174F44,0xE asm/non_matchings/code/padmgr/func_80174F7C.s,func_80174F7C,0x80174F7C,0x8 asm/non_matchings/code/padmgr/func_80174F9C.s,func_80174F9C,0x80174F9C,0xE asm/non_matchings/code/padmgr/Padmgr_GetEventCallback.s,Padmgr_GetEventCallback,0x80174FD4,0xD -asm/non_matchings/code/padmgr/func_80175008.s,func_80175008,0x80175008,0xD +asm/non_matchings/code/padmgr/PadMgr_LockSerialMesgQueue.s,PadMgr_LockSerialMesgQueue,0x80175008,0xD asm/non_matchings/code/padmgr/Padmgr_SetEventCallback.s,Padmgr_SetEventCallback,0x8017503C,0xC -asm/non_matchings/code/padmgr/func_8017506C.s,func_8017506C,0x8017506C,0xC +asm/non_matchings/code/padmgr/PadMgr_UnlockSerialMesgQueue.s,PadMgr_UnlockSerialMesgQueue,0x8017506C,0xC asm/non_matchings/code/padmgr/Padmgr_Lock.s,Padmgr_Lock,0x8017509C,0xC asm/non_matchings/code/padmgr/Padmgr_Unlock.s,Padmgr_Unlock,0x801750CC,0xC asm/non_matchings/code/padmgr/func_801750FC.s,func_801750FC,0x801750FC,0x9A From 1d30e8ba6b2afa82ef703f9f4e5121caf02106e1 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 18:07:32 +1100 Subject: [PATCH 044/130] Match func_801A5680, it's near identical to func_801A54D0 --- src/code/audio/code_801A51F0.c | 43 ++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index bcbf50bd7..bb2fd4dc1 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -195,7 +195,6 @@ s32 func_801A54D0(u16 arg0) { PadMgr_UnlockSerialMesgQueue(msgQ); if ((errorCode == 0) || (D_801FD5A4 == 0)) { - msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); @@ -207,9 +206,49 @@ s32 func_801A54D0(u16 arg0) { return errorCode; } +s32 func_801A5680(u16 arg0) { + s32 errorCode; + u8 phi_a3; + u8 sp22; + u8 i; + OSMesgQueue* msgQ; + + phi_a3 = true; + if (D_801FD5A0.unk_00 != 0) { + sp22 = D_801FD5A0.unk_00[0x258]; + } else { + sp22 = 0x14; + phi_a3 = false; + } + if (arg0 == 0xFFFF) { + for (i = 0; i < (((sp22 - 1) / 8) + 1); i++) { + D_801FD608[i] = 0; + } + } else { + if (!(D_801FD608[arg0 / 8] & (1 << (arg0 % 8)))) { + phi_a3 = false; + } else { + D_801FD608[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; + } + } + + if (phi_a3) { + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5680.s") + if ((errorCode == 0) || (D_801FD5A4 == 0)) { + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + PadMgr_UnlockSerialMesgQueue(msgQ); + } + + D_801FD5A4 = 0; + } + + return errorCode; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") From 7ac4c334eb7cac1b38fe47db5022c35d4296c180 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 18:41:16 +1100 Subject: [PATCH 045/130] code_801A51F0 OK --- src/code/audio/code_801A51F0.c | 80 +++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index bb2fd4dc1..2bc4a9950 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -5,8 +5,8 @@ u8* func_801A5A1C(s8* arg0); typedef struct { /* 0x00 */ u8* unk_00; - /* 0x04 */ u8 unk_04; - /* 0x08 */ s32 unk_08; + /* 0x04 */ s8 unk_04; + /* 0x08 */ OSVoiceData* unk_08; /* 0x0C */ u16 unk_0C; /* 0x0E */ u16 unk_0E; /* 0x10 */ u16 unk_10; @@ -16,8 +16,11 @@ typedef struct { extern OSVoiceUnk D_801FD5A0; extern OSVoiceHandle D_801FD5B8; +extern OSVoiceData D_801FD5C8; +extern OSVoiceData D_801FD5E8; extern u8 D_801FD610[]; extern s8 D_801FD5A4; +extern u8 D_801FD5C4; s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" @@ -67,7 +70,7 @@ s32 func_801A5228(u8* arg0) { s32 index; D_801FD5A0.unk_04 = 0; - D_801FD5A0.unk_08 = 0; + D_801FD5A0.unk_08 = NULL; D_801FD5A0.unk_0C = 1000; D_801FD5A0.unk_0E = 5; D_801FD5A0.unk_10 = 0; @@ -104,12 +107,12 @@ s32 func_801A5228(u8* arg0) { return errorCode; } -s32 func_801A5390(void) { - s32 temp_t6; +OSVoiceData* func_801A5390(void) { + OSVoiceData* temp_t6; OSMesgQueue* msgQ; temp_t6 = D_801FD5A0.unk_08; - D_801FD5A0.unk_08 = 0; + D_801FD5A0.unk_08 = NULL; msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStartReadData(&D_801FD5B8); @@ -171,9 +174,9 @@ s32 func_801A54D0(u16 arg0) { phi_t0 = true; if (D_801FD5A0.unk_00 != 0) { - sp22 = D_801FD5A0.unk_00[0x258]; + sp22 = D_801FD5A0.unk_00[600]; } else { - sp22 = 0x14; + sp22 = 20; phi_t0 = false; } @@ -215,9 +218,9 @@ s32 func_801A5680(u16 arg0) { phi_a3 = true; if (D_801FD5A0.unk_00 != 0) { - sp22 = D_801FD5A0.unk_00[0x258]; + sp22 = D_801FD5A0.unk_00[600]; } else { - sp22 = 0x14; + sp22 = 20; phi_a3 = false; } @@ -250,7 +253,62 @@ s32 func_801A5680(u16 arg0) { return errorCode; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") +void func_801A5808(void) { + s32 errorCode = 0; + s32 pad; + OSMesgQueue* msgQ; + + switch (D_801FD5A0.unk_04) { + case 0: + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceStartReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + D_801FD5A4 = 1; + break; + case 1: + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceGetReadData(&D_801FD5B8, &D_801FD5C8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + if (func_801A51F0(errorCode) == 0) { + switch (D_801FD5C4) { + case 0: + D_801FD5A4 = 2; + break; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + break; + case 7: + D_801FD5A4 = 2; + break; + } + } + break; + case 2: + if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { + D_801FD5E8 = D_801FD5C8; + D_801FD5A0.unk_08 = &D_801FD5E8; + } + + msgQ = PadMgr_LockSerialMesgQueue(); + osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceStartReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + D_801FD5A4 = 1; + break; + } + + func_801A51F0(errorCode); +} void func_801A5A10(void) { D_801FD5A0.unk_00 = 0; From 11275cf1b48cefc5d432ff9e5e74ea53d66efe8b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:10:21 +1100 Subject: [PATCH 046/130] Match func_801A4EB8 --- src/code/audio/code_801A4EB0.c | 40 +++++++++++++++++++++++++++++++++- src/code/audio/code_801A51F0.c | 4 ++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 441a70472..03d71c4b9 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,12 +1,50 @@ #include "global.h" +s32 func_801A5228(u8* arg0); +void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); + void func_801A5680(u16 arg0); void func_801A54D0(u16 arg0); +u8* func_801A54C4(void); + +extern u8 D_801D8BE0; +extern OSVoiceHandle D_801FD5B8; void func_801A4EB0(void) { } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") +void func_801A4EB8(void) { + u8* new_var; + OSMesgQueue* msgQ; + s32 index; + u8 sp38[1]; + u8 i; + + if (D_801D8E3C != 0) { + msgQ = PadMgr_LockSerialMesgQueue(); + osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + } + + new_var = func_801A54C4(); + + for (i = 0; i < 1; i++) { + sp38[i] = new_var[i]; + } + + if (func_801A5228(&D_801D8BE0) == 0) { + for (i = 0; i < 6; i++) { + index = i / 8; + if (((sp38[index] >> (i % 8)) & 1) == 1) { + func_801A54D0(i); + } + + } + + func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + D_801D8E3C = 1; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 2bc4a9950..03e186283 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -161,8 +161,8 @@ s32 func_801A5488(u8* word) { return sp1C; } -UNK_PTR func_801A54C4(void) { - return &D_801FD608; +u8* func_801A54C4(void) { + return D_801FD608; } s32 func_801A54D0(u16 arg0) { From 716de8820ef3b9006013e6ce45bbaeede3a58934 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:13:53 +1100 Subject: [PATCH 047/130] Match func_801A4FD8 (mips2c got it matching directly) --- src/code/audio/code_801A4EB0.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 03d71c4b9..ee4c9f4e6 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,8 +1,11 @@ #include "global.h" +void func_801A5080(u16 arg0); + s32 func_801A5228(u8* arg0); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); + void func_801A5680(u16 arg0); void func_801A54D0(u16 arg0); u8* func_801A54C4(void); @@ -46,7 +49,26 @@ void func_801A4EB8(void) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") +void func_801A4FD8(void) { + s32 sp24; + OSMesgQueue* msgQ; + + func_801A54D0(0xFFFF); + if (D_801D8E3C != 0) { + msgQ = PadMgr_LockSerialMesgQueue(); + osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + sp24 = func_801A5228(&D_801D8BE0); + func_801A54D0(0xFFFF); + if (sp24 == 0) { + func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + D_801D8E3C = 1; + } + func_801A5080(5); + func_801A5080(1); + } +} void func_801A5080(u16 arg0) { if ((D_801D8E3C != 0) && (arg0 < 6)) { From 957bc0b65f7e4f6010610058660065f05ded310b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:23:33 +1100 Subject: [PATCH 048/130] code_801A4EB0 & all of voice, OK --- src/code/audio/code_801A4EB0.c | 33 ++++++++++++++++++++++++++++++--- src/code/audio/code_801A51F0.c | 6 +++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index ee4c9f4e6..bb496ad5c 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -4,14 +4,16 @@ void func_801A5080(u16 arg0); s32 func_801A5228(u8* arg0); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); - - +s32 func_801A5808(void); +OSVoiceData* func_801A5390(void); void func_801A5680(u16 arg0); void func_801A54D0(u16 arg0); u8* func_801A54C4(void); extern u8 D_801D8BE0; extern OSVoiceHandle D_801FD5B8; +extern OSVoiceData* D_801D8E40; +extern u8 D_801D8E48; void func_801A4EB0(void) { } @@ -90,4 +92,29 @@ u8 func_801A510C(void) { return D_801D8E3C; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") +void func_801A5118(void) { + if (D_801D8E3C & 2) { + D_801D8E3C &= 1; + func_801A4EB8(); + } + + if (D_801D8E3C != 0) { + if (func_801A5808() != 0) { + D_801D8E48++; + if (D_801D8E48 == 0xA) { + D_801D8E3C = 0; + D_801D8E44 = 0xFFFF; + return; + } + } else { + D_801D8E48 = 0; + } + + D_801D8E40 = func_801A5390(); + if (D_801D8E40 != 0) { + D_801D8E44 = D_801D8E40->answer[0]; + } else { + D_801D8E44 = 0xFFFF; + } + } +} diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 03e186283..acff8dba6 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -253,9 +253,9 @@ s32 func_801A5680(u16 arg0) { return errorCode; } -void func_801A5808(void) { +s32 func_801A5808(void) { s32 errorCode = 0; - s32 pad; + s32 ret; OSMesgQueue* msgQ; switch (D_801FD5A0.unk_04) { @@ -307,7 +307,7 @@ void func_801A5808(void) { break; } - func_801A51F0(errorCode); + return func_801A51F0(errorCode); } void func_801A5A10(void) { From 1ede43f7ac6c4eaaab4a1590f77a9c8f714808aa Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:55:04 +1100 Subject: [PATCH 049/130] Import bss --- include/os.h | 11 +++++++ spec | 1 - src/boot_O2_g3/idle.c | 1 + src/code/audio/code_801A51F0.c | 59 ++++++++++++++++++---------------- src/libultra/flash/osFlash.c | 1 + tools/disasm/variables.txt | 3 +- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/include/os.h b/include/os.h index 82e1ac013..f894c2077 100644 --- a/include/os.h +++ b/include/os.h @@ -150,4 +150,15 @@ typedef struct { /* 0x14 */ u16 distance[5]; /* Distance value */ } OSVoiceData; // size = 0x20 +typedef struct { + /* 0x00 */ u8* unk_00; + /* 0x04 */ s8 unk_04; + /* 0x08 */ OSVoiceData* unk_08; + /* 0x0C */ u16 unk_0C; + /* 0x0E */ u16 unk_0E; + /* 0x10 */ u16 unk_10; + /* 0x12 */ u16 unk_12; + /* 0x14 */ u16 unk_14; +} OSVoiceUnk; // size = 0x18 + #endif diff --git a/spec b/spec index 8ba7c36ea..a1c57f47f 100644 --- a/spec +++ b/spec @@ -660,7 +660,6 @@ beginseg include "build/data/code/code_801D55B0.data.o" include "build/src/code/audio/code_801A4EB0.o" include "build/src/code/audio/code_801A51F0.o" - include "build/data/code/code_801A51F0.bss.o" pad_text include "build/src/code/code_801A5BD0.o" include "build/data/code/code_801A5BD0.bss.o" diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 4f9146530..4fe22534c 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index acff8dba6..cd89ba4df 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -3,25 +3,25 @@ // internal voice functions u8* func_801A5A1C(s8* arg0); -typedef struct { - /* 0x00 */ u8* unk_00; - /* 0x04 */ s8 unk_04; - /* 0x08 */ OSVoiceData* unk_08; - /* 0x0C */ u16 unk_0C; - /* 0x0E */ u16 unk_0E; - /* 0x10 */ u16 unk_10; - /* 0x12 */ u16 unk_12; - /* 0x14 */ u16 unk_14; -} OSVoiceUnk; // size = 0x18 +// BSS +OSVoiceUnk D_801FD5A0; +OSVoiceHandle D_801FD5B8; +OSVoiceData D_801FD5C8; +OSVoiceData D_801FD5E8; +u8 D_801FD608[8]; -extern OSVoiceUnk D_801FD5A0; -extern OSVoiceHandle D_801FD5B8; -extern OSVoiceData D_801FD5C8; -extern OSVoiceData D_801FD5E8; -extern u8 D_801FD610[]; -extern s8 D_801FD5A4; -extern u8 D_801FD5C4; +// Maybe all the same? +// u8 D_801FD610[0x11B0]; +u8 D_801FD610[0x100]; +u8 D_801FD710[0x1B0]; +u8 D_801FD8C0[0x240]; +u8 D_801FDB00[0x600]; +u8 D_801FE100[0x3C0]; +u8 D_801FE4C0[0x180]; +u8 D_801FE640[0x90]; +u8 D_801FE6D0[0xF0]; +// Data s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" @@ -197,13 +197,13 @@ s32 func_801A54D0(u16 arg0) { errorCode = osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A4 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A4 = 0; + D_801FD5A0.unk_04 = 0; } return errorCode; @@ -241,30 +241,33 @@ s32 func_801A5680(u16 arg0) { errorCode = osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A4 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A4 = 0; + D_801FD5A0.unk_04 = 0; } return errorCode; } +// #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") s32 func_801A5808(void) { s32 errorCode = 0; s32 ret; OSMesgQueue* msgQ; + if (1) {} + switch (D_801FD5A0.unk_04) { case 0: msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStartReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A4 = 1; + D_801FD5A0.unk_04 = 1; break; case 1: msgQ = PadMgr_LockSerialMesgQueue(); @@ -272,9 +275,9 @@ s32 func_801A5808(void) { PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) == 0) { - switch (D_801FD5C4) { + switch (D_801FD5B8.status) { case 0: - D_801FD5A4 = 2; + D_801FD5A0.unk_04 = 2; break; case 1: case 2: @@ -284,7 +287,7 @@ s32 func_801A5808(void) { case 6: break; case 7: - D_801FD5A4 = 2; + D_801FD5A0.unk_04 = 2; break; } } @@ -303,11 +306,13 @@ s32 func_801A5808(void) { errorCode = osVoiceStartReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A4 = 1; + D_801FD5A0.unk_04 = 1; break; } - return func_801A51F0(errorCode); + ret = func_801A51F0(errorCode); + + return ret; } void func_801A5A10(void) { diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index bf3044029..cf90bc75b 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "ultra64.h" #include "global.h" diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b320e233f..4a4937eb7 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4419,8 +4419,7 @@ 0x801FD533:("D_801FD533","UNK_TYPE1","",0x1), 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), - 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), - 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), + 0x801FD5A0:("D_801FD5A0","u8","0x18",0x1), 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), 0x801FD5C4:("D_801FD5C4","UNK_TYPE1","",0x1), 0x801FD5C8:("D_801FD5C8","UNK_TYPE1","",0x1), From 35297dfa170ba9c8c5cf549bc30777a97f7f5518 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 20:03:00 +1100 Subject: [PATCH 050/130] Better match for func_801A5A1C --- src/code/audio/code_801A51F0.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index cd89ba4df..cdb443307 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -253,7 +253,6 @@ s32 func_801A5680(u16 arg0) { return errorCode; } -// #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") s32 func_801A5808(void) { s32 errorCode = 0; s32 ret; @@ -320,29 +319,22 @@ void func_801A5A10(void) { } u8* func_801A5A1C(s8* arg0) { - u8* indexTemp1; u8 i; u8 j; - u8 temp_t6; - u8 temp_t8; - u8* index; u8 len = strlen(arg0); + u8 temp_t8[2]; for (j = 0, i = 0; i < len; i += 2) { + temp_t8[0] = arg0[i]; + temp_t8[1] = arg0[i + 1]; - temp_t8 = arg0[i]; - temp_t6 = arg0[i + 1]; - - indexTemp1 = &temp_t8; - index = &temp_t6; - - if (temp_t8 == 0x83) { - D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40)]; - D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40) + 1]; - } else if (temp_t8 == 0x82) { - D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F)]; - D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F) + 1]; - } else if (temp_t8 == 0x81 && temp_t6 == 0x5B) { + if (temp_t8[0] == 0x83) { + D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40)]; + D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40) + 1]; + } else if (temp_t8[0] == 0x82) { + D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F)]; + D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F) + 1]; + } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { D_801FD610[j++] = 0x2D; D_801FD610[j++] = 0x2D; } else { From 97d720e788a3c762c09cb6a337629662bcdd4a36 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 20:05:29 +1100 Subject: [PATCH 051/130] format --- src/code/audio/code_801A4EB0.c | 3 +-- src/code/audio/code_801A51F0.c | 39 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index bb496ad5c..4863a68a5 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -43,7 +43,6 @@ void func_801A4EB8(void) { if (((sp38[index] >> (i % 8)) & 1) == 1) { func_801A54D0(i); } - } func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); @@ -97,7 +96,7 @@ void func_801A5118(void) { D_801D8E3C &= 1; func_801A4EB8(); } - + if (D_801D8E3C != 0) { if (func_801A5808() != 0) { D_801D8E48++; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index cdb443307..18bf8bcb7 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -12,7 +12,7 @@ u8 D_801FD608[8]; // Maybe all the same? // u8 D_801FD610[0x11B0]; -u8 D_801FD610[0x100]; +u8 D_801FD610[0x100]; u8 D_801FD710[0x1B0]; u8 D_801FD8C0[0x240]; u8 D_801FDB00[0x600]; @@ -29,10 +29,10 @@ s8 D_801D8E50[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; s8 D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" - "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" - "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " - "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" + "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " + "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; /* char D_801E0EC0[] = "Error %d\n" @@ -75,7 +75,7 @@ s32 func_801A5228(u8* arg0) { D_801FD5A0.unk_0E = 5; D_801FD5A0.unk_10 = 0; D_801FD5A0.unk_00 = arg0; - + temp_s1 = arg0[600]; msgQ = PadMgr_LockSerialMesgQueue(); @@ -84,11 +84,10 @@ s32 func_801A5228(u8* arg0) { if (errorCode != 0) { return errorCode; - } + } for (i = 0; i < (((temp_s1 - 1) / 8) + 1); i++) { D_801FD608[i] = 0; - } for (i = 0; i < temp_s1; i++) { @@ -98,7 +97,7 @@ s32 func_801A5228(u8* arg0) { index = indexTemp * 30; errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); PadMgr_UnlockSerialMesgQueue(msgQ); - + if (func_801A51F0(errorCode) != 0) { func_801A5A1C(&arg0[index]); } @@ -171,7 +170,7 @@ s32 func_801A54D0(u16 arg0) { u8 sp22; u8 i; OSMesgQueue* msgQ; - + phi_t0 = true; if (D_801FD5A0.unk_00 != 0) { sp22 = D_801FD5A0.unk_00[600]; @@ -191,7 +190,7 @@ s32 func_801A54D0(u16 arg0) { D_801FD608[arg0 / 8] |= (1 << (arg0 % 8)); } } - + if (phi_t0) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStopReadData(&D_801FD5B8); @@ -205,7 +204,7 @@ s32 func_801A54D0(u16 arg0) { D_801FD5A0.unk_04 = 0; } - + return errorCode; } @@ -215,7 +214,7 @@ s32 func_801A5680(u16 arg0) { u8 sp22; u8 i; OSMesgQueue* msgQ; - + phi_a3 = true; if (D_801FD5A0.unk_00 != 0) { sp22 = D_801FD5A0.unk_00[600]; @@ -235,7 +234,7 @@ s32 func_801A5680(u16 arg0) { D_801FD608[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; } } - + if (phi_a3) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStopReadData(&D_801FD5B8); @@ -249,7 +248,7 @@ s32 func_801A5680(u16 arg0) { D_801FD5A0.unk_04 = 0; } - + return errorCode; } @@ -292,7 +291,9 @@ s32 func_801A5808(void) { } break; case 2: - if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { + if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && + (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && + (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { D_801FD5E8 = D_801FD5C8; D_801FD5A0.unk_08 = &D_801FD5E8; } @@ -300,7 +301,7 @@ s32 func_801A5808(void) { msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStartReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); @@ -342,10 +343,8 @@ u8* func_801A5A1C(s8* arg0) { D_801FD610[j++] = 0x20; } } - + D_801FD610[i] = 0; return D_801FD610; - } - From e488020b458779d8ece659451a696f19ae1949fc Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 22:18:44 +1100 Subject: [PATCH 052/130] Cleanup --- src/code/audio/code_801A4EB0.c | 22 +++++--- src/code/audio/code_801A51F0.c | 99 ++++++++++++++++++++++------------ 2 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 4863a68a5..62b88449b 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -6,8 +6,8 @@ s32 func_801A5228(u8* arg0); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); -void func_801A5680(u16 arg0); -void func_801A54D0(u16 arg0); +s32 func_801A5680(u16 arg0); +s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); extern u8 D_801D8BE0; @@ -45,13 +45,14 @@ void func_801A4EB8(void) { } } - func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; } } +// Used externally in code_8019AF00 void func_801A4FD8(void) { - s32 sp24; + s32 errorCode; OSMesgQueue* msgQ; func_801A54D0(0xFFFF); @@ -60,12 +61,13 @@ void func_801A4FD8(void) { osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - sp24 = func_801A5228(&D_801D8BE0); + errorCode = func_801A5228(&D_801D8BE0); func_801A54D0(0xFFFF); - if (sp24 == 0) { - func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + if (errorCode == 0) { + func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; } + func_801A5080(5); func_801A5080(1); } @@ -77,20 +79,24 @@ void func_801A5080(u16 arg0) { } } +// Unused void func_801A50C0(u16 arg0) { if ((D_801D8E3C != 0) && (arg0 < 6)) { func_801A54D0(arg0); } } +// Used externally in many files u16 func_801A5100(void) { return D_801D8E44; } +// Unused u8 func_801A510C(void) { return D_801D8E3C; } +// Used externally in Audio_Update (code_8019AF00) void func_801A5118(void) { if (D_801D8E3C & 2) { D_801D8E3C &= 1; @@ -100,7 +106,7 @@ void func_801A5118(void) { if (D_801D8E3C != 0) { if (func_801A5808() != 0) { D_801D8E48++; - if (D_801D8E48 == 0xA) { + if (D_801D8E48 == 10) { D_801D8E3C = 0; D_801D8E44 = 0xFFFF; return; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 18bf8bcb7..8227f6b4a 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -12,7 +12,7 @@ u8 D_801FD608[8]; // Maybe all the same? // u8 D_801FD610[0x11B0]; -u8 D_801FD610[0x100]; +char D_801FD610[0x100]; u8 D_801FD710[0x1B0]; u8 D_801FD8C0[0x240]; u8 D_801FDB00[0x600]; @@ -22,17 +22,43 @@ u8 D_801FE640[0x90]; u8 D_801FE6D0[0xF0]; // Data -s8 D_801D8E50[] = - "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" - "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" - "PE\0HO\0BO\0PO\0MA\0MI\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +s8 D_801D8E50[] = { + 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', + 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', + 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', + 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', + 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', + 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', + 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', + 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', + 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', + 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', + 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', 'M', 'U', '\0', 'M', 'E', '\0', 'M', 'O', '\0', + 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', 'Y', 'O', '\0', + 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', 'w', 'a', '\0', + 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', 'V', 'U', '\0', + 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +}; -s8 D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" - "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" - "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " - "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +s8 D_801D8F70[] = { + 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', + 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', + 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', + 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', + 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', + 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', + 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', + 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', + 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', + 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', + 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', ' ', ' ', '\0', 'M', 'U', '\0', 'M', 'E', '\0', + 'M', 'O', '\0', 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', + 'Y', 'O', '\0', 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', + 'w', 'a', '\0', 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', + 'V', 'U', '\0', 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +}; /* char D_801E0EC0[] = "Error %d\n" @@ -120,6 +146,7 @@ OSVoiceData* func_801A5390(void) { return temp_t6; } +// Unused s32 func_801A53DC(void) { return D_801FD5A0.unk_00; } @@ -132,32 +159,33 @@ void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { D_801FD5A0.unk_14 = arg4; } -void func_801A541C(s32 analog, s32 digital) { - s32 sp1C; +// Unused +// Could have a return? or be void return? +s32 func_801A541C(s32 analog, s32 digital) { + s32 errorCode; OSMesgQueue* msgQ; - if (D_801FD5A0.unk_00 != 0) { - + if (D_801FD5A0.unk_00 != NULL) { msgQ = PadMgr_LockSerialMesgQueue(); - sp1C = osVoiceControlGain(&D_801FD5B8, analog, digital); + errorCode = osVoiceControlGain(&D_801FD5B8, analog, digital); PadMgr_UnlockSerialMesgQueue(msgQ); - if (sp1C != 0) { - func_801A51F0(sp1C); + if (errorCode != 0) { + func_801A51F0(errorCode); } } } +// Unused s32 func_801A5488(u8* word) { - s32 sp1C; + s32 errorCode; OSMesgQueue* msgQ; - s32 temp_v0; msgQ = PadMgr_LockSerialMesgQueue(); - sp1C = osVoiceCheckWord(word); + errorCode = osVoiceCheckWord(word); PadMgr_UnlockSerialMesgQueue(msgQ); - return sp1C; + return errorCode; } u8* func_801A54C4(void) { @@ -172,7 +200,7 @@ s32 func_801A54D0(u16 arg0) { OSMesgQueue* msgQ; phi_t0 = true; - if (D_801FD5A0.unk_00 != 0) { + if (D_801FD5A0.unk_00 != NULL) { sp22 = D_801FD5A0.unk_00[600]; } else { sp22 = 20; @@ -216,7 +244,7 @@ s32 func_801A5680(u16 arg0) { OSMesgQueue* msgQ; phi_a3 = true; - if (D_801FD5A0.unk_00 != 0) { + if (D_801FD5A0.unk_00 != NULL) { sp22 = D_801FD5A0.unk_00[600]; } else { sp22 = 20; @@ -274,17 +302,17 @@ s32 func_801A5808(void) { if (func_801A51F0(errorCode) == 0) { switch (D_801FD5B8.status) { - case 0: + case VOICE_STATUS_READY: D_801FD5A0.unk_04 = 2; break; - case 1: + case VOICE_STATUS_START: case 2: - case 3: + case VOICE_STATUS_CANCEL: case 4: - case 5: + case VOICE_STATUS_BUSY: case 6: break; - case 7: + case VOICE_STATUS_END: D_801FD5A0.unk_04 = 2; break; } @@ -315,8 +343,9 @@ s32 func_801A5808(void) { return ret; } +// Unused void func_801A5A10(void) { - D_801FD5A0.unk_00 = 0; + D_801FD5A0.unk_00 = NULL; } u8* func_801A5A1C(s8* arg0) { @@ -336,15 +365,15 @@ u8* func_801A5A1C(s8* arg0) { D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F)]; D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F) + 1]; } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { - D_801FD610[j++] = 0x2D; - D_801FD610[j++] = 0x2D; + D_801FD610[j++] = '-'; + D_801FD610[j++] = '-'; } else { - D_801FD610[j++] = 0x20; - D_801FD610[j++] = 0x20; + D_801FD610[j++] = ' '; + D_801FD610[j++] = ' '; } } - D_801FD610[i] = 0; + D_801FD610[i] = '\0'; return D_801FD610; } From 12164233fa5db4fbd0ac5d62a4542720ea53d814 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 01:49:17 +1100 Subject: [PATCH 053/130] Clean up dictionary --- src/code/audio/code_801A51F0.c | 56 +++++++++++----------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 8227f6b4a..1d519758d 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -22,42 +22,22 @@ u8 D_801FE640[0x90]; u8 D_801FE6D0[0xF0]; // Data -s8 D_801D8E50[] = { - 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', - 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', - 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', - 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', - 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', - 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', - 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', - 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', - 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', - 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', - 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', 'M', 'U', '\0', 'M', 'E', '\0', 'M', 'O', '\0', - 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', 'Y', 'O', '\0', - 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', 'w', 'a', '\0', - 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', 'V', 'U', '\0', - 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +s8 D_801D8E50[96][3] = { + "aa", "AA", "ii", "II", "uu", "UU", "ee", "EE", "oo", "OO", "KA", "GA", "KI", "GI", "KU", "GU", + "KE", "GE", "KO", "GO", "SA", "ZA", "SI", "ZI", "SU", "ZU", "SE", "ZE", "SO", "ZO", "TA", "DA", + "TI", "DI", "tu", "TU", "DU", "TE", "DE", "TO", "DO", "NA", "NI", "NU", "NE", "NO", "HA", "BA", + "PA", "HI", "BI", "PI", "HU", "BU", "PU", "HE", "BE", "PE", "HO", "BO", "PO", "MA", "MI", "MU", + "ME", "MO", "ya", "YA", "yu", "YU", "yo", "YO", "RA", "RI", "RU", "RE", "RO", "wa", "WA", "WI", + "WE", "WO", "NN", "VU", "ka", "ke", "", "", "", "", "", "", "", "", "", "", }; -s8 D_801D8F70[] = { - 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', - 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', - 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', - 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', - 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', - 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', - 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', - 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', - 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', - 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', - 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', ' ', ' ', '\0', 'M', 'U', '\0', 'M', 'E', '\0', - 'M', 'O', '\0', 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', - 'Y', 'O', '\0', 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', - 'w', 'a', '\0', 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', - 'V', 'U', '\0', 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +s8 D_801D8F70[96][3] = { + "aa", "AA", "ii", "II", "uu", "UU", "ee", "EE", "oo", "OO", "KA", "GA", "KI", "GI", "KU", "GU", + "KE", "GE", "KO", "GO", "SA", "ZA", "SI", "ZI", "SU", "ZU", "SE", "ZE", "SO", "ZO", "TA", "DA", + "TI", "DI", "tu", "TU", "DU", "TE", "DE", "TO", "DO", "NA", "NI", "NU", "NE", "NO", "HA", "BA", + "PA", "HI", "BI", "PI", "HU", "BU", "PU", "HE", "BE", "PE", "HO", "BO", "PO", "MA", "MI", " ", + "MU", "ME", "MO", "ya", "YA", "yu", "YU", "yo", "YO", "RA", "RI", "RU", "RE", "RO", "wa", "WA", + "WI", "WE", "WO", "NN", "VU", "ka", "ke", "", "", "", "", "", "", "", "", "", }; /* @@ -359,11 +339,11 @@ u8* func_801A5A1C(s8* arg0) { temp_t8[1] = arg0[i + 1]; if (temp_t8[0] == 0x83) { - D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40)]; - D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40) + 1]; + D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][0]; + D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][1]; } else if (temp_t8[0] == 0x82) { - D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F)]; - D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F) + 1]; + D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][0]; + D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][1]; } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { D_801FD610[j++] = '-'; D_801FD610[j++] = '-'; From cb5d51579bdd289d980ace13500d17b13cfcd38f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 12:33:06 +1100 Subject: [PATCH 054/130] Introduce OSVoiceDictionary --- include/os.h | 9 +++- src/code/audio/code_801A4EB0.c | 4 +- src/code/audio/code_801A51F0.c | 89 ++++++++++++++++------------------ 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/include/os.h b/include/os.h index f894c2077..614b6c99a 100644 --- a/include/os.h +++ b/include/os.h @@ -151,9 +151,14 @@ typedef struct { } OSVoiceData; // size = 0x20 typedef struct { - /* 0x00 */ u8* unk_00; + /* 0x000 */ u8 words[20][30]; // 20 words, each with up to 15 syllables + /* 0x258 */ u8 numWords; +} OSVoiceDictionary; // size = 0x25C + +typedef struct { + /* 0x00 */ OSVoiceDictionary* dict; /* 0x04 */ s8 unk_04; - /* 0x08 */ OSVoiceData* unk_08; + /* 0x08 */ OSVoiceData* data; /* 0x0C */ u16 unk_0C; /* 0x0E */ u16 unk_0E; /* 0x10 */ u16 unk_10; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 62b88449b..bc08e9f77 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -2,7 +2,7 @@ void func_801A5080(u16 arg0); -s32 func_801A5228(u8* arg0); +s32 func_801A5228(OSVoiceDictionary* dict); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); @@ -10,7 +10,7 @@ s32 func_801A5680(u16 arg0); s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); -extern u8 D_801D8BE0; +extern OSVoiceDictionary D_801D8BE0; extern OSVoiceHandle D_801FD5B8; extern OSVoiceData* D_801D8E40; extern u8 D_801D8E48; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 1d519758d..ff0e2b6da 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -67,45 +67,40 @@ s32 func_801A51F0(s32 errorCode) { } } -s32 func_801A5228(u8* arg0) { +s32 func_801A5228(OSVoiceDictionary* dict) { OSMesgQueue* msgQ; s32 errorCode; - u8 temp_s1; + u8 numWords; u8 i; - u32 indexTemp; - s32 index; D_801FD5A0.unk_04 = 0; - D_801FD5A0.unk_08 = NULL; + D_801FD5A0.data = NULL; D_801FD5A0.unk_0C = 1000; D_801FD5A0.unk_0E = 5; D_801FD5A0.unk_10 = 0; - D_801FD5A0.unk_00 = arg0; + D_801FD5A0.dict = dict; - temp_s1 = arg0[600]; + numWords = dict->numWords; msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceClearDictionary(&D_801FD5B8, temp_s1); + errorCode = osVoiceClearDictionary(&D_801FD5B8, numWords); PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { return errorCode; } - for (i = 0; i < (((temp_s1 - 1) / 8) + 1); i++) { + for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { D_801FD608[i] = 0; } - for (i = 0; i < temp_s1; i++) { - + for (i = 0; i < numWords; i++) { msgQ = PadMgr_LockSerialMesgQueue(); - indexTemp = i; - index = indexTemp * 30; - errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); + errorCode = osVoiceSetWord(&D_801FD5B8, &dict->words[i]); PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) != 0) { - func_801A5A1C(&arg0[index]); + func_801A5A1C(&dict->words[i]); } } @@ -116,8 +111,8 @@ OSVoiceData* func_801A5390(void) { OSVoiceData* temp_t6; OSMesgQueue* msgQ; - temp_t6 = D_801FD5A0.unk_08; - D_801FD5A0.unk_08 = NULL; + temp_t6 = D_801FD5A0.data; + D_801FD5A0.data = NULL; msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStartReadData(&D_801FD5B8); @@ -127,8 +122,8 @@ OSVoiceData* func_801A5390(void) { } // Unused -s32 func_801A53DC(void) { - return D_801FD5A0.unk_00; +OSVoiceDictionary* func_801A53DC(void) { + return D_801FD5A0.dict; } void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { @@ -145,7 +140,7 @@ s32 func_801A541C(s32 analog, s32 digital) { s32 errorCode; OSMesgQueue* msgQ; - if (D_801FD5A0.unk_00 != NULL) { + if (D_801FD5A0.dict != NULL) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceControlGain(&D_801FD5B8, analog, digital); PadMgr_UnlockSerialMesgQueue(msgQ); @@ -175,20 +170,20 @@ u8* func_801A54C4(void) { s32 func_801A54D0(u16 arg0) { s32 errorCode; u8 phi_t0; - u8 sp22; + u8 numWords; u8 i; OSMesgQueue* msgQ; phi_t0 = true; - if (D_801FD5A0.unk_00 != NULL) { - sp22 = D_801FD5A0.unk_00[600]; + if (D_801FD5A0.dict != NULL) { + numWords = D_801FD5A0.dict->numWords; } else { - sp22 = 20; + numWords = 20; phi_t0 = false; } if (arg0 == 0xFFFF) { - for (i = 0; i < sp22; i++) { + for (i = 0; i < numWords; i++) { D_801FD608[i / 8] |= 1 << (i % 8); } } else { @@ -206,7 +201,7 @@ s32 func_801A54D0(u16 arg0) { if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } @@ -219,20 +214,20 @@ s32 func_801A54D0(u16 arg0) { s32 func_801A5680(u16 arg0) { s32 errorCode; u8 phi_a3; - u8 sp22; + u8 numWords; u8 i; OSMesgQueue* msgQ; phi_a3 = true; - if (D_801FD5A0.unk_00 != NULL) { - sp22 = D_801FD5A0.unk_00[600]; + if (D_801FD5A0.dict != NULL) { + numWords = D_801FD5A0.dict->numWords; } else { - sp22 = 20; + numWords = 20; phi_a3 = false; } if (arg0 == 0xFFFF) { - for (i = 0; i < (((sp22 - 1) / 8) + 1); i++) { + for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { D_801FD608[i] = 0; } } else { @@ -250,7 +245,7 @@ s32 func_801A5680(u16 arg0) { if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } @@ -303,7 +298,7 @@ s32 func_801A5808(void) { (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { D_801FD5E8 = D_801FD5C8; - D_801FD5A0.unk_08 = &D_801FD5E8; + D_801FD5A0.data = &D_801FD5E8; } msgQ = PadMgr_LockSerialMesgQueue(); @@ -325,26 +320,26 @@ s32 func_801A5808(void) { // Unused void func_801A5A10(void) { - D_801FD5A0.unk_00 = NULL; + D_801FD5A0.dict = NULL; } -u8* func_801A5A1C(s8* arg0) { +u8* func_801A5A1C(s8* word) { u8 i; u8 j; - u8 len = strlen(arg0); - u8 temp_t8[2]; + u8 numSyllables = strlen(word); // technically twice the num of syllables + u8 syllable[2]; - for (j = 0, i = 0; i < len; i += 2) { - temp_t8[0] = arg0[i]; - temp_t8[1] = arg0[i + 1]; + for (j = 0, i = 0; i < numSyllables; i += 2) { + syllable[0] = word[i]; + syllable[1] = word[i + 1]; - if (temp_t8[0] == 0x83) { - D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][0]; - D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][1]; - } else if (temp_t8[0] == 0x82) { - D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][0]; - D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][1]; - } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { + if (syllable[0] == 0x83) { + D_801FD610[j++] = D_801D8F70[syllable[1] - 0x40][0]; + D_801FD610[j++] = D_801D8F70[syllable[1] - 0x40][1]; + } else if (syllable[0] == 0x82) { + D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][0]; + D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][1]; + } else if (syllable[0] == 0x81 && syllable[1] == 0x5B) { D_801FD610[j++] = '-'; D_801FD610[j++] = '-'; } else { From 418b4718b88d30c94c129243067e366de3dbe8ca Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 13:25:34 +1100 Subject: [PATCH 055/130] More voice docs --- include/os.h | 20 ++--- include/variables.h | 4 +- src/code/audio/code_801A4EB0.c | 8 +- src/code/audio/code_801A51F0.c | 108 +++++++++++++------------- src/libultra/voice/voicegetreaddata.c | 10 +-- tools/disasm/variables.txt | 4 +- 6 files changed, 76 insertions(+), 78 deletions(-) diff --git a/include/os.h b/include/os.h index ee5ec86f4..379f18746 100644 --- a/include/os.h +++ b/include/os.h @@ -161,10 +161,10 @@ typedef struct { typedef struct { /* 0x00 */ u16 warning; /* Warning */ - /* 0x02 */ u16 answer_num; /* Candidate number (0~5) */ - /* 0x04 */ u16 voice_level; /* Voice input level */ - /* 0x06 */ u16 voice_sn; /* Relative voice level */ - /* 0x08 */ u16 voice_time; /* Voice input time */ + /* 0x02 */ u16 answerNum; /* Candidate number (0~5) */ + /* 0x04 */ u16 voiceLevel; /* Voice input level */ + /* 0x06 */ u16 voiceRelLevel; /* Relative voice level "voice_sn" */ + /* 0x08 */ u16 voiceTime; /* Voice input time */ /* 0x0A */ u16 answer[5]; /* Candidate word number */ /* 0x14 */ u16 distance[5]; /* Distance value */ } OSVoiceData; // size = 0x20 @@ -176,13 +176,13 @@ typedef struct { typedef struct { /* 0x00 */ OSVoiceDictionary* dict; - /* 0x04 */ s8 unk_04; + /* 0x04 */ s8 mode; /* 0x08 */ OSVoiceData* data; - /* 0x0C */ u16 unk_0C; - /* 0x0E */ u16 unk_0E; - /* 0x10 */ u16 unk_10; - /* 0x12 */ u16 unk_12; - /* 0x14 */ u16 unk_14; + /* 0x0C */ u16 distance; + /* 0x0E */ u16 answerNum; + /* 0x10 */ u16 warning; + /* 0x12 */ u16 voiceLevel; + /* 0x14 */ u16 voiceRelLevel; } OSVoiceUnk; // size = 0x18 #endif diff --git a/include/variables.h b/include/variables.h index be7cb79cf..a5adc2d93 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3621,11 +3621,11 @@ extern OSMesg D_801FD034; // extern UNK_TYPE1 D_801FD598; // extern UNK_TYPE1 D_801FD5A0; // extern UNK_TYPE1 D_801FD5A4; -// extern UNK_TYPE1 D_801FD5B8; +// extern UNK_TYPE1 sVoiceHandle; // extern UNK_TYPE1 D_801FD5C4; // extern UNK_TYPE1 D_801FD5C8; // extern UNK_TYPE1 D_801FD5E8; -extern u8 D_801FD608[]; +extern u8 sVoiceMaskPattern[]; // extern UNK_TYPE1 D_801FD610; // extern UNK_TYPE1 D_801FD710; // extern UNK_TYPE1 D_801FD8C0; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index bc08e9f77..cdc5be6fb 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -3,7 +3,7 @@ void func_801A5080(u16 arg0); s32 func_801A5228(OSVoiceDictionary* dict); -void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); +void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); s32 func_801A5680(u16 arg0); @@ -11,7 +11,7 @@ s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); extern OSVoiceDictionary D_801D8BE0; -extern OSVoiceHandle D_801FD5B8; +extern OSVoiceHandle sVoiceHandle; extern OSVoiceData* D_801D8E40; extern u8 D_801D8E48; @@ -27,7 +27,7 @@ void func_801A4EB8(void) { if (D_801D8E3C != 0) { msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStopReadData(&D_801FD5B8); + osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); } @@ -58,7 +58,7 @@ void func_801A4FD8(void) { func_801A54D0(0xFFFF); if (D_801D8E3C != 0) { msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStopReadData(&D_801FD5B8); + osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); errorCode = func_801A5228(&D_801D8BE0); diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index ff0e2b6da..325a28399 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,14 +1,14 @@ #include "global.h" // internal voice functions -u8* func_801A5A1C(s8* arg0); +u8* func_801A5A1C(s8* word); // BSS OSVoiceUnk D_801FD5A0; -OSVoiceHandle D_801FD5B8; -OSVoiceData D_801FD5C8; -OSVoiceData D_801FD5E8; -u8 D_801FD608[8]; +OSVoiceHandle sVoiceHandle; +OSVoiceData D_801FD5C8; // Intermediate Voice Data during processsing? +OSVoiceData D_801FD5E8; // Best Match Voice Data? +u8 sVoiceMaskPattern[8]; // Maybe all the same? // u8 D_801FD610[0x11B0]; @@ -73,17 +73,17 @@ s32 func_801A5228(OSVoiceDictionary* dict) { u8 numWords; u8 i; - D_801FD5A0.unk_04 = 0; + D_801FD5A0.mode = 0; D_801FD5A0.data = NULL; - D_801FD5A0.unk_0C = 1000; - D_801FD5A0.unk_0E = 5; - D_801FD5A0.unk_10 = 0; + D_801FD5A0.distance = 1000; + D_801FD5A0.answerNum = 5; + D_801FD5A0.warning = 0; D_801FD5A0.dict = dict; numWords = dict->numWords; msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceClearDictionary(&D_801FD5B8, numWords); + errorCode = osVoiceClearDictionary(&sVoiceHandle, numWords); PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { @@ -91,12 +91,12 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { - D_801FD608[i] = 0; + sVoiceMaskPattern[i] = 0; } for (i = 0; i < numWords; i++) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceSetWord(&D_801FD5B8, &dict->words[i]); + errorCode = osVoiceSetWord(&sVoiceHandle, &dict->words[i]); PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) != 0) { @@ -108,17 +108,17 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } OSVoiceData* func_801A5390(void) { - OSVoiceData* temp_t6; + OSVoiceData* voiceData; OSMesgQueue* msgQ; - temp_t6 = D_801FD5A0.data; + voiceData = D_801FD5A0.data; D_801FD5A0.data = NULL; msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStartReadData(&D_801FD5B8); + osVoiceStartReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - return temp_t6; + return voiceData; } // Unused @@ -126,12 +126,12 @@ OSVoiceDictionary* func_801A53DC(void) { return D_801FD5A0.dict; } -void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { - D_801FD5A0.unk_0C = arg0; - D_801FD5A0.unk_0E = arg1; - D_801FD5A0.unk_10 = arg2; - D_801FD5A0.unk_12 = arg3; - D_801FD5A0.unk_14 = arg4; +void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel) { + D_801FD5A0.distance = distance; + D_801FD5A0.answerNum = answerNum; + D_801FD5A0.warning = warning; + D_801FD5A0.voiceLevel = voiceLevel; + D_801FD5A0.voiceRelLevel = voiceRelLevel; } // Unused @@ -142,7 +142,7 @@ s32 func_801A541C(s32 analog, s32 digital) { if (D_801FD5A0.dict != NULL) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceControlGain(&D_801FD5B8, analog, digital); + errorCode = osVoiceControlGain(&sVoiceHandle, analog, digital); PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { @@ -164,17 +164,16 @@ s32 func_801A5488(u8* word) { } u8* func_801A54C4(void) { - return D_801FD608; + return sVoiceMaskPattern; } s32 func_801A54D0(u16 arg0) { s32 errorCode; - u8 phi_t0; + u8 phi_t0 = true; u8 numWords; u8 i; OSMesgQueue* msgQ; - phi_t0 = true; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; } else { @@ -184,28 +183,28 @@ s32 func_801A54D0(u16 arg0) { if (arg0 == 0xFFFF) { for (i = 0; i < numWords; i++) { - D_801FD608[i / 8] |= 1 << (i % 8); + sVoiceMaskPattern[i / 8] |= 1 << (i % 8); } } else { - if (D_801FD608[arg0 / 8] & (1 << (arg0 % 8))) { + if (sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8))) { phi_t0 = false; } else { - D_801FD608[arg0 / 8] |= (1 << (arg0 % 8)); + sVoiceMaskPattern[arg0 / 8] |= (1 << (arg0 % 8)); } } if (phi_t0) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStopReadData(&D_801FD5B8); + errorCode = osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&sVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A0.unk_04 = 0; + D_801FD5A0.mode = 0; } return errorCode; @@ -213,12 +212,11 @@ s32 func_801A54D0(u16 arg0) { s32 func_801A5680(u16 arg0) { s32 errorCode; - u8 phi_a3; + u8 phi_a3 = true; u8 numWords; u8 i; OSMesgQueue* msgQ; - phi_a3 = true; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; } else { @@ -228,28 +226,28 @@ s32 func_801A5680(u16 arg0) { if (arg0 == 0xFFFF) { for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { - D_801FD608[i] = 0; + sVoiceMaskPattern[i] = 0; } } else { - if (!(D_801FD608[arg0 / 8] & (1 << (arg0 % 8)))) { + if (!(sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8)))) { phi_a3 = false; } else { - D_801FD608[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; + sVoiceMaskPattern[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; } } if (phi_a3) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStopReadData(&D_801FD5B8); + errorCode = osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&sVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A0.unk_04 = 0; + D_801FD5A0.mode = 0; } return errorCode; @@ -262,23 +260,23 @@ s32 func_801A5808(void) { if (1) {} - switch (D_801FD5A0.unk_04) { + switch (D_801FD5A0.mode) { case 0: msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStartReadData(&D_801FD5B8); + errorCode = osVoiceStartReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A0.unk_04 = 1; + D_801FD5A0.mode = 1; break; case 1: msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceGetReadData(&D_801FD5B8, &D_801FD5C8); + errorCode = osVoiceGetReadData(&sVoiceHandle, &D_801FD5C8); PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) == 0) { - switch (D_801FD5B8.status) { + switch (sVoiceHandle.status) { case VOICE_STATUS_READY: - D_801FD5A0.unk_04 = 2; + D_801FD5A0.mode = 2; break; case VOICE_STATUS_START: case 2: @@ -288,28 +286,28 @@ s32 func_801A5808(void) { case 6: break; case VOICE_STATUS_END: - D_801FD5A0.unk_04 = 2; + D_801FD5A0.mode = 2; break; } } break; case 2: - if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && - (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && - (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { + if (((D_801FD5C8.warning & D_801FD5A0.warning) == 0) && (D_801FD5A0.answerNum >= D_801FD5C8.answerNum) && + (D_801FD5A0.distance >= D_801FD5C8.distance[0]) && (D_801FD5C8.voiceLevel >= D_801FD5A0.voiceLevel) && + (D_801FD5C8.voiceRelLevel >= D_801FD5A0.voiceRelLevel)) { D_801FD5E8 = D_801FD5C8; D_801FD5A0.data = &D_801FD5E8; } msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStopReadData(&D_801FD5B8); + osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStartReadData(&D_801FD5B8); + errorCode = osVoiceStartReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A0.unk_04 = 1; + D_801FD5A0.mode = 1; break; } diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 40d7b5b0b..1338a61a8 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -69,10 +69,10 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } result->warning = u.data[4] + (u.data[5] << 8); - result->answer_num = u.data[6]; - result->voice_level = u.data[8] + (u.data[9] << 8); - result->voice_sn = u.data[10] + (u.data[11] << 8); - result->voice_time = u.data[12] + (u.data[13] << 8); + result->answerNum = u.data[6]; + result->voiceLevel = u.data[8] + (u.data[9] << 8); + result->voiceRelLevel = u.data[10] + (u.data[11] << 8); + result->voiceTime = u.data[12] + (u.data[13] << 8); for (i = 0; i < 5; i++) { result->answer[i] = u.data[14 + 4 * (i ^ 0)] + (u.data[15 + 4 * (i ^ 0)] << 8); @@ -80,7 +80,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (result->answer[0] == 0x7FFF) { - result->answer_num = 0; + result->answerNum = 0; } new_var2 = D_8009CF60; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3e2508212..1779d6a3a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4420,11 +4420,11 @@ 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), 0x801FD5A0:("D_801FD5A0","u8","0x18",0x1), - 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), + 0x801FD5B8:("sVoiceHandle","UNK_TYPE1","",0x1), 0x801FD5C4:("D_801FD5C4","UNK_TYPE1","",0x1), 0x801FD5C8:("D_801FD5C8","UNK_TYPE1","",0x1), 0x801FD5E8:("D_801FD5E8","UNK_TYPE1","",0x1), - 0x801FD608:("D_801FD608","UNK_TYPE1","",0x1), + 0x801FD608:("sVoiceMaskPattern","UNK_TYPE1","",0x1), 0x801FD610:("D_801FD610","UNK_TYPE1","",0x1), 0x801FD710:("D_801FD710","UNK_TYPE1","",0x1), 0x801FD8C0:("D_801FD8C0","UNK_TYPE1","",0x1), From 3ab4bf67bd0becf1466b2cc2a63afbd19babeed1 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 17:02:01 +1100 Subject: [PATCH 056/130] Fix bss --- src/code/audio/code_801A51F0.c | 12 +----------- src/code/code_801A5BD0.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 325a28399..41ef0f98e 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -9,17 +9,7 @@ OSVoiceHandle sVoiceHandle; OSVoiceData D_801FD5C8; // Intermediate Voice Data during processsing? OSVoiceData D_801FD5E8; // Best Match Voice Data? u8 sVoiceMaskPattern[8]; - -// Maybe all the same? -// u8 D_801FD610[0x11B0]; -char D_801FD610[0x100]; -u8 D_801FD710[0x1B0]; -u8 D_801FD8C0[0x240]; -u8 D_801FDB00[0x600]; -u8 D_801FE100[0x3C0]; -u8 D_801FE4C0[0x180]; -u8 D_801FE640[0x90]; -u8 D_801FE6D0[0xF0]; +char D_801FD610[256]; // Data s8 D_801D8E50[96][3] = { diff --git a/src/code/code_801A5BD0.c b/src/code/code_801A5BD0.c index 32889dcb8..8e9eafe64 100644 --- a/src/code/code_801A5BD0.c +++ b/src/code/code_801A5BD0.c @@ -1,5 +1,36 @@ #include "global.h" +typedef struct { + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxUnk01; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIdx; + /* 0x2B */ u8 unk_2F; + /* 0x2C */ u8 token; +} SoundBankEntry; // size = 0x30 + +// gSoundBank +SoundBankEntry D_801FD710[9]; +SoundBankEntry D_801FD8C0[12]; +SoundBankEntry D_801FDB00[32]; +SoundBankEntry D_801FE100[20]; +SoundBankEntry D_801FE4C0[8]; +SoundBankEntry D_801FE640[3]; +SoundBankEntry D_801FE6D0[5]; + #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C28.s") From c527da691689f1f7b0b900cdcef3333e03b84ee0 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 22:10:26 +1100 Subject: [PATCH 057/130] Import code_801A4EB0 data --- include/variables.h | 4 ++-- src/code/audio/code_801A4EB0.c | 33 +++++++++++++++++++++++++---- src/code/code_801A5BD0.c | 38 +++++++++++++++++----------------- tools/disasm/files.txt | 1 + 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/include/variables.h b/include/variables.h index a5adc2d93..06546f440 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1821,9 +1821,9 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8BD0; // extern UNK_TYPE4 D_801D8BD4; // extern UNK_TYPE1 D_801D8BE0; -extern u8 D_801D8E3C; +// extern u8 D_801D8E3C; // extern UNK_TYPE4 D_801D8E40; -extern u16 D_801D8E44; +// extern u16 D_801D8E44; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index cdc5be6fb..9136477c1 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,7 +1,6 @@ #include "global.h" void func_801A5080(u16 arg0); - s32 func_801A5228(OSVoiceDictionary* dict); void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); s32 func_801A5808(void); @@ -10,10 +9,36 @@ s32 func_801A5680(u16 arg0); s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); -extern OSVoiceDictionary D_801D8BE0; extern OSVoiceHandle sVoiceHandle; -extern OSVoiceData* D_801D8E40; -extern u8 D_801D8E48; + +OSVoiceDictionary D_801D8BE0 = { + { + // "アトナンジカン" - "atonanjikan" - "How many hours" + { 0x83, 0x41, 0x83, 0x67, 0x83, 0x69, 0x83, 0x93, 0x83, 0x57, 0x83, 0x4A, 0x83, 0x93 }, + + // "ハイチーズ" - "haichīzu" - "say cheese" + { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x60, 0x81, 0x5B, 0x83, 0x59 }, + + // "オキロー" - "okirō" - "wake up" + { 0x83, 0x49, 0x83, 0x4C, 0x83, 0x8D, 0x81, 0x5B }, + + // "オスワリ" - "osuwari" - "sit" + { 0x83, 0x49, 0x83, 0x58, 0x83, 0x8F, 0x83, 0x8A }, + + // "ミルク" - "miruku" - "milk" + { 0x83, 0x7E, 0x83, 0x8B, 0x83, 0x4E }, + + // "ハイヤー" - "haiyā" - "hiya!" + { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x84, 0x81, 0x5B }, + }, + + 6, // number of words +}; + +u8 D_801D8E3C = 0; +OSVoiceData* D_801D8E40 = NULL; +u16 D_801D8E44 = 0xFFFF; +u8 D_801D8E48 = 0; void func_801A4EB0(void) { } diff --git a/src/code/code_801A5BD0.c b/src/code/code_801A5BD0.c index 8e9eafe64..0cafa50b1 100644 --- a/src/code/code_801A5BD0.c +++ b/src/code/code_801A5BD0.c @@ -1,25 +1,25 @@ #include "global.h" typedef struct { - /* 0x00 */ f32* posX; - /* 0x04 */ f32* posY; - /* 0x08 */ f32* posZ; - /* 0x0C */ f32* freqScale; - /* 0x10 */ f32* vol; - /* 0x14 */ s8* reverbAdd; - /* 0x18 */ f32 dist; - /* 0x1C */ u32 priority; // lower is more prioritized - /* 0x20 */ u16 sfxParams; - /* 0x22 */ u16 sfxId; - /* 0x25 */ u8 sfxUnk01; - /* 0x24 */ u8 sfxImportance; - /* 0x26 */ u8 state; // uses SfxState enum - /* 0x27 */ u8 freshness; - /* 0x28 */ u8 prev; - /* 0x29 */ u8 next; - /* 0x2A */ u8 channelIdx; - /* 0x2B */ u8 unk_2F; - /* 0x2C */ u8 token; + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxUnk01; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIdx; + /* 0x2B */ u8 unk_2F; + /* 0x2C */ u8 token; } SoundBankEntry; // size = 0x30 // gSoundBank diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index e4bd66da0..625946f4c 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -578,6 +578,7 @@ 0x801D2E80 : "", # audio_heap? 0x801D3D90 : "", 0x801D55B0 : "", + 0x801D8BE0 : "code_801A4EB0", 0x801D8E50 : "code_801A51F0", 0x801D9090 : "", From e84fd1d1393ef755e4b3bfb8377021b2d5eae117 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 22:39:59 +1100 Subject: [PATCH 058/130] Introduce Word Id enum --- include/os.h | 11 +++++++++++ include/variables.h | 2 +- src/code/audio/code_801A4EB0.c | 34 +++++++++++++++++----------------- src/code/audio/code_801A51F0.c | 16 ++++++++-------- tools/disasm/variables.txt | 2 +- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/include/os.h b/include/os.h index 379f18746..c3d76dd3b 100644 --- a/include/os.h +++ b/include/os.h @@ -141,6 +141,17 @@ typedef struct { /* 0xC */ u32* text_end; } OSProf; // size = 0x10 +typedef enum { + /* 0 */ VOICE_WORD_ID_HOURS, + /* 1 */ VOICE_WORD_ID_CHEESE, + /* 2 */ VOICE_WORD_ID_WAKE_UP, + /* 3 */ VOICE_WORD_ID_SIT, + /* 4 */ VOICE_WORD_ID_MILK, + /* 5 */ VOICE_WORD_ID_HIYA, + /* 6 */ VOICE_WORD_ID_MAX, + /* -1 */ VOICE_WORD_ID_NONE = 0xFFFF +} OSVoiceWordId; + #define VOICE_STATUS_READY 0 /* stop/end */ #define VOICE_STATUS_START 1 /* Voice Undetected (no voice input) */ #define VOICE_STATUS_CANCEL 3 /* Cancel (cancel extraneous noise) */ diff --git a/include/variables.h b/include/variables.h index 06546f440..45e31a527 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1823,7 +1823,7 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE1 D_801D8BE0; // extern u8 D_801D8E3C; // extern UNK_TYPE4 D_801D8E40; -// extern u16 D_801D8E44; +// extern u16 sTopScoreWordId; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 9136477c1..32b1dbc6c 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -5,8 +5,8 @@ s32 func_801A5228(OSVoiceDictionary* dict); void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); -s32 func_801A5680(u16 arg0); -s32 func_801A54D0(u16 arg0); +s32 func_801A5680(u16 wordId); +s32 func_801A54D0(u16 wordId); u8* func_801A54C4(void); extern OSVoiceHandle sVoiceHandle; @@ -32,12 +32,12 @@ OSVoiceDictionary D_801D8BE0 = { { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x84, 0x81, 0x5B }, }, - 6, // number of words + VOICE_WORD_ID_MAX, // number of words }; u8 D_801D8E3C = 0; OSVoiceData* D_801D8E40 = NULL; -u16 D_801D8E44 = 0xFFFF; +u16 sTopScoreWordId = VOICE_WORD_ID_NONE; u8 D_801D8E48 = 0; void func_801A4EB0(void) { @@ -63,7 +63,7 @@ void func_801A4EB8(void) { } if (func_801A5228(&D_801D8BE0) == 0) { - for (i = 0; i < 6; i++) { + for (i = 0; i < VOICE_WORD_ID_MAX; i++) { index = i / 8; if (((sp38[index] >> (i % 8)) & 1) == 1) { func_801A54D0(i); @@ -80,14 +80,14 @@ void func_801A4FD8(void) { s32 errorCode; OSMesgQueue* msgQ; - func_801A54D0(0xFFFF); + func_801A54D0(VOICE_WORD_ID_NONE); if (D_801D8E3C != 0) { msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); errorCode = func_801A5228(&D_801D8BE0); - func_801A54D0(0xFFFF); + func_801A54D0(VOICE_WORD_ID_NONE); if (errorCode == 0) { func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; @@ -98,22 +98,22 @@ void func_801A4FD8(void) { } } -void func_801A5080(u16 arg0) { - if ((D_801D8E3C != 0) && (arg0 < 6)) { - func_801A5680(arg0); +void func_801A5080(u16 wordId) { + if ((D_801D8E3C != 0) && (wordId < VOICE_WORD_ID_MAX)) { + func_801A5680(wordId); } } // Unused -void func_801A50C0(u16 arg0) { - if ((D_801D8E3C != 0) && (arg0 < 6)) { - func_801A54D0(arg0); +void func_801A50C0(u16 wordId) { + if ((D_801D8E3C != 0) && (wordId < VOICE_WORD_ID_MAX)) { + func_801A54D0(wordId); } } // Used externally in many files u16 func_801A5100(void) { - return D_801D8E44; + return sTopScoreWordId; } // Unused @@ -133,7 +133,7 @@ void func_801A5118(void) { D_801D8E48++; if (D_801D8E48 == 10) { D_801D8E3C = 0; - D_801D8E44 = 0xFFFF; + sTopScoreWordId = VOICE_WORD_ID_NONE; return; } } else { @@ -142,9 +142,9 @@ void func_801A5118(void) { D_801D8E40 = func_801A5390(); if (D_801D8E40 != 0) { - D_801D8E44 = D_801D8E40->answer[0]; + sTopScoreWordId = D_801D8E40->answer[0]; } else { - D_801D8E44 = 0xFFFF; + sTopScoreWordId = VOICE_WORD_ID_NONE; } } } diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 41ef0f98e..c5d7bafb4 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -157,7 +157,7 @@ u8* func_801A54C4(void) { return sVoiceMaskPattern; } -s32 func_801A54D0(u16 arg0) { +s32 func_801A54D0(u16 wordId) { s32 errorCode; u8 phi_t0 = true; u8 numWords; @@ -171,15 +171,15 @@ s32 func_801A54D0(u16 arg0) { phi_t0 = false; } - if (arg0 == 0xFFFF) { + if (wordId == VOICE_WORD_ID_NONE) { for (i = 0; i < numWords; i++) { sVoiceMaskPattern[i / 8] |= 1 << (i % 8); } } else { - if (sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8))) { + if (sVoiceMaskPattern[wordId / 8] & (1 << (wordId % 8))) { phi_t0 = false; } else { - sVoiceMaskPattern[arg0 / 8] |= (1 << (arg0 % 8)); + sVoiceMaskPattern[wordId / 8] |= (1 << (wordId % 8)); } } @@ -200,7 +200,7 @@ s32 func_801A54D0(u16 arg0) { return errorCode; } -s32 func_801A5680(u16 arg0) { +s32 func_801A5680(u16 wordId) { s32 errorCode; u8 phi_a3 = true; u8 numWords; @@ -214,15 +214,15 @@ s32 func_801A5680(u16 arg0) { phi_a3 = false; } - if (arg0 == 0xFFFF) { + if (wordId == VOICE_WORD_ID_NONE) { for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { sVoiceMaskPattern[i] = 0; } } else { - if (!(sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8)))) { + if (!(sVoiceMaskPattern[wordId / 8] & (1 << (wordId % 8)))) { phi_a3 = false; } else { - sVoiceMaskPattern[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; + sVoiceMaskPattern[wordId / 8] &= (1 << (wordId % 8)) ^ 0xFF; } } diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1779d6a3a..98ae20bd9 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2438,7 +2438,7 @@ 0x801D8BE0:("D_801D8BE0","UNK_TYPE1","",0x1), 0x801D8E3C:("D_801D8E3C","UNK_TYPE1","",0x1), 0x801D8E40:("D_801D8E40","UNK_TYPE4","",0x4), - 0x801D8E44:("D_801D8E44","UNK_TYPE2","",0x2), + 0x801D8E44:("sTopScoreWordId","UNK_TYPE2","",0x2), 0x801D8E48:("D_801D8E48","UNK_TYPE1","",0x1), 0x801D8E50:("D_801D8E50","UNK_TYPE1","",0x1), 0x801D8F70:("D_801D8F70","UNK_TYPE1","",0x1), From 0ca2818b8f5a17bc12b7376ae283f2736874cc80 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 23:45:01 +1100 Subject: [PATCH 059/130] Dictionary: u8 -> u16 --- include/os.h | 2 +- src/code/audio/code_801A4EB0.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/os.h b/include/os.h index c3d76dd3b..198c06935 100644 --- a/include/os.h +++ b/include/os.h @@ -181,7 +181,7 @@ typedef struct { } OSVoiceData; // size = 0x20 typedef struct { - /* 0x000 */ u8 words[20][30]; // 20 words, each with up to 15 syllables + /* 0x000 */ u16 words[20][15]; // 20 words, each with up to 15 syllables /* 0x258 */ u8 numWords; } OSVoiceDictionary; // size = 0x25C diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 32b1dbc6c..0712d4761 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -14,22 +14,22 @@ extern OSVoiceHandle sVoiceHandle; OSVoiceDictionary D_801D8BE0 = { { // "アトナンジカン" - "atonanjikan" - "How many hours" - { 0x83, 0x41, 0x83, 0x67, 0x83, 0x69, 0x83, 0x93, 0x83, 0x57, 0x83, 0x4A, 0x83, 0x93 }, + { 0x8341, 0x8367, 0x8369, 0x8393, 0x8357, 0x834A, 0x8393 }, // "ハイチーズ" - "haichīzu" - "say cheese" - { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x60, 0x81, 0x5B, 0x83, 0x59 }, + { 0x836E, 0x8343, 0x8360, 0x815B, 0x8359 }, // "オキロー" - "okirō" - "wake up" - { 0x83, 0x49, 0x83, 0x4C, 0x83, 0x8D, 0x81, 0x5B }, + { 0x8349, 0x834C, 0x838D, 0x815B }, // "オスワリ" - "osuwari" - "sit" - { 0x83, 0x49, 0x83, 0x58, 0x83, 0x8F, 0x83, 0x8A }, + { 0x8349, 0x8358, 0x838F, 0x838A }, // "ミルク" - "miruku" - "milk" - { 0x83, 0x7E, 0x83, 0x8B, 0x83, 0x4E }, + { 0x837E, 0x838B, 0x834E }, // "ハイヤー" - "haiyā" - "hiya!" - { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x84, 0x81, 0x5B }, + { 0x836E, 0x8343, 0x8384, 0x815B }, }, VOICE_WORD_ID_MAX, // number of words From a9311e94c9280cf9c61e45fe41bbaa93975b778b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 14:49:57 +1100 Subject: [PATCH 060/130] Introduce bgms --- include/bgm.h | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/include/bgm.h b/include/bgm.h index 4cd19c957..1dc9acdc3 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,4 +3,133 @@ #define NA_BGM_STOP 0x100000FF +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 +#define NA_BGM_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_STALKID 0x04 // Majora's Theme +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_RUIN_DUNGEON_FRONT 0x06 // Stone Tower Temple +#define NA_BGM_RUIN_DUNGEON_REVERSE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_OMENYA 0x0A // Mask Salesman +#define NA_BGM_DEMO_CURE 0x0B // Song of Healing +#define NA_BGM_DAMP_AREA 0x0C // Southern Swamp +#define NA_BGM_UFO 0x0D // Ghost Attack +#define NA_BGM_JUNGLE_CREWS 0x0E // Mini Game +#define NA_BGM_SHARP 0x0F // Sharp's Curse +#define NA_BGM_SEA_AREA 0x10 // Great Bay Coast +#define NA_BGM_IKANA_AREA 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_SNOW_AREA 0x13 // Mountain Village +#define NA_BGM_PIRATE_AREA 0x14 // Pirates' Fortress +#define NA_BGM_DUMMY_21 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D +#define NA_BGM_DUMMY_22 0x16 // Clock Town Day 2 This song's filename is dummied out in MM3D +#define NA_BGM_DUMMY_23 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_EVENT_CLEAR 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_JUNGLE_DUNGEON 0x1C // Woodfall Temple +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_LINK_HOUSE 0x1F // House +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear +#define NA_BGM_ITEM_GET 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_HEART_GET 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_ORGEL_HOUSE 0x27 // Music Box House +#define NA_BGM_GODESS 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_HIME 0x29 // Zelda's Lullaby +#define NA_BGM_SISTER_DANCER 0x2A // Rosa Sisters' Dance +#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Chest +#define NA_BGM_DRUGSTORE 0x2C // Marine Research Laboratory +#define NA_BGM_KYOJIN_ROOM 0x2D // The Four Giants +#define NA_BGM_FUSHA 0x2E // Guru-Guru's Song +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON 0x30 // Goron Village +#define NA_BGM_MEETING 0x31 // Mayor Dotour +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUN 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME_NORMAL 0x34 // Ocarina Song of Time +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA 0x36 // Zora Hall +#define NA_BGM_MASK_GET 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_S_ITEM_GET 0x39 // Small Item Catch +#define NA_BGM_TENMONDAI 0x3A // Astral Observatory +#define NA_BGM_NORMAL_DUNGEON 0x3B // Clock Town Cavern +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_MAYOIMORI 0x3E // Woods of Mystery +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. +#define NA_BGM_KOTAKE_KOUME 0x43 // Kotake's Potion Shop +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_BIGWING 0x47 // Ocarina Song of Soaring +#define NA_BGM_OCA_CURE 0x48 // Ocarina Song of Healing +#define NA_BGM_TIME_SPEED 0x49 // Inverted Song of Time +#define NA_BGM_TIME_JUMP 0x4A // Song of Double Time +#define NA_BGM_DEMO_AWAKING 0x4B // Sonata of Awakening +#define NA_BGM_DEMO_LULLABY 0x4C // Goron Lullaby +#define NA_BGM_DEMO_TIDE 0x4D // New Wave Bossa Nova +#define NA_BGM_DEMO_SHELL 0x4E // Elegy of Emptiness +#define NA_BGM_DEMO_PLEDGE 0x4F // Oath to Order +#define NA_BGM_EXERCISE_HALL 0x50 // Sword Training +#define NA_BGM_DEMO_LULLABY_HALF 0x51 // Ocarina Goron Lullaby Intro +#define NA_BGM_OCA_YOUSEI 0x52 // New Song +#define NA_BGM_FACEMASK 0x53 // Bremen March +#define NA_BGM_QUARTET 0x54 // Ballad of the Wind Fish +#define NA_BGM_WING_WARP 0x55 // Song of Soaring +#define NA_BGM_MILK_BAR_DUMMY 0x56 // Milk Bar Latte Duplicate. +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_LIFF 0x58 // Mikau's Tale +#define NA_BGM_MIKAU_FIN 0x59 // A single guitar chord. +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_AWAKING 0x5B // Ocarina Sonata of Awakening +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby +#define NA_BGM_OCA_TIDE 0x5D // Ocarina New Wave Bossa Nova +#define NA_BGM_OCA_SHELL 0x5E // Ocarina Elegy of Emptiness +#define NA_BGM_OCA_PLEDGE 0x5F // Ocarina Oath to Order +#define NA_BGM_LAST_DUNGEON 0x60 // +#define NA_BGM_OCA_LULLABY_HALF 0x61 // +#define NA_BGM_OCA_SESSION 0x62 // Bass and Guitar Session +#define NA_BGM_DEMO_SESSION 0x63 // Piano Solo +#define NA_BGM_ALLPART_SESSION 0x64 // The Indigo-Go's Rehearsal +#define NA_BGM_SILVER_DUNGEON 0x65 // Snowhead Temple +#define NA_BGM_DEEPBLUE_DUNGEON 0x66 // Great Bay Temple +#define NA_BGM_DEMO_TIDE_SAX 0x67 // +#define NA_BGM_DEMO_TIDE_VOCAL 0x68 // +#define NA_BGM_MUJURA_1 0x69 // Majora's Wrath +#define NA_BGM_MUJURA_2 0x6A // Majora's Incarnation +#define NA_BGM_MUJURA_3 0x6B // Majora's Mask Battle +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING 0x70 // Calling the Four Giants +#define NA_BGM_CAMARO_DANCE 0x71 // Kamaro's Dance +#define NA_BGM_DONKEY_CART 0x72 // Cremia's Carriage +#define NA_BGM_QUIZ 0x73 // Keaton +#define NA_BGM_END_DEMO 0x74 // The End/Credits I +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_PURIFICATION_0 0x78 // Woodfall Clear +#define NA_BGM_PURIFICATION_1 0x79 // Snowhead Clear +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_CHAT 0x7D // Tatl and Tael +#define NA_BGM_MOON_VANISH 0x7E // Moon's Destruction +#define NA_BGM_STAFFROLL2 0x7F // The End/Credits II +#define NA_BGM_DISABLED 0xFFFF + #endif From 85b280f68aacfcd8d5ec3f269eaf4fc0c2131c08 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 15:03:26 +1100 Subject: [PATCH 061/130] Fill in bgm enums --- include/functions.h | 12 ++++++------ src/code/code_8019AF00.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_scene.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 ++-- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 ++-- src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c | 4 ++-- src/overlays/actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c | 4 ++-- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 6 +++--- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 ++++---- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 4 ++-- src/overlays/actors/ovl_En_Suttari/z_en_suttari.c | 2 +- .../actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 6 +++--- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 21 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/functions.h b/include/functions.h index 1102363d5..039303645 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3895,10 +3895,10 @@ void func_801A0204(UNK_TYPE); // void func_801A1904(void); // void func_801A1A10(void); // void func_801A1A8C(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_801A1D44(Vec3f* vec, UNK_TYPE arg1, f32 arg2); -void func_801A1DB8(Vec3f* vec, UNK_TYPE arg1, f32 arg2); +void func_801A1D44(Vec3f* vec, u8 seqId, f32 arg2); +void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); -void func_801A1F00(s32 arg0, s32 arg1); +void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); // void func_801A1FB4(void); // void func_801A2090(void); @@ -3916,15 +3916,15 @@ void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); // void func_801A2D54(void); -s32 func_801A2DE0(UNK_TYPE4 arg1); +s32 Audio_IsSequencePlaying(u8 seqId); void func_801A2E54(s32 param_1); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 arg0); +void func_801A3098(u16 seqId); // void func_801A312C(void); -void func_801A31EC(UNK_TYPE1 arg1, UNK_TYPE4 arg2, u8 arg3); +void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801A32CC(void); // void func_801A3590(void); diff --git a/src/code/code_8019AF00.c b/src/code/code_8019AF00.c index 8f0d129ad..32934a82c 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/code_8019AF00.c @@ -296,7 +296,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2DE0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index c510c1974..edbf79ed7 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -66,7 +66,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: - if (func_801A8A50(1) != 32) { + if (func_801A8A50(1) != NA_BGM_GAME_OVER) { func_80169F78(globalCtx); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index dd158ac07..406685f85 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == 0x57) { + if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } 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 6b3c944f4..dc7f3639a 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(0x8021); + Audio_QueueSeqCmd(NA_BGM_BOSS_CLEAR | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); @@ -1342,7 +1342,7 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { if (D_809E0430 != 0) { D_809E0430--; if (D_809E0430 == 0) { - Audio_QueueSeqCmd(0x801B); + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); } } } 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 42ac8d510..b11647ddf 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -449,7 +449,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; @@ -535,7 +535,7 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } EnBigpo_SetupIdleFlying(this); 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 a73f5423f..bf0f977b7 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -528,7 +528,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } sp28.x = this->actor.world.pos.x; @@ -547,7 +547,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &D_0600C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; 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 644f2fedb..e1b71acb2 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); } } } 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 550a54f62..7a0386183 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -804,7 +804,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); 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 71e0c8cd0..252b1e973 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; 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 42b9a6c91..15eed7e02 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(0x19); + func_801A3098(NA_BGM_EVENT_CLEAR); } this->actionTimer--; if (this->actionTimer <= 0) { 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 eca46a8e8..92908ac6d 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -751,7 +751,7 @@ void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[0x8] &= (u8)~0x01; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); - Audio_QueueSeqCmd(0x8041); + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); } void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { 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 4c955f83f..d89ed4582 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 @@ -903,7 +903,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(9); + func_801A3098(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } this->actionFunc = EnMaYto_AfterMilkRunInit; 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 67c1d8659..9095d702b 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -462,7 +462,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { ActorCutscene_Start(this->actor.cutscene, &this->actor); this->actionFunc = EnMinifrog_SetupNextFrogChoir; this->timer = 5; - func_801A1F00(3, 0x5A); + func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; globalCtx->setPlayerTalkAnim(globalCtx, &D_0400E2A8, 0); } else { 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 446b4c100..514245a32 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -367,7 +367,7 @@ void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0x7D0, 360.0f, 200.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } @@ -396,7 +396,7 @@ void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0xBF6, 200.0f, 100.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -511,7 +511,7 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -721,7 +721,7 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { 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 12e234991..8acba6f8a 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1054,7 +1054,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { if (!this->unk_2AE) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1274,7 +1274,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* g void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.params == GEKKO_INIT_SNAPPER) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } 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 3a8db7839..546f029ff 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -1142,7 +1142,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { this->textId = 0x2A31; func_801518B0(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; - Audio_QueueSeqCmd(0x8003); + Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; } else { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); 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 5018c640f..bd961b7ad 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 @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index ef3fdf7dc..f846a2399 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(0x54, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_QUARTET, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,8 +621,8 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!func_801A2DE0(0x54)) { - actor = (Actor*)GET_PLAYER(globalCtx); // Needed for regalloc, possible FAKE MATCH + if (!Audio_IsSequencePlaying(NA_BGM_QUARTET)) { + actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { Actor_MarkForDeath(actor); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b6ec70b65..c2c4b7b3f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3951,7 +3951,7 @@ 0x801A2C44:("func_801A2C44",), 0x801A2C88:("func_801A2C88",), 0x801A2D54:("func_801A2D54",), - 0x801A2DE0:("func_801A2DE0",), + 0x801A2DE0:("Audio_IsSequencePlaying",), 0x801A2E54:("func_801A2E54",), 0x801A2ED8:("func_801A2ED8",), 0x801A2F88:("func_801A2F88",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9737ede4d..3a14ddbc3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3469,7 +3469,7 @@ asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2DE0.s,func_801A2DE0,0x801A2DE0,0x1D +asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF From ea906f4280afacbf6f278bdca28c0cbd54f34041 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 16:04:58 +1100 Subject: [PATCH 062/130] Rename bgm to clearer names --- include/bgm.h | 254 +++++++++--------- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 6 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 4 +- 8 files changed, 138 insertions(+), 138 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 1dc9acdc3..5038f66e0 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,133 +3,133 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x01 -#define NA_BGM_FIELD 0x02 // Termina Field -#define NA_BGM_CHASE 0x03 // Forest Chase -#define NA_BGM_STALKID 0x04 // Majora's Theme -#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower -#define NA_BGM_RUIN_DUNGEON_FRONT 0x06 // Stone Tower Temple -#define NA_BGM_RUIN_DUNGEON_REVERSE 0x07 // Stone Tower Temple Inverted -#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 -#define NA_BGM_FAILURE_1 0x09 // Title -#define NA_BGM_OMENYA 0x0A // Mask Salesman -#define NA_BGM_DEMO_CURE 0x0B // Song of Healing -#define NA_BGM_DAMP_AREA 0x0C // Southern Swamp -#define NA_BGM_UFO 0x0D // Ghost Attack -#define NA_BGM_JUNGLE_CREWS 0x0E // Mini Game -#define NA_BGM_SHARP 0x0F // Sharp's Curse -#define NA_BGM_SEA_AREA 0x10 // Great Bay Coast -#define NA_BGM_IKANA_AREA 0x11 // Ikana Valley -#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King -#define NA_BGM_SNOW_AREA 0x13 // Mountain Village -#define NA_BGM_PIRATE_AREA 0x14 // Pirates' Fortress -#define NA_BGM_DUMMY_21 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D -#define NA_BGM_DUMMY_22 0x16 // Clock Town Day 2 This song's filename is dummied out in MM3D -#define NA_BGM_DUMMY_23 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D -#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain -#define NA_BGM_EVENT_CLEAR 0x19 // Event Clear -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle -#define NA_BGM_JUNGLE_DUNGEON 0x1C // Woodfall Temple -#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ -#define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_LINK_HOUSE 0x1F // House -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear -#define NA_BGM_ITEM_GET 0x22 // Item Catch -#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_HEART_GET 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame -#define NA_BGM_GORON_RACE 0x26 // Goron Race -#define NA_BGM_ORGEL_HOUSE 0x27 // Music Box House -#define NA_BGM_GODESS 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_HIME 0x29 // Zelda's Lullaby -#define NA_BGM_SISTER_DANCER 0x2A // Rosa Sisters' Dance -#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Chest -#define NA_BGM_DRUGSTORE 0x2C // Marine Research Laboratory -#define NA_BGM_KYOJIN_ROOM 0x2D // The Four Giants -#define NA_BGM_FUSHA 0x2E // Guru-Guru's Song -#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" -#define NA_BGM_GORON 0x30 // Goron Village -#define NA_BGM_MEETING 0x31 // Mayor Dotour -#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song -#define NA_BGM_OCA_SUN 0x33 // Ocarina Sun's Song -#define NA_BGM_OCA_TIME_NORMAL 0x34 // Ocarina Song of Time -#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms -#define NA_BGM_ZORA 0x36 // Zora Hall -#define NA_BGM_MASK_GET 0x37 // A New Mask -#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" -#define NA_BGM_S_ITEM_GET 0x39 // Small Item Catch -#define NA_BGM_TENMONDAI 0x3A // Astral Observatory -#define NA_BGM_NORMAL_DUNGEON 0x3B // Clock Town Cavern -#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte -#define NA_BGM_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_MAYOIMORI 0x3E // Woods of Mystery -#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal -#define NA_BGM_HORSE 0x40 // Gorman Race -#define NA_BGM_HORSE_GOAL 0x41 // Race Finish -#define NA_BGM_INGO 0x42 // Gorman Bros. -#define NA_BGM_KOTAKE_KOUME 0x43 // Kotake's Potion Shop -#define NA_BGM_SHOP 0x44 // Store -#define NA_BGM_OWL 0x45 // Gaebora's Theme -#define NA_BGM_MINI_GAME 0x46 // Target Practice -#define NA_BGM_OCA_BIGWING 0x47 // Ocarina Song of Soaring -#define NA_BGM_OCA_CURE 0x48 // Ocarina Song of Healing -#define NA_BGM_TIME_SPEED 0x49 // Inverted Song of Time -#define NA_BGM_TIME_JUMP 0x4A // Song of Double Time -#define NA_BGM_DEMO_AWAKING 0x4B // Sonata of Awakening -#define NA_BGM_DEMO_LULLABY 0x4C // Goron Lullaby -#define NA_BGM_DEMO_TIDE 0x4D // New Wave Bossa Nova -#define NA_BGM_DEMO_SHELL 0x4E // Elegy of Emptiness -#define NA_BGM_DEMO_PLEDGE 0x4F // Oath to Order -#define NA_BGM_EXERCISE_HALL 0x50 // Sword Training -#define NA_BGM_DEMO_LULLABY_HALF 0x51 // Ocarina Goron Lullaby Intro -#define NA_BGM_OCA_YOUSEI 0x52 // New Song -#define NA_BGM_FACEMASK 0x53 // Bremen March -#define NA_BGM_QUARTET 0x54 // Ballad of the Wind Fish -#define NA_BGM_WING_WARP 0x55 // Song of Soaring -#define NA_BGM_MILK_BAR_DUMMY 0x56 // Milk Bar Latte Duplicate. -#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" -#define NA_BGM_MIKAU_LIFF 0x58 // Mikau's Tale -#define NA_BGM_MIKAU_FIN 0x59 // A single guitar chord. -#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song -#define NA_BGM_OCA_AWAKING 0x5B // Ocarina Sonata of Awakening -#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby -#define NA_BGM_OCA_TIDE 0x5D // Ocarina New Wave Bossa Nova -#define NA_BGM_OCA_SHELL 0x5E // Ocarina Elegy of Emptiness -#define NA_BGM_OCA_PLEDGE 0x5F // Ocarina Oath to Order -#define NA_BGM_LAST_DUNGEON 0x60 // -#define NA_BGM_OCA_LULLABY_HALF 0x61 // -#define NA_BGM_OCA_SESSION 0x62 // Bass and Guitar Session -#define NA_BGM_DEMO_SESSION 0x63 // Piano Solo -#define NA_BGM_ALLPART_SESSION 0x64 // The Indigo-Go's Rehearsal -#define NA_BGM_SILVER_DUNGEON 0x65 // Snowhead Temple -#define NA_BGM_DEEPBLUE_DUNGEON 0x66 // Great Bay Temple -#define NA_BGM_DEMO_TIDE_SAX 0x67 // -#define NA_BGM_DEMO_TIDE_VOCAL 0x68 // -#define NA_BGM_MUJURA_1 0x69 // Majora's Wrath -#define NA_BGM_MUJURA_2 0x6A // Majora's Incarnation -#define NA_BGM_MUJURA_3 0x6B // Majora's Mask Battle -#define NA_BGM_BASS_PLAY 0x6C // Bass Practice -#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice -#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice -#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle -#define NA_BGM_GATHERING 0x70 // Calling the Four Giants -#define NA_BGM_CAMARO_DANCE 0x71 // Kamaro's Dance -#define NA_BGM_DONKEY_CART 0x72 // Cremia's Carriage -#define NA_BGM_QUIZ 0x73 // Keaton -#define NA_BGM_END_DEMO 0x74 // The End/Credits I -#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. -#define NA_BGM_TITLE 0x76 // Title Screen -#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall -#define NA_BGM_PURIFICATION_0 0x78 // Woodfall Clear -#define NA_BGM_PURIFICATION_1 0x79 // Snowhead Clear -#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon -#define NA_BGM_GOODBYE_GIANT 0x7C // -#define NA_BGM_CHAT 0x7D // Tatl and Tael -#define NA_BGM_MOON_VANISH 0x7E // Moon's Destruction -#define NA_BGM_STAFFROLL2 0x7F // The End/Credits II +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" +#define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" +#define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif 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 dc7f3639a..498455011 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(NA_BGM_BOSS_CLEAR | 0x8000); + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); 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 e1b71acb2..1efecd257 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); } } } 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 7a0386183..a278711b5 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -804,7 +804,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); 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 252b1e973..edc0135a8 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; 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 15eed7e02..b10894b16 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(NA_BGM_EVENT_CLEAR); + func_801A3098(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { 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 bd961b7ad..1a038f5a7 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 @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index f846a2399..0acdc0485 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(NA_BGM_QUARTET, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,7 +621,7 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!Audio_IsSequencePlaying(NA_BGM_QUARTET)) { + if (!Audio_IsSequencePlaying(NA_BGM_BALLAD_OF_THE_WIND_FISH)) { actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { From 0499934d02e1e6a34607236f635fe62ac85a5734 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 16:07:55 +1100 Subject: [PATCH 063/130] Fix spacing --- include/bgm.h | 244 +++++++++++++++++++++++++------------------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 5038f66e0..391881221 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,133 +3,133 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises -#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field -#define NA_BGM_CHASE 0x03 // Forest Chase -#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" -#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower -#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple -#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted -#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 -#define NA_BGM_FAILURE_1 0x09 // Title -#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" -#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" -#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" -#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" -#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" -#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse -#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" -#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley -#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King -#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" -#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" -#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" -#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" -#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" -#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain -#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle -#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" -#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ -#define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear -#define NA_BGM_GET_ITEM 0x22 // Item Catch -#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame -#define NA_BGM_GORON_RACE 0x26 // Goron Race -#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" -#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" -#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" -#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" -#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" -#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" -#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" -#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" -#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" -#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village -#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" -#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song -#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song -#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" -#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms -#define NA_BGM_ZORA_HALL 0x36 // Zora Hall -#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask -#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" -#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" -#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" -#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" -#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte -#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" -#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal -#define NA_BGM_HORSE 0x40 // Gorman Race -#define NA_BGM_HORSE_GOAL 0x41 // Race Finish -#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" -#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" -#define NA_BGM_SHOP 0x44 // Store -#define NA_BGM_OWL 0x45 // Gaebora's Theme -#define NA_BGM_MINI_GAME 0x46 // Target Practice -#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" -#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" -#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" -#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" -#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" -#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" -#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" -#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" -#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" -#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" -#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" -#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" -#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" -#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" -#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" -#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" -#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" -#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" -#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" -#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song -#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" -#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" -#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" -#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" -#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" #define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" #define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" -#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" -#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" -#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" -#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" -#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" #define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" #define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" -#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" -#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" -#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" -#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" -#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" -#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" -#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle -#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants -#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" -#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" -#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" -#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" -#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. -#define NA_BGM_TITLE_THEME 0x76 // Title Screen -#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall -#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" -#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" -#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon #define NA_BGM_GOODBYE_GIANT 0x7C // -#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" -#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif From e85ef78e859e75967e56831544c4585370e6ce3b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 14:30:32 +1100 Subject: [PATCH 064/130] Fix "No_Music" define --- include/bgm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index 391881221..430be896e 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -129,7 +129,8 @@ #define NA_BGM_GOODBYE_GIANT 0x7C // #define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" #define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_NO_MUSIC 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif From f5f52dbaf0006e57b371ca77b87b4caa2863a549 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 14:35:51 +1100 Subject: [PATCH 065/130] remove comment --- include/bgm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index 430be896e..a8ed3a5d8 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -129,7 +129,7 @@ #define NA_BGM_GOODBYE_GIANT 0x7C // #define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" #define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_NO_MUSIC 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_NO_MUSIC 0x7F // #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF From b7160a2efc3c08cccffb7e99c2e9b1f5c6410e03 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 16:25:05 +1100 Subject: [PATCH 066/130] import rodata --- src/code/audio/code_801A51F0.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index c5d7bafb4..d5afc3858 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -30,17 +30,14 @@ s8 D_801D8F70[96][3] = { "WI", "WE", "WO", "NN", "VU", "ka", "ke", "", "", "", "", "", "", "", "", "", }; -/* -char D_801E0EC0[] = "Error %d\n" -char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n" -char D_801E0EF0[] = "NAI_VRS:dict error! (%d-%d %s)\n" -char D_801E0F10[] = "NAI_VRS:Ina_SetVruGain Error!\n" -char D_801E0F30[] = "NAI_VRS:mask on %d\n" -char D_801E0F48[] = "NAI_VRS:mask off %d\n" -char D_801E0F60[] = "NAI_VRS:answer No.:%d Dist:%d Warn:%04X Level:%5d SN:%5d (Num:%d)\n" -char D_801E0FA4[] = "NAI_VRS:error !! (ANS_MAX:%d DIST:%d WARNING:%04X LEVEL:%5d SN:%5d)\n" -*/ -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/D_801E0EC0.s") +const char D_801E0EC0[] = "Error %d\n"; +const char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n"; +const char D_801E0EF0[] = "NAI_VRS:dict error! (%d-%d %s)\n"; +const char D_801E0F10[] = "NAI_VRS:Ina_SetVruGain Error!\n"; +const char D_801E0F30[] = "NAI_VRS:mask on %d\n"; +const char D_801E0F48[] = "NAI_VRS:mask off %d\n"; +const char D_801E0F60[] = "NAI_VRS:answer No.:%d Dist:%d Warn:%04X Level:%5d SN:%5d (Num:%d)\n"; +const char D_801E0FA4[] = "NAI_VRS:error !! (ANS_MAX:%d DIST:%d WARNING:%04X LEVEL:%5d SN:%5d)\n"; s32 func_801A51F0(s32 errorCode) { switch (errorCode) { From f0ddf5a017c24540ca0923beb2c9584d0a58c325 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 02:58:40 +1100 Subject: [PATCH 067/130] Improve bgm names, found another seqId function --- include/bgm.h | 6 +++--- include/functions.h | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c | 4 ++-- src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index a8ed3a5d8..9a5f547f3 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,8 +3,8 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field #define NA_BGM_CHASE 0x03 // Forest Chase #define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" @@ -49,7 +49,7 @@ #define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" #define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" #define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" -#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_SONG_OF_STORMS 0x2E // Guru-Guru's Song "FUSHA" #define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" #define NA_BGM_GORON_VILLAGE 0x30 // Goron Village #define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" diff --git a/include/functions.h b/include/functions.h index 578d0c1ec..254c050c0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3911,7 +3911,7 @@ void func_801A246C(u8 param_1, u8 param_2); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); -void func_801A2BB8(s32 arg0); +void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); 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 c34f5cb82..a898ea7cc 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -543,7 +543,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; this->unk_53C = 0; func_800BDC5C(&this->skelAnime, sAnimations, 3); - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(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 edc0135a8..14a2ac839 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; 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 1a038f5a7..513762805 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 @@ -337,7 +337,7 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80123F2C(globalCtx, 80); this->unk_26A = 1; this->actionFunc = func_809C80C0; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); break; case 0xA32: @@ -657,7 +657,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80112AFC(globalCtx); func_80123F2C(globalCtx, 0x63); this->unk_26A = 1; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); this->actionFunc = func_809C8808; break; From 43d5adebf656e251e84e5fd5f84ba8db8ca94ebe Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 03:16:22 +1100 Subject: [PATCH 068/130] Another seqId function --- include/functions.h | 2 +- src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 254c050c0..e6c387cc0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3874,7 +3874,7 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); -void func_801A0204(UNK_TYPE); +void func_801A0204(s8 seqId); // void func_801A0238(void); // void func_801A026C(void); // void func_801A0318(void); 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 db3f66030..467b5493a 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -590,9 +590,9 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9904(this); } if (gSaveContext.weekEventReg[14] & 4) { - func_801A0204(0x27); + func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(0x1F); + func_801A0204(NA_BGM_HOUSE); } } From 7c51f64320545383e4cbe751efad1df48ce2f66d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 03:39:21 +1100 Subject: [PATCH 069/130] Another name change --- include/bgm.h | 2 +- src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 9a5f547f3..fd6b98e58 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -34,7 +34,7 @@ #define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" #define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ #define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_INSIDE_A_HOUSE 0x1F // House "LINK_HOUSE" #define NA_BGM_GAME_OVER 0x20 // Game Over #define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear #define NA_BGM_GET_ITEM 0x22 // Item Catch 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 467b5493a..129b1c94d 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -592,7 +592,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[14] & 4) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(NA_BGM_HOUSE); + func_801A0204(NA_BGM_INSIDE_A_HOUSE); } } From a2056da3b286edfa66f986c323bce1fc7195b512 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 17:20:34 +1100 Subject: [PATCH 070/130] Woods of Mystery -> Sarias Song --- include/bgm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index fd6b98e58..c3ac3b1d1 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -65,7 +65,7 @@ #define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" #define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte #define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_SARIAS_SONG 0x3E // Saria's Theme Song from OoT "MAYOIMORI" #define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal #define NA_BGM_HORSE 0x40 // Gorman Race #define NA_BGM_HORSE_GOAL 0x41 // Race Finish From cf7009b45c591d64926efc71240b1324c973385d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 17 Nov 2021 16:21:46 +1100 Subject: [PATCH 071/130] Fix match in osVoiceControlGain --- src/libultra/voice/voicecontrolgain.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index be4d75973..b96ae510c 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -18,14 +18,9 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { return errorCode; } - if (!((digital < 8) && (digital >= 0))) { - goto dummy; - } - - phi_a2 = D_80098180[digital] + 2; - - if (0) { - dummy: + if (((digital < 8) && (digital >= 0))) { + phi_a2 = D_80098180[digital] + 2; + } else { return CONT_ERR_INVALID; } From 597907c50a26fde27e5d1fdd08898312a1e0082f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 17 Nov 2021 16:25:34 +1100 Subject: [PATCH 072/130] Fix bss reordering --- src/boot_O2_g3/yaz0.c | 1 + src/code/sched.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 094c0bb38..5fb32b8ea 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; diff --git a/src/code/sched.c b/src/code/sched.c index 927a48f66..5f9cdf236 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 From 4e0ce6c70a07a7cca0c41367f02de6ed2bf3f186 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 17 Nov 2021 16:28:15 +1100 Subject: [PATCH 073/130] Fix bss file split --- src/code/code_801A5BD0.c | 31 ------------------------------- tools/disasm/files.txt | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/code/code_801A5BD0.c b/src/code/code_801A5BD0.c index 0cafa50b1..32889dcb8 100644 --- a/src/code/code_801A5BD0.c +++ b/src/code/code_801A5BD0.c @@ -1,36 +1,5 @@ #include "global.h" -typedef struct { - /* 0x00 */ f32* posX; - /* 0x04 */ f32* posY; - /* 0x08 */ f32* posZ; - /* 0x0C */ f32* freqScale; - /* 0x10 */ f32* vol; - /* 0x14 */ s8* reverbAdd; - /* 0x18 */ f32 dist; - /* 0x1C */ u32 priority; // lower is more prioritized - /* 0x20 */ u16 sfxParams; - /* 0x22 */ u16 sfxId; - /* 0x25 */ u8 sfxUnk01; - /* 0x24 */ u8 sfxImportance; - /* 0x26 */ u8 state; // uses SfxState enum - /* 0x27 */ u8 freshness; - /* 0x28 */ u8 prev; - /* 0x29 */ u8 next; - /* 0x2A */ u8 channelIdx; - /* 0x2B */ u8 unk_2F; - /* 0x2C */ u8 token; -} SoundBankEntry; // size = 0x30 - -// gSoundBank -SoundBankEntry D_801FD710[9]; -SoundBankEntry D_801FD8C0[12]; -SoundBankEntry D_801FDB00[32]; -SoundBankEntry D_801FE100[20]; -SoundBankEntry D_801FE4C0[8]; -SoundBankEntry D_801FE640[3]; -SoundBankEntry D_801FE6D0[5]; - #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C28.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 8de402900..2ad71313b 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -716,7 +716,7 @@ 0x801FD140 : "audio_load", 0x801FD1F0 : "code_8019AF00", 0x801FD5A0 : "code_801A51F0", - 0x801FE7C0 : "code_801A5BD0", + 0x801FD710 : "code_801A5BD0", 0x801FFD00 : "code_801A7B10", 0x80208E90 : "code_801AA020", 0x80208EA0 : "gfxbuffers", From e84d8bc3f5b707baced6b7fd05ca81303483ba92 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 18:53:37 +1100 Subject: [PATCH 074/130] add saria's song bgm to pierre --- src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 436386af9..631fc26e5 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -811,7 +811,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { if (currentDay == 3 && gSaveContext.isNight) { EnKakasi_SetupDigAway(this); } else { - func_801A2BB8(0x3E); + func_801A2BB8(NA_BGM_SARIAS_SONG); EnKakasi_SetupDanceNightAway(this); } } From a0882f3fd3c05dcc920629007ad63ffc391798b6 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 22:36:18 +1100 Subject: [PATCH 075/130] Another bgm function found! --- include/functions.h | 2 +- src/code/z_common_data.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/functions.h b/include/functions.h index 39bfe916e..4b21e3d0f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1761,7 +1761,7 @@ void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); -void func_800FD750(UNK_TYPE arg0); +void func_800FD750(u16 seqId); // void func_800FD768(void); void func_800FD78C(GlobalContext* globalCtx); void func_800FD858(GlobalContext* globalCtx); diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 88fa3e103..89a161b45 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -7,7 +7,7 @@ void SaveContext_Init(void) { gSaveContext.playerForm = 0; gSaveContext.seqIndex = 0xFF; gSaveContext.nightSeqIndex = 0xFF; - gSaveContext.unk_3F46 = 0; + gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; gSaveContext.unk_3F4D = 0; 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 381dd693f..95fd85c5a 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -860,7 +860,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; @@ -1107,7 +1107,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; From 5cc0ff2d6413e56b3f4825c903c2b5a1a7b4e937 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 22:45:36 +1100 Subject: [PATCH 076/130] Add bgm's to `gSaveContext.seqIndex` --- src/code/z_common_data.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_scene.c | 2 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 89a161b45..26fd324a7 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -5,7 +5,7 @@ SaveContext gSaveContext; void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(gSaveContext)); gSaveContext.playerForm = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index edbf79ed7..979b28cba 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -45,7 +45,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.unk_3DC0 = 2000; gSaveContext.naviTimer = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 406685f85..293a9762d 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { + if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 550bbbc8e..1cae35a85 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -45,7 +45,7 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { } gSaveContext.respawn[0].entranceIndex = 0xFFFF; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index ed732fc3d..62a85c863 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -127,7 +127,7 @@ void Title_Main(GameState* thisx) { Title_UpdateCounters(this); Title_Draw(&this->gameState); if (this->exit) { - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.gameMode = 1; From 6b79b958b7fe771c9c5eb6b01ba1de270aee9560 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 5 Feb 2022 12:59:27 +1100 Subject: [PATCH 077/130] Fix BSS --- include/variables.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/variables.h b/include/variables.h index cd30f42d1..68a58f72f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3343,6 +3343,7 @@ extern FaultAddrConvClient sGraphFaultAddrConvClient; extern FaultClient sGraphFaultClient; extern GfxMasterList* gGfxMasterDL; extern CfbInfo sGraphCfbInfos[3]; +extern OSTime sGraphTaskStartTime; extern OSMesgQueue sSiIntMsgQ; extern OSMesg sSiIntMsgBuf[1]; extern u32 gSegments[NUM_SEGMENTS]; From aa020a6c43023c3a35df19bc79c126e849c2465b Mon Sep 17 00:00:00 2001 From: Maide Date: Tue, 28 Sep 2021 21:01:36 +0100 Subject: [PATCH 078/130] Obj_Mine --- spec | 6 +- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 1052 ++++++++++++++++- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 60 +- 3 files changed, 1054 insertions(+), 64 deletions(-) diff --git a/spec b/spec index 1c64ca1e8..115bce29e 100644 --- a/spec +++ b/spec @@ -3103,9 +3103,11 @@ beginseg name "ovl_Obj_Mine" compress include "build/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.o" - include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.data.o" - include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.bss.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Mine/ovl_Obj_Mine_reloc.o" +#else include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 5b5e80d39..a1a35a780 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -5,6 +5,7 @@ */ #include "z_obj_mine.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" #define FLAGS 0x00000000 @@ -15,7 +16,30 @@ void ObjMine_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMine_Update(Actor* thisx, GlobalContext* globalCtx); void ObjMine_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A82F84(ObjMine* this); +void func_80A82F98(ObjMine* this, GlobalContext* globalCtx); +void func_80A82FA8(ObjMine* this); +void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx); +void func_80A83258(ObjMine* this, GlobalContext* globalCtx); +void func_80A832BC(ObjMine* this); +void func_80A832D0(ObjMine* this, GlobalContext* globalCtx); +void func_80A83A74(ObjMine* this); +void func_80A83A88(ObjMine* this, GlobalContext* globalCtx); +void func_80A83B14(ObjMine* this); +void func_80A83B28(ObjMine* this, GlobalContext* globalCtx); +void func_80A83CEC(ObjMine* this); +void func_80A83D00(ObjMine* this, GlobalContext* globalCtx); +void func_80A83E7C(Actor* thisx, GlobalContext* globalCtx); +void func_80A83FBC(Actor* thisx, GlobalContext* globalCtx); +void func_80A84088(Actor* thisx, GlobalContext* globalCtx); +void func_80A84338(Actor* thisx, GlobalContext* globalCtx); + +extern Gfx D_06000030[]; +extern Gfx D_06002068[]; +extern Gfx D_06002188[]; + +static s32 D_80A849D0[0xC0]; + const ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, ACTORCAT_PROP, @@ -28,127 +52,1035 @@ const ActorInit Obj_Mine_InitVars = { (ActorFunc)ObjMine_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A84570[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x01CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A84594 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A84570, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A845E8[] = { +static f32 D_80A845A4[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, +}; + +static Vec3f D_80A845C4 = { 1.0f, 0.0f, 0.0f }; + +static Vec3f D_80A845D0[] = { + { 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1300, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; +void func_80A811D0(ObjMine* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->unk_1B4[arg1]); +} + +s32 func_80A8120C(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); + + if (temp_f0 < 0.001f) { + return false; + } + + arg1->x = arg0->x * (1.0f / temp_f0); + arg1->y = arg0->y * (1.0f / temp_f0); + arg1->z = arg0->z * (1.0f / temp_f0); + return true; +} + +s32 func_80A81288(Vec3f* arg0, Vec3f* arg1, f32* arg2, f32* arg3) { + f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); + + if (temp_f0 < 0.001f) { + return false; + } + + arg1->x = arg0->x * (1.0f / temp_f0); + arg1->y = arg0->y * (1.0f / temp_f0); + arg1->z = arg0->z * (1.0f / temp_f0); + *arg2 = temp_f0; + *arg3 = 1.0f / temp_f0; + + return true; +} + +void func_80A8131C(ObjMine* this, GlobalContext* globalCtx) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } +} + +void func_80A81384(ObjMine* this, GlobalContext* globalCtx) { + f32 x = this->collider.elements[0].dim.worldSphere.center.x; + f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; + f32 z = this->collider.elements[0].dim.worldSphere.center.z; + + EnBom* bom = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); + + if (bom != NULL) { + bom->timer = 0; + } +} + +s32 func_80A8140C(ObjMine* this) { + if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + return true; + } + + if ((this->collider.base.ocFlags1 & OC2_UNK1)) { + Actor* mine = this->collider.base.oc; + + if ((mine->id == ACTOR_OBJ_MINE) && (mine->room == this->actor.room)) { + return true; + } + } + + return false; +} + +void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { + s32 pad2[3]; + Vec3f sp40; + s16 sp3E; + s16 pad; + Actor* temp_s0 = this->collider.base.ac; + + Math_Vec3s_ToVec3f(&sp40, &this->collider.elements[0].dim.worldSphere.center); + sp3E = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp40); + + if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { + *arg1 = temp_s0->shape.rot.y; + *arg2 = temp_s0->shape.rot.y - sp3E; + } else { + Vec3f sp2C; + Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + + Math_Vec3s_ToVec3f(&sp2C, hitPos); + *arg1 = Actor_YawBetweenActors(temp_s0, &this->actor); + *arg2 = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp2C) - sp3E; + } +} + +#ifdef NON_MATCHING +// stack, 1 var needs to go without changing code gen +void func_80A81544(ObjMine* this, Vec3f* arg1) { + ColliderJntSphElement* element = &this->collider.elements[0]; + Vec3s* sphere = &element->dim.worldSphere.center; + Actor* temp_v1 = this->collider.base.ac; + + if ((element->info.acHitInfo->toucher.dmgFlags & 0x13820)) { + SysMatrix_StatePush(); + Matrix_RotateY(temp_v1->shape.rot.y, MTXMODE_NEW); + SysMatrix_InsertXRotation_s(temp_v1->shape.rot.x, MTXMODE_APPLY); + SysMatrix_GetStateTranslationAndScaledZ(1.0f, arg1); + SysMatrix_StatePop(); + } else { + Vec3f sp20; + + sp20.x = sphere->x - temp_v1->world.pos.x; + sp20.y = sphere->y - temp_v1->world.pos.y; + sp20.z = sphere->z - temp_v1->world.pos.z; + if (!func_80A8120C(&sp20, arg1)) { + Math_Vec3f_Copy(arg1, D_80A845D0); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") #endif -extern ColliderJntSphElementInit D_80A84570[1]; -extern ColliderJntSphInit D_80A84594; -extern InitChainEntry D_80A845E8[]; +void func_80A81640(ObjMine* this) { +} -extern UNK_TYPE D_06000030; -extern UNK_TYPE D_06002068; +void func_80A8164C(Vec3f* arg0) { + MtxF* matrix = SysMatrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A811D0.s") + matrix->mf[3][0] = arg0->x; + matrix->mf[3][1] = arg0->y; + matrix->mf[3][2] = arg0->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8120C.s") +void func_80A81684(ObjMineUnkStruct* arg0) { + MtxF* matrix = SysMatrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81288.s") + matrix->mf[0][0] = arg0->unk_00.x; + matrix->mf[0][1] = arg0->unk_00.y; + matrix->mf[0][2] = arg0->unk_00.z; + matrix->mf[0][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8131C.s") + matrix->mf[1][0] = arg0->unk_0C.x; + matrix->mf[1][1] = arg0->unk_0C.y; + matrix->mf[1][2] = arg0->unk_0C.z; + matrix->mf[1][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81384.s") + matrix->mf[2][0] = arg0->unk_18.x; + matrix->mf[2][1] = arg0->unk_18.y; + matrix->mf[2][2] = arg0->unk_18.z; + matrix->mf[2][3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8140C.s") + matrix->mf[3][0] = 0.0f; + matrix->mf[3][1] = 0.0f; + matrix->mf[3][2] = 0.0f; + matrix->mf[3][3] = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8146C.s") +s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { + Vec3f sp3C; + Vec3f sp30; + Vec3f sp24; + f32 sp20 = Math3D_Parallel(arg0, arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") + if (cos_rad(arg2) <= sp20) { + Math_Vec3f_Copy(arg0, arg1); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81640.s") + SysMatrix_StatePush(); + Math_Vec3f_Copy(&sp30, arg0); + Math3D_CrossProduct(arg0, arg1, &sp3C); + if (func_80A8120C(&sp3C, &sp24)) { + SysMatrix_InsertRotationAroundUnitVector_s(arg2 * 10430.378f, &sp24, MTXMODE_NEW); + SysMatrix_MultiplyVector3fByState(&sp30, arg0); + } else { + SysMatrix_SetStateXRotation(arg2); + SysMatrix_MultiplyVector3fByState(&sp30, arg0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A8164C.s") + SysMatrix_StatePop(); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81684.s") +void func_80A81818(ObjMine* this) { + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81714.s") +void func_80A81868(ObjMine* this, s32 arg1) { + s32 i; + ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct3* unkStruct; + f32 arg = arg1; + f32 temp_f12 = this->actor.home.rot.z * 5.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81818.s") + ptr->unk_00.x = 1.0f; + ptr->unk_0C.y = 1.0f; + ptr->unk_18.z = 1.0f; + ptr->unk_24.y = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81868.s") + if (arg1 > 0) { + ptr->unk_40 = -sqrtf(0.001984f / arg); + ptr->unk_44 = (0.00031746097f * arg) + 0.95f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A819A4.s") + ptr->unk_58 = 0.0002f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81A00.s") + for (i = 0, unkStruct = &ptr->unk_60[0]; i < arg1; i++, unkStruct++) { + unkStruct->unk_00 = 0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81AA4.s") + if (temp_f12 < 0.0f) { + ptr->unk_5C = -1.0f; + } else if (temp_f12 <= 21.0f) { + ptr->unk_5C = 0.0f; + } else { + ptr->unk_5C = SQ(temp_f12 - 20.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81B14.s") +void func_80A819A4(ObjMine* this, s32 arg1) { + SysMatrix_InsertTranslation(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); + Collider_UpdateSpheres(0, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81B7C.s") +void func_80A81A00(ObjMine* this) { + ObjMineUnkStruct* ptr = &this->unk_1B8; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81D70.s") + sp28.x = -ptr->unk_30; + sp28.y = 1.0f; + sp28.z = -ptr->unk_34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81DEC.s") + func_80A8120C(&sp28, &ptr->unk_0C); + Math3D_CrossProduct(&D_80A845C4, &ptr->unk_0C, &sp28); + func_80A8120C(&sp28, &ptr->unk_18); + Math3D_CrossProduct(&ptr->unk_0C, &ptr->unk_18, &sp28); + func_80A8120C(&sp28, &ptr->unk_00); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81E7C.s") +void func_80A81AA4(ObjMine* this) { + s32 params = this->actor.params & 0x3F; + f32 temp_f0 = -((params * 12.0f) + 10.0f); + + this->actor.world.pos.x = (this->unk_1B8.unk_0C.x * temp_f0) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->unk_1B8.unk_0C.y * temp_f0) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->unk_1B8.unk_0C.z * temp_f0) + this->actor.home.pos.z; +} + +void func_80A81B14(ObjMine* this) { + s32 params = this->actor.params & 0x3F; + f32 temp_f0 = 1.0f / ((params * 12.0f) + 10.0f); + f32 x = this->actor.world.pos.x - this->actor.home.pos.x; + f32 z = this->actor.world.pos.z - this->actor.home.pos.z; + + this->unk_1B8.unk_30 = x * temp_f0; + this->unk_1B8.unk_34 = z * temp_f0; +} + +void func_80A81B7C(ObjMine* this, s32 arg1) { + ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct2* unkStruct; + s32 i; + f32 sp58 = this->actor.home.rot.z * 5.0f; + f32 temp_f24; + f32 temp_f26; + + ptr->unk_00.x = 0.9f; + ptr->unk_18.y = 0.003f; + + *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; + ptr->unk_24.x = -0.0002f; + ptr->unk_30 = -0.0002f; + + temp_f26 = ptr->unk_18.y * 6.0f; + temp_f24 = this->actor.home.pos.y; + + unkStruct = (ObjMineUnkStruct2*)&ptr->unk_44; + for (i = 0; i < arg1; i++, unkStruct++) { + temp_f24 += 12.0f; + unkStruct->unk_00.x = 1.0f; + unkStruct->unk_0C.y = 1.0f; + unkStruct->unk_18.z = 1.0f; + unkStruct->unk_24.x = this->actor.home.pos.x; + unkStruct->unk_24.y = temp_f24; + unkStruct->unk_24.z = this->actor.home.pos.z; + unkStruct->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; + unkStruct->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; + unkStruct->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; + } + + ptr->unk_24.y = temp_f24; + ptr->unk_24.z = temp_f24 * 0.97f; + temp_f24 = temp_f24 - 18.0f; + + if (ptr->unk_24.z < temp_f24) { + ptr->unk_24.z = temp_f24; + } + + if (sp58 < 0.0f) { + ptr->unk_34 = -1.0f; + } else if (sp58 <= 37.0f) { + ptr->unk_34 = 0.0f; + } else { + ptr->unk_34 = SQ(sp58 - 36.0f); + } +} + +void func_80A81D70(ObjMine* this, s32 arg1) { + SysMatrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, + this->actor.home.pos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); +} + +void func_80A81DEC(ObjMine* this) { + s32 pad[2]; + s32 temp_v0 = this->actor.params & 0x3F; + NextUnkStruct* temp_v1 = &((NextUnkStruct*)&this->unk_1B8)[temp_v0]; + + if (temp_v0 == 0) { + this->actor.world.pos.y = (this->actor.home.pos.y + 12.0f) + 10.0f; + } else { + Vec3f sp1C; + + Math_Vec3f_ScaleAndStore(&temp_v1->unk_08, 10.0f, &sp1C); + Math_Vec3f_Sum(&temp_v1->unk_20, &sp1C, &this->actor.world.pos); + } +} + +void func_80A81E7C(ObjMine* this, GlobalContext* globalCtx) { + ObjMineUnkStruct* temp_v1 = &this->unk_1B8; + s32 pad; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + CollisionPoly* sp48; + u32 sp44; + f32 sp40; + f32 sp3C; + + *(s8*)(&temp_v1->unk_40) = 0; + if (temp_v1->unk_34 > -0.000001f) { + if (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + this->actor.world.pos.x, this->actor.world.pos.z)) { + sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; + sp58.y = 0.0f; + sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; + if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { + sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); + sp70.y = this->actor.world.pos.y; + sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); + sp7C.x = this->actor.home.pos.x; + sp7C.y = this->actor.world.pos.y; + sp7C.z = this->actor.home.pos.z; + if (func_800C55C4(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { + *(s8*)(&temp_v1->unk_40) = 1; + temp_v1->unk_38 = sp4C.x * -0.2f; + temp_v1->unk_3C = sp4C.z * -0.2f; + } + } + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A828A8.s") +void func_80A828A8(ObjMine* this) { + s32 pad; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + s32 spC4 = this->actor.params & 0x3F; + s32 i = 0; + s32 phi_s5; + Vec3f* phi_s3 = NULL; + ObjMineUnkStruct* sp70 = &this->unk_1B8; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + Vec3f sp84; + ObjMineUnkStruct2* temp_s0 = (ObjMineUnkStruct2*)&sp70->unk_44; + f32 sp7C; + f32 sp78; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82C28.s") + sp84.x = this->actor.home.pos.x; + sp84.y = this->actor.home.pos.y + 6.0f; + sp84.z = this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Init.s") + for (; i < spC4; i++, temp_s0++) { + phi_s5 = false; + temp_s0->unk_30.x += temp_s0->unk_3C.x; + temp_s0->unk_30.y += temp_s0->unk_3C.y; + temp_s0->unk_30.z += temp_s0->unk_3C.z; + Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00.x); + Math_Vec3f_Copy(&sp90, &temp_s0->unk_24); + temp_s0->unk_24.x += temp_s0->unk_30.x; + temp_s0->unk_24.y += temp_s0->unk_30.y; + temp_s0->unk_24.z += temp_s0->unk_30.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Destroy.s") + if ((temp_s0->unk_24.y <= this->actor.home.pos.y) && (temp_s0->unk_30.y < 0.0f)) { + temp_s0->unk_30.y *= 0.1f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82F84.s") + Math_Vec3f_Diff(&temp_s0->unk_24, &sp84, &spA8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82F98.s") + if (func_80A81288(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { + Math_Vec3f_Copy(&spD4, &temp_s0->unk_0C); + func_80A81714(&spD4, &sp9C, 0.10471976f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82FA8.s") + Math3D_CrossProduct((phi_s3 == NULL) ? &D_80A845C4 : phi_s3, &spD4, &spA8); + if (func_80A8120C(&spA8, &spE0)) { + Math3D_CrossProduct(&spD4, &spE0, &spA8); + if (func_80A8120C(&spA8, &spC8)) { + phi_s5 = true; + } + } + } + + if (phi_s5) { + Math_Vec3f_Copy(&temp_s0->unk_00, &spC8); + Math_Vec3f_Copy(&temp_s0->unk_0C, &spD4); + Math_Vec3f_Copy(&temp_s0->unk_18, &spE0); + } else { + sp7C = 4.0f; + } + + if (sp7C >= 6.0f) { + temp_s0->unk_24.x = (temp_s0->unk_0C.x * 6.0f) + sp84.x; + temp_s0->unk_24.y = (temp_s0->unk_0C.y * 6.0f) + sp84.y; + temp_s0->unk_24.z = (temp_s0->unk_0C.z * 6.0f) + sp84.z; + } else { + temp_s0->unk_24.x = (temp_s0->unk_0C.x * sp7C) + sp84.x; + temp_s0->unk_24.y = (temp_s0->unk_0C.y * sp7C) + sp84.y; + temp_s0->unk_24.z = (temp_s0->unk_0C.z * sp7C) + sp84.z; + } + + sp84.x = temp_s0->unk_24.x + (temp_s0->unk_0C.x * 6.0f); + sp84.y = temp_s0->unk_24.y + (temp_s0->unk_0C.y * 6.0f); + sp84.z = temp_s0->unk_24.z + (temp_s0->unk_0C.z * 6.0f); + + phi_s3 = &temp_s0->unk_00; + } +} + +void func_80A81FFC(ObjMine* this); + +void func_80A82C28(ObjMine* this, GlobalContext* globalCtx) { + func_80A81E7C(this, globalCtx); + func_80A81FFC(this); + func_80A828A8(this); +} + +void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + s32 pad; + s32 sp44 = this->actor.params & 0xFF; + Path* path; + s32 sp3C; + s32 sp38 = (this->actor.params >> 0xC) & 3; + s32 sp34; + + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + + if (sp38 == 0) { + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 45.0f); + this->actor.shape.shadowAlpha = 140; + this->unk_1A8 = D_80A845A4[(this->actor.params >> 8) & 7]; + if (sp44 == 0xFF) { + func_80A82F84(this); + } else { + path = &globalCtx->setupPathList[sp44]; + this->unk_1B0 = 0; + this->unk_1AC = path->count - 1; + this->unk_1B4 = (Vec3s*)Lib_SegmentedToVirtual(path->points); + func_80A811D0(this, this->unk_1B0); + func_80A82FA8(this); + } + SysMatrix_SetStateRotationAndTranslation(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); + this->actor.floorHeight = + func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &this->actor.world.pos); + } else { + sp34 = this->actor.params & 0x3F; + this->actor.update = func_80A83E7C; + this->actor.uncullZoneScale = (sp34 * 21.0f) + 150.0f; + this->actor.uncullZoneDownward = (sp34 * 21.0f) + 150.0f; + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 45.0f); + this->actor.shape.shadowAlpha = 0x8C; + + if (sp38 == 1) { + this->actor.draw = func_80A84088; + func_80A81868(this, sp34); + this->actor.world.pos.y = (-10.0f - (sp34 * 12.0f)) + this->actor.home.pos.y; + func_80A819A4(this, sp34); + func_800B4AEC(globalCtx, &this->actor, 0.0f); + if (sp34 == 0) { + func_80A83A74(this); + } else { + func_80A832BC(this); + } + } else { + this->actor.draw = func_80A84338; + func_80A81B7C(this, sp34); + this->actor.world.pos.y = (sp34 * 12.0f) + 10.0f + this->actor.home.pos.y; + func_80A81D70(this, sp34); + if (sp34 == 0) { + func_80A83CEC(this); + } else { + func_80A83B14(this); + } + } + } +} + +void ObjMine_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80A82F84(ObjMine* this) { + this->actionFunc = func_80A82F98; +} + +void func_80A82F98(ObjMine* this, GlobalContext* globalCtx) { +} + +void func_80A82FA8(ObjMine* this) { + this->actor.flags |= 0x10; + this->actionFunc = func_80A82FC8; +} + +#ifdef NON_MATCHING +// stack +void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx) { + f32 phi_f0; + Vec3f spA0; + f32 sp9C; + s32 pad; + f32 phi_f12; + s32 sp90; + Vec3f sp84; + Vec3f sp78; + MtxF sp38; + + Math_Vec3s_ToVec3f(&spA0, &this->unk_1B4[this->unk_1B0 + 1]); + Math_Vec3f_Diff(&spA0, &this->actor.world.pos, &this->actor.velocity); + + sp9C = Math3D_Vec3fMagnitude(&this->actor.velocity); + if ((sp9C < (this->unk_1A8 * 8.0f)) && (this->unk_1A8 > 2.0f)) { + phi_f0 = ((this->unk_1A8 - 2.0f) * 0.1f) + 2.0f; + phi_f12 = this->unk_1A8 * 0.03f; + } else { + phi_f0 = this->unk_1A8; + phi_f12 = this->unk_1A8 * 0.16f; + } + + Math_StepToF(&this->actor.speedXZ, phi_f0, phi_f12); + + if ((this->actor.speedXZ + 0.05f) < sp9C) { + Math_Vec3f_Scale(&this->actor.velocity, this->actor.speedXZ / sp9C); + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + } else { + this->actor.speedXZ *= 0.4f; + this->unk_1B0++; + if (this->unk_1B0 >= this->unk_1AC) { + this->unk_1B0 = 0; + } + func_80A811D0(this, this->unk_1B0); + } + + this->actor.floorHeight = + func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp90, &this->actor, &this->actor.world.pos); + + if (this->actor.flags & 0x40) { + Math3D_CrossProduct(&D_80A845D0[0], &this->actor.velocity, &sp78); + if (func_80A8120C(&sp78, &sp84)) { + SysMatrix_InsertRotationAroundUnitVector_f(this->actor.speedXZ * 0.03125f, &sp84, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + SysMatrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + SysMatrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + SysMatrix_CopyCurrentState(&sp38); + func_8018219C(&sp38, &this->actor.shape.rot, 0); + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82FC8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83214.s") +void func_80A83214(ObjMine* this) { + this->actor.flags |= 0x10; + this->actor.draw = func_80A83FBC; + this->actor.shape.shadowDraw = NULL; + this->actor.scale.x = 0.02f; + this->actor.scale.y = 0.02f; + this->actor.scale.z = 0.02f; + this->actionFunc = func_80A83258; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83258.s") +void func_80A83258(ObjMine* this, GlobalContext* globalCtx) { + this->actor.scale.x *= 1.8f; + if (this->actor.scale.x > 0.17495999f) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A832BC.s") +void func_80A832BC(ObjMine* this) { + this->actionFunc = func_80A832D0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A832D0.s") +void func_80A832D0(ObjMine* this, GlobalContext* globalCtx) { + s32 pad; + s32 spA0 = this->actor.params & 0x3F; + ObjMineUnkStruct* unkStruct = &this->unk_1B8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83A74.s") + Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_0C); + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + } else { + ObjMineUnkStruct3* temp; + s32 i; + f32 sp90; + f32 sp8C; + f32 sp88; + s16 sp86; + s16 sp84; + s32 pad2; + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83A88.s") + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + unkStruct->unk_48 = 0.04f; + func_80A8146C(this, &unkStruct->unk_4C, &sp84); + sp8C = Math_SinS(sp84) * 150.0f; + sp88 = sp8C; + sp8C = -(sp8C / spA0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83B14.s") + for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { + temp->unk_02 += (s16)sp88; + temp->unk_02 = CLAMP(temp->unk_02, -800, 800); + sp88 -= sp8C; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83B28.s") + if (unkStruct->unk_48 > 0.0001f) { + sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; + sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; + unkStruct->unk_38 += sp90; + unkStruct->unk_3C += sp8C; + Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83CEC.s") + if ((u32)Rand_Next() >> 0x1B == 0) { + unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; + unkStruct->unk_54 = (u32)Rand_Next() >> 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83D00.s") + sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; + sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; + unkStruct->unk_38 += sp90; + unkStruct->unk_3C += sp8C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Update.s") + unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; + unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83E7C.s") + unkStruct->unk_38 *= unkStruct->unk_44; + unkStruct->unk_3C *= unkStruct->unk_44; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Draw.s") + unkStruct->unk_30 += unkStruct->unk_38; + unkStruct->unk_34 += unkStruct->unk_3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A83FBC.s") + unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); + unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A84088.s") + func_80A81A00(this); + func_80A81AA4(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A84338.s") + if ((unkStruct->unk_5C > -0.000001f) && + (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z))) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 0.0f, 1); + + if (this->actor.bgCheckFlags & 8) { + if (this->actor.wallPoly != NULL) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + sp4C.x = unkStruct->unk_38; + sp4C.y = 0.0f; + sp4C.z = unkStruct->unk_3C; + if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { + sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + func_80179F64(&sp70, &sp58, &sp64); + sp48 *= 0.5f; + unkStruct->unk_38 = sp64.x * sp48; + unkStruct->unk_3C = sp64.z * sp48; + } else { + unkStruct->unk_38 *= -0.1f; + unkStruct->unk_3C *= -0.1f; + } + func_80A81B14(this); + func_80A81A00(this); + func_80A81AA4(this); + } + } + } + + for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { + sp86 = temp->unk_00 - 0x4000; + sp88 = ((Rand_ZeroOne() * 30.0f) - 15.0f) + (temp->unk_02 + (sp86 * -0.05f)); + sp88 *= 0.995f; + temp->unk_02 = sp88; + temp->unk_00 += temp->unk_02; + } + + func_800B4AEC(globalCtx, &this->actor, 0.0f); + func_80A81818(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80A83A74(ObjMine* this) { + this->actionFunc = func_80A83A88; +} + +void func_80A83A88(ObjMine* this, GlobalContext* globalCtx) { + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80A83B14(ObjMine* this) { + this->actionFunc = func_80A83B28; +} + +void func_80A83B28(ObjMine* this, GlobalContext* globalCtx) { + ObjMineUnkStruct* ptr; + s16 rand; + + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + return; + } + + ptr = &this->unk_1B8; + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + func_80A81544(this, (Vec3f*)&ptr->unk_00.y); + ptr->unk_0C.y = 7.0f; + Math_Vec3f_Scale((Vec3f*)&ptr->unk_00.y, 7.0f); + } + + if (ptr->unk_0C.y > 0.0001f) { + ptr->unk_0C.y = Math_Vec3f_StepTo((Vec3f*)&ptr->unk_00.y, &D_801D15B0, 2.8f); + } + + ptr->unk_00.x = 0.9f; + ptr->unk_24.x = -0.0002f; + ptr->unk_30 = -0.0002f; + ptr->unk_18.y = 0.003f; + if (!((u32)Rand_Next() >> 0x1B)) { + rand = (u32)Rand_Next() >> 0x10; + ptr->unk_0C.z = Math_SinS(rand) * 1.8f * ptr->unk_18.y; + ptr->unk_18.x = Math_CosS(rand) * 0.2f * ptr->unk_18.y; + *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; + } + + func_80A82C28(this, globalCtx); + func_80A81DEC(this); + func_80A81818(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80A83CEC(ObjMine* this) { + this->actionFunc = func_80A83D00; +} + +void func_80A83D00(ObjMine* this, GlobalContext* globalCtx) { + if (func_80A8140C(this)) { + func_80A81384(this, globalCtx); + func_80A81640(this); + func_80A83214(this); + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjMine_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjMine* this = THIS; + + if ((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.acFlags & AC_HIT)) { + func_80A8131C(this, globalCtx); + func_80A83214(this); + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + if ((this->actor.flags & 0x40) && (this->actionFunc != func_80A83258)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80A83E7C(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjMine_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjMine* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actionFunc == func_80A82FC8) { + Collider_UpdateSpheres(0, &this->collider); + } + + func_800B8050(&this->actor, globalCtx, 1); + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPDisplayList(POLY_OPA_DISP++, D_06002068); + gSPDisplayList(POLY_OPA_DISP++, D_06002188); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A83FBC(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800B8118(&this->actor, globalCtx, 1); + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 75); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_06002068); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + s32 temp_s5 = this->actor.params & 0x3F; + ObjMineUnkStruct3* temp; + ObjMineUnkStruct* ptr = &this->unk_1B8; + s32 pad; + s32 i; + Vec3f sp94; + Vec3f sp88; + Gfx* gfx; + + func_800B8050(&this->actor, globalCtx, 1); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + + func_80A81684(ptr); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (temp_s5 != 0) { + Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -6.0f, &sp88); + sp94.x = this->actor.home.pos.x - sp88.x; + sp94.y = (this->actor.home.pos.y - 6.0f) - sp88.y; + sp94.z = this->actor.home.pos.z - sp88.z; + Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -12.0f, &sp88); + + for (i = 0, temp = &ptr->unk_60[0]; i < temp_s5; i++, temp++) { + Matrix_RotateY(temp->unk_00, MTXMODE_APPLY); + sp94.x += sp88.x; + sp94.y += sp88.y; + sp94.z += sp88.z; + func_80A8164C(&sp94); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + } + } + + SysMatrix_InsertXRotation_s(0x2000, MTXMODE_APPLY); + func_80A8164C(&this->actor.world.pos); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(gfx++); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(gfx++, 0, 0, 0, 255); + gSPDisplayList(gfx++, D_06002068); + gSPDisplayList(gfx++, D_06002188); + + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A84338(Actor* thisx, GlobalContext* globalCtx) { + ObjMine* this = THIS; + s32 temp_s7 = this->actor.params & 0x3F; + s32 i; + Gfx* gfx; + ObjMineUnkStruct2* temp; + s32 pad[2]; + + func_800B8050(&this->actor, globalCtx, 1); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + + for (i = 0, temp = (ObjMineUnkStruct2*)((u8*)this + 0x1FC); i < temp_s7; i++, temp++) { + func_80A81684((ObjMineUnkStruct*)temp); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); + if ((i & 1) == 0) { + Matrix_RotateY(0x4000, 1); + } + func_80A8164C(&temp->unk_24); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, D_06000030); + } + + SysMatrix_InsertXRotation_s(0x2000, 1); + func_80A8164C(&this->actor.world.pos); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(gfx++); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(gfx++, 0, 0, 0, 255); + gSPDisplayList(gfx++, D_06002068); + gSPDisplayList(gfx++, D_06002188); + + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 4b7f8ee3d..af2772fda 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,11 +7,67 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, GlobalContext*); +// definitely fake +typedef struct { + char unk_00[0x8]; + Vec3f unk_08; + char unk_14[0xC]; + Vec3f unk_20; + char unk_2C[0x1C]; +} NextUnkStruct; // size = 0x48 + +// maybe fake +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; +} ObjMineUnkStruct3; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + ///* 0x24 */ char unk_24[0x3C]; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; + /* 0x40 */ f32 unk_40; + /* 0x44 */ f32 unk_44; + /* 0x48 */ f32 unk_48; + /* 0x4C */ s16 unk_4C; + /* 0x50 */ f32 unk_50; + /* 0x54 */ s16 unk_54; + /* 0x58 */ f32 unk_58; + /* 0x5C */ f32 unk_5C; + /* 0x60 */ ObjMineUnkStruct3 unk_60[1]; +} ObjMineUnkStruct; // size = ?? 0x44??? 48 array??? + +// probably fake +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0c */ Vec3f unk_0C; + ///* 0x10 */ f32 unk_10; + ///* 0x14 */ char unk_14[0x4]; + /* 0x18 */ Vec3f unk_18; + ///* 0x1C */ char unk_1C[0x4]; + ///* 0x20 */ f32 unk_20; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ Vec3f unk_30; + /* 0x3C */ Vec3f unk_3C; +} ObjMineUnkStruct2; // size = 0x48??? + typedef struct ObjMine { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjMineActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0x120C]; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ s32 unk_1AC; + /* 0x01B0 */ s32 unk_1B0; + /* 0x01B4 */ Vec3s* unk_1B4; + /* 0x01B8 */ ObjMineUnkStruct unk_1B8; // array?? + /* 0x021C */ char unk_21C[0x1198]; } ObjMine; // size = 0x13B4 extern const ActorInit Obj_Mine_InitVars; From 5ce086ffe5685979b808b208d573447c76d911f0 Mon Sep 17 00:00:00 2001 From: Kelebek1 Date: Thu, 14 Apr 2022 02:18:01 +0100 Subject: [PATCH 079/130] Fixups --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index a1a35a780..c2b644cef 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -198,11 +198,11 @@ void func_80A81544(ObjMine* this, Vec3f* arg1) { Actor* temp_v1 = this->collider.base.ac; if ((element->info.acHitInfo->toucher.dmgFlags & 0x13820)) { - SysMatrix_StatePush(); + Matrix_StatePush(); Matrix_RotateY(temp_v1->shape.rot.y, MTXMODE_NEW); - SysMatrix_InsertXRotation_s(temp_v1->shape.rot.x, MTXMODE_APPLY); - SysMatrix_GetStateTranslationAndScaledZ(1.0f, arg1); - SysMatrix_StatePop(); + Matrix_InsertXRotation_s(temp_v1->shape.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, arg1); + Matrix_StatePop(); } else { Vec3f sp20; @@ -222,7 +222,7 @@ void func_80A81640(ObjMine* this) { } void func_80A8164C(Vec3f* arg0) { - MtxF* matrix = SysMatrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrentState(); matrix->mf[3][0] = arg0->x; matrix->mf[3][1] = arg0->y; @@ -230,7 +230,7 @@ void func_80A8164C(Vec3f* arg0) { } void func_80A81684(ObjMineUnkStruct* arg0) { - MtxF* matrix = SysMatrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrentState(); matrix->mf[0][0] = arg0->unk_00.x; matrix->mf[0][1] = arg0->unk_00.y; @@ -264,18 +264,18 @@ s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { return true; } - SysMatrix_StatePush(); + Matrix_StatePush(); Math_Vec3f_Copy(&sp30, arg0); Math3D_CrossProduct(arg0, arg1, &sp3C); if (func_80A8120C(&sp3C, &sp24)) { - SysMatrix_InsertRotationAroundUnitVector_s(arg2 * 10430.378f, &sp24, MTXMODE_NEW); - SysMatrix_MultiplyVector3fByState(&sp30, arg0); + Matrix_InsertRotationAroundUnitVector_s(arg2 * 10430.378f, &sp24, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp30, arg0); } else { - SysMatrix_SetStateXRotation(arg2); - SysMatrix_MultiplyVector3fByState(&sp30, arg0); + Matrix_SetStateXRotation(arg2); + Matrix_MultiplyVector3fByState(&sp30, arg0); } - SysMatrix_StatePop(); + Matrix_StatePop(); return false; } @@ -318,7 +318,7 @@ void func_80A81868(ObjMine* this, s32 arg1) { } void func_80A819A4(ObjMine* this, s32 arg1) { - SysMatrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(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); Collider_UpdateSpheres(0, &this->collider); } @@ -407,8 +407,8 @@ void func_80A81B7C(ObjMine* this, s32 arg1) { } void func_80A81D70(ObjMine* this, s32 arg1) { - SysMatrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, - this->actor.home.pos.z, MTXMODE_NEW); + Matrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, + this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -437,7 +437,7 @@ void func_80A81E7C(ObjMine* this, GlobalContext* globalCtx) { Vec3f sp58; Vec3f sp4C; CollisionPoly* sp48; - u32 sp44; + s32 sp44; f32 sp40; f32 sp3C; @@ -455,7 +455,7 @@ void func_80A81E7C(ObjMine* this, GlobalContext* globalCtx) { sp7C.x = this->actor.home.pos.x; sp7C.y = this->actor.world.pos.y; sp7C.z = this->actor.home.pos.z; - if (func_800C55C4(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { *(s8*)(&temp_v1->unk_40) = 1; temp_v1->unk_38 = sp4C.x * -0.2f; temp_v1->unk_3C = sp4C.z * -0.2f; @@ -570,7 +570,7 @@ void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); if (sp38 == 0) { - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 45.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 140; this->unk_1A8 = D_80A845A4[(this->actor.params >> 8) & 7]; if (sp44 == 0xFF) { @@ -583,18 +583,18 @@ void ObjMine_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A811D0(this, this->unk_1B0); func_80A82FA8(this); } - SysMatrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetStateRotationAndTranslation(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); - this->actor.floorHeight = - func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &this->actor.world.pos); + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp3C, + &this->actor, &this->actor.world.pos); } else { sp34 = this->actor.params & 0x3F; this->actor.update = func_80A83E7C; this->actor.uncullZoneScale = (sp34 * 21.0f) + 150.0f; this->actor.uncullZoneDownward = (sp34 * 21.0f) + 150.0f; - ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 45.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 0x8C; if (sp38 == 1) { @@ -681,17 +681,17 @@ void func_80A82FC8(ObjMine* this, GlobalContext* globalCtx) { func_80A811D0(this, this->unk_1B0); } - this->actor.floorHeight = - func_800C411C(&globalCtx->colCtx, &this->actor.floorPoly, &sp90, &this->actor, &this->actor.world.pos); + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp90, + &this->actor, &this->actor.world.pos); if (this->actor.flags & 0x40) { Math3D_CrossProduct(&D_80A845D0[0], &this->actor.velocity, &sp78); if (func_80A8120C(&sp78, &sp84)) { - SysMatrix_InsertRotationAroundUnitVector_f(this->actor.speedXZ * 0.03125f, &sp84, MTXMODE_NEW); + Matrix_InsertRotationAroundUnitVector_f(this->actor.speedXZ * 0.03125f, &sp84, MTXMODE_NEW); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - SysMatrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - SysMatrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - SysMatrix_CopyCurrentState(&sp38); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); func_8018219C(&sp38, &this->actor.shape.rot, 0); } } @@ -883,7 +883,7 @@ void func_80A83B28(ObjMine* this, GlobalContext* globalCtx) { } if (ptr->unk_0C.y > 0.0001f) { - ptr->unk_0C.y = Math_Vec3f_StepTo((Vec3f*)&ptr->unk_00.y, &D_801D15B0, 2.8f); + ptr->unk_0C.y = Math_Vec3f_StepTo((Vec3f*)&ptr->unk_00.y, &gZeroVec3f, 2.8f); } ptr->unk_00.x = 0.9f; @@ -1026,7 +1026,7 @@ void func_80A84088(Actor* thisx, GlobalContext* globalCtx) { } } - SysMatrix_InsertXRotation_s(0x2000, MTXMODE_APPLY); + Matrix_InsertXRotation_s(0x2000, MTXMODE_APPLY); func_80A8164C(&this->actor.world.pos); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1070,7 +1070,7 @@ void func_80A84338(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(gfx++, D_06000030); } - SysMatrix_InsertXRotation_s(0x2000, 1); + Matrix_InsertXRotation_s(0x2000, 1); func_80A8164C(&this->actor.world.pos); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); From 58c39701d5e58ebab0a4064284a7607df556379c Mon Sep 17 00:00:00 2001 From: mzxrules Date: Sun, 12 Jun 2022 20:43:13 -0400 Subject: [PATCH 080/130] match first couple of funcs --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 247 +++++++++++++++++- .../actors/ovl_En_Honotrap/z_en_honotrap.h | 36 ++- 2 files changed, 268 insertions(+), 15 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index aaea88252..0b2d38c7a 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -5,6 +5,7 @@ */ #include "z_en_honotrap.h" +#include "assets/objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -30,6 +31,19 @@ void func_8092F5EC(EnHonotrap* this, GlobalContext* globalCtx); void func_8092F7BC(EnHonotrap* this, GlobalContext* globalCtx); void func_8092F878(EnHonotrap* this, GlobalContext* globalCtx); +void func_8092E638(EnHonotrap* this, GlobalContext* globalCtx); // d +void func_8092E840(EnHonotrap* this, GlobalContext* globalCtx); // d +void func_8092E988(EnHonotrap* this, GlobalContext* globalCtx); // d +void func_8092FE44(Actor* thisx, GlobalContext* globalCtx); +void func_8092FEFC(Actor* thisx, GlobalContext* globalCtx); +void func_80930030(Actor* thisx, GlobalContext* globalCtx); +void func_80930190(Actor* thisx, GlobalContext* globalCtx); + +void func_8092EBC0(EnHonotrap* this); +void func_8092EE68(EnHonotrap* this); +void func_8092F0F8(EnHonotrap* this); +void func_8092F854(EnHonotrap* this); + #if 0 const ActorInit En_Honotrap_InitVars = { ACTOR_EN_HONOTRAP, @@ -79,7 +93,8 @@ static InitChainEntry D_809304E0[] = { }; #endif - +extern Gfx* D_809303F0[4]; +extern s32 D_80930400; extern ColliderTrisElementInit D_80930424[2]; extern ColliderTrisInit D_8093049C; extern ColliderCylinderInit D_809304AC; @@ -90,17 +105,136 @@ extern InitChainEntry D_809304E0[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E5A4.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E638.s") +// EnHonotrap_InitEye +void func_8092E638(EnHonotrap* this, GlobalContext* globalCtx) { + s32 i; + s32 j; + s32 k; + f32 sin; + f32 cos; + Vec3f sp70[3]; + Vec3f* vtx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E840.s") + sin = Math_SinS(this->actor.home.rot.y); + cos = Math_CosS(this->actor.home.rot.y); + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E988.s") + if (D_80930400 != 0) { + D_80930400 = 0; + for (k = 0; k < 4; k++) { + D_809303F0[k] = Lib_SegmentedToVirtual(D_809303F0[k]); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Init.s") + Collider_InitTris(globalCtx, &this->collider.tris); + Collider_SetTris(globalCtx, &this->collider.tris, &this->actor, &D_8093049C, this->collider.elements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Destroy.s") + for (i = 0; i < 2; i++) { + for (j = 0, vtx = sp70; j < 3; j++, vtx++) { + Vec3f* test = &D_8093049C.elements[i].dim.vtx[j]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EBC0.s") + vtx->x = (test->z * sin) + (test->x * cos); + vtx->y = test->y; + vtx->z = (test->z * cos) - (test->x * sin); + + Math_Vec3f_Sum(vtx, &this->actor.world.pos, vtx); + } + Collider_SetTrisVertices(&this->collider.tris, i, &sp70[0], &sp70[1], &sp70[2]); + } + Actor_SetFocus(&this->actor, 0.0f); + if (this->actor.params == 0) { + func_8092EBC0(this); + } else { + func_8092EE68(this); + } +} + +// EnHonotrap_InitFlame +void func_8092E840(EnHonotrap* this, GlobalContext* globalCtx) { + s32 pad[2]; + s32 params; + + params = this->actor.params; + Actor_SetScale(&this->actor, 0.0001f); + Collider_InitCylinder(globalCtx, &this->collider.cyl); + Collider_SetCylinder(globalCtx, &this->collider.cyl, &this->actor, &D_809304AC); + Collider_UpdateCylinder(&this->actor, &this->collider.cyl); + this->actor.terminalVelocity = -1.0f; + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &D_809304D8); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.shape.shadowAlpha = 0x80; + this->unk228 = GET_PLAYER(globalCtx)->actor.world.pos; + this->unk228.y += 10.0f; + this->unk23A = Rand_ZeroOne() * 511.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FLAME_IGNITION); + if (params == 2) { + this->actor.room = -1; + this->collider.cyl.dim.radius = 12; + this->collider.cyl.dim.height = 30; + this->actor.shape.yOffset = -1000.0f; + } + func_8092F0F8(this); +} + +void func_8092E988(EnHonotrap* this, GlobalContext* globalCtx) { + EnHonotrap23C* var_s2; + s32 var_s0; + s32 i; + + Actor_SetScale(&this->actor, 0.0001f); + Collider_InitCylinder(globalCtx, &this->collider.cyl); + Collider_SetCylinder(globalCtx, &this->collider.cyl, &this->actor, &D_809304AC); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &D_809304D8); + + var_s0 = Rand_ZeroOne() * 511.0f; + var_s2 = &this->unk23C; + for (i = 0; i < 6; i++) { + var_s2->unkC[i].unk_10 = var_s0; + var_s0 += (s32)Rand_ZeroFloat(300.0f) + 0x64; + var_s0 &= 0x1FF; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FLAME_IGNITION); + func_8092F854(this); +} + +void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 params; + EnHonotrap* this = (EnHonotrap*)thisx; + + params = this->actor.params; + Actor_ProcessInitChain(&this->actor, D_809304E0); + if ((params == 0) || (params == 3)) { + func_8092E638(this, globalCtx); + } else if (params == 4) { + func_8092E988(this, globalCtx); + this->actor.update = func_8092FEFC; + this->actor.draw = func_80930190; + this->actor.uncullZoneScale = 500.0f; + this->actor.uncullZoneDownward = 500.0f; + } else { + func_8092E840(this, globalCtx); + this->actor.update = func_8092FE44; + this->actor.draw = func_80930030; + } +} + +void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s16 params; + EnHonotrap* this = (EnHonotrap*)thisx; + + params = this->actor.params; + if ((params == 0) || (params == 3)) { + Collider_DestroyTris(globalCtx, &this->collider.tris); + } else { + Collider_DestroyCylinder(globalCtx, &this->collider.cyl); + } +} + +void func_8092EBC0(EnHonotrap* this) { + this->actionFunc = func_8092EBDC; + this->unk222 = 3; +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EBDC.s") @@ -116,7 +250,12 @@ extern InitChainEntry D_809304E0[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EE1C.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EE68.s") +void func_8092EE68(EnHonotrap* this) { + this->unk222 = 3; + this->unk220 = 0x50; + this->unk224 = 0; + this->actionFunc = func_8092EE90; +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EE90.s") @@ -152,18 +291,102 @@ extern InitChainEntry D_809304E0[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F7BC.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F854.s") +void func_8092F854(EnHonotrap* this) { + this->actionFunc = func_8092F878; + this->unk220 = 0x50; + this->unk23C.unk_08 = 0.0f; +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F878.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Update.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092FE44.s") +void func_8092FE44(Actor* thisx, GlobalContext* globalCtx) { + EnHonotrap* this = (EnHonotrap*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092FEFC.s") + if (this->unk220 > 0) { + this->unk220--; + } + this->unk2C0 = 0; // + 23C + 0x10 + 0x64 + 0x10 = s8 + this->unk238 += 0x640; + if (this->actor.params != 4) { + this->actor.shape.yOffset = Math_SinS(this->unk238) * 1000.0f + 600.0f; + } + Actor_SetFocus(&this->actor, 5.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + this->actionFunc(this, globalCtx); + this->unk23A -= 0x14; + this->unk23A &= 0x1FF; +} + +void func_8092FEFC(Actor* thisx, GlobalContext* globalCtx) { + EnHonotrap* this = (EnHonotrap*)thisx; + Actor* temp_v0; + + temp_v0 = this->actor.parent; + if ((temp_v0 != NULL) && (temp_v0->update == NULL)) { + this->actor.parent = NULL; + } + if (this->unk220 > 0) { + this->unk220--; + } + this->unk238 += 0x640; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); + this->actionFunc(this, globalCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Draw.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_80930030.s") +void func_80930030(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHonotrap* this = (EnHonotrap*)thisx; + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->unk23A, 32, 128)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + Matrix_RotateYS(Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 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++, gGameplayKeepDrawFlameDL); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +#ifdef NON_MATCHING +void func_80930190(Actor* thisx, GlobalContext* globalCtx) { + EnHonotrap* this = (EnHonotrap*)thisx; + Vec3s spB8; + EnHonotrapArr* temp_s0; + EnHonotrap23C* var_s3; + s32 i; // s4 + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + func_800DFC90(&spB8, globalCtx->cameraPtrs[globalCtx->activeCamera]); + spB8.y += 0x8000; + var_s3 = &this->unk23C; + for (i = 0; i < 6; i++) { + temp_s0 = &var_s3->unkC[i]; + if (temp_s0->unk12 != 0) { + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); + Matrix_SetTranslateRotateYXZ(temp_s0->unk0.x, temp_s0->unk0.y - (4000.0f * temp_s0->unkC), temp_s0->unk0.z, + &spB8); + // temp_fa1 = temp_s0->unkC; + Matrix_Scale(((fabsf(Math_SinS((s16)(spB8.y - this->actor.shape.rot.y) >> 1)) * 0.2f) + 1.7f) * + temp_s0->unkC, + temp_s0->unkC, 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++, gGameplayKeepDrawFlameDL); + } + } + CLOSE_DISPS(globalCtx->state.gfxCtx); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_80930190.s") +#endif diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index f9983e26a..2e3174648 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -7,10 +7,40 @@ struct EnHonotrap; typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, GlobalContext*); +typedef union { + struct { + ColliderTris tris; + ColliderTrisElement elements[2]; + }; + ColliderCylinder cyl; +} EnHonotrapCollider; // size = 0xD8 + +typedef struct { + /* 0x00 */ Vec3f unk0; + /* 0x0C */ f32 unkC; + /* 0x10 */ s16 unk_10; + /* 0x12 */ u8 unk12; +} EnHonotrapArr; //size 0x14 + +typedef struct { + char unk0[0x8]; + f32 unk_08; + EnHonotrapArr unkC[6]; +} EnHonotrap23C; + typedef struct EnHonotrap { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnHonotrapActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x17C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnHonotrapActionFunc actionFunc; + /* 0x148 */ EnHonotrapCollider collider; + /* 0x220 */ s16 unk220; + /* 0x222 */ s16 unk222; + /* 0x224 */ s16 unk224; + /* 0x228 */ Vec3f unk228; + /* 0x234 */ char pad234[4]; + /* 0x238 */ s16 unk238; + /* 0x23A */ s16 unk23A; + /* 0x23C */ EnHonotrap23C unk23C; + /* 0x2C0 */ s8 unk2C0; } EnHonotrap; // size = 0x2C4 extern const ActorInit En_Honotrap_InitVars; From dc950a93ea010835af504aec327560e9e1c57214 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 23 Jul 2022 00:52:17 +1000 Subject: [PATCH 081/130] fix bss --- src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 1 + 1 file changed, 1 insertion(+) 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 99d5c5a85..555f92798 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 @@ -4,6 +4,7 @@ * Description: Great Bay Temple - See-Saw */ +#include "prevent_bss_reordering.h" #include "z_bg_dblue_balance.h" #include "objects/object_dblue_object/object_dblue_object.h" From 58d545c4237c3d583772e326a6e4713ac875a53c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 24 Jul 2022 09:45:43 +1000 Subject: [PATCH 082/130] Fix bss --- src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c | 1 - 1 file changed, 1 deletion(-) 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 73c5e32c6..b699cd9af 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -4,7 +4,6 @@ * Description: Breakable Pot With Grass */ -#include "prevent_bss_reordering.h" #include "z_obj_flowerpot.h" #include "objects/object_flowerpot/object_flowerpot.h" From 75d5eae12f4017edf5e9880458f055daf0992f63 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 21 Aug 2022 20:50:59 -0700 Subject: [PATCH 083/130] Nonmatchings + cleanup --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 100 ++++++++---------- 1 file changed, 45 insertions(+), 55 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 1d4403c14..109a2b486 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -190,27 +190,27 @@ void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { } } +#define NON_MATCHING #ifdef NON_MATCHING // stack, 1 var needs to go without changing code gen void func_80A81544(ObjMine* this, Vec3f* arg1) { - ColliderJntSphElement* element = &this->collider.elements[0]; - Vec3s* sphere = &element->dim.worldSphere.center; - Actor* temp_v1 = this->collider.base.ac; + Actor* ac = this->collider.base.ac; + Vec3f sp20; - if ((element->info.acHitInfo->toucher.dmgFlags & 0x13820)) { + if ((this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820)) { Matrix_Push(); - Matrix_RotateYS(temp_v1->shape.rot.y, MTXMODE_NEW); - Matrix_RotateXS(temp_v1->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(ac->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(ac->shape.rot.x, MTXMODE_APPLY); Matrix_MultVecZ(1.0f, arg1); Matrix_Pop(); } else { - Vec3f sp20; + Sphere16* sphere = &this->collider.elements[0].dim.worldSphere; - sp20.x = sphere->x - temp_v1->world.pos.x; - sp20.y = sphere->y - temp_v1->world.pos.y; - sp20.z = sphere->z - temp_v1->world.pos.z; + sp20.x = sphere->center.x - ac->world.pos.x; + sp20.y = sphere->center.y - ac->world.pos.y; + sp20.z = sphere->center.z - ac->world.pos.z; if (!func_80A8120C(&sp20, arg1)) { - Math_Vec3f_Copy(arg1, D_80A845D0); + Math_Vec3f_Copy(arg1, &D_80A845D0[0]); } } } @@ -218,6 +218,7 @@ void func_80A81544(ObjMine* this, Vec3f* arg1) { void func_80A81544(ObjMine* this, Vec3f* arg1); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") #endif +#undef NON_MATCHING void func_80A81640(ObjMine* this) { } @@ -369,7 +370,7 @@ void func_80A81B7C(ObjMine* this, s32 arg1) { ptr->unk_00.x = 0.9f; ptr->unk_18.y = 0.003f; - *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; + *(s16*)((u8*)ptr + 0x20) = Rand_Next() >> 0x13; ptr->unk_24.x = -0.0002f; ptr->unk_30 = -0.0002f; @@ -637,69 +638,58 @@ void func_80A82F98(ObjMine* this, PlayState* play) { } void func_80A82FA8(ObjMine* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80A82FC8; } -#ifdef NON_MATCHING -// stack void func_80A82FC8(ObjMine* this, PlayState* play) { - f32 phi_f0; + Actor* thisx = &this->actor; Vec3f spA0; - f32 sp9C; - s32 pad; - f32 phi_f12; + f32 speed; + f32 step; + f32 target; s32 sp90; Vec3f sp84; Vec3f sp78; MtxF sp38; Math_Vec3s_ToVec3f(&spA0, &this->unk_1B4[this->unk_1B0 + 1]); - Math_Vec3f_Diff(&spA0, &this->actor.world.pos, &this->actor.velocity); - - sp9C = Math3D_Vec3fMagnitude(&this->actor.velocity); - if ((sp9C < (this->unk_1A8 * 8.0f)) && (this->unk_1A8 > 2.0f)) { - phi_f0 = ((this->unk_1A8 - 2.0f) * 0.1f) + 2.0f; - phi_f12 = this->unk_1A8 * 0.03f; + Math_Vec3f_Diff(&spA0, &thisx->world.pos, &thisx->velocity); + speed = Math3D_Vec3fMagnitude(&thisx->velocity); + if ((speed < (this->unk_1A8 * 8.0f)) && (this->unk_1A8 > 2.0f)) { + target = ((this->unk_1A8 - 2.0f) * 0.1f) + 2.0f; + step = this->unk_1A8 * 0.03f; } else { - phi_f0 = this->unk_1A8; - phi_f12 = this->unk_1A8 * 0.16f; + target = this->unk_1A8; + step = this->unk_1A8 * 0.16f; } - - Math_StepToF(&this->actor.speedXZ, phi_f0, phi_f12); - - if ((this->actor.speedXZ + 0.05f) < sp9C) { - Math_Vec3f_Scale(&this->actor.velocity, this->actor.speedXZ / sp9C); - this->actor.world.pos.x += this->actor.velocity.x; - this->actor.world.pos.y += this->actor.velocity.y; - this->actor.world.pos.z += this->actor.velocity.z; + Math_StepToF(&thisx->speedXZ, target, step); + if ((thisx->speedXZ + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); + thisx->world.pos.x += thisx->velocity.x; + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->velocity.z; } else { - this->actor.speedXZ *= 0.4f; + thisx->speedXZ *= 0.4f; this->unk_1B0++; if (this->unk_1B0 >= this->unk_1AC) { this->unk_1B0 = 0; } func_80A811D0(this, this->unk_1B0); } - - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp90, - &this->actor, &this->actor.world.pos); - - if (this->actor.flags & 0x40) { - Math3D_CrossProduct(&D_80A845D0[0], &this->actor.velocity, &sp78); + thisx->floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &sp90, thisx, &thisx->world.pos); + if (thisx->flags & 0x40) { + Math3D_CrossProduct(&D_80A845D0[0], &thisx->velocity, &sp78); if (func_80A8120C(&sp78, &sp84)) { - Matrix_RotateAxisF(this->actor.speedXZ * 0.03125f, &sp84, 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_RotateAxisF(thisx->speedXZ * 0.03125f, &sp84, MTXMODE_NEW); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); Matrix_Get(&sp38); - Matrix_MtxFToYXZRot(&sp38, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, false); } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A82FC8.s") -#endif void func_80A83214(ObjMine* this) { this->actor.flags |= 0x10; @@ -769,9 +759,9 @@ void func_80A832D0(ObjMine* this, PlayState* play) { Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); } - if ((u32)Rand_Next() >> 0x1B == 0) { + if ((Rand_Next() >> 0x1B) == 0) { unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; - unkStruct->unk_54 = (u32)Rand_Next() >> 0x10; + unkStruct->unk_54 = Rand_Next() >> 0x10; } sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; @@ -891,11 +881,11 @@ void func_80A83B28(ObjMine* this, PlayState* play) { ptr->unk_24.x = -0.0002f; ptr->unk_30 = -0.0002f; ptr->unk_18.y = 0.003f; - if (!((u32)Rand_Next() >> 0x1B)) { - rand = (u32)Rand_Next() >> 0x10; + if ((Rand_Next() >> 0x1B) == 0) { + rand = Rand_Next() >> 0x10; ptr->unk_0C.z = Math_SinS(rand) * 1.8f * ptr->unk_18.y; ptr->unk_18.x = Math_CosS(rand) * 0.2f * ptr->unk_18.y; - *(s16*)((u8*)ptr + 0x20) = (u32)Rand_Next() >> 0x13; + *(s16*)((u8*)ptr + 0x20) = Rand_Next() >> 0x13; } func_80A82C28(this, play); From 6c35387e82114e3cdb30ec1b213aa13edd86a661 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 15 Sep 2022 16:29:24 -0700 Subject: [PATCH 084/130] Small cleanup --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 109a2b486..40bc5c57c 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -6,6 +6,7 @@ #include "z_obj_mine.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "assets/objects/object_ny/object_ny.h" #define FLAGS 0x00000000 @@ -34,9 +35,9 @@ void func_80A83FBC(Actor* thisx, PlayState* play); void func_80A84088(Actor* thisx, PlayState* play); void func_80A84338(Actor* thisx, PlayState* play); -extern Gfx D_06000030[]; -extern Gfx D_06002068[]; -extern Gfx D_06002188[]; +extern Gfx object_ny_DL_000030[]; +extern Gfx object_ny_DL_002068[]; +extern Gfx object_ny_DL_002188[]; static s32 D_80A849D0[0xC0]; @@ -190,9 +191,6 @@ void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { } } -#define NON_MATCHING -#ifdef NON_MATCHING -// stack, 1 var needs to go without changing code gen void func_80A81544(ObjMine* this, Vec3f* arg1) { Actor* ac = this->collider.base.ac; Vec3f sp20; @@ -214,11 +212,6 @@ void func_80A81544(ObjMine* this, Vec3f* arg1) { } } } -#else -void func_80A81544(ObjMine* this, Vec3f* arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81544.s") -#endif -#undef NON_MATCHING void func_80A81640(ObjMine* this) { } @@ -954,8 +947,8 @@ void ObjMine_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - gSPDisplayList(POLY_OPA_DISP++, D_06002068); - gSPDisplayList(POLY_OPA_DISP++, D_06002188); + gSPDisplayList(POLY_OPA_DISP++, object_ny_DL_002068); + gSPDisplayList(POLY_OPA_DISP++, object_ny_DL_002188); CLOSE_DISPS(play->state.gfxCtx); } @@ -971,7 +964,7 @@ void func_80A83FBC(Actor* thisx, PlayState* play) { gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 75); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_06002068); + gSPDisplayList(POLY_XLU_DISP++, object_ny_DL_002068); CLOSE_DISPS(play->state.gfxCtx); } @@ -994,7 +987,7 @@ void func_80A84088(Actor* thisx, PlayState* play) { gSPDisplayList(gfx++, &sSetupDL[6 * 25]); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, D_06000030); + gSPDisplayList(gfx++, object_ny_DL_000030); func_80A81684(ptr); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -1013,7 +1006,7 @@ void func_80A84088(Actor* thisx, PlayState* play) { func_80A8164C(&sp94); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, D_06000030); + gSPDisplayList(gfx++, object_ny_DL_000030); } } @@ -1024,8 +1017,8 @@ void func_80A84088(Actor* thisx, PlayState* play) { gDPPipeSync(gfx++); gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(gfx++, 0, 0, 0, 255); - gSPDisplayList(gfx++, D_06002068); - gSPDisplayList(gfx++, D_06002188); + gSPDisplayList(gfx++, object_ny_DL_002068); + gSPDisplayList(gfx++, object_ny_DL_002188); POLY_OPA_DISP = gfx; @@ -1047,7 +1040,7 @@ void func_80A84338(Actor* thisx, PlayState* play) { gSPDisplayList(gfx++, &sSetupDL[6 * 25]); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, D_06000030); + gSPDisplayList(gfx++, object_ny_DL_000030); for (i = 0, temp = (ObjMineUnkStruct2*)((u8*)this + 0x1FC); i < temp_s7; i++, temp++) { func_80A81684((ObjMineUnkStruct*)temp); @@ -1058,7 +1051,7 @@ void func_80A84338(Actor* thisx, PlayState* play) { func_80A8164C(&temp->unk_24); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, D_06000030); + gSPDisplayList(gfx++, object_ny_DL_000030); } Matrix_RotateXS(0x2000, 1); @@ -1068,8 +1061,8 @@ void func_80A84338(Actor* thisx, PlayState* play) { gDPPipeSync(gfx++); gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(gfx++, 0, 0, 0, 255); - gSPDisplayList(gfx++, D_06002068); - gSPDisplayList(gfx++, D_06002188); + gSPDisplayList(gfx++, object_ny_DL_002068); + gSPDisplayList(gfx++, object_ny_DL_002188); POLY_OPA_DISP = gfx; From a141c9bc8e8b5009551931c3158d731e2422258e Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 15 Sep 2022 16:33:30 -0700 Subject: [PATCH 085/130] externs --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 40bc5c57c..3959be087 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -35,10 +35,6 @@ void func_80A83FBC(Actor* thisx, PlayState* play); void func_80A84088(Actor* thisx, PlayState* play); void func_80A84338(Actor* thisx, PlayState* play); -extern Gfx object_ny_DL_000030[]; -extern Gfx object_ny_DL_002068[]; -extern Gfx object_ny_DL_002188[]; - static s32 D_80A849D0[0xC0]; const ActorInit Obj_Mine_InitVars = { From 1b82352a6b4d99ddb2c8ac37b0ec37353a41af1c Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 29 Sep 2022 04:48:27 -0500 Subject: [PATCH 086/130] structs complete --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 523 ++++++++++-------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 53 +- 2 files changed, 330 insertions(+), 246 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 3959be087..41634e383 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -35,7 +35,7 @@ void func_80A83FBC(Actor* thisx, PlayState* play); void func_80A84088(Actor* thisx, PlayState* play); void func_80A84338(Actor* thisx, PlayState* play); -static s32 D_80A849D0[0xC0]; +static Vec3f D_80A849D0[0x40]; const ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, @@ -220,22 +220,22 @@ void func_80A8164C(Vec3f* arg0) { matrix->mf[3][2] = arg0->z; } -void func_80A81684(ObjMineUnkStruct* arg0) { +void func_80A81684(ObjMineMtxF3* arg0) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[0][0] = arg0->unk_00.x; - matrix->mf[0][1] = arg0->unk_00.y; - matrix->mf[0][2] = arg0->unk_00.z; + matrix->mf[0][0] = arg0->x.x; + matrix->mf[0][1] = arg0->x.y; + matrix->mf[0][2] = arg0->x.z; matrix->mf[0][3] = 0.0f; - matrix->mf[1][0] = arg0->unk_0C.x; - matrix->mf[1][1] = arg0->unk_0C.y; - matrix->mf[1][2] = arg0->unk_0C.z; + matrix->mf[1][0] = arg0->y.x; + matrix->mf[1][1] = arg0->y.y; + matrix->mf[1][2] = arg0->y.z; matrix->mf[1][3] = 0.0f; - matrix->mf[2][0] = arg0->unk_18.x; - matrix->mf[2][1] = arg0->unk_18.y; - matrix->mf[2][2] = arg0->unk_18.z; + matrix->mf[2][0] = arg0->z.x; + matrix->mf[2][1] = arg0->z.y; + matrix->mf[2][2] = arg0->z.z; matrix->mf[2][3] = 0.0f; matrix->mf[3][0] = 0.0f; @@ -278,24 +278,24 @@ void func_80A81818(ObjMine* this) { void func_80A81868(ObjMine* this, s32 arg1) { s32 i; - ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct* ptr = &this->chain1; ObjMineUnkStruct3* unkStruct; f32 arg = arg1; f32 temp_f12 = this->actor.home.rot.z * 5.0f; - ptr->unk_00.x = 1.0f; - ptr->unk_0C.y = 1.0f; - ptr->unk_18.z = 1.0f; + ptr->unk_00.x.x = 1.0f; + ptr->unk_00.y.y = 1.0f; + ptr->unk_00.z.z = 1.0f; ptr->unk_24.y = 1.0f; if (arg1 > 0) { - ptr->unk_40 = -sqrtf(0.001984f / arg); - ptr->unk_44 = (0.00031746097f * arg) + 0.95f; + ptr->unk_40 = -sqrtf(0.001984f / arg); // approx 1/504 = 1/8 * 1/63 + ptr->unk_44 = (0.00031746097f * arg) + 0.95f; // approx 1/3150 = 1/50 * 1/63 } ptr->unk_58 = 0.0002f; - for (i = 0, unkStruct = &ptr->unk_60[0]; i < arg1; i++, unkStruct++) { + for (i = 0, unkStruct = ptr->unk_60; i < arg1; i++, unkStruct++) { unkStruct->unk_00 = 0x4000; } @@ -315,27 +315,27 @@ void func_80A819A4(ObjMine* this, s32 arg1) { } void func_80A81A00(ObjMine* this) { - ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct* ptr = &this->chain1; Vec3f sp28; sp28.x = -ptr->unk_30; sp28.y = 1.0f; sp28.z = -ptr->unk_34; - func_80A8120C(&sp28, &ptr->unk_0C); - Math3D_CrossProduct(&D_80A845C4, &ptr->unk_0C, &sp28); - func_80A8120C(&sp28, &ptr->unk_18); - Math3D_CrossProduct(&ptr->unk_0C, &ptr->unk_18, &sp28); - func_80A8120C(&sp28, &ptr->unk_00); + func_80A8120C(&sp28, &ptr->unk_00.y); + Math3D_CrossProduct(&D_80A845C4, &ptr->unk_00.y, &sp28); + func_80A8120C(&sp28, &ptr->unk_00.z); + Math3D_CrossProduct(&ptr->unk_00.y, &ptr->unk_00.z, &sp28); + func_80A8120C(&sp28, &ptr->unk_00.x); } void func_80A81AA4(ObjMine* this) { s32 params = this->actor.params & 0x3F; f32 temp_f0 = -((params * 12.0f) + 10.0f); - this->actor.world.pos.x = (this->unk_1B8.unk_0C.x * temp_f0) + this->actor.home.pos.x; - this->actor.world.pos.y = (this->unk_1B8.unk_0C.y * temp_f0) + this->actor.home.pos.y; - this->actor.world.pos.z = (this->unk_1B8.unk_0C.z * temp_f0) + this->actor.home.pos.z; + this->actor.world.pos.x = (this->chain1.unk_00.y.x * temp_f0) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->chain1.unk_00.y.y * temp_f0) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->chain1.unk_00.y.z * temp_f0) + this->actor.home.pos.z; } void func_80A81B14(ObjMine* this) { @@ -344,34 +344,34 @@ void func_80A81B14(ObjMine* this) { f32 x = this->actor.world.pos.x - this->actor.home.pos.x; f32 z = this->actor.world.pos.z - this->actor.home.pos.z; - this->unk_1B8.unk_30 = x * temp_f0; - this->unk_1B8.unk_34 = z * temp_f0; + this->chain1.unk_30 = x * temp_f0; + this->chain1.unk_34 = z * temp_f0; } void func_80A81B7C(ObjMine* this, s32 arg1) { - ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineTestStruct2* ptr = &this->chain2; ObjMineUnkStruct2* unkStruct; s32 i; f32 sp58 = this->actor.home.rot.z * 5.0f; f32 temp_f24; f32 temp_f26; - ptr->unk_00.x = 0.9f; - ptr->unk_18.y = 0.003f; + ptr->unk_00 = 0.9f; + ptr->unk_1C = 0.003f; - *(s16*)((u8*)ptr + 0x20) = Rand_Next() >> 0x13; - ptr->unk_24.x = -0.0002f; + ptr->unk_20 = Rand_Next() >> 0x13; + ptr->unk_24 = -0.0002f; ptr->unk_30 = -0.0002f; - temp_f26 = ptr->unk_18.y * 6.0f; + temp_f26 = ptr->unk_1C * 6.0f; temp_f24 = this->actor.home.pos.y; - unkStruct = (ObjMineUnkStruct2*)&ptr->unk_44; + unkStruct = ptr->unk_44; for (i = 0; i < arg1; i++, unkStruct++) { temp_f24 += 12.0f; - unkStruct->unk_00.x = 1.0f; - unkStruct->unk_0C.y = 1.0f; - unkStruct->unk_18.z = 1.0f; + unkStruct->unk_00.x.x = 1.0f; + unkStruct->unk_00.y.y = 1.0f; + unkStruct->unk_00.z.z = 1.0f; unkStruct->unk_24.x = this->actor.home.pos.x; unkStruct->unk_24.y = temp_f24; unkStruct->unk_24.z = this->actor.home.pos.z; @@ -380,12 +380,12 @@ void func_80A81B7C(ObjMine* this, s32 arg1) { unkStruct->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; } - ptr->unk_24.y = temp_f24; - ptr->unk_24.z = temp_f24 * 0.97f; - temp_f24 = temp_f24 - 18.0f; + ptr->unk_28 = temp_f24; + ptr->unk_2C = temp_f24 * 0.97f; + temp_f24 -= 18.0f; - if (ptr->unk_24.z < temp_f24) { - ptr->unk_24.z = temp_f24; + if (ptr->unk_2C < temp_f24) { + ptr->unk_2C = temp_f24; } if (sp58 < 0.0f) { @@ -405,22 +405,24 @@ void func_80A81D70(ObjMine* this, s32 arg1) { } void func_80A81DEC(ObjMine* this) { - s32 pad[2]; + ObjMineTestStruct2* ptr = &this->chain2; + s32 pad; s32 temp_v0 = this->actor.params & 0x3F; - NextUnkStruct* temp_v1 = &((NextUnkStruct*)&this->unk_1B8)[temp_v0]; + if (temp_v0 == 0) { this->actor.world.pos.y = (this->actor.home.pos.y + 12.0f) + 10.0f; } else { + ObjMineUnkStruct2* ptr2 = &ptr->unk_44[temp_v0 - 1]; Vec3f sp1C; - Math_Vec3f_ScaleAndStore(&temp_v1->unk_08, 10.0f, &sp1C); - Math_Vec3f_Sum(&temp_v1->unk_20, &sp1C, &this->actor.world.pos); + Math_Vec3f_ScaleAndStore(&ptr2->unk_00.y, 10.0f, &sp1C); + Math_Vec3f_Sum(&ptr2->unk_24, &sp1C, &this->actor.world.pos); } } void func_80A81E7C(ObjMine* this, PlayState* play) { - ObjMineUnkStruct* temp_v1 = &this->unk_1B8; + ObjMineTestStruct2* temp_v1 = &this->chain2; s32 pad; Vec3f sp7C; Vec3f sp70; @@ -432,47 +434,122 @@ void func_80A81E7C(ObjMine* this, PlayState* play) { f32 sp40; f32 sp3C; - *(s8*)(&temp_v1->unk_40) = 0; - if (temp_v1->unk_34 > -0.000001f) { - if (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, - this->actor.world.pos.x, this->actor.world.pos.z)) { - sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; - sp58.y = 0.0f; - sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { - sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); - sp70.y = this->actor.world.pos.y; - sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); - sp7C.x = this->actor.home.pos.x; - sp7C.y = this->actor.world.pos.y; - sp7C.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { - *(s8*)(&temp_v1->unk_40) = 1; - temp_v1->unk_38 = sp4C.x * -0.2f; - temp_v1->unk_3C = sp4C.z * -0.2f; - } + temp_v1->unk_40 = 0; + if ((-0.000001f < temp_v1->unk_34) && (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + this->actor.world.pos.x, this->actor.world.pos.z))) { + sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; + sp58.y = 0.0f; + sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; + if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { + sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); + sp70.y = this->actor.world.pos.y; + sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); + sp7C.x = this->actor.home.pos.x; + sp7C.y = this->actor.world.pos.y; + sp7C.z = this->actor.home.pos.z; + if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { + temp_v1->unk_40 = 1; + temp_v1->unk_38 = sp4C.x * -0.2f; + temp_v1->unk_3C = sp4C.z * -0.2f; } } } } +#ifdef NON_MATCHING +void func_80A81FFC(ObjMine *this) { + s32 i; + ObjMineTestStruct2 *temp_s1 = &this->chain2; + ObjMineUnkStruct2 *var_s0; + s32 temp_s6 = this->actor.params & 0x3F; + s16 var_s3 = 0; + f32 temp_fs2 = 1.0f / (f32) temp_s6; + Vec3f sp90; + f32 temp_fs0 = (temp_s1->unk_44[temp_s6 - 1].unk_24.y - temp_s1->unk_2C) * temp_s1->unk_30; + f32 temp_ft4; + + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + Math_Vec3f_Copy(&D_80A849D0[i], &var_s0->unk_3C); + if (var_s0->unk_24.y <= this->actor.home.pos.y) { + var_s0->unk_3C.y = temp_s1->unk_30 * -96.0f; + } else if (temp_fs0 > 0.0f) { + var_s0->unk_3C.y = (i + 1) * temp_fs2 * (temp_fs0 / 0.3f); + } else { + var_s0->unk_3C.y = temp_fs0; + } + var_s0->unk_3C.x = (var_s0->unk_24.x - this->actor.home.pos.x) * temp_s1->unk_24; + var_s0->unk_3C.z = (var_s0->unk_24.z - this->actor.home.pos.z) * temp_s1->unk_24; + var_s0->unk_3C.x += temp_s1->unk_14 * Math_SinS(var_s3); + var_s0->unk_3C.y += temp_s1->unk_18; + var_s0->unk_3C.z += temp_s1->unk_14 * Math_CosS(var_s3); + var_s3 += temp_s1->unk_20; + } + if (temp_s1->unk_10 > 0.0001f) { + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + temp_ft4 = SQ((temp_s6 - i) * temp_fs2); + var_s0->unk_3C.x += temp_s1->unk_04.x * temp_ft4; + var_s0->unk_3C.y += temp_s1->unk_04.y * temp_ft4; + var_s0->unk_3C.z += temp_s1->unk_04.z * temp_ft4; + } + } + if (temp_s1->unk_40) { + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + var_s0->unk_3C.x += temp_s1->unk_38; + var_s0->unk_3C.z += temp_s1->unk_3C; + } + } + + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + Math_Vec3f_Copy(&sp90, &gZeroVec3f); + if(i - 2 >= 0) { + sp90.x += D_80A849D0[i - 2].x * 0.075f; + sp90.y += D_80A849D0[i - 2].y * 0.075f; + sp90.z += D_80A849D0[i - 2].z * 0.075f; + } + if(i - 1 >= 0) { + sp90.x += D_80A849D0[i - 1].x * 0.15f; + sp90.y += D_80A849D0[i - 1].y * 0.15f; + sp90.z += D_80A849D0[i - 1].z * 0.15f; + } + sp90.x += D_80A849D0[i].x * 0.3f; + sp90.y += D_80A849D0[i].y * 0.3f; + sp90.z += D_80A849D0[i].z * 0.3f; + if(i + 1 < temp_s6) { + sp90.x += D_80A849D0[i + 1].x * 0.15f; + sp90.y += D_80A849D0[i + 1].y * 0.15f; + sp90.z += D_80A849D0[i + 1].z * 0.15f; + } + if(i + 2 < temp_s6) { + sp90.x += D_80A849D0[i + 2].x * 0.075f; + sp90.y += D_80A849D0[i + 2].y * 0.075f; + sp90.z += D_80A849D0[i + 2].z * 0.075f; + } + var_s0->unk_3C.x += sp90.x; + var_s0->unk_3C.y += sp90.y; + var_s0->unk_3C.z += sp90.z; + } + +} +#else +void func_80A81FFC(ObjMine* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") +#endif void func_80A828A8(ObjMine* this) { - s32 pad; + s32 i; Vec3f spE0; Vec3f spD4; Vec3f spC8; s32 spC4 = this->actor.params & 0x3F; - s32 i = 0; + ObjMineTestStruct2* sp70 = &this->chain2; + ObjMineUnkStruct2* temp_s0; + Vec3f* phi_s3; s32 phi_s5; - Vec3f* phi_s3 = NULL; - ObjMineUnkStruct* sp70 = &this->unk_1B8; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Vec3f sp84; - ObjMineUnkStruct2* temp_s0 = (ObjMineUnkStruct2*)&sp70->unk_44; + s32 pad; f32 sp7C; f32 sp78; @@ -480,12 +557,12 @@ void func_80A828A8(ObjMine* this) { sp84.y = this->actor.home.pos.y + 6.0f; sp84.z = this->actor.home.pos.z; - for (; i < spC4; i++, temp_s0++) { + for (i = 0, phi_s3 = NULL, temp_s0 = sp70->unk_44; i < spC4; i++, phi_s3 = &temp_s0->unk_00.x, temp_s0++) { phi_s5 = false; temp_s0->unk_30.x += temp_s0->unk_3C.x; temp_s0->unk_30.y += temp_s0->unk_3C.y; temp_s0->unk_30.z += temp_s0->unk_3C.z; - Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00.x); + Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00); Math_Vec3f_Copy(&sp90, &temp_s0->unk_24); temp_s0->unk_24.x += temp_s0->unk_30.x; temp_s0->unk_24.y += temp_s0->unk_30.y; @@ -498,7 +575,7 @@ void func_80A828A8(ObjMine* this) { Math_Vec3f_Diff(&temp_s0->unk_24, &sp84, &spA8); if (func_80A81288(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { - Math_Vec3f_Copy(&spD4, &temp_s0->unk_0C); + Math_Vec3f_Copy(&spD4, &temp_s0->unk_00.y); func_80A81714(&spD4, &sp9C, 0.10471976f); Math3D_CrossProduct((phi_s3 == NULL) ? &D_80A845C4 : phi_s3, &spD4, &spA8); @@ -512,33 +589,29 @@ void func_80A828A8(ObjMine* this) { } if (phi_s5) { - Math_Vec3f_Copy(&temp_s0->unk_00, &spC8); - Math_Vec3f_Copy(&temp_s0->unk_0C, &spD4); - Math_Vec3f_Copy(&temp_s0->unk_18, &spE0); + Math_Vec3f_Copy(&temp_s0->unk_00.x, &spC8); + Math_Vec3f_Copy(&temp_s0->unk_00.y, &spD4); + Math_Vec3f_Copy(&temp_s0->unk_00.z, &spE0); } else { sp7C = 4.0f; } if (sp7C >= 6.0f) { - temp_s0->unk_24.x = (temp_s0->unk_0C.x * 6.0f) + sp84.x; - temp_s0->unk_24.y = (temp_s0->unk_0C.y * 6.0f) + sp84.y; - temp_s0->unk_24.z = (temp_s0->unk_0C.z * 6.0f) + sp84.z; + temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * 6.0f); + temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * 6.0f); + temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * 6.0f); } else { - temp_s0->unk_24.x = (temp_s0->unk_0C.x * sp7C) + sp84.x; - temp_s0->unk_24.y = (temp_s0->unk_0C.y * sp7C) + sp84.y; - temp_s0->unk_24.z = (temp_s0->unk_0C.z * sp7C) + sp84.z; + temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * sp7C); + temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * sp7C); + temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * sp7C); } - sp84.x = temp_s0->unk_24.x + (temp_s0->unk_0C.x * 6.0f); - sp84.y = temp_s0->unk_24.y + (temp_s0->unk_0C.y * 6.0f); - sp84.z = temp_s0->unk_24.z + (temp_s0->unk_0C.z * 6.0f); - - phi_s3 = &temp_s0->unk_00; + sp84.x = temp_s0->unk_24.x + (temp_s0->unk_00.y.x * 6.0f); + sp84.y = temp_s0->unk_24.y + (temp_s0->unk_00.y.y * 6.0f); + sp84.z = temp_s0->unk_24.z + (temp_s0->unk_00.y.z * 6.0f); } } -void func_80A81FFC(ObjMine* this); - void func_80A82C28(ObjMine* this, PlayState* play) { func_80A81E7C(this, play); func_80A81FFC(this); @@ -707,121 +780,118 @@ void func_80A832BC(ObjMine* this) { void func_80A832D0(ObjMine* this, PlayState* play) { s32 pad; s32 spA0 = this->actor.params & 0x3F; - ObjMineUnkStruct* unkStruct = &this->unk_1B8; + ObjMineUnkStruct* unkStruct = &this->chain1; + ObjMineUnkStruct3* temp; + s32 i; + f32 sp90; + f32 sp8C; + f32 sp88; + s16 sp86; + s16 sp84; + s32 pad2; + s32 pad3; - Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_0C); + Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_00.y); if (func_80A8140C(this)) { func_80A81384(this, play); func_80A81640(this); func_80A83214(this); - } else { - ObjMineUnkStruct3* temp; - s32 i; - f32 sp90; - f32 sp8C; - f32 sp88; - s16 sp86; - s16 sp84; - s32 pad2; - s32 pad3; + return; + } - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - unkStruct->unk_48 = 0.04f; - func_80A8146C(this, &unkStruct->unk_4C, &sp84); - sp8C = Math_SinS(sp84) * 150.0f; - sp88 = sp8C; - sp8C = -(sp8C / spA0); + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + unkStruct->unk_48 = 0.04f; + func_80A8146C(this, &unkStruct->unk_4C, &sp84); + sp88 = sp8C = Math_SinS(sp84) * 150.0f; + sp8C = -(sp8C / spA0); - for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { - temp->unk_02 += (s16)sp88; - temp->unk_02 = CLAMP(temp->unk_02, -800, 800); - sp88 -= sp8C; - } + for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { + temp->unk_02 += (s16)sp88; + temp->unk_02 = CLAMP(temp->unk_02, -800, 800); + sp88 -= sp8C; } + } - if (unkStruct->unk_48 > 0.0001f) { - sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; - sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; - unkStruct->unk_38 += sp90; - unkStruct->unk_3C += sp8C; - Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); - } - - if ((Rand_Next() >> 0x1B) == 0) { - unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; - unkStruct->unk_54 = Rand_Next() >> 0x10; - } - - sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; - sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; + if (unkStruct->unk_48 > 0.0001f) { + sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; + sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; unkStruct->unk_38 += sp90; unkStruct->unk_3C += sp8C; - - unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; - unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; - - unkStruct->unk_38 *= unkStruct->unk_44; - unkStruct->unk_3C *= unkStruct->unk_44; - - unkStruct->unk_30 += unkStruct->unk_38; - unkStruct->unk_34 += unkStruct->unk_3C; - - unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); - unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); - - func_80A81A00(this); - func_80A81AA4(this); - - if ((unkStruct->unk_5C > -0.000001f) && - (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, - this->actor.home.pos.x, this->actor.home.pos.z))) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); - - if (this->actor.bgCheckFlags & 8) { - if (this->actor.wallPoly != NULL) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - f32 sp48; - f32 sp44; - - sp4C.x = unkStruct->unk_38; - sp4C.y = 0.0f; - sp4C.z = unkStruct->unk_3C; - if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { - sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); - sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); - sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - func_80179F64(&sp70, &sp58, &sp64); - sp48 *= 0.5f; - unkStruct->unk_38 = sp64.x * sp48; - unkStruct->unk_3C = sp64.z * sp48; - } else { - unkStruct->unk_38 *= -0.1f; - unkStruct->unk_3C *= -0.1f; - } - func_80A81B14(this); - func_80A81A00(this); - func_80A81AA4(this); - } - } - } - - for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { - sp86 = temp->unk_00 - 0x4000; - sp88 = ((Rand_ZeroOne() * 30.0f) - 15.0f) + (temp->unk_02 + (sp86 * -0.05f)); - sp88 *= 0.995f; - temp->unk_02 = sp88; - temp->unk_00 += temp->unk_02; - } - - func_800B4AEC(play, &this->actor, 0.0f); - func_80A81818(this); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); } + + if ((Rand_Next() >> 0x1B) == 0) { + unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; + unkStruct->unk_54 = Rand_Next() >> 0x10; + } + + sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; + sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; + unkStruct->unk_38 += sp90; + unkStruct->unk_3C += sp8C; + + unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; + unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; + + unkStruct->unk_38 *= unkStruct->unk_44; + unkStruct->unk_3C *= unkStruct->unk_44; + + unkStruct->unk_30 += unkStruct->unk_38; + unkStruct->unk_34 += unkStruct->unk_3C; + + unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); + unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); + + func_80A81A00(this); + func_80A81AA4(this); + + if ((unkStruct->unk_5C > -0.000001f) && + (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z))) { + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + + if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + sp4C.x = unkStruct->unk_38; + sp4C.y = 0.0f; + sp4C.z = unkStruct->unk_3C; + if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { + sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + func_80179F64(&sp70, &sp58, &sp64); + sp48 *= 0.5f; + unkStruct->unk_38 = sp64.x * sp48; + unkStruct->unk_3C = sp64.z * sp48; + } else { + unkStruct->unk_38 *= -0.1f; + unkStruct->unk_3C *= -0.1f; + } + func_80A81B14(this); + func_80A81A00(this); + func_80A81AA4(this); + } + } + + for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { + sp86 = temp->unk_00 - 0x4000; + sp88 = temp->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); + sp88 *= 0.995f; + temp->unk_02 = sp88; + temp->unk_00 += temp->unk_02; + } + + func_800B4AEC(play, &this->actor, 0.0f); + func_80A81818(this); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } void func_80A83A74(ObjMine* this) { @@ -833,10 +903,11 @@ void func_80A83A88(ObjMine* this, PlayState* play) { func_80A81384(this, play); func_80A81640(this); func_80A83214(this); - } else { - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + return; } + + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } void func_80A83B14(ObjMine* this) { @@ -844,8 +915,7 @@ void func_80A83B14(ObjMine* this) { } void func_80A83B28(ObjMine* this, PlayState* play) { - ObjMineUnkStruct* ptr; - s16 rand; + ObjMineTestStruct2* ptr = &this->chain2; if (func_80A8140C(this)) { func_80A81384(this, play); @@ -854,27 +924,27 @@ void func_80A83B28(ObjMine* this, PlayState* play) { return; } - ptr = &this->unk_1B8; if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_80A81544(this, (Vec3f*)&ptr->unk_00.y); - ptr->unk_0C.y = 7.0f; - Math_Vec3f_Scale((Vec3f*)&ptr->unk_00.y, 7.0f); + func_80A81544(this, &ptr->unk_04); + ptr->unk_10 = 7.0f; + Math_Vec3f_Scale(&ptr->unk_04, 7.0f); } - if (ptr->unk_0C.y > 0.0001f) { - ptr->unk_0C.y = Math_Vec3f_StepTo((Vec3f*)&ptr->unk_00.y, &gZeroVec3f, 2.8f); + if (ptr->unk_10 > 0.0001f) { + ptr->unk_10 = Math_Vec3f_StepTo( &ptr->unk_04, &gZeroVec3f, 2.8f); } - ptr->unk_00.x = 0.9f; - ptr->unk_24.x = -0.0002f; + ptr->unk_00 = 0.9f; + ptr->unk_24 = -0.0002f; ptr->unk_30 = -0.0002f; - ptr->unk_18.y = 0.003f; + ptr->unk_1C = 0.003f; if ((Rand_Next() >> 0x1B) == 0) { - rand = Rand_Next() >> 0x10; - ptr->unk_0C.z = Math_SinS(rand) * 1.8f * ptr->unk_18.y; - ptr->unk_18.x = Math_CosS(rand) * 0.2f * ptr->unk_18.y; - *(s16*)((u8*)ptr + 0x20) = Rand_Next() >> 0x13; + s16 rand = Rand_Next() >> 0x10; + + ptr->unk_14 = Math_SinS(rand) * 1.8f * ptr->unk_1C; + ptr->unk_18 = Math_CosS(rand) * 0.2f * ptr->unk_1C; + ptr->unk_20 = Rand_Next() >> 0x13; } func_80A82C28(this, play); @@ -893,10 +963,12 @@ void func_80A83D00(ObjMine* this, PlayState* play) { func_80A81384(this, play); func_80A81640(this); func_80A83214(this); - } else { - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + return; } + + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } void ObjMine_Update(Actor* thisx, PlayState* play) { @@ -966,11 +1038,11 @@ void func_80A83FBC(Actor* thisx, PlayState* play) { } void func_80A84088(Actor* thisx, PlayState* play) { + s32 pad; ObjMine* this = THIS; s32 temp_s5 = this->actor.params & 0x3F; ObjMineUnkStruct3* temp; - ObjMineUnkStruct* ptr = &this->unk_1B8; - s32 pad; + ObjMineUnkStruct* ptr = &this->chain1; s32 i; Vec3f sp94; Vec3f sp88; @@ -985,16 +1057,16 @@ void func_80A84088(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - func_80A81684(ptr); + func_80A81684(&ptr->unk_00); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (temp_s5 != 0) { - Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -6.0f, &sp88); + Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -6.0f, &sp88); sp94.x = this->actor.home.pos.x - sp88.x; sp94.y = (this->actor.home.pos.y - 6.0f) - sp88.y; sp94.z = this->actor.home.pos.z - sp88.z; - Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -12.0f, &sp88); + Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -12.0f, &sp88); - for (i = 0, temp = &ptr->unk_60[0]; i < temp_s5; i++, temp++) { + for (i = 0, temp = ptr->unk_60; i < temp_s5; i++, temp++) { Matrix_RotateYS(temp->unk_00, MTXMODE_APPLY); sp94.x += sp88.x; sp94.y += sp88.y; @@ -1022,12 +1094,13 @@ void func_80A84088(Actor* thisx, PlayState* play) { } void func_80A84338(Actor* thisx, PlayState* play) { + s32 pad1; ObjMine* this = THIS; s32 temp_s7 = this->actor.params & 0x3F; + ObjMineTestStruct2* pad2 = &this->chain2; s32 i; Gfx* gfx; ObjMineUnkStruct2* temp; - s32 pad[2]; func_800B8050(&this->actor, play, 1); @@ -1038,8 +1111,8 @@ void func_80A84338(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - for (i = 0, temp = (ObjMineUnkStruct2*)((u8*)this + 0x1FC); i < temp_s7; i++, temp++) { - func_80A81684((ObjMineUnkStruct*)temp); + for (i = 0, temp = pad2->unk_44; i < temp_s7; i++, temp++) { + func_80A81684(&temp->unk_00); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); if ((i & 1) == 0) { Matrix_RotateYS(0x4000, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index be5f1bb58..ac4fb0182 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,26 +7,22 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); -// definitely fake typedef struct { - char unk_00[0x8]; - Vec3f unk_08; - char unk_14[0xC]; - Vec3f unk_20; - char unk_2C[0x1C]; -} NextUnkStruct; // size = 0x48 + Vec3f x; + Vec3f y; + Vec3f z; + // Vec3f w; +} ObjMineMtxF3; -// maybe fake typedef struct { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; } ObjMineUnkStruct3; typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ Vec3f unk_0C; - /* 0x18 */ Vec3f unk_18; - ///* 0x24 */ char unk_24[0x3C]; + /* 0x00 */ ObjMineMtxF3 unk_00; + // /* 0x0C */ Vec3f unk_0C; + // /* 0x18 */ Vec3f unk_18; /* 0x24 */ Vec3f unk_24; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; @@ -45,18 +41,33 @@ typedef struct { // probably fake typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0c */ Vec3f unk_0C; - ///* 0x10 */ f32 unk_10; - ///* 0x14 */ char unk_14[0x4]; - /* 0x18 */ Vec3f unk_18; - ///* 0x1C */ char unk_1C[0x4]; - ///* 0x20 */ f32 unk_20; + /* 0x00 */ ObjMineMtxF3 unk_00; + // /* 0x0c */ Vec3f unk_0C; + // /* 0x18 */ Vec3f unk_18; /* 0x24 */ Vec3f unk_24; /* 0x30 */ Vec3f unk_30; /* 0x3C */ Vec3f unk_3C; } ObjMineUnkStruct2; // size = 0x48??? +typedef struct { + f32 unk_00; + Vec3f unk_04; + f32 unk_10; + f32 unk_14; + f32 unk_18; + f32 unk_1C; + s16 unk_20; + f32 unk_24; + f32 unk_28; + f32 unk_2C; + f32 unk_30; + f32 unk_34; + f32 unk_38; + f32 unk_3C; + s8 unk_40; + ObjMineUnkStruct2 unk_44[0x3F]; +} ObjMineTestStruct2; + typedef struct ObjMine { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderJntSph collider; @@ -66,8 +77,8 @@ typedef struct ObjMine { /* 0x01AC */ s32 unk_1AC; /* 0x01B0 */ s32 unk_1B0; /* 0x01B4 */ Vec3s* unk_1B4; - /* 0x01B8 */ ObjMineUnkStruct unk_1B8; // array?? - /* 0x021C */ char unk_21C[0x1198]; + // ObjMineTestStruct2 chain2; + union { ObjMineTestStruct2 chain2; ObjMineUnkStruct chain1;}; } ObjMine; // size = 0x13B4 extern const ActorInit Obj_Mine_InitVars; From cb6549e3213f522e668281f654347a05fb289367 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Mon, 24 Oct 2022 08:17:36 -0500 Subject: [PATCH 087/130] wew --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 46 ++++++++++--------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 7 ++- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 41634e383..15a51f3c7 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -1,7 +1,7 @@ /* * File: z_obj_mine.c * Overlay: ovl_Obj_Mine - * Description: Spike metal Mine + * Description: Spike metal mine */ #include "z_obj_mine.h" @@ -141,10 +141,10 @@ void func_80A81384(ObjMine* this, PlayState* play) { f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; f32 z = this->collider.elements[0].dim.worldSphere.center.z; - EnBom* bom = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); - if (bom != NULL) { - bom->timer = 0; + if (bomb != NULL) { + bomb->timer = 0; } } @@ -153,10 +153,10 @@ s32 func_80A8140C(ObjMine* this) { return true; } - if ((this->collider.base.ocFlags1 & OC2_UNK1)) { - Actor* mine = this->collider.base.oc; + if ((this->collider.base.ocFlags1 & OC1_HIT)) { + Actor* hitActor = this->collider.base.oc; - if ((mine->id == ACTOR_OBJ_MINE) && (mine->room == this->actor.room)) { + if ((hitActor->id == ACTOR_OBJ_MINE) && (hitActor->room == this->actor.room)) { return true; } } @@ -189,8 +189,8 @@ void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { void func_80A81544(ObjMine* this, Vec3f* arg1) { Actor* ac = this->collider.base.ac; - Vec3f sp20; + // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if ((this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820)) { Matrix_Push(); Matrix_RotateYS(ac->shape.rot.y, MTXMODE_NEW); @@ -198,6 +198,7 @@ void func_80A81544(ObjMine* this, Vec3f* arg1) { Matrix_MultVecZ(1.0f, arg1); Matrix_Pop(); } else { + Vec3f sp20; Sphere16* sphere = &this->collider.elements[0].dim.worldSphere; sp20.x = sphere->center.x - ac->world.pos.x; @@ -259,7 +260,7 @@ s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { Math_Vec3f_Copy(&sp30, arg0); Math3D_CrossProduct(arg0, arg1, &sp3C); if (func_80A8120C(&sp3C, &sp24)) { - Matrix_RotateAxisS(arg2 * 10430.378f, &sp24, MTXMODE_NEW); + Matrix_RotateAxisS(RADF_TO_BINANG(arg2), &sp24, MTXMODE_NEW); Matrix_MultVec3f(&sp30, arg0); } else { Matrix_RotateXFNew(arg2); @@ -330,7 +331,7 @@ void func_80A81A00(ObjMine* this) { } void func_80A81AA4(ObjMine* this) { - s32 params = this->actor.params & 0x3F; + s32 params = OBJMINE_GET_PARAM_003F(&this->actor); f32 temp_f0 = -((params * 12.0f) + 10.0f); this->actor.world.pos.x = (this->chain1.unk_00.y.x * temp_f0) + this->actor.home.pos.x; @@ -339,7 +340,7 @@ void func_80A81AA4(ObjMine* this) { } void func_80A81B14(ObjMine* this) { - s32 params = this->actor.params & 0x3F; + s32 params = OBJMINE_GET_PARAM_003F(&this->actor); f32 temp_f0 = 1.0f / ((params * 12.0f) + 10.0f); f32 x = this->actor.world.pos.x - this->actor.home.pos.x; f32 z = this->actor.world.pos.z - this->actor.home.pos.z; @@ -407,11 +408,11 @@ void func_80A81D70(ObjMine* this, s32 arg1) { void func_80A81DEC(ObjMine* this) { ObjMineTestStruct2* ptr = &this->chain2; s32 pad; - s32 temp_v0 = this->actor.params & 0x3F; + s32 temp_v0 = OBJMINE_GET_PARAM_003F(&this->actor); if (temp_v0 == 0) { - this->actor.world.pos.y = (this->actor.home.pos.y + 12.0f) + 10.0f; + this->actor.world.pos.y = this->actor.home.pos.y + 12.0f + 10.0f; } else { ObjMineUnkStruct2* ptr2 = &ptr->unk_44[temp_v0 - 1]; Vec3f sp1C; @@ -457,11 +458,12 @@ void func_80A81E7C(ObjMine* this, PlayState* play) { } #ifdef NON_MATCHING +// Probably equivalent, but nightmare loop unrolls. void func_80A81FFC(ObjMine *this) { s32 i; ObjMineTestStruct2 *temp_s1 = &this->chain2; ObjMineUnkStruct2 *var_s0; - s32 temp_s6 = this->actor.params & 0x3F; + s32 temp_s6 = OBJMINE_GET_PARAM_003F(&this->actor); s16 var_s3 = 0; f32 temp_fs2 = 1.0f / (f32) temp_s6; Vec3f sp90; @@ -540,7 +542,7 @@ void func_80A828A8(ObjMine* this) { Vec3f spE0; Vec3f spD4; Vec3f spC8; - s32 spC4 = this->actor.params & 0x3F; + s32 spC4 = OBJMINE_GET_PARAM_003F(&this->actor); ObjMineTestStruct2* sp70 = &this->chain2; ObjMineUnkStruct2* temp_s0; Vec3f* phi_s3; @@ -621,10 +623,10 @@ void func_80A82C28(ObjMine* this, PlayState* play) { void ObjMine_Init(Actor* thisx, PlayState* play) { ObjMine* this = THIS; s32 pad; - s32 sp44 = this->actor.params & 0xFF; + s32 sp44 = OBJMINE_GET_PARAM_00FF(&this->actor); Path* path; s32 sp3C; - s32 sp38 = (this->actor.params >> 0xC) & 3; + s32 sp38 = OBJMINE_GET_PARAM_3000(&this->actor); s32 sp34; Actor_ProcessInitChain(&this->actor, sInitChain); @@ -636,7 +638,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { if (sp38 == 0) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 140; - this->unk_1A8 = D_80A845A4[(this->actor.params >> 8) & 7]; + this->unk_1A8 = D_80A845A4[OBJMINE_GET_PARAM_0700(&this->actor)]; if (sp44 == 0xFF) { func_80A82F84(this); } else { @@ -654,7 +656,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp3C, &this->actor, &this->actor.world.pos); } else { - sp34 = this->actor.params & 0x3F; + sp34 = OBJMINE_GET_PARAM_003F(&this->actor); this->actor.update = func_80A83E7C; this->actor.uncullZoneScale = (sp34 * 21.0f) + 150.0f; this->actor.uncullZoneDownward = (sp34 * 21.0f) + 150.0f; @@ -779,7 +781,7 @@ void func_80A832BC(ObjMine* this) { void func_80A832D0(ObjMine* this, PlayState* play) { s32 pad; - s32 spA0 = this->actor.params & 0x3F; + s32 spA0 = OBJMINE_GET_PARAM_003F(&this->actor); ObjMineUnkStruct* unkStruct = &this->chain1; ObjMineUnkStruct3* temp; s32 i; @@ -1040,7 +1042,7 @@ void func_80A83FBC(Actor* thisx, PlayState* play) { void func_80A84088(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; - s32 temp_s5 = this->actor.params & 0x3F; + s32 temp_s5 = OBJMINE_GET_PARAM_003F(&this->actor); ObjMineUnkStruct3* temp; ObjMineUnkStruct* ptr = &this->chain1; s32 i; @@ -1096,7 +1098,7 @@ void func_80A84088(Actor* thisx, PlayState* play) { void func_80A84338(Actor* thisx, PlayState* play) { s32 pad1; ObjMine* this = THIS; - s32 temp_s7 = this->actor.params & 0x3F; + s32 temp_s7 = OBJMINE_GET_PARAM_003F(&this->actor); ObjMineTestStruct2* pad2 = &this->chain2; s32 i; Gfx* gfx; diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index ac4fb0182..70c406f49 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,6 +7,11 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); +#define OBJMINE_GET_PARAM_003F(thisx) ((thisx)->params & 0x3F) +#define OBJMINE_GET_PARAM_00FF(thisx) ((thisx)->params & 0xFF) +#define OBJMINE_GET_PARAM_0700(thisx) ((thisx)->params >> 8 & 7) +#define OBJMINE_GET_PARAM_3000(thisx) ((thisx)->params >> 0xC & 3) + typedef struct { Vec3f x; Vec3f y; @@ -36,7 +41,7 @@ typedef struct { /* 0x54 */ s16 unk_54; /* 0x58 */ f32 unk_58; /* 0x5C */ f32 unk_5C; - /* 0x60 */ ObjMineUnkStruct3 unk_60[1]; + /* 0x60 */ ObjMineUnkStruct3* unk_60; } ObjMineUnkStruct; // size = ?? 0x44??? 48 array??? // probably fake From ee4e186def6306944461ef20cfa0f34ce7b1e40e Mon Sep 17 00:00:00 2001 From: petrie911 Date: Mon, 24 Oct 2022 14:33:10 -0500 Subject: [PATCH 088/130] some docs. still baffling --- include/macros.h | 4 + src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 1040 +++++++++-------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 91 +- tools/disasm/functions.txt | 84 +- 4 files changed, 624 insertions(+), 595 deletions(-) diff --git a/include/macros.h b/include/macros.h index ad963153f..5dc4ca943 100644 --- a/include/macros.h +++ b/include/macros.h @@ -129,6 +129,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) +#define CUBE(x) ((x) * (x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) #define DECR(x) ((x) == 0 ? 0 : --(x)) @@ -137,6 +138,9 @@ extern GraphicsContext* __gfxCtx; #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) +#define RAND_BITS(n) ((s32)Rand_Next() >> (0x20 - n)) +#define RANDU_BITS(n) (Rand_Next() >> (0x20 - n)) + #define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5)) #define SWAP(type, a, b) \ diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 9e894807b..d83a4a04f 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -14,28 +14,27 @@ void ObjMine_Init(Actor* thisx, PlayState* play); void ObjMine_Destroy(Actor* thisx, PlayState* play); -void ObjMine_Update(Actor* thisx, PlayState* play); -void ObjMine_Draw(Actor* thisx, PlayState* play); +void ObjMine_Path_Update(Actor* thisx, PlayState* play); +void ObjMine_Path_Draw(Actor* thisx, PlayState* play); -void func_80A82F84(ObjMine* this); -void func_80A82F98(ObjMine* this, PlayState* play); -void func_80A82FA8(ObjMine* this); -void func_80A82FC8(ObjMine* this, PlayState* play); -void func_80A83258(ObjMine* this, PlayState* play); -void func_80A832BC(ObjMine* this); -void func_80A832D0(ObjMine* this, PlayState* play); -void func_80A83A74(ObjMine* this); -void func_80A83A88(ObjMine* this, PlayState* play); -void func_80A83B14(ObjMine* this); -void func_80A83B28(ObjMine* this, PlayState* play); -void func_80A83CEC(ObjMine* this); -void func_80A83D00(ObjMine* this, PlayState* play); -void func_80A83E7C(Actor* thisx, PlayState* play); -void func_80A83FBC(Actor* thisx, PlayState* play); -void func_80A84088(Actor* thisx, PlayState* play); -void func_80A84338(Actor* thisx, PlayState* play); +void ObjMine_Path_SetupStationary(ObjMine* this); +void ObjMine_Path_Stationary(ObjMine* this, PlayState* play); +void ObjMine_Path_SetupMove(ObjMine* this); +void ObjMine_Path_Move(ObjMine* this, PlayState* play); +void ObjMine_Explode(ObjMine* this, PlayState* play); +void ObjMine_Air_SetupChained(ObjMine* this); +void ObjMine_Air_Chained(ObjMine* this, PlayState* play); +void ObjMine_Air_SetupStationary(ObjMine* this); +void ObjMine_Air_Stationary(ObjMine* this, PlayState* play); +void ObjMine_Water_SetupChained(ObjMine* this); +void ObjMine_Water_Chained(ObjMine* this, PlayState* play); +void ObjMine_Water_SetupStationary(ObjMine* this); +void ObjMine_Water_Stationary(ObjMine* this, PlayState* play); -static Vec3f D_80A849D0[0x40]; +void ObjMine_AirWater_Update(Actor* thisx, PlayState* play); +void ObjMine_DrawExplosion(Actor* thisx, PlayState* play); +void ObjMine_Air_Draw(Actor* thisx, PlayState* play); +void ObjMine_Water_Draw(Actor* thisx, PlayState* play); ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, @@ -45,8 +44,8 @@ ActorInit Obj_Mine_InitVars = { sizeof(ObjMine), (ActorFunc)ObjMine_Init, (ActorFunc)ObjMine_Destroy, - (ActorFunc)ObjMine_Update, - (ActorFunc)ObjMine_Draw, + (ActorFunc)ObjMine_Path_Update, + (ActorFunc)ObjMine_Path_Draw, }; static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -76,13 +75,12 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static f32 D_80A845A4[] = { +static f32 sPathSpeeds[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, }; -static Vec3f D_80A845C4 = { 1.0f, 0.0f, 0.0f }; - -static Vec3f D_80A845D0[] = { +static ObjMineMtxF3 sStandardBasis = { + { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, }; @@ -94,61 +92,61 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -void func_80A811D0(ObjMine* this, s32 arg1) { - Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->unk_1B4[arg1]); +void ObjMine_Path_MoveToWaypoint(ObjMine* this, s32 index) { + Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->waypoints[index]); } -s32 func_80A8120C(Vec3f* arg0, Vec3f* arg1) { - f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); +s32 ObjMine_GetUnitVec3f(Vec3f* src, Vec3f* dst) { + f32 temp_f0 = Math3D_Vec3fMagnitude(src); if (temp_f0 < 0.001f) { return false; } - arg1->x = arg0->x * (1.0f / temp_f0); - arg1->y = arg0->y * (1.0f / temp_f0); - arg1->z = arg0->z * (1.0f / temp_f0); + dst->x = src->x * (1.0f / temp_f0); + dst->y = src->y * (1.0f / temp_f0); + dst->z = src->z * (1.0f / temp_f0); return true; } -s32 func_80A81288(Vec3f* arg0, Vec3f* arg1, f32* arg2, f32* arg3) { - f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); +s32 ObjMine_GetUnitVec3fNorm(Vec3f* src, Vec3f* dst, f32* norm, f32* invNorm) { + f32 magnitude = Math3D_Vec3fMagnitude(src); - if (temp_f0 < 0.001f) { + if (magnitude < 0.001f) { return false; } - arg1->x = arg0->x * (1.0f / temp_f0); - arg1->y = arg0->y * (1.0f / temp_f0); - arg1->z = arg0->z * (1.0f / temp_f0); - *arg2 = temp_f0; - *arg3 = 1.0f / temp_f0; + dst->x = src->x * (1.0f / magnitude); + dst->y = src->y * (1.0f / magnitude); + dst->z = src->z * (1.0f / magnitude); + *norm = magnitude; + *invNorm = 1.0f / magnitude; return true; } -void func_80A8131C(ObjMine* this, PlayState* play) { +void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { bomb->timer = 0; } } -void func_80A81384(ObjMine* this, PlayState* play) { +void ObjMine_AirWater_SpawnBomb(ObjMine* this, PlayState* play) { f32 x = this->collider.elements[0].dim.worldSphere.center.x; f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; f32 z = this->collider.elements[0].dim.worldSphere.center.z; - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { bomb->timer = 0; } } -s32 func_80A8140C(ObjMine* this) { +s32 ObjMine_AirWater_CheckOC(ObjMine* this) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { return true; } @@ -164,79 +162,80 @@ s32 func_80A8140C(ObjMine* this) { return false; } -void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { - s32 pad2[3]; - Vec3f sp40; +void ObjMine_Air_CheckAC(ObjMine* this, s16* arg1, s16* arg2) { + s32 pad[2]; + Vec3s* centerPos3s = &this->collider.elements[0].dim.worldSphere.center; + Vec3f centerPos; s16 sp3E; - s16 pad; - Actor* temp_s0 = this->collider.base.ac; + Actor* attackActor = this->collider.base.ac; - Math_Vec3s_ToVec3f(&sp40, &this->collider.elements[0].dim.worldSphere.center); - sp3E = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp40); + Math_Vec3s_ToVec3f(¢erPos, centerPos3s); + sp3E = Math_Vec3f_Yaw(&attackActor->world.pos, ¢erPos); + // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { - *arg1 = temp_s0->shape.rot.y; - *arg2 = temp_s0->shape.rot.y - sp3E; + *arg1 = attackActor->shape.rot.y; + *arg2 = attackActor->shape.rot.y - sp3E; } else { - Vec3f sp2C; - Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + Vec3f hitPos; + Vec3s* hitPos3s = &this->collider.elements[0].info.bumper.hitPos; - Math_Vec3s_ToVec3f(&sp2C, hitPos); - *arg1 = Actor_YawBetweenActors(temp_s0, &this->actor); - *arg2 = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp2C) - sp3E; + Math_Vec3s_ToVec3f(&hitPos, hitPos3s); + *arg1 = Actor_YawBetweenActors(attackActor, &this->actor); + *arg2 = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - sp3E; } } -void func_80A81544(ObjMine* this, Vec3f* arg1) { - Actor* ac = this->collider.base.ac; +void ObjMine_Water_CheckAC(ObjMine* this, Vec3f* arg1) { + Actor* attackActor = this->collider.base.ac; // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if ((this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820)) { Matrix_Push(); - Matrix_RotateYS(ac->shape.rot.y, MTXMODE_NEW); - Matrix_RotateXS(ac->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(attackActor->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(attackActor->shape.rot.x, MTXMODE_APPLY); Matrix_MultVecZ(1.0f, arg1); Matrix_Pop(); } else { - Vec3f sp20; + Vec3f sp20; Sphere16* sphere = &this->collider.elements[0].dim.worldSphere; - sp20.x = sphere->center.x - ac->world.pos.x; - sp20.y = sphere->center.y - ac->world.pos.y; - sp20.z = sphere->center.z - ac->world.pos.z; - if (!func_80A8120C(&sp20, arg1)) { - Math_Vec3f_Copy(arg1, &D_80A845D0[0]); + sp20.x = sphere->center.x - attackActor->world.pos.x; + sp20.y = sphere->center.y - attackActor->world.pos.y; + sp20.z = sphere->center.z - attackActor->world.pos.z; + if (!ObjMine_GetUnitVec3f(&sp20, arg1)) { + Math_Vec3f_Copy(arg1, &sStandardBasis.y); } } } -void func_80A81640(ObjMine* this) { +void ObjMine_AirWater_Noop(ObjMine* this) { } -void func_80A8164C(Vec3f* arg0) { +void ObjMine_ReplaceTranslation(Vec3f* translation) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[3][0] = arg0->x; - matrix->mf[3][1] = arg0->y; - matrix->mf[3][2] = arg0->z; + matrix->mf[3][0] = translation->x; + matrix->mf[3][1] = translation->y; + matrix->mf[3][2] = translation->z; } -void func_80A81684(ObjMineMtxF3* arg0) { +void ObjMine_ReplaceRotation(ObjMineMtxF3* rotation) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[0][0] = arg0->x.x; - matrix->mf[0][1] = arg0->x.y; - matrix->mf[0][2] = arg0->x.z; + matrix->mf[0][0] = rotation->x.x; + matrix->mf[0][1] = rotation->x.y; + matrix->mf[0][2] = rotation->x.z; matrix->mf[0][3] = 0.0f; - matrix->mf[1][0] = arg0->y.x; - matrix->mf[1][1] = arg0->y.y; - matrix->mf[1][2] = arg0->y.z; + matrix->mf[1][0] = rotation->y.x; + matrix->mf[1][1] = rotation->y.y; + matrix->mf[1][2] = rotation->y.z; matrix->mf[1][3] = 0.0f; - matrix->mf[2][0] = arg0->z.x; - matrix->mf[2][1] = arg0->z.y; - matrix->mf[2][2] = arg0->z.z; + matrix->mf[2][0] = rotation->z.x; + matrix->mf[2][1] = rotation->z.y; + matrix->mf[2][2] = rotation->z.z; matrix->mf[2][3] = 0.0f; matrix->mf[3][0] = 0.0f; @@ -245,263 +244,267 @@ void func_80A81684(ObjMineMtxF3* arg0) { matrix->mf[3][3] = 1.0f; } -s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { +s32 ObjMine_StepUntilParallel(Vec3f* value, Vec3f* target, f32 angleStep) { Vec3f sp3C; Vec3f sp30; Vec3f sp24; - f32 sp20 = Math3D_Parallel(arg0, arg1); + f32 sp20 = Math3D_Parallel(value, target); - if (cos_rad(arg2) <= sp20) { - Math_Vec3f_Copy(arg0, arg1); + if (cos_rad(angleStep) <= sp20) { + Math_Vec3f_Copy(value, target); return true; } Matrix_Push(); - Math_Vec3f_Copy(&sp30, arg0); - Math3D_CrossProduct(arg0, arg1, &sp3C); - if (func_80A8120C(&sp3C, &sp24)) { - Matrix_RotateAxisS(RADF_TO_BINANG(arg2), &sp24, MTXMODE_NEW); - Matrix_MultVec3f(&sp30, arg0); + Math_Vec3f_Copy(&sp30, value); + Math3D_CrossProduct(value, target, &sp3C); + if (ObjMine_GetUnitVec3f(&sp3C, &sp24)) { + Matrix_RotateAxisS(RADF_TO_BINANG(angleStep), &sp24, MTXMODE_NEW); + Matrix_MultVec3f(&sp30, value); } else { - Matrix_RotateXFNew(arg2); - Matrix_MultVec3f(&sp30, arg0); + Matrix_RotateXFNew(angleStep); + Matrix_MultVec3f(&sp30, value); } Matrix_Pop(); return false; } -void func_80A81818(ObjMine* this) { - this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements->dim.worldSphere.center.y = this->actor.world.pos.y; - this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; +void ObjMine_UpdateCollider(ObjMine* this) { + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; } -void func_80A81868(ObjMine* this, s32 arg1) { +void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { + f32 arg1f = linkCount; + ObjMineAirChain* chain1 = &this->chain.air; + ObjMineAirLink* link1; s32 i; - ObjMineUnkStruct* ptr = &this->chain1; - ObjMineUnkStruct3* unkStruct; - f32 arg = arg1; f32 temp_f12 = this->actor.home.rot.z * 5.0f; - ptr->unk_00.x.x = 1.0f; - ptr->unk_00.y.y = 1.0f; - ptr->unk_00.z.z = 1.0f; - ptr->unk_24.y = 1.0f; + chain1->basis.x.x = 1.0f; + chain1->basis.y.y = 1.0f; + chain1->basis.z.z = 1.0f; + chain1->unk_24.y = 1.0f; - if (arg1 > 0) { - ptr->unk_40 = -sqrtf(0.001984f / arg); // approx 1/504 = 1/8 * 1/63 - ptr->unk_44 = (0.00031746097f * arg) + 0.95f; // approx 1/3150 = 1/50 * 1/63 + if (linkCount > 0) { + chain1->unk_40 = -sqrtf(0.001984f / arg1f); // approx 1/504 = 1/8 * 1/63 + chain1->unk_44 = 0.95f + (0.00031746097f * arg1f); // approx 1/3150 = 1/50 * 1/63 } - ptr->unk_58 = 0.0002f; + chain1->unk_58 = 0.0002f; - for (i = 0, unkStruct = ptr->unk_60; i < arg1; i++, unkStruct++) { - unkStruct->unk_00 = 0x4000; + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + link1->unk_00 = 0x4000; } if (temp_f12 < 0.0f) { - ptr->unk_5C = -1.0f; + chain1->unk_5C = -1.0f; } else if (temp_f12 <= 21.0f) { - ptr->unk_5C = 0.0f; + chain1->unk_5C = 0.0f; } else { - ptr->unk_5C = SQ(temp_f12 - 20.0f); + chain1->unk_5C = SQ(temp_f12 - 20.0f); } } -void func_80A819A4(ObjMine* this, s32 arg1) { +void ObjMine_Air_SetCollider(ObjMine* this, s32 linkCount) { 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); Collider_UpdateSpheres(0, &this->collider); } -void func_80A81A00(ObjMine* this) { - ObjMineUnkStruct* ptr = &this->chain1; +void ObjMine_Air_SetBasis(ObjMine* this) { + ObjMineAirChain* chain1 = &this->chain.air; Vec3f sp28; - sp28.x = -ptr->unk_30; + sp28.x = -chain1->unk_30; sp28.y = 1.0f; - sp28.z = -ptr->unk_34; + sp28.z = -chain1->unk_34; - func_80A8120C(&sp28, &ptr->unk_00.y); - Math3D_CrossProduct(&D_80A845C4, &ptr->unk_00.y, &sp28); - func_80A8120C(&sp28, &ptr->unk_00.z); - Math3D_CrossProduct(&ptr->unk_00.y, &ptr->unk_00.z, &sp28); - func_80A8120C(&sp28, &ptr->unk_00.x); + ObjMine_GetUnitVec3f(&sp28, &chain1->basis.y); + Math3D_CrossProduct(&sStandardBasis.x, &chain1->basis.y, &sp28); + ObjMine_GetUnitVec3f(&sp28, &chain1->basis.z); + Math3D_CrossProduct(&chain1->basis.y, &chain1->basis.z, &sp28); + ObjMine_GetUnitVec3f(&sp28, &chain1->basis.x); } -void func_80A81AA4(ObjMine* this) { - s32 params = OBJMINE_GET_PARAM_003F(&this->actor); - f32 temp_f0 = -((params * 12.0f) + 10.0f); +void ObjMine_Air_SetWorld(ObjMine* this) { + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + f32 temp_f0 = 10.0f + (linkCount * 12.0f); - this->actor.world.pos.x = (this->chain1.unk_00.y.x * temp_f0) + this->actor.home.pos.x; - this->actor.world.pos.y = (this->chain1.unk_00.y.y * temp_f0) + this->actor.home.pos.y; - this->actor.world.pos.z = (this->chain1.unk_00.y.z * temp_f0) + this->actor.home.pos.z; + this->actor.world.pos.x = (this->chain.air.basis.y.x * -temp_f0) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->chain.air.basis.y.y * -temp_f0) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->chain.air.basis.y.z * -temp_f0) + this->actor.home.pos.z; } -void func_80A81B14(ObjMine* this) { - s32 params = OBJMINE_GET_PARAM_003F(&this->actor); - f32 temp_f0 = 1.0f / ((params * 12.0f) + 10.0f); - f32 x = this->actor.world.pos.x - this->actor.home.pos.x; - f32 z = this->actor.world.pos.z - this->actor.home.pos.z; +void ObjMine_Air_SetChain3034(ObjMine* this) { + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + f32 temp_f0 = 1.0f / (10.0f + (linkCount * 12.0f)); + f32 dx = this->actor.world.pos.x - this->actor.home.pos.x; + f32 dz = this->actor.world.pos.z - this->actor.home.pos.z; - this->chain1.unk_30 = x * temp_f0; - this->chain1.unk_34 = z * temp_f0; + this->chain.air.unk_30 = dx * temp_f0; + this->chain.air.unk_34 = dz * temp_f0; } -void func_80A81B7C(ObjMine* this, s32 arg1) { - ObjMineTestStruct2* ptr = &this->chain2; - ObjMineUnkStruct2* unkStruct; +void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { + ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterLink* link2; s32 i; f32 sp58 = this->actor.home.rot.z * 5.0f; f32 temp_f24; f32 temp_f26; - ptr->unk_00 = 0.9f; - ptr->unk_1C = 0.003f; + chain2->unk_00 = 0.9f; + chain2->unk_1C = 0.003f; - ptr->unk_20 = Rand_Next() >> 0x13; - ptr->unk_24 = -0.0002f; - ptr->unk_30 = -0.0002f; + chain2->unk_20 = RANDU_BITS(13); + chain2->unk_24 = -0.0002f; + chain2->unk_30 = -0.0002f; - temp_f26 = ptr->unk_1C * 6.0f; + temp_f26 = chain2->unk_1C * 6.0f; temp_f24 = this->actor.home.pos.y; - unkStruct = ptr->unk_44; - for (i = 0; i < arg1; i++, unkStruct++) { + for (i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { temp_f24 += 12.0f; - unkStruct->unk_00.x.x = 1.0f; - unkStruct->unk_00.y.y = 1.0f; - unkStruct->unk_00.z.z = 1.0f; - unkStruct->unk_24.x = this->actor.home.pos.x; - unkStruct->unk_24.y = temp_f24; - unkStruct->unk_24.z = this->actor.home.pos.z; - unkStruct->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; - unkStruct->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; - unkStruct->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; + link2->basis.x.x = 1.0f; + link2->basis.y.y = 1.0f; + link2->basis.z.z = 1.0f; + link2->unk_24.x = this->actor.home.pos.x; + link2->unk_24.y = temp_f24; + link2->unk_24.z = this->actor.home.pos.z; + link2->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; + link2->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; + link2->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; } - ptr->unk_28 = temp_f24; - ptr->unk_2C = temp_f24 * 0.97f; + chain2->unk_28 = temp_f24; + chain2->unk_2C = temp_f24 * 0.97f; temp_f24 -= 18.0f; - if (ptr->unk_2C < temp_f24) { - ptr->unk_2C = temp_f24; + if (chain2->unk_2C < temp_f24) { + chain2->unk_2C = temp_f24; } if (sp58 < 0.0f) { - ptr->unk_34 = -1.0f; + chain2->unk_34 = -1.0f; } else if (sp58 <= 37.0f) { - ptr->unk_34 = 0.0f; + chain2->unk_34 = 0.0f; } else { - ptr->unk_34 = SQ(sp58 - 36.0f); + chain2->unk_34 = SQ(sp58 - 36.0f); } } -void func_80A81D70(ObjMine* this, s32 arg1) { - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, +void ObjMine_Water_SetCollider(ObjMine* this, s32 linkCount) { + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (linkCount * 12.0f) + 10.0f, this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } -void func_80A81DEC(ObjMine* this) { - ObjMineTestStruct2* ptr = &this->chain2; +void ObjMine_Water_SetWorld(ObjMine* this) { s32 pad; - s32 temp_v0 = OBJMINE_GET_PARAM_003F(&this->actor); + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* chain2 = &this->chain.water; - - if (temp_v0 == 0) { + if (linkCount == 0) { this->actor.world.pos.y = this->actor.home.pos.y + 12.0f + 10.0f; } else { - ObjMineUnkStruct2* ptr2 = &ptr->unk_44[temp_v0 - 1]; + ObjMineWaterLink* link2 = &chain2->links[linkCount - 1]; Vec3f sp1C; - Math_Vec3f_ScaleAndStore(&ptr2->unk_00.y, 10.0f, &sp1C); - Math_Vec3f_Sum(&ptr2->unk_24, &sp1C, &this->actor.world.pos); + Math_Vec3f_ScaleAndStore(&link2->basis.y, 10.0f, &sp1C); + Math_Vec3f_Sum(&link2->unk_24, &sp1C, &this->actor.world.pos); } } void func_80A81E7C(ObjMine* this, PlayState* play) { - ObjMineTestStruct2* temp_v1 = &this->chain2; s32 pad; - Vec3f sp7C; - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - CollisionPoly* sp48; - s32 sp44; - f32 sp40; - f32 sp3C; - - temp_v1->unk_40 = 0; - if ((-0.000001f < temp_v1->unk_34) && (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + ObjMineWaterChain* chain2 = &this->chain.water; + + chain2->unk_40 = false; + if ((-0.000001f < chain2->unk_34) && (chain2->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, this->actor.world.pos.x, this->actor.world.pos.z))) { - sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; - sp58.y = 0.0f; - sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { - sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f xzDistFromHome; + Vec3f xzDirFromHome; + CollisionPoly* dummyPoly; + s32 dummyBgId; + f32 dummyNorm; + f32 dummyInvNorm; + + xzDistFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; + xzDistFromHome.y = 0.0f; + xzDistFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; + + if (ObjMine_GetUnitVec3fNorm(&xzDistFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { + + sp70.x = this->actor.world.pos.x + (xzDirFromHome.x * 36.0f); sp70.y = this->actor.world.pos.y; - sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); + sp70.z = this->actor.world.pos.z + (xzDirFromHome.z * 36.0f); + sp7C.x = this->actor.home.pos.x; sp7C.y = this->actor.world.pos.y; sp7C.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { - temp_v1->unk_40 = 1; - temp_v1->unk_38 = sp4C.x * -0.2f; - temp_v1->unk_3C = sp4C.z * -0.2f; + + if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &dummyPoly, 1, 0, 0, 1, &dummyBgId)) { + chain2->unk_40 = true; + chain2->unk_38 = xzDirFromHome.x * -0.2f; + chain2->unk_3C = xzDirFromHome.z * -0.2f; } } } } #ifdef NON_MATCHING -// Probably equivalent, but nightmare loop unrolls. +// Probably equivalent, but nightmare loop unrolls. void func_80A81FFC(ObjMine *this) { + static Vec3f D_80A849D0[0x40]; + ObjMineWaterChain *chain2 = &this->chain.water; + ObjMineWaterLink *link2; s32 i; - ObjMineTestStruct2 *temp_s1 = &this->chain2; - ObjMineUnkStruct2 *var_s0; - s32 temp_s6 = OBJMINE_GET_PARAM_003F(&this->actor); - s16 var_s3 = 0; - f32 temp_fs2 = 1.0f / (f32) temp_s6; + s16 var_s3; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + f32 invLinkCount = 1.0f / (f32) linkCount; + f32 temp_fs0 = (chain2->links[linkCount - 1].unk_24.y - chain2->unk_2C) * chain2->unk_30; Vec3f sp90; - f32 temp_fs0 = (temp_s1->unk_44[temp_s6 - 1].unk_24.y - temp_s1->unk_2C) * temp_s1->unk_30; f32 temp_ft4; - - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { - Math_Vec3f_Copy(&D_80A849D0[i], &var_s0->unk_3C); - if (var_s0->unk_24.y <= this->actor.home.pos.y) { - var_s0->unk_3C.y = temp_s1->unk_30 * -96.0f; + + for(i = 0, link2 = chain2->links, var_s3 = 0; i < linkCount; i++, link2++, var_s3 += chain2->unk_20) { + Math_Vec3f_Copy(&D_80A849D0[i], &link2->unk_3C); + if (link2->unk_24.y <= this->actor.home.pos.y) { + link2->unk_3C.y = chain2->unk_30 * -96.0f; } else if (temp_fs0 > 0.0f) { - var_s0->unk_3C.y = (i + 1) * temp_fs2 * (temp_fs0 / 0.3f); + link2->unk_3C.y = (i + 1) * invLinkCount * (temp_fs0 / 0.3f); } else { - var_s0->unk_3C.y = temp_fs0; + link2->unk_3C.y = temp_fs0; } - var_s0->unk_3C.x = (var_s0->unk_24.x - this->actor.home.pos.x) * temp_s1->unk_24; - var_s0->unk_3C.z = (var_s0->unk_24.z - this->actor.home.pos.z) * temp_s1->unk_24; - var_s0->unk_3C.x += temp_s1->unk_14 * Math_SinS(var_s3); - var_s0->unk_3C.y += temp_s1->unk_18; - var_s0->unk_3C.z += temp_s1->unk_14 * Math_CosS(var_s3); - var_s3 += temp_s1->unk_20; + link2->unk_3C.x = (link2->unk_24.x - this->actor.home.pos.x) * chain2->unk_24; + link2->unk_3C.z = (link2->unk_24.z - this->actor.home.pos.z) * chain2->unk_24; + link2->unk_3C.x += chain2->unk_14 * Math_SinS(var_s3); + link2->unk_3C.y += chain2->unk_18; + link2->unk_3C.z += chain2->unk_14 * Math_CosS(var_s3); } - if (temp_s1->unk_10 > 0.0001f) { - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { - temp_ft4 = SQ((temp_s6 - i) * temp_fs2); - var_s0->unk_3C.x += temp_s1->unk_04.x * temp_ft4; - var_s0->unk_3C.y += temp_s1->unk_04.y * temp_ft4; - var_s0->unk_3C.z += temp_s1->unk_04.z * temp_ft4; + if (chain2->unk_10 > 0.0001f) { + for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { + temp_ft4 = SQ((linkCount - i) * invLinkCount); + + link2->unk_3C.x += chain2->unk_04.x * temp_ft4; + link2->unk_3C.y += chain2->unk_04.y * temp_ft4; + link2->unk_3C.z += chain2->unk_04.z * temp_ft4; } } - if (temp_s1->unk_40) { - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { - var_s0->unk_3C.x += temp_s1->unk_38; - var_s0->unk_3C.z += temp_s1->unk_3C; + if (chain2->unk_40) { + for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { + link2->unk_3C.x += chain2->unk_38; + link2->unk_3C.z += chain2->unk_3C; } } - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { Math_Vec3f_Copy(&sp90, &gZeroVec3f); if(i - 2 >= 0) { sp90.x += D_80A849D0[i - 2].x * 0.075f; @@ -513,176 +516,186 @@ void func_80A81FFC(ObjMine *this) { sp90.y += D_80A849D0[i - 1].y * 0.15f; sp90.z += D_80A849D0[i - 1].z * 0.15f; } - sp90.x += D_80A849D0[i].x * 0.3f; - sp90.y += D_80A849D0[i].y * 0.3f; - sp90.z += D_80A849D0[i].z * 0.3f; - if(i + 1 < temp_s6) { + sp90.x += D_80A849D0[i].x * 0.3f; + sp90.y += D_80A849D0[i].y * 0.3f; + sp90.z += D_80A849D0[i].z * 0.3f; + if(i + 1 < linkCount) { sp90.x += D_80A849D0[i + 1].x * 0.15f; sp90.y += D_80A849D0[i + 1].y * 0.15f; sp90.z += D_80A849D0[i + 1].z * 0.15f; } - if(i + 2 < temp_s6) { + if(i + 2 < linkCount) { sp90.x += D_80A849D0[i + 2].x * 0.075f; sp90.y += D_80A849D0[i + 2].y * 0.075f; sp90.z += D_80A849D0[i + 2].z * 0.075f; } - var_s0->unk_3C.x += sp90.x; - var_s0->unk_3C.y += sp90.y; - var_s0->unk_3C.z += sp90.z; + link2->unk_3C.x += sp90.x; + link2->unk_3C.y += sp90.y; + link2->unk_3C.z += sp90.z; } } #else +Vec3f D_80A849D0[0x40]; void func_80A81FFC(ObjMine* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") #endif void func_80A828A8(ObjMine* this) { - s32 i; + s32 pad; Vec3f spE0; Vec3f spD4; Vec3f spC8; - s32 spC4 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineTestStruct2* sp70 = &this->chain2; - ObjMineUnkStruct2* temp_s0; + s32 spC4 = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterLink* link2; + s32 i; Vec3f* phi_s3; - s32 phi_s5; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Vec3f sp84; - s32 pad; + s32 phi_s5; f32 sp7C; f32 sp78; + Vec3f* phi_x; sp84.x = this->actor.home.pos.x; sp84.y = this->actor.home.pos.y + 6.0f; sp84.z = this->actor.home.pos.z; - for (i = 0, phi_s3 = NULL, temp_s0 = sp70->unk_44; i < spC4; i++, phi_s3 = &temp_s0->unk_00.x, temp_s0++) { + for (i = 0, phi_s3 = NULL, link2 = chain2->links; i < spC4; i++, phi_s3 = &link2->basis.x, link2++) { phi_s5 = false; - temp_s0->unk_30.x += temp_s0->unk_3C.x; - temp_s0->unk_30.y += temp_s0->unk_3C.y; - temp_s0->unk_30.z += temp_s0->unk_3C.z; - Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00); - Math_Vec3f_Copy(&sp90, &temp_s0->unk_24); - temp_s0->unk_24.x += temp_s0->unk_30.x; - temp_s0->unk_24.y += temp_s0->unk_30.y; - temp_s0->unk_24.z += temp_s0->unk_30.z; - if ((temp_s0->unk_24.y <= this->actor.home.pos.y) && (temp_s0->unk_30.y < 0.0f)) { - temp_s0->unk_30.y *= 0.1f; + link2->unk_30.x += link2->unk_3C.x; + link2->unk_30.y += link2->unk_3C.y; + link2->unk_30.z += link2->unk_3C.z; + + Math_Vec3f_Scale(&link2->unk_30, chain2->unk_00); + Math_Vec3f_Copy(&sp90, &link2->unk_24); + + link2->unk_24.x += link2->unk_30.x; + link2->unk_24.y += link2->unk_30.y; + link2->unk_24.z += link2->unk_30.z; + + if ((link2->unk_24.y <= this->actor.home.pos.y) && (link2->unk_30.y < 0.0f)) { + link2->unk_30.y *= 0.1f; } - Math_Vec3f_Diff(&temp_s0->unk_24, &sp84, &spA8); + Math_Vec3f_Diff(&link2->unk_24, &sp84, &spA8); - if (func_80A81288(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { - Math_Vec3f_Copy(&spD4, &temp_s0->unk_00.y); - func_80A81714(&spD4, &sp9C, 0.10471976f); + if (ObjMine_GetUnitVec3fNorm(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { + Math_Vec3f_Copy(&spD4, &link2->basis.y); + ObjMine_StepUntilParallel(&spD4, &sp9C, M_PI / 30); + phi_x = (phi_s3 == NULL) ? &sStandardBasis.x : phi_s3; - Math3D_CrossProduct((phi_s3 == NULL) ? &D_80A845C4 : phi_s3, &spD4, &spA8); + Math3D_CrossProduct(phi_x, &spD4, &spA8); - if (func_80A8120C(&spA8, &spE0)) { + if (ObjMine_GetUnitVec3f(&spA8, &spE0)) { Math3D_CrossProduct(&spD4, &spE0, &spA8); - if (func_80A8120C(&spA8, &spC8)) { + if (ObjMine_GetUnitVec3f(&spA8, &spC8)) { phi_s5 = true; } } } if (phi_s5) { - Math_Vec3f_Copy(&temp_s0->unk_00.x, &spC8); - Math_Vec3f_Copy(&temp_s0->unk_00.y, &spD4); - Math_Vec3f_Copy(&temp_s0->unk_00.z, &spE0); + Math_Vec3f_Copy(&link2->basis.x, &spC8); + Math_Vec3f_Copy(&link2->basis.y, &spD4); + Math_Vec3f_Copy(&link2->basis.z, &spE0); } else { sp7C = 4.0f; } if (sp7C >= 6.0f) { - temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * 6.0f); - temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * 6.0f); - temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * 6.0f); + link2->unk_24.x = sp84.x + (link2->basis.y.x * 6.0f); + link2->unk_24.y = sp84.y + (link2->basis.y.y * 6.0f); + link2->unk_24.z = sp84.z + (link2->basis.y.z * 6.0f); } else { - temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * sp7C); - temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * sp7C); - temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * sp7C); + link2->unk_24.x = sp84.x + (link2->basis.y.x * sp7C); + link2->unk_24.y = sp84.y + (link2->basis.y.y * sp7C); + link2->unk_24.z = sp84.z + (link2->basis.y.z * sp7C); } - sp84.x = temp_s0->unk_24.x + (temp_s0->unk_00.y.x * 6.0f); - sp84.y = temp_s0->unk_24.y + (temp_s0->unk_00.y.y * 6.0f); - sp84.z = temp_s0->unk_24.z + (temp_s0->unk_00.y.z * 6.0f); + sp84.x = link2->unk_24.x + (link2->basis.y.x * 6.0f); + sp84.y = link2->unk_24.y + (link2->basis.y.y * 6.0f); + sp84.z = link2->unk_24.z + (link2->basis.y.z * 6.0f); } } -void func_80A82C28(ObjMine* this, PlayState* play) { +void ObjMine_Water_UpdateChain(ObjMine* this, PlayState* play) { func_80A81E7C(this, play); func_80A81FFC(this); func_80A828A8(this); } void ObjMine_Init(Actor* thisx, PlayState* play) { - ObjMine* this = THIS; s32 pad; - s32 sp44 = OBJMINE_GET_PARAM_00FF(&this->actor); + ObjMine* this = THIS; + s32 pathIndex = OBJMINE_GET_PATH(&this->actor); Path* path; - s32 sp3C; - s32 sp38 = OBJMINE_GET_PARAM_3000(&this->actor); - s32 sp34; + s32 dummyBgId; + s32 type = OBJMINE_GET_TYPE(&this->actor); Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; + Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - if (sp38 == 0) { + if (type == OBJMINE_TYPE_PATH) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 140; - this->unk_1A8 = D_80A845A4[OBJMINE_GET_PARAM_0700(&this->actor)]; - if (sp44 == 0xFF) { - func_80A82F84(this); + this->pathSpeed = sPathSpeeds[OBJMINE_GET_PATH_SPEED(&this->actor)]; + if (pathIndex == 0xFF) { + ObjMine_Path_SetupStationary(this); } else { - path = &play->setupPathList[sp44]; - this->unk_1B0 = 0; - this->unk_1AC = path->count - 1; - this->unk_1B4 = (Vec3s*)Lib_SegmentedToVirtual(path->points); - func_80A811D0(this, this->unk_1B0); - func_80A82FA8(this); + path = &play->setupPathList[pathIndex]; + + this->waypointIndex = 0; + this->waypointCount = path->count - 1; + this->waypoints = (Vec3s*)Lib_SegmentedToVirtual(path->points); + + ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); + ObjMine_Path_SetupMove(this); } 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); - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp3C, + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgId, &this->actor, &this->actor.world.pos); } else { - sp34 = OBJMINE_GET_PARAM_003F(&this->actor); - this->actor.update = func_80A83E7C; - this->actor.uncullZoneScale = (sp34 * 21.0f) + 150.0f; - this->actor.uncullZoneDownward = (sp34 * 21.0f) + 150.0f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); - this->actor.shape.shadowAlpha = 0x8C; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - if (sp38 == 1) { - this->actor.draw = func_80A84088; - func_80A81868(this, sp34); - this->actor.world.pos.y = (-10.0f - (sp34 * 12.0f)) + this->actor.home.pos.y; - func_80A819A4(this, sp34); + this->actor.update = ObjMine_AirWater_Update; + this->actor.uncullZoneScale = 150.0f + (linkCount * 21.0f); + this->actor.uncullZoneDownward = 150.0f + (linkCount * 21.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); + this->actor.shape.shadowAlpha = 140; + + if (type == OBJMINE_TYPE_AIR) { + this->actor.draw = ObjMine_Air_Draw; + ObjMine_Air_InitChain(this, linkCount); + this->actor.world.pos.y = -10.0f - (linkCount * 12.0f) + this->actor.home.pos.y; + ObjMine_Air_SetCollider(this, linkCount); func_800B4AEC(play, &this->actor, 0.0f); - if (sp34 == 0) { - func_80A83A74(this); + if (linkCount == 0) { + ObjMine_Air_SetupStationary(this); } else { - func_80A832BC(this); + ObjMine_Air_SetupChained(this); } } else { - this->actor.draw = func_80A84338; - func_80A81B7C(this, sp34); - this->actor.world.pos.y = (sp34 * 12.0f) + 10.0f + this->actor.home.pos.y; - func_80A81D70(this, sp34); - if (sp34 == 0) { - func_80A83CEC(this); + this->actor.draw = ObjMine_Water_Draw; + ObjMine_Water_InitChain(this, linkCount); + this->actor.world.pos.y = 10.0f + (linkCount * 12.0f) + this->actor.home.pos.y; + ObjMine_Water_SetCollider(this, linkCount); + if (linkCount == 0) { + ObjMine_Water_SetupStationary(this); } else { - func_80A83B14(this); + ObjMine_Water_SetupChained(this); } } } @@ -694,217 +707,223 @@ void ObjMine_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyJntSph(play, &this->collider); } -void func_80A82F84(ObjMine* this) { - this->actionFunc = func_80A82F98; +void ObjMine_Path_SetupStationary(ObjMine* this) { + this->actionFunc = ObjMine_Path_Stationary; } -void func_80A82F98(ObjMine* this, PlayState* play) { +void ObjMine_Path_Stationary(ObjMine* this, PlayState* play) { } -void func_80A82FA8(ObjMine* this) { +void ObjMine_Path_SetupMove(ObjMine* this) { this->actor.flags |= ACTOR_FLAG_10; - this->actionFunc = func_80A82FC8; + this->actionFunc = ObjMine_Path_Move; } -void func_80A82FC8(ObjMine* this, PlayState* play) { - Actor* thisx = &this->actor; - Vec3f spA0; +void ObjMine_Path_Move(ObjMine* this, PlayState* play) { + Actor* thisx = &this->actor; // pos and velocity need this, though it can replace all `this->actor`s and match + Vec3f nextWaypoint; f32 speed; f32 step; f32 target; - s32 sp90; - Vec3f sp84; - Vec3f sp78; - MtxF sp38; + s32 dummyBgVec; - Math_Vec3s_ToVec3f(&spA0, &this->unk_1B4[this->unk_1B0 + 1]); - Math_Vec3f_Diff(&spA0, &thisx->world.pos, &thisx->velocity); + Math_Vec3s_ToVec3f(&nextWaypoint, &this->waypoints[this->waypointIndex + 1]); + Math_Vec3f_Diff(&nextWaypoint, &thisx->world.pos, &thisx->velocity); speed = Math3D_Vec3fMagnitude(&thisx->velocity); - if ((speed < (this->unk_1A8 * 8.0f)) && (this->unk_1A8 > 2.0f)) { - target = ((this->unk_1A8 - 2.0f) * 0.1f) + 2.0f; - step = this->unk_1A8 * 0.03f; + if ((speed < (this->pathSpeed * 8.0f)) && (this->pathSpeed > 2.0f)) { + target = 2.0f + ((this->pathSpeed - 2.0f) * 0.1f); + step = this->pathSpeed * 0.03f; } else { - target = this->unk_1A8; - step = this->unk_1A8 * 0.16f; + target = this->pathSpeed; + step = this->pathSpeed * 0.16f; } - Math_StepToF(&thisx->speedXZ, target, step); - if ((thisx->speedXZ + 0.05f) < speed) { - Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); - thisx->world.pos.x += thisx->velocity.x; - thisx->world.pos.y += thisx->velocity.y; - thisx->world.pos.z += thisx->velocity.z; + Math_StepToF(&this->actor.speedXZ, target, step); + if ((this->actor.speedXZ + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, this->actor.speedXZ / speed); + this->actor.world.pos.x += thisx->velocity.x; + this->actor.world.pos.y += thisx->velocity.y; + this->actor.world.pos.z += thisx->velocity.z; } else { - thisx->speedXZ *= 0.4f; - this->unk_1B0++; - if (this->unk_1B0 >= this->unk_1AC) { - this->unk_1B0 = 0; + this->actor.speedXZ *= 0.4f; + this->waypointIndex++; + if (this->waypointIndex >= this->waypointCount) { + this->waypointIndex = 0; } - func_80A811D0(this, this->unk_1B0); + ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); } - thisx->floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &sp90, thisx, &thisx->world.pos); - if (thisx->flags & 0x40) { - Math3D_CrossProduct(&D_80A845D0[0], &thisx->velocity, &sp78); - if (func_80A8120C(&sp78, &sp84)) { - Matrix_RotateAxisF(thisx->speedXZ * 0.03125f, &sp84, MTXMODE_NEW); - Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); - Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, false); + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgVec, &this->actor, &thisx->world.pos); + if (this->actor.flags & ACTOR_FLAG_40) { + Vec3f rotAxis; + Vec3f yhatCrossV; + MtxF rotMtxF; + + Math3D_CrossProduct(&sStandardBasis.y, &thisx->velocity, &yhatCrossV); + if (ObjMine_GetUnitVec3f(&yhatCrossV, &rotAxis)) { + Matrix_RotateAxisF(this->actor.speedXZ / 32.0f, &rotAxis, 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(&rotMtxF); + Matrix_MtxFToYXZRot(&rotMtxF, &this->actor.shape.rot, false); } } } -void func_80A83214(ObjMine* this) { - this->actor.flags |= 0x10; - this->actor.draw = func_80A83FBC; +void ObjMine_SetupExplode(ObjMine* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->actor.draw = ObjMine_DrawExplosion; this->actor.shape.shadowDraw = NULL; this->actor.scale.x = 0.02f; this->actor.scale.y = 0.02f; this->actor.scale.z = 0.02f; - this->actionFunc = func_80A83258; + this->actionFunc = ObjMine_Explode; } -void func_80A83258(ObjMine* this, PlayState* play) { +void ObjMine_Explode(ObjMine* this, PlayState* play) { this->actor.scale.x *= 1.8f; - if (this->actor.scale.x > 0.17495999f) { - Actor_MarkForDeath(&this->actor); + if (this->actor.scale.x > 30.0f * 0.001f * CUBE(1.8f)) { + Actor_Kill(&this->actor); } else { this->actor.scale.y = this->actor.scale.x; this->actor.scale.z = this->actor.scale.x; } } -void func_80A832BC(ObjMine* this) { - this->actionFunc = func_80A832D0; +void ObjMine_Air_SetupChained(ObjMine* this) { + this->actionFunc = ObjMine_Air_Chained; } -void func_80A832D0(ObjMine* this, PlayState* play) { +void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { s32 pad; - s32 spA0 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineUnkStruct* unkStruct = &this->chain1; - ObjMineUnkStruct3* temp; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineAirChain* chain1 = &this->chain.air; + ObjMineAirLink* link1; s32 i; f32 sp90; f32 sp8C; f32 sp88; s16 sp86; s16 sp84; - s32 pad2; - s32 pad3; - Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_00.y); - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); + Math_Vec3f_Copy(&chain1->unk_24, &chain1->basis.y); + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - unkStruct->unk_48 = 0.04f; - func_80A8146C(this, &unkStruct->unk_4C, &sp84); + chain1->unk_48 = 0.04f; + ObjMine_Air_CheckAC(this, &chain1->unk_4C, &sp84); sp88 = sp8C = Math_SinS(sp84) * 150.0f; - sp8C = -(sp8C / spA0); + sp8C = -(sp8C / linkCount); - for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { - temp->unk_02 += (s16)sp88; - temp->unk_02 = CLAMP(temp->unk_02, -800, 800); + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + link1->unk_02 += (s16)sp88; + link1->unk_02 = CLAMP(link1->unk_02, -800, 800); sp88 -= sp8C; } } - if (unkStruct->unk_48 > 0.0001f) { - sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; - sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; - unkStruct->unk_38 += sp90; - unkStruct->unk_3C += sp8C; - Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); + if (chain1->unk_48 > 0.0001f) { + sp90 = Math_SinS(chain1->unk_4C) * chain1->unk_48; + sp8C = Math_CosS(chain1->unk_4C) * chain1->unk_48; + chain1->unk_38 += sp90; + chain1->unk_3C += sp8C; + Math_StepToF(&chain1->unk_48, 0.0f, 0.02f); } - if ((Rand_Next() >> 0x1B) == 0) { - unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; - unkStruct->unk_54 = Rand_Next() >> 0x10; + if (RANDU_BITS(5) == 0) { + chain1->unk_50 = Rand_ZeroOne() * chain1->unk_58; + chain1->unk_54 = RANDU_BITS(16); } - sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; - sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; - unkStruct->unk_38 += sp90; - unkStruct->unk_3C += sp8C; + sp90 = Math_SinS(chain1->unk_54) * chain1->unk_50; + sp8C = Math_CosS(chain1->unk_54) * chain1->unk_50; + chain1->unk_38 += sp90; + chain1->unk_3C += sp8C; - unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; - unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; + chain1->unk_38 += chain1->unk_30 * chain1->unk_40; + chain1->unk_3C += chain1->unk_34 * chain1->unk_40; - unkStruct->unk_38 *= unkStruct->unk_44; - unkStruct->unk_3C *= unkStruct->unk_44; + chain1->unk_38 *= chain1->unk_44; + chain1->unk_3C *= chain1->unk_44; - unkStruct->unk_30 += unkStruct->unk_38; - unkStruct->unk_34 += unkStruct->unk_3C; + chain1->unk_30 += chain1->unk_38; + chain1->unk_34 += chain1->unk_3C; - unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); - unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); + chain1->unk_30 = CLAMP(chain1->unk_30, -5.0f, 5.0f); + chain1->unk_34 = CLAMP(chain1->unk_34, -5.0f, 5.0f); - func_80A81A00(this); - func_80A81AA4(this); + ObjMine_Air_SetBasis(this); + ObjMine_Air_SetWorld(this); - if ((unkStruct->unk_5C > -0.000001f) && - (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, - this->actor.home.pos.x, this->actor.home.pos.z))) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + if (chain1->unk_5C > -0.000001f) { + Vec3f* world = &this->actor.world.pos; + Vec3f* home = &this->actor.home.pos; - if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - f32 sp48; - f32 sp44; + if (chain1->unk_5C <= Math3D_XZDistanceSquared(world->x, world->z, home->x, home->z)) { - sp4C.x = unkStruct->unk_38; - sp4C.y = 0.0f; - sp4C.z = unkStruct->unk_3C; - if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { - sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); - sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); - sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - func_80179F64(&sp70, &sp58, &sp64); - sp48 *= 0.5f; - unkStruct->unk_38 = sp64.x * sp48; - unkStruct->unk_3C = sp64.z * sp48; - } else { - unkStruct->unk_38 *= -0.1f; - unkStruct->unk_3C *= -0.1f; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + + if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + sp4C.x = chain1->unk_38; + sp4C.y = 0.0f; + sp4C.z = chain1->unk_3C; + + if (ObjMine_GetUnitVec3fNorm(&sp4C, &sp70, &sp48, &sp44)) { + sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + + func_80179F64(&sp70, &sp58, &sp64); + + sp48 *= 0.5f; + chain1->unk_38 = sp64.x * sp48; + chain1->unk_3C = sp64.z * sp48; + } else { + chain1->unk_38 *= -0.1f; + chain1->unk_3C *= -0.1f; + } + ObjMine_Air_SetChain3034(this); + ObjMine_Air_SetBasis(this); + ObjMine_Air_SetWorld(this); } - func_80A81B14(this); - func_80A81A00(this); - func_80A81AA4(this); } } - for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { - sp86 = temp->unk_00 - 0x4000; - sp88 = temp->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + sp86 = link1->unk_00 - 0x4000; + sp88 = link1->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); sp88 *= 0.995f; - temp->unk_02 = sp88; - temp->unk_00 += temp->unk_02; + link1->unk_02 = sp88; + link1->unk_00 += link1->unk_02; } func_800B4AEC(play, &this->actor, 0.0f); - func_80A81818(this); + ObjMine_UpdateCollider(this); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80A83A74(ObjMine* this) { - this->actionFunc = func_80A83A88; +void ObjMine_Air_SetupStationary(ObjMine* this) { + this->actionFunc = ObjMine_Air_Stationary; } -void func_80A83A88(ObjMine* this, PlayState* play) { - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); +void ObjMine_Air_Stationary(ObjMine* this, PlayState* play) { + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } @@ -912,59 +931,60 @@ void func_80A83A88(ObjMine* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80A83B14(ObjMine* this) { - this->actionFunc = func_80A83B28; +void ObjMine_Water_SetupChained(ObjMine* this) { + this->actionFunc = ObjMine_Water_Chained; } -void func_80A83B28(ObjMine* this, PlayState* play) { - ObjMineTestStruct2* ptr = &this->chain2; +void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { + ObjMineWaterChain* chain2 = &this->chain.water; - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_80A81544(this, &ptr->unk_04); - ptr->unk_10 = 7.0f; - Math_Vec3f_Scale(&ptr->unk_04, 7.0f); + ObjMine_Water_CheckAC(this, &chain2->unk_04); + chain2->unk_10 = 7.0f; + Math_Vec3f_Scale(&chain2->unk_04, 7.0f); } - if (ptr->unk_10 > 0.0001f) { - ptr->unk_10 = Math_Vec3f_StepTo( &ptr->unk_04, &gZeroVec3f, 2.8f); + if (chain2->unk_10 > 0.0001f) { + chain2->unk_10 = Math_Vec3f_StepTo(&chain2->unk_04, &gZeroVec3f, 2.8f); } - ptr->unk_00 = 0.9f; - ptr->unk_24 = -0.0002f; - ptr->unk_30 = -0.0002f; - ptr->unk_1C = 0.003f; - if ((Rand_Next() >> 0x1B) == 0) { - s16 rand = Rand_Next() >> 0x10; + chain2->unk_00 = 0.9f; + chain2->unk_24 = -0.0002f; + chain2->unk_30 = -0.0002f; + chain2->unk_1C = 0.003f; - ptr->unk_14 = Math_SinS(rand) * 1.8f * ptr->unk_1C; - ptr->unk_18 = Math_CosS(rand) * 0.2f * ptr->unk_1C; - ptr->unk_20 = Rand_Next() >> 0x13; + if (RANDU_BITS(5) == 0) { + s16 randAngle = RANDU_BITS(16); + + chain2->unk_14 = Math_SinS(randAngle) * 1.8f * chain2->unk_1C; + chain2->unk_18 = Math_CosS(randAngle) * 0.2f * chain2->unk_1C; + chain2->unk_20 = RANDU_BITS(13); } - func_80A82C28(this, play); - func_80A81DEC(this); - func_80A81818(this); + ObjMine_Water_UpdateChain(this, play); + ObjMine_Water_SetWorld(this); + ObjMine_UpdateCollider(this); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80A83CEC(ObjMine* this) { - this->actionFunc = func_80A83D00; +void ObjMine_Water_SetupStationary(ObjMine* this) { + this->actionFunc = ObjMine_Water_Stationary; } -void func_80A83D00(ObjMine* this, PlayState* play) { - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); +void ObjMine_Water_Stationary(ObjMine* this, PlayState* play) { + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } @@ -973,13 +993,13 @@ void func_80A83D00(ObjMine* this, PlayState* play) { } -void ObjMine_Update(Actor* thisx, PlayState* play) { +void ObjMine_Path_Update(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; if ((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.acFlags & AC_HIT)) { - func_80A8131C(this, play); - func_80A83214(this); + ObjMine_Path_SpawnBomb(this, play); + ObjMine_SetupExplode(this); } this->actionFunc(this, play); @@ -988,26 +1008,26 @@ void ObjMine_Update(Actor* thisx, PlayState* play) { this->collider.base.ocFlags1 &= ~OC1_HIT; this->collider.base.acFlags &= ~AC_HIT; this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - if ((this->actor.flags & 0x40) && (this->actionFunc != func_80A83258)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->actionFunc != ObjMine_Explode)) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80A83E7C(Actor* thisx, PlayState* play) { +void ObjMine_AirWater_Update(Actor* thisx, PlayState* play) { ObjMine* this = THIS; this->actionFunc(this, play); } -void ObjMine_Draw(Actor* thisx, PlayState* play) { +void ObjMine_Path_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; OPEN_DISPS(play->state.gfxCtx); - if (this->actionFunc == func_80A82FC8) { + if (this->actionFunc == ObjMine_Path_Move) { Collider_UpdateSpheres(0, &this->collider); } @@ -1023,12 +1043,12 @@ void ObjMine_Draw(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A83FBC(Actor* thisx, PlayState* play) { - ObjMine* this = THIS; +void ObjMine_DrawExplosion(Actor* thisx, PlayState* play) { + s32 pad; // This could be thisx recast or playstate recast. OPEN_DISPS(play->state.gfxCtx); - func_800B8118(&this->actor, play, 1); + func_800B8118(thisx, play, 1); func_8012C2DC(play->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); @@ -1039,12 +1059,12 @@ void func_80A83FBC(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A84088(Actor* thisx, PlayState* play) { +void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; - s32 temp_s5 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineUnkStruct3* temp; - ObjMineUnkStruct* ptr = &this->chain1; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineAirChain* chain1 = &this->chain.air; + ObjMineAirLink* link1; s32 i; Vec3f sp94; Vec3f sp88; @@ -1059,21 +1079,21 @@ void func_80A84088(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - func_80A81684(&ptr->unk_00); + ObjMine_ReplaceRotation(&chain1->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (temp_s5 != 0) { - Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -6.0f, &sp88); + if (linkCount != 0) { + Math_Vec3f_ScaleAndStore(&chain1->basis.y, -6.0f, &sp88); sp94.x = this->actor.home.pos.x - sp88.x; - sp94.y = (this->actor.home.pos.y - 6.0f) - sp88.y; + sp94.y = this->actor.home.pos.y - 6.0f - sp88.y; sp94.z = this->actor.home.pos.z - sp88.z; - Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -12.0f, &sp88); + Math_Vec3f_ScaleAndStore(&chain1->basis.y, -12.0f, &sp88); - for (i = 0, temp = ptr->unk_60; i < temp_s5; i++, temp++) { - Matrix_RotateYS(temp->unk_00, MTXMODE_APPLY); + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + Matrix_RotateYS(link1->unk_00, MTXMODE_APPLY); sp94.x += sp88.x; sp94.y += sp88.y; sp94.z += sp88.z; - func_80A8164C(&sp94); + ObjMine_ReplaceTranslation(&sp94); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); @@ -1081,7 +1101,7 @@ void func_80A84088(Actor* thisx, PlayState* play) { } Matrix_RotateXS(0x2000, MTXMODE_APPLY); - func_80A8164C(&this->actor.world.pos); + ObjMine_ReplaceTranslation(&this->actor.world.pos); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(gfx++); @@ -1095,14 +1115,14 @@ void func_80A84088(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A84338(Actor* thisx, PlayState* play) { - s32 pad1; +void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { + s32 pad; ObjMine* this = THIS; - s32 temp_s7 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineTestStruct2* pad2 = &this->chain2; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterLink* link2; s32 i; Gfx* gfx; - ObjMineUnkStruct2* temp; func_800B8050(&this->actor, play, 1); @@ -1113,20 +1133,20 @@ void func_80A84338(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - for (i = 0, temp = pad2->unk_44; i < temp_s7; i++, temp++) { - func_80A81684(&temp->unk_00); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); - if ((i & 1) == 0) { + for (i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { + ObjMine_ReplaceRotation(&link2->basis); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if ((i % 2) == 0) { Matrix_RotateYS(0x4000, MTXMODE_APPLY); } - func_80A8164C(&temp->unk_24); + ObjMine_ReplaceTranslation(&link2->unk_24); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); } - Matrix_RotateXS(0x2000, 1); - func_80A8164C(&this->actor.world.pos); + Matrix_RotateXS(0x2000, MTXMODE_APPLY); + ObjMine_ReplaceTranslation(&this->actor.world.pos); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(gfx++); diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 467509cd4..bcee16c65 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,27 +7,33 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); -#define OBJMINE_GET_PARAM_003F(thisx) ((thisx)->params & 0x3F) -#define OBJMINE_GET_PARAM_00FF(thisx) ((thisx)->params & 0xFF) -#define OBJMINE_GET_PARAM_0700(thisx) ((thisx)->params >> 8 & 7) -#define OBJMINE_GET_PARAM_3000(thisx) ((thisx)->params >> 0xC & 3) +#define OBJMINE_GET_LINK_COUNT(thisx) ((thisx)->params & 0x3F) +#define OBJMINE_GET_PATH(thisx) ((thisx)->params & 0xFF) +#define OBJMINE_GET_PATH_SPEED(thisx) (((thisx)->params >> 8) & 7) +#define OBJMINE_GET_TYPE(thisx) (((thisx)->params >> 12) & 3) + +#define OBJMINE_SET_PARAM0(pathIndex, pathSpeed, type) ((pathIndex) | ((pathSpeed) << 8)) +#define OBJMINE_SET_PARAM12(linkCount, type) ((linkCount) | ((type) << 0xC)) + +typedef enum { + /* 0 */ OBJMINE_TYPE_PATH, + /* 1 */ OBJMINE_TYPE_AIR, + /* 2 */ OBJMINE_TYPE_WATER +} ObjMineType; typedef struct { - Vec3f x; - Vec3f y; - Vec3f z; - // Vec3f w; -} ObjMineMtxF3; + /* 0x00 */ Vec3f x; + /* 0x0C */ Vec3f y; + /* 0x18 */ Vec3f z; +} ObjMineMtxF3; // size = 0x24 typedef struct { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; -} ObjMineUnkStruct3; +} ObjMineAirLink; // size = 0x4 typedef struct { - /* 0x00 */ ObjMineMtxF3 unk_00; - // /* 0x0C */ Vec3f unk_0C; - // /* 0x18 */ Vec3f unk_18; + /* 0x00 */ ObjMineMtxF3 basis; /* 0x24 */ Vec3f unk_24; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; @@ -41,49 +47,48 @@ typedef struct { /* 0x54 */ s16 unk_54; /* 0x58 */ f32 unk_58; /* 0x5C */ f32 unk_5C; - /* 0x60 */ ObjMineUnkStruct3* unk_60; -} ObjMineUnkStruct; // size = ?? 0x44??? 48 array??? + /* 0x60 */ ObjMineAirLink links[0x3F]; +} ObjMineAirChain; // size = 0x15C -// probably fake typedef struct { - /* 0x00 */ ObjMineMtxF3 unk_00; - // /* 0x0c */ Vec3f unk_0C; - // /* 0x18 */ Vec3f unk_18; + /* 0x00 */ ObjMineMtxF3 basis; /* 0x24 */ Vec3f unk_24; /* 0x30 */ Vec3f unk_30; /* 0x3C */ Vec3f unk_3C; -} ObjMineUnkStruct2; // size = 0x48??? +} ObjMineWaterLink; // size = 0x48 typedef struct { - f32 unk_00; - Vec3f unk_04; - f32 unk_10; - f32 unk_14; - f32 unk_18; - f32 unk_1C; - s16 unk_20; - f32 unk_24; - f32 unk_28; - f32 unk_2C; - f32 unk_30; - f32 unk_34; - f32 unk_38; - f32 unk_3C; - s8 unk_40; - ObjMineUnkStruct2 unk_44[0x3F]; -} ObjMineTestStruct2; + /* 0x0000 */ f32 unk_00; + /* 0x0004 */ Vec3f unk_04; + /* 0x0010 */ f32 unk_10; + /* 0x0014 */ f32 unk_14; + /* 0x0018 */ f32 unk_18; + /* 0x001C */ f32 unk_1C; + /* 0x0020 */ s16 unk_20; + /* 0x0024 */ f32 unk_24; + /* 0x0028 */ f32 unk_28; + /* 0x002C */ f32 unk_2C; + /* 0x0030 */ f32 unk_30; + /* 0x0034 */ f32 unk_34; + /* 0x0038 */ f32 unk_38; + /* 0x003C */ f32 unk_3C; + /* 0x0040 */ s8 unk_40; + /* 0x0044 */ ObjMineWaterLink links[0x3F]; +} ObjMineWaterChain; // size = 0x11FC typedef struct ObjMine { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderJntSph collider; /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjMineActionFunc actionFunc; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ s32 unk_1AC; - /* 0x01B0 */ s32 unk_1B0; - /* 0x01B4 */ Vec3s* unk_1B4; - // ObjMineTestStruct2 chain2; - union { ObjMineTestStruct2 chain2; ObjMineUnkStruct chain1;}; + /* 0x01A8 */ f32 pathSpeed; + /* 0x01AC */ s32 waypointCount; + /* 0x01B0 */ s32 waypointIndex; + /* 0x01B4 */ Vec3s* waypoints; + /* 0x01B8 */ union { + ObjMineAirChain air; + ObjMineWaterChain water; + } chain; } ObjMine; // size = 0x13B4 #endif // Z_OBJ_MINE_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0e450dfa2..38b9b34da 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11150,53 +11150,53 @@ 0x80A80508:("func_80A80508",), 0x80A80750:("func_80A80750",), 0x80A80904:("func_80A80904",), - 0x80A811D0:("func_80A811D0",), - 0x80A8120C:("func_80A8120C",), - 0x80A81288:("func_80A81288",), - 0x80A8131C:("func_80A8131C",), - 0x80A81384:("func_80A81384",), - 0x80A8140C:("func_80A8140C",), - 0x80A8146C:("func_80A8146C",), - 0x80A81544:("func_80A81544",), - 0x80A81640:("func_80A81640",), - 0x80A8164C:("func_80A8164C",), - 0x80A81684:("func_80A81684",), - 0x80A81714:("func_80A81714",), - 0x80A81818:("func_80A81818",), - 0x80A81868:("func_80A81868",), - 0x80A819A4:("func_80A819A4",), - 0x80A81A00:("func_80A81A00",), - 0x80A81AA4:("func_80A81AA4",), - 0x80A81B14:("func_80A81B14",), - 0x80A81B7C:("func_80A81B7C",), - 0x80A81D70:("func_80A81D70",), - 0x80A81DEC:("func_80A81DEC",), + 0x80A811D0:("ObjMine_Path_MoveToWaypoint",), + 0x80A8120C:("ObjMine_GetUnitVec3f",), + 0x80A81288:("ObjMine_GetUnitVec3fNorm",), + 0x80A8131C:("ObjMine_Path_SpawnBomb",), + 0x80A81384:("ObjMine_AirWater_SpawnBomb",), + 0x80A8140C:("ObjMine_AirWater_CheckOC",), + 0x80A8146C:("ObjMine_Air_CheckAC",), + 0x80A81544:("ObjMine_Water_CheckAC",), + 0x80A81640:("ObjMine_AirWater_Noop",), + 0x80A8164C:("ObjMine_ReplaceTranslation",), + 0x80A81684:("ObjMine_ReplaceRotation",), + 0x80A81714:("ObjMine_StepUntilParallel",), + 0x80A81818:("ObjMine_UpdateCollider",), + 0x80A81868:("ObjMine_Air_InitChain",), + 0x80A819A4:("ObjMine_Air_SetCollider",), + 0x80A81A00:("ObjMine_Air_SetBasis",), + 0x80A81AA4:("ObjMine_Air_SetWorld",), + 0x80A81B14:("ObjMine_Air_SetChain3034",), + 0x80A81B7C:("ObjMine_Water_InitChain",), + 0x80A81D70:("ObjMine_Water_SetCollider",), + 0x80A81DEC:("ObjMine_Water_SetWorld",), 0x80A81E7C:("func_80A81E7C",), 0x80A81FFC:("func_80A81FFC",), 0x80A828A8:("func_80A828A8",), - 0x80A82C28:("func_80A82C28",), + 0x80A82C28:("ObjMine_Water_UpdateChain",), 0x80A82C5C:("ObjMine_Init",), 0x80A82F58:("ObjMine_Destroy",), - 0x80A82F84:("func_80A82F84",), - 0x80A82F98:("func_80A82F98",), - 0x80A82FA8:("func_80A82FA8",), - 0x80A82FC8:("func_80A82FC8",), - 0x80A83214:("func_80A83214",), - 0x80A83258:("func_80A83258",), - 0x80A832BC:("func_80A832BC",), - 0x80A832D0:("func_80A832D0",), - 0x80A83A74:("func_80A83A74",), - 0x80A83A88:("func_80A83A88",), - 0x80A83B14:("func_80A83B14",), - 0x80A83B28:("func_80A83B28",), - 0x80A83CEC:("func_80A83CEC",), - 0x80A83D00:("func_80A83D00",), - 0x80A83D8C:("ObjMine_Update",), - 0x80A83E7C:("func_80A83E7C",), - 0x80A83EA0:("ObjMine_Draw",), - 0x80A83FBC:("func_80A83FBC",), - 0x80A84088:("func_80A84088",), - 0x80A84338:("func_80A84338",), + 0x80A82F84:("ObjMine_Path_SetupStationary",), + 0x80A82F98:("ObjMine_Path_Stationary",), + 0x80A82FA8:("ObjMine_Path_SetupMove",), + 0x80A82FC8:("ObjMine_Path_Move",), + 0x80A83214:("ObjMine_SetupExplode",), + 0x80A83258:("ObjMine_Explode",), + 0x80A832BC:("ObjMine_Air_SetupChained",), + 0x80A832D0:("ObjMine_Air_Chained",), + 0x80A83A74:("ObjMine_Air_SetupStationary",), + 0x80A83A88:("ObjMine_Air_Stationary",), + 0x80A83B14:("ObjMine_Water_SetupChained",), + 0x80A83B28:("ObjMine_Water_Chained",), + 0x80A83CEC:("ObjMine_Water_SetupStationary",), + 0x80A83D00:("ObjMine_Water_Stationary",), + 0x80A83D8C:("ObjMine_Path_Update",), + 0x80A83E7C:("ObjMine_AirWater_Update",), + 0x80A83EA0:("ObjMine_Path_Draw",), + 0x80A83FBC:("ObjMine_DrawExplosion",), + 0x80A84088:("ObjMine_Air_Draw",), + 0x80A84338:("ObjMine_Water_Draw",), 0x80A84CD0:("ObjPurify_SetSysMatrix",), 0x80A84CF8:("ObjPurify_IsPurified",), 0x80A84D68:("ObjPurify_Init",), From 4d783cdd698a4c0020db7b047455592c1644ee68 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Mon, 16 Jan 2023 04:49:16 -0500 Subject: [PATCH 089/130] Attempt all functions --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 500 ++++++++++++++++-- .../actors/ovl_En_Honotrap/z_en_honotrap.h | 9 +- 2 files changed, 461 insertions(+), 48 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 97804d2f4..3e56c0970 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -16,33 +16,44 @@ void EnHonotrap_Destroy(Actor* thisx, PlayState* play); void EnHonotrap_Update(Actor* thisx, PlayState* play); void EnHonotrap_Draw(Actor* thisx, PlayState* play); +void func_8092E5A4(Vec3f* arg0, Vec3f* arg1); +void func_8092E638(EnHonotrap* this, PlayState* play); +void func_8092E840(EnHonotrap* this, PlayState* play); +void func_8092E988(EnHonotrap* this, PlayState* play); +void func_8092EBC0(EnHonotrap* this); void func_8092EBDC(EnHonotrap* this, PlayState* play); +void func_8092EC9C(EnHonotrap* this); void func_8092ECF0(EnHonotrap* this, PlayState* play); +void func_8092EDC0(EnHonotrap* this); void func_8092EDD8(EnHonotrap* this, PlayState* play); +void func_8092EE08(EnHonotrap* this); void func_8092EE1C(EnHonotrap* this, PlayState* play); +void func_8092EE68(EnHonotrap* this); void func_8092EE90(EnHonotrap* this, PlayState* play); +void func_8092EF3C(EnHonotrap* this); void func_8092EF98(EnHonotrap* this, PlayState* play); +void func_8092F05C(EnHonotrap* this); void func_8092F074(EnHonotrap* this, PlayState* play); +void func_8092F0A4(EnHonotrap* this); void func_8092F0B8(EnHonotrap* this, PlayState* play); +void func_8092F0F8(EnHonotrap* this); void func_8092F10C(EnHonotrap* this, PlayState* play); +void func_8092F1A0(EnHonotrap* this); void func_8092F208(EnHonotrap* this, PlayState* play); +void func_8092F34C(EnHonotrap* this); void func_8092F3D8(EnHonotrap* this, PlayState* play); +void func_8092F5AC(EnHonotrap* this); void func_8092F5EC(EnHonotrap* this, PlayState* play); +void func_8092F7A8(EnHonotrap* this); void func_8092F7BC(EnHonotrap* this, PlayState* play); +void func_8092F854(EnHonotrap* this); void func_8092F878(EnHonotrap* this, PlayState* play); - -void func_8092E638(EnHonotrap* this, PlayState* play); // d -void func_8092E840(EnHonotrap* this, PlayState* play); // d -void func_8092E988(EnHonotrap* this, PlayState* play); // d void func_8092FE44(Actor* thisx, PlayState* play); void func_8092FEFC(Actor* thisx, PlayState* play); void func_80930030(Actor* thisx, PlayState* play); void func_80930190(Actor* thisx, PlayState* play); -void func_8092EBC0(EnHonotrap* this); -void func_8092EE68(EnHonotrap* this); -void func_8092F0F8(EnHonotrap* this); -void func_8092F854(EnHonotrap* this); +extern Gfx D_050085F0; #if 0 ActorInit En_Honotrap_InitVars = { @@ -101,9 +112,33 @@ extern ColliderCylinderInit D_809304AC; extern CollisionCheckInfoInit D_809304D8; extern InitChainEntry D_809304E0[]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E510.s") +void func_8092E510(EnHonotrap* this, PlayState* play) { + s32 pad[3]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E5A4.s") + Collider_UpdateCylinder(&this->actor, &this->collider.cyl); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.tris.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.tris.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.tris.base); + this->unk2C0 |= 1; + this->unk2C0 |= 2; + this->unk2C0 |= 4; +} + +void func_8092E5A4(Vec3f* arg0, Vec3f* arg1) { + f32 temp_fv0; + f32 temp_fv1; + + temp_fv0 = Math3D_Vec3fMagnitude(arg1); + if (temp_fv0 < 0.001f) { + arg0->x = arg0->y = 0.0f; + arg0->z = 1.0f; + return; + } + temp_fv1 = 1.0f / temp_fv0; + arg0->x = arg1->x * temp_fv1; + arg0->y = arg1->y * temp_fv1; + arg0->z = arg1->z * temp_fv1; +} // EnHonotrap_InitEye void func_8092E638(EnHonotrap* this, PlayState* play) { @@ -236,19 +271,66 @@ void func_8092EBC0(EnHonotrap* this) { this->unk222 = 3; } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EBDC.s") +void func_8092EBDC(EnHonotrap* this, PlayState* play) { + f32 temp_fv0; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EC9C.s") + if (this->actor.child != NULL) { + this->unk220 = 0xC8; + return; + } + if ((this->unk220 <= 0) && (this->actor.xzDistToPlayer < 750.0f)) { + temp_fv0 = this->actor.playerHeightRel; + if ((temp_fv0 < 0.0f) && (temp_fv0 > -700.0f)) { + temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if ((temp_v0 >= -0x3FFF) && (temp_v0 < 0x4000)) { + func_8092EC9C(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092ECF0.s") +void func_8092EC9C(EnHonotrap* this) { + this->actionFunc = func_8092ECF0; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + this->unk220 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RED_EYE); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EDC0.s") +void func_8092ECF0(EnHonotrap* this, PlayState* play) { + this->unk222 -= 1; + if (this->unk222 <= 0) { + func_8092EDC0(this); + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, + (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, + this->actor.home.pos.y - 10.0f, + (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, + this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, 1); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EDD8.s") +void func_8092EDC0(EnHonotrap* this) { + this->actionFunc = func_8092EDD8; + this->unk222 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EE08.s") +void func_8092EDD8(EnHonotrap* this, PlayState* play) { + if (this->unk220 <= 0) { + func_8092EE08(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EE1C.s") +void func_8092EE08(EnHonotrap* this) { + this->actionFunc = func_8092EE1C; +} + +void func_8092EE1C(EnHonotrap* this, PlayState* play) { + this->unk222 += 1; + if (this->unk222 >= 3) { + func_8092EBC0(this); + this->unk220 = 200; + } +} void func_8092EE68(EnHonotrap* this) { this->unk222 = 3; @@ -257,49 +339,372 @@ void func_8092EE68(EnHonotrap* this) { this->actionFunc = func_8092EE90; } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EE90.s") +void func_8092EE90(EnHonotrap* this, PlayState* play) { + f32 temp_fv0; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EF3C.s") + if ((this->unk220 <= 0) && (this->actor.xzDistToPlayer < 120.0f)) { + temp_fv0 = this->actor.playerHeightRel; + if ((temp_fv0 < 0.0f) && (temp_fv0 > -700.0f)) { + temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + if ((temp_v0 >= -0x3FFF) && (temp_v0 < 0x4000)) { + func_8092EF3C(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092EF98.s") +void func_8092EF3C(EnHonotrap* this) { + Actor_PlaySfxAtPos(&this->actor, 0x2881U); + Actor_SetColorFilter(&this->actor, 0x4000U, 255, 0, 40); + this->unk220 = 0x28; + this->actionFunc = func_8092EF98; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F05C.s") +void func_8092EF98(EnHonotrap* this, PlayState* play) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F074.s") + this->unk222 -= 1; + if (this->unk222 <= 0) { + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, + (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, + this->actor.home.pos.y, + (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, + this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, 4); + func_8092F05C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F0A4.s") +void func_8092F05C(EnHonotrap* this) { + this->actionFunc = func_8092F074; + this->unk222 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F0B8.s") +void func_8092F074(EnHonotrap* this, PlayState* play) { + if (this->unk220 <= 0) { + func_8092F0A4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F0F8.s") +void func_8092F0A4(EnHonotrap* this) { + this->actionFunc = func_8092F0B8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F10C.s") +void func_8092F0B8(EnHonotrap* this, PlayState* play) { + this->unk222 += 1; + if (this->unk222 >= 3) { + func_8092EE68(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F1A0.s") +void func_8092F0F8(EnHonotrap* this) { + this->actionFunc = func_8092F10C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F208.s") +void func_8092F10C(EnHonotrap* this, PlayState* play) { + f32 temp_fv0; + f32 var_fv0; + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F34C.s") + if (this->actor.params == 1) { + var_fv0 = 0.004f; + } else { + var_fv0 = 0.0048f; + } + temp_v0 = Math_StepToF(&this->actor.scale.x, var_fv0, 0.0006f); + temp_fv0 = this->actor.scale.x; + this->actor.scale.y = temp_fv0; + this->actor.scale.z = temp_fv0; + if (temp_v0 != 0) { + if (this->actor.params == 1) { + func_8092F34C(this); + return; + } + func_8092F1A0(this); + } +} +void func_8092F1A0(EnHonotrap* this) { + this->unk220 = 0x28; + this->actor.velocity.y = 1.0f; + this->actor.velocity.x = 2.0f * Math_SinS(this->actor.world.rot.y); + this->actor.velocity.z = 2.0f * Math_CosS(this->actor.world.rot.y); + this->actionFunc = func_8092F208; +} + +void func_8092F208(EnHonotrap* this, PlayState* play) { + if ((this->collider.tris.base.atFlags & 2) || (this->unk220 <= 0)) { + if ((this->collider.tris.base.atFlags & 2) && !(this->collider.tris.base.atFlags & 4)) { + func_800B8D98(play, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 0.0f); + } + this->actor.velocity.z = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.x = 0.0f; + func_8092F7A8(this); + return; + } + if (this->actor.velocity.y > 0.0f) { + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.z += this->actor.velocity.z; + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 12.0f, 0.0f, 5U); + } + if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 1.0f, this->actor.velocity.y) == 0) { + this->actor.velocity.y += 1.0f; + } else { + this->actor.velocity.y = 0.0f; + } + func_8092E510(this, play); +} + +void func_8092F34C(EnHonotrap* this) { + f32 temp_fv1; + + this->actionFunc = func_8092F3D8; + temp_fv1 = 1.0f / (Actor_DistanceToPoint(&this->actor, &this->unk228) + 1.0f); + this->actor.velocity.x = (this->unk228.x - this->actor.world.pos.x) * temp_fv1; + this->actor.velocity.y = (this->unk228.y - this->actor.world.pos.y) * temp_fv1; + this->actor.velocity.z = (this->unk228.z - this->actor.world.pos.z) * temp_fv1; + this->unk220 = 160; + this->unk234 = 0.0f; +} + +#ifdef NON_MATCHING +void func_8092F3D8(EnHonotrap* this, PlayState* play) { + s32 pad; + Vec3f sp60; + + s32 temp_s1; + Player* player; + + Vec3f sp4C; + Vec3f sp40; + Vec3f sp34; + + Math_StepToF(&this->unk234, 13.0f, 0.5f); + sp60.x = fabsf(this->unk234 * this->actor.velocity.x); + sp60.y = fabsf(this->unk234 * this->actor.velocity.y); + sp60.z = fabsf(this->unk234 * this->actor.velocity.z); + temp_s1 = 1; + temp_s1 &= Math_StepToF(&this->actor.world.pos.x, this->unk228.x, sp60.x); + temp_s1 &= Math_StepToF(&this->actor.world.pos.y, this->unk228.y, sp60.y); + temp_s1 &= Math_StepToF(&this->actor.world.pos.z, this->unk228.z, sp60.z); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 0x1DU); + + if (this->collider.tris.base.atFlags & 4) { + player = GET_PLAYER(play); + sp34.x = -player->shieldMf.xz; + sp34.y = -player->shieldMf.yz; + sp34.z = -player->shieldMf.zz; + func_8092E5A4(&sp4C, &sp34); + sp40 = this->actor.velocity; + func_80179F64(&sp40, &sp4C, &this->actor.velocity); + this->actor.speedXZ = this->unk234 * 0.5f; + this->actor.world.rot.y = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + func_8092F7A8(this); + return; + } + if (this->collider.tris.base.atFlags & 2) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_8092F7A8(this); + return; + } + if (this->unk220 <= 0) { + func_8092F7A8(this); + return; + } + func_8092E510(this, play); + if (temp_s1 != 0) { + func_8092F5AC(this); + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F3D8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F5AC.s") +void func_8092F5AC(EnHonotrap* this) { + this->actionFunc = func_8092F5EC; + this->actor.speedXZ = 0.0f; + this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; + this->unk220 = 100; + this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F5EC.s") +void func_8092F5EC(EnHonotrap* this, PlayState* play) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F7A8.s") + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x300); + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.1f); + if (-this->actor.playerHeightRel < 10.0f) { + this->actor.gravity = 0.08f; + } else { + this->actor.gravity = -0.08f; + } + Actor_UpdateVelocityWithGravity(&this->actor); + if (this->actor.velocity.y > 1.0f) { + this->actor.velocity.y = 1.0f; + } + this->actor.velocity.y *= 0.95f; + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 0x1DU); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F7BC.s") + if (this->collider.tris.base.atFlags & 4) { + Player* player = GET_PLAYER(play); + Vec3s sp30; + + Matrix_MtxFToYXZRot(&player->shieldMf, &sp30, 0); + this->actor.world.rot.y = ((sp30.y * 2) - this->actor.world.rot.y) + 0x8000; + func_8092F7A8(this); + } else if (this->collider.tris.base.atFlags & 2) { + this->actor.speedXZ *= 0.1f; + this->actor.velocity.y *= 0.1f; + func_8092F7A8(this); + } else if ((this->actor.bgCheckFlags & 8) || (this->unk220 <= 0)) { + func_8092F7A8(this); + } else { + func_8092E510(this, play); + } +} + +void func_8092F7A8(EnHonotrap* this) { + this->actionFunc = func_8092F7BC; +} + +void func_8092F7BC(EnHonotrap* this, PlayState* play) { + f32 temp_fv0; + s32 sp28 = Math_StepToF(&this->actor.scale.x, 0.0001f, 0.00015f); + temp_fv0 = this->actor.scale.x; + this->actor.scale.y = temp_fv0; + this->actor.scale.z = temp_fv0; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 0x1DU); + if (sp28 != 0) { + Actor_Kill(&this->actor); + } +} void func_8092F854(EnHonotrap* this) { this->actionFunc = func_8092F878; this->unk220 = 0x50; - this->unk23C.unk_08 = 0.0f; + this->unk23C.unk8 = 0.0f; } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F878.s") +void func_8092F878(EnHonotrap* this, PlayState* play) { + s32 var_v0; + EnHonotrap23C* sp98; + f32 var_fs0; + f32 temp_fs0; + f32 temp_fs1; + f32 sp88; + f32 sp84; + f32 sp80; + s32 sp7C; + s32 sp78; + f32 var_fs0_2; + Vec3f sp68; + EnHonotrapArr* var_s0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Update.s") + sp98 = &this->unk23C; + sp78 = 0; + sp80 = fabsf(Math_CosS(Camera_GetCamDirPitch(play->cameraPtrs[play->activeCamId]))); + sp7C = (s32)(sp80 * -10.5f) - 10; + Math_StepToF(&sp98->unk0, 1.0f, 0.05f); + if (this->unk220 <= 40) { + sp78 = Math_StepToF(&sp98->unk4, 1.0f, 0.05f); + } else if (this->actor.parent == NULL) { + this->unk220 = 40; + } + for (var_v0 = 0; var_v0 < 6; var_v0++) { + sp98->unkC[var_v0].unk12 = 0; + } + + sp88 = Math_SinS(this->actor.shape.rot.y) * 120.0f; + sp84 = Math_CosS(this->actor.shape.rot.y) * 120.0f; + + sp98->unk8 += 0.050f * (1.0f - sp98->unk4); + + if (sp98->unk8 > 0.16666667f) { + sp98->unk8 -= 0.16666667f; + } + var_fs0 = sp98->unk4 + sp98->unk8; + + for (var_v0 = 0; var_v0 < 6 && (var_fs0 <= sp98->unk0); var_v0++) { + var_s0 = &sp98->unkC[var_v0]; + var_s0->unk12 = 1; + + var_s0->unk0.x = (f32)((sp88 * var_fs0) + this->actor.world.pos.x); + var_s0->unk0.y = (f32)this->actor.world.pos.y; + var_s0->unk0.z = (f32)((sp84 * var_fs0) + this->actor.world.pos.z); + + var_s0->unkC = Math_SinS((s16)(s32)(var_fs0 * 25486.223f)) * 1.6f; + if (var_s0->unkC > 1.0f) { + var_s0->unkC = 1.0f; + } else if (var_s0->unkC < 0.0f) { + var_s0->unkC = 0.0f; + } + + var_fs0 += 0.16666667f; + var_s0->unkC = (f32)(var_s0->unkC * (0.006f * (((1.0f - sp98->unk4) * 0.8f) + 0.2f))); + var_s0->unk_10 = (s16)(var_s0->unk_10 + sp7C); + var_s0->unk_10 = (s16)(var_s0->unk_10 & 0x1FF); + } + + if ((sp78 != 0) || (this->unk220 <= 0)) { + Actor_Kill(&this->actor); + return; + } + temp_fs0 = sp98->unk0 * 120.0f; + temp_fs1 = sp98->unk4 * 120.0f; + Actor_OffsetOfPointInActorCoords(&this->actor, &sp68, &GET_PLAYER(play)->actor.world.pos); + + if (sp68.z < temp_fs1) { + sp68.z = temp_fs1; + } else if (temp_fs0 < sp68.z) { + sp68.z = temp_fs0; + } + + var_fs0_2 = Math_SinS((s16)(s32)(sp68.z * 212.3852f)) * 1.6f; + if (var_fs0_2 > 1.0f) { + var_fs0_2 = 1.0f; + } + sp80 *= ((1.0f - sp98->unk4) * 0.8f) + 0.2f; + if (sp80 > 0.2f) { + this->collider.cyl.dim.pos.x = + (s16)(s32)((Math_SinS(this->actor.shape.rot.y) * sp68.z) + this->actor.world.pos.x); + this->collider.cyl.dim.pos.y = (s16)(s32)(this->actor.world.pos.y - (24.0f * var_fs0_2)); + this->collider.cyl.dim.pos.z = + (s16)(s32)((Math_CosS(this->actor.shape.rot.y) * sp68.z) + this->actor.world.pos.z); + this->collider.cyl.dim.radius = (s16)(s32)(15.0f * var_fs0_2); + this->collider.cyl.dim.height = (s16)(s32)(37.5f * var_fs0_2); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.tris.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.tris.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.tris.base); + } +} + +extern Vec3f D_809304EC; +extern Vec3f D_809304F8; + +void EnHonotrap_Update(Actor* thisx, PlayState* play) { + EnHonotrap* this = (EnHonotrap*)thisx; + + if (this->unk220 > 0) { + this->unk220 -= 1; + } + if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { + this->actor.child = NULL; + } + this->actionFunc(this, play); + if (this->collider.tris.base.acFlags & 2) { + EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &D_809304EC, &D_809304F8, 15, 8); + Actor_Kill(&this->actor); + return; + } + if (this->unk222 < 3) { + this->collider.tris.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.tris.base); + } +} void func_8092FE44(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; @@ -307,7 +712,7 @@ void func_8092FE44(Actor* thisx, PlayState* play) { if (this->unk220 > 0) { this->unk220--; } - this->unk2C0 = 0; // + 23C + 0x10 + 0x64 + 0x10 = s8 + this->unk2C0 = 0; this->unk238 += 0x640; if (this->actor.params != 4) { this->actor.shape.yOffset = Math_SinS(this->unk238) * 1000.0f + 600.0f; @@ -335,7 +740,16 @@ void func_8092FEFC(Actor* thisx, PlayState* play) { this->actionFunc(this, play); } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Draw.s") +void EnHonotrap_Draw(Actor* thisx, PlayState* play) { + EnHonotrap* this = (EnHonotrap*)thisx; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, D_809303F0[this->unk222]); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &D_050085F0); + CLOSE_DISPS(play->state.gfxCtx); +} void func_80930030(Actor* thisx, PlayState* play) { s32 pad; @@ -365,23 +779,21 @@ void func_80930190(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - func_800DFC90(&spB8, play->cameraPtrs[play->activeCamId]); + Camera_GetCamDir(&spB8, play->cameraPtrs[play->activeCamId]); spB8.y += 0x8000; var_s3 = &this->unk23C; for (i = 0; i < 6; i++) { temp_s0 = &var_s3->unkC[i]; if (temp_s0->unk12 != 0) { - gSPSegment( - POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); Matrix_SetTranslateRotateYXZ(temp_s0->unk0.x, temp_s0->unk0.y - (4000.0f * temp_s0->unkC), temp_s0->unk0.z, &spB8); // temp_fa1 = temp_s0->unkC; Matrix_Scale(((fabsf(Math_SinS((s16)(spB8.y - this->actor.shape.rot.y) >> 1)) * 0.2f) + 1.7f) * temp_s0->unkC, temp_s0->unkC, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } } diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index f53bdac73..d101d9506 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -23,8 +23,9 @@ typedef struct { } EnHonotrapArr; //size 0x14 typedef struct { - char unk0[0x8]; - f32 unk_08; + f32 unk0; + f32 unk4; + f32 unk8; EnHonotrapArr unkC[6]; } EnHonotrap23C; @@ -36,11 +37,11 @@ typedef struct EnHonotrap { /* 0x222 */ s16 unk222; /* 0x224 */ s16 unk224; /* 0x228 */ Vec3f unk228; - /* 0x234 */ char pad234[4]; + /* 0x234 */ f32 unk234; /* 0x238 */ s16 unk238; /* 0x23A */ s16 unk23A; /* 0x23C */ EnHonotrap23C unk23C; - /* 0x2C0 */ s8 unk2C0; + /* 0x2C0 */ u8 unk2C0; } EnHonotrap; // size = 0x2C4 #endif // Z_EN_HONOTRAP_H From 2fdce40d9cc3fd8049ab5ead5d978d29f0453019 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Fri, 3 Feb 2023 09:43:32 -0600 Subject: [PATCH 090/130] documented physics stuff --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 725 +++++++++--------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 122 +-- tools/disasm/functions.txt | 2 +- 3 files changed, 407 insertions(+), 442 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index d83a4a04f..6f828f4ce 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -12,6 +12,15 @@ #define THIS ((ObjMine*)thisx) +#define LINK_SIZE 12.0f +#define ATTACH_OFFSET 10.0f +#define AIR_RADIUS 24.0f +#define WATER_RADIUS 36.0f +#define BOMB_SPAWN_OFFSET 15.0f + +#define RAND_PLUSMINUS(limit) (Rand_ZeroOne()*(2.0f * (limit)) - (limit)) +#define RAND_PLUSMINUSALT(limit) ((Rand_ZeroOne() - 0.5f) * (2.0f * limit)) + void ObjMine_Init(Actor* thisx, PlayState* play); void ObjMine_Destroy(Actor* thisx, PlayState* play); void ObjMine_Path_Update(Actor* thisx, PlayState* play); @@ -97,15 +106,15 @@ void ObjMine_Path_MoveToWaypoint(ObjMine* this, s32 index) { } s32 ObjMine_GetUnitVec3f(Vec3f* src, Vec3f* dst) { - f32 temp_f0 = Math3D_Vec3fMagnitude(src); + f32 mag = Math3D_Vec3fMagnitude(src); - if (temp_f0 < 0.001f) { + if (mag < 0.001f) { return false; } - dst->x = src->x * (1.0f / temp_f0); - dst->y = src->y * (1.0f / temp_f0); - dst->z = src->z * (1.0f / temp_f0); + dst->x = src->x * (1.0f / mag); + dst->y = src->y * (1.0f / mag); + dst->z = src->z * (1.0f / mag); return true; } @@ -162,49 +171,50 @@ s32 ObjMine_AirWater_CheckOC(ObjMine* this) { return false; } -void ObjMine_Air_CheckAC(ObjMine* this, s16* arg1, s16* arg2) { +void ObjMine_Air_CheckAC(ObjMine* this, s16* hitAngle, s16* hitTorque) { s32 pad[2]; Vec3s* centerPos3s = &this->collider.elements[0].dim.worldSphere.center; Vec3f centerPos; - s16 sp3E; + s16 yawToAttack; Actor* attackActor = this->collider.base.ac; Math_Vec3s_ToVec3f(¢erPos, centerPos3s); - sp3E = Math_Vec3f_Yaw(&attackActor->world.pos, ¢erPos); + yawToAttack = Math_Vec3f_Yaw(&attackActor->world.pos, ¢erPos); // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { - *arg1 = attackActor->shape.rot.y; - *arg2 = attackActor->shape.rot.y - sp3E; + *hitAngle = attackActor->shape.rot.y; + *hitTorque = attackActor->shape.rot.y - yawToAttack; } else { Vec3f hitPos; Vec3s* hitPos3s = &this->collider.elements[0].info.bumper.hitPos; Math_Vec3s_ToVec3f(&hitPos, hitPos3s); - *arg1 = Actor_YawBetweenActors(attackActor, &this->actor); - *arg2 = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - sp3E; + *hitAngle = Actor_YawBetweenActors(attackActor, &this->actor); + *hitTorque = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - yawToAttack; } } -void ObjMine_Water_CheckAC(ObjMine* this, Vec3f* arg1) { +void ObjMine_Water_CheckAC(ObjMine* this, Vec3f* knockbackDir) { Actor* attackActor = this->collider.base.ac; - // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) + // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_LIGHT_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if ((this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820)) { Matrix_Push(); Matrix_RotateYS(attackActor->shape.rot.y, MTXMODE_NEW); Matrix_RotateXS(attackActor->shape.rot.x, MTXMODE_APPLY); - Matrix_MultVecZ(1.0f, arg1); + Matrix_MultVecZ(1.0f, knockbackDir); Matrix_Pop(); } else { - Vec3f sp20; + Vec3f posDiff; Sphere16* sphere = &this->collider.elements[0].dim.worldSphere; - sp20.x = sphere->center.x - attackActor->world.pos.x; - sp20.y = sphere->center.y - attackActor->world.pos.y; - sp20.z = sphere->center.z - attackActor->world.pos.z; - if (!ObjMine_GetUnitVec3f(&sp20, arg1)) { - Math_Vec3f_Copy(arg1, &sStandardBasis.y); + posDiff.x = sphere->center.x - attackActor->world.pos.x; + posDiff.y = sphere->center.y - attackActor->world.pos.y; + posDiff.z = sphere->center.z - attackActor->world.pos.z; + + if (!ObjMine_GetUnitVec3f(&posDiff, knockbackDir)) { + Math_Vec3f_Copy(knockbackDir, &sStandardBasis.y); } } } @@ -245,25 +255,25 @@ void ObjMine_ReplaceRotation(ObjMineMtxF3* rotation) { } s32 ObjMine_StepUntilParallel(Vec3f* value, Vec3f* target, f32 angleStep) { - Vec3f sp3C; - Vec3f sp30; - Vec3f sp24; - f32 sp20 = Math3D_Parallel(value, target); + Vec3f perpVec; + Vec3f prevValue; + Vec3f perpNormal; + f32 cosAngle = Math3D_Parallel(value, target); - if (cos_rad(angleStep) <= sp20) { + if (cos_rad(angleStep) <= cosAngle) { Math_Vec3f_Copy(value, target); return true; } Matrix_Push(); - Math_Vec3f_Copy(&sp30, value); - Math3D_CrossProduct(value, target, &sp3C); - if (ObjMine_GetUnitVec3f(&sp3C, &sp24)) { - Matrix_RotateAxisS(RADF_TO_BINANG(angleStep), &sp24, MTXMODE_NEW); - Matrix_MultVec3f(&sp30, value); + Math_Vec3f_Copy(&prevValue, value); + Math3D_CrossProduct(value, target, &perpVec); + if (ObjMine_GetUnitVec3f(&perpVec, &perpNormal)) { + Matrix_RotateAxisS(RADF_TO_BINANG(angleStep), &perpNormal, MTXMODE_NEW); + Matrix_MultVec3f(&prevValue, value); } else { Matrix_RotateXFNew(angleStep); - Matrix_MultVec3f(&sp30, value); + Matrix_MultVec3f(&prevValue, value); } Matrix_Pop(); @@ -277,34 +287,34 @@ void ObjMine_UpdateCollider(ObjMine* this) { } void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { - f32 arg1f = linkCount; - ObjMineAirChain* chain1 = &this->chain.air; - ObjMineAirLink* link1; + f32 linkCountF = linkCount; + ObjMineAirChain* airChain = &this->chain.air; + ObjMineAirLink* airLink; s32 i; - f32 temp_f12 = this->actor.home.rot.z * 5.0f; + f32 wallCheckRadius = this->actor.home.rot.z * 5.0f; - chain1->basis.x.x = 1.0f; - chain1->basis.y.y = 1.0f; - chain1->basis.z.z = 1.0f; - chain1->unk_24.y = 1.0f; + airChain->basis.x.x = 1.0f; + airChain->basis.y.y = 1.0f; + airChain->basis.z.z = 1.0f; + airChain->translation.y = 1.0f; if (linkCount > 0) { - chain1->unk_40 = -sqrtf(0.001984f / arg1f); // approx 1/504 = 1/8 * 1/63 - chain1->unk_44 = 0.95f + (0.00031746097f * arg1f); // approx 1/3150 = 1/50 * 1/63 + airChain->restore = -sqrtf(0.001984f / linkCountF); // approx 1/504 = 1/8 * 1/63 + airChain->drag = 0.95f + (0.00031746097f * linkCountF); // approx 1/3150 = 1/50 * 1/63 } - chain1->unk_58 = 0.0002f; + airChain->wobble = 0.0002f; - for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { - link1->unk_00 = 0x4000; + for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { + airLink->twist = 0x4000; } - if (temp_f12 < 0.0f) { - chain1->unk_5C = -1.0f; - } else if (temp_f12 <= 21.0f) { - chain1->unk_5C = 0.0f; + if (wallCheckRadius < 0.0f) { + airChain->wallCheckDist = -1.0f; + } else if (wallCheckRadius <= 20.0f + 1.0f) { + airChain->wallCheckDist = 0.0f; } else { - chain1->unk_5C = SQ(temp_f12 - 20.0f); + airChain->wallCheckDist = SQ(wallCheckRadius - 20.0f); } } @@ -315,88 +325,88 @@ void ObjMine_Air_SetCollider(ObjMine* this, s32 linkCount) { } void ObjMine_Air_SetBasis(ObjMine* this) { - ObjMineAirChain* chain1 = &this->chain.air; - Vec3f sp28; + ObjMineAirChain* airChain = &this->chain.air; + Vec3f tempVec; - sp28.x = -chain1->unk_30; - sp28.y = 1.0f; - sp28.z = -chain1->unk_34; + tempVec.x = -airChain->xDiff; + tempVec.y = 1.0f; + tempVec.z = -airChain->zDiff; - ObjMine_GetUnitVec3f(&sp28, &chain1->basis.y); - Math3D_CrossProduct(&sStandardBasis.x, &chain1->basis.y, &sp28); - ObjMine_GetUnitVec3f(&sp28, &chain1->basis.z); - Math3D_CrossProduct(&chain1->basis.y, &chain1->basis.z, &sp28); - ObjMine_GetUnitVec3f(&sp28, &chain1->basis.x); + ObjMine_GetUnitVec3f(&tempVec, &airChain->basis.y); + Math3D_CrossProduct(&sStandardBasis.x, &airChain->basis.y, &tempVec); + ObjMine_GetUnitVec3f(&tempVec, &airChain->basis.z); + Math3D_CrossProduct(&airChain->basis.y, &airChain->basis.z, &tempVec); + ObjMine_GetUnitVec3f(&tempVec, &airChain->basis.x); } void ObjMine_Air_SetWorld(ObjMine* this) { s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 temp_f0 = 10.0f + (linkCount * 12.0f); + f32 chainLength = 10.0f + (linkCount * 12.0f); - this->actor.world.pos.x = (this->chain.air.basis.y.x * -temp_f0) + this->actor.home.pos.x; - this->actor.world.pos.y = (this->chain.air.basis.y.y * -temp_f0) + this->actor.home.pos.y; - this->actor.world.pos.z = (this->chain.air.basis.y.z * -temp_f0) + this->actor.home.pos.z; + this->actor.world.pos.x = (this->chain.air.basis.y.x * -chainLength) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->chain.air.basis.y.y * -chainLength) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->chain.air.basis.y.z * -chainLength) + this->actor.home.pos.z; } void ObjMine_Air_SetChain3034(ObjMine* this) { s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 temp_f0 = 1.0f / (10.0f + (linkCount * 12.0f)); + f32 invLength = 1.0f / (10.0f + (linkCount * 12.0f)); f32 dx = this->actor.world.pos.x - this->actor.home.pos.x; f32 dz = this->actor.world.pos.z - this->actor.home.pos.z; - this->chain.air.unk_30 = dx * temp_f0; - this->chain.air.unk_34 = dz * temp_f0; + this->chain.air.xDiff = dx * invLength; + this->chain.air.zDiff = dz * invLength; } void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { - ObjMineWaterChain* chain2 = &this->chain.water; - ObjMineWaterLink* link2; + ObjMineWaterChain* waterChain = &this->chain.water; + ObjMineWaterLink* waterLink; s32 i; - f32 sp58 = this->actor.home.rot.z * 5.0f; - f32 temp_f24; - f32 temp_f26; + f32 wallCheckRadius = this->actor.home.rot.z * 5.0f; + f32 linkY; + f32 wobbleVel; - chain2->unk_00 = 0.9f; - chain2->unk_1C = 0.003f; + waterChain->drag = 0.9f; + waterChain->wobble = 0.003f; - chain2->unk_20 = RANDU_BITS(13); - chain2->unk_24 = -0.0002f; - chain2->unk_30 = -0.0002f; + waterChain->wobblePhaseVel = RANDU_BITS(13); + waterChain->restoreX = -0.0002f; + waterChain->restoreY = -0.0002f; - temp_f26 = chain2->unk_1C * 6.0f; - temp_f24 = this->actor.home.pos.y; + wobbleVel = waterChain->wobble * 6.0f; + linkY = this->actor.home.pos.y; - for (i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { - temp_f24 += 12.0f; - link2->basis.x.x = 1.0f; - link2->basis.y.y = 1.0f; - link2->basis.z.z = 1.0f; - link2->unk_24.x = this->actor.home.pos.x; - link2->unk_24.y = temp_f24; - link2->unk_24.z = this->actor.home.pos.z; - link2->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; - link2->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; - link2->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; + for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + linkY += 12.0f; + waterLink->basis.x.x = 1.0f; + waterLink->basis.y.y = 1.0f; + waterLink->basis.z.z = 1.0f; + waterLink->pos.x = this->actor.home.pos.x; + waterLink->pos.y = linkY; + waterLink->pos.z = this->actor.home.pos.z; + waterLink->vel.x = (Rand_ZeroOne() - 0.5f) * wobbleVel; + waterLink->vel.y = (Rand_ZeroOne() - 0.5f) * wobbleVel; + waterLink->vel.z = (Rand_ZeroOne() - 0.5f) * wobbleVel; + } + waterChain->maxY = linkY; + + waterChain->restY = waterChain->maxY * 0.97f; + linkY -= 18.0f; + + if (waterChain->restY < linkY) { + waterChain->restY = linkY; } - chain2->unk_28 = temp_f24; - chain2->unk_2C = temp_f24 * 0.97f; - temp_f24 -= 18.0f; - - if (chain2->unk_2C < temp_f24) { - chain2->unk_2C = temp_f24; - } - - if (sp58 < 0.0f) { - chain2->unk_34 = -1.0f; - } else if (sp58 <= 37.0f) { - chain2->unk_34 = 0.0f; + if (wallCheckRadius < 0.0f) { + waterChain->wallCheckDist = -1.0f; + } else if (wallCheckRadius <= 36.0f + 1.0f) { + waterChain->wallCheckDist = 0.0f; } else { - chain2->unk_34 = SQ(sp58 - 36.0f); + waterChain->wallCheckDist = SQ(wallCheckRadius - 36.0f); } } -void ObjMine_Water_SetCollider(ObjMine* this, s32 linkCount) { +void ObjMine_Water_InitCollider(ObjMine* this, s32 linkCount) { Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (linkCount * 12.0f) + 10.0f, this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -406,227 +416,227 @@ void ObjMine_Water_SetCollider(ObjMine* this, s32 linkCount) { void ObjMine_Water_SetWorld(ObjMine* this) { s32 pad; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterChain* waterChain = &this->chain.water; if (linkCount == 0) { this->actor.world.pos.y = this->actor.home.pos.y + 12.0f + 10.0f; } else { - ObjMineWaterLink* link2 = &chain2->links[linkCount - 1]; - Vec3f sp1C; + ObjMineWaterLink* lastLink = &waterChain->links[linkCount - 1]; + Vec3f mineOffset; - Math_Vec3f_ScaleAndStore(&link2->basis.y, 10.0f, &sp1C); - Math_Vec3f_Sum(&link2->unk_24, &sp1C, &this->actor.world.pos); + Math_Vec3f_ScaleAndStore(&lastLink->basis.y, 10.0f, &mineOffset); + Math_Vec3f_Sum(&lastLink->pos, &mineOffset, &this->actor.world.pos); } } -void func_80A81E7C(ObjMine* this, PlayState* play) { +void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { s32 pad; - ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterChain* waterChain = &this->chain.water; - chain2->unk_40 = false; - if ((-0.000001f < chain2->unk_34) && (chain2->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, - this->actor.world.pos.x, this->actor.world.pos.z))) { - Vec3f sp7C; - Vec3f sp70; - Vec3f sp64; - Vec3f xzDistFromHome; - Vec3f xzDirFromHome; - CollisionPoly* dummyPoly; - s32 dummyBgId; - f32 dummyNorm; - f32 dummyInvNorm; + waterChain->touchWall = false; + if (waterChain->wallCheckDist > -1e-6f) { + if (waterChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + this->actor.world.pos.x, this->actor.world.pos.z)) { + Vec3f centerPos; + Vec3f offsetPos; + Vec3f dummyResult; + Vec3f xzDistFromHome; + Vec3f xzDirFromHome; + CollisionPoly* dummyPoly; + s32 dummyBgId; + f32 dummyNorm; + f32 dummyInvNorm; - xzDistFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; - xzDistFromHome.y = 0.0f; - xzDistFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; + xzDistFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; + xzDistFromHome.y = 0.0f; + xzDistFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (ObjMine_GetUnitVec3fNorm(&xzDistFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { + if (ObjMine_GetUnitVec3fNorm(&xzDistFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { - sp70.x = this->actor.world.pos.x + (xzDirFromHome.x * 36.0f); - sp70.y = this->actor.world.pos.y; - sp70.z = this->actor.world.pos.z + (xzDirFromHome.z * 36.0f); + offsetPos.x = this->actor.world.pos.x + (xzDirFromHome.x * 36.0f); + offsetPos.y = this->actor.world.pos.y; + offsetPos.z = this->actor.world.pos.z + (xzDirFromHome.z * 36.0f); - sp7C.x = this->actor.home.pos.x; - sp7C.y = this->actor.world.pos.y; - sp7C.z = this->actor.home.pos.z; + centerPos.x = this->actor.home.pos.x; + centerPos.y = this->actor.world.pos.y; + centerPos.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &dummyPoly, 1, 0, 0, 1, &dummyBgId)) { - chain2->unk_40 = true; - chain2->unk_38 = xzDirFromHome.x * -0.2f; - chain2->unk_3C = xzDirFromHome.z * -0.2f; + if (BgCheck_EntityLineTest1(&play->colCtx, ¢erPos, &offsetPos, &dummyResult, &dummyPoly, true, false, false, true, &dummyBgId)) { + waterChain->touchWall = true; + waterChain->wallEjectX = xzDirFromHome.x * -0.2f; + waterChain->wallEjectZ = xzDirFromHome.z * -0.2f; + } } } } } -#ifdef NON_MATCHING +#if 0 // Probably equivalent, but nightmare loop unrolls. -void func_80A81FFC(ObjMine *this) { - static Vec3f D_80A849D0[0x40]; - ObjMineWaterChain *chain2 = &this->chain.water; - ObjMineWaterLink *link2; +void ObjMine_Water_ApplyForces(ObjMine *this) { + static Vec3f sLinkAccel[0x40]; + ObjMineWaterChain *waterChain = &this->chain.water; + ObjMineWaterLink *waterLink; s32 i; - s16 var_s3; + s16 wobblePhase; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 invLinkCount = 1.0f / (f32) linkCount; - f32 temp_fs0 = (chain2->links[linkCount - 1].unk_24.y - chain2->unk_2C) * chain2->unk_30; - Vec3f sp90; - f32 temp_ft4; + f32 inverseCount = 1.0f / (f32) linkCount; + f32 restoreY = (waterChain->links[linkCount - 1].pos.y - waterChain->restY) * waterChain->restoreY; + Vec3f tension; + f32 scaledKnockback; - for(i = 0, link2 = chain2->links, var_s3 = 0; i < linkCount; i++, link2++, var_s3 += chain2->unk_20) { - Math_Vec3f_Copy(&D_80A849D0[i], &link2->unk_3C); - if (link2->unk_24.y <= this->actor.home.pos.y) { - link2->unk_3C.y = chain2->unk_30 * -96.0f; - } else if (temp_fs0 > 0.0f) { - link2->unk_3C.y = (i + 1) * invLinkCount * (temp_fs0 / 0.3f); + for(i = 0, waterLink = waterChain->links, wobblePhase = 0; i < linkCount; i++, waterLink++, wobblePhase += waterChain->wobblePhaseVel) { + Math_Vec3f_Copy(&sLinkAccel[i], &waterLink->accel); + if (waterLink->pos.y <= this->actor.home.pos.y) { + waterLink->accel.y = waterChain->restoreY * -96.0f; + } else if (restoreY > 0.0f) { + waterLink->accel.y = (i + 1) * inverseCount * (restoreY / 0.3f); } else { - link2->unk_3C.y = temp_fs0; + waterLink->accel.y = restoreY; } - link2->unk_3C.x = (link2->unk_24.x - this->actor.home.pos.x) * chain2->unk_24; - link2->unk_3C.z = (link2->unk_24.z - this->actor.home.pos.z) * chain2->unk_24; - link2->unk_3C.x += chain2->unk_14 * Math_SinS(var_s3); - link2->unk_3C.y += chain2->unk_18; - link2->unk_3C.z += chain2->unk_14 * Math_CosS(var_s3); + waterLink->accel.x = (waterLink->pos.x - this->actor.home.pos.x) * waterChain->restoreX; + waterLink->accel.z = (waterLink->pos.z - this->actor.home.pos.z) * waterChain->restoreX; + waterLink->accel.x += waterChain->wobbleXZ * Math_SinS(wobblePhase); + waterLink->accel.y += waterChain->wobbleY; + waterLink->accel.z += waterChain->wobbleXZ * Math_CosS(wobblePhase); } - if (chain2->unk_10 > 0.0001f) { - for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { - temp_ft4 = SQ((linkCount - i) * invLinkCount); + if (waterChain->knockback > 0.0001f) { + for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + scaledKnockback = SQ((linkCount - i) * inverseCount); - link2->unk_3C.x += chain2->unk_04.x * temp_ft4; - link2->unk_3C.y += chain2->unk_04.y * temp_ft4; - link2->unk_3C.z += chain2->unk_04.z * temp_ft4; + waterLink->accel.x += waterChain->knockbackDir.x * scaledKnockback; + waterLink->accel.y += waterChain->knockbackDir.y * scaledKnockback; + waterLink->accel.z += waterChain->knockbackDir.z * scaledKnockback; } } - if (chain2->unk_40) { - for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { - link2->unk_3C.x += chain2->unk_38; - link2->unk_3C.z += chain2->unk_3C; + if (waterChain->touchWall) { + for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + waterLink->accel.x += waterChain->wallEjectX; + waterLink->accel.z += waterChain->wallEjectZ; } } - for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { - Math_Vec3f_Copy(&sp90, &gZeroVec3f); + for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + Math_Vec3f_Copy(&tension, &gZeroVec3f); if(i - 2 >= 0) { - sp90.x += D_80A849D0[i - 2].x * 0.075f; - sp90.y += D_80A849D0[i - 2].y * 0.075f; - sp90.z += D_80A849D0[i - 2].z * 0.075f; + tension.x += sLinkAccel[i - 2].x * 0.075f; + tension.y += sLinkAccel[i - 2].y * 0.075f; + tension.z += sLinkAccel[i - 2].z * 0.075f; } if(i - 1 >= 0) { - sp90.x += D_80A849D0[i - 1].x * 0.15f; - sp90.y += D_80A849D0[i - 1].y * 0.15f; - sp90.z += D_80A849D0[i - 1].z * 0.15f; + tension.x += sLinkAccel[i - 1].x * 0.15f; + tension.y += sLinkAccel[i - 1].y * 0.15f; + tension.z += sLinkAccel[i - 1].z * 0.15f; } - sp90.x += D_80A849D0[i].x * 0.3f; - sp90.y += D_80A849D0[i].y * 0.3f; - sp90.z += D_80A849D0[i].z * 0.3f; + tension.x += sLinkAccel[i].x * 0.3f; + tension.y += sLinkAccel[i].y * 0.3f; + tension.z += sLinkAccel[i].z * 0.3f; if(i + 1 < linkCount) { - sp90.x += D_80A849D0[i + 1].x * 0.15f; - sp90.y += D_80A849D0[i + 1].y * 0.15f; - sp90.z += D_80A849D0[i + 1].z * 0.15f; + tension.x += sLinkAccel[i + 1].x * 0.15f; + tension.y += sLinkAccel[i + 1].y * 0.15f; + tension.z += sLinkAccel[i + 1].z * 0.15f; } if(i + 2 < linkCount) { - sp90.x += D_80A849D0[i + 2].x * 0.075f; - sp90.y += D_80A849D0[i + 2].y * 0.075f; - sp90.z += D_80A849D0[i + 2].z * 0.075f; + tension.x += sLinkAccel[i + 2].x * 0.075f; + tension.y += sLinkAccel[i + 2].y * 0.075f; + tension.z += sLinkAccel[i + 2].z * 0.075f; } - link2->unk_3C.x += sp90.x; - link2->unk_3C.y += sp90.y; - link2->unk_3C.z += sp90.z; + waterLink->accel.x += tension.x; + waterLink->accel.y += tension.y; + waterLink->accel.z += tension.z; } } #else Vec3f D_80A849D0[0x40]; -void func_80A81FFC(ObjMine* this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") +void ObjMine_Water_ApplyForces(ObjMine* this); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Water_ApplyForces.s") #endif -void func_80A828A8(ObjMine* this) { +void ObjMine_Water_UpdateLinks(ObjMine* this) { s32 pad; - Vec3f spE0; - Vec3f spD4; - Vec3f spC8; - s32 spC4 = OBJMINE_GET_LINK_COUNT(&this->actor); - ObjMineWaterChain* chain2 = &this->chain.water; - ObjMineWaterLink* link2; + ObjMineMtxF3 newBasis; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* waterChain = &this->chain.water; + ObjMineWaterLink* waterLink; s32 i; - Vec3f* phi_s3; - Vec3f spA8; - Vec3f sp9C; - Vec3f sp90; - Vec3f sp84; - s32 phi_s5; - f32 sp7C; - f32 sp78; - Vec3f* phi_x; + Vec3f* lastBasisX; + Vec3f tempVec; + Vec3f diffDir; + Vec3f unusedLinkPos; + Vec3f lastLinkPos; + s32 changeBasis; + f32 diffNorm; + f32 dummyInvNorm; + Vec3f* tempBasisX; - sp84.x = this->actor.home.pos.x; - sp84.y = this->actor.home.pos.y + 6.0f; - sp84.z = this->actor.home.pos.z; + lastLinkPos.x = this->actor.home.pos.x; + lastLinkPos.y = this->actor.home.pos.y + 6.0f; + lastLinkPos.z = this->actor.home.pos.z; - for (i = 0, phi_s3 = NULL, link2 = chain2->links; i < spC4; i++, phi_s3 = &link2->basis.x, link2++) { - phi_s5 = false; + for (i = 0, lastBasisX = NULL, waterLink = waterChain->links; i < linkCount; i++, lastBasisX = &waterLink->basis.x, waterLink++) { + changeBasis = false; - link2->unk_30.x += link2->unk_3C.x; - link2->unk_30.y += link2->unk_3C.y; - link2->unk_30.z += link2->unk_3C.z; + waterLink->vel.x += waterLink->accel.x; + waterLink->vel.y += waterLink->accel.y; + waterLink->vel.z += waterLink->accel.z; - Math_Vec3f_Scale(&link2->unk_30, chain2->unk_00); - Math_Vec3f_Copy(&sp90, &link2->unk_24); + Math_Vec3f_Scale(&waterLink->vel, waterChain->drag); + Math_Vec3f_Copy(&unusedLinkPos, &waterLink->pos); - link2->unk_24.x += link2->unk_30.x; - link2->unk_24.y += link2->unk_30.y; - link2->unk_24.z += link2->unk_30.z; + waterLink->pos.x += waterLink->vel.x; + waterLink->pos.y += waterLink->vel.y; + waterLink->pos.z += waterLink->vel.z; - if ((link2->unk_24.y <= this->actor.home.pos.y) && (link2->unk_30.y < 0.0f)) { - link2->unk_30.y *= 0.1f; + if ((waterLink->pos.y <= this->actor.home.pos.y) && (waterLink->vel.y < 0.0f)) { + waterLink->vel.y *= 0.1f; } - Math_Vec3f_Diff(&link2->unk_24, &sp84, &spA8); + Math_Vec3f_Diff(&waterLink->pos, &lastLinkPos, &tempVec); - if (ObjMine_GetUnitVec3fNorm(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { - Math_Vec3f_Copy(&spD4, &link2->basis.y); - ObjMine_StepUntilParallel(&spD4, &sp9C, M_PI / 30); - phi_x = (phi_s3 == NULL) ? &sStandardBasis.x : phi_s3; + if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &dummyInvNorm) && (diffNorm > 4.0f)) { + Math_Vec3f_Copy(&newBasis.y, &waterLink->basis.y); + ObjMine_StepUntilParallel(&newBasis.y, &diffDir, M_PI / 30); + tempBasisX = (lastBasisX == NULL) ? &sStandardBasis.x : lastBasisX; - Math3D_CrossProduct(phi_x, &spD4, &spA8); + Math3D_CrossProduct(tempBasisX, &newBasis.y, &tempVec); - if (ObjMine_GetUnitVec3f(&spA8, &spE0)) { - Math3D_CrossProduct(&spD4, &spE0, &spA8); - if (ObjMine_GetUnitVec3f(&spA8, &spC8)) { - phi_s5 = true; + if (ObjMine_GetUnitVec3f(&tempVec, &newBasis.z)) { + Math3D_CrossProduct(&newBasis.y, &newBasis.z, &tempVec); + if (ObjMine_GetUnitVec3f(&tempVec, &newBasis.x)) { + changeBasis = true; } } } - if (phi_s5) { - Math_Vec3f_Copy(&link2->basis.x, &spC8); - Math_Vec3f_Copy(&link2->basis.y, &spD4); - Math_Vec3f_Copy(&link2->basis.z, &spE0); + if (changeBasis) { + Math_Vec3f_Copy(&waterLink->basis.x, &newBasis.x); + Math_Vec3f_Copy(&waterLink->basis.y, &newBasis.y); + Math_Vec3f_Copy(&waterLink->basis.z, &newBasis.z); } else { - sp7C = 4.0f; + diffNorm = 4.0f; } - if (sp7C >= 6.0f) { - link2->unk_24.x = sp84.x + (link2->basis.y.x * 6.0f); - link2->unk_24.y = sp84.y + (link2->basis.y.y * 6.0f); - link2->unk_24.z = sp84.z + (link2->basis.y.z * 6.0f); + if (diffNorm >= 6.0f) { + waterLink->pos.x = lastLinkPos.x + (waterLink->basis.y.x * 6.0f); + waterLink->pos.y = lastLinkPos.y + (waterLink->basis.y.y * 6.0f); + waterLink->pos.z = lastLinkPos.z + (waterLink->basis.y.z * 6.0f); } else { - link2->unk_24.x = sp84.x + (link2->basis.y.x * sp7C); - link2->unk_24.y = sp84.y + (link2->basis.y.y * sp7C); - link2->unk_24.z = sp84.z + (link2->basis.y.z * sp7C); + waterLink->pos.x = lastLinkPos.x + (waterLink->basis.y.x * diffNorm); + waterLink->pos.y = lastLinkPos.y + (waterLink->basis.y.y * diffNorm); + waterLink->pos.z = lastLinkPos.z + (waterLink->basis.y.z * diffNorm); } - sp84.x = link2->unk_24.x + (link2->basis.y.x * 6.0f); - sp84.y = link2->unk_24.y + (link2->basis.y.y * 6.0f); - sp84.z = link2->unk_24.z + (link2->basis.y.z * 6.0f); + lastLinkPos.x = waterLink->pos.x + (waterLink->basis.y.x * 6.0f); + lastLinkPos.y = waterLink->pos.y + (waterLink->basis.y.y * 6.0f); + lastLinkPos.z = waterLink->pos.z + (waterLink->basis.y.z * 6.0f); } } void ObjMine_Water_UpdateChain(ObjMine* this, PlayState* play) { - func_80A81E7C(this, play); - func_80A81FFC(this); - func_80A828A8(this); + ObjMine_Water_WallCheck(this, play); + ObjMine_Water_ApplyForces(this); // ObjMine_Water_ApplyForces + ObjMine_Water_UpdateLinks(this); } void ObjMine_Init(Actor* thisx, PlayState* play) { @@ -691,7 +701,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { this->actor.draw = ObjMine_Water_Draw; ObjMine_Water_InitChain(this, linkCount); this->actor.world.pos.y = 10.0f + (linkCount * 12.0f) + this->actor.home.pos.y; - ObjMine_Water_SetCollider(this, linkCount); + ObjMine_Water_InitCollider(this, linkCount); if (linkCount == 0) { ObjMine_Water_SetupStationary(this); } else { @@ -796,16 +806,15 @@ void ObjMine_Air_SetupChained(ObjMine* this) { void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { s32 pad; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - ObjMineAirChain* chain1 = &this->chain.air; - ObjMineAirLink* link1; + ObjMineAirChain* airChain = &this->chain.air; + ObjMineAirLink* airLink; s32 i; - f32 sp90; - f32 sp8C; - f32 sp88; - s16 sp86; - s16 sp84; + f32 xAccel; + f32 zAccel; + f32 torque; + s16 twistDiff; - Math_Vec3f_Copy(&chain1->unk_24, &chain1->basis.y); + Math_Vec3f_Copy(&airChain->translation, &airChain->basis.y); if (ObjMine_AirWater_CheckOC(this)) { ObjMine_AirWater_SpawnBomb(this, play); ObjMine_AirWater_Noop(this); @@ -813,86 +822,90 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { return; } - if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.base.acFlags & AC_HIT) { // initial knockback calc + s16 torqueAngle; + f32 torque; + f32 torqueDiff; + this->collider.base.acFlags &= ~AC_HIT; - chain1->unk_48 = 0.04f; - ObjMine_Air_CheckAC(this, &chain1->unk_4C, &sp84); - sp88 = sp8C = Math_SinS(sp84) * 150.0f; - sp8C = -(sp8C / linkCount); + airChain->knockback = 0.04f; + ObjMine_Air_CheckAC(this, &airChain->knockbackAngle, &torqueAngle); + torque = Math_SinS(torqueAngle) * 150.0f; + torqueDiff = -(torque / linkCount); - for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { - link1->unk_02 += (s16)sp88; - link1->unk_02 = CLAMP(link1->unk_02, -800, 800); - sp88 -= sp8C; + for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { + airLink->spin += (s16)torque; + airLink->spin = CLAMP(airLink->spin, -800, 800); + torque -= torqueDiff; } } - if (chain1->unk_48 > 0.0001f) { - sp90 = Math_SinS(chain1->unk_4C) * chain1->unk_48; - sp8C = Math_CosS(chain1->unk_4C) * chain1->unk_48; - chain1->unk_38 += sp90; - chain1->unk_3C += sp8C; - Math_StepToF(&chain1->unk_48, 0.0f, 0.02f); + if (airChain->knockback > 0.0001f) { // residual knockback calc + xAccel = Math_SinS(airChain->knockbackAngle) * airChain->knockback; + zAccel = Math_CosS(airChain->knockbackAngle) * airChain->knockback; + airChain->xVel += xAccel; + airChain->zVel += zAccel; + Math_StepToF(&airChain->knockback, 0.0f, 0.02f); } - if (RANDU_BITS(5) == 0) { - chain1->unk_50 = Rand_ZeroOne() * chain1->unk_58; - chain1->unk_54 = RANDU_BITS(16); + if (RANDU_BITS(5) == 0) { // wobble + airChain->wobbleSize = Rand_ZeroOne() * airChain->wobble; + airChain->wobblePhase = RANDU_BITS(16); } - sp90 = Math_SinS(chain1->unk_54) * chain1->unk_50; - sp8C = Math_CosS(chain1->unk_54) * chain1->unk_50; - chain1->unk_38 += sp90; - chain1->unk_3C += sp8C; + xAccel = Math_SinS(airChain->wobblePhase) * airChain->wobbleSize; + zAccel = Math_CosS(airChain->wobblePhase) * airChain->wobbleSize; + airChain->xVel += xAccel; + airChain->zVel += zAccel; - chain1->unk_38 += chain1->unk_30 * chain1->unk_40; - chain1->unk_3C += chain1->unk_34 * chain1->unk_40; + airChain->xVel += airChain->xDiff * airChain->restore; + airChain->zVel += airChain->zDiff * airChain->restore; - chain1->unk_38 *= chain1->unk_44; - chain1->unk_3C *= chain1->unk_44; + airChain->xVel *= airChain->drag; + airChain->zVel *= airChain->drag; - chain1->unk_30 += chain1->unk_38; - chain1->unk_34 += chain1->unk_3C; + airChain->xDiff += airChain->xVel; + airChain->zDiff += airChain->zVel; - chain1->unk_30 = CLAMP(chain1->unk_30, -5.0f, 5.0f); - chain1->unk_34 = CLAMP(chain1->unk_34, -5.0f, 5.0f); + airChain->xDiff = CLAMP(airChain->xDiff, -5.0f, 5.0f); + airChain->zDiff = CLAMP(airChain->zDiff, -5.0f, 5.0f); ObjMine_Air_SetBasis(this); ObjMine_Air_SetWorld(this); - if (chain1->unk_5C > -0.000001f) { - Vec3f* world = &this->actor.world.pos; - Vec3f* home = &this->actor.home.pos; + if (airChain->wallCheckDist > -1e-6f) { + // Vec3f* world = &this->actor.world.pos; + // Vec3f* home = &this->actor.home.pos; - if (chain1->unk_5C <= Math3D_XZDistanceSquared(world->x, world->z, home->x, home->z)) { + if (airChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z)) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - f32 sp48; - f32 sp44; + Vec3f xzDir; + Vec3f reflectedDir; + Vec3f wallNormal; + Vec3f xzVel; + f32 xzSpeed; + f32 dummyInvNorm; - sp4C.x = chain1->unk_38; - sp4C.y = 0.0f; - sp4C.z = chain1->unk_3C; + xzVel.x = airChain->xVel; + xzVel.y = 0.0f; + xzVel.z = airChain->zVel; - if (ObjMine_GetUnitVec3fNorm(&sp4C, &sp70, &sp48, &sp44)) { - sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); - sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); - sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + if (ObjMine_GetUnitVec3fNorm(&xzVel, &xzDir, &xzSpeed, &dummyInvNorm)) { + wallNormal.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + wallNormal.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + wallNormal.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - func_80179F64(&sp70, &sp58, &sp64); + func_80179F64(&xzDir, &wallNormal, &reflectedDir); - sp48 *= 0.5f; - chain1->unk_38 = sp64.x * sp48; - chain1->unk_3C = sp64.z * sp48; + xzSpeed /= 2.0f; + airChain->xVel = reflectedDir.x * xzSpeed; + airChain->zVel = reflectedDir.z * xzSpeed; } else { - chain1->unk_38 *= -0.1f; - chain1->unk_3C *= -0.1f; + airChain->xVel *= -0.1f; + airChain->zVel *= -0.1f; } ObjMine_Air_SetChain3034(this); ObjMine_Air_SetBasis(this); @@ -901,12 +914,12 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { } } - for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { - sp86 = link1->unk_00 - 0x4000; - sp88 = link1->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); - sp88 *= 0.995f; - link1->unk_02 = sp88; - link1->unk_00 += link1->unk_02; + for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { + twistDiff = airLink->twist - 0x4000; + torque = airLink->spin + (twistDiff * -0.05f) + RAND_PLUSMINUS(15.0f); + torque *= 0.995f; + airLink->spin = torque; + airLink->twist += airLink->spin; } func_800B4AEC(play, &this->actor, 0.0f); @@ -936,7 +949,7 @@ void ObjMine_Water_SetupChained(ObjMine* this) { } void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { - ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterChain* waterChain = &this->chain.water; if (ObjMine_AirWater_CheckOC(this)) { ObjMine_AirWater_SpawnBomb(this, play); @@ -947,26 +960,26 @@ void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - ObjMine_Water_CheckAC(this, &chain2->unk_04); - chain2->unk_10 = 7.0f; - Math_Vec3f_Scale(&chain2->unk_04, 7.0f); + ObjMine_Water_CheckAC(this, &waterChain->knockbackDir); + waterChain->knockback = 7.0f; + Math_Vec3f_Scale(&waterChain->knockbackDir, 7.0f); } - if (chain2->unk_10 > 0.0001f) { - chain2->unk_10 = Math_Vec3f_StepTo(&chain2->unk_04, &gZeroVec3f, 2.8f); + if (waterChain->knockback > 0.0001f) { + waterChain->knockback = Math_Vec3f_StepTo(&waterChain->knockbackDir, &gZeroVec3f, 2.8f); } - chain2->unk_00 = 0.9f; - chain2->unk_24 = -0.0002f; - chain2->unk_30 = -0.0002f; - chain2->unk_1C = 0.003f; + waterChain->drag = 0.9f; + waterChain->restoreX = -0.0002f; + waterChain->restoreY = -0.0002f; + waterChain->wobble = 0.003f; if (RANDU_BITS(5) == 0) { s16 randAngle = RANDU_BITS(16); - chain2->unk_14 = Math_SinS(randAngle) * 1.8f * chain2->unk_1C; - chain2->unk_18 = Math_CosS(randAngle) * 0.2f * chain2->unk_1C; - chain2->unk_20 = RANDU_BITS(13); + waterChain->wobbleXZ = Math_SinS(randAngle) * 1.8f * waterChain->wobble; + waterChain->wobbleY = Math_CosS(randAngle) * 0.2f * waterChain->wobble; + waterChain->wobblePhaseVel = RANDU_BITS(13); } ObjMine_Water_UpdateChain(this, play); @@ -1031,7 +1044,7 @@ void ObjMine_Path_Draw(Actor* thisx, PlayState* play) { Collider_UpdateSpheres(0, &this->collider); } - func_800B8050(&this->actor, play, 1); + func_800B8050(&this->actor, play, true); func_8012C28C(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1048,7 +1061,7 @@ void ObjMine_DrawExplosion(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); - func_800B8118(thisx, play, 1); + func_800B8118(thisx, play, true); func_8012C2DC(play->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); @@ -1063,14 +1076,14 @@ void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - ObjMineAirChain* chain1 = &this->chain.air; - ObjMineAirLink* link1; + ObjMineAirChain* airChain = &this->chain.air; + ObjMineAirLink* airLink; s32 i; - Vec3f sp94; - Vec3f sp88; + Vec3f linkPos; + Vec3f linkOffset; Gfx* gfx; - func_800B8050(&this->actor, play, 1); + func_800B8050(&this->actor, play, true); OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -1079,21 +1092,21 @@ void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - ObjMine_ReplaceRotation(&chain1->basis); + ObjMine_ReplaceRotation(&airChain->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (linkCount != 0) { - Math_Vec3f_ScaleAndStore(&chain1->basis.y, -6.0f, &sp88); - sp94.x = this->actor.home.pos.x - sp88.x; - sp94.y = this->actor.home.pos.y - 6.0f - sp88.y; - sp94.z = this->actor.home.pos.z - sp88.z; - Math_Vec3f_ScaleAndStore(&chain1->basis.y, -12.0f, &sp88); + Math_Vec3f_ScaleAndStore(&airChain->basis.y, -6.0f, &linkOffset); + linkPos.x = this->actor.home.pos.x - linkOffset.x; + linkPos.y = this->actor.home.pos.y - 6.0f - linkOffset.y; + linkPos.z = this->actor.home.pos.z - linkOffset.z; - for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { - Matrix_RotateYS(link1->unk_00, MTXMODE_APPLY); - sp94.x += sp88.x; - sp94.y += sp88.y; - sp94.z += sp88.z; - ObjMine_ReplaceTranslation(&sp94); + Math_Vec3f_ScaleAndStore(&airChain->basis.y, -12.0f, &linkOffset); + for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { + Matrix_RotateYS(airLink->twist, MTXMODE_APPLY); + linkPos.x += linkOffset.x; + linkPos.y += linkOffset.y; + linkPos.z += linkOffset.z; + ObjMine_ReplaceTranslation(&linkPos); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); @@ -1119,12 +1132,12 @@ void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - ObjMineWaterChain* chain2 = &this->chain.water; - ObjMineWaterLink* link2; + ObjMineWaterChain* waterChain = &this->chain.water; + ObjMineWaterLink* waterLink; s32 i; Gfx* gfx; - func_800B8050(&this->actor, play, 1); + func_800B8050(&this->actor, play, true); OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -1133,13 +1146,13 @@ void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - for (i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { - ObjMine_ReplaceRotation(&link2->basis); + for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + ObjMine_ReplaceRotation(&waterLink->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if ((i % 2) == 0) { Matrix_RotateYS(0x4000, MTXMODE_APPLY); } - ObjMine_ReplaceTranslation(&link2->unk_24); + ObjMine_ReplaceTranslation(&waterLink->pos); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 680e766cb..cfc2ff2f2 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -15,6 +15,8 @@ typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); #define OBJMINE_SET_PARAM0(pathIndex, pathSpeed, type) ((pathIndex) | ((pathSpeed) << 8)) #define OBJMINE_SET_PARAM12(linkCount, type) ((linkCount) | ((type) << 0xC)) +#define OBJMINE_CHAIN_MAX 63 + typedef enum { /* 0 */ OBJMINE_TYPE_PATH, /* 1 */ OBJMINE_TYPE_AIR, @@ -28,104 +30,54 @@ typedef struct { } ObjMineMtxF3; // size = 0x24 typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; + /* 0x00 */ s16 twist; + /* 0x02 */ s16 spin; } ObjMineAirLink; // size = 0x4 typedef struct { /* 0x00 */ ObjMineMtxF3 basis; - /* 0x24 */ Vec3f unk_24; - /* 0x30 */ f32 unk_30; - /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; - /* 0x3C */ f32 unk_3C; - /* 0x40 */ f32 unk_40; - /* 0x44 */ f32 unk_44; - /* 0x48 */ f32 unk_48; - /* 0x4C */ s16 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ s16 unk_54; - /* 0x58 */ f32 unk_58; - /* 0x5C */ f32 unk_5C; - /* 0x60 */ ObjMineAirLink links[0x3F]; + /* 0x24 */ Vec3f translation; + /* 0x30 */ f32 xDiff; + /* 0x34 */ f32 zDiff; + /* 0x38 */ f32 xVel; + /* 0x3C */ f32 zVel; + /* 0x40 */ f32 restore; + /* 0x44 */ f32 drag; + /* 0x48 */ f32 knockback; + /* 0x4C */ s16 knockbackAngle; + /* 0x50 */ f32 wobbleSize; + /* 0x54 */ s16 wobblePhase; + /* 0x58 */ f32 wobble; + /* 0x5C */ f32 wallCheckDist; + /* 0x60 */ ObjMineAirLink links[OBJMINE_CHAIN_MAX]; } ObjMineAirChain; // size = 0x15C typedef struct { /* 0x00 */ ObjMineMtxF3 basis; - /* 0x24 */ Vec3f unk_24; - /* 0x30 */ Vec3f unk_30; - /* 0x3C */ Vec3f unk_3C; + /* 0x24 */ Vec3f pos; + /* 0x30 */ Vec3f vel; + /* 0x3C */ Vec3f accel; } ObjMineWaterLink; // size = 0x48 typedef struct { - /* 0x0000 */ f32 unk_00; - /* 0x0004 */ Vec3f unk_04; - /* 0x0010 */ f32 unk_10; - /* 0x0014 */ f32 unk_14; - /* 0x0018 */ f32 unk_18; - /* 0x001C */ f32 unk_1C; - /* 0x0020 */ s16 unk_20; - /* 0x0024 */ f32 unk_24; - /* 0x0028 */ f32 unk_28; - /* 0x002C */ f32 unk_2C; - /* 0x0030 */ f32 unk_30; - /* 0x0034 */ f32 unk_34; - /* 0x0038 */ f32 unk_38; - /* 0x003C */ f32 unk_3C; - /* 0x0040 */ s8 unk_40; - /* 0x0044 */ ObjMineWaterLink links[0x3F]; + /* 0x00 */ f32 drag; + /* 0x04 */ Vec3f knockbackDir; + /* 0x10 */ f32 knockback; + /* 0x14 */ f32 wobbleXZ; + /* 0x18 */ f32 wobbleY; + /* 0x1C */ f32 wobble; + /* 0x20 */ s16 wobblePhaseVel; + /* 0x24 */ f32 restoreX; + /* 0x28 */ f32 maxY; + /* 0x2C */ f32 restY; + /* 0x30 */ f32 restoreY; + /* 0x34 */ f32 wallCheckDist; + /* 0x38 */ f32 wallEjectX; + /* 0x3C */ f32 wallEjectZ; + /* 0x40 */ s8 touchWall; + /* 0x44 */ ObjMineWaterLink links[OBJMINE_CHAIN_MAX]; } ObjMineWaterChain; // size = 0x11FC -// definitely fake -typedef struct { - char unk_00[0x8]; - Vec3f unk_08; - char unk_14[0xC]; - Vec3f unk_20; - char unk_2C[0x1C]; -} NextUnkStruct; // size = 0x48 - -// maybe fake -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} ObjMineUnkStruct3; - -typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ Vec3f unk_0C; - /* 0x18 */ Vec3f unk_18; - ///* 0x24 */ char unk_24[0x3C]; - /* 0x24 */ Vec3f unk_24; - /* 0x30 */ f32 unk_30; - /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; - /* 0x3C */ f32 unk_3C; - /* 0x40 */ f32 unk_40; - /* 0x44 */ f32 unk_44; - /* 0x48 */ f32 unk_48; - /* 0x4C */ s16 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ s16 unk_54; - /* 0x58 */ f32 unk_58; - /* 0x5C */ f32 unk_5C; - /* 0x60 */ ObjMineUnkStruct3 unk_60[1]; -} ObjMineUnkStruct; // size = ?? 0x44??? 48 array??? - -// probably fake -typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0c */ Vec3f unk_0C; - ///* 0x10 */ f32 unk_10; - ///* 0x14 */ char unk_14[0x4]; - /* 0x18 */ Vec3f unk_18; - ///* 0x1C */ char unk_1C[0x4]; - ///* 0x20 */ f32 unk_20; - /* 0x24 */ Vec3f unk_24; - /* 0x30 */ Vec3f unk_30; - /* 0x3C */ Vec3f unk_3C; -} ObjMineUnkStruct2; // size = 0x48??? - typedef struct ObjMine { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderJntSph collider; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8e6ddd36f..8b9684c49 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11172,7 +11172,7 @@ 0x80A81D70:("ObjMine_Water_SetCollider",), 0x80A81DEC:("ObjMine_Water_SetWorld",), 0x80A81E7C:("func_80A81E7C",), - 0x80A81FFC:("func_80A81FFC",), + 0x80A81FFC:("ObjMine_Water_ApplyForces",), 0x80A828A8:("func_80A828A8",), 0x80A82C28:("ObjMine_Water_UpdateChain",), 0x80A82C5C:("ObjMine_Init",), From 8b9625483fda154e90db4607bf7b1a17eece7079 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Mon, 6 Feb 2023 12:28:37 -0600 Subject: [PATCH 091/130] docs. physics be wack --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 266 ++++++++++-------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 4 +- 2 files changed, 153 insertions(+), 117 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 6f828f4ce..e85f60503 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -13,10 +13,14 @@ #define THIS ((ObjMine*)thisx) #define LINK_SIZE 12.0f +// #define (LINK_SIZE / 2.0f) (LINK_SIZE / 2.0f) #define ATTACH_OFFSET 10.0f -#define AIR_RADIUS 24.0f +#define PATH_RADIUS 32.0f +#define AIR_RADIUS 20.0f #define WATER_RADIUS 36.0f #define BOMB_SPAWN_OFFSET 15.0f +#define WATER_KNOCKBACK 7.0f +#define AIR_KNOCKBACK 0.04f #define RAND_PLUSMINUS(limit) (Rand_ZeroOne()*(2.0f * (limit)) - (limit)) #define RAND_PLUSMINUSALT(limit) ((Rand_ZeroOne() - 0.5f) * (2.0f * limit)) @@ -136,7 +140,7 @@ s32 ObjMine_GetUnitVec3fNorm(Vec3f* src, Vec3f* dst, f32* norm, f32* invNorm) { void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { bomb->timer = 0; @@ -145,9 +149,8 @@ void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { void ObjMine_AirWater_SpawnBomb(ObjMine* this, PlayState* play) { f32 x = this->collider.elements[0].dim.worldSphere.center.x; - f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; + f32 y = this->collider.elements[0].dim.worldSphere.center.y - BOMB_SPAWN_OFFSET; f32 z = this->collider.elements[0].dim.worldSphere.center.z; - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { @@ -171,7 +174,7 @@ s32 ObjMine_AirWater_CheckOC(ObjMine* this) { return false; } -void ObjMine_Air_CheckAC(ObjMine* this, s16* hitAngle, s16* hitTorque) { +void ObjMine_Air_CheckAC(ObjMine* this, s16* hitAngle, s16* torqueAngle) { s32 pad[2]; Vec3s* centerPos3s = &this->collider.elements[0].dim.worldSphere.center; Vec3f centerPos; @@ -184,14 +187,14 @@ void ObjMine_Air_CheckAC(ObjMine* this, s16* hitAngle, s16* hitTorque) { // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { *hitAngle = attackActor->shape.rot.y; - *hitTorque = attackActor->shape.rot.y - yawToAttack; + *torqueAngle = attackActor->shape.rot.y - yawToAttack; } else { Vec3f hitPos; Vec3s* hitPos3s = &this->collider.elements[0].info.bumper.hitPos; Math_Vec3s_ToVec3f(&hitPos, hitPos3s); *hitAngle = Actor_YawBetweenActors(attackActor, &this->actor); - *hitTorque = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - yawToAttack; + *torqueAngle = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - yawToAttack; } } @@ -230,22 +233,22 @@ void ObjMine_ReplaceTranslation(Vec3f* translation) { matrix->mf[3][2] = translation->z; } -void ObjMine_ReplaceRotation(ObjMineMtxF3* rotation) { +void ObjMine_ReplaceRotation(ObjMineMtxF3* basis) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[0][0] = rotation->x.x; - matrix->mf[0][1] = rotation->x.y; - matrix->mf[0][2] = rotation->x.z; + matrix->mf[0][0] = basis->x.x; + matrix->mf[0][1] = basis->x.y; + matrix->mf[0][2] = basis->x.z; matrix->mf[0][3] = 0.0f; - matrix->mf[1][0] = rotation->y.x; - matrix->mf[1][1] = rotation->y.y; - matrix->mf[1][2] = rotation->y.z; + matrix->mf[1][0] = basis->y.x; + matrix->mf[1][1] = basis->y.y; + matrix->mf[1][2] = basis->y.z; matrix->mf[1][3] = 0.0f; - matrix->mf[2][0] = rotation->z.x; - matrix->mf[2][1] = rotation->z.y; - matrix->mf[2][2] = rotation->z.z; + matrix->mf[2][0] = basis->z.x; + matrix->mf[2][1] = basis->z.y; + matrix->mf[2][2] = basis->z.z; matrix->mf[2][3] = 0.0f; matrix->mf[3][0] = 0.0f; @@ -296,25 +299,28 @@ void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { airChain->basis.x.x = 1.0f; airChain->basis.y.y = 1.0f; airChain->basis.z.z = 1.0f; + airChain->translation.y = 1.0f; + // Sets restoring force and drag. Longer chains have lower frequency and less drag. if (linkCount > 0) { - airChain->restore = -sqrtf(0.001984f / linkCountF); // approx 1/504 = 1/8 * 1/63 - airChain->drag = 0.95f + (0.00031746097f * linkCountF); // approx 1/3150 = 1/50 * 1/63 + airChain->restore = -sqrtf((0.124992f / (63.0f)) / linkCountF); // constant is close to 1/8 + airChain->drag = 0.95f + ((0.02000004f / (63.0f)) * linkCountF); // constant is close to 1/50 } airChain->wobble = 0.0002f; + // Consecutive chain links are offset 90 degrees. for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { airLink->twist = 0x4000; } if (wallCheckRadius < 0.0f) { airChain->wallCheckDist = -1.0f; - } else if (wallCheckRadius <= 20.0f + 1.0f) { + } else if (wallCheckRadius <= AIR_RADIUS + 1.0f) { airChain->wallCheckDist = 0.0f; } else { - airChain->wallCheckDist = SQ(wallCheckRadius - 20.0f); + airChain->wallCheckDist = SQ(wallCheckRadius - AIR_RADIUS); } } @@ -341,16 +347,16 @@ void ObjMine_Air_SetBasis(ObjMine* this) { void ObjMine_Air_SetWorld(ObjMine* this) { s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 chainLength = 10.0f + (linkCount * 12.0f); + f32 chainLength = ATTACH_OFFSET + (linkCount * LINK_SIZE); this->actor.world.pos.x = (this->chain.air.basis.y.x * -chainLength) + this->actor.home.pos.x; this->actor.world.pos.y = (this->chain.air.basis.y.y * -chainLength) + this->actor.home.pos.y; this->actor.world.pos.z = (this->chain.air.basis.y.z * -chainLength) + this->actor.home.pos.z; } -void ObjMine_Air_SetChain3034(ObjMine* this) { +void ObjMine_Air_SetChainXZ(ObjMine* this) { s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 invLength = 1.0f / (10.0f + (linkCount * 12.0f)); + f32 invLength = 1.0f / (ATTACH_OFFSET + (linkCount * LINK_SIZE)); f32 dx = this->actor.world.pos.x - this->actor.home.pos.x; f32 dz = this->actor.world.pos.z - this->actor.home.pos.z; @@ -370,14 +376,14 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { waterChain->wobble = 0.003f; waterChain->wobblePhaseVel = RANDU_BITS(13); - waterChain->restoreX = -0.0002f; + waterChain->restoreXZ = -0.0002f; waterChain->restoreY = -0.0002f; - wobbleVel = waterChain->wobble * 6.0f; + wobbleVel = waterChain->wobble * (LINK_SIZE / 2.0f); linkY = this->actor.home.pos.y; for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { - linkY += 12.0f; + linkY += LINK_SIZE; waterLink->basis.x.x = 1.0f; waterLink->basis.y.y = 1.0f; waterLink->basis.z.z = 1.0f; @@ -390,24 +396,24 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { } waterChain->maxY = linkY; + // Rest position is slightly below max chain length to give slack. waterChain->restY = waterChain->maxY * 0.97f; - linkY -= 18.0f; - - if (waterChain->restY < linkY) { + linkY -= LINK_SIZE * 1.5f; + if (waterChain->restY < linkY) { // This should only happen if linkCount > 50 waterChain->restY = linkY; } if (wallCheckRadius < 0.0f) { waterChain->wallCheckDist = -1.0f; - } else if (wallCheckRadius <= 36.0f + 1.0f) { + } else if (wallCheckRadius <= WATER_RADIUS + 1.0f) { waterChain->wallCheckDist = 0.0f; } else { - waterChain->wallCheckDist = SQ(wallCheckRadius - 36.0f); + waterChain->wallCheckDist = SQ(wallCheckRadius - WATER_RADIUS); } } void ObjMine_Water_InitCollider(ObjMine* this, s32 linkCount) { - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (linkCount * 12.0f) + 10.0f, + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (linkCount * LINK_SIZE) + ATTACH_OFFSET, this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); @@ -419,12 +425,12 @@ void ObjMine_Water_SetWorld(ObjMine* this) { ObjMineWaterChain* waterChain = &this->chain.water; if (linkCount == 0) { - this->actor.world.pos.y = this->actor.home.pos.y + 12.0f + 10.0f; + this->actor.world.pos.y = this->actor.home.pos.y + LINK_SIZE + ATTACH_OFFSET; } else { ObjMineWaterLink* lastLink = &waterChain->links[linkCount - 1]; Vec3f mineOffset; - Math_Vec3f_ScaleAndStore(&lastLink->basis.y, 10.0f, &mineOffset); + Math_Vec3f_ScaleAndStore(&lastLink->basis.y, ATTACH_OFFSET, &mineOffset); Math_Vec3f_Sum(&lastLink->pos, &mineOffset, &this->actor.world.pos); } } @@ -435,27 +441,28 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { waterChain->touchWall = false; if (waterChain->wallCheckDist > -1e-6f) { + // Checks for walls if mine is sufficiently far from home. if (waterChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, this->actor.world.pos.x, this->actor.world.pos.z)) { Vec3f centerPos; Vec3f offsetPos; Vec3f dummyResult; - Vec3f xzDistFromHome; + Vec3f xzFromHome; Vec3f xzDirFromHome; CollisionPoly* dummyPoly; s32 dummyBgId; f32 dummyNorm; f32 dummyInvNorm; - xzDistFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; - xzDistFromHome.y = 0.0f; - xzDistFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; + xzFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; + xzFromHome.y = 0.0f; + xzFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (ObjMine_GetUnitVec3fNorm(&xzDistFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { + if (ObjMine_GetUnitVec3fNorm(&xzFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { - offsetPos.x = this->actor.world.pos.x + (xzDirFromHome.x * 36.0f); + offsetPos.x = this->actor.world.pos.x + (xzDirFromHome.x * WATER_RADIUS); offsetPos.y = this->actor.world.pos.y; - offsetPos.z = this->actor.world.pos.z + (xzDirFromHome.z * 36.0f); + offsetPos.z = this->actor.world.pos.z + (xzDirFromHome.z * WATER_RADIUS); centerPos.x = this->actor.home.pos.x; centerPos.y = this->actor.world.pos.y; @@ -474,7 +481,7 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { #if 0 // Probably equivalent, but nightmare loop unrolls. void ObjMine_Water_ApplyForces(ObjMine *this) { - static Vec3f sLinkAccel[0x40]; + static Vec3f sLastLinkAccel[0x40]; ObjMineWaterChain *waterChain = &this->chain.water; ObjMineWaterLink *waterLink; s32 i; @@ -485,8 +492,9 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { Vec3f tension; f32 scaledKnockback; + // Applies the buoyant force and sway from the water. for(i = 0, waterLink = waterChain->links, wobblePhase = 0; i < linkCount; i++, waterLink++, wobblePhase += waterChain->wobblePhaseVel) { - Math_Vec3f_Copy(&sLinkAccel[i], &waterLink->accel); + Math_Vec3f_Copy(&sLastLinkAccel[i], &waterLink->accel); if (waterLink->pos.y <= this->actor.home.pos.y) { waterLink->accel.y = waterChain->restoreY * -96.0f; } else if (restoreY > 0.0f) { @@ -494,12 +502,14 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { } else { waterLink->accel.y = restoreY; } - waterLink->accel.x = (waterLink->pos.x - this->actor.home.pos.x) * waterChain->restoreX; - waterLink->accel.z = (waterLink->pos.z - this->actor.home.pos.z) * waterChain->restoreX; + waterLink->accel.x = (waterLink->pos.x - this->actor.home.pos.x) * waterChain->restoreXZ; + waterLink->accel.z = (waterLink->pos.z - this->actor.home.pos.z) * waterChain->restoreXZ; waterLink->accel.x += waterChain->wobbleXZ * Math_SinS(wobblePhase); waterLink->accel.y += waterChain->wobbleY; waterLink->accel.z += waterChain->wobbleXZ * Math_CosS(wobblePhase); } + + // Applies knockback force. Knockback on the links is scaled quadratically, possibly to account for link rotations being cumulative if (waterChain->knockback > 0.0001f) { for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { scaledKnockback = SQ((linkCount - i) * inverseCount); @@ -509,6 +519,8 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { waterLink->accel.z += waterChain->knockbackDir.z * scaledKnockback; } } + + // Links that intersect walls are ejected from them. if (waterChain->touchWall) { for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { waterLink->accel.x += waterChain->wallEjectX; @@ -516,30 +528,33 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { } } + // Forces on the links from other links. This is simulated by a triangle filter on the forces from the previous frame. for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { Math_Vec3f_Copy(&tension, &gZeroVec3f); if(i - 2 >= 0) { - tension.x += sLinkAccel[i - 2].x * 0.075f; - tension.y += sLinkAccel[i - 2].y * 0.075f; - tension.z += sLinkAccel[i - 2].z * 0.075f; + tension.x += sLastLinkAccel[i - 2].x * 0.075f; + tension.y += sLastLinkAccel[i - 2].y * 0.075f; + tension.z += sLastLinkAccel[i - 2].z * 0.075f; } if(i - 1 >= 0) { - tension.x += sLinkAccel[i - 1].x * 0.15f; - tension.y += sLinkAccel[i - 1].y * 0.15f; - tension.z += sLinkAccel[i - 1].z * 0.15f; + tension.x += sLastLinkAccel[i - 1].x * 0.15f; + tension.y += sLastLinkAccel[i - 1].y * 0.15f; + tension.z += sLastLinkAccel[i - 1].z * 0.15f; } - tension.x += sLinkAccel[i].x * 0.3f; - tension.y += sLinkAccel[i].y * 0.3f; - tension.z += sLinkAccel[i].z * 0.3f; + + tension.x += sLastLinkAccel[i].x * 0.3f; + tension.y += sLastLinkAccel[i].y * 0.3f; + tension.z += sLastLinkAccel[i].z * 0.3f; + if(i + 1 < linkCount) { - tension.x += sLinkAccel[i + 1].x * 0.15f; - tension.y += sLinkAccel[i + 1].y * 0.15f; - tension.z += sLinkAccel[i + 1].z * 0.15f; + tension.x += sLastLinkAccel[i + 1].x * 0.15f; + tension.y += sLastLinkAccel[i + 1].y * 0.15f; + tension.z += sLastLinkAccel[i + 1].z * 0.15f; } if(i + 2 < linkCount) { - tension.x += sLinkAccel[i + 2].x * 0.075f; - tension.y += sLinkAccel[i + 2].y * 0.075f; - tension.z += sLinkAccel[i + 2].z * 0.075f; + tension.x += sLastLinkAccel[i + 2].x * 0.075f; + tension.y += sLastLinkAccel[i + 2].y * 0.075f; + tension.z += sLastLinkAccel[i + 2].z * 0.075f; } waterLink->accel.x += tension.x; waterLink->accel.y += tension.y; @@ -560,21 +575,22 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { ObjMineWaterChain* waterChain = &this->chain.water; ObjMineWaterLink* waterLink; s32 i; - Vec3f* lastBasisX; + Vec3f* jointBasisX; Vec3f tempVec; Vec3f diffDir; Vec3f unusedLinkPos; - Vec3f lastLinkPos; + Vec3f jointPos; s32 changeBasis; f32 diffNorm; f32 dummyInvNorm; Vec3f* tempBasisX; - lastLinkPos.x = this->actor.home.pos.x; - lastLinkPos.y = this->actor.home.pos.y + 6.0f; - lastLinkPos.z = this->actor.home.pos.z; + // The joint between the current link and next link is half the link's length from its center. The first link is assumed to be vertical and centered on home. + jointPos.x = this->actor.home.pos.x; + jointPos.y = this->actor.home.pos.y + (LINK_SIZE / 2.0f); + jointPos.z = this->actor.home.pos.z; - for (i = 0, lastBasisX = NULL, waterLink = waterChain->links; i < linkCount; i++, lastBasisX = &waterLink->basis.x, waterLink++) { + for (i = 0, jointBasisX = NULL, waterLink = waterChain->links; i < linkCount; i++, jointBasisX = &waterLink->basis.x, waterLink++) { changeBasis = false; waterLink->vel.x += waterLink->accel.x; @@ -592,12 +608,13 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { waterLink->vel.y *= 0.1f; } - Math_Vec3f_Diff(&waterLink->pos, &lastLinkPos, &tempVec); + // If the calculated position is less than 1/3 of the link's length from the joint, the chain is considered slack and the link keeps the same basis. Otherwise the basis is updated with the new position relative to the joint. The StepUntilParallel causes the chain to straighten over time. + Math_Vec3f_Diff(&waterLink->pos, &jointPos, &tempVec); - if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &dummyInvNorm) && (diffNorm > 4.0f)) { + if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &dummyInvNorm) && (diffNorm > LINK_SIZE / 3.0f)) { Math_Vec3f_Copy(&newBasis.y, &waterLink->basis.y); ObjMine_StepUntilParallel(&newBasis.y, &diffDir, M_PI / 30); - tempBasisX = (lastBasisX == NULL) ? &sStandardBasis.x : lastBasisX; + tempBasisX = (jointBasisX == NULL) ? &sStandardBasis.x : jointBasisX; Math3D_CrossProduct(tempBasisX, &newBasis.y, &tempVec); @@ -614,28 +631,28 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { Math_Vec3f_Copy(&waterLink->basis.y, &newBasis.y); Math_Vec3f_Copy(&waterLink->basis.z, &newBasis.z); } else { - diffNorm = 4.0f; + diffNorm = LINK_SIZE / 3.0f; } - if (diffNorm >= 6.0f) { - waterLink->pos.x = lastLinkPos.x + (waterLink->basis.y.x * 6.0f); - waterLink->pos.y = lastLinkPos.y + (waterLink->basis.y.y * 6.0f); - waterLink->pos.z = lastLinkPos.z + (waterLink->basis.y.z * 6.0f); + if (diffNorm >= (LINK_SIZE / 2.0f)) { + waterLink->pos.x = jointPos.x + (waterLink->basis.y.x * (LINK_SIZE / 2.0f)); + waterLink->pos.y = jointPos.y + (waterLink->basis.y.y * (LINK_SIZE / 2.0f)); + waterLink->pos.z = jointPos.z + (waterLink->basis.y.z * (LINK_SIZE / 2.0f)); } else { - waterLink->pos.x = lastLinkPos.x + (waterLink->basis.y.x * diffNorm); - waterLink->pos.y = lastLinkPos.y + (waterLink->basis.y.y * diffNorm); - waterLink->pos.z = lastLinkPos.z + (waterLink->basis.y.z * diffNorm); + waterLink->pos.x = jointPos.x + (waterLink->basis.y.x * diffNorm); + waterLink->pos.y = jointPos.y + (waterLink->basis.y.y * diffNorm); + waterLink->pos.z = jointPos.z + (waterLink->basis.y.z * diffNorm); } - lastLinkPos.x = waterLink->pos.x + (waterLink->basis.y.x * 6.0f); - lastLinkPos.y = waterLink->pos.y + (waterLink->basis.y.y * 6.0f); - lastLinkPos.z = waterLink->pos.z + (waterLink->basis.y.z * 6.0f); + jointPos.x = waterLink->pos.x + (waterLink->basis.y.x * (LINK_SIZE / 2.0f)); + jointPos.y = waterLink->pos.y + (waterLink->basis.y.y * (LINK_SIZE / 2.0f)); + jointPos.z = waterLink->pos.z + (waterLink->basis.y.z * (LINK_SIZE / 2.0f)); } } void ObjMine_Water_UpdateChain(ObjMine* this, PlayState* play) { ObjMine_Water_WallCheck(this, play); - ObjMine_Water_ApplyForces(this); // ObjMine_Water_ApplyForces + ObjMine_Water_ApplyForces(this); ObjMine_Water_UpdateLinks(this); } @@ -658,7 +675,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { if (type == OBJMINE_TYPE_PATH) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 140; - this->pathSpeed = sPathSpeeds[OBJMINE_GET_PATH_SPEED(&this->actor)]; + this->pathSpeed = sPathSpeeds[OBJMINE_GET_PATH_SPEED(&this->actor)]; // sPathSpeeds[i] = i + 1.0f if (pathIndex == 0xFF) { ObjMine_Path_SetupStationary(this); } else { @@ -681,15 +698,15 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); this->actor.update = ObjMine_AirWater_Update; - this->actor.uncullZoneScale = 150.0f + (linkCount * 21.0f); - this->actor.uncullZoneDownward = 150.0f + (linkCount * 21.0f); + this->actor.uncullZoneScale = 150.0f + (linkCount * (LINK_SIZE * 1.75f)); + this->actor.uncullZoneDownward = 150.0f + (linkCount * (LINK_SIZE * 1.75f)); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 140; if (type == OBJMINE_TYPE_AIR) { this->actor.draw = ObjMine_Air_Draw; ObjMine_Air_InitChain(this, linkCount); - this->actor.world.pos.y = -10.0f - (linkCount * 12.0f) + this->actor.home.pos.y; + this->actor.world.pos.y = -ATTACH_OFFSET - (linkCount * LINK_SIZE) + this->actor.home.pos.y; ObjMine_Air_SetCollider(this, linkCount); func_800B4AEC(play, &this->actor, 0.0f); if (linkCount == 0) { @@ -700,7 +717,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { } else { this->actor.draw = ObjMine_Water_Draw; ObjMine_Water_InitChain(this, linkCount); - this->actor.world.pos.y = 10.0f + (linkCount * 12.0f) + this->actor.home.pos.y; + this->actor.world.pos.y = ATTACH_OFFSET + (linkCount * LINK_SIZE) + this->actor.home.pos.y; ObjMine_Water_InitCollider(this, linkCount); if (linkCount == 0) { ObjMine_Water_SetupStationary(this); @@ -725,22 +742,24 @@ void ObjMine_Path_Stationary(ObjMine* this, PlayState* play) { } void ObjMine_Path_SetupMove(ObjMine* this) { - this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_10; // @bug? Sets flag 10, but later checks flag 40. this->actionFunc = ObjMine_Path_Move; } void ObjMine_Path_Move(ObjMine* this, PlayState* play) { Actor* thisx = &this->actor; // pos and velocity need this, though it can replace all `this->actor`s and match Vec3f nextWaypoint; - f32 speed; + f32 distToWaypoint; f32 step; f32 target; s32 dummyBgVec; Math_Vec3s_ToVec3f(&nextWaypoint, &this->waypoints[this->waypointIndex + 1]); Math_Vec3f_Diff(&nextWaypoint, &thisx->world.pos, &thisx->velocity); - speed = Math3D_Vec3fMagnitude(&thisx->velocity); - if ((speed < (this->pathSpeed * 8.0f)) && (this->pathSpeed > 2.0f)) { + distToWaypoint = Math3D_Vec3fMagnitude(&thisx->velocity); + + // Mine slows to 2.0f speed when 8 frames away from the next waypoint + if ((distToWaypoint < (this->pathSpeed * 8.0f)) && (this->pathSpeed > 2.0f)) { target = 2.0f + ((this->pathSpeed - 2.0f) * 0.1f); step = this->pathSpeed * 0.03f; } else { @@ -748,8 +767,11 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { step = this->pathSpeed * 0.16f; } Math_StepToF(&this->actor.speedXZ, target, step); - if ((this->actor.speedXZ + 0.05f) < speed) { - Math_Vec3f_Scale(&thisx->velocity, this->actor.speedXZ / speed); + + // Checks if mine will reach the waypoint next frame + if ((this->actor.speedXZ + 0.05f) < distToWaypoint) { + // Scales thisx->velocity to be equal in magnitude to speedXZ + Math_Vec3f_Scale(&thisx->velocity, this->actor.speedXZ / distToWaypoint); this->actor.world.pos.x += thisx->velocity.x; this->actor.world.pos.y += thisx->velocity.y; this->actor.world.pos.z += thisx->velocity.z; @@ -767,9 +789,10 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { Vec3f yhatCrossV; MtxF rotMtxF; + // Makes mines appear to roll while traversing the path Math3D_CrossProduct(&sStandardBasis.y, &thisx->velocity, &yhatCrossV); if (ObjMine_GetUnitVec3f(&yhatCrossV, &rotAxis)) { - Matrix_RotateAxisF(this->actor.speedXZ / 32.0f, &rotAxis, MTXMODE_NEW); + Matrix_RotateAxisF(this->actor.speedXZ / PATH_RADIUS, &rotAxis, 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); @@ -791,7 +814,7 @@ void ObjMine_SetupExplode(ObjMine* this) { void ObjMine_Explode(ObjMine* this, PlayState* play) { this->actor.scale.x *= 1.8f; - if (this->actor.scale.x > 30.0f * 0.001f * CUBE(1.8f)) { + if (this->actor.scale.x > 0.02f * 1.5f * 5.832f) { // 5.832 = 1.8^3 Actor_Kill(&this->actor); } else { this->actor.scale.y = this->actor.scale.x; @@ -815,6 +838,8 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { s16 twistDiff; Math_Vec3f_Copy(&airChain->translation, &airChain->basis.y); + + // Explodes if collision with Player or another mine is detected. if (ObjMine_AirWater_CheckOC(this)) { ObjMine_AirWater_SpawnBomb(this, play); ObjMine_AirWater_Noop(this); @@ -822,48 +847,53 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { return; } - if (this->collider.base.acFlags & AC_HIT) { // initial knockback calc + // Calculates initial knockback and torque from hit scaled to chain length + if (this->collider.base.acFlags & AC_HIT) { s16 torqueAngle; f32 torque; f32 torqueDiff; this->collider.base.acFlags &= ~AC_HIT; - airChain->knockback = 0.04f; + airChain->knockback = AIR_KNOCKBACK; ObjMine_Air_CheckAC(this, &airChain->knockbackAngle, &torqueAngle); - torque = Math_SinS(torqueAngle) * 150.0f; + torque = Math_SinS(torqueAngle) * 0x96; torqueDiff = -(torque / linkCount); for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { airLink->spin += (s16)torque; - airLink->spin = CLAMP(airLink->spin, -800, 800); + airLink->spin = CLAMP(airLink->spin, -0x320, 0x320); torque -= torqueDiff; } } - if (airChain->knockback > 0.0001f) { // residual knockback calc + // Applies knockback force. Knockback applies over two frames, with the second at half strength + if (airChain->knockback > 0.0001f) { xAccel = Math_SinS(airChain->knockbackAngle) * airChain->knockback; zAccel = Math_CosS(airChain->knockbackAngle) * airChain->knockback; airChain->xVel += xAccel; airChain->zVel += zAccel; - Math_StepToF(&airChain->knockback, 0.0f, 0.02f); + Math_StepToF(&airChain->knockback, 0.0f, AIR_KNOCKBACK * 0.5f); } - if (RANDU_BITS(5) == 0) { // wobble + // Applies chain sway, choosing a new sway randomly about every 32 frames + if (RANDU_BITS(5) == 0) { airChain->wobbleSize = Rand_ZeroOne() * airChain->wobble; airChain->wobblePhase = RANDU_BITS(16); } - xAccel = Math_SinS(airChain->wobblePhase) * airChain->wobbleSize; zAccel = Math_CosS(airChain->wobblePhase) * airChain->wobbleSize; airChain->xVel += xAccel; airChain->zVel += zAccel; + // Applies the restoring force of gravity and chain tension using small-angle approximation airChain->xVel += airChain->xDiff * airChain->restore; airChain->zVel += airChain->zDiff * airChain->restore; + // Applies linear drag airChain->xVel *= airChain->drag; airChain->zVel *= airChain->drag; + // Updates scaled position and does a safety clamp to 5.0f. airChain->xDiff += airChain->xVel; airChain->zDiff += airChain->zVel; @@ -873,13 +903,11 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { ObjMine_Air_SetBasis(this); ObjMine_Air_SetWorld(this); + // Checks for wall collisions if sufficiently far from home. If collision detected, bounce off the wall at half speed. If speed is close to zero when hitting wall, weakly eject it instead. if (airChain->wallCheckDist > -1e-6f) { - // Vec3f* world = &this->actor.world.pos; - // Vec3f* home = &this->actor.home.pos; - if (airChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z)) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, AIR_RADIUS, 0.0f, 1); if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { Vec3f xzDir; @@ -907,13 +935,14 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { airChain->xVel *= -0.1f; airChain->zVel *= -0.1f; } - ObjMine_Air_SetChain3034(this); + ObjMine_Air_SetChainXZ(this); ObjMine_Air_SetBasis(this); ObjMine_Air_SetWorld(this); } } } + // Applies three torques to individual chain links. The restoring torque towards the default twist of 0x4000, a random torque for variance, and a linear drag. for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { twistDiff = airLink->twist - 0x4000; torque = airLink->spin + (twistDiff * -0.05f) + RAND_PLUSMINUS(15.0f); @@ -933,6 +962,7 @@ void ObjMine_Air_SetupStationary(ObjMine* this) { } void ObjMine_Air_Stationary(ObjMine* this, PlayState* play) { + // Explodes if collision with Player or another mine is detected. if (ObjMine_AirWater_CheckOC(this)) { ObjMine_AirWater_SpawnBomb(this, play); ObjMine_AirWater_Noop(this); @@ -951,6 +981,7 @@ void ObjMine_Water_SetupChained(ObjMine* this) { void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { ObjMineWaterChain* waterChain = &this->chain.water; + // Explodes if collision with Player or another mine is detected. if (ObjMine_AirWater_CheckOC(this)) { ObjMine_AirWater_SpawnBomb(this, play); ObjMine_AirWater_Noop(this); @@ -958,19 +989,21 @@ void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { return; } + // Calculates knockback from AC hits if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; ObjMine_Water_CheckAC(this, &waterChain->knockbackDir); - waterChain->knockback = 7.0f; - Math_Vec3f_Scale(&waterChain->knockbackDir, 7.0f); + waterChain->knockback = WATER_KNOCKBACK; + Math_Vec3f_Scale(&waterChain->knockbackDir, WATER_KNOCKBACK); } + // Reduces knockback each frame. Effectively makes knockback 60% on the first frame and 20% on the second. if (waterChain->knockback > 0.0001f) { - waterChain->knockback = Math_Vec3f_StepTo(&waterChain->knockbackDir, &gZeroVec3f, 2.8f); + waterChain->knockback = Math_Vec3f_StepTo(&waterChain->knockbackDir, &gZeroVec3f, WATER_KNOCKBACK * 0.4f); } waterChain->drag = 0.9f; - waterChain->restoreX = -0.0002f; + waterChain->restoreXZ = -0.0002f; waterChain->restoreY = -0.0002f; waterChain->wobble = 0.003f; @@ -994,6 +1027,7 @@ void ObjMine_Water_SetupStationary(ObjMine* this) { } void ObjMine_Water_Stationary(ObjMine* this, PlayState* play) { + // Explodes if collision with Player or another mine is detected. if (ObjMine_AirWater_CheckOC(this)) { ObjMine_AirWater_SpawnBomb(this, play); ObjMine_AirWater_Noop(this); @@ -1095,12 +1129,13 @@ void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { ObjMine_ReplaceRotation(&airChain->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (linkCount != 0) { - Math_Vec3f_ScaleAndStore(&airChain->basis.y, -6.0f, &linkOffset); + // Sets pivot point to be half a chain link length below home + Math_Vec3f_ScaleAndStore(&airChain->basis.y, -(LINK_SIZE / 2.0f), &linkOffset); linkPos.x = this->actor.home.pos.x - linkOffset.x; - linkPos.y = this->actor.home.pos.y - 6.0f - linkOffset.y; + linkPos.y = this->actor.home.pos.y - (LINK_SIZE / 2.0f) - linkOffset.y; linkPos.z = this->actor.home.pos.z - linkOffset.z; + Math_Vec3f_ScaleAndStore(&airChain->basis.y, -LINK_SIZE, &linkOffset); - Math_Vec3f_ScaleAndStore(&airChain->basis.y, -12.0f, &linkOffset); for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { Matrix_RotateYS(airLink->twist, MTXMODE_APPLY); linkPos.x += linkOffset.x; @@ -1149,6 +1184,7 @@ void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { ObjMine_ReplaceRotation(&waterLink->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + // Consecutive chain links are offset 90 degrees. if ((i % 2) == 0) { Matrix_RotateYS(0x4000, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index cfc2ff2f2..92176d36a 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -36,7 +36,7 @@ typedef struct { typedef struct { /* 0x00 */ ObjMineMtxF3 basis; - /* 0x24 */ Vec3f translation; + /* 0x24 */ Vec3f translation; // unused /* 0x30 */ f32 xDiff; /* 0x34 */ f32 zDiff; /* 0x38 */ f32 xVel; @@ -67,7 +67,7 @@ typedef struct { /* 0x18 */ f32 wobbleY; /* 0x1C */ f32 wobble; /* 0x20 */ s16 wobblePhaseVel; - /* 0x24 */ f32 restoreX; + /* 0x24 */ f32 restoreXZ; /* 0x28 */ f32 maxY; /* 0x2C */ f32 restY; /* 0x30 */ f32 restoreY; From 058246cb4411d39990708e704599718ec128522e Mon Sep 17 00:00:00 2001 From: petrie911 Date: Mon, 6 Feb 2023 12:31:32 -0600 Subject: [PATCH 092/130] forgot some things --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 1 - tools/disasm/functions.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index e85f60503..8c08f9ff3 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -13,7 +13,6 @@ #define THIS ((ObjMine*)thisx) #define LINK_SIZE 12.0f -// #define (LINK_SIZE / 2.0f) (LINK_SIZE / 2.0f) #define ATTACH_OFFSET 10.0f #define PATH_RADIUS 32.0f #define AIR_RADIUS 20.0f diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8b9684c49..0ef8fe70f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11167,7 +11167,7 @@ 0x80A819A4:("ObjMine_Air_SetCollider",), 0x80A81A00:("ObjMine_Air_SetBasis",), 0x80A81AA4:("ObjMine_Air_SetWorld",), - 0x80A81B14:("ObjMine_Air_SetChain3034",), + 0x80A81B14:("ObjMine_Air_SetChainXZ",), 0x80A81B7C:("ObjMine_Water_InitChain",), 0x80A81D70:("ObjMine_Water_SetCollider",), 0x80A81DEC:("ObjMine_Water_SetWorld",), From ed68e1cccf5d472363962c1245eeee46504a1a14 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Tue, 7 Feb 2023 05:28:45 -0600 Subject: [PATCH 093/130] format --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 8c08f9ff3..2af6aaa9b 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -21,7 +21,7 @@ #define WATER_KNOCKBACK 7.0f #define AIR_KNOCKBACK 0.04f -#define RAND_PLUSMINUS(limit) (Rand_ZeroOne()*(2.0f * (limit)) - (limit)) +#define RAND_PLUSMINUS(limit) (Rand_ZeroOne() * (2.0f * (limit)) - (limit)) #define RAND_PLUSMINUSALT(limit) ((Rand_ZeroOne() - 0.5f) * (2.0f * limit)) void ObjMine_Init(Actor* thisx, PlayState* play); @@ -138,8 +138,9 @@ s32 ObjMine_GetUnitVec3fNorm(Vec3f* src, Vec3f* dst, f32* norm, f32* invNorm) { } void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + EnBom* bomb = + (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { bomb->timer = 0; @@ -303,8 +304,8 @@ void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { // Sets restoring force and drag. Longer chains have lower frequency and less drag. if (linkCount > 0) { - airChain->restore = -sqrtf((0.124992f / (63.0f)) / linkCountF); // constant is close to 1/8 - airChain->drag = 0.95f + ((0.02000004f / (63.0f)) * linkCountF); // constant is close to 1/50 + airChain->restore = -sqrtf((0.124992f / (63.0f)) / linkCountF); // constant is close to 1/8 + airChain->drag = 0.95f + ((0.02000004f / (63.0f)) * linkCountF); // constant is close to 1/50 } airChain->wobble = 0.0002f; @@ -394,7 +395,7 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { waterLink->vel.z = (Rand_ZeroOne() - 0.5f) * wobbleVel; } waterChain->maxY = linkY; - + // Rest position is slightly below max chain length to give slack. waterChain->restY = waterChain->maxY * 0.97f; linkY -= LINK_SIZE * 1.5f; @@ -413,7 +414,7 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { void ObjMine_Water_InitCollider(ObjMine* this, s32 linkCount) { Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (linkCount * LINK_SIZE) + ATTACH_OFFSET, - this->actor.home.pos.z, MTXMODE_NEW); + this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -422,7 +423,7 @@ void ObjMine_Water_SetWorld(ObjMine* this) { s32 pad; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); ObjMineWaterChain* waterChain = &this->chain.water; - + if (linkCount == 0) { this->actor.world.pos.y = this->actor.home.pos.y + LINK_SIZE + ATTACH_OFFSET; } else { @@ -437,12 +438,12 @@ void ObjMine_Water_SetWorld(ObjMine* this) { void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { s32 pad; ObjMineWaterChain* waterChain = &this->chain.water; - + waterChain->touchWall = false; if (waterChain->wallCheckDist > -1e-6f) { // Checks for walls if mine is sufficiently far from home. if (waterChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, - this->actor.world.pos.x, this->actor.world.pos.z)) { + this->actor.world.pos.x, this->actor.world.pos.z)) { Vec3f centerPos; Vec3f offsetPos; Vec3f dummyResult; @@ -467,7 +468,8 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { centerPos.y = this->actor.world.pos.y; centerPos.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, ¢erPos, &offsetPos, &dummyResult, &dummyPoly, true, false, false, true, &dummyBgId)) { + if (BgCheck_EntityLineTest1(&play->colCtx, ¢erPos, &offsetPos, &dummyResult, &dummyPoly, true, + false, false, true, &dummyBgId)) { waterChain->touchWall = true; waterChain->wallEjectX = xzDirFromHome.x * -0.2f; waterChain->wallEjectZ = xzDirFromHome.z * -0.2f; @@ -584,12 +586,14 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { f32 dummyInvNorm; Vec3f* tempBasisX; - // The joint between the current link and next link is half the link's length from its center. The first link is assumed to be vertical and centered on home. + // The joint between the current link and next link is half the link's length from its center. The first link is + // assumed to be vertical and centered on home. jointPos.x = this->actor.home.pos.x; jointPos.y = this->actor.home.pos.y + (LINK_SIZE / 2.0f); jointPos.z = this->actor.home.pos.z; - for (i = 0, jointBasisX = NULL, waterLink = waterChain->links; i < linkCount; i++, jointBasisX = &waterLink->basis.x, waterLink++) { + for (i = 0, jointBasisX = NULL, waterLink = waterChain->links; i < linkCount; + i++, jointBasisX = &waterLink->basis.x, waterLink++) { changeBasis = false; waterLink->vel.x += waterLink->accel.x; @@ -607,7 +611,9 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { waterLink->vel.y *= 0.1f; } - // If the calculated position is less than 1/3 of the link's length from the joint, the chain is considered slack and the link keeps the same basis. Otherwise the basis is updated with the new position relative to the joint. The StepUntilParallel causes the chain to straighten over time. + // If the calculated position is less than 1/3 of the link's length from the joint, the chain is considered + // slack and the link keeps the same basis. Otherwise the basis is updated with the new position relative to the + // joint. The StepUntilParallel causes the chain to straighten over time. Math_Vec3f_Diff(&waterLink->pos, &jointPos, &tempVec); if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &dummyInvNorm) && (diffNorm > LINK_SIZE / 3.0f)) { @@ -667,7 +673,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; - + Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -688,7 +694,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { ObjMine_Path_SetupMove(this); } Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + &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); this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgId, @@ -716,7 +722,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { } else { this->actor.draw = ObjMine_Water_Draw; ObjMine_Water_InitChain(this, linkCount); - this->actor.world.pos.y = ATTACH_OFFSET + (linkCount * LINK_SIZE) + this->actor.home.pos.y; + this->actor.world.pos.y = ATTACH_OFFSET + (linkCount * LINK_SIZE) + this->actor.home.pos.y; ObjMine_Water_InitCollider(this, linkCount); if (linkCount == 0) { ObjMine_Water_SetupStationary(this); @@ -751,12 +757,12 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { f32 distToWaypoint; f32 step; f32 target; - s32 dummyBgVec; + s32 dummyBgVec; Math_Vec3s_ToVec3f(&nextWaypoint, &this->waypoints[this->waypointIndex + 1]); Math_Vec3f_Diff(&nextWaypoint, &thisx->world.pos, &thisx->velocity); distToWaypoint = Math3D_Vec3fMagnitude(&thisx->velocity); - + // Mine slows to 2.0f speed when 8 frames away from the next waypoint if ((distToWaypoint < (this->pathSpeed * 8.0f)) && (this->pathSpeed > 2.0f)) { target = 2.0f + ((this->pathSpeed - 2.0f) * 0.1f); @@ -782,7 +788,8 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { } ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); } - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgVec, &this->actor, &thisx->world.pos); + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgVec, + &this->actor, &thisx->world.pos); if (this->actor.flags & ACTOR_FLAG_40) { Vec3f rotAxis; Vec3f yhatCrossV; @@ -851,7 +858,7 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { s16 torqueAngle; f32 torque; f32 torqueDiff; - + this->collider.base.acFlags &= ~AC_HIT; airChain->knockback = AIR_KNOCKBACK; ObjMine_Air_CheckAC(this, &airChain->knockbackAngle, &torqueAngle); @@ -902,9 +909,11 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { ObjMine_Air_SetBasis(this); ObjMine_Air_SetWorld(this); - // Checks for wall collisions if sufficiently far from home. If collision detected, bounce off the wall at half speed. If speed is close to zero when hitting wall, weakly eject it instead. + // Checks for wall collisions if sufficiently far from home. If collision detected, bounce off the wall at half + // speed. If speed is close to zero when hitting wall, weakly eject it instead. if (airChain->wallCheckDist > -1e-6f) { - if (airChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z)) { + if (airChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z)) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, AIR_RADIUS, 0.0f, 1); @@ -941,7 +950,8 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { } } - // Applies three torques to individual chain links. The restoring torque towards the default twist of 0x4000, a random torque for variance, and a linear drag. + // Applies three torques to individual chain links. The restoring torque towards the default twist of 0x4000, a + // random torque for variance, and a linear drag. for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { twistDiff = airLink->twist - 0x4000; torque = airLink->spin + (twistDiff * -0.05f) + RAND_PLUSMINUS(15.0f); @@ -1011,7 +1021,7 @@ void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { waterChain->wobbleXZ = Math_SinS(randAngle) * 1.8f * waterChain->wobble; waterChain->wobbleY = Math_CosS(randAngle) * 0.2f * waterChain->wobble; - waterChain->wobblePhaseVel = RANDU_BITS(13); + waterChain->wobblePhaseVel = RANDU_BITS(13); } ObjMine_Water_UpdateChain(this, play); @@ -1036,7 +1046,6 @@ void ObjMine_Water_Stationary(ObjMine* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - } void ObjMine_Path_Update(Actor* thisx, PlayState* play) { From 6d047a7b7d92a18d0d3294e52067913039a0086c Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 13 Apr 2023 08:50:46 -0500 Subject: [PATCH 094/130] more cleanup --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 42 +++++++++---------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 14 +++---- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 2af6aaa9b..970b1050e 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -308,7 +308,7 @@ void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { airChain->drag = 0.95f + ((0.02000004f / (63.0f)) * linkCountF); // constant is close to 1/50 } - airChain->wobble = 0.0002f; + airChain->swayMax = 0.0002f; // Consecutive chain links are offset 90 degrees. for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { @@ -370,16 +370,16 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { s32 i; f32 wallCheckRadius = this->actor.home.rot.z * 5.0f; f32 linkY; - f32 wobbleVel; + f32 swayVel; waterChain->drag = 0.9f; - waterChain->wobble = 0.003f; + waterChain->swayMax = 0.003f; - waterChain->wobblePhaseVel = RANDU_BITS(13); + waterChain->swayPhaseVel = RANDU_BITS(13); waterChain->restoreXZ = -0.0002f; waterChain->restoreY = -0.0002f; - wobbleVel = waterChain->wobble * (LINK_SIZE / 2.0f); + swayVel = waterChain->swayMax * (LINK_SIZE / 2.0f); linkY = this->actor.home.pos.y; for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { @@ -390,9 +390,9 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { waterLink->pos.x = this->actor.home.pos.x; waterLink->pos.y = linkY; waterLink->pos.z = this->actor.home.pos.z; - waterLink->vel.x = (Rand_ZeroOne() - 0.5f) * wobbleVel; - waterLink->vel.y = (Rand_ZeroOne() - 0.5f) * wobbleVel; - waterLink->vel.z = (Rand_ZeroOne() - 0.5f) * wobbleVel; + waterLink->vel.x = (Rand_ZeroOne() - 0.5f) * swayVel; + waterLink->vel.y = (Rand_ZeroOne() - 0.5f) * swayVel; + waterLink->vel.z = (Rand_ZeroOne() - 0.5f) * swayVel; } waterChain->maxY = linkY; @@ -486,7 +486,7 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { ObjMineWaterChain *waterChain = &this->chain.water; ObjMineWaterLink *waterLink; s32 i; - s16 wobblePhase; + s16 swayPhase; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); f32 inverseCount = 1.0f / (f32) linkCount; f32 restoreY = (waterChain->links[linkCount - 1].pos.y - waterChain->restY) * waterChain->restoreY; @@ -494,7 +494,7 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { f32 scaledKnockback; // Applies the buoyant force and sway from the water. - for(i = 0, waterLink = waterChain->links, wobblePhase = 0; i < linkCount; i++, waterLink++, wobblePhase += waterChain->wobblePhaseVel) { + for(i = 0, waterLink = waterChain->links, swayPhase = 0; i < linkCount; i++, waterLink++, swayPhase += waterChain->swayPhaseVel) { Math_Vec3f_Copy(&sLastLinkAccel[i], &waterLink->accel); if (waterLink->pos.y <= this->actor.home.pos.y) { waterLink->accel.y = waterChain->restoreY * -96.0f; @@ -505,9 +505,9 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { } waterLink->accel.x = (waterLink->pos.x - this->actor.home.pos.x) * waterChain->restoreXZ; waterLink->accel.z = (waterLink->pos.z - this->actor.home.pos.z) * waterChain->restoreXZ; - waterLink->accel.x += waterChain->wobbleXZ * Math_SinS(wobblePhase); - waterLink->accel.y += waterChain->wobbleY; - waterLink->accel.z += waterChain->wobbleXZ * Math_CosS(wobblePhase); + waterLink->accel.x += waterChain->swayXZ * Math_SinS(swayPhase); + waterLink->accel.y += waterChain->swayY; + waterLink->accel.z += waterChain->swayXZ * Math_CosS(swayPhase); } // Applies knockback force. Knockback on the links is scaled quadratically, possibly to account for link rotations being cumulative @@ -883,11 +883,11 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { // Applies chain sway, choosing a new sway randomly about every 32 frames if (RANDU_BITS(5) == 0) { - airChain->wobbleSize = Rand_ZeroOne() * airChain->wobble; - airChain->wobblePhase = RANDU_BITS(16); + airChain->swaySize = Rand_ZeroOne() * airChain->swayMax; + airChain->swayPhase = RANDU_BITS(16); } - xAccel = Math_SinS(airChain->wobblePhase) * airChain->wobbleSize; - zAccel = Math_CosS(airChain->wobblePhase) * airChain->wobbleSize; + xAccel = Math_SinS(airChain->swayPhase) * airChain->swaySize; + zAccel = Math_CosS(airChain->swayPhase) * airChain->swaySize; airChain->xVel += xAccel; airChain->zVel += zAccel; @@ -1014,14 +1014,14 @@ void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { waterChain->drag = 0.9f; waterChain->restoreXZ = -0.0002f; waterChain->restoreY = -0.0002f; - waterChain->wobble = 0.003f; + waterChain->swayMax = 0.003f; if (RANDU_BITS(5) == 0) { s16 randAngle = RANDU_BITS(16); - waterChain->wobbleXZ = Math_SinS(randAngle) * 1.8f * waterChain->wobble; - waterChain->wobbleY = Math_CosS(randAngle) * 0.2f * waterChain->wobble; - waterChain->wobblePhaseVel = RANDU_BITS(13); + waterChain->swayXZ = Math_SinS(randAngle) * 1.8f * waterChain->swayMax; + waterChain->swayY = Math_CosS(randAngle) * 0.2f * waterChain->swayMax; + waterChain->swayPhaseVel = RANDU_BITS(13); } ObjMine_Water_UpdateChain(this, play); diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 92176d36a..05a4e1a40 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -45,9 +45,9 @@ typedef struct { /* 0x44 */ f32 drag; /* 0x48 */ f32 knockback; /* 0x4C */ s16 knockbackAngle; - /* 0x50 */ f32 wobbleSize; - /* 0x54 */ s16 wobblePhase; - /* 0x58 */ f32 wobble; + /* 0x50 */ f32 swaySize; + /* 0x54 */ s16 swayPhase; + /* 0x58 */ f32 swayMax; /* 0x5C */ f32 wallCheckDist; /* 0x60 */ ObjMineAirLink links[OBJMINE_CHAIN_MAX]; } ObjMineAirChain; // size = 0x15C @@ -63,10 +63,10 @@ typedef struct { /* 0x00 */ f32 drag; /* 0x04 */ Vec3f knockbackDir; /* 0x10 */ f32 knockback; - /* 0x14 */ f32 wobbleXZ; - /* 0x18 */ f32 wobbleY; - /* 0x1C */ f32 wobble; - /* 0x20 */ s16 wobblePhaseVel; + /* 0x14 */ f32 swayXZ; + /* 0x18 */ f32 swayY; + /* 0x1C */ f32 swayMax; + /* 0x20 */ s16 swayPhaseVel; /* 0x24 */ f32 restoreXZ; /* 0x28 */ f32 maxY; /* 0x2C */ f32 restY; From 1789fe5a854fc00bba3234194885b767383ff8ff Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 13 Apr 2023 17:41:26 -0500 Subject: [PATCH 095/130] merge and such --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 970b1050e..d1c68f41b 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -140,7 +140,7 @@ s32 ObjMine_GetUnitVec3fNorm(Vec3f* src, Vec3f* dst, f32* norm, f32* invNorm) { void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; @@ -151,7 +151,7 @@ void ObjMine_AirWater_SpawnBomb(ObjMine* this, PlayState* play) { f32 x = this->collider.elements[0].dim.worldSphere.center.x; f32 y = this->collider.elements[0].dim.worldSphere.center.y - BOMB_SPAWN_OFFSET; f32 z = this->collider.elements[0].dim.worldSphere.center.z; - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, ENBOM_0); + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; @@ -193,7 +193,7 @@ void ObjMine_Air_CheckAC(ObjMine* this, s16* hitAngle, s16* torqueAngle) { Vec3s* hitPos3s = &this->collider.elements[0].info.bumper.hitPos; Math_Vec3s_ToVec3f(&hitPos, hitPos3s); - *hitAngle = Actor_YawBetweenActors(attackActor, &this->actor); + *hitAngle = Actor_WorldYawTowardActor(attackActor, &this->actor); *torqueAngle = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - yawToAttack; } } @@ -771,17 +771,17 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { target = this->pathSpeed; step = this->pathSpeed * 0.16f; } - Math_StepToF(&this->actor.speedXZ, target, step); + Math_StepToF(&this->actor.speed, target, step); // Checks if mine will reach the waypoint next frame - if ((this->actor.speedXZ + 0.05f) < distToWaypoint) { - // Scales thisx->velocity to be equal in magnitude to speedXZ - Math_Vec3f_Scale(&thisx->velocity, this->actor.speedXZ / distToWaypoint); + if ((this->actor.speed + 0.05f) < distToWaypoint) { + // Scales thisx->velocity to be equal in magnitude to speed + Math_Vec3f_Scale(&thisx->velocity, this->actor.speed / distToWaypoint); this->actor.world.pos.x += thisx->velocity.x; this->actor.world.pos.y += thisx->velocity.y; this->actor.world.pos.z += thisx->velocity.z; } else { - this->actor.speedXZ *= 0.4f; + this->actor.speed *= 0.4f; this->waypointIndex++; if (this->waypointIndex >= this->waypointCount) { this->waypointIndex = 0; @@ -798,7 +798,7 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { // Makes mines appear to roll while traversing the path Math3D_CrossProduct(&sStandardBasis.y, &thisx->velocity, &yhatCrossV); if (ObjMine_GetUnitVec3f(&yhatCrossV, &rotAxis)) { - Matrix_RotateAxisF(this->actor.speedXZ / PATH_RADIUS, &rotAxis, MTXMODE_NEW); + Matrix_RotateAxisF(this->actor.speed / PATH_RADIUS, &rotAxis, 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); From 279e3049e5524988a4a579a1ae543ebae0af5591 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Fri, 14 Apr 2023 08:48:19 -0500 Subject: [PATCH 096/130] format --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index d1c68f41b..f9ec833c5 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -138,9 +138,9 @@ s32 ObjMine_GetUnitVec3fNorm(Vec3f* src, Vec3f* dst, f32* norm, f32* invNorm) { } void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { - EnBom* bomb = - (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, BOMB_TYPE_BODY); + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y - BOMB_SPAWN_OFFSET, this->actor.world.pos.z, 0, 0, 0, + BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; From a635b540ee9096478af3786e9ca4617e7e19a766 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Fri, 14 Apr 2023 11:35:58 -0500 Subject: [PATCH 097/130] more format and cleanup --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 229 ++++++++++-------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 21 +- 2 files changed, 132 insertions(+), 118 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index f9ec833c5..cc3ee9fd7 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -109,15 +109,15 @@ void ObjMine_Path_MoveToWaypoint(ObjMine* this, s32 index) { } s32 ObjMine_GetUnitVec3f(Vec3f* src, Vec3f* dst) { - f32 mag = Math3D_Vec3fMagnitude(src); + f32 magnitude = Math3D_Vec3fMagnitude(src); - if (mag < 0.001f) { + if (magnitude < 0.001f) { return false; } - dst->x = src->x * (1.0f / mag); - dst->y = src->y * (1.0f / mag); - dst->z = src->z * (1.0f / mag); + dst->x = src->x * (1.0f / magnitude); + dst->y = src->y * (1.0f / magnitude); + dst->z = src->z * (1.0f / magnitude); return true; } @@ -290,7 +290,7 @@ void ObjMine_UpdateCollider(ObjMine* this) { } void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { - f32 linkCountF = linkCount; + f32 linkCountF = (f32)linkCount; ObjMineAirChain* airChain = &this->chain.air; ObjMineAirLink* airLink; s32 i; @@ -304,8 +304,8 @@ void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { // Sets restoring force and drag. Longer chains have lower frequency and less drag. if (linkCount > 0) { - airChain->restore = -sqrtf((0.124992f / (63.0f)) / linkCountF); // constant is close to 1/8 - airChain->drag = 0.95f + ((0.02000004f / (63.0f)) * linkCountF); // constant is close to 1/50 + airChain->restore = -sqrtf((0.124992f / OBJMINE_CHAIN_MAX) / linkCountF); // constant is close to 1/8 + airChain->drag = 0.95f + ((0.02000004f / OBJMINE_CHAIN_MAX) * linkCountF); // constant is close to 1/50 } airChain->swayMax = 0.0002f; @@ -316,15 +316,15 @@ void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { } if (wallCheckRadius < 0.0f) { - airChain->wallCheckDist = -1.0f; + airChain->wallCheckDistSq = -1.0f; } else if (wallCheckRadius <= AIR_RADIUS + 1.0f) { - airChain->wallCheckDist = 0.0f; + airChain->wallCheckDistSq = 0.0f; } else { - airChain->wallCheckDist = SQ(wallCheckRadius - AIR_RADIUS); + airChain->wallCheckDistSq = SQ(wallCheckRadius - AIR_RADIUS); } } -void ObjMine_Air_SetCollider(ObjMine* this, s32 linkCount) { +void ObjMine_Air_InitCollider(ObjMine* this, s32 linkCount) { 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); Collider_UpdateSpheres(0, &this->collider); @@ -334,13 +334,15 @@ void ObjMine_Air_SetBasis(ObjMine* this) { ObjMineAirChain* airChain = &this->chain.air; Vec3f tempVec; - tempVec.x = -airChain->xDiff; + tempVec.x = -airChain->displacement.x; tempVec.y = 1.0f; - tempVec.z = -airChain->zDiff; + tempVec.z = -airChain->displacement.z; ObjMine_GetUnitVec3f(&tempVec, &airChain->basis.y); + Math3D_CrossProduct(&sStandardBasis.x, &airChain->basis.y, &tempVec); ObjMine_GetUnitVec3f(&tempVec, &airChain->basis.z); + Math3D_CrossProduct(&airChain->basis.y, &airChain->basis.z, &tempVec); ObjMine_GetUnitVec3f(&tempVec, &airChain->basis.x); } @@ -360,8 +362,8 @@ void ObjMine_Air_SetChainXZ(ObjMine* this) { f32 dx = this->actor.world.pos.x - this->actor.home.pos.x; f32 dz = this->actor.world.pos.z - this->actor.home.pos.z; - this->chain.air.xDiff = dx * invLength; - this->chain.air.zDiff = dz * invLength; + this->chain.air.displacement.x = dx * invLength; + this->chain.air.displacement.z = dz * invLength; } void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { @@ -390,9 +392,9 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { waterLink->pos.x = this->actor.home.pos.x; waterLink->pos.y = linkY; waterLink->pos.z = this->actor.home.pos.z; - waterLink->vel.x = (Rand_ZeroOne() - 0.5f) * swayVel; - waterLink->vel.y = (Rand_ZeroOne() - 0.5f) * swayVel; - waterLink->vel.z = (Rand_ZeroOne() - 0.5f) * swayVel; + waterLink->velocity.x = (Rand_ZeroOne() - 0.5f) * swayVel; + waterLink->velocity.y = (Rand_ZeroOne() - 0.5f) * swayVel; + waterLink->velocity.z = (Rand_ZeroOne() - 0.5f) * swayVel; } waterChain->maxY = linkY; @@ -404,11 +406,11 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { } if (wallCheckRadius < 0.0f) { - waterChain->wallCheckDist = -1.0f; + waterChain->wallCheckDistSq = -1.0f; } else if (wallCheckRadius <= WATER_RADIUS + 1.0f) { - waterChain->wallCheckDist = 0.0f; + waterChain->wallCheckDistSq = 0.0f; } else { - waterChain->wallCheckDist = SQ(wallCheckRadius - WATER_RADIUS); + waterChain->wallCheckDistSq = SQ(wallCheckRadius - WATER_RADIUS); } } @@ -420,9 +422,9 @@ void ObjMine_Water_InitCollider(ObjMine* this, s32 linkCount) { } void ObjMine_Water_SetWorld(ObjMine* this) { - s32 pad; - s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + s32 pad; // Could be recast to thisx as in ObjMine_Path_Move ObjMineWaterChain* waterChain = &this->chain.water; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); if (linkCount == 0) { this->actor.world.pos.y = this->actor.home.pos.y + LINK_SIZE + ATTACH_OFFSET; @@ -436,14 +438,14 @@ void ObjMine_Water_SetWorld(ObjMine* this) { } void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { - s32 pad; + s32 pad; // Could be recast to thisx as in ObjMine_Path_Move ObjMineWaterChain* waterChain = &this->chain.water; waterChain->touchWall = false; - if (waterChain->wallCheckDist > -1e-6f) { + if (waterChain->wallCheckDistSq > -1e-6f) { // Checks for walls if mine is sufficiently far from home. - if (waterChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, - this->actor.world.pos.x, this->actor.world.pos.z)) { + if (waterChain->wallCheckDistSq <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + this->actor.world.pos.x, this->actor.world.pos.z)) { Vec3f centerPos; Vec3f offsetPos; Vec3f dummyResult; @@ -471,30 +473,33 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { if (BgCheck_EntityLineTest1(&play->colCtx, ¢erPos, &offsetPos, &dummyResult, &dummyPoly, true, false, false, true, &dummyBgId)) { waterChain->touchWall = true; - waterChain->wallEjectX = xzDirFromHome.x * -0.2f; - waterChain->wallEjectZ = xzDirFromHome.z * -0.2f; + waterChain->wallEject.x = xzDirFromHome.x * -0.2f; + waterChain->wallEject.z = xzDirFromHome.z * -0.2f; } } } } } -#if 0 -// Probably equivalent, but nightmare loop unrolls. -void ObjMine_Water_ApplyForces(ObjMine *this) { - static Vec3f sLastLinkAccel[0x40]; - ObjMineWaterChain *waterChain = &this->chain.water; - ObjMineWaterLink *waterLink; +#ifdef NON_MATCHING +// Probably equivalent, but nightmare loop unrolls. The tension section also has weird comparisons. It should be +// equivalent to what's written, but it seems the actual code comparisons were implemented differently. ASM suggests +// multiple index variables were used at once. +void ObjMine_Water_ApplyForces(ObjMine* this) { + static Vec3f sLastLinkAccel[OBJMINE_CHAIN_MAX + 1]; + ObjMineWaterChain* waterChain = &this->chain.water; + ObjMineWaterLink* waterLink; s32 i; s16 swayPhase; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 inverseCount = 1.0f / (f32) linkCount; + f32 inverseCount = 1.0f / (f32)linkCount; f32 restoreY = (waterChain->links[linkCount - 1].pos.y - waterChain->restY) * waterChain->restoreY; Vec3f tension; f32 scaledKnockback; // Applies the buoyant force and sway from the water. - for(i = 0, waterLink = waterChain->links, swayPhase = 0; i < linkCount; i++, waterLink++, swayPhase += waterChain->swayPhaseVel) { + for (i = 0, waterLink = waterChain->links, swayPhase = 0; i < linkCount; + i++, waterLink++, swayPhase += waterChain->swayPhaseVel) { Math_Vec3f_Copy(&sLastLinkAccel[i], &waterLink->accel); if (waterLink->pos.y <= this->actor.home.pos.y) { waterLink->accel.y = waterChain->restoreY * -96.0f; @@ -510,49 +515,51 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { waterLink->accel.z += waterChain->swayXZ * Math_CosS(swayPhase); } - // Applies knockback force. Knockback on the links is scaled quadratically, possibly to account for link rotations being cumulative + // Applies knockback force. Knockback on the links is scaled quadratically, possibly to account for link rotations + // being cumulative if (waterChain->knockback > 0.0001f) { - for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { scaledKnockback = SQ((linkCount - i) * inverseCount); - + waterLink->accel.x += waterChain->knockbackDir.x * scaledKnockback; waterLink->accel.y += waterChain->knockbackDir.y * scaledKnockback; waterLink->accel.z += waterChain->knockbackDir.z * scaledKnockback; } } - // Links that intersect walls are ejected from them. + // Moves chain away from wall if mine is intersecting one if (waterChain->touchWall) { - for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { - waterLink->accel.x += waterChain->wallEjectX; - waterLink->accel.z += waterChain->wallEjectZ; + for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + waterLink->accel.x += waterChain->wallEject.x; + waterLink->accel.z += waterChain->wallEject.z; } } - // Forces on the links from other links. This is simulated by a triangle filter on the forces from the previous frame. - for(i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { + // Forces on the links from other links. This is simulated by a triangle filter on the forces from the previous + // frame. + for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { Math_Vec3f_Copy(&tension, &gZeroVec3f); - if(i - 2 >= 0) { + if (i - 2 >= 0) { tension.x += sLastLinkAccel[i - 2].x * 0.075f; tension.y += sLastLinkAccel[i - 2].y * 0.075f; tension.z += sLastLinkAccel[i - 2].z * 0.075f; } - if(i - 1 >= 0) { + if (i - 1 >= 0) { tension.x += sLastLinkAccel[i - 1].x * 0.15f; tension.y += sLastLinkAccel[i - 1].y * 0.15f; tension.z += sLastLinkAccel[i - 1].z * 0.15f; } - tension.x += sLastLinkAccel[i].x * 0.3f; - tension.y += sLastLinkAccel[i].y * 0.3f; - tension.z += sLastLinkAccel[i].z * 0.3f; + tension.x += sLastLinkAccel[i].x * 0.3f; + tension.y += sLastLinkAccel[i].y * 0.3f; + tension.z += sLastLinkAccel[i].z * 0.3f; - if(i + 1 < linkCount) { + if (i + 1 < linkCount) { tension.x += sLastLinkAccel[i + 1].x * 0.15f; tension.y += sLastLinkAccel[i + 1].y * 0.15f; tension.z += sLastLinkAccel[i + 1].z * 0.15f; } - if(i + 2 < linkCount) { + if (i + 2 < linkCount) { tension.x += sLastLinkAccel[i + 2].x * 0.075f; tension.y += sLastLinkAccel[i + 2].y * 0.075f; tension.z += sLastLinkAccel[i + 2].z * 0.075f; @@ -561,7 +568,6 @@ void ObjMine_Water_ApplyForces(ObjMine *this) { waterLink->accel.y += tension.y; waterLink->accel.z += tension.z; } - } #else Vec3f D_80A849D0[0x40]; @@ -570,13 +576,13 @@ void ObjMine_Water_ApplyForces(ObjMine* this); #endif void ObjMine_Water_UpdateLinks(ObjMine* this) { - s32 pad; + s32 pad; // Could be recast to thisx as in ObjMine_Path_Move ObjMineMtxF3 newBasis; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); ObjMineWaterChain* waterChain = &this->chain.water; ObjMineWaterLink* waterLink; s32 i; - Vec3f* jointBasisX; + Vec3f* prevBasisX; Vec3f tempVec; Vec3f diffDir; Vec3f unusedLinkPos; @@ -592,23 +598,24 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { jointPos.y = this->actor.home.pos.y + (LINK_SIZE / 2.0f); jointPos.z = this->actor.home.pos.z; - for (i = 0, jointBasisX = NULL, waterLink = waterChain->links; i < linkCount; - i++, jointBasisX = &waterLink->basis.x, waterLink++) { + for (i = 0, prevBasisX = NULL, waterLink = waterChain->links; i < linkCount; + i++, prevBasisX = &waterLink->basis.x, waterLink++) { changeBasis = false; - waterLink->vel.x += waterLink->accel.x; - waterLink->vel.y += waterLink->accel.y; - waterLink->vel.z += waterLink->accel.z; + waterLink->velocity.x += waterLink->accel.x; + waterLink->velocity.y += waterLink->accel.y; + waterLink->velocity.z += waterLink->accel.z; - Math_Vec3f_Scale(&waterLink->vel, waterChain->drag); + Math_Vec3f_Scale(&waterLink->velocity, waterChain->drag); Math_Vec3f_Copy(&unusedLinkPos, &waterLink->pos); - waterLink->pos.x += waterLink->vel.x; - waterLink->pos.y += waterLink->vel.y; - waterLink->pos.z += waterLink->vel.z; + waterLink->pos.x += waterLink->velocity.x; + waterLink->pos.y += waterLink->velocity.y; + waterLink->pos.z += waterLink->velocity.z; - if ((waterLink->pos.y <= this->actor.home.pos.y) && (waterLink->vel.y < 0.0f)) { - waterLink->vel.y *= 0.1f; + // Heavily reduce velocity if link is below home and moving downward. + if ((waterLink->pos.y <= this->actor.home.pos.y) && (waterLink->velocity.y < 0.0f)) { + waterLink->velocity.y *= 0.1f; } // If the calculated position is less than 1/3 of the link's length from the joint, the chain is considered @@ -619,10 +626,12 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &dummyInvNorm) && (diffNorm > LINK_SIZE / 3.0f)) { Math_Vec3f_Copy(&newBasis.y, &waterLink->basis.y); ObjMine_StepUntilParallel(&newBasis.y, &diffDir, M_PI / 30); - tempBasisX = (jointBasisX == NULL) ? &sStandardBasis.x : jointBasisX; + + tempBasisX = (prevBasisX == NULL) ? &sStandardBasis.x : prevBasisX; Math3D_CrossProduct(tempBasisX, &newBasis.y, &tempVec); + // Skips change of basis if any of the basis vectors would be zero. if (ObjMine_GetUnitVec3f(&tempVec, &newBasis.z)) { Math3D_CrossProduct(&newBasis.y, &newBasis.z, &tempVec); if (ObjMine_GetUnitVec3f(&tempVec, &newBasis.x)) { @@ -639,6 +648,8 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { diffNorm = LINK_SIZE / 3.0f; } + // Sets new link position from calculated rotation basis. The check ensures displacement from the previous link + // doesn't cause the links to separate if (diffNorm >= (LINK_SIZE / 2.0f)) { waterLink->pos.x = jointPos.x + (waterLink->basis.y.x * (LINK_SIZE / 2.0f)); waterLink->pos.y = jointPos.y + (waterLink->basis.y.y * (LINK_SIZE / 2.0f)); @@ -649,6 +660,7 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { waterLink->pos.z = jointPos.z + (waterLink->basis.y.z * diffNorm); } + // Calculate the position of the joint with the next link. jointPos.x = waterLink->pos.x + (waterLink->basis.y.x * (LINK_SIZE / 2.0f)); jointPos.y = waterLink->pos.y + (waterLink->basis.y.y * (LINK_SIZE / 2.0f)); jointPos.z = waterLink->pos.z + (waterLink->basis.y.z * (LINK_SIZE / 2.0f)); @@ -662,7 +674,7 @@ void ObjMine_Water_UpdateChain(ObjMine* this, PlayState* play) { } void ObjMine_Init(Actor* thisx, PlayState* play) { - s32 pad; + s32 pad; // Can be playstate recast. Must be gamestate recast. ObjMine* this = THIS; s32 pathIndex = OBJMINE_GET_PATH(&this->actor); Path* path; @@ -712,7 +724,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { this->actor.draw = ObjMine_Air_Draw; ObjMine_Air_InitChain(this, linkCount); this->actor.world.pos.y = -ATTACH_OFFSET - (linkCount * LINK_SIZE) + this->actor.home.pos.y; - ObjMine_Air_SetCollider(this, linkCount); + ObjMine_Air_InitCollider(this, linkCount); func_800B4AEC(play, &this->actor, 0.0f); if (linkCount == 0) { ObjMine_Air_SetupStationary(this); @@ -735,6 +747,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { void ObjMine_Destroy(Actor* thisx, PlayState* play) { ObjMine* this = THIS; + // PlayState* play = play2; // must be in this order to match with recast Collider_DestroyJntSph(play, &this->collider); } @@ -747,7 +760,7 @@ void ObjMine_Path_Stationary(ObjMine* this, PlayState* play) { } void ObjMine_Path_SetupMove(ObjMine* this) { - this->actor.flags |= ACTOR_FLAG_10; // @bug? Sets flag 10, but later checks flag 40. + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = ObjMine_Path_Move; } @@ -757,8 +770,9 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { f32 distToWaypoint; f32 step; f32 target; - s32 dummyBgVec; + s32 dummyBgId; + // thisx->velocity is temporarily set to the vector difference to the next waypoint. Math_Vec3s_ToVec3f(&nextWaypoint, &this->waypoints[this->waypointIndex + 1]); Math_Vec3f_Diff(&nextWaypoint, &thisx->world.pos, &thisx->velocity); distToWaypoint = Math3D_Vec3fMagnitude(&thisx->velocity); @@ -775,7 +789,7 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { // Checks if mine will reach the waypoint next frame if ((this->actor.speed + 0.05f) < distToWaypoint) { - // Scales thisx->velocity to be equal in magnitude to speed + // Rescales thisx->velocity to be equal in magnitude to speed Math_Vec3f_Scale(&thisx->velocity, this->actor.speed / distToWaypoint); this->actor.world.pos.x += thisx->velocity.x; this->actor.world.pos.y += thisx->velocity.y; @@ -788,8 +802,8 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { } ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); } - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgVec, - &this->actor, &thisx->world.pos); + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgId, &this->actor, &thisx->world.pos); if (this->actor.flags & ACTOR_FLAG_40) { Vec3f rotAxis; Vec3f yhatCrossV; @@ -833,14 +847,14 @@ void ObjMine_Air_SetupChained(ObjMine* this) { } void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { - s32 pad; + s32 pad; // Could be recast to thisx as in ObjMine_Path_Move s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); ObjMineAirChain* airChain = &this->chain.air; ObjMineAirLink* airLink; s32 i; f32 xAccel; f32 zAccel; - f32 torque; + f32 spin; s16 twistDiff; Math_Vec3f_Copy(&airChain->translation, &airChain->basis.y); @@ -876,8 +890,8 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { if (airChain->knockback > 0.0001f) { xAccel = Math_SinS(airChain->knockbackAngle) * airChain->knockback; zAccel = Math_CosS(airChain->knockbackAngle) * airChain->knockback; - airChain->xVel += xAccel; - airChain->zVel += zAccel; + airChain->velocity.x += xAccel; + airChain->velocity.z += zAccel; Math_StepToF(&airChain->knockback, 0.0f, AIR_KNOCKBACK * 0.5f); } @@ -888,32 +902,32 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { } xAccel = Math_SinS(airChain->swayPhase) * airChain->swaySize; zAccel = Math_CosS(airChain->swayPhase) * airChain->swaySize; - airChain->xVel += xAccel; - airChain->zVel += zAccel; + airChain->velocity.x += xAccel; + airChain->velocity.z += zAccel; // Applies the restoring force of gravity and chain tension using small-angle approximation - airChain->xVel += airChain->xDiff * airChain->restore; - airChain->zVel += airChain->zDiff * airChain->restore; + airChain->velocity.x += airChain->displacement.x * airChain->restore; + airChain->velocity.z += airChain->displacement.z * airChain->restore; // Applies linear drag - airChain->xVel *= airChain->drag; - airChain->zVel *= airChain->drag; + airChain->velocity.x *= airChain->drag; + airChain->velocity.z *= airChain->drag; // Updates scaled position and does a safety clamp to 5.0f. - airChain->xDiff += airChain->xVel; - airChain->zDiff += airChain->zVel; + airChain->displacement.x += airChain->velocity.x; + airChain->displacement.z += airChain->velocity.z; - airChain->xDiff = CLAMP(airChain->xDiff, -5.0f, 5.0f); - airChain->zDiff = CLAMP(airChain->zDiff, -5.0f, 5.0f); + airChain->displacement.x = CLAMP(airChain->displacement.x, -5.0f, 5.0f); + airChain->displacement.z = CLAMP(airChain->displacement.z, -5.0f, 5.0f); ObjMine_Air_SetBasis(this); ObjMine_Air_SetWorld(this); // Checks for wall collisions if sufficiently far from home. If collision detected, bounce off the wall at half // speed. If speed is close to zero when hitting wall, weakly eject it instead. - if (airChain->wallCheckDist > -1e-6f) { - if (airChain->wallCheckDist <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, - this->actor.home.pos.x, this->actor.home.pos.z)) { + if (airChain->wallCheckDistSq > -1e-6f) { + if (airChain->wallCheckDistSq <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z)) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, AIR_RADIUS, 0.0f, 1); @@ -925,9 +939,9 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { f32 xzSpeed; f32 dummyInvNorm; - xzVel.x = airChain->xVel; + xzVel.x = airChain->velocity.x; xzVel.y = 0.0f; - xzVel.z = airChain->zVel; + xzVel.z = airChain->velocity.z; if (ObjMine_GetUnitVec3fNorm(&xzVel, &xzDir, &xzSpeed, &dummyInvNorm)) { wallNormal.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); @@ -937,11 +951,11 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { func_80179F64(&xzDir, &wallNormal, &reflectedDir); xzSpeed /= 2.0f; - airChain->xVel = reflectedDir.x * xzSpeed; - airChain->zVel = reflectedDir.z * xzSpeed; + airChain->velocity.x = reflectedDir.x * xzSpeed; + airChain->velocity.z = reflectedDir.z * xzSpeed; } else { - airChain->xVel *= -0.1f; - airChain->zVel *= -0.1f; + airChain->velocity.x *= -0.1f; + airChain->velocity.z *= -0.1f; } ObjMine_Air_SetChainXZ(this); ObjMine_Air_SetBasis(this); @@ -954,9 +968,9 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { // random torque for variance, and a linear drag. for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { twistDiff = airLink->twist - 0x4000; - torque = airLink->spin + (twistDiff * -0.05f) + RAND_PLUSMINUS(15.0f); - torque *= 0.995f; - airLink->spin = torque; + spin = airLink->spin + (twistDiff * -0.05f) + (30.0f * Rand_ZeroOne() - 15.0f); + spin *= 0.995f; + airLink->spin = spin; airLink->twist += airLink->spin; } @@ -1016,6 +1030,7 @@ void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { waterChain->restoreY = -0.0002f; waterChain->swayMax = 0.003f; + // Chooses a new sway randomly about every 32 frames. if (RANDU_BITS(5) == 0) { s16 randAngle = RANDU_BITS(16); @@ -1049,7 +1064,7 @@ void ObjMine_Water_Stationary(ObjMine* this, PlayState* play) { } void ObjMine_Path_Update(Actor* thisx, PlayState* play) { - s32 pad; + s32 pad; // Can be playstate recast. ObjMine* this = THIS; if ((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.acFlags & AC_HIT)) { @@ -1077,7 +1092,7 @@ void ObjMine_AirWater_Update(Actor* thisx, PlayState* play) { } void ObjMine_Path_Draw(Actor* thisx, PlayState* play) { - s32 pad; + s32 pad; // Can be playstate recast ObjMine* this = THIS; OPEN_DISPS(play->state.gfxCtx); @@ -1099,7 +1114,7 @@ void ObjMine_Path_Draw(Actor* thisx, PlayState* play) { } void ObjMine_DrawExplosion(Actor* thisx, PlayState* play) { - s32 pad; // This could be thisx recast or playstate recast. + s32 pad; // This could be thisx recast or playstate recast. Not enough room on stack for both. OPEN_DISPS(play->state.gfxCtx); @@ -1115,7 +1130,7 @@ void ObjMine_DrawExplosion(Actor* thisx, PlayState* play) { } void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { - s32 pad; + s32 pad; // Can be playstate recast ObjMine* this = THIS; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); ObjMineAirChain* airChain = &this->chain.air; @@ -1172,7 +1187,7 @@ void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { } void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { - s32 pad; + s32 pad; // Can be playstate recast ObjMine* this = THIS; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); ObjMineWaterChain* waterChain = &this->chain.water; diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 05a4e1a40..5338602e2 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -12,8 +12,10 @@ typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); #define OBJMINE_GET_PATH_SPEED(thisx) (((thisx)->params >> 8) & 7) #define OBJMINE_GET_TYPE(thisx) (((thisx)->params >> 12) & 3) -#define OBJMINE_SET_PARAM0(pathIndex, pathSpeed, type) ((pathIndex) | ((pathSpeed) << 8)) -#define OBJMINE_SET_PARAM12(linkCount, type) ((linkCount) | ((type) << 0xC)) +#define OBJMINE_SET_PARAM(type, linkCount, pathIndex, pathSpeed) (((type) << 0xC) | ((type == OBJMINE_TYPE_PATH) ? ((pathIndex) | ((pathSpeed) << 8)) : (linkCount))) +#define OBJMINE_PATH_SET_PARAM(pathIndex, pathSpeed) OBJMINE_SET_PARAM(OBJMINE_TYPE_PATH, 0, pathIndex, pathSpeed) +#define OBJMINE_AIR_SET_PARAM(linkCount) OBJMINE_SET_PARAM(OBJMINE_TYPE_AIR, linkCount, 0, 0) +#define OBJMINE_WATER_SET_PARAM(linkCount) OBJMINE_SET_PARAM(OBJMINE_TYPE_WATER, linkCount, 0, 0) #define OBJMINE_CHAIN_MAX 63 @@ -37,10 +39,8 @@ typedef struct { typedef struct { /* 0x00 */ ObjMineMtxF3 basis; /* 0x24 */ Vec3f translation; // unused - /* 0x30 */ f32 xDiff; - /* 0x34 */ f32 zDiff; - /* 0x38 */ f32 xVel; - /* 0x3C */ f32 zVel; + /* 0x30 */ Vec2f displacement; + /* 0x38 */ Vec2f velocity; /* 0x40 */ f32 restore; /* 0x44 */ f32 drag; /* 0x48 */ f32 knockback; @@ -48,14 +48,14 @@ typedef struct { /* 0x50 */ f32 swaySize; /* 0x54 */ s16 swayPhase; /* 0x58 */ f32 swayMax; - /* 0x5C */ f32 wallCheckDist; + /* 0x5C */ f32 wallCheckDistSq; /* 0x60 */ ObjMineAirLink links[OBJMINE_CHAIN_MAX]; } ObjMineAirChain; // size = 0x15C typedef struct { /* 0x00 */ ObjMineMtxF3 basis; /* 0x24 */ Vec3f pos; - /* 0x30 */ Vec3f vel; + /* 0x30 */ Vec3f velocity; /* 0x3C */ Vec3f accel; } ObjMineWaterLink; // size = 0x48 @@ -71,9 +71,8 @@ typedef struct { /* 0x28 */ f32 maxY; /* 0x2C */ f32 restY; /* 0x30 */ f32 restoreY; - /* 0x34 */ f32 wallCheckDist; - /* 0x38 */ f32 wallEjectX; - /* 0x3C */ f32 wallEjectZ; + /* 0x34 */ f32 wallCheckDistSq; + /* 0x38 */ Vec2f wallEject; /* 0x40 */ s8 touchWall; /* 0x44 */ ObjMineWaterLink links[OBJMINE_CHAIN_MAX]; } ObjMineWaterChain; // size = 0x11FC From e74f9e07829e92d25ae213555dd1ff2623cd4354 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Fri, 14 Apr 2023 11:39:02 -0500 Subject: [PATCH 098/130] asm stuff --- tools/disasm/functions.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ac3f30ada..2f0a5158d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11171,9 +11171,9 @@ 0x80A81B7C:("ObjMine_Water_InitChain",), 0x80A81D70:("ObjMine_Water_SetCollider",), 0x80A81DEC:("ObjMine_Water_SetWorld",), - 0x80A81E7C:("func_80A81E7C",), + 0x80A81E7C:("ObjMine_Water_WallCheck",), 0x80A81FFC:("ObjMine_Water_ApplyForces",), - 0x80A828A8:("func_80A828A8",), + 0x80A828A8:("ObjMine_Water_UpdateLinks",), 0x80A82C28:("ObjMine_Water_UpdateChain",), 0x80A82C5C:("ObjMine_Init",), 0x80A82F58:("ObjMine_Destroy",), From 5d9d496f0297aa3ed9cb1429a54a8bcade4b5a11 Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Fri, 14 Apr 2023 12:50:31 -0500 Subject: [PATCH 099/130] Update src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c Co-authored-by: Anghelo Carvajal --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index cc3ee9fd7..24c8bbd9c 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -163,7 +163,7 @@ s32 ObjMine_AirWater_CheckOC(ObjMine* this) { return true; } - if ((this->collider.base.ocFlags1 & OC1_HIT)) { + if (this->collider.base.ocFlags1 & OC1_HIT) { Actor* hitActor = this->collider.base.oc; if ((hitActor->id == ACTOR_OBJ_MINE) && (hitActor->room == this->actor.room)) { From 9e3cd5054475bfb88e9e29387eb3725266cd1dc3 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Fri, 14 Apr 2023 14:14:57 -0500 Subject: [PATCH 100/130] now with decomp.me --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 8 +++++--- tools/disasm/variables.txt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index cc3ee9fd7..228f44527 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -6,7 +6,7 @@ #include "z_obj_mine.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "assets/objects/object_ny/object_ny.h" +#include "objects/object_ny/object_ny.h" #define FLAGS 0x00000000 @@ -482,9 +482,11 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { } #ifdef NON_MATCHING +// https://decomp.me/scratch/BW51G // Probably equivalent, but nightmare loop unrolls. The tension section also has weird comparisons. It should be // equivalent to what's written, but it seems the actual code comparisons were implemented differently. ASM suggests // multiple index variables were used at once. + void ObjMine_Water_ApplyForces(ObjMine* this) { static Vec3f sLastLinkAccel[OBJMINE_CHAIN_MAX + 1]; ObjMineWaterChain* waterChain = &this->chain.water; @@ -492,7 +494,7 @@ void ObjMine_Water_ApplyForces(ObjMine* this) { s32 i; s16 swayPhase; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - f32 inverseCount = 1.0f / (f32)linkCount; + f32 inverseCount = 1.0f / linkCount; f32 restoreY = (waterChain->links[linkCount - 1].pos.y - waterChain->restY) * waterChain->restoreY; Vec3f tension; f32 scaledKnockback; @@ -570,7 +572,7 @@ void ObjMine_Water_ApplyForces(ObjMine* this) { } } #else -Vec3f D_80A849D0[0x40]; +Vec3f sLastLinkAccel[OBJMINE_CHAIN_MAX + 1]; void ObjMine_Water_ApplyForces(ObjMine* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Water_ApplyForces.s") #endif diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0b44baae3..c8d56bead 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -12311,7 +12311,7 @@ 0x80A84698:("D_80A84698","f32","",0x4), 0x80A8469C:("D_80A8469C","f32","",0x4), 0x80A846A0:("D_80A846A0","f32","",0x4), - 0x80A849D0:("D_80A849D0","UNK_TYPE4","",0x4), + 0x80A849D0:("sLastLinkAccel","Vec3f[]","",0x4), 0x80A85460:("Obj_Purify_InitVars","UNK_TYPE1","",0x1), 0x80A85480:("ObjPurifyInfoList","UNK_TYPE1","",0x1), 0x80A854A0:("D_80A854A0","UNK_TYPE1","",0x1), From b2b18bed98ddb3f1b0e18c760de4d922b3b618a9 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Fri, 14 Apr 2023 15:07:39 -0500 Subject: [PATCH 101/130] removed some extraneous macros I didn't end up using --- include/macros.h | 1 - src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/include/macros.h b/include/macros.h index 0f372fcc0..5b1a31112 100644 --- a/include/macros.h +++ b/include/macros.h @@ -132,7 +132,6 @@ extern GraphicsContext* __gfxCtx; (void)0 #define SQ(x) ((x) * (x)) -#define CUBE(x) ((x) * (x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) #define DECR(x) ((x) == 0 ? 0 : --(x)) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index f05ccdff0..b63b9dc31 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -21,9 +21,6 @@ #define WATER_KNOCKBACK 7.0f #define AIR_KNOCKBACK 0.04f -#define RAND_PLUSMINUS(limit) (Rand_ZeroOne() * (2.0f * (limit)) - (limit)) -#define RAND_PLUSMINUSALT(limit) ((Rand_ZeroOne() - 0.5f) * (2.0f * limit)) - void ObjMine_Init(Actor* thisx, PlayState* play); void ObjMine_Destroy(Actor* thisx, PlayState* play); void ObjMine_Path_Update(Actor* thisx, PlayState* play); From 3ff090636befbb72f6804848eee9540e149ba700 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Wed, 19 Apr 2023 09:29:43 -0500 Subject: [PATCH 102/130] fixes and formats --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 94 ++++++++++--------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 12 +-- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index b63b9dc31..75cb23af7 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -199,7 +199,7 @@ void ObjMine_Water_CheckAC(ObjMine* this, Vec3f* knockbackDir) { Actor* attackActor = this->collider.base.ac; // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_LIGHT_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) - if ((this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820)) { + if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { Matrix_Push(); Matrix_RotateYS(attackActor->shape.rot.y, MTXMODE_NEW); Matrix_RotateXS(attackActor->shape.rot.x, MTXMODE_APPLY); @@ -225,33 +225,33 @@ void ObjMine_AirWater_Noop(ObjMine* this) { void ObjMine_ReplaceTranslation(Vec3f* translation) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[3][0] = translation->x; - matrix->mf[3][1] = translation->y; - matrix->mf[3][2] = translation->z; + matrix->xw = translation->x; + matrix->yw = translation->y; + matrix->zw = translation->z; } -void ObjMine_ReplaceRotation(ObjMineMtxF3* basis) { +void ObjMine_SetRotation(ObjMineMtxF3* basis) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[0][0] = basis->x.x; - matrix->mf[0][1] = basis->x.y; - matrix->mf[0][2] = basis->x.z; - matrix->mf[0][3] = 0.0f; + matrix->xx = basis->x.x; + matrix->yx = basis->x.y; + matrix->zx = basis->x.z; + matrix->wx = 0.0f; - matrix->mf[1][0] = basis->y.x; - matrix->mf[1][1] = basis->y.y; - matrix->mf[1][2] = basis->y.z; - matrix->mf[1][3] = 0.0f; + matrix->xy = basis->y.x; + matrix->yy = basis->y.y; + matrix->zy = basis->y.z; + matrix->wy = 0.0f; - matrix->mf[2][0] = basis->z.x; - matrix->mf[2][1] = basis->z.y; - matrix->mf[2][2] = basis->z.z; - matrix->mf[2][3] = 0.0f; + matrix->xz = basis->z.x; + matrix->yz = basis->z.y; + matrix->zz = basis->z.z; + matrix->wz = 0.0f; - matrix->mf[3][0] = 0.0f; - matrix->mf[3][1] = 0.0f; - matrix->mf[3][2] = 0.0f; - matrix->mf[3][3] = 1.0f; + matrix->xw = 0.0f; + matrix->yw = 0.0f; + matrix->zw = 0.0f; + matrix->ww = 1.0f; } s32 ObjMine_StepUntilParallel(Vec3f* value, Vec3f* target, f32 angleStep) { @@ -269,7 +269,7 @@ s32 ObjMine_StepUntilParallel(Vec3f* value, Vec3f* target, f32 angleStep) { Math_Vec3f_Copy(&prevValue, value); Math3D_CrossProduct(value, target, &perpVec); if (ObjMine_GetUnitVec3f(&perpVec, &perpNormal)) { - Matrix_RotateAxisS(RADF_TO_BINANG(angleStep), &perpNormal, MTXMODE_NEW); + Matrix_RotateAxisS(RAD_TO_BINANG(angleStep), &perpNormal, MTXMODE_NEW); Matrix_MultVec3f(&prevValue, value); } else { Matrix_RotateXFNew(angleStep); @@ -313,7 +313,7 @@ void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { } if (wallCheckRadius < 0.0f) { - airChain->wallCheckDistSq = -1.0f; + airChain->wallCheckDistSq = -1.0f; // Negative value means skip wall collision checks } else if (wallCheckRadius <= AIR_RADIUS + 1.0f) { airChain->wallCheckDistSq = 0.0f; } else { @@ -403,7 +403,7 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { } if (wallCheckRadius < 0.0f) { - waterChain->wallCheckDistSq = -1.0f; + waterChain->wallCheckDistSq = -1.0f; // Negative value means skip wall collision checks } else if (wallCheckRadius <= WATER_RADIUS + 1.0f) { waterChain->wallCheckDistSq = 0.0f; } else { @@ -440,24 +440,24 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { waterChain->touchWall = false; if (waterChain->wallCheckDistSq > -1e-6f) { - // Checks for walls if mine is sufficiently far from home. + // Checks for walls if mine is sufficiently far from home. If found, sets ejection force towards home. if (waterChain->wallCheckDistSq <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, this->actor.world.pos.x, this->actor.world.pos.z)) { Vec3f centerPos; Vec3f offsetPos; - Vec3f dummyResult; + Vec3f result; // not used Vec3f xzFromHome; Vec3f xzDirFromHome; - CollisionPoly* dummyPoly; - s32 dummyBgId; - f32 dummyNorm; - f32 dummyInvNorm; + CollisionPoly* poly; // not used + s32 bgId; // not used + f32 norm; // not used + f32 invNorm; // not used xzFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; xzFromHome.y = 0.0f; xzFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (ObjMine_GetUnitVec3fNorm(&xzFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { + if (ObjMine_GetUnitVec3fNorm(&xzFromHome, &xzDirFromHome, &norm, &invNorm)) { offsetPos.x = this->actor.world.pos.x + (xzDirFromHome.x * WATER_RADIUS); offsetPos.y = this->actor.world.pos.y; @@ -467,8 +467,8 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { centerPos.y = this->actor.world.pos.y; centerPos.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, ¢erPos, &offsetPos, &dummyResult, &dummyPoly, true, - false, false, true, &dummyBgId)) { + if (BgCheck_EntityLineTest1(&play->colCtx, ¢erPos, &offsetPos, &result, &poly, true, false, false, + true, &bgId)) { waterChain->touchWall = true; waterChain->wallEject.x = xzDirFromHome.x * -0.2f; waterChain->wallEject.z = xzDirFromHome.z * -0.2f; @@ -588,7 +588,7 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { Vec3f jointPos; s32 changeBasis; f32 diffNorm; - f32 dummyInvNorm; + f32 invNorm; // not used Vec3f* tempBasisX; // The joint between the current link and next link is half the link's length from its center. The first link is @@ -622,7 +622,7 @@ void ObjMine_Water_UpdateLinks(ObjMine* this) { // joint. The StepUntilParallel causes the chain to straighten over time. Math_Vec3f_Diff(&waterLink->pos, &jointPos, &tempVec); - if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &dummyInvNorm) && (diffNorm > LINK_SIZE / 3.0f)) { + if (ObjMine_GetUnitVec3fNorm(&tempVec, &diffDir, &diffNorm, &invNorm) && (diffNorm > LINK_SIZE / 3.0f)) { Math_Vec3f_Copy(&newBasis.y, &waterLink->basis.y); ObjMine_StepUntilParallel(&newBasis.y, &diffDir, M_PI / 30); @@ -677,7 +677,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { ObjMine* this = THIS; s32 pathIndex = OBJMINE_GET_PATH(&this->actor); Path* path; - s32 dummyBgId; + s32 bgId; // not used s32 type = OBJMINE_GET_TYPE(&this->actor); Actor_ProcessInitChain(&this->actor, sInitChain); @@ -708,7 +708,7 @@ void ObjMine_Init(Actor* thisx, PlayState* play) { &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); - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgId, + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &this->actor.world.pos); } else { s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); @@ -769,7 +769,7 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { f32 distToWaypoint; f32 step; f32 target; - s32 dummyBgId; + s32 bgId; // not used // thisx->velocity is temporarily set to the vector difference to the next waypoint. Math_Vec3s_ToVec3f(&nextWaypoint, &this->waypoints[this->waypointIndex + 1]); @@ -802,7 +802,7 @@ void ObjMine_Path_Move(ObjMine* this, PlayState* play) { ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); } this->actor.floorHeight = - BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgId, &this->actor, &thisx->world.pos); + BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &thisx->world.pos); if (this->actor.flags & ACTOR_FLAG_40) { Vec3f rotAxis; Vec3f yhatCrossV; @@ -930,19 +930,19 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, AIR_RADIUS, 0.0f, 1); - if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (this->actor.wallPoly != NULL)) { Vec3f xzDir; Vec3f reflectedDir; Vec3f wallNormal; Vec3f xzVel; f32 xzSpeed; - f32 dummyInvNorm; + f32 invNorm; // not used xzVel.x = airChain->velocity.x; xzVel.y = 0.0f; xzVel.z = airChain->velocity.z; - if (ObjMine_GetUnitVec3fNorm(&xzVel, &xzDir, &xzSpeed, &dummyInvNorm)) { + if (ObjMine_GetUnitVec3fNorm(&xzVel, &xzDir, &xzSpeed, &invNorm)) { wallNormal.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); wallNormal.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); wallNormal.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); @@ -963,8 +963,10 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { } } - // Applies three torques to individual chain links. The restoring torque towards the default twist of 0x4000, a - // random torque for variance, and a linear drag. + // Applies three torques to individual chain links: + // - restoring torque towards the default twist of 0x4000 + // - random torque for variance + // - linear drag torque for (i = 0, airLink = airChain->links; i < linkCount; i++, airLink++) { twistDiff = airLink->twist - 0x4000; spin = airLink->spin + (twistDiff * -0.05f) + (30.0f * Rand_ZeroOne() - 15.0f); @@ -1148,7 +1150,7 @@ void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - ObjMine_ReplaceRotation(&airChain->basis); + ObjMine_SetRotation(&airChain->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (linkCount != 0) { // Sets pivot point to be half a chain link length below home @@ -1204,7 +1206,7 @@ void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { gSPDisplayList(gfx++, object_ny_DL_000030); for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { - ObjMine_ReplaceRotation(&waterLink->basis); + ObjMine_SetRotation(&waterLink->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); // Consecutive chain links are offset 90 degrees. if ((i % 2) == 0) { diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 5338602e2..26b93be37 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -12,10 +12,10 @@ typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); #define OBJMINE_GET_PATH_SPEED(thisx) (((thisx)->params >> 8) & 7) #define OBJMINE_GET_TYPE(thisx) (((thisx)->params >> 12) & 3) -#define OBJMINE_SET_PARAM(type, linkCount, pathIndex, pathSpeed) (((type) << 0xC) | ((type == OBJMINE_TYPE_PATH) ? ((pathIndex) | ((pathSpeed) << 8)) : (linkCount))) -#define OBJMINE_PATH_SET_PARAM(pathIndex, pathSpeed) OBJMINE_SET_PARAM(OBJMINE_TYPE_PATH, 0, pathIndex, pathSpeed) -#define OBJMINE_AIR_SET_PARAM(linkCount) OBJMINE_SET_PARAM(OBJMINE_TYPE_AIR, linkCount, 0, 0) -#define OBJMINE_WATER_SET_PARAM(linkCount) OBJMINE_SET_PARAM(OBJMINE_TYPE_WATER, linkCount, 0, 0) +#define OBJMINE_PARAM(type, linkCount, pathIndex, pathSpeed) (((type) << 0xC) | ((type == OBJMINE_TYPE_PATH) ? ((pathIndex) | ((pathSpeed) << 8)) : (linkCount))) +#define OBJMINE_PATH_PARAM(pathIndex, pathSpeed) OBJMINE_PARAM(OBJMINE_TYPE_PATH, 0, pathIndex, pathSpeed) +#define OBJMINE_AIR_PARAM(linkCount) OBJMINE_PARAM(OBJMINE_TYPE_AIR, linkCount, 0, 0) +#define OBJMINE_WATER_PARAM(linkCount) OBJMINE_PARAM(OBJMINE_TYPE_WATER, linkCount, 0, 0) #define OBJMINE_CHAIN_MAX 63 @@ -32,8 +32,8 @@ typedef struct { } ObjMineMtxF3; // size = 0x24 typedef struct { - /* 0x00 */ s16 twist; - /* 0x02 */ s16 spin; + /* 0x0 */ s16 twist; + /* 0x2 */ s16 spin; } ObjMineAirLink; // size = 0x4 typedef struct { From 82324a84f7b378c6cb3a399557d0e841987bfd4e Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 8 Jun 2023 06:39:57 -0500 Subject: [PATCH 103/130] merge --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 75cb23af7..25c07120a 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -260,7 +260,7 @@ s32 ObjMine_StepUntilParallel(Vec3f* value, Vec3f* target, f32 angleStep) { Vec3f perpNormal; f32 cosAngle = Math3D_Parallel(value, target); - if (cos_rad(angleStep) <= cosAngle) { + if (Math_CosF(angleStep) <= cosAngle) { Math_Vec3f_Copy(value, target); return true; } @@ -1103,7 +1103,7 @@ void ObjMine_Path_Draw(Actor* thisx, PlayState* play) { } func_800B8050(&this->actor, play, true); - func_8012C28C(play->state.gfxCtx); + Gfx_SetupDL25_Opa(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2); @@ -1120,7 +1120,7 @@ void ObjMine_DrawExplosion(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); func_800B8118(thisx, play, true); - func_8012C2DC(play->state.gfxCtx); + Gfx_SetupDL25_Xlu(play->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 75); @@ -1146,7 +1146,7 @@ void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; - gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPDisplayList(gfx++, &gSetupDLs[SETUPDL_25]); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); @@ -1201,7 +1201,7 @@ void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; - gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPDisplayList(gfx++, &gSetupDLs[SETUPDL_25]); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); From a1f4906aa0453c7bd148087816f1c9345badeaf8 Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 8 Jun 2023 17:41:07 -0500 Subject: [PATCH 104/130] my god, it matches --- spec | 4 -- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 50 +++++++++---------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/spec b/spec index 9f7cb3dd4..bb4a78b66 100644 --- a/spec +++ b/spec @@ -2926,11 +2926,7 @@ beginseg name "ovl_Obj_Mine" compress include "build/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Mine/ovl_Obj_Mine_reloc.o" -#else - include "build/data/ovl_Obj_Mine/ovl_Obj_Mine.reloc.o" -#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 25c07120a..23c520b31 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -478,28 +478,27 @@ void ObjMine_Water_WallCheck(ObjMine* this, PlayState* play) { } } -#ifdef NON_MATCHING -// https://decomp.me/scratch/BW51G -// Probably equivalent, but nightmare loop unrolls. The tension section also has weird comparisons. It should be -// equivalent to what's written, but it seems the actual code comparisons were implemented differently. ASM suggests -// multiple index variables were used at once. +Vec3f sLastLinkAccel[OBJMINE_CHAIN_MAX + 1]; void ObjMine_Water_ApplyForces(ObjMine* this) { - static Vec3f sLastLinkAccel[OBJMINE_CHAIN_MAX + 1]; ObjMineWaterChain* waterChain = &this->chain.water; ObjMineWaterLink* waterLink; s32 i; - s16 swayPhase; + s16 swayPhase = 0; s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); f32 inverseCount = 1.0f / linkCount; f32 restoreY = (waterChain->links[linkCount - 1].pos.y - waterChain->restY) * waterChain->restoreY; Vec3f tension; f32 scaledKnockback; + s32 index; + s32 pad; + Vec3f* lastLinkAccel; // Applies the buoyant force and sway from the water. - for (i = 0, waterLink = waterChain->links, swayPhase = 0; i < linkCount; - i++, waterLink++, swayPhase += waterChain->swayPhaseVel) { - Math_Vec3f_Copy(&sLastLinkAccel[i], &waterLink->accel); + for (i = 0, waterLink = waterChain->links, lastLinkAccel = sLastLinkAccel; i < linkCount; + i++, waterLink++, swayPhase += waterChain->swayPhaseVel, lastLinkAccel++) { + Math_Vec3f_Copy(lastLinkAccel, &waterLink->accel); + if (waterLink->pos.y <= this->actor.home.pos.y) { waterLink->accel.y = waterChain->restoreY * -96.0f; } else if (restoreY > 0.0f) { @@ -507,6 +506,7 @@ void ObjMine_Water_ApplyForces(ObjMine* this) { } else { waterLink->accel.y = restoreY; } + waterLink->accel.x = (waterLink->pos.x - this->actor.home.pos.x) * waterChain->restoreXZ; waterLink->accel.z = (waterLink->pos.z - this->actor.home.pos.z) * waterChain->restoreXZ; waterLink->accel.x += waterChain->swayXZ * Math_SinS(swayPhase); @@ -538,12 +538,14 @@ void ObjMine_Water_ApplyForces(ObjMine* this) { // frame. for (i = 0, waterLink = waterChain->links; i < linkCount; i++, waterLink++) { Math_Vec3f_Copy(&tension, &gZeroVec3f); - if (i - 2 >= 0) { + + if (i >= 2) { tension.x += sLastLinkAccel[i - 2].x * 0.075f; tension.y += sLastLinkAccel[i - 2].y * 0.075f; tension.z += sLastLinkAccel[i - 2].z * 0.075f; } - if (i - 1 >= 0) { + + if (i >= 1) { tension.x += sLastLinkAccel[i - 1].x * 0.15f; tension.y += sLastLinkAccel[i - 1].y * 0.15f; tension.z += sLastLinkAccel[i - 1].z * 0.15f; @@ -553,26 +555,24 @@ void ObjMine_Water_ApplyForces(ObjMine* this) { tension.y += sLastLinkAccel[i].y * 0.3f; tension.z += sLastLinkAccel[i].z * 0.3f; - if (i + 1 < linkCount) { - tension.x += sLastLinkAccel[i + 1].x * 0.15f; - tension.y += sLastLinkAccel[i + 1].y * 0.15f; - tension.z += sLastLinkAccel[i + 1].z * 0.15f; + index = i + 1; + if (index < linkCount) { + tension.x += sLastLinkAccel[index].x * 0.15f; + tension.y += sLastLinkAccel[index].y * 0.15f; + tension.z += sLastLinkAccel[index].z * 0.15f; } - if (i + 2 < linkCount) { - tension.x += sLastLinkAccel[i + 2].x * 0.075f; - tension.y += sLastLinkAccel[i + 2].y * 0.075f; - tension.z += sLastLinkAccel[i + 2].z * 0.075f; + + index = i + 2; + if (index < linkCount) { + tension.x += sLastLinkAccel[index].x * 0.075f; + tension.y += sLastLinkAccel[index].y * 0.075f; + tension.z += sLastLinkAccel[index].z * 0.075f; } waterLink->accel.x += tension.x; waterLink->accel.y += tension.y; waterLink->accel.z += tension.z; } } -#else -Vec3f sLastLinkAccel[OBJMINE_CHAIN_MAX + 1]; -void ObjMine_Water_ApplyForces(ObjMine* this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/ObjMine_Water_ApplyForces.s") -#endif void ObjMine_Water_UpdateLinks(ObjMine* this) { s32 pad; // Could be recast to thisx as in ObjMine_Path_Move From e1b7794f33375d37e672b9a0f8977e62dd7950bd Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 8 Jun 2023 17:41:49 -0500 Subject: [PATCH 105/130] format --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 23c520b31..072371f53 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -561,7 +561,7 @@ void ObjMine_Water_ApplyForces(ObjMine* this) { tension.y += sLastLinkAccel[index].y * 0.15f; tension.z += sLastLinkAccel[index].z * 0.15f; } - + index = i + 2; if (index < linkCount) { tension.x += sLastLinkAccel[index].x * 0.075f; From 5194d2be8bf1c2c97446f67710f0ea2a992871e6 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 11:32:00 +1000 Subject: [PATCH 106/130] cleanup --- include/functions.h | 19 ----------- include/ultra64/os_voice.h | 12 ------- include/z64voice.h | 34 +++++++++++++++++++ src/audio/voice_external.c | 16 +++------ src/audio/voice_internal.c | 3 ++ src/code/padmgr.c | 1 + src/code/z_parameter.c | 15 ++++---- src/libultra/voice/voicegetreaddata.c | 4 +-- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 9 +++-- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 5 +-- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 5 +-- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 7 ++-- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 14 files changed, 71 insertions(+), 63 deletions(-) create mode 100644 include/z64voice.h diff --git a/include/functions.h b/include/functions.h index 6a9ebcf60..39342e094 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2338,25 +2338,6 @@ void Audio_ResetForAudioHeapStep3(void); void Audio_ResetForAudioHeapStep2(void); void Audio_ResetForAudioHeapStep1(s32 specId); -void func_801A4EB0(void); -// void func_801A4EB8(void); -void func_801A4FD8(void); -void func_801A5080(u16 arg0); -u16 func_801A5100(void); -void func_801A5118(void); -UNK_TYPE func_801A51F0(UNK_TYPE arg0); -// void func_801A5228(void); -// void func_801A5390(void); -// void func_801A53E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_801A541C(void); -// void func_801A5488(void); -// void func_801A54C4(void); -// void func_801A54D0(void); -// void func_801A5680(void); -// void func_801A5808(void); -void AudioVoice_ResetData(void); -// void func_801A5A1C(void); - void AudioSfx_MuteBanks(u16 muteMask); void AudioSfx_LowerBgmVolume(u8 channelIndex); void AudioSfx_RestoreBgmVolume(u8 channelIndex); diff --git a/include/ultra64/os_voice.h b/include/ultra64/os_voice.h index 2f7827ed5..fd08d3bf9 100644 --- a/include/ultra64/os_voice.h +++ b/include/ultra64/os_voice.h @@ -29,18 +29,6 @@ typedef struct { /* 0x14 */ u16 distance[5]; // Distance value } OSVoiceData; // size = 0x20 - -typedef enum { - /* 0 */ VOICE_WORD_ID_HOURS, - /* 1 */ VOICE_WORD_ID_CHEESE, - /* 2 */ VOICE_WORD_ID_WAKE_UP, - /* 3 */ VOICE_WORD_ID_SIT, - /* 4 */ VOICE_WORD_ID_MILK, - /* 5 */ VOICE_WORD_ID_HIYA, - /* 6 */ VOICE_WORD_ID_MAX, - /* -1 */ VOICE_WORD_ID_NONE = 0xFFFF -} OSVoiceWordId; - #define VOICE_STATUS_READY 0 /* stop/end */ #define VOICE_STATUS_START 1 /* Voice Undetected (no voice input) */ #define VOICE_STATUS_CANCEL 3 /* Cancel (cancel extraneous noise) */ diff --git a/include/z64voice.h b/include/z64voice.h new file mode 100644 index 000000000..e456c0a12 --- /dev/null +++ b/include/z64voice.h @@ -0,0 +1,34 @@ +#ifndef Z64VOICE_H +#define Z64VOICE_H + +#include "PR/ultratypes.h" +#include "unk.h" +#include "ultra64/os_voice.h" + +typedef enum { + /* 0 */ VOICE_WORD_ID_HOURS, + /* 1 */ VOICE_WORD_ID_CHEESE, + /* 2 */ VOICE_WORD_ID_WAKE_UP, + /* 3 */ VOICE_WORD_ID_SIT, + /* 4 */ VOICE_WORD_ID_MILK, + /* 5 */ VOICE_WORD_ID_HIYA, + /* 6 */ VOICE_WORD_ID_MAX, + /* -1 */ VOICE_WORD_ID_NONE = 0xFFFF +} OSVoiceWordId; + +void func_801A4EB0(void); +void func_801A4FD8(void); +void func_801A5080(u16 wordId); +u16 AudioVoice_GetWord(void); +void func_801A5118(void); +s32 func_801A51F0(s32 errorCode); +s32 func_801A5228(OSVoiceDictionary* dict); +OSVoiceData* func_801A5390(void); +void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); +u8* func_801A54C4(void); +s32 func_801A54D0(u16 wordId); +s32 func_801A5680(u16 wordId); +s32 func_801A5808(void); +void AudioVoice_ResetData(void); + +#endif diff --git a/src/audio/voice_external.c b/src/audio/voice_external.c index b585a2716..69b465e9b 100644 --- a/src/audio/voice_external.c +++ b/src/audio/voice_external.c @@ -1,13 +1,5 @@ #include "global.h" - -void func_801A5080(u16 arg0); -s32 func_801A5228(OSVoiceDictionary* dict); -void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); -s32 func_801A5808(void); -OSVoiceData* func_801A5390(void); -s32 func_801A5680(u16 wordId); -s32 func_801A54D0(u16 wordId); -u8* func_801A54C4(void); +#include "z64voice.h" extern OSVoiceHandle gVoiceHandle; @@ -93,8 +85,8 @@ void func_801A4FD8(void) { D_801D8E3C = 1; } - func_801A5080(5); - func_801A5080(1); + func_801A5080(VOICE_WORD_ID_HIYA); + func_801A5080(VOICE_WORD_ID_CHEESE); } } @@ -112,7 +104,7 @@ void func_801A50C0(u16 wordId) { } // Used externally in many files -u16 func_801A5100(void) { +u16 AudioVoice_GetWord(void) { return sTopScoreWordId; } diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c index 6ad766f91..2367887d5 100644 --- a/src/audio/voice_internal.c +++ b/src/audio/voice_internal.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64voice.h" // internal voice functions u8* func_801A5A1C(s8* word); @@ -265,6 +266,7 @@ s32 func_801A5808(void) { case VOICE_STATUS_READY: D_801FD5A0.mode = 2; break; + case VOICE_STATUS_START: case 2: case VOICE_STATUS_CANCEL: @@ -272,6 +274,7 @@ s32 func_801A5808(void) { case VOICE_STATUS_BUSY: case 6: break; + case VOICE_STATUS_END: D_801FD5A0.mode = 2; break; diff --git a/src/code/padmgr.c b/src/code/padmgr.c index a04a14f57..f8e164c39 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -31,6 +31,7 @@ * done while waiting for this operation to complete. */ #include "global.h" +#include "z64voice.h" #include "io/controller.h" #include "ultra64/motor.h" diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index e63c9d8e5..d3718d55d 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,6 +1,7 @@ #include "global.h" #include "z64snap.h" #include "z64view.h" +#include "z64voice.h" #include "interface/parameter_static/parameter_static.h" #include "interface/do_action_static/do_action_static.h" #include "misc/story_static/story_static.h" @@ -2166,7 +2167,7 @@ void Interface_UpdateButtonsPart1(PlayState* play) { if (gSaveContext.save.cutsceneIndex < 0xFFF0) { gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; if ((player->stateFlags1 & PLAYER_STATE1_800000) || CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) || - (!(CHECK_EVENTINF(EVENTINF_41)) && (play->unk_1887C >= 2))) { + (!CHECK_EVENTINF(EVENTINF_41) && (play->unk_1887C >= 2))) { // Riding Epona OR Honey & Darling minigame OR Horseback balloon minigame OR related to swamp boat // (non-minigame?) if ((player->stateFlags1 & PLAYER_STATE1_800000) && (player->currentMask == PLAYER_MASK_BLAST) && @@ -2239,8 +2240,7 @@ void Interface_UpdateButtonsPart1(PlayState* play) { (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && (Cutscene_GetSceneLayer(play) != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); - } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && - (CHECK_EVENTINF(EVENTINF_35))) { + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && CHECK_EVENTINF(EVENTINF_35)) { Interface_SetHudVisibility(HUD_VISIBILITY_B_MINIMAP); } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_82_08) && (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE)) { @@ -2328,9 +2328,10 @@ void Interface_UpdateButtonsPart1(PlayState* play) { interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; restoreHudVisibility = true; sPictoState = PICTO_BOX_STATE_OFF; - } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || (func_801A5100() == 1)) { - if (!(CHECK_EVENTINF(EVENTINF_41)) || - ((CHECK_EVENTINF(EVENTINF_41)) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || + (AudioVoice_GetWord() == VOICE_WORD_ID_CHEESE)) { + if (!CHECK_EVENTINF(EVENTINF_41) || + (CHECK_EVENTINF(EVENTINF_41) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { play_sound(NA_SE_SY_CAMERA_SHUTTER); SREG(89) = 1; play->haltAllActors = true; @@ -4078,7 +4079,7 @@ void Interface_DrawBButtonIcons(PlayState* play) { (play->sceneId != SCENE_BOWLING) && ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || (gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0))) && - ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || !(CHECK_EVENTINF(EVENTINF_35))) && + ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || !CHECK_EVENTINF(EVENTINF_35)) && (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80) || (play->unk_1887C != 100))) { Interface_DrawAmmoCount(play, EQUIP_SLOT_B, interfaceCtx->bAlpha); } diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index d271f71c7..7f5f1e87b 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -33,7 +33,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { sHandleStatus = data[0] & 7; hd->status = sHandleStatus; - if ((sHandleStatus != 0) && (sHandleStatus != 7)) { + if ((sHandleStatus != VOICE_STATUS_READY) && (sHandleStatus != VOICE_STATUS_END)) { return CONT_ERR_NOT_READY; } // fallthrough @@ -88,7 +88,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } hd->status = data[34] & 7; - if ((sHandleStatus == 0) || (hd->status == 0)) { + if ((sHandleStatus == VOICE_STATUS_READY) || (hd->status == VOICE_STATUS_READY)) { break; } // fallthrough 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 aa74c5007..27fd87bbc 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -6,6 +6,7 @@ #include "z_en_cow.h" #include "z64horse.h" +#include "z64voice.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -132,8 +133,9 @@ void EnCow_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 6; gHorsePlayedEponasSong = false; - func_801A5080(4); + func_801A5080(VOICE_WORD_ID_MILK); break; + case EN_COW_TYPE_TAIL: SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, COW_TAIL_LIMB_MAX); @@ -148,6 +150,9 @@ void EnCow_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; break; + + default: + break; } this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -289,7 +294,7 @@ void EnCow_Idle(EnCow* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { - if (func_801A5100() == 4) { + if (AudioVoice_GetWord() == VOICE_WORD_ID_MILK) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_87_01)) { SET_WEEKEVENTREG(WEEKEVENTREG_87_01); if (Inventory_HasEmptyBottle()) { 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 6f6f2cad9..125f92ad3 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -5,6 +5,7 @@ */ #include "z_en_gs.h" +#include "z64voice.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_gs/object_gs.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -158,7 +159,7 @@ void EnGs_Init(Actor* thisx, PlayState* play) { Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); - func_801A5080(0); + func_801A5080(VOICE_WORD_ID_HOURS); if (this->actor.params == ENGS_1) { Actor_SetScale(&this->actor, 0.15f); this->collider.dim.radius *= 1.5f; @@ -924,7 +925,7 @@ void func_80999BC8(Actor* thisx, PlayState* play2) { EnGs* this = THIS; s32 pad; - if (this->actor.isTargeted && !func_801A5100()) { + if (this->actor.isTargeted && AudioVoice_GetWord() == VOICE_WORD_ID_HOURS) { this->unk_19D = 0; this->unk_19A |= 1; func_80999AC0(this); diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index 8ad694a11..5115a5ef9 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -5,6 +5,7 @@ */ #include "z_en_hidden_nuts.h" +#include "z64voice.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_hintnuts/object_hintnuts.h" @@ -106,7 +107,7 @@ void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { this->path = SubS_GetPathByIndex(play, this->pathIndex, ENHIDDENNUTS_PATH_INDEX_NONE_ALT); this->csId = this->actor.csId; - func_801A5080(2); + func_801A5080(VOICE_WORD_ID_WAKE_UP); func_80BDB268(this); } @@ -186,7 +187,7 @@ void func_80BDB2B8(EnHiddenNuts* this, PlayState* play) { if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_SONATA)) { play->msgCtx.ocarinaMode = 4; func_80BDB788(this); - } else if (func_801A5100() == 2) { + } else if (AudioVoice_GetWord() == VOICE_WORD_ID_WAKE_UP) { func_80BDB788(this); } else { func_800B8614(&this->actor, play, BREG(13) + 100.0f); 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 787a40da7..05fbf25cb 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -7,6 +7,7 @@ #include "z_en_horse.h" #include "z64horse.h" #include "z64rumble.h" +#include "z64voice.h" #include "overlays/actors/ovl_En_In/z_en_in.h" #include "overlays/actors/ovl_Obj_Um/z_obj_um.h" #include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" @@ -3987,9 +3988,9 @@ void func_80886C00(EnHorse* this, PlayState* play) { if (((this->action == ENHORSE_ACTION_MOUNTED_WALK) || (this->action == ENHORSE_ACTION_MOUNTED_TROT) || (this->action == ENHORSE_ACTION_MOUNTED_GALLOP)) && - (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && (play->interfaceCtx.unk_212 == 8) && - !(this->stateFlags & ENHORSE_BOOST) && !(this->stateFlags & ENHORSE_FLAG_8) && - !(this->stateFlags & ENHORSE_FLAG_9)) { + (CHECK_BTN_ALL(input->press.button, BTN_A) || (AudioVoice_GetWord() == VOICE_WORD_ID_HIYA)) && + (play->interfaceCtx.unk_212 == 8) && !(this->stateFlags & ENHORSE_BOOST) && + !(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { if (this->numBoosts > 0) { Rumble_Request(0.0f, 180, 20, 100); this->stateFlags |= ENHORSE_BOOST; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4fc8f07c1..3a66be7ab 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4014,7 +4014,7 @@ 0x801A4FD8:("func_801A4FD8",), 0x801A5080:("func_801A5080",), 0x801A50C0:("func_801A50C0",), - 0x801A5100:("func_801A5100",), + 0x801A5100:("AudioVoice_GetWord",), 0x801A510C:("func_801A510C",), 0x801A5118:("func_801A5118",), 0x801A51F0:("func_801A51F0",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 80d36de95..a72b9e4b1 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3531,7 +3531,7 @@ asm/non_matchings/code/voice_external/func_801A4EB8.s,func_801A4EB8,0x801A4EB8,0 asm/non_matchings/code/voice_external/func_801A4FD8.s,func_801A4FD8,0x801A4FD8,0x2A asm/non_matchings/code/voice_external/func_801A5080.s,func_801A5080,0x801A5080,0x10 asm/non_matchings/code/voice_external/func_801A50C0.s,func_801A50C0,0x801A50C0,0x10 -asm/non_matchings/code/voice_external/func_801A5100.s,func_801A5100,0x801A5100,0x3 +asm/non_matchings/code/voice_external/AudioVoice_GetWord.s,AudioVoice_GetWord,0x801A5100,0x3 asm/non_matchings/code/voice_external/func_801A510C.s,func_801A510C,0x801A510C,0x3 asm/non_matchings/code/voice_external/func_801A5118.s,func_801A5118,0x801A5118,0x36 asm/non_matchings/code/voice_internal/func_801A51F0.s,func_801A51F0,0x801A51F0,0xE From 721d097c101c37683896c726c8086fd16b98da8b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 11:44:07 +1000 Subject: [PATCH 107/130] more cleanup --- src/audio/voice_external.c | 12 ++--- src/audio/voice_internal.c | 89 ++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/audio/voice_external.c b/src/audio/voice_external.c index 69b465e9b..00d5f24a0 100644 --- a/src/audio/voice_external.c +++ b/src/audio/voice_external.c @@ -37,15 +37,15 @@ void func_801A4EB0(void) { void func_801A4EB8(void) { u8* new_var; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; s32 index; u8 sp38[1]; u8 i; if (D_801D8E3C != 0) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); } new_var = func_801A54C4(); @@ -70,13 +70,13 @@ void func_801A4EB8(void) { // Used externally in code_8019AF00 void func_801A4FD8(void) { s32 errorCode; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; func_801A54D0(VOICE_WORD_ID_NONE); if (D_801D8E3C != 0) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); errorCode = func_801A5228(&D_801D8BE0); func_801A54D0(VOICE_WORD_ID_NONE); diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c index 2367887d5..a8a19d228 100644 --- a/src/audio/voice_internal.c +++ b/src/audio/voice_internal.c @@ -2,7 +2,7 @@ #include "z64voice.h" // internal voice functions -u8* func_801A5A1C(s8* word); +u8* func_801A5A1C(s8* words); // BSS OSVoiceUnk D_801FD5A0; @@ -50,13 +50,14 @@ s32 func_801A51F0(s32 errorCode) { case CONT_ERR_VOICE_WORD: case CONT_ERR_VOICE_NO_RESPONSE: return -1; + default: return 0; } } s32 func_801A5228(OSVoiceDictionary* dict) { - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; s32 errorCode; u8 numWords; u8 i; @@ -70,9 +71,9 @@ s32 func_801A5228(OSVoiceDictionary* dict) { numWords = dict->numWords; - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceClearDictionary(&gVoiceHandle, numWords); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (errorCode != 0) { return errorCode; @@ -83,9 +84,9 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } for (i = 0; i < numWords; i++) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceSetWord(&gVoiceHandle, &dict->words[i]); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (func_801A51F0(errorCode) != 0) { func_801A5A1C(&dict->words[i]); @@ -97,14 +98,14 @@ s32 func_801A5228(OSVoiceDictionary* dict) { OSVoiceData* func_801A5390(void) { OSVoiceData* voiceData; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; voiceData = D_801FD5A0.data; D_801FD5A0.data = NULL; - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStartReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); return voiceData; } @@ -126,12 +127,12 @@ void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 // Could have a return? or be void return? s32 func_801A541C(s32 analog, s32 digital) { s32 errorCode; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; if (D_801FD5A0.dict != NULL) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceControlGain(&gVoiceHandle, analog, digital); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (errorCode != 0) { func_801A51F0(errorCode); @@ -142,11 +143,11 @@ s32 func_801A541C(s32 analog, s32 digital) { // Unused s32 func_801A5488(u8* word) { s32 errorCode; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceCheckWord(word); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); return errorCode; } @@ -160,7 +161,7 @@ s32 func_801A54D0(u16 wordId) { u8 phi_t0 = true; u8 numWords; u8 i; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; @@ -182,14 +183,14 @@ s32 func_801A54D0(u16 wordId) { } if (phi_t0) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceMaskDictionary(&gVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); } D_801FD5A0.mode = 0; @@ -203,7 +204,7 @@ s32 func_801A5680(u16 wordId) { u8 phi_a3 = true; u8 numWords; u8 i; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; @@ -225,14 +226,14 @@ s32 func_801A5680(u16 wordId) { } if (phi_a3) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceMaskDictionary(&gVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); } D_801FD5A0.mode = 0; @@ -244,22 +245,21 @@ s32 func_801A5680(u16 wordId) { s32 func_801A5808(void) { s32 errorCode = 0; s32 ret; - OSMesgQueue* msgQ; - - if (1) {} + OSMesgQueue* serialEventQueue; switch (D_801FD5A0.mode) { case 0: - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStartReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); D_801FD5A0.mode = 1; break; + case 1: - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceGetReadData(&gVoiceHandle, &D_801FD5C8); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (func_801A51F0(errorCode) == 0) { switch (gVoiceHandle.status) { @@ -278,9 +278,13 @@ s32 func_801A5808(void) { case VOICE_STATUS_END: D_801FD5A0.mode = 2; break; + + default: + break; } } break; + case 2: if (((D_801FD5C8.warning & D_801FD5A0.warning) == 0) && (D_801FD5A0.answerNum >= D_801FD5C8.answerNum) && (D_801FD5A0.distance >= D_801FD5C8.distance[0]) && (D_801FD5C8.voiceLevel >= D_801FD5A0.voiceLevel) && @@ -289,16 +293,19 @@ s32 func_801A5808(void) { D_801FD5A0.data = &D_801FD5E8; } - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStartReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); D_801FD5A0.mode = 1; break; + + default: + break; } ret = func_801A51F0(errorCode); @@ -311,15 +318,15 @@ void AudioVoice_ResetData(void) { D_801FD5A0.dict = NULL; } -u8* func_801A5A1C(s8* word) { +u8* func_801A5A1C(s8* words) { u8 i; u8 j; - u8 numSyllables = strlen(word); // technically twice the num of syllables + u8 numSyllables = strlen(words); // technically twice the num of syllables u8 syllable[2]; for (j = 0, i = 0; i < numSyllables; i += 2) { - syllable[0] = word[i]; - syllable[1] = word[i + 1]; + syllable[0] = words[i]; + syllable[1] = words[i + 1]; if (syllable[0] == 0x83) { D_801FD610[j++] = D_801D8F70[syllable[1] - 0x40][0]; @@ -327,7 +334,7 @@ u8* func_801A5A1C(s8* word) { } else if (syllable[0] == 0x82) { D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][0]; D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][1]; - } else if (syllable[0] == 0x81 && syllable[1] == 0x5B) { + } else if ((syllable[0] == 0x81) && (syllable[1] == 0x5B)) { D_801FD610[j++] = '-'; D_801FD610[j++] = '-'; } else { From db5335c42a7c98b2d2178217b918f66b42576223 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 11:58:13 +1000 Subject: [PATCH 108/130] cow voice weekeventflag --- include/z64save.h | 3 ++- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 8 ++++---- tools/weekeventregconvert.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 69b9e7ad8..0960185ef 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1299,7 +1299,8 @@ typedef enum { #define WEEKEVENTREG_86_20 PACK_WEEKEVENTREG_FLAG(86, 0x20) #define WEEKEVENTREG_86_40 PACK_WEEKEVENTREG_FLAG(86, 0x40) #define WEEKEVENTREG_86_80 PACK_WEEKEVENTREG_FLAG(86, 0x80) -#define WEEKEVENTREG_87_01 PACK_WEEKEVENTREG_FLAG(87, 0x01) +// Currently talking to a cow using the voice recognition unit +#define WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE PACK_WEEKEVENTREG_FLAG(87, 0x01) #define WEEKEVENTREG_87_02 PACK_WEEKEVENTREG_FLAG(87, 0x02) #define WEEKEVENTREG_87_04 PACK_WEEKEVENTREG_FLAG(87, 0x04) #define WEEKEVENTREG_87_08 PACK_WEEKEVENTREG_FLAG(87, 0x08) 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 27fd87bbc..c9621e420 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -159,7 +159,7 @@ void EnCow_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_87_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); } void EnCow_Destroy(Actor* thisx, PlayState* play) { @@ -295,8 +295,8 @@ void EnCow_Idle(EnCow* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { if (AudioVoice_GetWord() == VOICE_WORD_ID_MILK) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_87_01)) { - SET_WEEKEVENTREG(WEEKEVENTREG_87_01); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); if (Inventory_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { @@ -307,7 +307,7 @@ void EnCow_Idle(EnCow* this, PlayState* play) { this->actionFunc = EnCow_Talk; } } else { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_87_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); } } diff --git a/tools/weekeventregconvert.py b/tools/weekeventregconvert.py index 591671ab8..8415b02f8 100755 --- a/tools/weekeventregconvert.py +++ b/tools/weekeventregconvert.py @@ -700,7 +700,7 @@ weekEventReg = { (86 << 8) | 0x20: "WEEKEVENTREG_86_20", (86 << 8) | 0x40: "WEEKEVENTREG_86_40", (86 << 8) | 0x80: "WEEKEVENTREG_86_80", - (87 << 8) | 0x01: "WEEKEVENTREG_87_01", + (87 << 8) | 0x01: "WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE", (87 << 8) | 0x02: "WEEKEVENTREG_87_02", (87 << 8) | 0x04: "WEEKEVENTREG_87_04", (87 << 8) | 0x08: "WEEKEVENTREG_87_08", From 6ef3cefb9f1dbad08d7ec1cfacf17e12fed041f4 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 12:02:48 +1000 Subject: [PATCH 109/130] small cleanup --- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 12 ++++++------ src/overlays/actors/ovl_En_Gs/z_en_gs.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) 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 c9621e420..28f37897f 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -292,8 +292,8 @@ void EnCow_Idle(EnCow* this, PlayState* play) { } } - if (this->actor.xzDistToPlayer < 150.0f && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + if ((this->actor.xzDistToPlayer < 150.0f) && + (ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x61A8)) { if (AudioVoice_GetWord() == VOICE_WORD_ID_MILK) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE)) { SET_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); @@ -323,8 +323,8 @@ void EnCow_DoTail(EnCow* this, PlayState* play) { Animation_GetLastFrame(&gCowTailIdleAnim), ANIMMODE_ONCE, 1.0f); } - if (this->actor.xzDistToPlayer < 150.0f && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 25000) { + if ((this->actor.xzDistToPlayer < 150.0f) && + (ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 0x61A8)) { if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; if (this->skelAnime.animation == &gCowTailIdleAnim) { @@ -361,8 +361,8 @@ void EnCow_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); - if (this->actor.xzDistToPlayer < 150.0f && - ABS_ALT(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000) { + if ((this->actor.xzDistToPlayer < 150.0f) && + (ABS_ALT(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000)) { targetX = Math_Vec3f_Pitch(&thisx->focus.pos, &player->actor.focus.pos); targetY = Math_Vec3f_Yaw(&thisx->focus.pos, &player->actor.focus.pos) - this->actor.shape.rot.y; 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 125f92ad3..846b90a2f 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -925,7 +925,7 @@ void func_80999BC8(Actor* thisx, PlayState* play2) { EnGs* this = THIS; s32 pad; - if (this->actor.isTargeted && AudioVoice_GetWord() == VOICE_WORD_ID_HOURS) { + if (this->actor.isTargeted && (AudioVoice_GetWord() == VOICE_WORD_ID_HOURS)) { this->unk_19D = 0; this->unk_19A |= 1; func_80999AC0(this); From 924cf524bcebb57dd26bb8424e54f114a825ca2a Mon Sep 17 00:00:00 2001 From: petrie911 Date: Thu, 15 Jun 2023 07:22:05 -0500 Subject: [PATCH 110/130] removed macros --- include/macros.h | 3 --- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/macros.h b/include/macros.h index 43f526f24..d2b98dec5 100644 --- a/include/macros.h +++ b/include/macros.h @@ -94,9 +94,6 @@ #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) -#define RAND_BITS(n) ((s32)Rand_Next() >> (0x20 - n)) -#define RANDU_BITS(n) (Rand_Next() >> (0x20 - n)) - #define RGBA16_GET_R(pixel) (((pixel) >> 11) & 0x1F) #define RGBA16_GET_G(pixel) (((pixel) >> 6) & 0x1F) #define RGBA16_GET_B(pixel) (((pixel) >> 1) & 0x1F) diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 072371f53..35df2c5a3 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -374,7 +374,7 @@ void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { waterChain->drag = 0.9f; waterChain->swayMax = 0.003f; - waterChain->swayPhaseVel = RANDU_BITS(13); + waterChain->swayPhaseVel = Rand_Next() >> (0x20 - 13); waterChain->restoreXZ = -0.0002f; waterChain->restoreY = -0.0002f; @@ -895,9 +895,9 @@ void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { } // Applies chain sway, choosing a new sway randomly about every 32 frames - if (RANDU_BITS(5) == 0) { + if ((Rand_Next() >> (0x20 - 5)) == 0) { airChain->swaySize = Rand_ZeroOne() * airChain->swayMax; - airChain->swayPhase = RANDU_BITS(16); + airChain->swayPhase = Rand_Next() >> (0x20 - 16); } xAccel = Math_SinS(airChain->swayPhase) * airChain->swaySize; zAccel = Math_CosS(airChain->swayPhase) * airChain->swaySize; @@ -1032,12 +1032,12 @@ void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { waterChain->swayMax = 0.003f; // Chooses a new sway randomly about every 32 frames. - if (RANDU_BITS(5) == 0) { - s16 randAngle = RANDU_BITS(16); + if (Rand_Next() >> (0x20 - 5) == 0) { + s16 randAngle = Rand_Next() >> (0x20 - 16); waterChain->swayXZ = Math_SinS(randAngle) * 1.8f * waterChain->swayMax; waterChain->swayY = Math_CosS(randAngle) * 0.2f * waterChain->swayMax; - waterChain->swayPhaseVel = RANDU_BITS(13); + waterChain->swayPhaseVel = Rand_Next() >> (0x20 - 13); } ObjMine_Water_UpdateChain(this, play); From 018b9b7c6383824b3a26e656291e948b68a7e077 Mon Sep 17 00:00:00 2001 From: Synray <31429825+Synray@users.noreply.github.com> Date: Wed, 9 Aug 2023 22:27:31 -0700 Subject: [PATCH 111/130] Bg_Danpei_Movebg OK --- spec | 3 +- .../ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c | 194 ++++++++++++++++-- .../ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h | 6 +- 3 files changed, 182 insertions(+), 21 deletions(-) diff --git a/spec b/spec index 3e7b86be0..631426029 100644 --- a/spec +++ b/spec @@ -3466,8 +3466,7 @@ beginseg name "ovl_Bg_Danpei_Movebg" compress include "build/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.o" - include "build/data/ovl_Bg_Danpei_Movebg/ovl_Bg_Danpei_Movebg.data.o" - include "build/data/ovl_Bg_Danpei_Movebg/ovl_Bg_Danpei_Movebg.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Danpei_Movebg/ovl_Bg_Danpei_Movebg_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index a5d01fe65..a18aa958a 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -5,6 +5,7 @@ */ #include "z_bg_danpei_movebg.h" +#include "objects/object_d_lift/object_d_lift.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +15,6 @@ void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play); void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play); void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play); -#if 0 ActorInit Bg_Danpei_Movebg_InitVars = { ACTOR_BG_DANPEI_MOVEBG, ACTORCAT_BG, @@ -27,38 +27,198 @@ ActorInit Bg_Danpei_Movebg_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AF753C[] = { +static u16 D_80AF7530[] = { OBJECT_D_LIFT, OBJECT_DANPEI_OBJECT }; + +static Gfx* D_80AF7534[] = { gDampeGraveBrownElevatorDL }; + +static CollisionHeader* D_80AF7538[] = { &gDampeGraveBrownElevatorCol }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 func_80AF6DE0(PlayState* this, ActorPathing* actorPathing) { + Actor* actor; + s32 res; -extern InitChainEntry D_80AF753C[]; + actor = actorPathing->actor; + res = 0; + if (actorPathing->distSqToCurPoint < actor->speed * actor->speed) { + res = 1; + } else { + actor->world.rot.x = actorPathing->rotToCurPoint.x; + actor->world.rot.y = actorPathing->rotToCurPoint.y; + } + return res; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF6DE0.s") +void func_80AF6EA8(BgDanpeiMovebg*, PlayState*); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/BgDanpeiMovebg_Init.s") +void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play) { + BgDanpeiMovebg* this = THIS; + DynaPolyActor_Init(&this->dyna, 1); + this->bankIdx = SubS_GetObjectIndex(D_80AF7530[(this->dyna.actor.params >> 0xE) & 0x3], play); + if (this->bankIdx < 0) { + Actor_Kill(&this->dyna.actor); + } + this->actionFunc = func_80AF6EA8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF6EA8.s") +void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play); +void func_80AF74CC(Actor* thisx, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/BgDanpeiMovebg_Destroy.s") +void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play) { + Actor* thisx = (Actor*)this; + if (SubS_IsObjectLoaded(this->bankIdx, play)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->bankIdx].segment); + this->dyna.actor.objBankIndex = this->bankIdx; + this->dyna.actor.draw = func_80AF74CC; + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_LoadMesh(play, &this->dyna, D_80AF7538[(thisx->params >> 0xE) & 0x3]); + this->unk_1D0 = D_80AF7534[((thisx->params >> 0xE) & 0x3)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/BgDanpeiMovebg_Update.s") + /* If D_LIFT */ + if (((thisx->params >> 0xE) & 0x3) == 0) { + this->dyna.actor.gravity = 0.0f; + this->dyna.actor.speed = 1.0f; + SubS_ActorPathing_Init(play, &thisx->world.pos, thisx, &this->actorPath, play->setupPathList, + thisx->params & 0x7F, 0, 0, 0, 0); + this->actionFunc = func_80AF70FC; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF705C.s") +void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play) { + BgDanpeiMovebg* this = THIS; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF70FC.s") +void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play) { + BgDanpeiMovebg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF71FC.s") + this->actionFunc(this, play); + this->unk_1CE = this->unk_1CC; + this->unk_1CC &= ~1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF72F8.s") +u16 func_80AF705C(BgDanpeiMovebg* this, u16 unk_1CC) { + u16 v1 = unk_1CC & ~0x1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF7354.s") + if (DynaPolyActor_IsActorOnTop(&this->dyna) && (this->unk_1CC & 1)) { + v1 |= 4; + } + if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { + if (gSaveContext.save.playerForm == 3) { + v1 |= 8; + } else { + v1 |= 0x10; + } + } + return v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF746C.s") +u16 func_80AF705C(BgDanpeiMovebg*, u16); +void func_80AF71FC(BgDanpeiMovebg*, PlayState*); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF74CC.s") +void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play) { + this->unk_1CC = func_80AF705C(this, this->unk_1CC); + if (this->unk_1CC & 0xC) { + if (this->unk_1CC & 4) { + this->unk_1CC |= 2; + } + this->actionFunc = func_80AF71FC; + return; + } + if (this->unk_1CC & 0x10) { + if (!(this->unk_1CE & 0x10)) { + Actor_PlaySfx(&this->dyna.actor, 0x2979U); + } + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 8.0f, 1.0f, 2.0f, 0.01f); + return; + } + if (this->unk_1CE & 0x10) { + Actor_PlaySfx(&this->dyna.actor, 0x297AU); + } + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f, 2.0f, 0.01f); +} + +s32 func_80AF6DE0(PlayState*, ActorPathing*); +void func_80AF72F8(BgDanpeiMovebg*, PlayState*); +void func_80AF7354(BgDanpeiMovebg*, PlayState*); +void func_80AF746C(BgDanpeiMovebg*, PlayState*); + +void func_80AF71FC(BgDanpeiMovebg* this, PlayState* play) { + SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, func_80AF6DE0, + SubS_ActorPathing_MoveWithoutGravityReverse, SubS_ActorPathing_SetNextPoint); + Actor_PlaySfx_Flagged(&this->dyna.actor, 0x2103U); + if (this->actorPath.flags & 0x80) { + if (this->unk_1CC & 2) { + this->unk_1CC &= ~0x2; + } + this->actionFunc = func_80AF72F8; + return; + } + this->unk_1CC = func_80AF705C(this, this->unk_1CC); + if ((this->unk_1CC & 0x10) || ((this->unk_1CC & 0xC) == 0xC)) { + this->actionFunc = func_80AF746C; + return; + } + if (!(this->unk_1CC & 0x1C)) { + this->actorPath.flags |= 8; + this->dyna.actor.speed = 2.0f; + this->actionFunc = func_80AF7354; + } +} + +void func_80AF72F8(BgDanpeiMovebg* this, PlayState* play) { + this->unk_1CC = func_80AF705C(this, this->unk_1CC); + if (!(this->unk_1CC & 0x1C)) { + this->actorPath.flags |= 8; + this->dyna.actor.speed = 2.0f; + this->actionFunc = func_80AF7354; + } +} + +void func_80AF7354(BgDanpeiMovebg* this, PlayState* play) { + Actor_PlaySfx_Flagged(&this->dyna.actor, 0x2103U); + this->unk_1CC = func_80AF705C(this, this->unk_1CC); + SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, func_80AF6DE0, + SubS_ActorPathing_MoveWithoutGravityReverse, SubS_ActorPathing_SetNextPoint); + if ((this->unk_1CC & 0x10) || (this->unk_1CC & 0xC) == 0xC) { + this->actionFunc = func_80AF746C; + } else if ((this->unk_1CC & 0xC) && (this->unk_1CC & 0xC) != 0xC) { + this->actorPath.flags &= 0xFFF7; + this->dyna.actor.speed = 1.0f; + if (this->unk_1CC & 4) { + this->unk_1CC = this->unk_1CC | 2; + } + this->actionFunc = func_80AF71FC; + } + if (this->actorPath.flags & 0x80) { + this->actorPath.flags = this->actorPath.flags & 0xFFF7; + this->unk_1CC &= 0xFFFD; + this->dyna.actor.speed = 1.0f; + this->actionFunc = func_80AF70FC; + } +} + +void func_80AF746C(BgDanpeiMovebg* this, PlayState* arg1) { + this->unk_1CC = func_80AF705C(this, this->unk_1CC); + if (!(this->unk_1CC & 0x18)) { + if (this->actorPath.flags & 8) { + this->actionFunc = func_80AF7354; + } else { + this->actionFunc = func_80AF71FC; + } + } +} + +void func_80AF74CC(Actor* thisx, PlayState* play) { + BgDanpeiMovebg* this = THIS; + if (this->unk_1D0 != NULL) { + Gfx_DrawDListOpa(play, this->unk_1D0); + } +} diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h index c99bb813f..7719bb518 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h @@ -10,9 +10,11 @@ typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, PlayState*); typedef struct BgDanpeiMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgDanpeiMovebgActionFunc actionFunc; - /* 0x160 */ char unk_160[0x6C]; + /* 0x160 */ ActorPathing actorPath; /* 0x1CC */ u16 unk_1CC; - /* 0x1CE */ char unk_1CE[0xA]; + /* 0x1CE */ u16 unk_1CE; + /* 0x1D0 */ Gfx* unk_1D0; + /* 0x1D4 */ s8 bankIdx; } BgDanpeiMovebg; // size = 0x1D8 #endif // Z_BG_DANPEI_MOVEBG_H From 2ae90ab393e8d953e45ff8f8d6c69e90407f7dc1 Mon Sep 17 00:00:00 2001 From: Synray <31429825+Synray@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:33:47 -0700 Subject: [PATCH 112/130] Cleanup --- .../ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c | 142 +++++++++--------- .../ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h | 9 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 4 +- 3 files changed, 75 insertions(+), 80 deletions(-) diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index a18aa958a..109b9c4db 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -15,6 +15,15 @@ void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play); void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play); void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play); +void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play); +void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play); +void func_80AF74CC(Actor* thisx, PlayState* play); +u16 func_80AF705C(BgDanpeiMovebg* this, u16 flags); +void func_80AF71FC(BgDanpeiMovebg* this, PlayState* play); +void func_80AF72F8(BgDanpeiMovebg* this, PlayState* play); +void func_80AF7354(BgDanpeiMovebg* this, PlayState* play); +void func_80AF746C(BgDanpeiMovebg* this, PlayState* play); + ActorInit Bg_Danpei_Movebg_InitVars = { ACTOR_BG_DANPEI_MOVEBG, ACTORCAT_BG, @@ -55,21 +64,16 @@ s32 func_80AF6DE0(PlayState* this, ActorPathing* actorPathing) { return res; } -void func_80AF6EA8(BgDanpeiMovebg*, PlayState*); - void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play) { BgDanpeiMovebg* this = THIS; DynaPolyActor_Init(&this->dyna, 1); - this->bankIdx = SubS_GetObjectIndex(D_80AF7530[(this->dyna.actor.params >> 0xE) & 0x3], play); + this->bankIdx = SubS_GetObjectIndex(D_80AF7530[BGDANPEIMOVEBG_GET_TYPE(thisx)], play); if (this->bankIdx < 0) { Actor_Kill(&this->dyna.actor); } this->actionFunc = func_80AF6EA8; } -void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play); -void func_80AF74CC(Actor* thisx, PlayState* play); - void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play) { Actor* thisx = (Actor*)this; if (SubS_IsObjectLoaded(this->bankIdx, play)) { @@ -77,15 +81,15 @@ void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play) { this->dyna.actor.objBankIndex = this->bankIdx; this->dyna.actor.draw = func_80AF74CC; Actor_ProcessInitChain(thisx, sInitChain); - DynaPolyActor_LoadMesh(play, &this->dyna, D_80AF7538[(thisx->params >> 0xE) & 0x3]); - this->unk_1D0 = D_80AF7534[((thisx->params >> 0xE) & 0x3)]; + DynaPolyActor_LoadMesh(play, &this->dyna, D_80AF7538[BGDANPEIMOVEBG_GET_TYPE(thisx)]); + this->dList = D_80AF7534[BGDANPEIMOVEBG_GET_TYPE(thisx)]; /* If D_LIFT */ - if (((thisx->params >> 0xE) & 0x3) == 0) { + if (BGDANPEIMOVEBG_GET_TYPE(thisx) == 0) { this->dyna.actor.gravity = 0.0f; this->dyna.actor.speed = 1.0f; SubS_ActorPathing_Init(play, &thisx->world.pos, thisx, &this->actorPath, play->setupPathList, - thisx->params & 0x7F, 0, 0, 0, 0); + BGDANPEIMOVEBG_GET_PATH_INDEX(thisx), 0, 0, 0, 0); this->actionFunc = func_80AF70FC; } } @@ -100,115 +104,103 @@ void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play) { BgDanpeiMovebg* this = THIS; this->actionFunc(this, play); - this->unk_1CE = this->unk_1CC; - this->unk_1CC &= ~1; + this->prevFlags = this->flags; + this->flags &= ~1; } -u16 func_80AF705C(BgDanpeiMovebg* this, u16 unk_1CC) { - u16 v1 = unk_1CC & ~0x1C; +u16 func_80AF705C(BgDanpeiMovebg* this, u16 flags) { + u16 newFlags = flags & ~0x1C; - if (DynaPolyActor_IsActorOnTop(&this->dyna) && (this->unk_1CC & 1)) { - v1 |= 4; + if (DynaPolyActor_IsActorOnTop(&this->dyna) && (this->flags & 1)) { + newFlags |= 4; } if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { - if (gSaveContext.save.playerForm == 3) { - v1 |= 8; + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + newFlags |= 8; } else { - v1 |= 0x10; + newFlags |= 0x10; } } - return v1; + return newFlags; } -u16 func_80AF705C(BgDanpeiMovebg*, u16); -void func_80AF71FC(BgDanpeiMovebg*, PlayState*); - void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play) { - this->unk_1CC = func_80AF705C(this, this->unk_1CC); - if (this->unk_1CC & 0xC) { - if (this->unk_1CC & 4) { - this->unk_1CC |= 2; + this->flags = func_80AF705C(this, this->flags); + if (this->flags & 0xC) { + if (this->flags & 4) { + this->flags |= 2; } this->actionFunc = func_80AF71FC; - return; - } - if (this->unk_1CC & 0x10) { - if (!(this->unk_1CE & 0x10)) { - Actor_PlaySfx(&this->dyna.actor, 0x2979U); + } else if (this->flags & 0x10) { + if (!(this->prevFlags & 0x10)) { + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SINK_WOOD_FLOOR); } Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 8.0f, 1.0f, 2.0f, 0.01f); - return; + } else { + if (this->prevFlags & 0x10) { + Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_REBOUND_WOOD_FLOOR); + } + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f, 2.0f, 0.01f); } - if (this->unk_1CE & 0x10) { - Actor_PlaySfx(&this->dyna.actor, 0x297AU); - } - Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f, 2.0f, 0.01f); } -s32 func_80AF6DE0(PlayState*, ActorPathing*); -void func_80AF72F8(BgDanpeiMovebg*, PlayState*); -void func_80AF7354(BgDanpeiMovebg*, PlayState*); -void func_80AF746C(BgDanpeiMovebg*, PlayState*); - void func_80AF71FC(BgDanpeiMovebg* this, PlayState* play) { SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, func_80AF6DE0, SubS_ActorPathing_MoveWithoutGravityReverse, SubS_ActorPathing_SetNextPoint); - Actor_PlaySfx_Flagged(&this->dyna.actor, 0x2103U); - if (this->actorPath.flags & 0x80) { - if (this->unk_1CC & 2) { - this->unk_1CC &= ~0x2; + Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { + if (this->flags & 2) { + this->flags &= ~0x2; } this->actionFunc = func_80AF72F8; - return; - } - this->unk_1CC = func_80AF705C(this, this->unk_1CC); - if ((this->unk_1CC & 0x10) || ((this->unk_1CC & 0xC) == 0xC)) { - this->actionFunc = func_80AF746C; - return; - } - if (!(this->unk_1CC & 0x1C)) { - this->actorPath.flags |= 8; - this->dyna.actor.speed = 2.0f; - this->actionFunc = func_80AF7354; + } else { + this->flags = func_80AF705C(this, this->flags); + if ((this->flags & 0x10) || (this->flags & 0xC) == 0xC) { + this->actionFunc = func_80AF746C; + } else if ((this->flags & 0x1C) == 0) { + this->actorPath.flags |= ACTOR_PATHING_MOVE_BACKWARDS; + this->dyna.actor.speed = 2.0f; + this->actionFunc = func_80AF7354; + } } } void func_80AF72F8(BgDanpeiMovebg* this, PlayState* play) { - this->unk_1CC = func_80AF705C(this, this->unk_1CC); - if (!(this->unk_1CC & 0x1C)) { - this->actorPath.flags |= 8; + this->flags = func_80AF705C(this, this->flags); + if (!(this->flags & 0x1C)) { + this->actorPath.flags |= ACTOR_PATHING_MOVE_BACKWARDS; this->dyna.actor.speed = 2.0f; this->actionFunc = func_80AF7354; } } void func_80AF7354(BgDanpeiMovebg* this, PlayState* play) { - Actor_PlaySfx_Flagged(&this->dyna.actor, 0x2103U); - this->unk_1CC = func_80AF705C(this, this->unk_1CC); + Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG); + this->flags = func_80AF705C(this, this->flags); SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, func_80AF6DE0, SubS_ActorPathing_MoveWithoutGravityReverse, SubS_ActorPathing_SetNextPoint); - if ((this->unk_1CC & 0x10) || (this->unk_1CC & 0xC) == 0xC) { + if ((this->flags & 0x10) || (this->flags & 0xC) == 0xC) { this->actionFunc = func_80AF746C; - } else if ((this->unk_1CC & 0xC) && (this->unk_1CC & 0xC) != 0xC) { - this->actorPath.flags &= 0xFFF7; + } else if ((this->flags & 0xC) && (this->flags & 0xC) != 0xC) { + this->actorPath.flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; this->dyna.actor.speed = 1.0f; - if (this->unk_1CC & 4) { - this->unk_1CC = this->unk_1CC | 2; + if (this->flags & 4) { + this->flags |= 2; } this->actionFunc = func_80AF71FC; } - if (this->actorPath.flags & 0x80) { - this->actorPath.flags = this->actorPath.flags & 0xFFF7; - this->unk_1CC &= 0xFFFD; + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { + this->actorPath.flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; + this->flags &= ~2; this->dyna.actor.speed = 1.0f; this->actionFunc = func_80AF70FC; } } void func_80AF746C(BgDanpeiMovebg* this, PlayState* arg1) { - this->unk_1CC = func_80AF705C(this, this->unk_1CC); - if (!(this->unk_1CC & 0x18)) { - if (this->actorPath.flags & 8) { + this->flags = func_80AF705C(this, this->flags); + if (!(this->flags & 0x18)) { + if (this->actorPath.flags & ACTOR_PATHING_MOVE_BACKWARDS) { this->actionFunc = func_80AF7354; } else { this->actionFunc = func_80AF71FC; @@ -218,7 +210,7 @@ void func_80AF746C(BgDanpeiMovebg* this, PlayState* arg1) { void func_80AF74CC(Actor* thisx, PlayState* play) { BgDanpeiMovebg* this = THIS; - if (this->unk_1D0 != NULL) { - Gfx_DrawDListOpa(play, this->unk_1D0); + if (this->dList != NULL) { + Gfx_DrawDListOpa(play, this->dList); } } diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h index 7719bb518..bd57a4822 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.h @@ -7,13 +7,16 @@ struct BgDanpeiMovebg; typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, PlayState*); +#define BGDANPEIMOVEBG_GET_PATH_INDEX(thisx) ((thisx)->params & 0x7F) +#define BGDANPEIMOVEBG_GET_TYPE(thisx) (((thisx)->params >> 0xE) & 3) + typedef struct BgDanpeiMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgDanpeiMovebgActionFunc actionFunc; /* 0x160 */ ActorPathing actorPath; - /* 0x1CC */ u16 unk_1CC; - /* 0x1CE */ u16 unk_1CE; - /* 0x1D0 */ Gfx* unk_1D0; + /* 0x1CC */ u16 flags; + /* 0x1CE */ u16 prevFlags; + /* 0x1D0 */ Gfx* dList; /* 0x1D4 */ s8 bankIdx; } BgDanpeiMovebg; // size = 0x1D8 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 ccc5e4489..17b7c853d 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -1297,8 +1297,8 @@ void EnTk_Update(Actor* thisx, PlayState* play) { if (platform != NULL) { if (platform->dyna.actor.id == ACTOR_BG_DANPEI_MOVEBG) { - platform->unk_1CC |= 1; - if (platform->unk_1CC & 2) { + platform->flags |= 1; + if (platform->flags & 2) { this->unk_2CA |= 1; } } From 320e19bd6ffb63e073e2b755c1308fb84b6eec56 Mon Sep 17 00:00:00 2001 From: Thar0 <17233964+Thar0@users.noreply.github.com> Date: Sat, 16 Jul 2022 02:24:22 +0100 Subject: [PATCH 113/130] Decompiled, mostly named --- assets/xml/objects/object_po_composer.xml | 27 +- spec | 3 +- .../ovl_En_Po_Composer/z_en_po_composer.c | 690 ++++++++++++++++-- .../ovl_En_Po_Composer/z_en_po_composer.h | 39 +- 4 files changed, 664 insertions(+), 95 deletions(-) diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index c45cf9039..40d77d827 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -1,4 +1,5 @@  + @@ -13,23 +14,15 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/spec b/spec index 5f8c616e5..6b7b441cf 100644 --- a/spec +++ b/spec @@ -4263,8 +4263,7 @@ beginseg name "ovl_En_Po_Composer" compress include "build/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.o" - include "build/data/ovl_En_Po_Composer/ovl_En_Po_Composer.data.o" - include "build/data/ovl_En_Po_Composer/ovl_En_Po_Composer.reloc.o" + include "build/src/overlays/actors/ovl_En_Po_Composer/ovl_En_Po_Composer_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 0772249ba..0f88f364d 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -15,20 +15,24 @@ void EnPoComposer_Destroy(Actor* thisx, PlayState* play); void EnPoComposer_Update(Actor* thisx, PlayState* play); void EnPoComposer_Draw(Actor* thisx, PlayState* play); -void func_80BC5294(EnPoComposer* this, PlayState* play); -void func_80BC52F0(EnPoComposer* this, PlayState* play); -void func_80BC53A0(EnPoComposer* this, PlayState* play); -void func_80BC5404(EnPoComposer* this, PlayState* play); -void func_80BC5570(EnPoComposer* this, PlayState* play); -void func_80BC55E0(EnPoComposer* this, PlayState* play); -void func_80BC5670(EnPoComposer* this, PlayState* play); -void func_80BC56D0(EnPoComposer* this, PlayState* play); -void func_80BC5780(EnPoComposer* this, PlayState* play); -void func_80BC5830(EnPoComposer* this, PlayState* play); -void func_80BC58E0(EnPoComposer* this, PlayState* play); +void EnPoComposer_AwaitPlayer(EnPoComposer* this, PlayState* play); +void EnPoComposer_StartCutscene(EnPoComposer* this, PlayState* play); +void EnPoComposer_StartedCutscene(EnPoComposer* this, PlayState* play); +void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play); +void EnPoComposer_IdleStill(EnPoComposer* this, PlayState* play); +void EnPoComposer_Appear(EnPoComposer* this, PlayState* play); +void EnPoComposer_Idle(EnPoComposer* this, PlayState* play); +void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play); +void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play); +void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play); +void EnPoComposer_Roll(EnPoComposer* this, PlayState* play); -#if 0 -ActorInit En_Po_Composer_InitVars = { +void EnPoComposer_SetupAwaitPlayer(EnPoComposer* this); +void EnPoComposer_SetupStartCutscene(EnPoComposer* this); +void EnPoComposer_SetupStartedCutscene(EnPoComposer* this); +void EnPoComposer_StepLightAlpha(EnPoComposer* this); + +const ActorInit En_Po_Composer_InitVars = { ACTOR_EN_PO_COMPOSER, ACTORCAT_ITEMACTION, FLAGS, @@ -40,32 +44,56 @@ ActorInit En_Po_Composer_InitVars = { (ActorFunc)EnPoComposer_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BC6780 = { - { COLTYPE_HIT3, 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, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + 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, + OCELEM_ON, + }, { 20, 40, 20, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BC67AC[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 9, { { 0, -1500, 0 }, 10 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BC67D0 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_80BC67AC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80BC67E0 = { 4, 25, 50, 40 }; +static CollisionCheckInfoInit sColChkInfoInit = { 4, 25, 50, 40 }; -// static DamageTable sDamageTable = { -static DamageTable D_80BC67E8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(2, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -100,88 +128,602 @@ static DamageTable D_80BC67E8 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC6958[] = { +typedef enum { + PO_COMPOSER_ANIM_IDLE_STILL, + PO_COMPOSER_ANIM_APPEAR_DISAPPEAR, + PO_COMPOSER_ANIM_IDLE, + PO_COMPOSER_ANIM_RAISE_ARMS, + PO_COMPOSER_ANIM_ARMS_RAISED, + PO_COMPOSER_ANIM_LOWER_ARMS, + PO_COMPOSER_ANIM_IDLE_FACING_DOWN, + PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE, + PO_COMPOSER_ANIM_PLAYING_CURSE, + PO_COMPOSER_ANIM_BEGIN_ROLLING, + PO_COMPOSER_ANIM_ROLLING, + PO_COMPOSER_ANIM_FLEE, + PO_COMPOSER_ANIM_ATTACK, + PO_COMPOSER_ANIM_MAX, +} EnPoComposerAnim; + +static AnimationInfo sAnimationInfo[PO_COMPOSER_ANIM_MAX] = { + /* 0 */ { &object_po_composer_Anim_003DB0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 1 */ { &object_po_composer_Anim_003954, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + /* 2 */ { &object_po_composer_Anim_00188C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 3 */ { &object_po_composer_Anim_000570, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 4 */ { &object_po_composer_Anim_001F44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 5 */ { &object_po_composer_Anim_0023E8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 6 */ { &object_po_composer_Anim_002AE0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 7 */ { &object_po_composer_Anim_000A58, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 8 */ { &object_po_composer_Anim_001420, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 9 */ { &object_po_composer_Anim_003024, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 10 */ { &object_po_composer_Anim_00334C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 11 */ { &object_po_composer_Anim_0015B8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 12 */ { &object_po_composer_Anim_00020C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; + +static Color_RGBA8 sLightColorInit = { 255, 255, 210, 0 }; + +static Color_RGBA8 sEnvColorInit = { 0, 0, 0, 255 }; + +Color_RGBA8 D_80BC6948 = { 75, 20, 25, 255 }; + +Color_RGBA8 D_80BC694C = { 80, 110, 90, 255 }; + +Color_RGBA8 D_80BC6950 = { 90, 85, 50, 255 }; + +Color_RGBA8 D_80BC6954 = { 100, 90, 100, 255 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; -#endif +static s32 sPlayerIsPlayingOcarina = false; -extern ColliderCylinderInit D_80BC6780; -extern ColliderJntSphElementInit D_80BC67AC[1]; -extern ColliderJntSphInit D_80BC67D0; -extern CollisionCheckInfoInit D_80BC67E0; -extern DamageTable D_80BC67E8; -extern InitChainEntry D_80BC6958[]; +void EnPoComposer_Init(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; -extern UNK_TYPE D_0600188C; -extern UNK_TYPE D_06006E08; -extern UNK_TYPE D_06006FD8; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &object_po_composer_Skel_009930, &object_po_composer_Anim_00188C, + this->jointTable, this->morphTable, OBJECT_PO_COMPOSER_LIMB_MAX); + Collider_InitJntSph(play, &this->lanternCollider); + Collider_SetJntSph(play, &this->lanternCollider, &this->actor, &sJntSphInit, this->lanternColliderElements); + Collider_InitCylinder(play, &this->bodyCollider); + Collider_SetCylinder(play, &this->bodyCollider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + 255, 255, 255, 0); + this->actor.flags &= ~1; + this->lightColor = sLightColorInit; + this->envColor = sEnvColorInit; + this->lastCsAction = COMPOSER_CS_ACTION_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Init.s") + if (PO_COMPOSER_IS_FLAT(&this->actor)) { + this->unk290 = 0; + this->unk330 = true; + EnPoComposer_SetupStartedCutscene(this); + } else if (this->actor.params & 0x4000) { + if (gSaveContext.save.entrance != 0x20A0) { + Actor_Kill(&this->actor); + } else { + this->unk290 = 0; + this->unk330 = true; + EnPoComposer_SetupStartedCutscene(this); + } + } else { + s32 i; + s16 csIndex = this->actor.csId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Destroy.s") + if (gSaveContext.save.saveInfo.weekEventReg[14] & 4) { + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5250.s") + for (i = 0; i < ARRAY_COUNT(this->csIndices); i++) { + if (csIndex == -1) { + break; + } + this->csIndices[i] = csIndex; + csIndex = CutsceneManager_GetAdditionalCsId(csIndex); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5294.s") + if (gSaveContext.save.saveInfo.weekEventReg[14] & 2) { + this->unk290 = 1; + } else { + this->unk290 = 0; + } + this->unk330 = false; + EnPoComposer_SetupAwaitPlayer(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC52D4.s") +void EnPoComposer_Destroy(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC52F0.s") + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + Collider_DestroyJntSph(play, &this->lanternCollider); + Collider_DestroyCylinder(play, &this->bodyCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC538C.s") +void EnPoComposer_SetupAwaitPlayer(EnPoComposer* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_STILL); + this->actionFunc = EnPoComposer_AwaitPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC53A0.s") +void EnPoComposer_AwaitPlayer(EnPoComposer* this, PlayState* play) { + if (this->actor.xzDistToPlayer < 200.0f) { + EnPoComposer_SetupStartCutscene(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC53B0.s") +void EnPoComposer_SetupStartCutscene(EnPoComposer* this) { + this->unk330 = true; + this->actionFunc = EnPoComposer_StartCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5404.s") +void EnPoComposer_StartCutscene(EnPoComposer* this, PlayState* play) { + if (CutsceneManager_IsNext(this->csIndices[this->unk290])) { + CutsceneManager_Start(this->csIndices[this->unk290], &this->actor); + EnPoComposer_SetupStartedCutscene(this); + } else { + if (CutsceneManager_GetCurrentCsId() == 0x7C) { + CutsceneManager_Stop(0x7C); + } + CutsceneManager_Queue(this->csIndices[this->unk290]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC552C.s") +void EnPoComposer_SetupStartedCutscene(EnPoComposer* this) { + this->actionFunc = EnPoComposer_StartedCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5570.s") +void EnPoComposer_StartedCutscene(EnPoComposer* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5580.s") +void EnPoComposer_SetupPlayCurse(EnPoComposer* this) { + this->actionTimer = 0; + this->actor.flags |= ACTOR_FLAG_TARGETABLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_PLAYING_CURSE); + this->actionFunc = EnPoComposer_PlayCurse; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC55E0.s") +void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC562C.s") + // Damage the player every second + if (this->actionTimer == 20) { + func_800B8D10(play, &this->actor, 0.0f, 0, 0.0f, 1, 4); + this->actionTimer = 0; + } else { + this->actionTimer++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5670.s") + // Ocarina check + if (player->stateFlags2 & PLAYER_STATE2_8000000) { + if (!sPlayerIsPlayingOcarina) { + // Play sound whenever the player begins playing the Ocarina + Audio_PlaySfx(NA_SE_SY_TRE_BOX_APPEAR); + } + sPlayerIsPlayingOcarina = true; + } else { + sPlayerIsPlayingOcarina = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5680.s") + // Song check, check if player just played song of storms or song of healing to react to + if (play->msgCtx.ocarinaMode == 3) { + switch (play->msgCtx.lastPlayedSong) { + case OCARINA_SONG_STORMS: + this->unk290 = 3; + EnPoComposer_SetupStartCutscene(this); + break; + case OCARINA_SONG_HEALING: + this->unk290 = 2; + EnPoComposer_SetupStartCutscene(this); + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC56D0.s") + // Play sharp's curse bgm + func_801A1FB4(3, &this->actor.projectedPos, NA_BGM_SHARPS_CURSE, 2000.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5738.s") +void EnPoComposer_SetupIdleStill(EnPoComposer* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_STILL); + this->actionFunc = EnPoComposer_IdleStill; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5780.s") +void EnPoComposer_IdleStill(EnPoComposer* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC57E8.s") +void EnPoComposer_SetupAppear(EnPoComposer* this) { + this->actionTimer = 0; + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_APPEAR_DISAPPEAR); + this->actionFunc = EnPoComposer_Appear; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5830.s") +void EnPoComposer_Appear(EnPoComposer* this, PlayState* play) { + this->actionTimer++; + this->actor.shape.rot.y += 0x1000; + if (this->actionTimer == 32) { + EnPoComposer_SetupIdleStill(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5898.s") +void EnPoComposer_SetupIdle(EnPoComposer* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE); + this->actionFunc = EnPoComposer_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC58E0.s") +void EnPoComposer_Idle(EnPoComposer* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC59BC.s") +void EnPoComposer_SetupRaiseArms(EnPoComposer* this) { + this->csActionTimer = 0; + Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_RAISE_ARMS); + this->actionFunc = EnPoComposer_RaiseArms; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC59EC.s") +void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play) { + if (this->csActionTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csActionTimer++; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ARMS_RAISED); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5CC8.s") +void EnPoComposer_SetupLowerArms(EnPoComposer* this) { + this->csActionTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_LOWER_ARMS); + this->actionFunc = EnPoComposer_LowerArms; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5D34.s") +void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play) { + if (this->csActionTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csActionTimer++; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_FACING_DOWN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5DEC.s") +void EnPoComposer_SetupCutscenePlayCurse(EnPoComposer* this) { + this->csActionTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE); + this->actionFunc = EnPoComposer_CutscenePlayCurse; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5FE8.s") +void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play) { + if (this->csActionTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csActionTimer++; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_PLAYING_CURSE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Update.s") +void EnPoComposer_SetupRoll(EnPoComposer* this) { + this->csActionTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_BEGIN_ROLLING); + this->actionFunc = EnPoComposer_Roll; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC60BC.s") +void EnPoComposer_Roll(EnPoComposer* this, PlayState* play) { + if (this->csActionTimer == 0) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csActionTimer++; + Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ROLLING); + } + } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && this->lightColor.a >= 33) { + if (this->csActionTimer == 1) { + Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND2_OLD); + this->csActionTimer = 2; + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND3_OLD); + this->csActionTimer = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC617C.s") +void EnPoComposer_SharpCutsceneDone(EnPoComposer* this) { + gSaveContext.save.saveInfo.weekEventReg[14] |= 4; + Actor_Kill(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Draw.s") +s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { + u16 actorAction = PO_COMPOSER_IS_FLAT(&this->actor) ? 0x1E2 : 0x1E1; + s32 actorActionIdx; + + if (!this->unk330) { + return false; + } + + if (Cutscene_IsCueInChannel(play, actorAction)) { + actorActionIdx = Cutscene_GetCueChannel(play, actorAction); + if (this->lastCsAction != play->csCtx.actorCues[actorActionIdx]->id) { + this->lastCsAction = play->csCtx.actorCues[actorActionIdx]->id; + switch (play->csCtx.actorCues[actorActionIdx]->id) { + case COMPOSER_CS_ACTION_IDLE: // loop idle + EnPoComposer_SetupIdleStill(this); + break; + case COMPOSER_CS_ACTION_APPEAR_SPIN: // appear/disappear -> loop idle + EnPoComposer_SetupAppear(this); + break; + case COMPOSER_CS_ACTION_IDLE2: // loop sharp idle + EnPoComposer_SetupIdle(this); + break; + case COMPOSER_CS_ACTION_RAISE_ARMS: // raise arms -> loop arms raised + EnPoComposer_SetupRaiseArms(this); + break; + case COMPOSER_CS_ACTION_LOWER_ARMS: // lower arms -> loop idle + EnPoComposer_SetupLowerArms(this); + break; + case COMPOSER_CS_ACTION_PLAY_CURSE: // begin playing -> loop playing + EnPoComposer_SetupCutscenePlayCurse(this); + break; + case COMPOSER_CS_ACTION_ROLL: // begin rolling -> loop rolling + EnPoComposer_SetupRoll(this); + break; + case COMPOSER_CS_ACTION_APPEAR: // appear + this->visible = true; + break; + case COMPOSER_CS_ACTION_DISAPPEAR: // disappear + this->visible = false; + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); + break; + case COMPOSER_CS_ACTION_DONE: + if (actorAction == 0x1E1) { + EnPoComposer_SharpCutsceneDone(this); + } else { + Actor_Kill(&this->actor); + } + break; + } + } + if (this->actionFunc != EnPoComposer_Appear) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, actorActionIdx); + } else { + Cutscene_ActorTranslate(&this->actor, play, actorActionIdx); + } + + EnPoComposer_StepLightAlpha(this); + + if (this->unk290 == 3 && play->csCtx.curFrame == 204) { + Audio_PlaySfx(NA_SE_SY_DIZZY_EFFECT); + } + + if (this->visible == true) { + Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); + } + return true; + } + + if (this->actionFunc != EnPoComposer_StartedCutscene && this->actionFunc != EnPoComposer_StartCutscene && + this->actionFunc != EnPoComposer_PlayCurse && play->csCtx.state == 0) { + if (PO_COMPOSER_IS_FLAT(&this->actor)) { + EnPoComposer_SetupStartedCutscene(this); + } else if (this->actor.params & 0x4000) { + EnPoComposer_SetupStartedCutscene(this); + } else { + this->unk330 = false; + if (this->unk290 < 3) { + if (!(gSaveContext.save.saveInfo.weekEventReg[14] & 2)) { + gSaveContext.save.saveInfo.weekEventReg[14] |= 2; + } + EnPoComposer_SetupPlayCurse(this); + } else { + EnPoComposer_SetupStartedCutscene(this); + } + } + } + + this->lastCsAction = COMPOSER_CS_ACTION_NONE; + return false; +} + +void EnPoComposer_StepLightAlpha(EnPoComposer* this) { + if (this->visible == true && this->lightColor.a != 255) { + if (this->lightColor.a > 247) { + this->lightColor.a = 255; + } else { + this->lightColor.a = this->lightColor.a + 7; + } + } else if (!this->visible && this->lightColor.a != 0) { + if (this->lightColor.a < 8) { + this->lightColor.a = 0; + } else { + this->lightColor.a = this->lightColor.a - 7; + } + } +} + +void EnPoComposer_StepLightColor(EnPoComposer* this) { + s16 color; + + color = this->lightColor.r + 5; + this->lightColor.r = CLAMP_MAX(color, 255); + + color = this->lightColor.g + 5; + this->lightColor.g = CLAMP_MAX(color, 255); + + if (this->lightColor.b > 210) { + color = this->lightColor.b - 5; + this->lightColor.b = CLAMP_MIN(color, 210); + } else { + color = this->lightColor.b + 5; + this->lightColor.b = CLAMP_MAX(color, 210); + } +} + +void EnPoComposer_UpdateEnvColor(EnPoComposer* this) { + f32 temp_fv0; + u32 temp_v0; + + if (this->actionFunc == EnPoComposer_Appear && this->skelAnime.curFrame < 12.0f) { + temp_v0 = 55.0f + this->skelAnime.curFrame * 16.66f; + this->envColor.b = temp_v0; + this->envColor.g = temp_v0; + this->envColor.r = temp_v0; + this->envColor.a = this->skelAnime.curFrame * 16.666666f; + } else { + temp_fv0 = Rand_ZeroOne(); + this->envColor.r = 225 + (s32)(temp_fv0 * 30.0f); + this->envColor.g = 155 + (s32)(temp_fv0 * 100.0f); + this->envColor.b = 95 + (s32)(temp_fv0 * 160.0f); + this->envColor.a = 200; + } + if (this->lightColor.a == 0) { + this->envColor.a = 0; + } +} + +void EnPoComposer_UpdateCollision(EnPoComposer* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->bodyCollider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->lanternCollider.base); +} + +void EnPoComposer_Update(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; + + EnPoComposer_UpdateEnvColor(this); + SkelAnime_Update(&this->skelAnime); + Actor_SetFocus(&this->actor, 42.0f); + + this->actionFunc(this, play); + + if (!EnPoComposer_UpdateAction(this, play)) { + EnPoComposer_UpdateCollision(this, play); + } +} + +s32 EnPoComposer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPoComposer* this = THIS; + + if (this->lightColor.a == 0 || limbIndex == OBJECT_PO_COMPOSER_LIMB_09) { // lantern + *dList = NULL; + } else if (PO_COMPOSER_IS_FLAT(&this->actor) && limbIndex == OBJECT_PO_COMPOSER_LIMB_0A) { // head + *dList = object_po_composer_DL_006FD8; // flat head + } + + if (limbIndex == 19) { + //! @bug skeleton does not have a limb 19, this is leftover from OoT Poes + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); + } + + return 0; +} + +void EnPoComposer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnPoComposer* this = THIS; + + Collider_UpdateSpheres(limbIndex, &this->lanternCollider); + if (limbIndex == OBJECT_PO_COMPOSER_LIMB_09) { + Matrix_Get(&this->lanternMtxF); + } +} + +void EnPoComposer_Draw(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; + s32 pad; + Gfx* dl; + Color_RGBA8* clothingColor; + Color_RGBA8* var_t0; + Vec3f sp88; + Vec3s lightPos; + + OPEN_DISPS(play->state.gfxCtx); + + EnPoComposer_StepLightColor(this); + + // Select colors + + if (PO_COMPOSER_IS_FLAT(&this->actor)) { + clothingColor = &D_80BC694C; + var_t0 = &D_80BC6954; + } else { + clothingColor = &D_80BC6948; + var_t0 = &D_80BC6950; + } + + // Draw skeleton + + if (this->lightColor.a == 255 || this->lightColor.a == 0) { + Gfx_SetupDL25_Opa(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(play->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, + this->lightColor.a)); + gSPSegment( + POLY_OPA_DISP++, 0x0A, + Gfx_EnvColor(play->state.gfxCtx, clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0B, + Gfx_EnvColor(play->state.gfxCtx, var_t0->r, var_t0->g, var_t0->b, this->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0C, D_801AEFA0); + + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPoComposer_OverrideLimbDraw, EnPoComposer_PostLimbDraw, &this->actor, POLY_OPA_DISP); + } else { + Gfx_SetupDL25_Opa(play->state.gfxCtx); + Gfx_SetupDL25_Xlu(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_EnvColor(play->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, + this->lightColor.a)); + gSPSegment( + POLY_XLU_DISP++, 0x0A, + Gfx_EnvColor(play->state.gfxCtx, clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0B, + Gfx_EnvColor(play->state.gfxCtx, var_t0->r, var_t0->g, var_t0->b, this->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_801AEF88); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPoComposer_OverrideLimbDraw, EnPoComposer_PostLimbDraw, &this->actor, POLY_XLU_DISP); + } + + if (this->lightColor.a != 0) { + // Draw lantern if visible + + if (this->lightColor.a == 255) { + Scene_SetRenderModeXlu(play, 0, 1); + dl = POLY_OPA_DISP; + } else { + Scene_SetRenderModeXlu(play, 1, 2); + dl = POLY_XLU_DISP; + } + + gDPPipeSync(&dl[0]); + gDPSetEnvColor(&dl[1], this->envColor.r, this->envColor.g, this->envColor.b, this->lightColor.a); + + Matrix_Put(&this->lanternMtxF); + gSPMatrix(&dl[2], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dl[3], object_po_composer_DL_006E08); // lantern base + gSPDisplayList(&dl[4], object_po_composer_DL_006F38); // lantern enclosure + + gDPPipeSync(&dl[5]); + gDPSetEnvColor(&dl[6], clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a); + gSPDisplayList(&dl[7], object_po_composer_DL_006EA8); // lantern top + + if (this->lightColor.a == 255) { + POLY_OPA_DISP = &dl[8]; + } else { + POLY_XLU_DISP = &dl[8]; + } + } + + Matrix_Put(&play->billboardMtxF); + Matrix_MultVecZ(15.0f, &sp88); + lightPos = this->lanternCollider.elements[0].dim.worldSphere.center; + lightPos.x += (s16)sp88.x; + lightPos.y += (s16)sp88.y; + lightPos.z += (s16)sp88.z; + + Lights_PointGlowSetInfo(&this->lightInfo, lightPos.x, lightPos.y, lightPos.z, this->envColor.r, this->envColor.g, + this->envColor.b, this->envColor.a * 0.78431374f); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index a42b5048f..8eb1d8ebd 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -2,6 +2,24 @@ #define Z_EN_PO_COMPOSER_H #include "global.h" +#include "objects/object_po_composer/object_po_composer.h" + +#define PO_COMPOSER_IS_FLAT(actor) ((actor)->params & 0x8000) + +typedef enum { + COMPOSER_CS_ACTION_IDLE = 1, + COMPOSER_CS_ACTION_APPEAR_SPIN, + COMPOSER_CS_ACTION_IDLE2, + COMPOSER_CS_ACTION_RAISE_ARMS, + COMPOSER_CS_ACTION_LOWER_ARMS, + COMPOSER_CS_ACTION_PLAY_CURSE, + COMPOSER_CS_ACTION_ROLL, + COMPOSER_CS_ACTION_APPEAR, + COMPOSER_CS_ACTION_DISAPPEAR, + COMPOSER_CS_ACTION_DONE, + + COMPOSER_CS_ACTION_NONE = 99 +} EnPoComposerCutsceneAction; struct EnPoComposer; @@ -9,9 +27,26 @@ typedef void (*EnPoComposerActionFunc)(struct EnPoComposer*, PlayState*); typedef struct EnPoComposer { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xF0]; + /* 0x144 */ ColliderCylinder bodyCollider; + /* 0x190 */ ColliderJntSph lanternCollider; + /* 0x1B0 */ ColliderJntSphElement lanternColliderElements[1]; + /* 0x1F0 */ SkelAnime skelAnime; /* 0x234 */ EnPoComposerActionFunc actionFunc; - /* 0x238 */ char unk_238[0x108]; + /* 0x238 */ MtxF lanternMtxF; + /* 0x278 */ LightNode* lightNode; + /* 0x27C */ LightInfo lightInfo; + /* 0x28A */ char unk_28A[0x6]; + /* 0x290 */ s32 unk290; // cutscene to play + /* 0x294 */ Vec3s jointTable[OBJECT_PO_COMPOSER_LIMB_MAX]; + /* 0x2DC */ Vec3s morphTable[OBJECT_PO_COMPOSER_LIMB_MAX]; + /* 0x324 */ s16 csIndices[4]; + /* 0x32C */ s16 actionTimer; + /* 0x32E */ s16 csActionTimer; + /* 0x330 */ s16 unk330; // boolean, do respond to cs actions? + /* 0x332 */ s16 visible; + /* 0x334 */ u16 lastCsAction; + /* 0x336 */ Color_RGBA8 lightColor; + /* 0x33A */ Color_RGBA8 envColor; } EnPoComposer; // size = 0x340 #endif // Z_EN_PO_COMPOSER_H From 4c1e0be9f09846eaa9e9f5f3dd410f2ac494baaf Mon Sep 17 00:00:00 2001 From: Thar0 <17233964+Thar0@users.noreply.github.com> Date: Sun, 24 Sep 2023 02:20:19 +0100 Subject: [PATCH 114/130] Few more labels and document object --- assets/xml/objects/object_po_composer.xml | 80 ++++--- .../ovl_En_Po_Composer/z_en_po_composer.c | 198 +++++++++--------- .../ovl_En_Po_Composer/z_en_po_composer.h | 37 ++-- 3 files changed, 172 insertions(+), 143 deletions(-) diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 40d77d827..96c9a6c17 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -1,28 +1,36 @@  + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,17 +43,21 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 0f88f364d..1089446bc 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -1,7 +1,7 @@ /* * File: z_en_po_composer.c * Overlay: ovl_En_Po_Composer - * Description: Poe Composers + * Description: Poe Composers Flat and Sharp */ #include "z_en_po_composer.h" @@ -129,49 +129,50 @@ static DamageTable sDamageTable = { }; typedef enum { - PO_COMPOSER_ANIM_IDLE_STILL, - PO_COMPOSER_ANIM_APPEAR_DISAPPEAR, - PO_COMPOSER_ANIM_IDLE, - PO_COMPOSER_ANIM_RAISE_ARMS, - PO_COMPOSER_ANIM_ARMS_RAISED, - PO_COMPOSER_ANIM_LOWER_ARMS, - PO_COMPOSER_ANIM_IDLE_FACING_DOWN, - PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE, - PO_COMPOSER_ANIM_PLAYING_CURSE, - PO_COMPOSER_ANIM_BEGIN_ROLLING, - PO_COMPOSER_ANIM_ROLLING, - PO_COMPOSER_ANIM_FLEE, - PO_COMPOSER_ANIM_ATTACK, - PO_COMPOSER_ANIM_MAX, + /* 0 */ PO_COMPOSER_ANIM_IDLE_STILL, + /* 1 */ PO_COMPOSER_ANIM_APPEAR_DISAPPEAR, + /* 2 */ PO_COMPOSER_ANIM_IDLE, + /* 3 */ PO_COMPOSER_ANIM_RAISE_ARMS, + /* 4 */ PO_COMPOSER_ANIM_ARMS_RAISED, + /* 5 */ PO_COMPOSER_ANIM_LOWER_ARMS, + /* 6 */ PO_COMPOSER_ANIM_IDLE_FACING_DOWN, + /* 7 */ PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE, + /* 8 */ PO_COMPOSER_ANIM_PLAYING_CURSE, + /* 9 */ PO_COMPOSER_ANIM_BEGIN_ROLLING, + /* 10 */ PO_COMPOSER_ANIM_ROLLING, + /* 11 */ PO_COMPOSER_ANIM_FLEE, + /* 12 */ PO_COMPOSER_ANIM_ATTACK, + + /* 13 */ PO_COMPOSER_ANIM_MAX } EnPoComposerAnim; static AnimationInfo sAnimationInfo[PO_COMPOSER_ANIM_MAX] = { - /* 0 */ { &object_po_composer_Anim_003DB0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 1 */ { &object_po_composer_Anim_003954, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - /* 2 */ { &object_po_composer_Anim_00188C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 3 */ { &object_po_composer_Anim_000570, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 4 */ { &object_po_composer_Anim_001F44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 5 */ { &object_po_composer_Anim_0023E8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 6 */ { &object_po_composer_Anim_002AE0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 7 */ { &object_po_composer_Anim_000A58, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 8 */ { &object_po_composer_Anim_001420, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 9 */ { &object_po_composer_Anim_003024, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 10 */ { &object_po_composer_Anim_00334C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 11 */ { &object_po_composer_Anim_0015B8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 12 */ { &object_po_composer_Anim_00020C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + /* 0 */ { &gPoeComposerIdleStillAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 1 */ { &gPoeComposerAppearDisappearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + /* 2 */ { &gPoeComposerIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 3 */ { &gPoeComposerRaiseArmsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 4 */ { &gPoeComposerArmsRaisedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 5 */ { &gPoeComposerLowerArmsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 6 */ { &gPoeComposerIdleLookingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 7 */ { &gPoeComposerBeginPlayingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 8 */ { &gPoeComposerPlayingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 9 */ { &gPoeComposerBeginRollingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 10 */ { &gPoeComposerRollingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 11 */ { &gPoeComposerFleeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 12 */ { &gPoeComposerAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static Color_RGBA8 sLightColorInit = { 255, 255, 210, 0 }; static Color_RGBA8 sEnvColorInit = { 0, 0, 0, 255 }; -Color_RGBA8 D_80BC6948 = { 75, 20, 25, 255 }; +static Color_RGBA8 sSharpClothingColor1 = { 75, 20, 25, 255 }; -Color_RGBA8 D_80BC694C = { 80, 110, 90, 255 }; +static Color_RGBA8 sFlatClothingColor1 = { 80, 110, 90, 255 }; -Color_RGBA8 D_80BC6950 = { 90, 85, 50, 255 }; +static Color_RGBA8 sSharpClothingColor2 = { 90, 85, 50, 255 }; -Color_RGBA8 D_80BC6954 = { 100, 90, 100, 255 }; +static Color_RGBA8 sFlatClothingColor2 = { 100, 90, 100, 255 }; static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), @@ -184,8 +185,8 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_po_composer_Skel_009930, &object_po_composer_Anim_00188C, - this->jointTable, this->morphTable, OBJECT_PO_COMPOSER_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gPoeComposerSkel, &gPoeComposerIdleAnim, + this->jointTable, this->morphTable, PO_COMPOSER_LIMB_MAX); Collider_InitJntSph(play, &this->lanternCollider); Collider_SetJntSph(play, &this->lanternCollider, &this->actor, &sJntSphInit, this->lanternColliderElements); Collider_InitCylinder(play, &this->bodyCollider); @@ -194,21 +195,21 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 255, 255, 255, 0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->lightColor = sLightColorInit; this->envColor = sEnvColorInit; this->lastCsAction = COMPOSER_CS_ACTION_NONE; if (PO_COMPOSER_IS_FLAT(&this->actor)) { - this->unk290 = 0; - this->unk330 = true; + this->sharpCsNum = 0; + this->inCutscene = true; EnPoComposer_SetupStartedCutscene(this); } else if (this->actor.params & 0x4000) { if (gSaveContext.save.entrance != 0x20A0) { Actor_Kill(&this->actor); } else { - this->unk290 = 0; - this->unk330 = true; + this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; + this->inCutscene = true; EnPoComposer_SetupStartedCutscene(this); } } else { @@ -221,7 +222,7 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { } for (i = 0; i < ARRAY_COUNT(this->csIndices); i++) { - if (csIndex == -1) { + if (csIndex == CS_ID_NONE) { break; } this->csIndices[i] = csIndex; @@ -229,11 +230,11 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { } if (gSaveContext.save.saveInfo.weekEventReg[14] & 2) { - this->unk290 = 1; + this->sharpCsNum = SHARP_CS_ENCOUNTER_OTHER; } else { - this->unk290 = 0; + this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; } - this->unk330 = false; + this->inCutscene = false; EnPoComposer_SetupAwaitPlayer(this); } } @@ -258,19 +259,19 @@ void EnPoComposer_AwaitPlayer(EnPoComposer* this, PlayState* play) { } void EnPoComposer_SetupStartCutscene(EnPoComposer* this) { - this->unk330 = true; + this->inCutscene = true; this->actionFunc = EnPoComposer_StartCutscene; } void EnPoComposer_StartCutscene(EnPoComposer* this, PlayState* play) { - if (CutsceneManager_IsNext(this->csIndices[this->unk290])) { - CutsceneManager_Start(this->csIndices[this->unk290], &this->actor); + if (CutsceneManager_IsNext(this->csIndices[this->sharpCsNum])) { + CutsceneManager_Start(this->csIndices[this->sharpCsNum], &this->actor); EnPoComposer_SetupStartedCutscene(this); } else { - if (CutsceneManager_GetCurrentCsId() == 0x7C) { - CutsceneManager_Stop(0x7C); + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - CutsceneManager_Queue(this->csIndices[this->unk290]); + CutsceneManager_Queue(this->csIndices[this->sharpCsNum]); } } @@ -314,18 +315,19 @@ void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { if (play->msgCtx.ocarinaMode == 3) { switch (play->msgCtx.lastPlayedSong) { case OCARINA_SONG_STORMS: - this->unk290 = 3; + this->sharpCsNum = SHARP_CS_SONG_STORMS; EnPoComposer_SetupStartCutscene(this); break; + case OCARINA_SONG_HEALING: - this->unk290 = 2; + this->sharpCsNum = SHARP_CS_SONG_HEALING; EnPoComposer_SetupStartCutscene(this); break; } } // Play sharp's curse bgm - func_801A1FB4(3, &this->actor.projectedPos, NA_BGM_SHARPS_CURSE, 2000.0f); + func_801A1FB4(SEQ_PLAYER_BGM_SUB, &this->actor.projectedPos, NA_BGM_SHARPS_CURSE, 2000.0f); } void EnPoComposer_SetupIdleStill(EnPoComposer* this) { @@ -430,48 +432,59 @@ void EnPoComposer_SharpCutsceneDone(EnPoComposer* this) { } s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { - u16 actorAction = PO_COMPOSER_IS_FLAT(&this->actor) ? 0x1E2 : 0x1E1; - s32 actorActionIdx; + u16 cueType = PO_COMPOSER_IS_FLAT(&this->actor) ? 0x1E2 : 0x1E1; + s32 cueChannel; - if (!this->unk330) { + if (!this->inCutscene) { return false; } - if (Cutscene_IsCueInChannel(play, actorAction)) { - actorActionIdx = Cutscene_GetCueChannel(play, actorAction); - if (this->lastCsAction != play->csCtx.actorCues[actorActionIdx]->id) { - this->lastCsAction = play->csCtx.actorCues[actorActionIdx]->id; - switch (play->csCtx.actorCues[actorActionIdx]->id) { + if (Cutscene_IsCueInChannel(play, cueType)) { + cueChannel = Cutscene_GetCueChannel(play, cueType); + + if (this->lastCsAction != play->csCtx.actorCues[cueChannel]->id) { + this->lastCsAction = play->csCtx.actorCues[cueChannel]->id; + + switch (play->csCtx.actorCues[cueChannel]->id) { case COMPOSER_CS_ACTION_IDLE: // loop idle EnPoComposer_SetupIdleStill(this); break; + case COMPOSER_CS_ACTION_APPEAR_SPIN: // appear/disappear -> loop idle EnPoComposer_SetupAppear(this); break; + case COMPOSER_CS_ACTION_IDLE2: // loop sharp idle EnPoComposer_SetupIdle(this); break; + case COMPOSER_CS_ACTION_RAISE_ARMS: // raise arms -> loop arms raised EnPoComposer_SetupRaiseArms(this); break; + case COMPOSER_CS_ACTION_LOWER_ARMS: // lower arms -> loop idle EnPoComposer_SetupLowerArms(this); break; + case COMPOSER_CS_ACTION_PLAY_CURSE: // begin playing -> loop playing EnPoComposer_SetupCutscenePlayCurse(this); break; + case COMPOSER_CS_ACTION_ROLL: // begin rolling -> loop rolling EnPoComposer_SetupRoll(this); break; + case COMPOSER_CS_ACTION_APPEAR: // appear this->visible = true; break; + case COMPOSER_CS_ACTION_DISAPPEAR: // disappear this->visible = false; Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); break; + case COMPOSER_CS_ACTION_DONE: - if (actorAction == 0x1E1) { + if (cueType == 0x1E1) { EnPoComposer_SharpCutsceneDone(this); } else { Actor_Kill(&this->actor); @@ -479,15 +492,16 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { break; } } + if (this->actionFunc != EnPoComposer_Appear) { - Cutscene_ActorTranslateAndYaw(&this->actor, play, actorActionIdx); + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); } else { - Cutscene_ActorTranslate(&this->actor, play, actorActionIdx); + Cutscene_ActorTranslate(&this->actor, play, cueChannel); } EnPoComposer_StepLightAlpha(this); - if (this->unk290 == 3 && play->csCtx.curFrame == 204) { + if (this->sharpCsNum == SHARP_CS_SONG_STORMS && play->csCtx.curFrame == 204) { Audio_PlaySfx(NA_SE_SY_DIZZY_EFFECT); } @@ -498,14 +512,16 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { } if (this->actionFunc != EnPoComposer_StartedCutscene && this->actionFunc != EnPoComposer_StartCutscene && - this->actionFunc != EnPoComposer_PlayCurse && play->csCtx.state == 0) { + this->actionFunc != EnPoComposer_PlayCurse && play->csCtx.state == CS_STATE_IDLE) { + if (PO_COMPOSER_IS_FLAT(&this->actor)) { EnPoComposer_SetupStartedCutscene(this); } else if (this->actor.params & 0x4000) { EnPoComposer_SetupStartedCutscene(this); } else { - this->unk330 = false; - if (this->unk290 < 3) { + this->inCutscene = false; + + if (this->sharpCsNum < SHARP_CS_SONG_STORMS) { if (!(gSaveContext.save.saveInfo.weekEventReg[14] & 2)) { gSaveContext.save.saveInfo.weekEventReg[14] |= 2; } @@ -555,20 +571,14 @@ void EnPoComposer_StepLightColor(EnPoComposer* this) { } void EnPoComposer_UpdateEnvColor(EnPoComposer* this) { - f32 temp_fv0; - u32 temp_v0; - if (this->actionFunc == EnPoComposer_Appear && this->skelAnime.curFrame < 12.0f) { - temp_v0 = 55.0f + this->skelAnime.curFrame * 16.66f; - this->envColor.b = temp_v0; - this->envColor.g = temp_v0; - this->envColor.r = temp_v0; + this->envColor.r = this->envColor.g = this->envColor.b = 55.0f + this->skelAnime.curFrame * 16.66f; this->envColor.a = this->skelAnime.curFrame * 16.666666f; } else { - temp_fv0 = Rand_ZeroOne(); - this->envColor.r = 225 + (s32)(temp_fv0 * 30.0f); - this->envColor.g = 155 + (s32)(temp_fv0 * 100.0f); - this->envColor.b = 95 + (s32)(temp_fv0 * 160.0f); + f32 rand = Rand_ZeroOne(); + this->envColor.r = 225 + (s32)(rand * 30.0f); + this->envColor.g = 155 + (s32)(rand * 100.0f); + this->envColor.b = 95 + (s32)(rand * 160.0f); this->envColor.a = 200; } if (this->lightColor.a == 0) { @@ -600,10 +610,10 @@ s32 EnPoComposer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V Gfx** gfx) { EnPoComposer* this = THIS; - if (this->lightColor.a == 0 || limbIndex == OBJECT_PO_COMPOSER_LIMB_09) { // lantern + if (this->lightColor.a == 0 || limbIndex == PO_COMPOSER_LIMB_LANTERN) { // lantern *dList = NULL; - } else if (PO_COMPOSER_IS_FLAT(&this->actor) && limbIndex == OBJECT_PO_COMPOSER_LIMB_0A) { // head - *dList = object_po_composer_DL_006FD8; // flat head + } else if (PO_COMPOSER_IS_FLAT(&this->actor) && limbIndex == PO_COMPOSER_LIMB_HEAD) { // head + *dList = gPoeComposerFlatHeadDL; // flat head } if (limbIndex == 19) { @@ -619,7 +629,7 @@ void EnPoComposer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 EnPoComposer* this = THIS; Collider_UpdateSpheres(limbIndex, &this->lanternCollider); - if (limbIndex == OBJECT_PO_COMPOSER_LIMB_09) { + if (limbIndex == PO_COMPOSER_LIMB_LANTERN) { Matrix_Get(&this->lanternMtxF); } } @@ -630,7 +640,7 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { Gfx* dl; Color_RGBA8* clothingColor; Color_RGBA8* var_t0; - Vec3f sp88; + Vec3f lightOffset; Vec3s lightPos; OPEN_DISPS(play->state.gfxCtx); @@ -640,11 +650,11 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { // Select colors if (PO_COMPOSER_IS_FLAT(&this->actor)) { - clothingColor = &D_80BC694C; - var_t0 = &D_80BC6954; + clothingColor = &sFlatClothingColor1; + var_t0 = &sFlatClothingColor2; } else { - clothingColor = &D_80BC6948; - var_t0 = &D_80BC6950; + clothingColor = &sSharpClothingColor1; + var_t0 = &sSharpClothingColor2; } // Draw skeleton @@ -701,12 +711,12 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { Matrix_Put(&this->lanternMtxF); gSPMatrix(&dl[2], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(&dl[3], object_po_composer_DL_006E08); // lantern base - gSPDisplayList(&dl[4], object_po_composer_DL_006F38); // lantern enclosure + gSPDisplayList(&dl[3], gPoeComposerLanternBaseDL); + gSPDisplayList(&dl[4], gPoeComposerLanternGlassDL); gDPPipeSync(&dl[5]); gDPSetEnvColor(&dl[6], clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a); - gSPDisplayList(&dl[7], object_po_composer_DL_006EA8); // lantern top + gSPDisplayList(&dl[7], gPoeComposerLanternTopDL); if (this->lightColor.a == 255) { POLY_OPA_DISP = &dl[8]; @@ -716,11 +726,11 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { } Matrix_Put(&play->billboardMtxF); - Matrix_MultVecZ(15.0f, &sp88); + Matrix_MultVecZ(15.0f, &lightOffset); lightPos = this->lanternCollider.elements[0].dim.worldSphere.center; - lightPos.x += (s16)sp88.x; - lightPos.y += (s16)sp88.y; - lightPos.z += (s16)sp88.z; + lightPos.x += (s16)lightOffset.x; + lightPos.y += (s16)lightOffset.y; + lightPos.z += (s16)lightOffset.z; Lights_PointGlowSetInfo(&this->lightInfo, lightPos.x, lightPos.y, lightPos.z, this->envColor.r, this->envColor.g, this->envColor.b, this->envColor.a * 0.78431374f); diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index 8eb1d8ebd..af8c0ecb1 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -7,20 +7,27 @@ #define PO_COMPOSER_IS_FLAT(actor) ((actor)->params & 0x8000) typedef enum { - COMPOSER_CS_ACTION_IDLE = 1, - COMPOSER_CS_ACTION_APPEAR_SPIN, - COMPOSER_CS_ACTION_IDLE2, - COMPOSER_CS_ACTION_RAISE_ARMS, - COMPOSER_CS_ACTION_LOWER_ARMS, - COMPOSER_CS_ACTION_PLAY_CURSE, - COMPOSER_CS_ACTION_ROLL, - COMPOSER_CS_ACTION_APPEAR, - COMPOSER_CS_ACTION_DISAPPEAR, - COMPOSER_CS_ACTION_DONE, + /* 1 */ COMPOSER_CS_ACTION_IDLE = 1, + /* 2 */ COMPOSER_CS_ACTION_APPEAR_SPIN, + /* 3 */ COMPOSER_CS_ACTION_IDLE2, + /* 4 */ COMPOSER_CS_ACTION_RAISE_ARMS, + /* 5 */ COMPOSER_CS_ACTION_LOWER_ARMS, + /* 6 */ COMPOSER_CS_ACTION_PLAY_CURSE, + /* 7 */ COMPOSER_CS_ACTION_ROLL, + /* 8 */ COMPOSER_CS_ACTION_APPEAR, + /* 9 */ COMPOSER_CS_ACTION_DISAPPEAR, + /* 10 */ COMPOSER_CS_ACTION_DONE, - COMPOSER_CS_ACTION_NONE = 99 + /* 99 */ COMPOSER_CS_ACTION_NONE = 99 } EnPoComposerCutsceneAction; +typedef enum { + /* 0 */ SHARP_CS_ENCOUNTER_FIRST, + /* 1 */ SHARP_CS_ENCOUNTER_OTHER, + /* 2 */ SHARP_CS_SONG_HEALING, + /* 3 */ SHARP_CS_SONG_STORMS +} SharpCsId; + struct EnPoComposer; typedef void (*EnPoComposerActionFunc)(struct EnPoComposer*, PlayState*); @@ -36,13 +43,13 @@ typedef struct EnPoComposer { /* 0x278 */ LightNode* lightNode; /* 0x27C */ LightInfo lightInfo; /* 0x28A */ char unk_28A[0x6]; - /* 0x290 */ s32 unk290; // cutscene to play - /* 0x294 */ Vec3s jointTable[OBJECT_PO_COMPOSER_LIMB_MAX]; - /* 0x2DC */ Vec3s morphTable[OBJECT_PO_COMPOSER_LIMB_MAX]; + /* 0x290 */ s32 sharpCsNum; + /* 0x294 */ Vec3s jointTable[PO_COMPOSER_LIMB_MAX]; + /* 0x2DC */ Vec3s morphTable[PO_COMPOSER_LIMB_MAX]; /* 0x324 */ s16 csIndices[4]; /* 0x32C */ s16 actionTimer; /* 0x32E */ s16 csActionTimer; - /* 0x330 */ s16 unk330; // boolean, do respond to cs actions? + /* 0x330 */ s16 inCutscene; /* 0x332 */ s16 visible; /* 0x334 */ u16 lastCsAction; /* 0x336 */ Color_RGBA8 lightColor; From de9f4bd947925e16728d87612ce1b52316118cf3 Mon Sep 17 00:00:00 2001 From: Thar0 <17233964+Thar0@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:06:51 +0100 Subject: [PATCH 115/130] Review changes --- assets/xml/objects/object_po_composer.xml | 2 +- .../ovl_En_Po_Composer/z_en_po_composer.c | 112 +++++++++--------- .../ovl_En_Po_Composer/z_en_po_composer.h | 28 ++--- 3 files changed, 74 insertions(+), 68 deletions(-) diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 96c9a6c17..67036066f 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -18,7 +18,7 @@ - + diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 1089446bc..daa4f6338 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -32,7 +32,7 @@ void EnPoComposer_SetupStartCutscene(EnPoComposer* this); void EnPoComposer_SetupStartedCutscene(EnPoComposer* this); void EnPoComposer_StepLightAlpha(EnPoComposer* this); -const ActorInit En_Po_Composer_InitVars = { +ActorInit En_Po_Composer_InitVars = { ACTOR_EN_PO_COMPOSER, ACTORCAT_ITEMACTION, FLAGS, @@ -74,7 +74,7 @@ static ColliderJntSphElementInit sJntSphElementsInit[1] = { BUMP_NONE, OCELEM_ON, }, - { 9, { { 0, -1500, 0 }, 10 }, 100 }, + { PO_COMPOSER_LIMB_LANTERN, { { 0, -1500, 0 }, 10 }, 100 }, }, }; @@ -142,7 +142,6 @@ typedef enum { /* 10 */ PO_COMPOSER_ANIM_ROLLING, /* 11 */ PO_COMPOSER_ANIM_FLEE, /* 12 */ PO_COMPOSER_ANIM_ATTACK, - /* 13 */ PO_COMPOSER_ANIM_MAX } EnPoComposerAnim; @@ -185,8 +184,8 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &gPoeComposerSkel, &gPoeComposerIdleAnim, - this->jointTable, this->morphTable, PO_COMPOSER_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gPoeComposerSkel, &gPoeComposerIdleAnim, this->jointTable, + this->morphTable, PO_COMPOSER_LIMB_MAX); Collider_InitJntSph(play, &this->lanternCollider); Collider_SetJntSph(play, &this->lanternCollider, &this->actor, &sJntSphInit, this->lanternColliderElements); Collider_InitCylinder(play, &this->bodyCollider); @@ -198,38 +197,38 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->lightColor = sLightColorInit; this->envColor = sEnvColorInit; - this->lastCsAction = COMPOSER_CS_ACTION_NONE; + this->lastCsAction = COMPOSER_CUEID_NONE; if (PO_COMPOSER_IS_FLAT(&this->actor)) { this->sharpCsNum = 0; this->inCutscene = true; EnPoComposer_SetupStartedCutscene(this); - } else if (this->actor.params & 0x4000) { - if (gSaveContext.save.entrance != 0x20A0) { + } else if (PO_COMPOSER_4000(&this->actor)) { + if (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 10)) { Actor_Kill(&this->actor); - } else { - this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; - this->inCutscene = true; - EnPoComposer_SetupStartedCutscene(this); + return; } + this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; + this->inCutscene = true; + EnPoComposer_SetupStartedCutscene(this); } else { s32 i; - s16 csIndex = this->actor.csId; + s16 csId = this->actor.csId; - if (gSaveContext.save.saveInfo.weekEventReg[14] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { Actor_Kill(&this->actor); return; } - for (i = 0; i < ARRAY_COUNT(this->csIndices); i++) { - if (csIndex == CS_ID_NONE) { + for (i = 0; i < ARRAY_COUNT(this->csIds); i++) { + if (csId == CS_ID_NONE) { break; } - this->csIndices[i] = csIndex; - csIndex = CutsceneManager_GetAdditionalCsId(csIndex); + this->csIds[i] = csId; + csId = CutsceneManager_GetAdditionalCsId(csId); } - if (gSaveContext.save.saveInfo.weekEventReg[14] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_02)) { this->sharpCsNum = SHARP_CS_ENCOUNTER_OTHER; } else { this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; @@ -264,14 +263,14 @@ void EnPoComposer_SetupStartCutscene(EnPoComposer* this) { } void EnPoComposer_StartCutscene(EnPoComposer* this, PlayState* play) { - if (CutsceneManager_IsNext(this->csIndices[this->sharpCsNum])) { - CutsceneManager_Start(this->csIndices[this->sharpCsNum], &this->actor); + if (CutsceneManager_IsNext(this->csIds[this->sharpCsNum])) { + CutsceneManager_Start(this->csIds[this->sharpCsNum], &this->actor); EnPoComposer_SetupStartedCutscene(this); } else { if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { CutsceneManager_Stop(CS_ID_GLOBAL_TALK); } - CutsceneManager_Queue(this->csIndices[this->sharpCsNum]); + CutsceneManager_Queue(this->csIds[this->sharpCsNum]); } } @@ -323,6 +322,9 @@ void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { this->sharpCsNum = SHARP_CS_SONG_HEALING; EnPoComposer_SetupStartCutscene(this); break; + + default: + break; } } @@ -370,7 +372,7 @@ void EnPoComposer_SetupRaiseArms(EnPoComposer* this) { } void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play) { - if (this->csActionTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->csActionTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csActionTimer++; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ARMS_RAISED); } @@ -383,7 +385,7 @@ void EnPoComposer_SetupLowerArms(EnPoComposer* this) { } void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play) { - if (this->csActionTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->csActionTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csActionTimer++; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_FACING_DOWN); } @@ -396,7 +398,7 @@ void EnPoComposer_SetupCutscenePlayCurse(EnPoComposer* this) { } void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play) { - if (this->csActionTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->csActionTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csActionTimer++; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_PLAYING_CURSE); } @@ -415,7 +417,7 @@ void EnPoComposer_Roll(EnPoComposer* this, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ROLLING); } - } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && this->lightColor.a >= 33) { + } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->lightColor.a >= 33)) { if (this->csActionTimer == 1) { Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND2_OLD); this->csActionTimer = 2; @@ -427,12 +429,12 @@ void EnPoComposer_Roll(EnPoComposer* this, PlayState* play) { } void EnPoComposer_SharpCutsceneDone(EnPoComposer* this) { - gSaveContext.save.saveInfo.weekEventReg[14] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_14_04); Actor_Kill(&this->actor); } s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { - u16 cueType = PO_COMPOSER_IS_FLAT(&this->actor) ? 0x1E2 : 0x1E1; + u16 cueType = PO_COMPOSER_IS_FLAT(&this->actor) ? CS_CMD_ACTOR_CUE_482 : CS_CMD_ACTOR_CUE_481; s32 cueChannel; if (!this->inCutscene) { @@ -446,50 +448,53 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { this->lastCsAction = play->csCtx.actorCues[cueChannel]->id; switch (play->csCtx.actorCues[cueChannel]->id) { - case COMPOSER_CS_ACTION_IDLE: // loop idle + case COMPOSER_CUEID_IDLE: // loop idle EnPoComposer_SetupIdleStill(this); break; - case COMPOSER_CS_ACTION_APPEAR_SPIN: // appear/disappear -> loop idle + case COMPOSER_CUEID_APPEAR_SPIN: // appear/disappear -> loop idle EnPoComposer_SetupAppear(this); break; - case COMPOSER_CS_ACTION_IDLE2: // loop sharp idle + case COMPOSER_CUEID_IDLE2: // loop sharp idle EnPoComposer_SetupIdle(this); break; - case COMPOSER_CS_ACTION_RAISE_ARMS: // raise arms -> loop arms raised + case COMPOSER_CUEID_RAISE_ARMS: // raise arms -> loop arms raised EnPoComposer_SetupRaiseArms(this); break; - case COMPOSER_CS_ACTION_LOWER_ARMS: // lower arms -> loop idle + case COMPOSER_CUEID_LOWER_ARMS: // lower arms -> loop idle EnPoComposer_SetupLowerArms(this); break; - case COMPOSER_CS_ACTION_PLAY_CURSE: // begin playing -> loop playing + case COMPOSER_CUEID_PLAY_CURSE: // begin playing -> loop playing EnPoComposer_SetupCutscenePlayCurse(this); break; - case COMPOSER_CS_ACTION_ROLL: // begin rolling -> loop rolling + case COMPOSER_CUEID_ROLL: // begin rolling -> loop rolling EnPoComposer_SetupRoll(this); break; - case COMPOSER_CS_ACTION_APPEAR: // appear + case COMPOSER_CUEID_APPEAR: // appear this->visible = true; break; - case COMPOSER_CS_ACTION_DISAPPEAR: // disappear + case COMPOSER_CUEID_DISAPPEAR: // disappear this->visible = false; Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); break; - case COMPOSER_CS_ACTION_DONE: - if (cueType == 0x1E1) { + case COMPOSER_CUEID_DONE: + if (cueType == CS_CMD_ACTOR_CUE_481) { EnPoComposer_SharpCutsceneDone(this); } else { Actor_Kill(&this->actor); } break; + + default: + break; } } @@ -501,7 +506,7 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { EnPoComposer_StepLightAlpha(this); - if (this->sharpCsNum == SHARP_CS_SONG_STORMS && play->csCtx.curFrame == 204) { + if ((this->sharpCsNum == SHARP_CS_SONG_STORMS) && (play->csCtx.curFrame == 204)) { Audio_PlaySfx(NA_SE_SY_DIZZY_EFFECT); } @@ -516,14 +521,14 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { if (PO_COMPOSER_IS_FLAT(&this->actor)) { EnPoComposer_SetupStartedCutscene(this); - } else if (this->actor.params & 0x4000) { + } else if (PO_COMPOSER_4000(&this->actor)) { EnPoComposer_SetupStartedCutscene(this); } else { this->inCutscene = false; if (this->sharpCsNum < SHARP_CS_SONG_STORMS) { - if (!(gSaveContext.save.saveInfo.weekEventReg[14] & 2)) { - gSaveContext.save.saveInfo.weekEventReg[14] |= 2; + if (!(CHECK_WEEKEVENTREG(WEEKEVENTREG_14_02))) { + SET_WEEKEVENTREG(WEEKEVENTREG_14_02); } EnPoComposer_SetupPlayCurse(this); } else { @@ -532,22 +537,22 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { } } - this->lastCsAction = COMPOSER_CS_ACTION_NONE; + this->lastCsAction = COMPOSER_CUEID_NONE; return false; } void EnPoComposer_StepLightAlpha(EnPoComposer* this) { - if (this->visible == true && this->lightColor.a != 255) { + if ((this->visible == true) && (this->lightColor.a != 255)) { if (this->lightColor.a > 247) { this->lightColor.a = 255; } else { - this->lightColor.a = this->lightColor.a + 7; + this->lightColor.a += 7; } - } else if (!this->visible && this->lightColor.a != 0) { + } else if (!this->visible && (this->lightColor.a != 0)) { if (this->lightColor.a < 8) { this->lightColor.a = 0; } else { - this->lightColor.a = this->lightColor.a - 7; + this->lightColor.a -= 7; } } } @@ -571,11 +576,12 @@ void EnPoComposer_StepLightColor(EnPoComposer* this) { } void EnPoComposer_UpdateEnvColor(EnPoComposer* this) { - if (this->actionFunc == EnPoComposer_Appear && this->skelAnime.curFrame < 12.0f) { + if ((this->actionFunc == EnPoComposer_Appear) && (this->skelAnime.curFrame < 12.0f)) { this->envColor.r = this->envColor.g = this->envColor.b = 55.0f + this->skelAnime.curFrame * 16.66f; this->envColor.a = this->skelAnime.curFrame * 16.666666f; } else { f32 rand = Rand_ZeroOne(); + this->envColor.r = 225 + (s32)(rand * 30.0f); this->envColor.g = 155 + (s32)(rand * 100.0f); this->envColor.b = 95 + (s32)(rand * 160.0f); @@ -610,10 +616,10 @@ s32 EnPoComposer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V Gfx** gfx) { EnPoComposer* this = THIS; - if (this->lightColor.a == 0 || limbIndex == PO_COMPOSER_LIMB_LANTERN) { // lantern + if ((this->lightColor.a == 0) || (limbIndex == PO_COMPOSER_LIMB_LANTERN)) { *dList = NULL; - } else if (PO_COMPOSER_IS_FLAT(&this->actor) && limbIndex == PO_COMPOSER_LIMB_HEAD) { // head - *dList = gPoeComposerFlatHeadDL; // flat head + } else if (PO_COMPOSER_IS_FLAT(&this->actor) && (limbIndex == PO_COMPOSER_LIMB_HEAD)) { + *dList = gPoeComposerFlatHeadDL; } if (limbIndex == 19) { @@ -659,7 +665,7 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { // Draw skeleton - if (this->lightColor.a == 255 || this->lightColor.a == 0) { + if ((this->lightColor.a == 255) || (this->lightColor.a == 0)) { Gfx_SetupDL25_Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index af8c0ecb1..c067b8d5e 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -5,20 +5,20 @@ #include "objects/object_po_composer/object_po_composer.h" #define PO_COMPOSER_IS_FLAT(actor) ((actor)->params & 0x8000) +#define PO_COMPOSER_4000(actor) ((actor)->params & 0x4000) typedef enum { - /* 1 */ COMPOSER_CS_ACTION_IDLE = 1, - /* 2 */ COMPOSER_CS_ACTION_APPEAR_SPIN, - /* 3 */ COMPOSER_CS_ACTION_IDLE2, - /* 4 */ COMPOSER_CS_ACTION_RAISE_ARMS, - /* 5 */ COMPOSER_CS_ACTION_LOWER_ARMS, - /* 6 */ COMPOSER_CS_ACTION_PLAY_CURSE, - /* 7 */ COMPOSER_CS_ACTION_ROLL, - /* 8 */ COMPOSER_CS_ACTION_APPEAR, - /* 9 */ COMPOSER_CS_ACTION_DISAPPEAR, - /* 10 */ COMPOSER_CS_ACTION_DONE, - - /* 99 */ COMPOSER_CS_ACTION_NONE = 99 + /* 1 */ COMPOSER_CUEID_IDLE = 1, + /* 2 */ COMPOSER_CUEID_APPEAR_SPIN, + /* 3 */ COMPOSER_CUEID_IDLE2, + /* 4 */ COMPOSER_CUEID_RAISE_ARMS, + /* 5 */ COMPOSER_CUEID_LOWER_ARMS, + /* 6 */ COMPOSER_CUEID_PLAY_CURSE, + /* 7 */ COMPOSER_CUEID_ROLL, + /* 8 */ COMPOSER_CUEID_APPEAR, + /* 9 */ COMPOSER_CUEID_DISAPPEAR, + /* 10 */ COMPOSER_CUEID_DONE, + /* 99 */ COMPOSER_CUEID_NONE = 99 } EnPoComposerCutsceneAction; typedef enum { @@ -42,11 +42,11 @@ typedef struct EnPoComposer { /* 0x238 */ MtxF lanternMtxF; /* 0x278 */ LightNode* lightNode; /* 0x27C */ LightInfo lightInfo; - /* 0x28A */ char unk_28A[0x6]; + /* 0x28A */ UNK_TYPE1 unk_28A[0x6]; /* 0x290 */ s32 sharpCsNum; /* 0x294 */ Vec3s jointTable[PO_COMPOSER_LIMB_MAX]; /* 0x2DC */ Vec3s morphTable[PO_COMPOSER_LIMB_MAX]; - /* 0x324 */ s16 csIndices[4]; + /* 0x324 */ s16 csIds[4]; /* 0x32C */ s16 actionTimer; /* 0x32E */ s16 csActionTimer; /* 0x330 */ s16 inCutscene; From 630212af0d2a883f131e3268430aec810f5da557 Mon Sep 17 00:00:00 2001 From: Thar0 <17233964+Thar0@users.noreply.github.com> Date: Wed, 4 Oct 2023 00:30:10 +0100 Subject: [PATCH 116/130] Further review changes --- assets/xml/objects/object_po_composer.xml | 2 +- .../ovl_En_Po_Composer/z_en_po_composer.c | 50 +++++++++---------- .../ovl_En_Po_Composer/z_en_po_composer.h | 13 ++--- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 67036066f..4b5ca10b8 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -58,6 +58,6 @@ - + diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index daa4f6338..e223c4504 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -197,7 +197,7 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->lightColor = sLightColorInit; this->envColor = sEnvColorInit; - this->lastCsAction = COMPOSER_CUEID_NONE; + this->cueId = COMPOSER_CUEID_NONE; if (PO_COMPOSER_IS_FLAT(&this->actor)) { this->sharpCsNum = 0; @@ -365,65 +365,65 @@ void EnPoComposer_Idle(EnPoComposer* this, PlayState* play) { } void EnPoComposer_SetupRaiseArms(EnPoComposer* this) { - this->csActionTimer = 0; + this->csCueTimer = 0; Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_RAISE_ARMS); this->actionFunc = EnPoComposer_RaiseArms; } void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play) { - if ((this->csActionTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->csActionTimer++; + if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ARMS_RAISED); } } void EnPoComposer_SetupLowerArms(EnPoComposer* this) { - this->csActionTimer = 0; + this->csCueTimer = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_LOWER_ARMS); this->actionFunc = EnPoComposer_LowerArms; } void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play) { - if ((this->csActionTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->csActionTimer++; + if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_FACING_DOWN); } } void EnPoComposer_SetupCutscenePlayCurse(EnPoComposer* this) { - this->csActionTimer = 0; + this->csCueTimer = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE); this->actionFunc = EnPoComposer_CutscenePlayCurse; } void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play) { - if ((this->csActionTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->csActionTimer++; + if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_PLAYING_CURSE); } } void EnPoComposer_SetupRoll(EnPoComposer* this) { - this->csActionTimer = 0; + this->csCueTimer = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_BEGIN_ROLLING); this->actionFunc = EnPoComposer_Roll; } void EnPoComposer_Roll(EnPoComposer* this, PlayState* play) { - if (this->csActionTimer == 0) { + if (this->csCueTimer == 0) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->csActionTimer++; + this->csCueTimer++; Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ROLLING); } - } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->lightColor.a >= 33)) { - if (this->csActionTimer == 1) { + } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->lightColor.a > 32)) { + if (this->csCueTimer == 1) { Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND2_OLD); - this->csActionTimer = 2; + this->csCueTimer = 2; } else { Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND3_OLD); - this->csActionTimer = 1; + this->csCueTimer = 1; } } } @@ -444,8 +444,8 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { if (Cutscene_IsCueInChannel(play, cueType)) { cueChannel = Cutscene_GetCueChannel(play, cueType); - if (this->lastCsAction != play->csCtx.actorCues[cueChannel]->id) { - this->lastCsAction = play->csCtx.actorCues[cueChannel]->id; + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; switch (play->csCtx.actorCues[cueChannel]->id) { case COMPOSER_CUEID_IDLE: // loop idle @@ -516,8 +516,8 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { return true; } - if (this->actionFunc != EnPoComposer_StartedCutscene && this->actionFunc != EnPoComposer_StartCutscene && - this->actionFunc != EnPoComposer_PlayCurse && play->csCtx.state == CS_STATE_IDLE) { + if ((this->actionFunc != EnPoComposer_StartedCutscene) && (this->actionFunc != EnPoComposer_StartCutscene) && + (this->actionFunc != EnPoComposer_PlayCurse) && (play->csCtx.state == CS_STATE_IDLE)) { if (PO_COMPOSER_IS_FLAT(&this->actor)) { EnPoComposer_SetupStartedCutscene(this); @@ -527,7 +527,7 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { this->inCutscene = false; if (this->sharpCsNum < SHARP_CS_SONG_STORMS) { - if (!(CHECK_WEEKEVENTREG(WEEKEVENTREG_14_02))) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_02)) { SET_WEEKEVENTREG(WEEKEVENTREG_14_02); } EnPoComposer_SetupPlayCurse(this); @@ -537,7 +537,7 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { } } - this->lastCsAction = COMPOSER_CUEID_NONE; + this->cueId = COMPOSER_CUEID_NONE; return false; } @@ -628,7 +628,7 @@ s32 EnPoComposer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V gDPSetEnvColor((*gfx)++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); } - return 0; + return false; } void EnPoComposer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { @@ -739,7 +739,7 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { lightPos.z += (s16)lightOffset.z; Lights_PointGlowSetInfo(&this->lightInfo, lightPos.x, lightPos.y, lightPos.z, this->envColor.r, this->envColor.g, - this->envColor.b, this->envColor.a * 0.78431374f); + this->envColor.b, this->envColor.a * (200.0f / 255.0f)); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index c067b8d5e..535a63b3b 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -19,14 +19,15 @@ typedef enum { /* 9 */ COMPOSER_CUEID_DISAPPEAR, /* 10 */ COMPOSER_CUEID_DONE, /* 99 */ COMPOSER_CUEID_NONE = 99 -} EnPoComposerCutsceneAction; +} EnPoComposerCueId; typedef enum { /* 0 */ SHARP_CS_ENCOUNTER_FIRST, /* 1 */ SHARP_CS_ENCOUNTER_OTHER, /* 2 */ SHARP_CS_SONG_HEALING, - /* 3 */ SHARP_CS_SONG_STORMS -} SharpCsId; + /* 3 */ SHARP_CS_SONG_STORMS, + /* 4 */ SHARP_CS_MAX +} SharpCsIdIndex; struct EnPoComposer; @@ -46,12 +47,12 @@ typedef struct EnPoComposer { /* 0x290 */ s32 sharpCsNum; /* 0x294 */ Vec3s jointTable[PO_COMPOSER_LIMB_MAX]; /* 0x2DC */ Vec3s morphTable[PO_COMPOSER_LIMB_MAX]; - /* 0x324 */ s16 csIds[4]; + /* 0x324 */ s16 csIds[SHARP_CS_MAX]; /* 0x32C */ s16 actionTimer; - /* 0x32E */ s16 csActionTimer; + /* 0x32E */ s16 csCueTimer; /* 0x330 */ s16 inCutscene; /* 0x332 */ s16 visible; - /* 0x334 */ u16 lastCsAction; + /* 0x334 */ u16 cueId; /* 0x336 */ Color_RGBA8 lightColor; /* 0x33A */ Color_RGBA8 envColor; } EnPoComposer; // size = 0x340 From 7ed2f171857fc5b830963ccc4ba11641b4b6d28b Mon Sep 17 00:00:00 2001 From: Thar0 <17233964+Thar0@users.noreply.github.com> Date: Wed, 4 Oct 2023 03:39:48 +0100 Subject: [PATCH 117/130] Improve EnPoComposer_UpdateEnvColor --- src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index e223c4504..3ea6559f7 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -577,8 +577,9 @@ void EnPoComposer_StepLightColor(EnPoComposer* this) { void EnPoComposer_UpdateEnvColor(EnPoComposer* this) { if ((this->actionFunc == EnPoComposer_Appear) && (this->skelAnime.curFrame < 12.0f)) { + // Step rgb from 55 to 255 and alpha from 0 to 200 over the first 12 frames of the appear anim this->envColor.r = this->envColor.g = this->envColor.b = 55.0f + this->skelAnime.curFrame * 16.66f; - this->envColor.a = this->skelAnime.curFrame * 16.666666f; + this->envColor.a = this->skelAnime.curFrame * (200.0f / 12.0f); } else { f32 rand = Rand_ZeroOne(); From 974c9a6aad5d2863f78eab0214aae2dd6737ea9c Mon Sep 17 00:00:00 2001 From: Thar0 <17233964+Thar0@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:06:00 +0100 Subject: [PATCH 118/130] PO_COMPOSER -> POE_COMPOSER, tweak animation names --- assets/xml/objects/object_po_composer.xml | 37 +++--- .../ovl_En_Po_Composer/z_en_po_composer.c | 116 +++++++++--------- .../ovl_En_Po_Composer/z_en_po_composer.h | 30 ++--- 3 files changed, 92 insertions(+), 91 deletions(-) diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 4b5ca10b8..4ac60c00b 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -1,21 +1,22 @@  + - - + + - - - + + + - + @@ -45,19 +46,19 @@ - - - - - - - - - - - + + + + + + + + + + + - + diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 3ea6559f7..b8a4089e8 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -74,7 +74,7 @@ static ColliderJntSphElementInit sJntSphElementsInit[1] = { BUMP_NONE, OCELEM_ON, }, - { PO_COMPOSER_LIMB_LANTERN, { { 0, -1500, 0 }, 10 }, 100 }, + { POE_COMPOSER_LIMB_LANTERN, { { 0, -1500, 0 }, 10 }, 100 }, }, }; @@ -129,34 +129,34 @@ static DamageTable sDamageTable = { }; typedef enum { - /* 0 */ PO_COMPOSER_ANIM_IDLE_STILL, - /* 1 */ PO_COMPOSER_ANIM_APPEAR_DISAPPEAR, - /* 2 */ PO_COMPOSER_ANIM_IDLE, - /* 3 */ PO_COMPOSER_ANIM_RAISE_ARMS, - /* 4 */ PO_COMPOSER_ANIM_ARMS_RAISED, - /* 5 */ PO_COMPOSER_ANIM_LOWER_ARMS, - /* 6 */ PO_COMPOSER_ANIM_IDLE_FACING_DOWN, - /* 7 */ PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE, - /* 8 */ PO_COMPOSER_ANIM_PLAYING_CURSE, - /* 9 */ PO_COMPOSER_ANIM_BEGIN_ROLLING, - /* 10 */ PO_COMPOSER_ANIM_ROLLING, - /* 11 */ PO_COMPOSER_ANIM_FLEE, - /* 12 */ PO_COMPOSER_ANIM_ATTACK, - /* 13 */ PO_COMPOSER_ANIM_MAX + /* 0 */ POE_COMPOSER_ANIM_STILL, + /* 1 */ POE_COMPOSER_ANIM_APPEAR_DISAPPEAR, + /* 2 */ POE_COMPOSER_ANIM_IDLE, + /* 3 */ POE_COMPOSER_ANIM_RAISE_ARMS, + /* 4 */ POE_COMPOSER_ANIM_ARMS_RAISED, + /* 5 */ POE_COMPOSER_ANIM_LOWER_ARMS, + /* 6 */ POE_COMPOSER_ANIM_LOOKING_DOWN, + /* 7 */ POE_COMPOSER_ANIM_BEGIN_PLAYING_CURSE, + /* 8 */ POE_COMPOSER_ANIM_PLAYING_CURSE, + /* 9 */ POE_COMPOSER_ANIM_BEGIN_ROLLING, + /* 10 */ POE_COMPOSER_ANIM_ROLLING, + /* 11 */ POE_COMPOSER_ANIM_FLEE, + /* 12 */ POE_COMPOSER_ANIM_ATTACK, + /* 13 */ POE_COMPOSER_ANIM_MAX } EnPoComposerAnim; -static AnimationInfo sAnimationInfo[PO_COMPOSER_ANIM_MAX] = { - /* 0 */ { &gPoeComposerIdleStillAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, +static AnimationInfo sAnimationInfo[POE_COMPOSER_ANIM_MAX] = { + /* 0 */ { &gPoeComposerStillAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, /* 1 */ { &gPoeComposerAppearDisappearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, /* 2 */ { &gPoeComposerIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, /* 3 */ { &gPoeComposerRaiseArmsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, /* 4 */ { &gPoeComposerArmsRaisedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, /* 5 */ { &gPoeComposerLowerArmsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 6 */ { &gPoeComposerIdleLookingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 7 */ { &gPoeComposerBeginPlayingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 8 */ { &gPoeComposerPlayingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 9 */ { &gPoeComposerBeginRollingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - /* 10 */ { &gPoeComposerRollingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 6 */ { &gPoeComposerLookingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 7 */ { &gPoeComposerBeginPlayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 8 */ { &gPoeComposerPlayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 9 */ { &gPoeComposerBeginRollAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 10 */ { &gPoeComposerRollAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, /* 11 */ { &gPoeComposerFleeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, /* 12 */ { &gPoeComposerAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; @@ -185,7 +185,7 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gPoeComposerSkel, &gPoeComposerIdleAnim, this->jointTable, - this->morphTable, PO_COMPOSER_LIMB_MAX); + this->morphTable, POE_COMPOSER_LIMB_MAX); Collider_InitJntSph(play, &this->lanternCollider); Collider_SetJntSph(play, &this->lanternCollider, &this->actor, &sJntSphInit, this->lanternColliderElements); Collider_InitCylinder(play, &this->bodyCollider); @@ -197,13 +197,13 @@ void EnPoComposer_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->lightColor = sLightColorInit; this->envColor = sEnvColorInit; - this->cueId = COMPOSER_CUEID_NONE; + this->cueId = POE_COMPOSER_CUEID_NONE; - if (PO_COMPOSER_IS_FLAT(&this->actor)) { + if (POE_COMPOSER_IS_FLAT(&this->actor)) { this->sharpCsNum = 0; this->inCutscene = true; EnPoComposer_SetupStartedCutscene(this); - } else if (PO_COMPOSER_4000(&this->actor)) { + } else if (POE_COMPOSER_4000(&this->actor)) { if (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 10)) { Actor_Kill(&this->actor); return; @@ -247,7 +247,7 @@ void EnPoComposer_Destroy(Actor* thisx, PlayState* play) { } void EnPoComposer_SetupAwaitPlayer(EnPoComposer* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_STILL); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_STILL); this->actionFunc = EnPoComposer_AwaitPlayer; } @@ -284,7 +284,7 @@ void EnPoComposer_StartedCutscene(EnPoComposer* this, PlayState* play) { void EnPoComposer_SetupPlayCurse(EnPoComposer* this) { this->actionTimer = 0; this->actor.flags |= ACTOR_FLAG_TARGETABLE; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_PLAYING_CURSE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_PLAYING_CURSE); this->actionFunc = EnPoComposer_PlayCurse; } @@ -310,7 +310,7 @@ void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { sPlayerIsPlayingOcarina = false; } - // Song check, check if player just played song of storms or song of healing to react to + // Song check, check if player just played song of storms or song of healing if (play->msgCtx.ocarinaMode == 3) { switch (play->msgCtx.lastPlayedSong) { case OCARINA_SONG_STORMS: @@ -333,7 +333,7 @@ void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { } void EnPoComposer_SetupIdleStill(EnPoComposer* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_STILL); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_STILL); this->actionFunc = EnPoComposer_IdleStill; } @@ -344,7 +344,7 @@ void EnPoComposer_SetupAppear(EnPoComposer* this) { this->actionTimer = 0; Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_APPEAR_DISAPPEAR); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_APPEAR_DISAPPEAR); this->actionFunc = EnPoComposer_Appear; } @@ -357,7 +357,7 @@ void EnPoComposer_Appear(EnPoComposer* this, PlayState* play) { } void EnPoComposer_SetupIdle(EnPoComposer* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_IDLE); this->actionFunc = EnPoComposer_Idle; } @@ -367,46 +367,46 @@ void EnPoComposer_Idle(EnPoComposer* this, PlayState* play) { void EnPoComposer_SetupRaiseArms(EnPoComposer* this) { this->csCueTimer = 0; Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_RAISE_ARMS); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_RAISE_ARMS); this->actionFunc = EnPoComposer_RaiseArms; } void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play) { if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csCueTimer++; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ARMS_RAISED); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_ARMS_RAISED); } } void EnPoComposer_SetupLowerArms(EnPoComposer* this) { this->csCueTimer = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_LOWER_ARMS); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_LOWER_ARMS); this->actionFunc = EnPoComposer_LowerArms; } void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play) { if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csCueTimer++; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_IDLE_FACING_DOWN); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_LOOKING_DOWN); } } void EnPoComposer_SetupCutscenePlayCurse(EnPoComposer* this) { this->csCueTimer = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_BEGIN_PLAYING_CURSE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_BEGIN_PLAYING_CURSE); this->actionFunc = EnPoComposer_CutscenePlayCurse; } void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play) { if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csCueTimer++; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_PLAYING_CURSE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_PLAYING_CURSE); } } void EnPoComposer_SetupRoll(EnPoComposer* this) { this->csCueTimer = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_BEGIN_ROLLING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_BEGIN_ROLLING); this->actionFunc = EnPoComposer_Roll; } @@ -415,7 +415,7 @@ void EnPoComposer_Roll(EnPoComposer* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->csCueTimer++; Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, PO_COMPOSER_ANIM_ROLLING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_ROLLING); } } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->lightColor.a > 32)) { if (this->csCueTimer == 1) { @@ -434,7 +434,7 @@ void EnPoComposer_SharpCutsceneDone(EnPoComposer* this) { } s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { - u16 cueType = PO_COMPOSER_IS_FLAT(&this->actor) ? CS_CMD_ACTOR_CUE_482 : CS_CMD_ACTOR_CUE_481; + u16 cueType = POE_COMPOSER_IS_FLAT(&this->actor) ? CS_CMD_ACTOR_CUE_482 : CS_CMD_ACTOR_CUE_481; s32 cueChannel; if (!this->inCutscene) { @@ -448,44 +448,44 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { this->cueId = play->csCtx.actorCues[cueChannel]->id; switch (play->csCtx.actorCues[cueChannel]->id) { - case COMPOSER_CUEID_IDLE: // loop idle + case POE_COMPOSER_CUEID_IDLE: // loop idle EnPoComposer_SetupIdleStill(this); break; - case COMPOSER_CUEID_APPEAR_SPIN: // appear/disappear -> loop idle + case POE_COMPOSER_CUEID_APPEAR_SPIN: // appear/disappear -> loop idle EnPoComposer_SetupAppear(this); break; - case COMPOSER_CUEID_IDLE2: // loop sharp idle + case POE_COMPOSER_CUEID_IDLE2: // loop sharp idle EnPoComposer_SetupIdle(this); break; - case COMPOSER_CUEID_RAISE_ARMS: // raise arms -> loop arms raised + case POE_COMPOSER_CUEID_RAISE_ARMS: // raise arms -> loop arms raised EnPoComposer_SetupRaiseArms(this); break; - case COMPOSER_CUEID_LOWER_ARMS: // lower arms -> loop idle + case POE_COMPOSER_CUEID_LOWER_ARMS: // lower arms -> loop idle EnPoComposer_SetupLowerArms(this); break; - case COMPOSER_CUEID_PLAY_CURSE: // begin playing -> loop playing + case POE_COMPOSER_CUEID_PLAY_CURSE: // begin playing -> loop playing EnPoComposer_SetupCutscenePlayCurse(this); break; - case COMPOSER_CUEID_ROLL: // begin rolling -> loop rolling + case POE_COMPOSER_CUEID_ROLL: // begin rolling -> loop rolling EnPoComposer_SetupRoll(this); break; - case COMPOSER_CUEID_APPEAR: // appear + case POE_COMPOSER_CUEID_APPEAR: // appear this->visible = true; break; - case COMPOSER_CUEID_DISAPPEAR: // disappear + case POE_COMPOSER_CUEID_DISAPPEAR: // disappear this->visible = false; Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); break; - case COMPOSER_CUEID_DONE: + case POE_COMPOSER_CUEID_DONE: if (cueType == CS_CMD_ACTOR_CUE_481) { EnPoComposer_SharpCutsceneDone(this); } else { @@ -519,9 +519,9 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { if ((this->actionFunc != EnPoComposer_StartedCutscene) && (this->actionFunc != EnPoComposer_StartCutscene) && (this->actionFunc != EnPoComposer_PlayCurse) && (play->csCtx.state == CS_STATE_IDLE)) { - if (PO_COMPOSER_IS_FLAT(&this->actor)) { + if (POE_COMPOSER_IS_FLAT(&this->actor)) { EnPoComposer_SetupStartedCutscene(this); - } else if (PO_COMPOSER_4000(&this->actor)) { + } else if (POE_COMPOSER_4000(&this->actor)) { EnPoComposer_SetupStartedCutscene(this); } else { this->inCutscene = false; @@ -537,7 +537,7 @@ s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { } } - this->cueId = COMPOSER_CUEID_NONE; + this->cueId = POE_COMPOSER_CUEID_NONE; return false; } @@ -617,9 +617,9 @@ s32 EnPoComposer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, V Gfx** gfx) { EnPoComposer* this = THIS; - if ((this->lightColor.a == 0) || (limbIndex == PO_COMPOSER_LIMB_LANTERN)) { + if ((this->lightColor.a == 0) || (limbIndex == POE_COMPOSER_LIMB_LANTERN)) { *dList = NULL; - } else if (PO_COMPOSER_IS_FLAT(&this->actor) && (limbIndex == PO_COMPOSER_LIMB_HEAD)) { + } else if (POE_COMPOSER_IS_FLAT(&this->actor) && (limbIndex == POE_COMPOSER_LIMB_HEAD)) { *dList = gPoeComposerFlatHeadDL; } @@ -636,7 +636,7 @@ void EnPoComposer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 EnPoComposer* this = THIS; Collider_UpdateSpheres(limbIndex, &this->lanternCollider); - if (limbIndex == PO_COMPOSER_LIMB_LANTERN) { + if (limbIndex == POE_COMPOSER_LIMB_LANTERN) { Matrix_Get(&this->lanternMtxF); } } @@ -656,7 +656,7 @@ void EnPoComposer_Draw(Actor* thisx, PlayState* play) { // Select colors - if (PO_COMPOSER_IS_FLAT(&this->actor)) { + if (POE_COMPOSER_IS_FLAT(&this->actor)) { clothingColor = &sFlatClothingColor1; var_t0 = &sFlatClothingColor2; } else { diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index 535a63b3b..d64fc2430 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -4,21 +4,21 @@ #include "global.h" #include "objects/object_po_composer/object_po_composer.h" -#define PO_COMPOSER_IS_FLAT(actor) ((actor)->params & 0x8000) -#define PO_COMPOSER_4000(actor) ((actor)->params & 0x4000) +#define POE_COMPOSER_IS_FLAT(actor) ((actor)->params & 0x8000) +#define POE_COMPOSER_4000(actor) ((actor)->params & 0x4000) typedef enum { - /* 1 */ COMPOSER_CUEID_IDLE = 1, - /* 2 */ COMPOSER_CUEID_APPEAR_SPIN, - /* 3 */ COMPOSER_CUEID_IDLE2, - /* 4 */ COMPOSER_CUEID_RAISE_ARMS, - /* 5 */ COMPOSER_CUEID_LOWER_ARMS, - /* 6 */ COMPOSER_CUEID_PLAY_CURSE, - /* 7 */ COMPOSER_CUEID_ROLL, - /* 8 */ COMPOSER_CUEID_APPEAR, - /* 9 */ COMPOSER_CUEID_DISAPPEAR, - /* 10 */ COMPOSER_CUEID_DONE, - /* 99 */ COMPOSER_CUEID_NONE = 99 + /* 1 */ POE_COMPOSER_CUEID_IDLE = 1, + /* 2 */ POE_COMPOSER_CUEID_APPEAR_SPIN, + /* 3 */ POE_COMPOSER_CUEID_IDLE2, + /* 4 */ POE_COMPOSER_CUEID_RAISE_ARMS, + /* 5 */ POE_COMPOSER_CUEID_LOWER_ARMS, + /* 6 */ POE_COMPOSER_CUEID_PLAY_CURSE, + /* 7 */ POE_COMPOSER_CUEID_ROLL, + /* 8 */ POE_COMPOSER_CUEID_APPEAR, + /* 9 */ POE_COMPOSER_CUEID_DISAPPEAR, + /* 10 */ POE_COMPOSER_CUEID_DONE, + /* 99 */ POE_COMPOSER_CUEID_NONE = 99 } EnPoComposerCueId; typedef enum { @@ -45,8 +45,8 @@ typedef struct EnPoComposer { /* 0x27C */ LightInfo lightInfo; /* 0x28A */ UNK_TYPE1 unk_28A[0x6]; /* 0x290 */ s32 sharpCsNum; - /* 0x294 */ Vec3s jointTable[PO_COMPOSER_LIMB_MAX]; - /* 0x2DC */ Vec3s morphTable[PO_COMPOSER_LIMB_MAX]; + /* 0x294 */ Vec3s jointTable[POE_COMPOSER_LIMB_MAX]; + /* 0x2DC */ Vec3s morphTable[POE_COMPOSER_LIMB_MAX]; /* 0x324 */ s16 csIds[SHARP_CS_MAX]; /* 0x32C */ s16 actionTimer; /* 0x32E */ s16 csCueTimer; From 404dc163e11c340527d866852632eeb338438591 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Mon, 9 Oct 2023 00:13:52 -0400 Subject: [PATCH 119/130] add flags, func_80930190 OK --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 1c4dec2e6..3cd6e0159 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -292,7 +292,7 @@ void func_8092EBDC(EnHonotrap* this, PlayState* play) { void func_8092EC9C(EnHonotrap* this) { this->actionFunc = func_8092ECF0; - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, 0, 40); this->unk220 = 30; Actor_PlaySfx(&this->actor, NA_SE_EV_RED_EYE); } @@ -355,8 +355,8 @@ void func_8092EE90(EnHonotrap* this, PlayState* play) { } void func_8092EF3C(EnHonotrap* this) { - Actor_PlaySfx(&this->actor, 0x2881U); - Actor_SetColorFilter(&this->actor, 0x4000U, 255, 0, 40); + Actor_PlaySfx(&this->actor, NA_SE_EV_RED_EYE); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, 0, 40); this->unk220 = 0x28; this->actionFunc = func_8092EF98; } @@ -433,8 +433,8 @@ void func_8092F1A0(EnHonotrap* this) { } void func_8092F208(EnHonotrap* this, PlayState* play) { - if ((this->collider.tris.base.atFlags & 2) || (this->unk220 <= 0)) { - if ((this->collider.tris.base.atFlags & 2) && !(this->collider.tris.base.atFlags & 4)) { + if ((this->collider.tris.base.atFlags & AT_HIT) || (this->unk220 <= 0)) { + if ((this->collider.tris.base.atFlags & AT_HIT) && !(this->collider.tris.base.atFlags & AT_BOUNCED)) { func_800B8D98(play, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 0.0f); } this->actor.velocity.z = 0.0f; @@ -446,7 +446,7 @@ void func_8092F208(EnHonotrap* this, PlayState* play) { if (this->actor.velocity.y > 0.0f) { this->actor.world.pos.x += this->actor.velocity.x; this->actor.world.pos.z += this->actor.velocity.z; - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 12.0f, 0.0f, 5U); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 1.0f, this->actor.velocity.y) == 0) { this->actor.velocity.y += 1.0f; @@ -488,9 +488,11 @@ void func_8092F3D8(EnHonotrap* this, PlayState* play) { temp_s1 &= Math_StepToF(&this->actor.world.pos.x, this->unk228.x, sp60.x); temp_s1 &= Math_StepToF(&this->actor.world.pos.y, this->unk228.y, sp60.y); temp_s1 &= Math_StepToF(&this->actor.world.pos.z, this->unk228.z, sp60.z); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); - if (this->collider.tris.base.atFlags & 4) { + if (this->collider.tris.base.atFlags & AT_BOUNCED) { player = GET_PLAYER(play); sp34.x = -player->shieldMf.xz; sp34.y = -player->shieldMf.yz; @@ -503,7 +505,7 @@ void func_8092F3D8(EnHonotrap* this, PlayState* play) { func_8092F7A8(this); return; } - if (this->collider.tris.base.atFlags & 2) { + if (this->collider.tris.base.atFlags & AT_HIT) { this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; func_8092F7A8(this); @@ -546,20 +548,22 @@ void func_8092F5EC(EnHonotrap* this, PlayState* play) { } this->actor.velocity.y *= 0.95f; Actor_UpdatePos(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); - if (this->collider.tris.base.atFlags & 4) { + if (this->collider.tris.base.atFlags & AT_BOUNCED) { Player* player = GET_PLAYER(play); Vec3s sp30; Matrix_MtxFToYXZRot(&player->shieldMf, &sp30, 0); this->actor.world.rot.y = ((sp30.y * 2) - this->actor.world.rot.y) + 0x8000; func_8092F7A8(this); - } else if (this->collider.tris.base.atFlags & 2) { + } else if (this->collider.tris.base.atFlags & AT_HIT) { this->actor.speed *= 0.1f; this->actor.velocity.y *= 0.1f; func_8092F7A8(this); - } else if ((this->actor.bgCheckFlags & 8) || (this->unk220 <= 0)) { + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk220 <= 0)) { func_8092F7A8(this); } else { func_8092E510(this, play); @@ -577,7 +581,9 @@ void func_8092F7BC(EnHonotrap* this, PlayState* play) { this->actor.scale.y = temp_fv0; this->actor.scale.z = temp_fv0; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, 0x1DU); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); if (sp28 != 0) { Actor_Kill(&this->actor); } @@ -695,7 +701,7 @@ void EnHonotrap_Update(Actor* thisx, PlayState* play) { this->actor.child = NULL; } this->actionFunc(this, play); - if (this->collider.tris.base.acFlags & 2) { + if (this->collider.tris.base.acFlags & AC_HIT) { EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &D_809304EC, &D_809304F8, 15, 8); Actor_Kill(&this->actor); return; @@ -767,13 +773,14 @@ void func_80930030(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -#ifdef NON_MATCHING void func_80930190(Actor* thisx, PlayState* play) { - EnHonotrap* this = (EnHonotrap*)thisx; - Vec3s spB8; + s32 pad; + EnHonotrap* this; EnHonotrapArr* temp_s0; EnHonotrap23C* var_s3; s32 i; // s4 + s32 pad2; + Vec3s spB8; OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL25_Xlu(play->state.gfxCtx); @@ -781,6 +788,7 @@ void func_80930190(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Camera_GetCamDir(&spB8, play->cameraPtrs[play->activeCamId]); spB8.y += 0x8000; + this = ((EnHonotrap*)thisx); var_s3 = &this->unk23C; for (i = 0; i < 6; i++) { temp_s0 = &var_s3->unkC[i]; @@ -789,9 +797,7 @@ void func_80930190(Actor* thisx, PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); Matrix_SetTranslateRotateYXZ(temp_s0->unk0.x, temp_s0->unk0.y - (4000.0f * temp_s0->unkC), temp_s0->unk0.z, &spB8); - // temp_fa1 = temp_s0->unkC; - Matrix_Scale(((fabsf(Math_SinS((s16)(spB8.y - this->actor.shape.rot.y) >> 1)) * 0.2f) + 1.7f) * - temp_s0->unkC, + Matrix_Scale(((fabsf(Math_SinS((s16)(spB8.y - thisx->shape.rot.y) >> 1)) * 0.2f) + 1.7f) * temp_s0->unkC, temp_s0->unkC, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); @@ -799,6 +805,3 @@ void func_80930190(Actor* thisx, PlayState* play) { } CLOSE_DISPS(play->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_80930190.s") -#endif From 5f057d56e0397222724910b8c71e36d936d9353d Mon Sep 17 00:00:00 2001 From: mzxrules Date: Mon, 9 Oct 2023 00:33:23 -0400 Subject: [PATCH 120/130] z_en_honotrap OK --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 58 +++++++++---------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 3cd6e0159..25cd1a782 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -468,61 +468,55 @@ void func_8092F34C(EnHonotrap* this) { this->unk234 = 0.0f; } -#ifdef NON_MATCHING void func_8092F3D8(EnHonotrap* this, PlayState* play) { - s32 pad; + Actor* thisx = &this->actor; Vec3f sp60; s32 temp_s1; - Player* player; - - Vec3f sp4C; - Vec3f sp40; - Vec3f sp34; Math_StepToF(&this->unk234, 13.0f, 0.5f); - sp60.x = fabsf(this->unk234 * this->actor.velocity.x); - sp60.y = fabsf(this->unk234 * this->actor.velocity.y); - sp60.z = fabsf(this->unk234 * this->actor.velocity.z); + sp60.x = fabsf(this->unk234 * thisx->velocity.x); + sp60.y = fabsf(this->unk234 * thisx->velocity.y); + sp60.z = fabsf(this->unk234 * thisx->velocity.z); temp_s1 = 1; - temp_s1 &= Math_StepToF(&this->actor.world.pos.x, this->unk228.x, sp60.x); - temp_s1 &= Math_StepToF(&this->actor.world.pos.y, this->unk228.y, sp60.y); - temp_s1 &= Math_StepToF(&this->actor.world.pos.z, this->unk228.z, sp60.z); - Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, + temp_s1 &= Math_StepToF(&thisx->world.pos.x, this->unk228.x, sp60.x); + temp_s1 &= Math_StepToF(&thisx->world.pos.y, this->unk228.y, sp60.y); + temp_s1 &= Math_StepToF(&thisx->world.pos.z, this->unk228.z, sp60.z); + Actor_UpdateBgCheckInfo(play, thisx, 10.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->collider.tris.base.atFlags & AT_BOUNCED) { - player = GET_PLAYER(play); + Player* player = GET_PLAYER(play); + Vec3f sp4C; + Vec3f sp40; + Vec3f sp34; + sp34.x = -player->shieldMf.xz; sp34.y = -player->shieldMf.yz; sp34.z = -player->shieldMf.zz; func_8092E5A4(&sp4C, &sp34); - sp40 = this->actor.velocity; - func_80179F64(&sp40, &sp4C, &this->actor.velocity); - this->actor.speed = this->unk234 * 0.5f; - this->actor.world.rot.y = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + sp40 = thisx->velocity; + func_80179F64(&sp40, &sp4C, &thisx->velocity); + thisx->speed = this->unk234 * 0.5f; + thisx->world.rot.y = Math_Atan2S_XY(thisx->velocity.z, thisx->velocity.x); func_8092F7A8(this); - return; } - if (this->collider.tris.base.atFlags & AT_HIT) { - this->actor.speed = 0.0f; - this->actor.velocity.y = 0.0f; + else if (this->collider.tris.base.atFlags & AT_HIT) { + thisx->speed = 0.0f; + thisx->velocity.y = 0.0f; func_8092F7A8(this); - return; } - if (this->unk220 <= 0) { + else if (this->unk220 <= 0) { func_8092F7A8(this); - return; } - func_8092E510(this, play); - if (temp_s1 != 0) { - func_8092F5AC(this); + else { + func_8092E510(this, play); + if (temp_s1 != 0) { + func_8092F5AC(this); + } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092F3D8.s") -#endif void func_8092F5AC(EnHonotrap* this) { this->actionFunc = func_8092F5EC; From cc17013391a74ee32464a0d9cb830ea826c20c5b Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 11 Oct 2023 03:37:00 -0400 Subject: [PATCH 121/130] clean things up --- spec | 5 +- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 782 +++++++++--------- .../actors/ovl_En_Honotrap/z_en_honotrap.h | 36 +- 3 files changed, 416 insertions(+), 407 deletions(-) diff --git a/spec b/spec index 339a701c8..4f21bc20a 100644 --- a/spec +++ b/spec @@ -656,7 +656,7 @@ beginseg include "build/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.o" #ifdef NON_MATCHING include "build/src/overlays/gamestates/ovl_file_choose/ovl_file_choose_reloc.o" - #else + #else include "build/data/ovl_file_choose/ovl_file_choose.reloc.o" #endif endseg @@ -1340,8 +1340,7 @@ beginseg name "ovl_En_Honotrap" compress include "build/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.o" - include "build/data/ovl_En_Honotrap/ovl_En_Honotrap.data.o" - include "build/data/ovl_En_Honotrap/ovl_En_Honotrap.reloc.o" + include "build/src/overlays/actors/ovl_En_Honotrap/ovl_En_Honotrap_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 25cd1a782..bf64f7048 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -6,56 +6,68 @@ #include "z_en_honotrap.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" +#include "assets/objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) -#define THIS ((EnHonotrap*)thisx) +#define HONOTRAP_AT_ACTIVE (1 << 0) +#define HONOTRAP_AC_ACTIVE (1 << 1) +#define HONOTRAP_OC_ACTIVE (1 << 2) + +typedef enum { + /* 0 */ HONOTRAP_EYE_OPEN, + /* 1 */ HONOTRAP_EYE_HALF, + /* 2 */ HONOTRAP_EYE_CLOSE, + /* 3 */ HONOTRAP_EYE_SHUT +} EnHonotrapEyeState; void EnHonotrap_Init(Actor* thisx, PlayState* play); void EnHonotrap_Destroy(Actor* thisx, PlayState* play); void EnHonotrap_Update(Actor* thisx, PlayState* play); void EnHonotrap_Draw(Actor* thisx, PlayState* play); -void func_8092E5A4(Vec3f* arg0, Vec3f* arg1); -void func_8092E638(EnHonotrap* this, PlayState* play); -void func_8092E840(EnHonotrap* this, PlayState* play); -void func_8092E988(EnHonotrap* this, PlayState* play); -void func_8092EBC0(EnHonotrap* this); -void func_8092EBDC(EnHonotrap* this, PlayState* play); -void func_8092EC9C(EnHonotrap* this); -void func_8092ECF0(EnHonotrap* this, PlayState* play); -void func_8092EDC0(EnHonotrap* this); -void func_8092EDD8(EnHonotrap* this, PlayState* play); -void func_8092EE08(EnHonotrap* this); -void func_8092EE1C(EnHonotrap* this, PlayState* play); -void func_8092EE68(EnHonotrap* this); -void func_8092EE90(EnHonotrap* this, PlayState* play); -void func_8092EF3C(EnHonotrap* this); -void func_8092EF98(EnHonotrap* this, PlayState* play); -void func_8092F05C(EnHonotrap* this); -void func_8092F074(EnHonotrap* this, PlayState* play); -void func_8092F0A4(EnHonotrap* this); -void func_8092F0B8(EnHonotrap* this, PlayState* play); -void func_8092F0F8(EnHonotrap* this); -void func_8092F10C(EnHonotrap* this, PlayState* play); -void func_8092F1A0(EnHonotrap* this); -void func_8092F208(EnHonotrap* this, PlayState* play); -void func_8092F34C(EnHonotrap* this); -void func_8092F3D8(EnHonotrap* this, PlayState* play); -void func_8092F5AC(EnHonotrap* this); -void func_8092F5EC(EnHonotrap* this, PlayState* play); -void func_8092F7A8(EnHonotrap* this); -void func_8092F7BC(EnHonotrap* this, PlayState* play); -void func_8092F854(EnHonotrap* this); -void func_8092F878(EnHonotrap* this, PlayState* play); -void func_8092FE44(Actor* thisx, PlayState* play); -void func_8092FEFC(Actor* thisx, PlayState* play); -void func_80930030(Actor* thisx, PlayState* play); -void func_80930190(Actor* thisx, PlayState* play); +void EnHonotrap_GetNormal(Vec3f* normal, Vec3f* vec); +void EnHonotrap_InitEye(EnHonotrap* this, PlayState* play); +void EnHonotrap_InitFlame(EnHonotrap* this, PlayState* play); +void EnHonotrap_InitFlameGroup(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeIdle(EnHonotrap* this); +void EnHonotrap_EyeIdle(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeOpen(EnHonotrap* this); +void EnHonotrap_EyeOpen(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeAttack(EnHonotrap* this); +void EnHonotrap_EyeAttack(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeClose(EnHonotrap* this); +void EnHonotrap_EyeClose(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeIdle2(EnHonotrap* this); +void EnHonotrap_EyeIdle2(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeOpen2(EnHonotrap* this); +void EnHonotrap_EyeOpen2(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeAttack2(EnHonotrap* this); +void EnHonotrap_EyeAttack2(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupEyeClose2(EnHonotrap* this); +void EnHonotrap_EyeClose2(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlame(EnHonotrap* this); +void EnHonotrap_Flame(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlameDrop(EnHonotrap* this); +void EnHonotrap_FlameDrop(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlameMove(EnHonotrap* this); +void EnHonotrap_FlameMove(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlameChase(EnHonotrap* this); +void EnHonotrap_FlameChase(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlameVanish(EnHonotrap* this); +void EnHonotrap_FlameVanish(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlameGroup(EnHonotrap* this); +void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play); +void EnHonotrap_UpdateFlame(Actor* thisx, PlayState* play); +void EnHonotrap_UpdateFlameGroup(Actor* thisx, PlayState* play); +void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play); +void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play); -extern Gfx D_050085F0; +TexturePtr sSilverEyeTextures[4] = { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, + gEyeSwitchSilverClosedTex }; + +s32 sIsFirstInitEye = true; -#if 0 ActorInit En_Honotrap_InitVars = { ACTOR_EN_HONOTRAP, ACTORCAT_PROP, @@ -68,169 +80,186 @@ ActorInit En_Honotrap_InitVars = { (ActorFunc)EnHonotrap_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80930424[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093049C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - ARRAY_COUNT(sTrisElementsInit), D_80930424, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sTrisElementsInit), + sTrisElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809304AC = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x04 }, { 0x00100000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x04 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 10, 25, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809304D8 = { 0, 9, 23, 1 }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 9, 23, 1 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809304E0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif -extern Gfx* D_809303F0[4]; -extern s32 D_80930400; -extern ColliderTrisElementInit D_80930424[2]; -extern ColliderTrisInit D_8093049C; -extern ColliderCylinderInit D_809304AC; -extern CollisionCheckInfoInit D_809304D8; -extern InitChainEntry D_809304E0[]; - -void func_8092E510(EnHonotrap* this, PlayState* play) { +void EnHonotrap_FlameCollisionCheck(EnHonotrap* this, PlayState* play) { s32 pad[3]; Collider_UpdateCylinder(&this->actor, &this->collider.cyl); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.tris.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.tris.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.tris.base); - this->unk2C0 |= 1; - this->unk2C0 |= 2; - this->unk2C0 |= 4; + this->colChkFlags |= HONOTRAP_AT_ACTIVE; + this->colChkFlags |= HONOTRAP_AC_ACTIVE; + this->colChkFlags |= HONOTRAP_OC_ACTIVE; } -void func_8092E5A4(Vec3f* arg0, Vec3f* arg1) { - f32 temp_fv0; - f32 temp_fv1; +void EnHonotrap_GetNormal(Vec3f* normal, Vec3f* vec) { + f32 magnitude = Math3D_Vec3fMagnitude(vec); - temp_fv0 = Math3D_Vec3fMagnitude(arg1); - if (temp_fv0 < 0.001f) { - arg0->x = arg0->y = 0.0f; - arg0->z = 1.0f; - return; + if (magnitude < 0.001f) { + normal->x = normal->y = 0.0f; + normal->z = 1.0f; + } else { + normal->x = vec->x * (1.0f / magnitude); + normal->y = vec->y * (1.0f / magnitude); + normal->z = vec->z * (1.0f / magnitude); } - temp_fv1 = 1.0f / temp_fv0; - arg0->x = arg1->x * temp_fv1; - arg0->y = arg1->y * temp_fv1; - arg0->z = arg1->z * temp_fv1; } -// EnHonotrap_InitEye -void func_8092E638(EnHonotrap* this, PlayState* play) { +void EnHonotrap_InitEye(EnHonotrap* this, PlayState* play) { s32 i; s32 j; s32 k; f32 sin; f32 cos; - Vec3f sp70[3]; + Vec3f triangle[3]; Vec3f* vtx; sin = Math_SinS(this->actor.home.rot.y); cos = Math_CosS(this->actor.home.rot.y); Actor_SetScale(&this->actor, 0.1f); - if (D_80930400 != 0) { - D_80930400 = 0; - for (k = 0; k < 4; k++) { - D_809303F0[k] = Lib_SegmentedToVirtual(D_809303F0[k]); + if (sIsFirstInitEye) { + sIsFirstInitEye = false; + for (k = 0; k < ARRAY_COUNT(sSilverEyeTextures); k++) { + sSilverEyeTextures[k] = Lib_SegmentedToVirtual(sSilverEyeTextures[k]); } } Collider_InitTris(play, &this->collider.tris); - Collider_SetTris(play, &this->collider.tris, &this->actor, &D_8093049C, this->collider.elements); + Collider_SetTris(play, &this->collider.tris, &this->actor, &sTrisInit, this->collider.elements); for (i = 0; i < 2; i++) { - for (j = 0, vtx = sp70; j < 3; j++, vtx++) { - Vec3f* test = &D_8093049C.elements[i].dim.vtx[j]; + for (j = 0, vtx = triangle; j < 3; j++, vtx++) { + Vec3f* baseVtx = &sTrisInit.elements[i].dim.vtx[j]; - vtx->x = (test->z * sin) + (test->x * cos); - vtx->y = test->y; - vtx->z = (test->z * cos) - (test->x * sin); + vtx->x = (baseVtx->z * sin) + (baseVtx->x * cos); + vtx->y = baseVtx->y; + vtx->z = (baseVtx->z * cos) - (baseVtx->x * sin); Math_Vec3f_Sum(vtx, &this->actor.world.pos, vtx); } - Collider_SetTrisVertices(&this->collider.tris, i, &sp70[0], &sp70[1], &sp70[2]); + Collider_SetTrisVertices(&this->collider.tris, i, &triangle[0], &triangle[1], &triangle[2]); } Actor_SetFocus(&this->actor, 0.0f); - if (this->actor.params == 0) { - func_8092EBC0(this); - } else { - func_8092EE68(this); + if (this->actor.params == HONOTRAP_EYE) { + EnHonotrap_SetupEyeIdle(this); + } else { // HONOTRAP_EYE_MUTI_FLAME + EnHonotrap_SetupEyeIdle2(this); } } -// EnHonotrap_InitFlame -void func_8092E840(EnHonotrap* this, PlayState* play) { +void EnHonotrap_InitFlame(EnHonotrap* this, PlayState* play) { s32 pad[2]; s32 params; params = this->actor.params; Actor_SetScale(&this->actor, 0.0001f); Collider_InitCylinder(play, &this->collider.cyl); - Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &D_809304AC); + Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collider.cyl); this->actor.terminalVelocity = -1.0f; - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &D_809304D8); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.shape.shadowAlpha = 0x80; - this->unk228 = GET_PLAYER(play)->actor.world.pos; - this->unk228.y += 10.0f; - this->unk23A = Rand_ZeroOne() * 511.0f; + this->targetPos = GET_PLAYER(play)->actor.world.pos; + this->targetPos.y += 10.0f; + this->flameScroll = Rand_ZeroOne() * 511.0f; Actor_PlaySfx(&this->actor, NA_SE_EV_FLAME_IGNITION); - if (params == 2) { + if (params == HONOTRAP_FLAME_DROP) { this->actor.room = -1; this->collider.cyl.dim.radius = 12; this->collider.cyl.dim.height = 30; this->actor.shape.yOffset = -1000.0f; } - func_8092F0F8(this); + EnHonotrap_SetupFlame(this); } -void func_8092E988(EnHonotrap* this, PlayState* play) { - EnHonotrap23C* var_s2; - s32 var_s0; +void EnHonotrap_InitFlameGroup(EnHonotrap* this, PlayState* play) { + EnHonotrapFlameGroup* flameGroup; + s32 flameScroll; s32 i; Actor_SetScale(&this->actor, 0.0001f); Collider_InitCylinder(play, &this->collider.cyl); - Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &D_809304AC); - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &D_809304D8); + Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); - var_s0 = Rand_ZeroOne() * 511.0f; - var_s2 = &this->unk23C; - for (i = 0; i < 6; i++) { - var_s2->unkC[i].unk_10 = var_s0; - var_s0 += (s32)Rand_ZeroFloat(300.0f) + 0x64; - var_s0 &= 0x1FF; + flameScroll = Rand_ZeroOne() * 511.0f; + flameGroup = &this->flameGroup; + for (i = 0; i < ARRAY_COUNT(flameGroup->flameList); i++) { + flameGroup->flameList[i].flameScroll = flameScroll; + flameScroll += (s32)Rand_ZeroFloat(300.0f) + 100; + flameScroll &= 0x1FF; } Actor_PlaySfx(&this->actor, NA_SE_EV_FLAME_IGNITION); - func_8092F854(this); + EnHonotrap_SetupFlameGroup(this); } void EnHonotrap_Init(Actor* thisx, PlayState* play) { @@ -238,19 +267,19 @@ void EnHonotrap_Init(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; params = this->actor.params; - Actor_ProcessInitChain(&this->actor, D_809304E0); - if ((params == 0) || (params == 3)) { - func_8092E638(this, play); - } else if (params == 4) { - func_8092E988(this, play); - this->actor.update = func_8092FEFC; - this->actor.draw = func_80930190; + Actor_ProcessInitChain(&this->actor, sInitChain); + if ((params == HONOTRAP_EYE) || (params == HONOTRAP_EYE_MUTI_FLAME)) { + EnHonotrap_InitEye(this, play); + } else if (params == HONOTRAP_FLAME_GROUP) { + EnHonotrap_InitFlameGroup(this, play); + this->actor.update = EnHonotrap_UpdateFlameGroup; + this->actor.draw = EnHonotrap_DrawFlameGroup; this->actor.uncullZoneScale = 500.0f; this->actor.uncullZoneDownward = 500.0f; - } else { - func_8092E840(this, play); - this->actor.update = func_8092FE44; - this->actor.draw = func_80930030; + } else { // HONOTRAP_FLAME_MOVE, HONOTRAP_FLAME_DROP + EnHonotrap_InitFlame(this, play); + this->actor.update = EnHonotrap_UpdateFlame; + this->actor.draw = EnHonotrap_DrawFlame; } } @@ -259,188 +288,171 @@ void EnHonotrap_Destroy(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; params = this->actor.params; - if ((params == 0) || (params == 3)) { + if ((params == HONOTRAP_EYE) || (params == HONOTRAP_EYE_MUTI_FLAME)) { Collider_DestroyTris(play, &this->collider.tris); } else { Collider_DestroyCylinder(play, &this->collider.cyl); } } -void func_8092EBC0(EnHonotrap* this) { - this->actionFunc = func_8092EBDC; - this->unk222 = 3; +void EnHonotrap_SetupEyeIdle(EnHonotrap* this) { + this->actionFunc = EnHonotrap_EyeIdle; + this->eyeState = HONOTRAP_EYE_SHUT; } -void func_8092EBDC(EnHonotrap* this, PlayState* play) { - f32 temp_fv0; - s16 temp_v0; - +void EnHonotrap_EyeIdle(EnHonotrap* this, PlayState* play) { if (this->actor.child != NULL) { - this->unk220 = 0xC8; - return; - } - if ((this->unk220 <= 0) && (this->actor.xzDistToPlayer < 750.0f)) { - temp_fv0 = this->actor.playerHeightRel; - if ((temp_fv0 < 0.0f) && (temp_fv0 > -700.0f)) { - temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((temp_v0 >= -0x3FFF) && (temp_v0 < 0x4000)) { - func_8092EC9C(this); + this->timer = 200; + } else if ((this->timer <= 0) && (this->actor.xzDistToPlayer < 750.0f)) { + if ((this->actor.playerHeightRel < 0.0f) && (this->actor.playerHeightRel > -700.0f)) { + s16 angle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + if ((angle > -0x4000) && (angle < 0x4000)) { + EnHonotrap_SetupEyeOpen(this); } } } } -void func_8092EC9C(EnHonotrap* this) { - this->actionFunc = func_8092ECF0; - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, 0, 40); - this->unk220 = 30; +void EnHonotrap_SetupEyeOpen(EnHonotrap* this) { + this->actionFunc = EnHonotrap_EyeOpen; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); + this->timer = 30; Actor_PlaySfx(&this->actor, NA_SE_EV_RED_EYE); } -void func_8092ECF0(EnHonotrap* this, PlayState* play) { - this->unk222 -= 1; - if (this->unk222 <= 0) { - func_8092EDC0(this); +void EnHonotrap_EyeOpen(EnHonotrap* this, PlayState* play) { + this->eyeState--; + if (this->eyeState <= HONOTRAP_EYE_OPEN) { + EnHonotrap_SetupEyeAttack(this); Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, this->actor.home.pos.y - 10.0f, (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, - this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, 1); + this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, HONOTRAP_FLAME_MOVE); } } -void func_8092EDC0(EnHonotrap* this) { - this->actionFunc = func_8092EDD8; - this->unk222 = 0; +void EnHonotrap_SetupEyeAttack(EnHonotrap* this) { + this->actionFunc = EnHonotrap_EyeAttack; + this->eyeState = HONOTRAP_EYE_OPEN; } -void func_8092EDD8(EnHonotrap* this, PlayState* play) { - if (this->unk220 <= 0) { - func_8092EE08(this); +void EnHonotrap_EyeAttack(EnHonotrap* this, PlayState* play) { + if (this->timer <= 0) { + EnHonotrap_SetupEyeClose(this); } } -void func_8092EE08(EnHonotrap* this) { - this->actionFunc = func_8092EE1C; +void EnHonotrap_SetupEyeClose(EnHonotrap* this) { + this->actionFunc = EnHonotrap_EyeClose; } -void func_8092EE1C(EnHonotrap* this, PlayState* play) { - this->unk222 += 1; - if (this->unk222 >= 3) { - func_8092EBC0(this); - this->unk220 = 200; +void EnHonotrap_EyeClose(EnHonotrap* this, PlayState* play) { + this->eyeState++; + if (this->eyeState >= HONOTRAP_EYE_SHUT) { + EnHonotrap_SetupEyeIdle(this); + this->timer = 200; } } -void func_8092EE68(EnHonotrap* this) { - this->unk222 = 3; - this->unk220 = 0x50; +void EnHonotrap_SetupEyeIdle2(EnHonotrap* this) { + this->eyeState = HONOTRAP_EYE_SHUT; + this->timer = 80; this->unk224 = 0; - this->actionFunc = func_8092EE90; + this->actionFunc = EnHonotrap_EyeIdle2; } -void func_8092EE90(EnHonotrap* this, PlayState* play) { - f32 temp_fv0; - s16 temp_v0; +void EnHonotrap_EyeIdle2(EnHonotrap* this, PlayState* play) { + if ((this->timer <= 0) && (this->actor.xzDistToPlayer < 120.0f)) { + if ((this->actor.playerHeightRel < 0.0f) && (this->actor.playerHeightRel > -700.0f)) { + s16 angle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((this->unk220 <= 0) && (this->actor.xzDistToPlayer < 120.0f)) { - temp_fv0 = this->actor.playerHeightRel; - if ((temp_fv0 < 0.0f) && (temp_fv0 > -700.0f)) { - temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if ((temp_v0 >= -0x3FFF) && (temp_v0 < 0x4000)) { - func_8092EF3C(this); + if ((angle > -0x4000) && (angle < 0x4000)) { + EnHonotrap_SetupEyeOpen2(this); } } } } -void func_8092EF3C(EnHonotrap* this) { +void EnHonotrap_SetupEyeOpen2(EnHonotrap* this) { Actor_PlaySfx(&this->actor, NA_SE_EV_RED_EYE); - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, 0, 40); - this->unk220 = 0x28; - this->actionFunc = func_8092EF98; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 40); + this->timer = 40; + this->actionFunc = EnHonotrap_EyeOpen2; } -void func_8092EF98(EnHonotrap* this, PlayState* play) { +void EnHonotrap_EyeOpen2(EnHonotrap* this, PlayState* play) { s32 pad; - this->unk222 -= 1; - if (this->unk222 <= 0) { - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, - (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, - this->actor.home.pos.y, - (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, - this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, 4); - func_8092F05C(this); + this->eyeState--; + if (this->eyeState <= HONOTRAP_EYE_OPEN) { + Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, + (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, this->actor.home.pos.y, + (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, this->actor.home.rot.x, + this->actor.home.rot.y, this->actor.home.rot.z, HONOTRAP_FLAME_GROUP); + EnHonotrap_SetupEyeAttack2(this); } } -void func_8092F05C(EnHonotrap* this) { - this->actionFunc = func_8092F074; - this->unk222 = 0; +void EnHonotrap_SetupEyeAttack2(EnHonotrap* this) { + this->actionFunc = EnHonotrap_EyeAttack2; + this->eyeState = HONOTRAP_EYE_OPEN; } -void func_8092F074(EnHonotrap* this, PlayState* play) { - if (this->unk220 <= 0) { - func_8092F0A4(this); +void EnHonotrap_EyeAttack2(EnHonotrap* this, PlayState* play) { + if (this->timer <= 0) { + EnHonotrap_SetupEyeClose2(this); } } -void func_8092F0A4(EnHonotrap* this) { - this->actionFunc = func_8092F0B8; +void EnHonotrap_SetupEyeClose2(EnHonotrap* this) { + this->actionFunc = EnHonotrap_EyeClose2; } -void func_8092F0B8(EnHonotrap* this, PlayState* play) { - this->unk222 += 1; - if (this->unk222 >= 3) { - func_8092EE68(this); +void EnHonotrap_EyeClose2(EnHonotrap* this, PlayState* play) { + this->eyeState++; + if (this->eyeState >= HONOTRAP_EYE_SHUT) { + EnHonotrap_SetupEyeIdle2(this); } } -void func_8092F0F8(EnHonotrap* this) { - this->actionFunc = func_8092F10C; +void EnHonotrap_SetupFlame(EnHonotrap* this) { + this->actionFunc = EnHonotrap_Flame; } -void func_8092F10C(EnHonotrap* this, PlayState* play) { - f32 temp_fv0; - f32 var_fv0; - s32 temp_v0; +void EnHonotrap_Flame(EnHonotrap* this, PlayState* play) { + f32 targetScale = (this->actor.params == HONOTRAP_FLAME_MOVE) ? 0.004f : 0.0048f; + s32 targetReached = Math_StepToF(&this->actor.scale.x, targetScale, 0.0006f); - if (this->actor.params == 1) { - var_fv0 = 0.004f; - } else { - var_fv0 = 0.0048f; - } - temp_v0 = Math_StepToF(&this->actor.scale.x, var_fv0, 0.0006f); - temp_fv0 = this->actor.scale.x; - this->actor.scale.y = temp_fv0; - this->actor.scale.z = temp_fv0; - if (temp_v0 != 0) { - if (this->actor.params == 1) { - func_8092F34C(this); - return; + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + if (targetReached) { + if (this->actor.params == HONOTRAP_FLAME_MOVE) { + EnHonotrap_SetupFlameMove(this); + } else { // HONOTRAP_FLAME_DROP + EnHonotrap_SetupFlameDrop(this); } - func_8092F1A0(this); } } -void func_8092F1A0(EnHonotrap* this) { - this->unk220 = 0x28; +void EnHonotrap_SetupFlameDrop(EnHonotrap* this) { + this->timer = 40; this->actor.velocity.y = 1.0f; this->actor.velocity.x = 2.0f * Math_SinS(this->actor.world.rot.y); this->actor.velocity.z = 2.0f * Math_CosS(this->actor.world.rot.y); - this->actionFunc = func_8092F208; + this->actionFunc = EnHonotrap_FlameDrop; } -void func_8092F208(EnHonotrap* this, PlayState* play) { - if ((this->collider.tris.base.atFlags & AT_HIT) || (this->unk220 <= 0)) { +void EnHonotrap_FlameDrop(EnHonotrap* this, PlayState* play) { + if ((this->collider.tris.base.atFlags & AT_HIT) || (this->timer <= 0)) { if ((this->collider.tris.base.atFlags & AT_HIT) && !(this->collider.tris.base.atFlags & AT_BOUNCED)) { func_800B8D98(play, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 0.0f); } this->actor.velocity.z = 0.0f; this->actor.velocity.y = 0.0f; this->actor.velocity.x = 0.0f; - func_8092F7A8(this); + EnHonotrap_SetupFlameVanish(this); return; } if (this->actor.velocity.y > 0.0f) { @@ -448,94 +460,86 @@ void func_8092F208(EnHonotrap* this, PlayState* play) { this->actor.world.pos.z += this->actor.velocity.z; Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 12.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4); } - if (Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 1.0f, this->actor.velocity.y) == 0) { + if (!Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 1.0f, this->actor.velocity.y)) { this->actor.velocity.y += 1.0f; } else { this->actor.velocity.y = 0.0f; } - func_8092E510(this, play); + EnHonotrap_FlameCollisionCheck(this, play); } -void func_8092F34C(EnHonotrap* this) { - f32 temp_fv1; +void EnHonotrap_SetupFlameMove(EnHonotrap* this) { + f32 distInverse; - this->actionFunc = func_8092F3D8; - temp_fv1 = 1.0f / (Actor_WorldDistXYZToPoint(&this->actor, &this->unk228) + 1.0f); - this->actor.velocity.x = (this->unk228.x - this->actor.world.pos.x) * temp_fv1; - this->actor.velocity.y = (this->unk228.y - this->actor.world.pos.y) * temp_fv1; - this->actor.velocity.z = (this->unk228.z - this->actor.world.pos.z) * temp_fv1; - this->unk220 = 160; - this->unk234 = 0.0f; + this->actionFunc = EnHonotrap_FlameMove; + distInverse = 1.0f / (Actor_WorldDistXYZToPoint(&this->actor, &this->targetPos) + 1.0f); + this->actor.velocity.x = (this->targetPos.x - this->actor.world.pos.x) * distInverse; + this->actor.velocity.y = (this->targetPos.y - this->actor.world.pos.y) * distInverse; + this->actor.velocity.z = (this->targetPos.z - this->actor.world.pos.z) * distInverse; + this->speedMod = 0.0f; + this->timer = 160; } -void func_8092F3D8(EnHonotrap* this, PlayState* play) { +void EnHonotrap_FlameMove(EnHonotrap* this, PlayState* play) { Actor* thisx = &this->actor; - Vec3f sp60; + Vec3f speed; + s32 cond; - s32 temp_s1; - - Math_StepToF(&this->unk234, 13.0f, 0.5f); - sp60.x = fabsf(this->unk234 * thisx->velocity.x); - sp60.y = fabsf(this->unk234 * thisx->velocity.y); - sp60.z = fabsf(this->unk234 * thisx->velocity.z); - temp_s1 = 1; - temp_s1 &= Math_StepToF(&thisx->world.pos.x, this->unk228.x, sp60.x); - temp_s1 &= Math_StepToF(&thisx->world.pos.y, this->unk228.y, sp60.y); - temp_s1 &= Math_StepToF(&thisx->world.pos.z, this->unk228.z, sp60.z); + Math_StepToF(&this->speedMod, 13.0f, 0.5f); + speed.x = fabsf(this->speedMod * thisx->velocity.x); + speed.y = fabsf(this->speedMod * thisx->velocity.y); + speed.z = fabsf(this->speedMod * thisx->velocity.z); + cond = true; + cond &= Math_StepToF(&thisx->world.pos.x, this->targetPos.x, speed.x); + cond &= Math_StepToF(&thisx->world.pos.y, this->targetPos.y, speed.y); + cond &= Math_StepToF(&thisx->world.pos.z, this->targetPos.z, speed.z); Actor_UpdateBgCheckInfo(play, thisx, 10.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); if (this->collider.tris.base.atFlags & AT_BOUNCED) { Player* player = GET_PLAYER(play); - Vec3f sp4C; - Vec3f sp40; - Vec3f sp34; + Vec3f shieldNorm; + Vec3f tempVel; + Vec3f shieldVec; - sp34.x = -player->shieldMf.xz; - sp34.y = -player->shieldMf.yz; - sp34.z = -player->shieldMf.zz; - func_8092E5A4(&sp4C, &sp34); - sp40 = thisx->velocity; - func_80179F64(&sp40, &sp4C, &thisx->velocity); - thisx->speed = this->unk234 * 0.5f; + shieldVec.x = -player->shieldMf.xz; + shieldVec.y = -player->shieldMf.yz; + shieldVec.z = -player->shieldMf.zz; + EnHonotrap_GetNormal(&shieldNorm, &shieldVec); + tempVel = thisx->velocity; + func_80179F64(&tempVel, &shieldNorm, &thisx->velocity); + thisx->speed = this->speedMod * 0.5f; thisx->world.rot.y = Math_Atan2S_XY(thisx->velocity.z, thisx->velocity.x); - func_8092F7A8(this); - } - else if (this->collider.tris.base.atFlags & AT_HIT) { + EnHonotrap_SetupFlameVanish(this); + } else if (this->collider.tris.base.atFlags & AT_HIT) { thisx->speed = 0.0f; thisx->velocity.y = 0.0f; - func_8092F7A8(this); - } - else if (this->unk220 <= 0) { - func_8092F7A8(this); - } - else { - func_8092E510(this, play); - if (temp_s1 != 0) { - func_8092F5AC(this); + EnHonotrap_SetupFlameVanish(this); + } else if (this->timer <= 0) { + EnHonotrap_SetupFlameVanish(this); + } else { + EnHonotrap_FlameCollisionCheck(this, play); + if (cond != 0) { + EnHonotrap_SetupFlameChase(this); } } } -void func_8092F5AC(EnHonotrap* this) { - this->actionFunc = func_8092F5EC; +void EnHonotrap_SetupFlameChase(EnHonotrap* this) { + this->actionFunc = EnHonotrap_FlameChase; this->actor.speed = 0.0f; this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - this->unk220 = 100; + this->timer = 100; this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; } -void func_8092F5EC(EnHonotrap* this, PlayState* play) { +void EnHonotrap_FlameChase(EnHonotrap* this, PlayState* play) { s32 pad; Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x300); Math_StepToF(&this->actor.speed, 3.0f, 0.1f); - if (-this->actor.playerHeightRel < 10.0f) { - this->actor.gravity = 0.08f; - } else { - this->actor.gravity = -0.08f; - } + this->actor.gravity = (-this->actor.playerHeightRel < 10.0f) ? 0.08f : -0.08f; Actor_UpdateVelocityWithGravity(&this->actor); if (this->actor.velocity.y > 1.0f) { this->actor.velocity.y = 1.0f; @@ -548,113 +552,112 @@ void func_8092F5EC(EnHonotrap* this, PlayState* play) { if (this->collider.tris.base.atFlags & AT_BOUNCED) { Player* player = GET_PLAYER(play); - Vec3s sp30; + Vec3s shieldRot; - Matrix_MtxFToYXZRot(&player->shieldMf, &sp30, 0); - this->actor.world.rot.y = ((sp30.y * 2) - this->actor.world.rot.y) + 0x8000; - func_8092F7A8(this); + Matrix_MtxFToYXZRot(&player->shieldMf, &shieldRot, 0); + this->actor.world.rot.y = ((shieldRot.y * 2) - this->actor.world.rot.y) + 0x8000; + EnHonotrap_SetupFlameVanish(this); } else if (this->collider.tris.base.atFlags & AT_HIT) { this->actor.speed *= 0.1f; this->actor.velocity.y *= 0.1f; - func_8092F7A8(this); - } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk220 <= 0)) { - func_8092F7A8(this); + EnHonotrap_SetupFlameVanish(this); + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->timer <= 0)) { + EnHonotrap_SetupFlameVanish(this); } else { - func_8092E510(this, play); + EnHonotrap_FlameCollisionCheck(this, play); } } -void func_8092F7A8(EnHonotrap* this) { - this->actionFunc = func_8092F7BC; +void EnHonotrap_SetupFlameVanish(EnHonotrap* this) { + this->actionFunc = EnHonotrap_FlameVanish; } -void func_8092F7BC(EnHonotrap* this, PlayState* play) { - f32 temp_fv0; - s32 sp28 = Math_StepToF(&this->actor.scale.x, 0.0001f, 0.00015f); - temp_fv0 = this->actor.scale.x; - this->actor.scale.y = temp_fv0; - this->actor.scale.z = temp_fv0; +void EnHonotrap_FlameVanish(EnHonotrap* this, PlayState* play) { + s32 pad; + s32 targetReached = Math_StepToF(&this->actor.scale.x, 0.0001f, 0.00015f); + + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 0.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); - if (sp28 != 0) { + if (targetReached) { Actor_Kill(&this->actor); } } -void func_8092F854(EnHonotrap* this) { - this->actionFunc = func_8092F878; - this->unk220 = 0x50; - this->unk23C.unk8 = 0.0f; +void EnHonotrap_SetupFlameGroup(EnHonotrap* this) { + this->actionFunc = EnHonotrap_FlameGroup; + this->timer = 80; + this->flameGroup.unk8 = 0.0f; } -void func_8092F878(EnHonotrap* this, PlayState* play) { - s32 var_v0; - EnHonotrap23C* sp98; +void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { + s32 i; + EnHonotrapFlameGroup* flameGroup; f32 var_fs0; f32 temp_fs0; f32 temp_fs1; f32 sp88; f32 sp84; f32 sp80; - s32 sp7C; + s32 flameScrollDisplacement; s32 sp78; f32 var_fs0_2; Vec3f sp68; - EnHonotrapArr* var_s0; + EnHonotrapFlameElement* flameElem; - sp98 = &this->unk23C; + flameGroup = &this->flameGroup; sp78 = 0; sp80 = fabsf(Math_CosS(Camera_GetCamDirPitch(play->cameraPtrs[play->activeCamId]))); - sp7C = (s32)(sp80 * -10.5f) - 10; - Math_StepToF(&sp98->unk0, 1.0f, 0.05f); - if (this->unk220 <= 40) { - sp78 = Math_StepToF(&sp98->unk4, 1.0f, 0.05f); + flameScrollDisplacement = (s32)(sp80 * -10.5f) - 10; + Math_StepToF(&flameGroup->unk0, 1.0f, 0.05f); + if (this->timer <= 40) { + sp78 = Math_StepToF(&flameGroup->unk4, 1.0f, 0.05f); } else if (this->actor.parent == NULL) { - this->unk220 = 40; + this->timer = 40; } - for (var_v0 = 0; var_v0 < 6; var_v0++) { - sp98->unkC[var_v0].unk12 = 0; + for (i = 0; i < ARRAY_COUNT(flameGroup->flameList); i++) { + flameGroup->flameList[i].isDrawn = false; } sp88 = Math_SinS(this->actor.shape.rot.y) * 120.0f; sp84 = Math_CosS(this->actor.shape.rot.y) * 120.0f; - sp98->unk8 += 0.050f * (1.0f - sp98->unk4); + flameGroup->unk8 += 0.050f * (1.0f - flameGroup->unk4); - if (sp98->unk8 > 0.16666667f) { - sp98->unk8 -= 0.16666667f; + if (flameGroup->unk8 > 1.0f / 6) { + flameGroup->unk8 -= 1.0f / 6; } - var_fs0 = sp98->unk4 + sp98->unk8; + var_fs0 = flameGroup->unk4 + flameGroup->unk8; - for (var_v0 = 0; var_v0 < 6 && (var_fs0 <= sp98->unk0); var_v0++) { - var_s0 = &sp98->unkC[var_v0]; - var_s0->unk12 = 1; + for (i = 0; i < ARRAY_COUNT(flameGroup->flameList) && (var_fs0 <= flameGroup->unk0); i++) { + flameElem = &flameGroup->flameList[i]; + flameElem->isDrawn = true; - var_s0->unk0.x = (f32)((sp88 * var_fs0) + this->actor.world.pos.x); - var_s0->unk0.y = (f32)this->actor.world.pos.y; - var_s0->unk0.z = (f32)((sp84 * var_fs0) + this->actor.world.pos.z); + flameElem->pos.x = (sp88 * var_fs0) + this->actor.world.pos.x; + flameElem->pos.y = this->actor.world.pos.y; + flameElem->pos.z = (sp84 * var_fs0) + this->actor.world.pos.z; - var_s0->unkC = Math_SinS((s16)(s32)(var_fs0 * 25486.223f)) * 1.6f; - if (var_s0->unkC > 1.0f) { - var_s0->unkC = 1.0f; - } else if (var_s0->unkC < 0.0f) { - var_s0->unkC = 0.0f; + flameElem->unkC = Math_SinS((s16)(s32)(var_fs0 * 25486.223f)) * 1.6f; + if (flameElem->unkC > 1.0f) { + flameElem->unkC = 1.0f; + } else if (flameElem->unkC < 0.0f) { + flameElem->unkC = 0.0f; } - var_fs0 += 0.16666667f; - var_s0->unkC = (f32)(var_s0->unkC * (0.006f * (((1.0f - sp98->unk4) * 0.8f) + 0.2f))); - var_s0->unk_10 = (s16)(var_s0->unk_10 + sp7C); - var_s0->unk_10 = (s16)(var_s0->unk_10 & 0x1FF); + var_fs0 += 1.0f / 6; + flameElem->unkC *= (0.006f * (((1.0f - flameGroup->unk4) * 0.8f) + 0.2f)); + flameElem->flameScroll += flameScrollDisplacement; + flameElem->flameScroll &= 0x1FF; } - if ((sp78 != 0) || (this->unk220 <= 0)) { + if ((sp78 != 0) || (this->timer <= 0)) { Actor_Kill(&this->actor); return; } - temp_fs0 = sp98->unk0 * 120.0f; - temp_fs1 = sp98->unk4 * 120.0f; + temp_fs0 = flameGroup->unk0 * 120.0f; + temp_fs1 = flameGroup->unk4 * 120.0f; Actor_OffsetOfPointInActorCoords(&this->actor, &sp68, &GET_PLAYER(play)->actor.world.pos); if (sp68.z < temp_fs1) { @@ -667,7 +670,7 @@ void func_8092F878(EnHonotrap* this, PlayState* play) { if (var_fs0_2 > 1.0f) { var_fs0_2 = 1.0f; } - sp80 *= ((1.0f - sp98->unk4) * 0.8f) + 0.2f; + sp80 *= ((1.0f - flameGroup->unk4) * 0.8f) + 0.2f; if (sp80 > 0.2f) { this->collider.cyl.dim.pos.x = (s16)(s32)((Math_SinS(this->actor.shape.rot.y) * sp68.z) + this->actor.world.pos.x); @@ -682,60 +685,57 @@ void func_8092F878(EnHonotrap* this, PlayState* play) { } } -extern Vec3f D_809304EC; -extern Vec3f D_809304F8; - void EnHonotrap_Update(Actor* thisx, PlayState* play) { + static Vec3f velocity = { 0, 0, 0 }; + static Vec3f accel = { 0, 0.1, 0 }; EnHonotrap* this = (EnHonotrap*)thisx; - if (this->unk220 > 0) { - this->unk220 -= 1; + if (this->timer > 0) { + this->timer--; } if ((this->actor.child != NULL) && (this->actor.child->update == NULL)) { this->actor.child = NULL; } this->actionFunc(this, play); if (this->collider.tris.base.acFlags & AC_HIT) { - EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &D_809304EC, &D_809304F8, 15, 8); + EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &velocity, &accel, 15, 8); Actor_Kill(&this->actor); - return; - } - if (this->unk222 < 3) { + } else if (this->eyeState < HONOTRAP_EYE_SHUT) { this->collider.tris.base.acFlags &= ~AC_HIT; CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.tris.base); } } -void func_8092FE44(Actor* thisx, PlayState* play) { +void EnHonotrap_UpdateFlame(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; - if (this->unk220 > 0) { - this->unk220--; + if (this->timer > 0) { + this->timer--; } - this->unk2C0 = 0; - this->unk238 += 0x640; - if (this->actor.params != 4) { - this->actor.shape.yOffset = Math_SinS(this->unk238) * 1000.0f + 600.0f; + this->colChkFlags = 0; + this->bobPhase += 0x640; + if (this->actor.params != HONOTRAP_FLAME_GROUP) { + this->actor.shape.yOffset = Math_SinS(this->bobPhase) * 1000.0f + 600.0f; } Actor_SetFocus(&this->actor, 5.0f); Actor_PlaySfx(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); this->actionFunc(this, play); - this->unk23A -= 0x14; - this->unk23A &= 0x1FF; + this->flameScroll -= 20; + this->flameScroll &= 0x1FF; } -void func_8092FEFC(Actor* thisx, PlayState* play) { +void EnHonotrap_UpdateFlameGroup(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; - Actor* temp_v0; + Actor* parent; - temp_v0 = this->actor.parent; - if ((temp_v0 != NULL) && (temp_v0->update == NULL)) { + parent = this->actor.parent; + if ((parent != NULL) && (parent->update == NULL)) { this->actor.parent = NULL; } - if (this->unk220 > 0) { - this->unk220--; + if (this->timer > 0) { + this->timer--; } - this->unk238 += 0x640; + this->bobPhase += 0x640; Actor_PlaySfx(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); this->actionFunc(this, play); } @@ -745,20 +745,20 @@ void EnHonotrap_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, D_809303F0[this->unk222]); + gSPSegment(POLY_OPA_DISP++, 0x08, sSilverEyeTextures[this->eyeState]); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, &D_050085F0); + gSPDisplayList(POLY_OPA_DISP++, &gEyeSwitchSilverDL); CLOSE_DISPS(play->state.gfxCtx); } -void func_80930030(Actor* thisx, PlayState* play) { +void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play) { s32 pad; EnHonotrap* this = (EnHonotrap*)thisx; OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL25_Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->unk23A, 32, 128)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->flameScroll, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Matrix_RotateYS(Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]) + 0x8000, MTXMODE_APPLY); @@ -767,32 +767,34 @@ void func_80930030(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80930190(Actor* thisx, PlayState* play) { +void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { s32 pad; EnHonotrap* this; - EnHonotrapArr* temp_s0; - EnHonotrap23C* var_s3; - s32 i; // s4 + EnHonotrapFlameElement* flameElem; + EnHonotrapFlameGroup* flameGroup; + s32 i; s32 pad2; - Vec3s spB8; + Vec3s camDir; OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL25_Xlu(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Camera_GetCamDir(&spB8, play->cameraPtrs[play->activeCamId]); - spB8.y += 0x8000; + Camera_GetCamDir(&camDir, play->cameraPtrs[play->activeCamId]); + camDir.y += 0x8000; this = ((EnHonotrap*)thisx); - var_s3 = &this->unk23C; - for (i = 0; i < 6; i++) { - temp_s0 = &var_s3->unkC[i]; - if (temp_s0->unk12 != 0) { - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); - Matrix_SetTranslateRotateYXZ(temp_s0->unk0.x, temp_s0->unk0.y - (4000.0f * temp_s0->unkC), temp_s0->unk0.z, - &spB8); - Matrix_Scale(((fabsf(Math_SinS((s16)(spB8.y - thisx->shape.rot.y) >> 1)) * 0.2f) + 1.7f) * temp_s0->unkC, - temp_s0->unkC, 1.0f, MTXMODE_APPLY); + flameGroup = &this->flameGroup; + for (i = 0; i < ARRAY_COUNT(flameGroup->flameList); i++) { + flameElem = &flameGroup->flameList[i]; + if (flameElem->isDrawn) { + gSPSegment( + POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, flameElem->flameScroll, 0x20, 0x80)); + Matrix_SetTranslateRotateYXZ(flameElem->pos.x, flameElem->pos.y - (4000.0f * flameElem->unkC), + flameElem->pos.z, &camDir); + Matrix_Scale(((fabsf(Math_SinS((s16)(camDir.y - thisx->shape.rot.y) >> 1)) * 0.2f) + 1.7f) * + flameElem->unkC, + flameElem->unkC, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index d101d9506..7691ed643 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -16,32 +16,40 @@ typedef union { } EnHonotrapCollider; // size = 0xD8 typedef struct { - /* 0x00 */ Vec3f unk0; + /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unkC; - /* 0x10 */ s16 unk_10; - /* 0x12 */ u8 unk12; -} EnHonotrapArr; //size 0x14 + /* 0x10 */ s16 flameScroll; + /* 0x12 */ u8 isDrawn; +} EnHonotrapFlameElement; //size 0x14 typedef struct { f32 unk0; f32 unk4; f32 unk8; - EnHonotrapArr unkC[6]; -} EnHonotrap23C; + EnHonotrapFlameElement flameList[6]; +} EnHonotrapFlameGroup; typedef struct EnHonotrap { /* 0x000 */ Actor actor; /* 0x144 */ EnHonotrapActionFunc actionFunc; /* 0x148 */ EnHonotrapCollider collider; - /* 0x220 */ s16 unk220; - /* 0x222 */ s16 unk222; + /* 0x220 */ s16 timer; + /* 0x222 */ s16 eyeState; /* 0x224 */ s16 unk224; - /* 0x228 */ Vec3f unk228; - /* 0x234 */ f32 unk234; - /* 0x238 */ s16 unk238; - /* 0x23A */ s16 unk23A; - /* 0x23C */ EnHonotrap23C unk23C; - /* 0x2C0 */ u8 unk2C0; + /* 0x228 */ Vec3f targetPos; + /* 0x234 */ f32 speedMod; + /* 0x238 */ s16 bobPhase; + /* 0x23A */ s16 flameScroll; + /* 0x23C */ EnHonotrapFlameGroup flameGroup; + /* 0x2C0 */ u8 colChkFlags; } EnHonotrap; // size = 0x2C4 +typedef enum { + HONOTRAP_EYE, + HONOTRAP_FLAME_MOVE, + HONOTRAP_FLAME_DROP, + HONOTRAP_EYE_MUTI_FLAME, + HONOTRAP_FLAME_GROUP +} EnHonotrapType; + #endif // Z_EN_HONOTRAP_H From b148f50c36774ae687296ec031a1be061fdc7f99 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 12 Oct 2023 15:37:12 -0400 Subject: [PATCH 122/130] implement most suggestions --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 73 +++++++++---------- .../actors/ovl_En_Honotrap/z_en_honotrap.h | 28 +++---- 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index bf64f7048..8d8f5540d 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -18,7 +18,8 @@ typedef enum { /* 0 */ HONOTRAP_EYE_OPEN, /* 1 */ HONOTRAP_EYE_HALF, /* 2 */ HONOTRAP_EYE_CLOSE, - /* 3 */ HONOTRAP_EYE_SHUT + /* 3 */ HONOTRAP_EYE_SHUT, + /* 4 */ HONOTRAP_EYE_MAX } EnHonotrapEyeState; void EnHonotrap_Init(Actor* thisx, PlayState* play); @@ -63,10 +64,10 @@ void EnHonotrap_UpdateFlameGroup(Actor* thisx, PlayState* play); void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play); void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play); -TexturePtr sSilverEyeTextures[4] = { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, - gEyeSwitchSilverClosedTex }; +static TexturePtr sSilverEyeTextures[HONOTRAP_EYE_MAX] = { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, + gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }; -s32 sIsFirstInitEye = true; +static s32 sIsFirstInitEye = true; ActorInit En_Honotrap_InitVars = { ACTOR_EN_HONOTRAP, @@ -207,18 +208,17 @@ void EnHonotrap_InitEye(EnHonotrap* this, PlayState* play) { Collider_SetTrisVertices(&this->collider.tris, i, &triangle[0], &triangle[1], &triangle[2]); } Actor_SetFocus(&this->actor, 0.0f); - if (this->actor.params == HONOTRAP_EYE) { + if (this->actor.params == HONOTRAP_TYPE_EYE) { EnHonotrap_SetupEyeIdle(this); - } else { // HONOTRAP_EYE_MUTI_FLAME + } else { // HONOTRAP_TYPE_EYE_MUTI_FLAME EnHonotrap_SetupEyeIdle2(this); } } void EnHonotrap_InitFlame(EnHonotrap* this, PlayState* play) { s32 pad[2]; - s32 params; + s32 params = this->actor.params; - params = this->actor.params; Actor_SetScale(&this->actor, 0.0001f); Collider_InitCylinder(play, &this->collider.cyl); Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &sCylinderInit); @@ -226,12 +226,12 @@ void EnHonotrap_InitFlame(EnHonotrap* this, PlayState* play) { this->actor.terminalVelocity = -1.0f; CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - this->actor.shape.shadowAlpha = 0x80; + this->actor.shape.shadowAlpha = 128; this->targetPos = GET_PLAYER(play)->actor.world.pos; this->targetPos.y += 10.0f; this->flameScroll = Rand_ZeroOne() * 511.0f; Actor_PlaySfx(&this->actor, NA_SE_EV_FLAME_IGNITION); - if (params == HONOTRAP_FLAME_DROP) { + if (params == HONOTRAP_TYPE_FLAME_DROP) { this->actor.room = -1; this->collider.cyl.dim.radius = 12; this->collider.cyl.dim.height = 30; @@ -268,15 +268,15 @@ void EnHonotrap_Init(Actor* thisx, PlayState* play) { params = this->actor.params; Actor_ProcessInitChain(&this->actor, sInitChain); - if ((params == HONOTRAP_EYE) || (params == HONOTRAP_EYE_MUTI_FLAME)) { + if ((params == HONOTRAP_TYPE_EYE) || (params == HONOTRAP_TYPE_EYE_MUTI_FLAME)) { EnHonotrap_InitEye(this, play); - } else if (params == HONOTRAP_FLAME_GROUP) { + } else if (params == HONOTRAP_TYPE_FLAME_GROUP) { EnHonotrap_InitFlameGroup(this, play); this->actor.update = EnHonotrap_UpdateFlameGroup; this->actor.draw = EnHonotrap_DrawFlameGroup; this->actor.uncullZoneScale = 500.0f; this->actor.uncullZoneDownward = 500.0f; - } else { // HONOTRAP_FLAME_MOVE, HONOTRAP_FLAME_DROP + } else { // HONOTRAP_TYPE_FLAME_MOVE, HONOTRAP_TYPE_FLAME_DROP EnHonotrap_InitFlame(this, play); this->actor.update = EnHonotrap_UpdateFlame; this->actor.draw = EnHonotrap_DrawFlame; @@ -288,7 +288,7 @@ void EnHonotrap_Destroy(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; params = this->actor.params; - if ((params == HONOTRAP_EYE) || (params == HONOTRAP_EYE_MUTI_FLAME)) { + if ((params == HONOTRAP_TYPE_EYE) || (params == HONOTRAP_TYPE_EYE_MUTI_FLAME)) { Collider_DestroyTris(play, &this->collider.tris); } else { Collider_DestroyCylinder(play, &this->collider.cyl); @@ -325,11 +325,11 @@ void EnHonotrap_EyeOpen(EnHonotrap* this, PlayState* play) { this->eyeState--; if (this->eyeState <= HONOTRAP_EYE_OPEN) { EnHonotrap_SetupEyeAttack(this); - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, - (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, - this->actor.home.pos.y - 10.0f, - (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, - this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, HONOTRAP_FLAME_MOVE); + Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, + (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, this->actor.home.pos.y - 10.0f, + (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, this->actor.home.rot.x, + this->actor.home.rot.y, this->actor.home.rot.z, HONOTRAP_TYPE_FLAME_MOVE); } } @@ -391,7 +391,7 @@ void EnHonotrap_EyeOpen2(EnHonotrap* this, PlayState* play) { &play->actorCtx, &this->actor, play, ACTOR_EN_HONOTRAP, (Math_SinS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.x, this->actor.home.pos.y, (Math_CosS(this->actor.shape.rot.y) * 12.0f) + this->actor.home.pos.z, this->actor.home.rot.x, - this->actor.home.rot.y, this->actor.home.rot.z, HONOTRAP_FLAME_GROUP); + this->actor.home.rot.y, this->actor.home.rot.z, HONOTRAP_TYPE_FLAME_GROUP); EnHonotrap_SetupEyeAttack2(this); } } @@ -423,14 +423,14 @@ void EnHonotrap_SetupFlame(EnHonotrap* this) { } void EnHonotrap_Flame(EnHonotrap* this, PlayState* play) { - f32 targetScale = (this->actor.params == HONOTRAP_FLAME_MOVE) ? 0.004f : 0.0048f; + f32 targetScale = (this->actor.params == HONOTRAP_TYPE_FLAME_MOVE) ? 0.004f : 0.0048f; s32 targetReached = Math_StepToF(&this->actor.scale.x, targetScale, 0.0006f); this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; if (targetReached) { - if (this->actor.params == HONOTRAP_FLAME_MOVE) { + if (this->actor.params == HONOTRAP_TYPE_FLAME_MOVE) { EnHonotrap_SetupFlameMove(this); - } else { // HONOTRAP_FLAME_DROP + } else { // HONOTRAP_TYPE_FLAME_DROP EnHonotrap_SetupFlameDrop(this); } } @@ -594,7 +594,7 @@ void EnHonotrap_SetupFlameGroup(EnHonotrap* this) { void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { s32 i; - EnHonotrapFlameGroup* flameGroup; + EnHonotrapFlameGroup* flameGroup = &this->flameGroup; f32 var_fs0; f32 temp_fs0; f32 temp_fs1; @@ -602,14 +602,12 @@ void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { f32 sp84; f32 sp80; s32 flameScrollDisplacement; - s32 sp78; + s32 sp78 = false; f32 var_fs0_2; Vec3f sp68; EnHonotrapFlameElement* flameElem; - flameGroup = &this->flameGroup; - sp78 = 0; - sp80 = fabsf(Math_CosS(Camera_GetCamDirPitch(play->cameraPtrs[play->activeCamId]))); + sp80 = fabsf(Math_CosS(Camera_GetCamDirPitch(GET_ACTIVE_CAM(play)))); flameScrollDisplacement = (s32)(sp80 * -10.5f) - 10; Math_StepToF(&flameGroup->unk0, 1.0f, 0.05f); if (this->timer <= 40) { @@ -652,7 +650,7 @@ void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { flameElem->flameScroll &= 0x1FF; } - if ((sp78 != 0) || (this->timer <= 0)) { + if (sp78 || (this->timer <= 0)) { Actor_Kill(&this->actor); return; } @@ -686,8 +684,8 @@ void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { } void EnHonotrap_Update(Actor* thisx, PlayState* play) { - static Vec3f velocity = { 0, 0, 0 }; - static Vec3f accel = { 0, 0.1, 0 }; + static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f accel = { 0.0f, 0.1f, 0.0f }; EnHonotrap* this = (EnHonotrap*)thisx; if (this->timer > 0) { @@ -700,7 +698,9 @@ void EnHonotrap_Update(Actor* thisx, PlayState* play) { if (this->collider.tris.base.acFlags & AC_HIT) { EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &velocity, &accel, 15, 8); Actor_Kill(&this->actor); - } else if (this->eyeState < HONOTRAP_EYE_SHUT) { + return; + } + if (this->eyeState < HONOTRAP_EYE_SHUT) { this->collider.tris.base.acFlags &= ~AC_HIT; CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.tris.base); } @@ -714,7 +714,7 @@ void EnHonotrap_UpdateFlame(Actor* thisx, PlayState* play) { } this->colChkFlags = 0; this->bobPhase += 0x640; - if (this->actor.params != HONOTRAP_FLAME_GROUP) { + if (this->actor.params != HONOTRAP_TYPE_FLAME_GROUP) { this->actor.shape.yOffset = Math_SinS(this->bobPhase) * 1000.0f + 600.0f; } Actor_SetFocus(&this->actor, 5.0f); @@ -726,9 +726,8 @@ void EnHonotrap_UpdateFlame(Actor* thisx, PlayState* play) { void EnHonotrap_UpdateFlameGroup(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; - Actor* parent; + Actor* parent = this->actor.parent; - parent = this->actor.parent; if ((parent != NULL) && (parent->update == NULL)) { this->actor.parent = NULL; } @@ -761,7 +760,7 @@ void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play) { Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->flameScroll, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_RotateYS(Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]) + 0x8000, MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); CLOSE_DISPS(play->state.gfxCtx); @@ -780,7 +779,7 @@ void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Camera_GetCamDir(&camDir, play->cameraPtrs[play->activeCamId]); + Camera_GetCamDir(&camDir, GET_ACTIVE_CAM(play)); camDir.y += 0x8000; this = ((EnHonotrap*)thisx); flameGroup = &this->flameGroup; diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index 7691ed643..a954ea6d8 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -9,10 +9,10 @@ typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, PlayState*); typedef union { struct { - ColliderTris tris; - ColliderTrisElement elements[2]; + /* 0x00 */ ColliderTris tris; + /* 0x20 */ ColliderTrisElement elements[2]; }; - ColliderCylinder cyl; + /* 0x00 */ ColliderCylinder cyl; } EnHonotrapCollider; // size = 0xD8 typedef struct { @@ -20,14 +20,14 @@ typedef struct { /* 0x0C */ f32 unkC; /* 0x10 */ s16 flameScroll; /* 0x12 */ u8 isDrawn; -} EnHonotrapFlameElement; //size 0x14 +} EnHonotrapFlameElement; // size = 0x14 typedef struct { - f32 unk0; - f32 unk4; - f32 unk8; - EnHonotrapFlameElement flameList[6]; -} EnHonotrapFlameGroup; + /* 0x00 */ f32 unk0; + /* 0x04 */ f32 unk4; + /* 0x08 */ f32 unk8; + /* 0x0C */ EnHonotrapFlameElement flameList[6]; +} EnHonotrapFlameGroup; // size = 0x84; typedef struct EnHonotrap { /* 0x000 */ Actor actor; @@ -45,11 +45,11 @@ typedef struct EnHonotrap { } EnHonotrap; // size = 0x2C4 typedef enum { - HONOTRAP_EYE, - HONOTRAP_FLAME_MOVE, - HONOTRAP_FLAME_DROP, - HONOTRAP_EYE_MUTI_FLAME, - HONOTRAP_FLAME_GROUP + HONOTRAP_TYPE_EYE, + HONOTRAP_TYPE_FLAME_MOVE, + HONOTRAP_TYPE_FLAME_DROP, + HONOTRAP_TYPE_EYE_MUTI_FLAME, + HONOTRAP_TYPE_FLAME_GROUP } EnHonotrapType; #endif // Z_EN_HONOTRAP_H From efc9ad4f3dc3234d299f1882ad0dc4a3ffcb3077 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 12 Oct 2023 22:07:44 -0400 Subject: [PATCH 123/130] space out OPEN/CLOSE_DISP --- src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 8d8f5540d..705fe3490 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -743,10 +743,12 @@ void EnHonotrap_Draw(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; OPEN_DISPS(play->state.gfxCtx); + Gfx_SetupDL25_Opa(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, sSilverEyeTextures[this->eyeState]); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gEyeSwitchSilverDL); + CLOSE_DISPS(play->state.gfxCtx); } @@ -755,6 +757,7 @@ void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; OPEN_DISPS(play->state.gfxCtx); + Gfx_SetupDL25_Xlu(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->flameScroll, 32, 128)); @@ -763,6 +766,7 @@ void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play) { Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + CLOSE_DISPS(play->state.gfxCtx); } @@ -776,6 +780,7 @@ void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { Vec3s camDir; OPEN_DISPS(play->state.gfxCtx); + Gfx_SetupDL25_Xlu(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); @@ -798,5 +803,6 @@ void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } } + CLOSE_DISPS(play->state.gfxCtx); } From 60d953cac4a61c95769361972139997e40286e73 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Mon, 16 Oct 2023 21:50:02 -0400 Subject: [PATCH 124/130] more improvements --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 19 ++++++++++++------- .../actors/ovl_En_Honotrap/z_en_honotrap.h | 18 +++++++++--------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 705fe3490..d3bc8eefe 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -64,8 +64,12 @@ void EnHonotrap_UpdateFlameGroup(Actor* thisx, PlayState* play); void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play); void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play); -static TexturePtr sSilverEyeTextures[HONOTRAP_EYE_MAX] = { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, - gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }; +static TexturePtr sSilverEyeTextures[HONOTRAP_EYE_MAX] = { + gEyeSwitchSilverOpenTex, + gEyeSwitchSilverHalfTex, + gEyeSwitchSilverClosedTex, + gEyeSwitchSilverClosedTex, +}; static s32 sIsFirstInitEye = true; @@ -81,7 +85,7 @@ ActorInit En_Honotrap_InitVars = { (ActorFunc)EnHonotrap_Draw, }; -static ColliderTrisElementInit sTrisElementsInit[2] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { { ELEMTYPE_UNK4, @@ -187,7 +191,7 @@ void EnHonotrap_InitEye(EnHonotrap* this, PlayState* play) { if (sIsFirstInitEye) { sIsFirstInitEye = false; - for (k = 0; k < ARRAY_COUNT(sSilverEyeTextures); k++) { + for (k = 0; k < HONOTRAP_EYE_MAX; k++) { sSilverEyeTextures[k] = Lib_SegmentedToVirtual(sSilverEyeTextures[k]); } } @@ -684,8 +688,8 @@ void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { } void EnHonotrap_Update(Actor* thisx, PlayState* play) { - static Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f accel = { 0.0f, 0.1f, 0.0f }; + static Vec3f sVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f sAccel = { 0.0f, 0.1f, 0.0f }; EnHonotrap* this = (EnHonotrap*)thisx; if (this->timer > 0) { @@ -696,7 +700,7 @@ void EnHonotrap_Update(Actor* thisx, PlayState* play) { } this->actionFunc(this, play); if (this->collider.tris.base.acFlags & AC_HIT) { - EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &velocity, &accel, 15, 8); + EffectSsBomb2_SpawnLayered(play, &this->actor.world.pos, &sVelocity, &sAccel, 15, 8); Actor_Kill(&this->actor); return; } @@ -786,6 +790,7 @@ void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Camera_GetCamDir(&camDir, GET_ACTIVE_CAM(play)); camDir.y += 0x8000; + //! FAKE: this = ((EnHonotrap*)thisx); flameGroup = &this->flameGroup; for (i = 0; i < ARRAY_COUNT(flameGroup->flameList); i++) { diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h index a954ea6d8..db78f30ff 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -23,10 +23,10 @@ typedef struct { } EnHonotrapFlameElement; // size = 0x14 typedef struct { - /* 0x00 */ f32 unk0; - /* 0x04 */ f32 unk4; - /* 0x08 */ f32 unk8; - /* 0x0C */ EnHonotrapFlameElement flameList[6]; + /* 0x0 */ f32 unk0; + /* 0x4 */ f32 unk4; + /* 0x8 */ f32 unk8; + /* 0xC */ EnHonotrapFlameElement flameList[6]; } EnHonotrapFlameGroup; // size = 0x84; typedef struct EnHonotrap { @@ -45,11 +45,11 @@ typedef struct EnHonotrap { } EnHonotrap; // size = 0x2C4 typedef enum { - HONOTRAP_TYPE_EYE, - HONOTRAP_TYPE_FLAME_MOVE, - HONOTRAP_TYPE_FLAME_DROP, - HONOTRAP_TYPE_EYE_MUTI_FLAME, - HONOTRAP_TYPE_FLAME_GROUP + /* 0 */ HONOTRAP_TYPE_EYE, + /* 1 */ HONOTRAP_TYPE_FLAME_MOVE, + /* 2 */ HONOTRAP_TYPE_FLAME_DROP, + /* 3 */ HONOTRAP_TYPE_EYE_MUTI_FLAME, + /* 4 */ HONOTRAP_TYPE_FLAME_GROUP } EnHonotrapType; #endif // Z_EN_HONOTRAP_H From 6e37057cbd018e9d68d028daaf97ab95b2788a6f Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 25 Oct 2023 05:27:36 -0400 Subject: [PATCH 125/130] implement suggestions --- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index d3bc8eefe..8590aa676 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -47,8 +47,8 @@ void EnHonotrap_SetupEyeAttack2(EnHonotrap* this); void EnHonotrap_EyeAttack2(EnHonotrap* this, PlayState* play); void EnHonotrap_SetupEyeClose2(EnHonotrap* this); void EnHonotrap_EyeClose2(EnHonotrap* this, PlayState* play); -void EnHonotrap_SetupFlame(EnHonotrap* this); -void EnHonotrap_Flame(EnHonotrap* this, PlayState* play); +void EnHonotrap_SetupFlameGrow(EnHonotrap* this); +void EnHonotrap_FlameGrow(EnHonotrap* this, PlayState* play); void EnHonotrap_SetupFlameDrop(EnHonotrap* this); void EnHonotrap_FlameDrop(EnHonotrap* this, PlayState* play); void EnHonotrap_SetupFlameMove(EnHonotrap* this); @@ -241,7 +241,7 @@ void EnHonotrap_InitFlame(EnHonotrap* this, PlayState* play) { this->collider.cyl.dim.height = 30; this->actor.shape.yOffset = -1000.0f; } - EnHonotrap_SetupFlame(this); + EnHonotrap_SetupFlameGrow(this); } void EnHonotrap_InitFlameGroup(EnHonotrap* this, PlayState* play) { @@ -422,11 +422,11 @@ void EnHonotrap_EyeClose2(EnHonotrap* this, PlayState* play) { } } -void EnHonotrap_SetupFlame(EnHonotrap* this) { - this->actionFunc = EnHonotrap_Flame; +void EnHonotrap_SetupFlameGrow(EnHonotrap* this) { + this->actionFunc = EnHonotrap_FlameGrow; } -void EnHonotrap_Flame(EnHonotrap* this, PlayState* play) { +void EnHonotrap_FlameGrow(EnHonotrap* this, PlayState* play) { f32 targetScale = (this->actor.params == HONOTRAP_TYPE_FLAME_MOVE) ? 0.004f : 0.0048f; s32 targetReached = Math_StepToF(&this->actor.scale.x, targetScale, 0.0006f); @@ -776,9 +776,9 @@ void EnHonotrap_DrawFlame(Actor* thisx, PlayState* play) { void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { s32 pad; - EnHonotrap* this; + EnHonotrap* this = ((EnHonotrap*)thisx); EnHonotrapFlameElement* flameElem; - EnHonotrapFlameGroup* flameGroup; + EnHonotrapFlameGroup* flameGroup = &this->flameGroup; s32 i; s32 pad2; Vec3s camDir; @@ -790,9 +790,7 @@ void EnHonotrap_DrawFlameGroup(Actor* thisx, PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Camera_GetCamDir(&camDir, GET_ACTIVE_CAM(play)); camDir.y += 0x8000; - //! FAKE: - this = ((EnHonotrap*)thisx); - flameGroup = &this->flameGroup; + for (i = 0; i < ARRAY_COUNT(flameGroup->flameList); i++) { flameElem = &flameGroup->flameList[i]; if (flameElem->isDrawn) { From 04010f8903d4d6ba4b7f0f3215fff2f7a9c2f9d6 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 25 Oct 2023 13:41:58 -0400 Subject: [PATCH 126/130] implement alf suggestions --- src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 8590aa676..a1dc40263 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -180,13 +180,11 @@ void EnHonotrap_InitEye(EnHonotrap* this, PlayState* play) { s32 i; s32 j; s32 k; - f32 sin; - f32 cos; + f32 sin = Math_SinS(this->actor.home.rot.y); + f32 cos = Math_CosS(this->actor.home.rot.y); Vec3f triangle[3]; Vec3f* vtx; - sin = Math_SinS(this->actor.home.rot.y); - cos = Math_CosS(this->actor.home.rot.y); Actor_SetScale(&this->actor, 0.1f); if (sIsFirstInitEye) { From 87d182defbd469c6d85b6346c9a09a829e31c398 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 25 Oct 2023 17:12:05 -0400 Subject: [PATCH 127/130] u substitution --- src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index a1dc40263..4ea4b410d 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -649,7 +649,7 @@ void EnHonotrap_FlameGroup(EnHonotrap* this, PlayState* play) { var_fs0 += 1.0f / 6; flameElem->unkC *= (0.006f * (((1.0f - flameGroup->unk4) * 0.8f) + 0.2f)); flameElem->flameScroll += flameScrollDisplacement; - flameElem->flameScroll &= 0x1FF; + flameElem->flameScroll %= 0x200u; } if (sp78 || (this->timer <= 0)) { @@ -723,7 +723,7 @@ void EnHonotrap_UpdateFlame(Actor* thisx, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); this->actionFunc(this, play); this->flameScroll -= 20; - this->flameScroll &= 0x1FF; + this->flameScroll %= 0x200u; } void EnHonotrap_UpdateFlameGroup(Actor* thisx, PlayState* play) { From 6e35e51b545f19605f976fb297a7c02d5ab98434 Mon Sep 17 00:00:00 2001 From: RevoSucks Date: Tue, 31 Oct 2023 19:59:21 -0400 Subject: [PATCH 128/130] ovl_Bg_Danpei_Movebg --- .../actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index 69220bf40..f54bdb88e 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -67,7 +67,7 @@ s32 func_80AF6DE0(PlayState* this, ActorPathing* actorPathing) { void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play) { BgDanpeiMovebg* this = THIS; DynaPolyActor_Init(&this->dyna, 1); - this->bankIdx = SubS_GetObjectIndex(D_80AF7530[BGDANPEIMOVEBG_GET_TYPE(thisx)], play); + this->bankIdx = SubS_GetObjectSlot(D_80AF7530[BGDANPEIMOVEBG_GET_TYPE(thisx)], play); if (this->bankIdx < 0) { Actor_Kill(&this->dyna.actor); } @@ -77,8 +77,8 @@ void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play) { void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play) { Actor* thisx = (Actor*)this; if (SubS_IsObjectLoaded(this->bankIdx, play)) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->bankIdx].segment); - this->dyna.actor.objBankIndex = this->bankIdx; + gSegments[6] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[this->bankIdx].segment); + this->dyna.actor.objectSlot = this->bankIdx; this->dyna.actor.draw = func_80AF74CC; Actor_ProcessInitChain(thisx, sInitChain); DynaPolyActor_LoadMesh(play, &this->dyna, D_80AF7538[BGDANPEIMOVEBG_GET_TYPE(thisx)]); From 156463ddf5532673b28261549ff3d7742cabe5a8 Mon Sep 17 00:00:00 2001 From: RevoSucks Date: Tue, 31 Oct 2023 20:08:52 -0400 Subject: [PATCH 129/130] ovl_En_Honotrap --- src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 7326069af..5dbb270a9 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -510,7 +510,7 @@ void EnHonotrap_FlameMove(EnHonotrap* this, PlayState* play) { shieldVec.z = -player->shieldMf.zz; EnHonotrap_GetNormal(&shieldNorm, &shieldVec); tempVel = thisx->velocity; - func_80179F64(&tempVel, &shieldNorm, &thisx->velocity); + Math3D_Vec3fReflect(&tempVel, &shieldNorm, &thisx->velocity); thisx->speed = this->speedMod * 0.5f; thisx->world.rot.y = Math_Atan2S_XY(thisx->velocity.z, thisx->velocity.x); EnHonotrap_SetupFlameVanish(this); From 591e0007e1f489b52e634321e00b132621d3251a Mon Sep 17 00:00:00 2001 From: RevoSucks Date: Tue, 31 Oct 2023 20:11:56 -0400 Subject: [PATCH 130/130] ovl_En_Po_Composer --- src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 3cec4b5bd..6444eac45 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -329,7 +329,7 @@ void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { } // Play sharp's curse bgm - func_801A1FB4(SEQ_PLAYER_BGM_SUB, &this->actor.projectedPos, NA_BGM_SHARPS_CURSE, 2000.0f); + Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &this->actor.projectedPos, NA_BGM_SHARPS_CURSE, 2000.0f); } void EnPoComposer_SetupIdleStill(EnPoComposer* this) {