diff --git a/Makefile b/Makefile index 7326b88a7..ac7174e89 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ ASFLAGS := -march=vr4300 -32 -Iinclude MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 +CFLAGS += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712,516 # Use relocations and abi fpr names in the dump OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml index d48335ec7..03329f0c5 100644 --- a/assets/xml/code/sub_s.xml +++ b/assets/xml/code/sub_s.xml @@ -1,6 +1,6 @@ - - + + diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index 3bd04c90e..c9c6a0a90 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -3,7 +3,7 @@ - + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index 0370e1ae2..9a400554b 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -1,99 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 2e9529d4c..8a45dd04a 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -1,42 +1,55 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 4e07a455c..ad69c7722 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,4 +1,5 @@  + @@ -33,17 +34,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_dora.xml b/assets/xml/objects/object_dora.xml index 6a0972666..ab4b09cf7 100644 --- a/assets/xml/objects/object_dora.xml +++ b/assets/xml/objects/object_dora.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index 26c0741ec..e3b4d2d93 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -1,42 +1,58 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sinkai_kabe.xml b/assets/xml/objects/object_sinkai_kabe.xml index 96f8531ad..3c23a73ce 100644 --- a/assets/xml/objects/object_sinkai_kabe.xml +++ b/assets/xml/objects/object_sinkai_kabe.xml @@ -1,5 +1,6 @@  + - + diff --git a/include/functions.h b/include/functions.h index c1ef4ac7a..109395810 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2236,7 +2236,7 @@ void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd); void Door_InitContext(GameState* gameState, DoorContext* doorCtx); void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd); -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd); @@ -2441,7 +2441,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 func_8013AD6C(GlobalContext* globalCtx); +s32 SubS_InCsMode(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); @@ -2458,10 +2458,10 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); -void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); -void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); -void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); @@ -2486,12 +2486,12 @@ s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actor void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); -void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); -s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); -s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); -void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); @@ -2886,7 +2886,7 @@ void* GameAlloc_Malloc(GameAlloc* this, size_t size); void GameAlloc_Free(GameAlloc* this, void* data); void GameAlloc_Cleanup(GameAlloc* this); void GameAlloc_Init(GameAlloc* this); -void* Graph_FaultClient(void); +void Graph_FaultClient(void); void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); GameStateOverlay* Graph_GetNextGameState(GameState* gameState); diff --git a/include/variables.h b/include/variables.h index 605b63939..4acb019a4 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1349,12 +1349,6 @@ extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; extern UNK_PTR D_801C5CB0; -extern MtxF sMtxFClear; -// extern UNK_TYPE1 D_801C5D10; -// extern UNK_TYPE1 D_801C5D20; -// extern UNK_TYPE1 D_801C5D60; -// extern UNK_TYPE1 D_801C5D80; -extern Vec3f D_801C5DB0; // extern UNK_TYPE1 D_801C5DD0; // extern UNK_TYPE1 D_801C5DE0; // extern UNK_TYPE1 D_801C5DF0; diff --git a/include/z64animation.h b/include/z64animation.h index 974b8bea0..58ddb34df 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -187,7 +187,10 @@ typedef struct SkelAnime { /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph - /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph + /* 0x30 */ union { + s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph + s32 (*link)(struct GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph + } update; /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. diff --git a/include/z64math.h b/include/z64math.h index de0285e6c..78e1743ec 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -49,6 +49,10 @@ typedef struct { /* 0x0C */ f32 radius; } Spheref; // size = 0x10 +/* +The plane paramaters are of form `ax + by + cz + d = 0` +where `(a,b,c)` is the plane's normal vector and d is the originDist + */ typedef struct { /* 0x00 */ Vec3f normal; /* 0x0C */ f32 originDist; diff --git a/include/z64subs.h b/include/z64subs.h index ca69e72cb..f01230fdb 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -4,16 +4,25 @@ #include "z64actor.h" #include "z64scene.h" +#include "code/sub_s/sub_s.h" + +extern Vec3f gOneVec3f; + typedef enum { /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, /* 1 */ SUBS_CUTSCENE_NORMAL, /* 2 */ SUBS_CUTSCENE_SET_FLAG } SubSCutsceneType; -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, void*); +//! @TODO: rename based on func_8013E748 and func_800B8500 +typedef s32 (*func_8013E748_VerifyFunc)(struct GlobalContext*, Actor*, void*); typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); +#define SUBS_SHADOW_TEX_WIDTH 64 +#define SUBS_SHADOW_TEX_HEIGHT 64 +#define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) + #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) #define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 997a41233..970706760 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -72,8 +72,8 @@ typedef struct EnHy { } EnHy; // size = 0x3EC extern s8 gEnHyBodyParts[]; -extern s8 gEnHyBodyPartsIndex[]; -extern u8 gEnHyShadowSize[]; +extern s8 gEnHyParentBodyParts[]; +extern u8 gEnHyShadowSizes[]; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); diff --git a/spec b/spec index 45b796d54..5c8da2164 100644 --- a/spec +++ b/spec @@ -1055,8 +1055,7 @@ beginseg name "ovl_En_Bbfall" compress include "build/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.data.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.reloc.o" + include "build/src/overlays/actors/ovl_En_Bbfall/ovl_En_Bbfall_reloc.o" endseg beginseg @@ -1546,8 +1545,7 @@ beginseg name "ovl_Obj_Blockstop" compress include "build/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.data.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Blockstop/ovl_Obj_Blockstop_reloc.o" endseg beginseg @@ -2546,8 +2544,7 @@ beginseg name "ovl_En_Raf" compress include "build/src/overlays/actors/ovl_En_Raf/z_en_raf.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.data.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.reloc.o" + include "build/src/overlays/actors/ovl_En_Raf/ovl_En_Raf_reloc.o" endseg beginseg @@ -4057,8 +4054,7 @@ beginseg name "ovl_Obj_Dora" compress include "build/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.data.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dora/ovl_Obj_Dora_reloc.o" endseg beginseg @@ -4097,8 +4093,7 @@ beginseg name "ovl_Bg_Sinkai_Kabe" compress include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.data.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe_reloc.o" endseg beginseg diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index b63f8192b..8faf565ea 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -459,6 +459,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { if (instrument->normalRangeHi != 0x7F) { return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); } + // TODO: is this missing return UB? } else if (instId == 0x7F) { Drum* drum = AudioPlayback_GetDrum(fontId, drumId); @@ -468,6 +469,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { AudioLoad_SyncLoadSample(drum->sound.sample, fontId); return 0; } + // TODO: is this missing return UB? } void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { diff --git a/src/code/graph.c b/src/code/graph.c index 04ab72057..28327c35f 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -12,7 +12,7 @@ GfxMasterList* gGfxMasterDL; CfbInfo sGraphCfbInfos[3]; OSTime sGraphTaskStartTime; -void* Graph_FaultClient(void) { +void Graph_FaultClient(void) { FaultDrawer_DrawText(30, 100, "ShowFrameBuffer PAGE 0/1"); osViSwapBuffer(SysCfb_GetFbPtr(0)); osViSetMode(D_801FBB88); diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 93eeeddc7..24bc91a17 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -240,7 +240,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx } actor->shape.unk_17 &= ~spB8; - if (!mapper->l.l) {} // POSSIBLE FAKE MATCH + if ((uintptr_t)mapper->l.l) {} // POSSIBLE FAKE MATCH } } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index b2891de90..028f68011 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4441,11 +4441,13 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, return false; } +// boolean s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); } +// boolean s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 0af7dfb4d..762be4538 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1418,6 +1418,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } } #else +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr); #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") #endif diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index b17799aff..6ab70f1ef 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -309,6 +309,7 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 Vec3s sp30; f32 mode4Param; EffectBlureElement* elem = &this->elements[index]; + Vec3s* unusedPtr = &sp30; // Optimized out but seems necessary to match stack usage switch (this->calcMode) { case 1: @@ -367,8 +368,6 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 break; } - sp30 = sp30; // Optimized out but seems necessary to match stack usage - if (this->flags & 0x10) { color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 6b16cc91c..28c177068 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -37,9 +37,9 @@ static AnimationInfoS sAnimations[] = { s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 gEnHyBodyPartsIndex[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +s8 gEnHyParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 gEnHyShadowSize[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 2b0db8ad4..5d47b4153 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -216,7 +216,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo } } -LightNode* Lights_FindBufSlot() { +LightNode* Lights_FindBufSlot(void) { LightNode* ret; if (sLightsBuffer.numOccupied >= LIGHTS_BUFFER_SIZE) { diff --git a/src/code/z_quake.c b/src/code/z_quake.c index ee4fa3a6d..d57dc8e54 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -638,7 +638,7 @@ void Distortion_Update(void) { sDistortionContext.countdown = 2; player = GET_PLAYER(globalCtx); - if (&player->actor != NULL) { + if (player != NULL) { Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 8a9bdd4e7..b03990702 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -341,7 +341,7 @@ void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) { * Loads different texture files for each region of the world. * These later are stored in segment 0x06, and used in maps. */ -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { static RomFile sceneTextureFiles[9] = { { 0, 0 }, // Default { SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) }, @@ -358,10 +358,8 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { if (size != 0) { globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); - return DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); + DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); } - - // UB: Undefined behaviour to not have a return statement here, but it breaks matching to add one. } // SceneTableEntry Header Command 0x11: Skybox Settings diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index f7f71a2dd..8f369008f 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -234,7 +234,7 @@ f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp) { s32 i; s32 j; - for (i = 0, weightsPtr = weights, xPtr1 = x, fxPtr = fx, weightsPtr = weightsPtr; i < n; i++) { + for (i = 0, xPtr1 = x, fxPtr = fx, weightsPtr = weights; i < n; i++) { for (xVal = *xPtr1, m = 1.0f, j = 0, xPtr2 = x; j < n; j++) { if (j != i) { m *= xVal - (*xPtr2); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8ad36c891..6563eecfc 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1238,9 +1238,9 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel */ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = LinkAnimation_Loop; + skelAnime->update.link = LinkAnimation_Loop; } else { - skelAnime->update = LinkAnimation_Once; + skelAnime->update.link = LinkAnimation_Once; } skelAnime->morphWeight = 0.0f; } @@ -1250,7 +1250,7 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * finishes. */ s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->update(globalCtx, skelAnime); + return skelAnime->update.link(globalCtx, skelAnime); } /** @@ -1355,7 +1355,7 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update = LinkAnimation_Morph; + skelAnime->update.link = LinkAnimation_Morph; AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1599,11 +1599,11 @@ void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHead */ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = SkelAnime_LoopFull; + skelAnime->update.normal = SkelAnime_LoopFull; } else if (skelAnime->mode <= ANIMMODE_ONCE_INTERP) { - skelAnime->update = SkelAnime_Once; + skelAnime->update.normal = SkelAnime_Once; } else { - skelAnime->update = SkelAnime_LoopPartial; + skelAnime->update.normal = SkelAnime_LoopPartial; } } @@ -1612,7 +1612,7 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update.normal(skelAnime); } /** @@ -1774,10 +1774,10 @@ void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames = -morphFrames; } else { if (taper != ANIMTAPER_NONE) { - skelAnime->update = SkelAnime_MorphTaper; + skelAnime->update.normal = SkelAnime_MorphTaper; skelAnime->taper = taper; } else { - skelAnime->update = SkelAnime_Morph; + skelAnime->update.normal = SkelAnime_Morph; } SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->morphTable); } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 63c3a1571..05078382b 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1494,7 +1494,7 @@ void func_80146DF8(SramContext* sramCtx) { } void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { - if (&gSaveContext.save) {} + if (gSaveContext.save.entranceIndex) {} // Required to match func_801A3D98(gSaveContext.options.audioSetting); } diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index c36365d48..b51de4897 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -10,7 +10,7 @@ s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; #include "code/sub_s/sub_s.c" -Vec3f D_801C5DB0 = { 1.0f, 1.0f, 1.0f }; +Vec3f gOneVec3f = { 1.0f, 1.0f, 1.0f }; s32 D_801C5DBC[] = { 0, 1 }; // Unused @@ -158,7 +158,15 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo return gfx; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD6C.s") +s32 SubS_InCsMode(GlobalContext* globalCtx) { + s32 inCsMode = false; + + if (Play_InCsMode(globalCtx)) { + inCsMode = true; + } + + return inCsMode; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") @@ -333,13 +341,189 @@ s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) { + s32 ret = false; + s16 x; + s16 y; + f32 xzDistToPlayerTemp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CC2C.s") + Actor_GetScreenPos(globalCtx, actor, &x, &y); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CD64.s") + switch (type) { + case 1: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange); + break; + case 2: + if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 3: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 4: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + xzDistToPlayerTemp = actor->xzDistToPlayer; + actor->xzDistToPlayer = 0.0f; + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + actor->xzDistToPlayer = xzDistToPlayerTemp; + break; + case 5: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) { + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 6: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CF04.s") +const u8 sShadowMaps[4][12][12] = { + { + { 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, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 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, 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, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 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, 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, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 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, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + }, +}; + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size) { + s32 i; + s32 j; + s32 start; + + for (i = 0; i < 12; i++) { + start = ((startRow + i) * 64) + startCol - 390; + for (j = 0; j < 12; j++) { + if (sShadowMaps[size][i][j] != 0) { + if ((start + j >= 0) && (start + j < SUBS_SHADOW_TEX_SIZE)) { + tex[start + j] = 255; + } + } + } + } +} + +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], + s8 parentBodyParts[]) { + Vec3f pos; + Vec3f startVec; + s32 i; + s32 parentBodyPart; + Vec3f* bodyPartPos; + s32 startCol; + s32 startRow; + + for (i = 0; i < bodyPartsNum; i++) { + if (parentBodyParts[i] >= 0) { + parentBodyPart = parentBodyParts[i]; + bodyPartPos = &bodyPartsPos[i]; + + pos.x = (bodyPartsPos[parentBodyPart].x - bodyPartPos->x) * tween + (bodyPartPos->x - worldPos->x); + pos.y = (bodyPartsPos[parentBodyPart].y - bodyPartPos->y) * tween + (bodyPartPos->y - worldPos->y); + pos.z = (bodyPartsPos[parentBodyPart].z - bodyPartPos->z) * tween + (bodyPartPos->z - worldPos->z); + } else { + bodyPartPos = &bodyPartsPos[i]; + + pos.x = bodyPartPos->x - worldPos->x; + pos.y = bodyPartPos->y - worldPos->y; + pos.z = bodyPartPos->z - worldPos->z; + } + + Matrix_MultiplyVector3fByState(&pos, &startVec); + startCol = 64.0f + startVec.x; + startRow = 64.0f - startVec.z; + SubS_FillShadowTex(startCol >> 1, startRow >> 1, tex, sizes[i]); + } +} + +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { + s32 pad; + GraphicsContext* gfxCtx = gameState->gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 100); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + Matrix_InsertTranslation(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gShadowDL); + gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_OPA_DISP++, gShadowVtxDL); + + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") @@ -688,9 +872,58 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { return i; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") +/** + * Computes a plane based on a point on the plane, a unit vector and two angles + * + * @param[in] point a point on the plane + * @param[in] unitVec the unit vector rotated that becomes the plane's normal + * @param[in] rot the angles to rotate with, uses just the x and y components + * @param[out] plane the computed plane + * + * Notes: + * The unit input vector is expected to already be normalized (only uses are with the z unit vector) + * + */ +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { + f32 sin; + f32 cos; + f32 temp; + f32 unitVecZ; + f32 normY; + f32 unitVecYX; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") + sin = Math_SinS(-rot->x); + cos = Math_CosS(-rot->x); + unitVecZ = unitVec->z; + unitVecYX = unitVec->y; + + // Apply a rotation by -x about the X axis + temp = (unitVecZ * cos) - (unitVecYX * sin); + normY = (unitVecZ * sin) + (unitVecYX * cos); + + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + unitVecYX = unitVec->x; + plane->normal.y = normY; + + // Apply a rotation by y about the Y axis + plane->normal.z = (temp * cos) - (unitVecYX * sin); + plane->normal.x = (temp * sin) + (unitVecYX * cos); + + plane->originDist = -((point->x * plane->normal.x) + (plane->normal.y * point->y) + (plane->normal.z * point->z)); +} + +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, + Vec3f* intersect) { + s32 lineSegVsPlane; + Plane plane; + + SubS_ConstructPlane(point, unitVec, rot, &plane); + lineSegVsPlane = Math3D_LineSegVsPlane(plane.normal.x, plane.normal.y, plane.normal.z, plane.originDist, linePointA, + linePointB, intersect, false); + + return lineSegVsPlane ? true : false; +} /** * Finds the first actor instance of a specified Id and category verified with a custom callback. @@ -714,10 +947,44 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor return actorIter; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, + func_8013E748_VerifyFunc verifyFunc) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E7C0.s") + if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E8F8.s") +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) { + Player* player = GET_PLAYER(globalCtx); + Vec3s* yawTols = (Vec3s*)data; + s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y)); + s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + s32 areFacing = false; + s32 actorYawTol = ABS(yawTols->y); + s32 playerYawTol; + + if (actorYaw < (s16)actorYawTol) { + playerYawTol = ABS(yawTols->x); + if (playerYaw < (s16)playerYawTol) { + areFacing = true; + } + } + + return areFacing; +} + +//! TODO: Needs docs with func_800B8500 +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, + s16 actorYawTol) { + Vec3s yawTols; + + yawTols.x = playerYawTol; + yawTols.y = actorYawTol; + return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s") diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 8c55cc2f3..11936a9d2 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -300,7 +300,6 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F208(); } else { - this = this; func_800B7298(globalCtx, &this->dyna.actor, 6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index e5af3fe1f..e5bba655d 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,10 +1,18 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Manages the Deep Pythons and Seahorse in Pinnacle Rock + * Description: Manages the Deep Pythons in Pinnacle Rock + * + * While its name describes one of its responsibilities ("Deep Sea Wall", aka the invisible + * wall blocking a Deep Python's den before you defeat it), it is also responsible for + * spawning in the Deep Pythons when the area first loads, as well as signalling to the + * Deep Python that it should extend its body. Furthermore, if the player defeats all + * eight Deep Pythons and spawns the second Seahorse, this actor is responsible for spawning + * it again if the player leaves and re-enters Pinnacle Rock. */ #include "z_bg_sinkai_kabe.h" +#include "objects/object_sinkai_kabe/object_sinkai_kabe.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +22,8 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx); + const ActorInit Bg_Sinkai_Kabe_InitVars = { ACTOR_BG_SINKAI_KABE, ACTORCAT_ITEMACTION, @@ -27,14 +36,117 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sCurrentPythonIndex = 0; -extern UNK_TYPE D_06000048; +void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; + Vec3f pos; + s32 pad2; + s32 shouldSpawnSeahorse; + s32 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Init.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gPinnacleRockPythonDenCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Math_Vec3f_Copy(&pos, &this->dyna.actor.world.pos); + pos.x += Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + pos.z += Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + cs = this->dyna.actor.cutscene; + i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Destroy.s") + // clang-format off + while (cs != -1) { this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/func_80B6DA20.s") + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; + this->pythonIndex = sCurrentPythonIndex; + sCurrentPythonIndex++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Update.s") + if (!(gSaveContext.save.weekEventReg[13] & 1)) { + this->deepPython = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_DRAGON, pos.x, pos.y, pos.z, + 0, this->dyna.actor.world.rot.y, 1, this->dyna.actor.params); + + if (this->deepPython != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + dragon->grabCutsceneIndex = this->cutscenes[0]; + dragon->deathCutsceneIndex = this->cutscenes[1]; + dragon->actor.cutscene = this->dyna.actor.cutscene; + Math_Vec3f_Copy(&dragon->burrowEntrancePos, &this->dyna.actor.world.pos); + dragon->pythonIndex = this->pythonIndex; + } + } else { + shouldSpawnSeahorse = false; + if (((this->dyna.actor.params == 0) && (gSaveContext.save.weekEventReg[83] & 0x10)) || + ((this->dyna.actor.params == 1) && (gSaveContext.save.weekEventReg[83] & 0x20)) || + ((this->dyna.actor.params == 2) && (gSaveContext.save.weekEventReg[83] & 0x40)) || + ((this->dyna.actor.params == 3) && (gSaveContext.save.weekEventReg[83] & 0x80)) || + ((this->dyna.actor.params == 4) && (gSaveContext.save.weekEventReg[84] & 1)) || + ((this->dyna.actor.params == 5) && (gSaveContext.save.weekEventReg[84] & 2)) || + ((this->dyna.actor.params == 6) && (gSaveContext.save.weekEventReg[84] & 4)) || + ((this->dyna.actor.params == 7) && (gSaveContext.save.weekEventReg[84] & 8))) { + shouldSpawnSeahorse = true; + } + + Math_Vec3f_Copy(&pos, &this->dyna.actor.home.pos); + pos.x += (Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + pos.y += -100.0f; + pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + if (shouldSpawnSeahorse) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, + this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene, + this->dyna.actor.unk20, NULL); + } + + Actor_MarkForDeath(&this->dyna.actor); + } + + this->actionFunc = BgSinkaiKabe_WaitForPlayer; +} + +void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +/** + * Extends this actor's Deep Python if the player gets close enough. + */ +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx) { + if (this->deepPython != NULL) { + if (this->deepPython->update != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + if (dragon->action == DEEP_PYTHON_ACTION_IDLE) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->dyna.actor.xzDistToPlayer < 500.0f) || + ((ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.world.rot.y)) < 0x2000) && + (this->dyna.actor.xzDistToPlayer < 700.0f))) { + if (fabsf(this->dyna.actor.world.pos.y - player->actor.world.pos.y) < 400.0f) { + dragon->action = DEEP_PYTHON_ACTION_EXTEND; + } + } + } + } else { + this->deepPython = NULL; + } + } + + if (this->deepPython == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h index 5fb866529..1a29f512f 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h @@ -2,16 +2,19 @@ #define Z_BG_SINKAI_KABE_H #include "global.h" +#include "overlays/actors/ovl_En_Dragon/z_en_dragon.h" struct BgSinkaiKabe; typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, GlobalContext*); typedef struct BgSinkaiKabe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgSinkaiKabeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgSinkaiKabeActionFunc actionFunc; + /* 0x160 */ Actor* deepPython; + /* 0x164 */ s16 cutscenes[2]; + /* 0x168 */ UNK_TYPE1 unk_168[0x4]; + /* 0x16C */ s32 pythonIndex; } BgSinkaiKabe; // size = 0x170 extern const ActorInit Bg_Sinkai_Kabe_InitVars; 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 888a0587a..4a9061207 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -4,10 +4,10 @@ * Description: Twinmold */ +#include "prevent_bss_reordering.h" #include "z_boss_02.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" -#include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "prevent_bss_reordering.h" @@ -597,8 +597,8 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 20; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_boss02_Skel_009B10, &object_boss02_Anim_009C78, - this->jointTable, this->morphTable, 13); + SkelAnime_Init(globalCtx, &this->skelAnime, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, + this->morphTable, TWINMOLD_HEAD_LIMB_MAX); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, this->colliderSphere1Elements); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere2, &this->actor, &sJntSphInit2, @@ -637,7 +637,7 @@ void func_809DAA98(Boss02* this, GlobalContext* globalCtx) { void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { this->actionFunc = func_809DAB78; - Animation_MorphToLoop(&this->skelAnime, &object_boss02_Anim_009C78, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &gTwinmoldHeadFlyAnim, 0.0f); if (D_809E042C->unk_1D20 != 0) { this->unk_0144 = 10; } else { @@ -1323,12 +1323,12 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, + gTwinmoldBodySegment1DL, gTwinmoldBodySegment2DL, gTwinmoldBodySegment3DL, gTwinmoldBodySegment4DL, + gTwinmoldBodySegment5DL, gTwinmoldBodySegment6DL, gTwinmoldBodySegment7DL, gTwinmoldBodySegment8DL, + gTwinmoldBodySegment9DL, gTwinmoldBodySegment10DL, gTwinmoldBodySegment11DL, gTwinmoldBodySegment12DL, + gTwinmoldBodySegment13DL, gTwinmoldBodySegment14DL, gTwinmoldBodySegment15DL, gTwinmoldBodySegment16DL, + gTwinmoldBodySegment17DL, gTwinmoldBodySegment18DL, gTwinmoldBodySegment19DL, gTwinmoldBodySegment20DL, + gTwinmoldBodySegment21DL, gTwinmoldBodyTailDL, }; static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; GlobalContext* globalCtx = globalCtx2; @@ -1353,9 +1353,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0003A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldRedSkinTex)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0041A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldBlueSkinTex)); } gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); @@ -1528,7 +1528,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 1) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); flag++; } @@ -1549,7 +1549,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } @@ -1598,7 +1598,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); flag++; } @@ -1614,7 +1614,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } @@ -2141,7 +2141,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == (u32)(KREG(92) + 125)) { TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, - Lib_SegmentedToVirtual(object_boss02_Tex_008650), 160, 180, 128, 40); + Lib_SegmentedToVirtual(gTwinmoldTitleCardTex), 160, 180, 128, 40); } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index babf40b76..6c20814fb 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -2,6 +2,7 @@ #define Z_BOSS_02_H #include "global.h" +#include "objects/object_boss02/object_boss02.h" struct Boss02; @@ -56,8 +57,8 @@ typedef struct Boss02 { /* 0x0B1C */ Vec3f unk_0B1C[200]; /* 0x147C */ Vec3f unk_147C[23]; /* 0x1590 */ SkelAnime skelAnime; - /* 0x15D4 */ Vec3s jointTable[13]; - /* 0x1622 */ Vec3s morphTable[13]; + /* 0x15D4 */ Vec3s jointTable[TWINMOLD_HEAD_LIMB_MAX]; + /* 0x1622 */ Vec3s morphTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1670 */ Boss02ActionFunc actionFunc; /* 0x1674 */ struct Boss02* unk_1674; // points to the other's instance /* 0x1678 */ s32 unk_1678; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index b2b05230f..dd41ac015 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1093,6 +1093,7 @@ static Color_RGB8 D_808BBB50[] = { { 0, 50, 200 }, { 120, 150, 0 }, }; +void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") #endif diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index be25dec24..5f0f7a5b2 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -541,7 +541,7 @@ void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + 60; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2D8 & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2D8 & 7); if (!(this->unk_2D8 & 0x10)) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index e86f3971d..259c52614 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -647,7 +647,7 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; case 2: - this->unk_4F0 = 0; + this->unk_4F0 = EXCH_ITEM_NONE; this->unk_4EA = 0; func_80BDE27C(this, 2); break; @@ -660,7 +660,7 @@ s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_4F0 = 0; + this->unk_4F0 = EXCH_ITEM_NONE; this->unk_4C2 = 0; this->unk_4D4 = 40.0f; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 9fcb56018..b787dd003 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -598,7 +598,7 @@ s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->currentPoint)) { ActorCutscene_Stop(this->unk_430); this->unk_3F4 = npc; this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); @@ -614,7 +614,7 @@ s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->index == ((EnRacedog*)npc)->selectedDogIndex)) { this->unk_3F4 = npc; return true; } @@ -629,7 +629,7 @@ s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { s16 count = 0; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_29C == 3)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->raceStatus == RACEDOG_RACE_STATUS_FINISHED)) { count++; } npc = npc->next; @@ -669,7 +669,6 @@ void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x20; if (func_809C25E4(this, globalCtx)) { - globalCtx = globalCtx; if (func_801A8A50(0) != 0x41) { globalCtx->nextEntranceIndex = 0x7C10; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; @@ -853,12 +852,12 @@ s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { - this->unk_432 = ((EnDg*)dog)->unk_288; + this->unk_432 = ((EnDg*)dog)->selectedDogIndex; if (this->unk_432 == -1) { return false; } - if (this->unk_432 == ENDG_GET_3E0(dog)) { + if (this->unk_432 == ENDG_GET_INDEX(dog)) { return true; } } diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index ff2d7c48e..a2f28a6dd 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -384,7 +384,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_430; sp50 = this->unk_42C; sp58 = this->actor.world.pos; @@ -401,7 +401,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_430 = sp54; this->unk_42C = sp50; this->unk_414 = sp58; diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 82b3ab923..311c2f633 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -521,7 +521,7 @@ void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); this->collider.base.atFlags &= ~AT_ON; if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || - (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { Actor_SetDropFlag(&this->actor, &this->collider.info); this->flameScaleY = 0.0f; this->flameScaleX = 0.0f; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index e502b6637..883d4dd60 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -308,7 +308,7 @@ void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBba01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -322,14 +322,14 @@ void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBba01_TransformLimbDraw, &this->enHy.actor); Matrix_InsertXRotation_s(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 8af8e650a..3ccd807d8 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -5,6 +5,7 @@ */ #include "z_en_bbfall.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) @@ -15,16 +16,25 @@ void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808BF734(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF830(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF8DC(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFA3C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFB4C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFE58(EnBbfall* this, GlobalContext* globalCtx); -void func_808C00A0(EnBbfall* this, GlobalContext* globalCtx); -void func_808C0178(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupWaitForPlayer(EnBbfall* this); +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupEmerge(EnBbfall* this); +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupFly(EnBbfall* this); +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupSinkIntoLava(EnBbfall* this); +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BBFALL_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BBFALL_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BBFALL_BODY_PART_DRAW_STATUS_DEAD, +} EnBbfallBodyPartDrawStatus; -#if 0 const ActorInit En_Bbfall_InitVars = { ACTOR_EN_BBFALL, ACTORCAT_ENEMY, @@ -37,140 +47,720 @@ const ActorInit En_Bbfall_InitVars = { (ActorFunc)EnBbfall_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[3] = { -static ColliderJntSphElementInit D_808C0D30[3] = { +static ColliderJntSphElementInit sJntSphElementsInit[3] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808C0D9C = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808C0D30, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C0DAC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BBFALL_DMGEFF_NONE, + /* 0x1 */ EN_BBFALL_DMGEFF_STUN, + /* 0x3 */ EN_BBFALL_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BBFALL_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BBFALL_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BBFALL_DMGEFF_HOOKSHOT = 0xE, +} EnBbfallDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C0DCC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C0DD4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 36, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderJntSphElementInit D_808C0D30[3]; -extern ColliderJntSphInit D_808C0D9C; -extern DamageTable D_808C0DAC; -extern CollisionCheckInfoInit D_808C0DCC; -extern InitChainEntry D_808C0DD4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + this->timer = 0; + EnBbfall_SetupWaitForPlayer(this); + Actor_SetFocus(&this->actor, 0.0f); + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Destroy.s") +void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF344.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF3B8.s") +void EnBbfall_Freeze(EnBbfall* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF438.s") +void EnBbfall_Thaw(EnBbfall* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF4B4.s") +/** + * Returns true if the Bubble is touching a floor that it should "sink into" (i.e., if it's touching lava). + */ +s32 EnBbfall_IsTouchingLava(EnBbfall* this, GlobalContext* globalCtx) { + if (!SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + u32 floorType = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF514.s") + if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF578.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5AC.s") +void EnBbfall_PlaySfx(EnBbfall* this) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5E0.s") + func_800B9010(&this->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF734.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBbfall_CheckForWall(EnBbfall* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF7A0.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF830.s") + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF894.s") + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF8DC.s") +void EnBbfall_EnableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK1; // Fire + this->collider.elements[1].info.toucherFlags |= TOUCH_ON; + this->collider.elements[2].info.toucherFlags |= TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA18.s") +void EnBbfall_DisableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK0; // Nothing + this->collider.elements[1].info.toucherFlags &= ~TOUCH_ON; + this->collider.elements[2].info.toucherFlags &= ~TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA3C.s") +void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFAB4.s") + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->flameOpacity = 255; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actor.colorFilterTimer = 0; + this->isBgCheckCollisionEnabled = false; + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.world.pos.y -= 90.0f; + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++) { + Math_Vec3f_Copy(&this->flamePos[i], &this->actor.world.pos); + this->flamePos[i].y -= 47.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFB4C.s") + this->actor.bgCheckFlags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBbfall_WaitForPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFCCC.s") +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.xyzDistToPlayerSq <= SQ(250.0f))) { + EnBbfall_SetupEmerge(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFE58.s") +void EnBbfall_SetupEmerge(EnBbfall* this) { + this->actor.gravity = -1.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; + this->actor.velocity.y = 17.0f; + EnBbfall_EnableColliders(this); + this->actor.flags |= ACTOR_FLAG_1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEFALL_APPEAR); + this->actionFunc = EnBbfall_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFF8C.s") +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.home.pos.y < this->actor.world.pos.y) { + EnBbfall_SetupFly(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C00A0.s") + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C013C.s") +void EnBbfall_SetupFly(EnBbfall* this) { + this->flameOpacity = 255; + this->isBgCheckCollisionEnabled = true; + this->actor.bgCheckFlags &= ~1; + this->actor.speedXZ = 5.0f; + this->actor.gravity = -1.0f; + this->actionFunc = EnBbfall_Fly; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C0178.s") +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBbfall_CheckForWall(this); + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + // Bounce upwards off the ground + this->actor.velocity.y *= -1.2f; + this->actor.velocity.y = CLAMP(this->actor.velocity.y, 8.0f, 12.0f); + this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(73728.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C01E0.s") + this->actor.bgCheckFlags &= ~1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Update.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C07D4.s") +void EnBbfall_SetupSinkIntoLava(EnBbfall* this) { + this->isBgCheckCollisionEnabled = false; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnBbfall_SinkIntoLava; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C080C.s") +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.world.pos.y < (this->actor.floorHeight - 90.0f)) { + this->timer = 10; + EnBbfall_SetupWaitForPlayer(this); + } else { + EnBbfall_PlaySfx(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Draw.s") +void EnBbfall_SetupDown(EnBbfall* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 200; + this->flameOpacity = 0; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBbfall_Down; +} + +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBbfall_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + return; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBbfall_EnableColliders(this); + this->actor.velocity.y = 8.0f; + EnBbfall_SetupFly(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBbfall_SetupDead(EnBbfall* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE5CC(&this->actor, &this->collider, 0); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actionFunc = EnBbfall_Dead; +} + +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + Actor_MarkForDeath(&this->actor); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBbfall_SetupDamage(EnBbfall* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE5CC(&this->actor, &this->collider, 0); + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actionFunc = EnBbfall_Damage; +} + +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_SetupFrozen(EnBbfall* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBbfall_Frozen; +} + +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBbfall_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + Actor_SetDropFlagJntSph(&this->actor, &this->collider); + this->flameOpacity = 0; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBbfall_DisableColliders(this); + EnBbfall_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ICE_ARROW) { + EnBbfall_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBbfall_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.elements[0].info.bumper.hitPos.x, + this->collider.elements[0].info.bumper.hitPos.y, + this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + EnBbfall_DisableColliders(this); + if (this->actionFunc != EnBbfall_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBbfall_SetupDown(this); + } + } + } +} + +void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + Sphere16* sphere; + Vec3f diff; + s32 i; + f32 scale; + s32 pad[2]; + + EnBbfall_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if (this->actionFunc != EnBbfall_Dead) { + Actor_MoveWithGravity(&this->actor); + if (this->isBgCheckCollisionEnabled) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 20.0f, 7); + } + + for (i = ARRAY_COUNT(this->flamePos) - 1; i >= 2; i--) { + Math_Vec3f_Diff(&this->flamePos[i - 2], &this->flamePos[i - 1], &diff); + Math_Vec3f_Scale(&diff, (i - 1) * 0.1f); + Math_Vec3f_Copy(&this->flamePos[i], &this->flamePos[i - 1]); + Math_Vec3f_Sum(&this->flamePos[i], &diff, &this->flamePos[i]); + } + + Math_Vec3f_Copy(&this->flamePos[1], &this->flamePos[0]); + Math_Vec3f_Copy(&this->flamePos[0], &this->actor.world.pos); + this->flamePos[0].y += 15.0f; + this->flamePos[0].y -= 47.0f * this->flameScaleY; + + for (i = 0, scale = this->flameScaleX; i < ARRAY_COUNT(this->colliderElements); i++, scale *= 0.7569f) { + sphere = &this->collider.elements[i].dim.worldSphere; + sphere->radius = 30.0f * scale; + sphere->center.x = this->flamePos[2 * i].x; + sphere->center.y = this->flamePos[2 * i].y + (47.0f * scale); + sphere->center.z = this->flamePos[2 * i].z; + } + + this->collider.elements[0].dim.worldSphere.radius = + CLAMP_MIN(this->collider.elements[0].dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements->dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBbfall_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBbfall* this = THIS; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + s32 opacity; + Vec3f* pos; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBbfall_OverrideLimbDraw, + EnBbfall_PostLimbDraw, &this->actor); + + if (this->flameOpacity > 0) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + currentMatrixState = Matrix_GetCurrentState(); + + opacity = this->flameOpacity; + pos = &this->flamePos[0]; + + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++, pos++) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((globalCtx->gameplayFrames + (i * 10)) * (-20 + i * 2)) & 0x1FF, 32, 128)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, opacity); + currentMatrixState->mf[3][0] = pos->x; + currentMatrixState->mf[3][1] = pos->y; + currentMatrixState->mf[3][2] = pos->z; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + opacity -= 35; + if (opacity < 0) { + break; + } + + Matrix_Scale(0.87f, 0.87f, 1.0f, MTXMODE_APPLY); + } + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h index 90c209b31..411c4b17f 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h @@ -2,16 +2,35 @@ #define Z_EN_BBFALL_H #include "global.h" +#include "objects/object_bb/object_bb.h" struct EnBbfall; typedef void (*EnBbfallActionFunc)(struct EnBbfall*, GlobalContext*); typedef struct EnBbfall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbfallActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbfallActionFunc actionFunc; + /* 0x24C */ u8 flameOpacity; + /* 0x24D */ u8 isBgCheckCollisionEnabled; + /* 0x24E */ s8 bodyPartDrawStatus; + /* 0x24F */ u8 drawDmgEffType; + /* 0x250 */ s16 timer; + /* 0x254 */ f32 flameScaleY; + /* 0x258 */ f32 flameScaleX; + /* 0x25C */ f32 drawDmgEffAlpha; + /* 0x260 */ f32 drawDmgEffScale; + /* 0x264 */ f32 drawDmgEffFrozenSteamScale; + /* 0x268 */ Vec3f flamePos[6]; + /* 0x2B0 */ Vec3f bodyPartsPos[5]; + /* 0x2EC */ Vec3f bodyPartsVelocity[5]; + /* 0x328 */ Gfx* limbDList; + /* 0x32C */ UNK_TYPE1 unk_32C[0x58]; + /* 0x384 */ ColliderJntSph collider; + /* 0x3A4 */ ColliderJntSphElement colliderElements[3]; } EnBbfall; // size = 0x464 extern const ActorInit En_Bbfall_InitVars; 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 38ab1c5d2..09ed84312 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -775,7 +775,6 @@ void EnBigpo_AdjustPoAlpha(EnBigpo* this, s32 alphaDiff) { this->actor.scale.x = newXYScale; this->actor.scale.z = newXYScale; this->actor.scale.y = (0.007f - (0.007f * lowerAlpha)) + 0.007f; - lowerAlpha = lowerAlpha; } else { Actor_SetScale(&this->actor, lowerAlpha * 0.007f); this->actor.world.pos.y = this->savedHeight + (lowerAlpha * 15.0f); diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index e7c6ebc6e..53198c594 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -299,7 +299,7 @@ void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCne01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -314,14 +314,14 @@ void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCne01_TransformLimbDraw, &this->enHy.actor); Matrix_InsertXRotation_s(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index bd7de1418..f8118e199 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -564,7 +564,7 @@ void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); func_80B3E834(this); if (!(this->unk_1CE & 0x200)) { - func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, 0, this->unk_1CE & 7); + func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, EXCH_ITEM_NONE, this->unk_1CE & 7); } func_80B3E460(this); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 7461239d3..da9f37237 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -6,7 +6,6 @@ #include "z_en_dekunuts.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -119,8 +118,8 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_00326C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubIdleAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_194 = ENDEKUNUTS_GET_FF00(&this->actor); @@ -166,7 +165,7 @@ void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD428(EnDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->unk_190 = Rand_S16Offset(100, 50); this->collider.dim.height = 5; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); @@ -221,7 +220,7 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD78C(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_002FA4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubLookAroundAnim); this->unk_190 = 2; this->actionFunc = func_808BD7D4; } @@ -241,7 +240,7 @@ void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD870(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); if (this->actionFunc == func_808BDA4C) { this->unk_190 = 4098; } else { @@ -280,7 +279,7 @@ void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDA08(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubSpitAnim); this->unk_190 = this->unk_194; this->actionFunc = func_808BDA4C; } @@ -324,7 +323,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubSpitAnim, -3.0f); if (this->unk_190 != 0) { this->unk_190--; } @@ -332,14 +331,14 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDC9C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->unk_190 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } void func_808BDCF0(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); @@ -367,7 +366,7 @@ void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDE7C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002DD4, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubUnburrowAnim, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); @@ -387,7 +386,7 @@ void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDF60(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_003780); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubRunAnim); this->unk_190 = 2; this->unk_18C = 0; this->collider.base.acFlags |= AC_ON; @@ -444,7 +443,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE1CC(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_0033E4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubPantingAnim); this->unk_190 = 3; this->actor.speedXZ = 0.0f; if (this->unk_18D != 0) { @@ -467,7 +466,7 @@ void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE294(EnDekunuts* this, s32 arg1) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_00259C, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubDamageAnim, -3.0f); if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { this->actor.speedXZ = 10.0f; if (arg1 != 0) { @@ -480,7 +479,7 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actionFunc = func_808BE358; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&object_dekunuts_Anim_00259C)); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&gDekuScrubDamageAnim)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { @@ -519,7 +518,7 @@ void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE484(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_002BD4); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubDieAnim); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); @@ -543,13 +542,13 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, 0x80); EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, 64, 10, - object_dekunuts_DL_001F50); + gDekuScrubFlowerFragmentDL); Actor_MarkForDeath(&this->actor); } } void func_808BE680(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); this->actionFunc = func_808BE6C4; } @@ -669,7 +668,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d f32 currentFrame; if (this->actionFunc == func_808BDA4C) { - if (limbIndex == 5) { + if (limbIndex == DEKU_SCRUB_LIMB_SNOUT) { currentFrame = this->skelAnime.curFrame; if (currentFrame <= 6.0f) { arg2 = 1.0f - (currentFrame * 0.0833f); @@ -688,7 +687,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return 0; } Matrix_Scale(arg1, arg2, arg3, MTXMODE_APPLY); - } else if ((limbIndex == 2) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { + } else if ((limbIndex == DEKU_SCRUB_LIMB_HEAD) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { rot->z = this->actor.world.rot.x; } } @@ -723,7 +722,7 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } } - if (limbIndex == 2) { + if (limbIndex == DEKU_SCRUB_LIMB_HEAD) { Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -739,7 +738,7 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); } - Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); + Gfx_DrawDListOpa(globalCtx, gDekuScrubFlowerDL); Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index 3e1af35eb..39d0dd954 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -2,6 +2,7 @@ #define Z_EN_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" struct EnDekunuts; @@ -26,8 +27,8 @@ typedef struct EnDekunuts { /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; - /* 0x196 */ Vec3s jointTable[10]; - /* 0x1D2 */ Vec3s morphTable[10]; + /* 0x196 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x1D2 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x210 */ f32 drawDmgEffAlpha; /* 0x214 */ f32 drawDmgEffScale; /* 0x218 */ f32 drawDmgEffFrozenSteamScale; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index dce730c48..23bd7e183 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -57,19 +57,32 @@ typedef struct { static D_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; +/** + * Stores the state for the dogs milling about at the Doggy Racetrack. + */ typedef struct { - s16 unk_00; - s16 unk_02; - s16 unk_04; -} D_8098C2A8_s; + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 textId; // The ID of the text to display when the dog is picked up +} RacetrackDogInfo; -static D_8098C2A8_s D_8098C2A8[] = { - { 3, 0, 0x3539 }, { 1, 1, 0x353A }, { 5, 2, 0x353B }, { 2, 3, 0x353C }, { 4, 4, 0x3538 }, - { 2, 5, 0x353E }, { 3, 6, 0x353F }, { 1, 7, 0x3540 }, { 1, 8, 0x3541 }, { 6, 9, 0x3542 }, - { 2, 10, 0x3543 }, { 3, 11, 0x3544 }, { 1, 12, 0x3545 }, { 4, 13, 0x3546 }, +/** + * A table of RacetrackDogInfo for every dog at the Doggy Racetrack. Note that the textId values + * in this table are updated by functions within this actor. + */ +static RacetrackDogInfo sRacetrackDogInfo[] = { + { DOG_COLOR_BEIGE, 0, 0x3539 }, { DOG_COLOR_WHITE, 1, 0x353A }, { DOG_COLOR_BLUE, 2, 0x353B }, + { DOG_COLOR_GRAY, 3, 0x353C }, { DOG_COLOR_BROWN, 4, 0x3538 }, { DOG_COLOR_GRAY, 5, 0x353E }, + { DOG_COLOR_BEIGE, 6, 0x353F }, { DOG_COLOR_WHITE, 7, 0x3540 }, { DOG_COLOR_WHITE, 8, 0x3541 }, + { DOG_COLOR_GOLD, 9, 0x3542 }, { DOG_COLOR_GRAY, 10, 0x3543 }, { DOG_COLOR_BEIGE, 11, 0x3544 }, + { DOG_COLOR_WHITE, 12, 0x3545 }, { DOG_COLOR_BROWN, 13, 0x3546 }, }; -static D_8098C2A8_s D_8098C2FC = { 0, -1, 0x353E }; +/** + * Stores the RacetrackDogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in func_80989E18. + */ +static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; static ColliderCylinderInit sCylinderInit = { { @@ -252,29 +265,29 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { s16 phi_a1; f32 sp30; - if (this->unk_1DC != NULL) { - phi_a1 = func_809895B4(this->unk_1DC, this->unk_1E0, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + phi_a1 = func_809895B4(this->path, this->unk_1E0, &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { phi_a1 = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->unk_1DC, this->unk_1E0)) { - if (this->unk_1E0 >= (this->unk_1DC->count - 1)) { + if (func_80989418(this, this->path, this->unk_1E0)) { + if (this->unk_1E0 >= (this->path->count - 1)) { this->unk_1E0 = 0; } else { this->unk_1E0++; } } - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -289,7 +302,7 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; Vec3f sp38; - if (((this->unk_286 + frame) % mod) == 0) { + if (((this->index + frame) % mod) == 0) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; @@ -329,13 +342,13 @@ void func_80989A9C(EnDg* this, f32 arg1) { void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { if (!(this->actor.bgCheckFlags & 0x20)) { - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { func_80989140(&this->skelAnime, sAnimations, 2); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { func_80989140(&this->skelAnime, sAnimations, 2); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { func_80989140(&this->skelAnime, sAnimations, 1); } else { func_80989140(&this->skelAnime, sAnimations, 2); @@ -345,38 +358,37 @@ void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { } void func_80989BF8(EnDg* this) { - if (this->unk_286 < 14) { - if (this->unk_286 % 2) { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + - ((gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); + if (this->index < 14) { + if (this->index % 2) { + sRacetrackDogInfo[this->index].textId = + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); + sRacetrackDogInfo[this->index].textId = + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); } - if ((D_8098C2A8[this->unk_286].unk_04 >= 0x3547) || (D_8098C2A8[this->unk_286].unk_04 < 0x3538)) { - D_8098C2A8[this->unk_286].unk_04 = 0x353E; + if ((sRacetrackDogInfo[this->index].textId >= 0x3547) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + sRacetrackDogInfo[this->index].textId = 0x353E; } - if (D_8098C2A8[this->unk_286].unk_04 == 0x353D) { - D_8098C2A8[this->unk_286].unk_04 = 0x3538; + if (sRacetrackDogInfo[this->index].textId == 0x353D) { + sRacetrackDogInfo[this->index].textId = 0x3538; } } void func_80989D38(EnDg* this, GlobalContext* globalCtx) { - if (this->unk_286 == 21) { + if (this->index == 21) { if (CURRENT_DAY == 1) { Message_StartTextbox(globalCtx, 0x91C, NULL); } else { Message_StartTextbox(globalCtx, 0x91E, NULL); } - } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - Message_StartTextbox(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); - } else if (this->unk_286 == 20) { + } else if ((this->index >= 0) && (this->index < 14)) { + Message_StartTextbox(globalCtx, sRacetrackDogInfo[this->index].textId, NULL); + } else if (this->index == 20) { Message_StartTextbox(globalCtx, 0x353D, NULL); } else { Message_StartTextbox(globalCtx, 0x627, NULL); @@ -384,7 +396,7 @@ void func_80989D38(EnDg* this, GlobalContext* globalCtx) { } void func_80989E18(EnDg* this, GlobalContext* globalCtx) { - D_8098C2A8_s* temp; + RacetrackDogInfo* temp; if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { this->actor.flags |= ACTOR_FLAG_8000000; @@ -397,7 +409,7 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->unk_290 = 1; - D_8098C2FC = D_8098C2A8[this->unk_286]; + sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; if (D_8098C2A0 == 0) { this->actor.flags |= ACTOR_FLAG_8000000; D_8098C2A0 = 1; @@ -427,13 +439,13 @@ s32 func_80989FC8(GlobalContext* globalCtx) { while (enemy != NULL) { if (enemy->actor.id == ACTOR_EN_DG) { if (enemy->actor.isTargeted) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; return true; } dist = enemy->actor.xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; minDist = dist; } } @@ -455,7 +467,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { func_80989FC8(globalCtx); } - if (this->unk_286 == D_8098C2A4.unk_00) { + if (this->index == D_8098C2A4.unk_00) { if (!(this->unk_280 & 0x20)) { this->unk_280 |= 0x20; func_80989140(&this->skelAnime, sAnimations, 1); @@ -467,7 +479,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } } } - } else if (this->unk_286 == D_8098C2A4.unk_00) { + } else if (this->index == D_8098C2A4.unk_00) { this->unk_280 &= ~0x20; D_8098C2A4.unk_00 = 99; func_80989ADC(this, globalCtx); @@ -1053,8 +1065,8 @@ void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { D_8098C2A0 = 0; this->unk_280 &= ~1; } - this->unk_288 = -1; - D_8098C2FC.unk_02 = this->unk_288; + this->selectedDogIndex = -1; + sSelectedRacetrackDogInfo.index = this->selectedDogIndex; this->unk_28A = 100; Actor_MoveWithGravity(&this->actor); this->unk_280 |= 0x10; @@ -1114,7 +1126,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = SubS_GetPathByIndex(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENDG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; @@ -1122,7 +1134,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_280 = 0; this->unk_28E = 20; this->unk_284 = 10; - this->unk_286 = ENDG_GET_3E0(&this->actor); + this->index = ENDG_GET_INDEX(&this->actor); this->unk_28C = 0; this->unk_290 = 0; if (globalCtx->sceneNum == SCENE_F01_B) { @@ -1144,7 +1156,7 @@ void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; - this->unk_288 = D_8098C2FC.unk_02; + this->selectedDogIndex = sSelectedRacetrackDogInfo.index; if (!(player->stateFlags1 & 0x20) || (globalCtx->sceneNum != SCENE_CLOCKTOWER)) { if (func_8098A1B4(this, globalCtx)) { func_8098A234(this, globalCtx); @@ -1194,25 +1206,31 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_8098C2A8[this->unk_286].unk_00) { - case 3: + switch (sRacetrackDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index 09732ba81..ca85d4a4d 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -4,12 +4,22 @@ #include "global.h" #include "objects/object_dog/object_dog.h" +typedef enum { + /* 0 */ DOG_COLOR_DEFAULT, // ends up just being treated as beige + /* 1 */ DOG_COLOR_WHITE, + /* 2 */ DOG_COLOR_GRAY, + /* 3 */ DOG_COLOR_BEIGE, + /* 4 */ DOG_COLOR_BROWN, + /* 5 */ DOG_COLOR_BLUE, + /* 6 */ DOG_COLOR_GOLD, +} DogColors; + struct EnDg; typedef void (*EnDgActionFunc)(struct EnDg*, GlobalContext*); -#define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) -#define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnDg { /* 0x000 */ Actor actor; @@ -17,15 +27,15 @@ typedef struct EnDg { /* 0x148 */ UNK_TYPE1 unk_148[0x4]; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; - /* 0x1DC */ Path* unk_1DC; + /* 0x1DC */ Path* path; /* 0x1E0 */ s32 unk_1E0; /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x280 */ u16 unk_280; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ s16 unk_288; + /* 0x286 */ s16 index; + /* 0x288 */ s16 selectedDogIndex; /* 0x28A */ s16 unk_28A; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 969c719fd..99c5d23d9 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -116,20 +116,20 @@ static AnimationInfoS sAnimations[] = { { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003180, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_002950, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubSpitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubDamageAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubDieAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubUnburrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubPantingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { @@ -179,7 +179,7 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, - this->morphTable, 11); + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); func_80A514F0(&this->skelAnime, 7); break; @@ -190,8 +190,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { break; case ENDNK_GET_3_2: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, NULL, this->jointTable, - this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, NULL, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); func_80A514F0(&this->skelAnime, 35); break; } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index ceffe3d93..e774c8965 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -149,8 +149,8 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { - if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, - &this->actor.world.pos, &sp88)) { + if (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, + &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); Matrix_RotateY(-crace->actor.home.rot.y, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&sp7C, &sp70); diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 27bd5e359..4df6085a5 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -410,7 +410,7 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk_322 & 0x400) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } - func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); + func_8013C964(&this->actor, globalCtx, sp2C, sp28, EXCH_ITEM_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); func_80B3CC80(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index d2a29442d..a192e24ef 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -455,7 +455,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); this->unk_394 = this->actor.xzDistToPlayer; func_80A52C6C(this, globalCtx); - func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, + func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, EXCH_ITEM_NONE, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; Actor_SetFocus(&this->actor, 46.0f); diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index e2c07cce7..6b7943504 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -554,7 +554,7 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { func_8092C934(this); func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); - func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7); + func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, EXCH_ITEM_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, globalCtx); func_8092C5C0(this); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 20a44c01d..a630a0dcb 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -293,7 +293,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.r = 255; this->unk_330.g = 10; this->unk_330.a = 200; - Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_314, &gOneVec3f); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_dodongo_Skel_008318, &object_dodongo_Anim_004C20, this->jointTable, this->morphTable, 31); diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 5b7091d02..efd901eb3 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -31,16 +31,6 @@ typedef enum { /* 3 */ DEEP_PYTHON_ANIMATION_IDLE } DeepPythonAnimationIndex; -typedef enum { - /* 0 */ DEEP_PYTHON_ACTION_IDLE, - /* 1 */ DEEP_PYTHON_ACTION_EXTEND, - /* 2 */ DEEP_PYTHON_ACTION_GRAB, - /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, - /* 4 */ DEEP_PYTHON_ACTION_RETREAT, - /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, - /* 6 */ DEEP_PYTHON_ACTION_DEAD, -} DeepPythonAction; - typedef enum { /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, /* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED, diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index c7ec4d81e..5fe44083b 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -6,6 +6,16 @@ #define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F) +typedef enum { + /* 0 */ DEEP_PYTHON_ACTION_IDLE, + /* 1 */ DEEP_PYTHON_ACTION_EXTEND, + /* 2 */ DEEP_PYTHON_ACTION_GRAB, + /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, + /* 4 */ DEEP_PYTHON_ACTION_RETREAT, + /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, + /* 6 */ DEEP_PYTHON_ACTION_DEAD, +} DeepPythonAction; + struct EnDragon; typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 676d4f701..c1cb3c64c 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -982,7 +982,6 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGb2* this = THIS; if (limbIndex == 7) { - limbIndex = limbIndex; Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 107c9a656..0c80ce319 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1363,7 +1363,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { f32 temp_f0; door = func_8094DF90(globalCtx, this->unk_258); - if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_3C4 != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1412,7 +1412,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_254; sp50 = this->unk_250; sp58 = this->actor.world.pos; @@ -1429,7 +1429,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_254 = sp54; this->unk_250 = sp50; this->unk_238 = sp58; @@ -1626,7 +1626,7 @@ void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { func_8094DFF8(this, globalCtx); func_8094E2D0(this); func_8094F2E8(this); - func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); + func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, EXCH_ITEM_NONE, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 57c8dc044..c05de7ab8 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -213,7 +213,7 @@ static AnimationInfoS sAnimations[] = { { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { +EnGoStruct* func_80A10FD0(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -233,7 +233,7 @@ EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, return ptr; } -void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { s32 pad; s32 i; s32 flag = false; @@ -279,7 +279,7 @@ void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { +void func_80A1143C(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -299,7 +299,7 @@ void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg } } -void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { static TexturePtr D_80A16644[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; @@ -355,7 +355,7 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { } #ifdef NON_MATCHING -void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; @@ -400,10 +400,11 @@ void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") #endif -void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { +void func_80A11BF8(EnGoStruct* ptr, f32 arg1) { f32 test; f32 test2; f32 x; @@ -449,7 +450,7 @@ void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { } #ifdef NON_MATCHING -void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx arg3[], u8 arg4) { +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4) { s32 i; u8 flag = false; @@ -484,6 +485,7 @@ void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx a CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") #endif @@ -1926,10 +1928,10 @@ void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { } else { phi_f0 = this->colliderCylinder.dim.radius + 40; } - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } else if ((this->unk_390 & 0x200) && (this->unk_3EC != 0)) { phi_f0 = this->colliderCylinder.dim.radius + 40; - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && @@ -1976,7 +1978,6 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - limbIndex = limbIndex; Matrix_GetStateTranslation(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); 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 cfd252d07..37f56469d 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -154,8 +154,8 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { func_80997AFC(this->unk_194, &this->unk_1FA); this->unk_1F4 = this->unk_1FA; - Math_Vec3f_Copy(&this->unk_1B0[0], &D_801C5DB0); - Math_Vec3f_Copy(&this->unk_1B0[1], &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); + Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); func_801A5080(0); if (this->actor.params == ENGS_1) { @@ -183,8 +183,8 @@ void func_80997D38(EnGs* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { - func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], 0, - 0x2000, 0x2000); + func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], + EXCH_ITEM_NONE, 0x2000, 0x2000); } } diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index 2434ca2cf..3a8cfdcd9 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -98,7 +98,7 @@ void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, - this->morphTable, OBJECT_DNK_LIMB_MAX); + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 1; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -355,7 +355,7 @@ s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnGuardNuts* this = THIS; - if (limbIndex == OBJECT_DNK_LIMB_HEAD) { + if (limbIndex == DEKU_PALACE_GUARD_LIMB_HEAD) { rot->x += this->headRot.x; rot->y += this->headRot.y; rot->z += this->headRot.z; diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h index 59f885563..4a42e4e5a 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h @@ -11,8 +11,8 @@ typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); typedef struct EnGuardNuts { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; - /* 0x1CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; /* 0x20C */ EnGuardNutsActionFunc actionFunc; /* 0x210 */ s16 eyeState; /* 0x212 */ s16 blinkTimer; 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 440bfef00..cc724c938 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -4555,7 +4555,6 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { if (this->type == HORSE_2) { Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } else { - curFrame = curFrame; Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index 7f847cf08..ed747c640 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -702,7 +702,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { f32 temp; s32 pad; - if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_3EC != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -748,7 +748,7 @@ s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_294; sp50 = this->unk_290; sp58 = this->actor.world.pos; @@ -765,7 +765,7 @@ s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_294 = sp54; this->unk_290 = sp50; this->unk_278 = sp58; @@ -918,7 +918,7 @@ void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); - func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, 0, this->unk_3D0 & 7); + func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, EXCH_ITEM_NONE, this->unk_3D0 & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BF1354(this, globalCtx); 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 8d2f416a7..c80b9432c 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3956,21 +3956,14 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { Vec3f sp4C; Vec3f sp40; s16 diff; - s8 temp_v1; + s16 pad; s16 sp3A; - s8 temp_v0; + s16 pad2; func_80B44700(this); func_80B44EFC(this, globalCtx); func_80B43E6C(this, 6, 2000, 100); - if (1) {} - temp_v1 = this->pathIndex; - temp_v0 = this->endPoint; - phi_a2 = temp_v0 - 1; - if (temp_v1 < temp_v0) { - phi_a2 = temp_v1; - } else if (temp_v1_3) { - } + phi_a2 = ((this->pathIndex < this->endPoint) ? this->pathIndex : this->endPoint - 1); Math_Vec3s_ToVec3f(&sp4C, &this->pathPoints[phi_a2]); Math_Vec3s_ToVec3f(&sp40, &this->pathPoints[phi_a2 + 1]); diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 392d8091e..5c57c883f 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -379,7 +379,7 @@ void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + 30; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_340 & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_340 & 7); if (this->unk_1D8.unk_00 != 2) { Actor_MoveWithGravity(&this->actor); diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 07b9e8db0..73a559a70 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -104,7 +104,7 @@ void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, - this->morphTable, OBJECT_DNK_LIMB_MAX); + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -169,6 +169,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); } + //! @bug sp30 is uninitialised if path == NULL. Fix by enclosing everything in the path NULL check. if (sp30 < 10.0f) { if (this->path != NULL) { this->currentPathIndex++; @@ -181,6 +182,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { } } } + Math_SmoothStepToS(&this->actor.shape.rot.y, sp34, 1, 0x1388, 0); this->actor.world.rot.y = this->actor.shape.rot.y; } diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index c06f0e2cd..e6eb6597a 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -15,8 +15,8 @@ typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); typedef struct EnLookNuts { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; - /* 0x01CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 0x0188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x01CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; /* 0x020C */ EnLookNutsActionFunc actionFunc; /* 0x0210 */ Path *path; /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path 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 bd92db4bc..5847aa897 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 @@ -22,7 +22,6 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx); s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupKeepLookingForRomani(EnMaYto* this); void EnMaYto_KeepLookingForRomani(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_SetupDefaultWait(EnMaYto* this); void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this); @@ -44,7 +43,6 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this); void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this); void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunGiveReward(EnMaYto* this); void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx); @@ -53,7 +51,6 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this); void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this); - void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this); void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx); @@ -68,9 +65,8 @@ void func_80B90E50(EnMaYto* this, s16); void EnMaYto_SetRomaniFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthIndex); void EnMaYto_InitFaceExpression(EnMaYto* this); -s32 EnMaYto_HasSpokeToPlayerToday(); - -s32 EnMaYto_HasSpokeToPlayer(void); +s32 EnMaYto_HasSpokenToPlayerToday(void); +s32 EnMaYto_HasSpokenToPlayer(void); void EnMaYto_SetTalkedFlag(void); const ActorInit En_Ma_Yto_InitVars = { @@ -1129,7 +1125,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x3394, &this->actor); this->textId = 0x3394; } else { @@ -1140,7 +1136,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } } } else if (CURRENT_DAY == 3) { - if (EnMaYto_HasSpokeToPlayerToday()) { + if (EnMaYto_HasSpokenToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x33C5, &this->actor); this->textId = 0x33C5; @@ -1186,7 +1182,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x339F, &this->actor); this->textId = 0x339F; } else { @@ -1198,7 +1194,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 2: - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); @@ -1210,7 +1206,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 3: - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); @@ -1249,7 +1245,7 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); Message_StartTextbox(globalCtx, 0x33B3, &this->actor); @@ -1357,7 +1353,7 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { } } -s32 EnMaYto_HasSpokeToPlayerToday(void) { +s32 EnMaYto_HasSpokenToPlayerToday(void) { switch (CURRENT_DAY) { case 1: if (gSaveContext.save.weekEventReg[13] & 4) { @@ -1380,7 +1376,7 @@ s32 EnMaYto_HasSpokeToPlayerToday(void) { return false; } -s32 EnMaYto_HasSpokeToPlayer(void) { +s32 EnMaYto_HasSpokenToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 2736fc71a..21f9487ad 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1086,7 +1086,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (arg2->unk0 == 24) { Flags_UnsetSwitch(globalCtx, 0); Flags_UnsetSwitch(globalCtx, 1); - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_368 = 60.0f; func_80AF7E98(this, 9); } @@ -1274,7 +1274,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_356 = 0; this->unk_368 = 40.0f; @@ -1409,7 +1409,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Vec3f* sp28; f32 temp; - if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_374 != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1457,7 +1457,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_254; sp50 = this->unk_250; sp58 = this->actor.world.pos; @@ -1474,7 +1474,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_254 = sp54; this->unk_250 = sp50; this->unk_238 = sp58; diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 1cd7a4f83..29dc269d4 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -219,7 +219,7 @@ void func_80B1A768(EnPoSisters* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_2EC, 170.0f, 10.0f); } sp20 = this->unk_2EC; - } else if (this->unk_18D != 0) { + } else if (this->unk_18D != 0) { // An else would be sufficient sp20 = this->actor.parent->xzDistToPlayer; } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 0166ed423..e6fb2535a 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -9,6 +9,7 @@ */ #include "z_en_racedog.h" +#include "overlays/actors/ovl_En_Dg/z_en_dg.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) @@ -19,26 +20,63 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24E14(EnRacedog* this); -void func_80B24F08(EnRacedog* this); -void func_80B251EC(EnRacedog* this); -void func_80B252F8(EnRacedog* this); -void func_80B2538C(EnRacedog* this); -void func_80B25448(EnRacedog* this); -s32 func_80B25490(EnRacedog* this, Vec2f* arg1); -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx); -void func_80B256BC(EnRacedog* this); +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_UpdateTextId(EnRacedog* this); +void EnRacedog_UpdateSpeed(EnRacedog* this); +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this); +void EnRacedog_UpdateRaceVariables(EnRacedog* this); +void EnRacedog_CheckForFinish(EnRacedog* this); +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this); +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* arg1); +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_PlayWalkSfx(EnRacedog* this); +/** + * Dogs can be in three conditions, which is indicated by the message it says when + * you pick it up prior to entering the race. + * If it starts with "Ruff!", it's in good condition. + * If it starts with "Rrr-Ruff!", it's in normal condition. + * If it starts with "Hoo-whine", it's in bad condition. + * These text boxes are grouped up like so: + * - 0x3538 - 0x353D: Good condition + * - 0x353E - 0x3541: Normal condition + * - 0x3542 - 0x3546: Bad condition + */ +#define DOG_IS_IN_GOOD_CONDITION(this) (sDogInfo[this->index].textId < 0x353E) +#define DOG_IS_IN_BAD_CONDITION(this) (sDogInfo[this->index].textId >= 0x3542) + +typedef enum { + /* 0 */ RACEDOG_ANIMATION_IDLE, + /* 1 */ RACEDOG_ANIMATION_WALK_1, + /* 2 */ RACEDOG_ANIMATION_RUN, + /* 3 */ RACEDOG_ANIMATION_BARK, + /* 4 */ RACEDOG_ANIMATION_SIT_DOWN_1, + /* 5 */ RACEDOG_ANIMATION_SIT_DOWN_2, + /* 6 */ RACEDOG_ANIMATION_LYING_DOWN_START_1, + /* 7 */ RACEDOG_ANIMATION_LYING_DOWN_LOOP, + /* 8 */ RACEDOG_ANIMATION_LYING_DOWN_START_2, + /* 9 */ RACEDOG_ANIMATION_LYING_DOWN_START_3, + /* 10 */ RACEDOG_ANIMATION_LYING_DOWN_START_4, + /* 11 */ RACEDOG_ANIMATION_WALK_2, + /* 12 */ RACEDOG_ANIMATION_JUMP, + /* 13 */ RACEDOG_ANIMATION_LONG_JUMP, + /* 14 */ RACEDOG_ANIMATION_JUMP_2, + /* 15 */ RACEDOG_ANIMATION_WALK_3, + /* 16 */ RACEDOG_ANIMATION_MAX +} RacedogAnimationIndex; + +/** + * Stores various information for each dog in the race, mostly related to speed. + */ typedef struct { - f32 unk_00; - f32 unk_04; - s16 unk_08; - s16 unk_0A; - s16 unk_0C; - s16 unk_0E; -} UnkRacedogStruct; + f32 sprintSpeedMultiplier; // Target speed is multiplied by this when the dog is in the last 1/4 of the race + f32 goodConditionSpeedMultiplier; // Target speed is multiplied by this if the dog is in good condition + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 pointToUseSecondBaseSpeed; // When the dog is at or after this point, the second value in sBaseSpeeds is used + s16 textId; // Used to determine the dog's condition +} RaceDogInfo; const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, @@ -52,31 +90,65 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -static s16 D_80B25D40 = 0; +static s16 sNumberOfDogsFinished = 0; -static s16 D_80B25D44 = -1; +/** + * The furthest point along the race track path that any dog has reached. + */ +static s16 sFurthestPoint = -1; -static s16 D_80B25D48 = 0; +/** + * Starts counting up as soon as the first-place dog gets 3/4ths of the way through the race track, + * and stops counting up as soon as the first-place dog finishes. Used to scale up the sprint + * multiplier in EnRacedog_CalculateFinalStretchTargetSpeed. + */ +static s16 sSprintTimer = 0; -static s16 D_80B25D4C = -1; +/** + * The index of the dog currently in first place. It's determined by checking, for each dog on the track, + * if its current point along the race track path is greater than or equal to sFurthestPoint. + */ +static s16 sFirstPlaceIndex = -1; -static f32 D_80B25D50[][2] = { +/** + * The base speeds for each dog indexed by its color. The two values are used during different parts of the race. + * - At the very start of the race, all dogs will use the first value for their color, but only for a single point + * along the race track's path. After that, they will have a base speed of 5.0, regardless of what's in the table + * for their color. The sole exception to this is the blue dog, who will use its first value for the entire + * first 1/4th of the race. + * - For the last 3/4ths of the race, all dogs will check to see if their current point along the race track path is + * greater than or equal to the pointToUseSecondBaseSpeed for their RaceDogInfo. If it is, then they will use the + * second value for their color as their base speed; otherwise, they will use 5.0. + */ +static f32 sBaseSpeeds[][2] = { { 0.0f, 0.0f }, { 5.0f, 5.5f }, { 5.0f, 5.0f }, { 5.5f, 5.0f }, { 4.5f, 5.5f }, { 6.0f, 4.0f }, { 4.0f, 6.0f }, }; -static UnkRacedogStruct D_80B25D88[] = { - { -1.0f, 1.20000004768f, 3, 0, 9, 0x3539 }, { -1.0f, 1.20000004768f, 1, 1, 9, 0x353A }, - { -1.0f, 1.20000004768f, 5, 2, 10, 0x353B }, { -1.0f, 1.20000004768f, 2, 3, 9, 0x353C }, - { -1.0f, 1.20000004768f, 4, 4, 8, 0x353D }, { -1.0f, 1.20000004768f, 2, 5, 9, 0x353E }, - { -1.0f, 1.20000004768f, 3, 6, 9, 0x353F }, { -1.0f, 1.20000004768f, 1, 7, 9, 0x3540 }, - { -1.0f, 1.20000004768f, 1, 8, 9, 0x3541 }, { -1.0f, 1.20000004768f, 6, 9, 8, 0x3542 }, - { -1.0f, 1.20000004768f, 2, 10, 9, 0x3543 }, { -1.0f, 1.20000004768f, 3, 11, 9, 0x3544 }, - { -1.0f, 1.20000004768f, 1, 12, 9, 0x3545 }, { -1.0f, 1.20000004768f, 4, 13, 8, 0x3546 }, +/** + * A table of RaceDogInfo for every dog in the race. Note that the sprintSpeedMultiplier and + * textId values in this table are updated by functions within this actor. + */ +static RaceDogInfo sDogInfo[] = { + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 0, 9, 0x3539 }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 1, 9, 0x353A }, + { -1.0f, 1.2f, DOG_COLOR_BLUE, 2, 10, 0x353B }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 3, 9, 0x353C }, + { -1.0f, 1.2f, DOG_COLOR_BROWN, 4, 8, 0x353D }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 5, 9, 0x353E }, + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 6, 9, 0x353F }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 7, 9, 0x3540 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 8, 9, 0x3541 }, { -1.0f, 1.2f, DOG_COLOR_GOLD, 9, 8, 0x3542 }, + { -1.0f, 1.2f, DOG_COLOR_GRAY, 10, 9, 0x3543 }, { -1.0f, 1.2f, DOG_COLOR_BEIGE, 11, 9, 0x3544 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 12, 9, 0x3545 }, { -1.0f, 1.2f, DOG_COLOR_BROWN, 13, 8, 0x3546 }, }; -static UnkRacedogStruct D_80B25E68 = { -1.0f, 1.0, 0, -1, 0, 0x353E }; +/** + * Stores the RacedogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sDogInfo in EnRacedog_Init. + */ +static RaceDogInfo sSelectedDogInfo = { -1.0f, 1.0, DOG_COLOR_DEFAULT, -1, 0, 0x353E }; -static Vec2f D_80B25E78[] = { +/** + * The XZ-coordinates used to determine if the dog is inside the finish line. + * They're a little bit bigger than the in-game visual. + */ +static Vec2f sFinishLineCoordinates[] = { { -3914.0f, 1283.0f }, { -3747.0f, 1104.0f }, { -3717.0f, 1169.0f }, @@ -140,7 +212,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS D_80B25EF0[] = { +static AnimationInfoS sAnimations[] = { { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, @@ -155,21 +227,21 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80B24630(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { +void EnRacedog_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 index) { f32 frameCount; - arg1 += arg2; - if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animation); + animationInfo += index; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = arg1->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, - arg1->mode, arg1->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_UpdateCollision(EnRacedog* this, GlobalContext* globalCtx) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; @@ -177,40 +249,44 @@ void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); } -s16 func_80B2478C(Path* path, s32 arg1, Vec3f* pos, f32* arg3) { +/** + * Returns the Y-rotation the dog should have to move to the next point along the race track path. + * There is a small degree of randomness incorporated into this angle. + */ +s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { Vec3s* point; - f32 phi_f14; - f32 sp1C; + f32 xDiffRand; + f32 zDiffRand; f32 xDiff; f32 zDiff; if (path != NULL) { point = Lib_SegmentedToVirtual(path->points); - point = &point[arg1]; - phi_f14 = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; - sp1C = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + point = &point[pointIndex]; + xDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + zDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; xDiff = point->x - pos->x; zDiff = point->z - pos->z; } else { - phi_f14 = 0.0f; - sp1C = 0.0f; + xDiffRand = 0.0f; + zDiffRand = 0.0f; xDiff = 0.0f; zDiff = 0.0f; } - *arg3 = SQ(xDiff) + SQ(zDiff); - return RADF_TO_BINANG(Math_Acot2F(sp1C, phi_f14)); + *distSQ = SQ(xDiff) + SQ(zDiff); + return RADF_TO_BINANG(Math_Acot2F(zDiffRand, xDiffRand)); } -void func_80B248B8(EnRacedog* this, Vec3f* arg1) { - f32 sp20; - f32 sp1C; +void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { + f32 ny; + f32 nz; if (this->actor.floorPoly != NULL) { - sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); } } @@ -225,43 +301,51 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1E0 = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; - if (ENRACEDOG_GET_3E0(&this->actor) < 14) { - this->unk_290 = ENRACEDOG_GET_3E0(&this->actor); + if (ENRACEDOG_GET_INDEX(&this->actor) < 14) { + this->index = ENRACEDOG_GET_INDEX(&this->actor); } else { Actor_MarkForDeath(&this->actor); } - this->unk_2BC = 0xFF; - this->unk_2C0 = 0x32; - this->unk_288 = 0xC; - this->unk_2A0.x = 0.0f; - this->unk_2A0.y = 0.0f; - this->unk_2A0.z = 0.0f; - this->unk_2C4 = 1.0f; + this->selectionArrowGreenPrimColor = 255; + this->selectionArrowGreenEnvColor = 50; + this->selectionArrowTimer = 12; + this->prevRot.x = 0.0f; + this->prevRot.y = 0.0f; + this->prevRot.z = 0.0f; + this->selectionArrowScale = 1.0f; - if ((D_80B25D88[this->unk_290].unk_0E >= 0x353F) && (this->unk_290 == (s16)Rand_ZeroFloat(20.0f))) { - this->unk_28C = 5; + // The first part of this check is a bit strange. If they intended to check for dogs that were + // in good condition, they should've stopped at 0x353D instead of 0x353E. Additionally, this + // runs before EnRacedog_UpdateTextId is called to set the text IDs to their "correct" values, + // meaning that the IDs are just whatever their default values in sDogInfo are. As a result, + // the blue dog, one beige dog, one white dog, one brown dog, and two gray dogs never bother + // to do the random 1/20 check here, regardless of anything else. + if ((sDogInfo[this->index].textId > 0x353E) && (this->index == (s16)Rand_ZeroFloat(20.0f))) { + this->extraTimeBeforeRaceStart = 5; } else { - this->unk_28C = 0; + this->extraTimeBeforeRaceStart = 0; } - this->unk_28A = 60; - this->unk_28A += this->unk_28C; - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; - this->unk_29C = 0; - this->unk_2B8 = -1; + this->raceStartTimer = 60; + this->raceStartTimer += this->extraTimeBeforeRaceStart; + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; + this->raceStatus = RACEDOG_RACE_STATUS_BEFORE_POINT_9; + this->pointForCurrentTargetSpeed = -1; - func_80B24E14(this); + EnRacedog_UpdateTextId(this); this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_20; - D_80B25E68 = D_80B25D88[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; - this->unk_292 = D_80B25E68.unk_0A; - func_80B24630(&this->skelAnime, D_80B25EF0, 0); - D_80B25EF0->playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; - this->actionFunc = func_80B24C14; + + sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->selectedDogIndex = sSelectedDogInfo.index; + + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_IDLE); + sAnimations[RACEDOG_ANIMATION_IDLE].playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = EnRacedog_RaceStart; } void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -270,125 +354,150 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_v1; - - if (this->unk_28A == 0) { - phi_v1 = 0; - } else { - this->unk_28A--; - phi_v1 = this->unk_28A; - } - - if (phi_v1 == 0) { - this->unk_28A = Rand_S16Offset(50, 50); - if (this->unk_28C == 0) { +/** + * This function makes the dog wait at the starting line until the race actually begins. + * It's also responsible for playing the starting shot sound once the race begins. + */ +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx) { + if (DECR(this->raceStartTimer) == 0) { + this->raceStartTimer = Rand_S16Offset(50, 50); + if (this->extraTimeBeforeRaceStart == 0) { play_sound(NA_SE_SY_START_SHOT); } - func_80B24630(&this->skelAnime, D_80B25EF0, 2); - this->actionFunc = func_80B24CB4; + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_RUN); + this->actionFunc = EnRacedog_Race; } } -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_a1; - f32 sp30; +/** + * This function handles the dog's behavior and state for the entire time the race is going. + */ +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSq; this->collider.dim.radius = 15; - if (this->unk_1E0 != 0) { - phi_a1 = func_80B2478C(this->unk_1E0, this->unk_1E8, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + yRotation = EnRacedog_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (sp30 <= 2500.0f) { - this->unk_1E8++; - if (this->unk_1E8 >= (this->unk_1E0->count - 1)) { - this->unk_1E8 = 0; + if (distSq <= SQ(50.0f)) { + this->currentPoint++; + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } } - func_80B24F08(this); - if ((this->unk_1E8 >= ((this->unk_1E0->count / 4) * 3)) && (this->unk_290 == D_80B25D4C)) { - D_80B25D48++; + EnRacedog_UpdateSpeed(this); + + // Putting this after EnRacedog_UpdateSpeed will ensure that when EnRacedog_CalculateFinalStretchTargetSpeed + // is called for the first-place dog, the sprint timer will be 0, so the first-place dog will be guaranteed + // to have a sprint speed multiplier of 1. + if ((this->currentPoint >= ((this->path->count / 4) * 3)) && (this->index == sFirstPlaceIndex)) { + sSprintTimer++; } - func_80B252F8(this); - func_80B2538C(this); + EnRacedog_UpdateRaceVariables(this); + EnRacedog_CheckForFinish(this); Actor_MoveWithGravity(&this->actor); } - func_80B25448(this); - func_80B256BC(this); - func_80B255AC(this, globalCtx); + EnRacedog_UpdateRunAnimationPlaySpeed(this); + EnRacedog_PlayWalkSfx(this); + EnRacedog_SpawnFloorDustRing(this, globalCtx); } -void func_80B24E14(EnRacedog* this) { - if (this->unk_290 % 2) { - D_80B25D88[this->unk_290].unk_0E = - (((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; +/** + * Updates the text ID in sDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it so sDogInfo can be used in other functions to determine + * the condition of the dog. + */ +void EnRacedog_UpdateTextId(EnRacedog* this) { + if (this->index % 2) { + sDogInfo[this->index].textId = + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; } else { - D_80B25D88[this->unk_290].unk_0E = - ((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + sDogInfo[this->index].textId = + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; } - if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { - D_80B25D88[this->unk_290].unk_0E = 0x353E; + // This makes sure the text ID is something in the range of 0x3539 to 0x3547. + if ((sDogInfo[this->index].textId >= 0x3547) || (sDogInfo[this->index].textId < 0x3539)) { + sDogInfo[this->index].textId = 0x353E; } - if (D_80B25D88[this->unk_290].unk_0E == 0x3547) { - D_80B25D88[this->unk_290].unk_0E = 0x3538; + + // Actual valid text IDs for the race dogs range between 0x3538 and 0x3546, so this + // code makes the two ranges match up. Perhaps the text got shifted? + if (sDogInfo[this->index].textId == 0x3547) { + sDogInfo[this->index].textId = 0x3538; } } -void func_80B24F08(EnRacedog* this) { - s32 temp_a0; - s32 temp_v1 = this->unk_1E0->count; +/** + * Responsible for calculating the dog's target speed and for making its actual speed + * approach the target speed. + */ +void EnRacedog_UpdateSpeed(EnRacedog* this) { + s32 quarterPathCount; + s32 pathCount = this->path->count; - if (this->unk_2B8 < this->unk_1E8) { - this->unk_2B8 = this->unk_1E8; - if (this->unk_1E8 == 0) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + // Only update the target speed if the dog is at a further point along the path + // than it was when the target speed was last updated. + if (this->pointForCurrentTargetSpeed < this->currentPoint) { + this->pointForCurrentTargetSpeed = this->currentPoint; + if (this->currentPoint == 0) { + // The dog is at the very start of the race track. + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; } else { - temp_a0 = temp_v1 / 4; - if (this->unk_1E8 < temp_a0) { - if (D_80B25D88[this->unk_290].unk_08 == 5) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0] + randPlusMinusPoint5Scaled(1.0f); + quarterPathCount = pathCount / 4; + if (this->currentPoint < quarterPathCount) { + // The dog is past the very start, but is still less than 1/4th of the way through the race track. + // This code will give the blue dog a higher base speed than any other dog (6.0 instead of 5.0). + if (sDogInfo[this->index].color == DOG_COLOR_BLUE) { + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0] + randPlusMinusPoint5Scaled(1.0f); } else { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } - } else if (this->unk_1E8 < (temp_a0 * 3)) { - if (this->unk_1E8 < D_80B25D88[this->unk_290].unk_0C) { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else if (this->currentPoint < (quarterPathCount * 3)) { + // The dog is between 1/4th and 3/4ths of the way through the race track. + if (this->currentPoint < sDogInfo[this->index].pointToUseSecondBaseSpeed) { + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } else { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][1] + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][1] + randPlusMinusPoint5Scaled(1.0f); - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } - } else if (this->unk_1E8 < temp_v1) { - func_80B251EC(this); + } else if (this->currentPoint < pathCount) { + // The dog is more than 3/4ths of the way through the race track. + EnRacedog_CalculateFinalStretchTargetSpeed(this); } else { - this->unk_298 = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + this->targetSpeed = randPlusMinusPoint5Scaled(1.0f) + 5.0f; } } } - if ((this->unk_1E8 != 0) || (this->unk_29C != 0)) { + // Seemingly the only point of this raceStatus check is to ensure this code still runs when + // the dog has finished the race and is at point 0 along their second lap. + if ((this->currentPoint != 0) || (this->raceStatus != RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { this->actor.shape.rot.y = this->actor.world.rot.y; } - Math_ApproachF(&this->actor.speedXZ, this->unk_298, 0.5f, 3.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetSpeed, 0.5f, 3.0f); - if (this->unk_290 == this->unk_292) { + // The dog that the player has selected has a slightly higher max speed than the other dogs. + if (this->index == this->selectedDogIndex) { if (this->actor.speedXZ > 7.5f) { this->actor.speedXZ = 7.5f; } @@ -399,66 +508,90 @@ void func_80B24F08(EnRacedog* this) { } } -void func_80B251EC(EnRacedog* this) { - f32 temp; +/** + * This function handles updating targetSpeed for the final stretch of the race, + * where the dog starts sprinting towards the finish line. + */ +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this) { + f32 sprintSpeedMultiplier; - if (D_80B25D88[this->unk_290].unk_00 == -1.0f) { - if (D_80B25D48 < 100.0f) { - D_80B25D88[this->unk_290].unk_00 = 200.0f / (200.0f - D_80B25D48); + // Dogs are only allowed to update their sprintSpeedMultiplier once, so its value will + // depend on the value of sSprintTimer when they first hit the 3/4th mark on the track. + if (sDogInfo[this->index].sprintSpeedMultiplier == -1.0f) { + if (sSprintTimer < 100.0f) { + sDogInfo[this->index].sprintSpeedMultiplier = 200.0f / (200.0f - sSprintTimer); } else { - D_80B25D88[this->unk_290].unk_00 = 2.0f; + sDogInfo[this->index].sprintSpeedMultiplier = 2.0f; } } - if (D_80B25D88[this->unk_290].unk_0E < 0x3542) { - temp = D_80B25D88[this->unk_290].unk_00; - this->unk_298 = temp * D_80B25D50[D_80B25D88[this->unk_290].unk_08][1]; + if (!DOG_IS_IN_BAD_CONDITION(this)) { + sprintSpeedMultiplier = sDogInfo[this->index].sprintSpeedMultiplier; + this->targetSpeed = sprintSpeedMultiplier * sBaseSpeeds[sDogInfo[this->index].color][1]; } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } -void func_80B252F8(EnRacedog* this) { - if ((this->unk_1E8 >= 9) && (this->unk_29C == 0)) { - this->unk_29C = 1; +/** + * Responsible for updating the raceStatus variable for this dog, as well as updating the + * sFurthestPoint and sFirstPlaceIndex variables. + */ +void EnRacedog_UpdateRaceVariables(EnRacedog* this) { + if ((this->currentPoint >= 9) && (this->raceStatus == RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { + this->raceStatus = RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11; } - if ((this->unk_1E8 >= 0xB) && (this->unk_29C == 1)) { - this->unk_29C = 2; + if ((this->currentPoint >= 11) && (this->raceStatus == RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11)) { + this->raceStatus = RACEDOG_RACE_STATUS_AFTER_POINT_11; } - if (((this->unk_1E8 >= D_80B25D44) || (this->unk_29C <= 0)) && (this->unk_1E8 > D_80B25D44)) { - D_80B25D44 = this->unk_1E8; - D_80B25D4C = this->unk_290; + if (((this->currentPoint >= sFurthestPoint) || (this->raceStatus <= RACEDOG_RACE_STATUS_BEFORE_POINT_9)) && + (this->currentPoint > sFurthestPoint)) { + sFurthestPoint = this->currentPoint; + sFirstPlaceIndex = this->index; } } -void func_80B2538C(EnRacedog* this) { - if (func_80B25490(this, D_80B25E78) && this->unk_29C == 2) { - D_80B25D40++; - if (D_80B25D40 == 1) { +/** + * Checks to see if this dog has finished the race. This function is responsible for changing the + * music when the first dog finishes the race, and it is also responsible for updating the event + * flags with what position the player's selected dog finished in. + */ +void EnRacedog_CheckForFinish(EnRacedog* this) { + if (EnRacedog_IsOverFinishLine(this, sFinishLineCoordinates) && + this->raceStatus == RACEDOG_RACE_STATUS_AFTER_POINT_11) { + sNumberOfDogsFinished++; + if (sNumberOfDogsFinished == 1) { Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); play_sound(NA_SE_SY_START_SHOT); } - this->unk_29C = 3; - if (this->unk_290 == this->unk_292) { - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (D_80B25D40 * 8); + this->raceStatus = RACEDOG_RACE_STATUS_FINISHED; + if (this->index == this->selectedDogIndex) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (sNumberOfDogsFinished * 8); } } } -void func_80B25448(EnRacedog* this) { +/** + * Slows the dog's running speed animation if its speed is less than 3.0, and sets it + * to normal speed otherwise. + */ +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this) { if (this->actor.speedXZ < 3.0f) { - D_80B25EF0[2].playSpeed = 0.9f; + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 0.9f; } else { - D_80B25EF0[2].playSpeed = 1.0f; + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 1.0f; } } -s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { +/** + * Returns true if the dog's current position is in the finish line. + */ +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { f32 xDistToTopFront; f32 zDistToTopFront; f32 xDistToBottomFront; @@ -467,53 +600,57 @@ s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { f32 zDistToBottomFront; f32 zDistToTopBack; f32 xDistToTopBack; - f32 temp_f0; - f32 temp; + f32 frontPointsCrossProduct; + f32 crossProductTemp; - xDistToTopFront = this->actor.world.pos.x - arg1[0].x; - zDistToTopFront = this->actor.world.pos.z - arg1[0].z; - xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; - zDistToBottomFront = this->actor.world.pos.z - arg1[1].z; - xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; - zDistToBottomBack = this->actor.world.pos.z - arg1[2].z; - xDistToTopBack = this->actor.world.pos.x - arg1[3].x; - zDistToTopBack = this->actor.world.pos.z - arg1[3].z; + xDistToTopFront = this->actor.world.pos.x - finishLineCoordinates[0].x; + zDistToTopFront = this->actor.world.pos.z - finishLineCoordinates[0].z; + xDistToBottomFront = this->actor.world.pos.x - finishLineCoordinates[1].x; + zDistToBottomFront = this->actor.world.pos.z - finishLineCoordinates[1].z; + xDistToBottomBack = this->actor.world.pos.x - finishLineCoordinates[2].x; + zDistToBottomBack = this->actor.world.pos.z - finishLineCoordinates[2].z; + xDistToTopBack = this->actor.world.pos.x - finishLineCoordinates[3].x; + zDistToTopBack = this->actor.world.pos.z - finishLineCoordinates[3].z; - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); - if (temp_f0 * temp < 0.0f) { + // frontPointsCrossProduct is positive if the dog is to the left of the line formed by the front points + // crossProductTemp is positive if the dog is above the line formed by the bottom points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); - if (temp_f0 * temp < 0.0f) { + // crossProductTemp is positive if the dog is to the right of the line formed by the back points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); - if (temp_f0 * temp < 0.0f) { + // crossProductTemp is positive if the dog is below the line formed by the top points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } return true; } -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; - Vec3f sp38; + Vec3f pos; - if (((this->unk_290 + curFrame) % mod) == 0) { - sp38.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); - sp38.y = this->actor.world.pos.y; - sp38.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, true); + if (((this->index + curFrame) % mod) == 0) { + pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void func_80B256BC(EnRacedog* this) { +void EnRacedog_PlayWalkSfx(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { @@ -524,18 +661,20 @@ void func_80B256BC(EnRacedog* this) { void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp2C = { 0.0f, 0.0f, 0.0f }; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; - this->unk_292 = D_80B25E68.unk_0A; + this->selectedDogIndex = sSelectedDogInfo.index; this->actionFunc(this, globalCtx); - func_80B246F4(this, globalCtx); - func_80B248B8(this, &sp2C); - Math_ApproachF(&this->unk_2AC.x, sp2C.x, 0.2f, 0.1f); + EnRacedog_UpdateCollision(this, globalCtx); + EnRacedog_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); - if (this->unk_2A0.x > 0.0f) { - if ((this->unk_2AC.x < 0.0f) && (this->unk_2AC.x > -0.1f)) { + if (this->prevRot.x > 0.0f) { + if ((this->curRot.x < 0.0f) && (this->curRot.x > -0.1f)) { + // Moves to the part of the running animation where the dog has four feet + // on the ground and is about to lift its feet off the ground. this->skelAnime.curFrame = 4.0f; this->actor.velocity.y = 5.5f; } @@ -545,51 +684,43 @@ void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.curFrame = 0.0f; } - this->unk_2A0 = this->unk_2AC; + this->prevRot = this->curRot; SkelAnime_Update(&this->skelAnime); } -void func_80B2583C(EnRacedog* this) { - s16 phi_v1; - - if (this->unk_288 >= 7) { - this->unk_2BC -= 0x10; - this->unk_2C0 += 8; - this->unk_2C4 += 0.05f; +void EnRacedog_UpdateSelectionArrow(EnRacedog* this) { + if (this->selectionArrowTimer > 6) { + this->selectionArrowGreenPrimColor -= 16; + this->selectionArrowGreenEnvColor += 8; + this->selectionArrowScale += 0.05f; } else { - this->unk_2BC += 0x10; - this->unk_2C0 -= 8; - this->unk_2C4 -= 0.05f; + this->selectionArrowGreenPrimColor += 16; + this->selectionArrowGreenEnvColor -= 8; + this->selectionArrowScale -= 0.05f; } - if (this->unk_288 == 0) { - phi_v1 = 0; - } else { - this->unk_288--; - phi_v1 = this->unk_288; - } - - if (phi_v1 == 0) { - this->unk_288 = 0xC; + if (DECR(this->selectionArrowTimer) == 0) { + this->selectionArrowTimer = 12; } } -void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { - Vec3s sp48 = gZeroVec3s; - s32 phi_v0 = (this->unk_290 == this->unk_292) ? true : false; +void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { + Vec3s rotation = gZeroVec3s; + s32 shouldDrawSelectionArrow = (this->index == this->selectedDogIndex) ? true : false; - if (phi_v0) { + if (shouldDrawSelectionArrow) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - func_80B2583C(this); + EnRacedog_UpdateSelectionArrow(this); Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, - this->actor.world.pos.z, &sp48); + this->actor.world.pos.z, &rotation); gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->unk_2BC, 0, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); - Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->selectionArrowGreenPrimColor, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, this->selectionArrowGreenEnvColor, 0, 255); + Matrix_Scale(this->selectionArrowScale * 2.0f, this->selectionArrowScale * 2.0f, + this->selectionArrowScale * 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowEmptyDL); gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowDL); @@ -606,14 +737,14 @@ s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; + Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&focusOffset, &this->actor.focus.pos); } if (limbIndex == DOG_LIMB_TAIL) { - func_80B258D8(this, globalCtx); + EnRacedog_DrawSelectionArrow(this, globalCtx); } } @@ -626,32 +757,38 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_80B25D88[this->unk_290].unk_08) { - case 3: + switch (sDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; } Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->unk_2AC.x); + Matrix_RotateStateAroundXAxis(this->curRot.x); Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 19f7af7a5..a4406b04c 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -4,9 +4,20 @@ #include "global.h" #include "objects/object_dog/object_dog.h" -#define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENRACEDOG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) #define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) +/** + * The main point of this seems to be some very light anti-cheat detection. The dog + * must progress through these statuses in a linear order to finish the race. + */ +typedef enum { + /* 0 */ RACEDOG_RACE_STATUS_BEFORE_POINT_9, + /* 1 */ RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11, + /* 2 */ RACEDOG_RACE_STATUS_AFTER_POINT_11, + /* 3 */ RACEDOG_RACE_STATUS_FINISHED +} RacedogRaceStatus; + struct EnRacedog; typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); @@ -18,26 +29,26 @@ typedef struct EnRacedog { /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; - /* 0x1E0 */ Path* unk_1E0; + /* 0x1E0 */ Path* path; /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; - /* 0x1E8 */ s32 unk_1E8; + /* 0x1E8 */ s32 currentPoint; /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; - /* 0x288 */ s16 unk_288; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; + /* 0x288 */ s16 selectionArrowTimer; + /* 0x28A */ s16 raceStartTimer; + /* 0x28C */ s16 extraTimeBeforeRaceStart; /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; + /* 0x290 */ s16 index; + /* 0x292 */ s16 selectedDogIndex; /* 0x294 */ UNK_TYPE1 unk_294[0x4]; - /* 0x298 */ f32 unk_298; - /* 0x29C */ s16 unk_29C; - /* 0x2A0 */ Vec3f unk_2A0; - /* 0x2AC */ Vec3f unk_2AC; - /* 0x2B8 */ s32 unk_2B8; - /* 0x2BC */ s32 unk_2BC; - /* 0x2C0 */ s32 unk_2C0; - /* 0x2C4 */ f32 unk_2C4; + /* 0x298 */ f32 targetSpeed; + /* 0x29C */ s16 raceStatus; + /* 0x2A0 */ Vec3f prevRot; + /* 0x2AC */ Vec3f curRot; + /* 0x2B8 */ s32 pointForCurrentTargetSpeed; + /* 0x2BC */ s32 selectionArrowGreenPrimColor; + /* 0x2C0 */ s32 selectionArrowGreenEnvColor; + /* 0x2C4 */ f32 selectionArrowScale; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index a32811620..4d880a389 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -1,7 +1,7 @@ /* * File: z_en_raf.c * Overlay: ovl_En_Raf - * Description: Carnivorous Lilypad + * Description: Carnivorous Lily Pad */ #include "z_en_raf.h" @@ -15,16 +15,58 @@ void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A171D8(EnRaf* this, GlobalContext* globalCtx); -void func_80A17464(EnRaf* this, GlobalContext* globalCtx); -void func_80A175E4(EnRaf* this, GlobalContext* globalCtx); -void func_80A178A0(EnRaf* this, GlobalContext* globalCtx); -void func_80A17C6C(EnRaf* this, GlobalContext* globalCtx); -void func_80A17D54(EnRaf* this, GlobalContext* globalCtx); -void func_80A17E1C(EnRaf* this, GlobalContext* globalCtx); -void func_80A180B4(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupIdle(EnRaf* this); +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupGrab(EnRaf* this); +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupChew(EnRaf* this); +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDissolve(EnRaf* this); +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDormant(EnRaf* this); +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, s16 timer); +void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAF_ANIMATION_IDLE, + /* 1 */ EN_RAF_ANIMATION_CLOSE, + /* 2 */ EN_RAF_ANIMATION_CHEW, + /* 3 */ EN_RAF_ANIMATION_SPIT, + /* 4 */ EN_RAF_ANIMATION_CONVULSE, + /* 5 */ EN_RAF_ANIMATION_DEATH, +} EnRafAnimationIndex; + +typedef enum { + /* 0 */ EN_RAF_ACTION_IDLE, + /* 1 */ EN_RAF_ACTION_GRAB, + /* 2 */ EN_RAF_ACTION_CHEW, + /* 3 */ EN_RAF_ACTION_THROW, + /* 4 */ EN_RAF_ACTION_EXPLODE, + /* 5 */ EN_RAF_ACTION_CONVULSE, + /* 6 */ EN_RAF_ACTION_DISSOLVE, + /* 7 */ EN_RAF_ACTION_DORMANT, +} EnRafAction; + +typedef enum { + /* 0 */ EN_RAF_GRAB_TARGET_PLAYER, + /* 1 */ EN_RAF_GRAB_TARGET_EXPLOSIVE, + /* 2 */ EN_RAF_GRAB_TARGET_GORON_PLAYER +} EnRafGrabTarget; + +typedef enum { + /* 0 */ EN_RAF_PETAL_SCALE_TYPE_DEAD, + /* 1 */ EN_RAF_PETAL_SCALE_TYPE_GRAB, + /* 2 */ EN_RAF_PETAL_SCALE_TYPE_CHEW, + /* 3 */ EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW +} EnRafPetalScaleType; -#if 0 const ActorInit En_Raf_InitVars = { ACTOR_EN_RAF, ACTORCAT_PROP, @@ -37,15 +79,71 @@ const ActorInit En_Raf_InitVars = { (ActorFunc)EnRaf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A18EE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 50, 10, -10, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A1939C = { +static u8 sTeethClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, +}; + +static u8 sTeethClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static u8 sPetalClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, +}; + +static u8 sPetalClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,65 +178,786 @@ static DamageTable D_80A1939C = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -#endif +/** + * Sets the `index`th pixel of the trap teeth texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelTeeth(u16* texture, u8* clearPixelTable, s32 index) { + if ((index < (8 * 8)) && (clearPixelTable[index] != 0)) { + texture[index] = 0; + } +} -extern ColliderCylinderInit D_80A18EE0; -extern DamageTable D_80A1939C; +/** + * Sets the `index`th pixel of the trap petal texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelPetal(u16* texture, u8* clearPixelTable, s32 index) { + if (clearPixelTable[index] != 0) { + texture[index] = 0; + } +} -extern UNK_TYPE D_06000108; -extern UNK_TYPE D_060024E0; -extern UNK_TYPE D_060032F8; +void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; + s32 pad; + s32 i; + CollisionHeader* colHeader = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D40.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gCarnivorousLilyPadCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.targetMode = 3; + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCarnivorousLilyPadSkel, &gCarnivorousLilyPadSpitAnim, + this->jointTable, this->morphTable, CARNIVOROUS_LILY_PAD_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D6C.s") + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &limbScale); + Math_Vec3f_Copy(&this->limbScale[i], &limbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Init.s") + this->dyna.actor.colChkInfo.damageTable = &sDamageTable; + this->dyna.actor.colChkInfo.health = BREG(1) + 2; + this->mainType = EN_RAF_GET_TYPE(&this->dyna.actor); + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->switchFlag = EN_RAF_GET_SWITCH_FLAG(&this->dyna.actor); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Destroy.s") + if (this->reviveTimer == 31) { + this->reviveTimer = -1; + } else { + this->reviveTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17060.s") + if (((this->switchFlag >= 0) || (this->mainType == EN_RAF_TYPE_DORMANT) || + (gSaveContext.save.weekEventReg[12] & 1)) && + ((Flags_GetSwitch(globalCtx, this->switchFlag)) || (this->mainType == EN_RAF_TYPE_DORMANT))) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1712C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A171D8.s") + EnRaf_SetupDormant(this); + } else { + this->bobPhase = Rand_ZeroFloat(1.0f) * 20000.0f; + Actor_SetScale(&this->dyna.actor, 0.01f); + EnRaf_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17414.s") +void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17464.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17530.s") +void EnRaf_ChangeAnimation(EnRaf* this, s32 index) { + static AnimationHeader* sAnimations[] = { + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadCloseAnim, &gCarnivorousLilyPadChewAnim, + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadConvulseAnim, &gCarnivorousLilyPadDeathAnim, + }; + static u8 sAnimationModes[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + }; + f32 startFrame = 0.0f; + f32 playSpeed = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A175E4.s") + this->endFrame = Animation_GetLastFrame(sAnimations[index]); + if (index == EN_RAF_ANIMATION_IDLE) { + startFrame = this->endFrame; + } else if (index == EN_RAF_ANIMATION_CLOSE) { + playSpeed = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17848.s") + Animation_Change(&this->skelAnime, sAnimations[index], playSpeed, startFrame, this->endFrame, + sAnimationModes[index], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A178A0.s") +void EnRaf_SetupIdle(EnRaf* this) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A179C8.s") + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_IDLE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17C6C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D14.s") + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->actionFunc = EnRaf_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D54.s") +/** + * Sits around waiting for the player or an explosive to get near in order to grab them. + */ +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* explosive; + f32 xDiff; + f32 yDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17DDC.s") + if (this->timer == 0) { + if ((player->transformation != PLAYER_FORM_DEKU) && + (this->dyna.actor.xzDistToPlayer < (BREG(48) + 80.0f) && (player->invincibilityTimer == 0) && + DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & 0x8000000) && + globalCtx->grabPlayer(globalCtx, player))) { + player->actor.parent = &this->dyna.actor; + this->grabTarget = EN_RAF_GRAB_TARGET_PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17E1C.s") + if (player->transformation == PLAYER_FORM_GORON) { + this->grabTarget = EN_RAF_GRAB_TARGET_GORON_PLAYER; + } else { + player->unk_AE8 = 50; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18080.s") + this->playerRotYWhenGrabbed = player->actor.world.rot.y; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A180B4.s") + if ((globalCtx->gameplayFrames % 2) == 0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Update.s") + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (explosive != NULL) { + // This check is pointless, since EnRaf is never in the explosive category. + if ((EnRaf*)explosive == this) { + explosive = explosive->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1859C.s") + xDiff = explosive->world.pos.x - this->dyna.actor.world.pos.x; + yDiff = explosive->world.pos.y - this->dyna.actor.world.pos.y; + zDiff = explosive->world.pos.z - this->dyna.actor.world.pos.z; + if ((fabsf(xDiff) < 80.0f) && (fabsf(yDiff) < 30.0f) && (fabsf(zDiff) < 80.0f) && + (explosive->update != NULL) && (explosive->velocity.y != 0.0f)) { + Actor_MarkForDeath(explosive); + this->grabTarget = EN_RAF_GRAB_TARGET_EXPLOSIVE; + this->collider.dim.radius = 30; + this->collider.dim.height = 90; + this->collider.dim.yShift = -10; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Draw.s") + explosive = explosive->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18A90.s") +void EnRaf_SetupGrab(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CLOSE); + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_GRAB; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DRINK); + this->action = EN_RAF_ACTION_GRAB; + this->actionFunc = EnRaf_Grab; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18B8C.s") +/** + * Grabs the player or explosive that entered its range. + */ +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18DA0.s") + if ((this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && (player->stateFlags2 & 0x80) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + EnRaf_SetupChew(this); + } +} + +void EnRaf_SetupChew(EnRaf* this) { + s32 i; + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CHEW); + this->chewCount = 0; + for (i = 0; i < ARRAY_COUNT(this->chewLimbRot); i++) { + this->chewLimbRot[i].x = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].y = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].z = Rand_S16Offset(8, 8) << 8; + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_CHEW; + this->action = EN_RAF_ACTION_CHEW; + this->actionFunc = EnRaf_Chew; +} + +/** + * Chews the player or explosive that was grabbed. If it grabbed a non-Goron player, it will deal + * damage to them and eventually throw them. If it grabbed a Goron player or explosive, it will + * instead explode after chewing them a bit. + */ +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { + f32 targetChewScale; + f32 curFrame; + Player* player = GET_PLAYER(globalCtx); + + curFrame = this->skelAnime.curFrame; + targetChewScale = (BREG(51) / 100.0f) + 0.2f; + Math_ApproachF(&this->chewScale, targetChewScale, 0.2f, 0.03f); + + if ((player->stateFlags2 & 0x80) && (this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + if (BREG(52) == 0) { + this->chewCount++; + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); + switch (this->grabTarget) { + case EN_RAF_GRAB_TARGET_PLAYER: + globalCtx->damagePlayer(globalCtx, -2); + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & 0x80)) { + player->actor.freezeTimer = 10; + EnRaf_SetupThrow(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_EXPLOSIVE: + Actor_ApplyDamage(&this->dyna.actor); + if (this->chewCount > (BREG(54) + 4)) { + EnRaf_Explode(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_GORON_PLAYER: + if (this->chewCount > (BREG(54) + 4)) { + player->actor.parent = NULL; + player->unk_AE8 = 1000; + EnRaf_Explode(this, globalCtx); + } + break; + } + } +} + +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + player->actor.freezeTimer = 10; + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_THROW; + this->actionFunc = EnRaf_Throw; +} + +/** + * Spits out the grabbed player. + */ +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + player->actor.freezeTimer = 0; + player->actor.parent = NULL; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_THROW); + func_800B8D50(globalCtx, &this->dyna.actor, BREG(55) + 3.0f, this->playerRotYWhenGrabbed + 0x8000, + BREG(56) + 10.0f, 0); + } else if (curFrame < 10.0f) { + player->actor.freezeTimer = 10; + } + + if (this->endFrame <= curFrame) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->timer = 20; + this->actionFunc = EnRaf_Idle; + } +} + +/** + * Creates an explosion effect/sound and spawns particles. + */ +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f explosionPos; + s32 i; + s32 pad; + + this->action = EN_RAF_ACTION_EXPLODE; + Math_Vec3f_Copy(&explosionPos, &this->dyna.actor.world.pos); + explosionPos.y += 10.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, + 0, 0, CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + for (i = 0; i < BREG(57) + 30; i++) { + acceleration.x = (Rand_ZeroOne() - 0.5f) * 0.5f; + acceleration.y = -0.3f; + acceleration.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + velocity.x = Rand_ZeroOne() - 0.5f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = Rand_ZeroOne() - 0.5f; + EnRaf_InitializeParticle(this, &this->dyna.actor.world.pos, &velocity, &acceleration, + (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + } + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + this->timer = 5; + if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 5); + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + } + + this->actionFunc = EnRaf_PostDetonation; +} + +/** + * Switches the lily pad to the "dead" state once the timer reaches 0. + */ +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->collider.dim.radius = 50; + this->collider.dim.height = 10; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 6); + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EnRaf_SetupDormant(this); + } else if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + this->collider.dim.radius = 80; + this->collider.dim.height = 50; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnRaf_SetupConvulse(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CONVULSE); + this->chewCount = 0; + this->action = EN_RAF_ACTION_CONVULSE; + this->actionFunc = EnRaf_Convulse; +} + +/** + * Plays the convulsing animation and sets the lily pad's switch flag to prevent it from + * ever coming back to life. When the water in Woodfall Temple is purified, this function + * and EnRaf_Dissolve are jointly responsible for controlling the lily pad's death. + */ +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->endFrame <= curFrame) { + this->chewCount++; + if (this->chewCount > (BREG(2) + 2)) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + EnRaf_SetupDissolve(this); + } + } +} + +void EnRaf_SetupDissolve(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_DEATH); + this->action = EN_RAF_ACTION_DISSOLVE; + this->dissolveTimer = 0; + this->actionFunc = EnRaf_Dissolve; +} + +/** + * Makes the trap petals on the lily pad dissolve and switches the lily pad to the "dead" state. + * When the water in Woodfall Temple is purified, this function and EnRaf_Convulse are jointly + * responsible for controlling the lily pad's death. + */ +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + if (this->endFrame <= curFrame) { + this->dissolveTimer++; + if (this->dissolveTimer < (BREG(3) + 105)) { + for (i = 0; i < (BREG(4) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableFirstPass, this->petalClearPixelFirstPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableFirstPass, this->teethClearPixelFirstPassIndex); + if (this->petalClearPixelFirstPassIndex < (16 * 32)) { + this->petalClearPixelFirstPassIndex++; + } + + if (this->teethClearPixelFirstPassIndex < (8 * 8)) { + this->teethClearPixelFirstPassIndex++; + } + } + } + } + + if (this->dissolveTimer > (BREG(5) + 50)) { + for (i = 0; i < (BREG(6) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableSecondPass, this->petalClearPixelSecondPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableSecondPass, this->teethClearPixelSecondPassIndex); + if (this->petalClearPixelSecondPassIndex < (16 * 32)) { + this->petalClearPixelSecondPassIndex++; + } + + if (this->teethClearPixelSecondPassIndex < (8 * 8)) { + this->teethClearPixelSecondPassIndex++; + } + } + } + + if (this->dissolveTimer > (BREG(7) + 160)) { + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + EnRaf_SetupDormant(this); + } +} + +void EnRaf_SetupDormant(EnRaf* this) { + if (this->action == EN_RAF_ACTION_EXPLODE) { + this->timer = 90; + } else { + this->action = EN_RAF_ACTION_DORMANT; + } + + this->actionFunc = EnRaf_Dormant; +} + +/** + * Simply sits around doing nothing. If the revive timer is non-zero, then this function + * will decrement the revive timer and revive the trap petals once it reaches 0. + */ +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; + + if (this->timer == 0) { + this->action = EN_RAF_ACTION_DORMANT; + } + + if (this->reviveTimer >= 0) { + DECR(this->reviveTimer); + + if (this->reviveTimer == 0) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; + i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->reviveTimer += 30; + this->actionFunc = EnRaf_Idle; + } + } +} + +void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRaf* this = THIS; + WaterBox* waterBox; + f32 ySurface; + Vec3f ripplePos; + s32 i; + + SkelAnime_Update(&this->skelAnime); + DECR(this->rippleTimer); + DECR(this->timer); + this->actionFunc(this, globalCtx); + + if ((this->action == EN_RAF_ACTION_IDLE) && (gSaveContext.save.weekEventReg[12] & 1)) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + EnRaf_SetupConvulse(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if ((this->heightDiffFromPlayer > -0.1f) && !this->isCurrentlyInRidingMovingState) { + this->heightDiffFromPlayer = -20.0f; + this->isCurrentlyInRidingMovingState = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_COMMON_WATER_MID); + } + } else { + this->isCurrentlyInRidingMovingState = false; + } + + this->bobPhase += 3000.0f; + this->bobOffset = 2.0f * Math_SinS(this->bobPhase); + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + ySurface = BREG(60) + (this->dyna.actor.world.pos.y - 60.0f); + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { + ySurface -= this->bobOffset + BREG(59); + Math_ApproachF(&this->dyna.actor.world.pos.y, this->heightDiffFromPlayer + ySurface, 0.5f, 40.0f); + if (this->rippleTimer == 0) { + this->rippleTimer = 30; + if (this->petalScaleType == EN_RAF_PETAL_SCALE_TYPE_CHEW) { + this->rippleTimer = 10; + } + + Math_Vec3f_Copy(&ripplePos, &this->dyna.actor.world.pos); + ripplePos.y = ySurface; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 650, 3150, 0); + } + } + } else { + Math_ApproachF(&this->dyna.actor.world.pos.y, + (this->dyna.actor.home.pos.y + this->heightDiffFromPlayer) - this->bobOffset, 0.5f, 40.0f); + } + + Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_UpdateParticles(this, globalCtx); + } + + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + if (this->action < EN_RAF_ACTION_EXPLODE) { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 0.4f, 0.5f); + } else { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 1.0f, 1.0f); + } + } + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (this->action < EN_RAF_ACTION_EXPLODE) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static s16 sGrabAnimationCheckFrames[] = { 0, 4, 6 }; + +static Vec3f sMiddleSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 1.0f, 2.0f, 1.0f }, + { 0.0f, 1.5f, 0.7f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 3.0f, 2.0f, 1.5f }, + { 1.5f, 1.2f, 0.8f }, +}; + +static s16 sSpitAnimationCheckFrames[] = { 0, 7, 9, 13, 19 }; + +static Vec3f sMiddleSegmentTargetScaleDuringSpit[] = { + { 1.0f, 1.5f, 0.7f }, { 1.0f, 2.0f, 1.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringSpit[] = { + { 1.5f, 1.5f, 1.7f }, { 1.5f, 1.5f, 1.3f }, { 3.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* thisx) { + GlobalContext* globalCtx = globalCtx2; + EnRaf* this = THIS; + s32 i; + + switch (this->petalScaleType) { + case EN_RAF_PETAL_SCALE_TYPE_GRAB: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[i]); + } + } + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_CHEW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[2]); + } else if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[2]); + } + + // These matrix operations make the trap petals look a bit more "wobbly" as it chews + // by stretching the limbs in various random directions. + if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { + Matrix_RotateY((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertXRotation_s((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertZRotation_s((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertXRotation_s(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateY(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sSpitAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringSpit[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < 4; i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringSpit[i]); + } + } + } + break; + } + + Matrix_Scale(this->limbScale[limbIndex].x, this->limbScale[limbIndex].y, this->limbScale[limbIndex].z, + MTXMODE_APPLY); +} + +void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); + + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_DrawParticles(this, globalCtx); + } +} + +void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, + s16 timer) { + s16 i; + EnRafParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (!particle->isVisible) { + particle->isVisible = true; + particle->position = *position; + particle->velocity = *velocity; + particle->acceleration = *acceleration; + particle->scale = scale; + particle->timer = timer; + particle->rotation.x = randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.z = randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx) { + s32 i; + EnRafParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + particle->position.x += particle->velocity.x; + particle->position.y += particle->velocity.y; + particle->position.z += particle->velocity.z; + particle->rotation.x += 0xBB8; + particle->rotation.y += 0xBB8; + particle->rotation.z += 0xBB8; + particle->velocity.x += particle->acceleration.x; + particle->velocity.y += particle->acceleration.y; + particle->velocity.z += particle->acceleration.z; + + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { + EffectSsGSplash_Spawn(globalCtx, &particle->position, NULL, NULL, 0, particle->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &particle->position, 50, NA_SE_EV_BOMB_DROP_WATER); + particle->isVisible = false; + } + } else if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); + if (particle->scale <= 0.0001f) { + particle->timer = 0; + } + } + + if (particle->timer != 0) { + particle->timer--; + } else { + particle->isVisible = false; + } + } + } +} + +void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { + s16 i; + EnRafParticle* particle = this->particles; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.h b/src/overlays/actors/ovl_En_Raf/z_en_raf.h index 95ddfc54d..f63924402 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -2,16 +2,64 @@ #define Z_EN_RAF_H #include "global.h" +#include "objects/object_raf/object_raf.h" + +#define EN_RAF_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define EN_RAF_GET_REVIVE_TIMER(thisx) (((thisx)->params >> 7) & 0x1F) +#define EN_RAF_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + +typedef enum { + /* 0 */ EN_RAF_TYPE_NORMAL, + /* 1 */ EN_RAF_TYPE_DORMANT, // Spawns without trap, so it can't eat bombs/player + /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and particles won't produce splashes +} EnRafType; struct EnRaf; typedef void (*EnRafActionFunc)(struct EnRaf*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 isVisible; + /* 0x04 */ Vec3f position; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f acceleration; + /* 0x28 */ Vec3s rotation; + /* 0x30 */ f32 scale; + /* 0x34 */ s16 timer; +} EnRafParticle; // size = 0x38 + typedef struct EnRaf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; - /* 0x0230 */ EnRafActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x8B0]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x230 */ EnRafActionFunc actionFunc; + /* 0x234 */ Vec3f limbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x2C4 */ Vec3f targetLimbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x354 */ Vec3s chewLimbRot[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x39C */ s16 grabTarget; + /* 0x39E */ u8 isCurrentlyInRidingMovingState; + /* 0x3A0 */ f32 endFrame; + /* 0x3A4 */ f32 chewScale; + /* 0x3A8 */ f32 bobOffset; + /* 0x3AC */ f32 heightDiffFromPlayer; + /* 0x3B0 */ f32 bobPhase; + /* 0x3B4 */ s16 timer; + /* 0x3B6 */ s16 dissolveTimer; + /* 0x3B8 */ s16 rippleTimer; + /* 0x3BA */ s16 reviveTimer; + /* 0x3BC */ s16 playerRotYWhenGrabbed; + /* 0x3BE */ s16 mainType; + /* 0x3C0 */ s16 switchFlag; + /* 0x3C2 */ s16 petalScaleType; + /* 0x3C4 */ s16 chewCount; + /* 0x3C6 */ s16 action; + /* 0x3C8 */ s16 petalClearPixelFirstPassIndex; + /* 0x3CA */ s16 teethClearPixelFirstPassIndex; + /* 0x3CC */ s16 petalClearPixelSecondPassIndex; + /* 0x3CE */ s16 teethClearPixelSecondPassIndex; + /* 0x3D0 */ ColliderCylinder collider; + /* 0x41C */ EnRafParticle particles[31]; } EnRaf; // size = 0xAE4 extern const ActorInit En_Raf_InitVars; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 13d4a93e9..09d2093ce 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -401,6 +401,7 @@ s32 func_80BF43FC(EnRg* this) { return phi_s4; } #else +s32 func_80BF43FC(EnRg* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rg/func_80BF43FC.s") #endif diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 89e1cb217..b6b595549 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -380,7 +380,7 @@ void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { func_80AE6130(this); func_80AE63A8(this, globalCtx); this->unk_2E0 = 0; - func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, 0, this->unk_1D8 & 7); + func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, EXCH_ITEM_NONE, this->unk_1D8 & 7); } s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { 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 b778a2dad..76b6bea99 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -758,7 +758,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { } this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk424; sp50 = this->unk420; sp58 = this->actor.world.pos; @@ -772,7 +772,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { sp64 = this->unk408; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk424 = sp54; this->unk420 = sp50; this->unk408 = sp58; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index f0d1a3aa7..91d602f87 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -450,6 +450,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } } #else +void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") #endif @@ -816,6 +817,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = temp_f0; } #else +void func_808DA578(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA578.s") #endif @@ -854,6 +856,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DA6FC(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") #endif @@ -1013,6 +1016,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DACF4(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") #endif diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 944838b3c..92168ef76 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -7,7 +7,6 @@ #include "z_en_syateki_dekunuts.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -70,13 +69,13 @@ static ColliderCylinderInit sCylinderInit = { static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; static AnimationInfo sAnimations[] = { - { &object_dekunuts_Anim_003180, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_00326C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_dekunuts_Anim_00259C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubBurrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubLookAroundAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubUnburrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, }; static InitChainEntry sInitChain[] = { @@ -124,8 +123,8 @@ void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_002A5C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); if (path == NULL) { Actor_MarkForDeath(&this->actor); return; @@ -147,7 +146,7 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80A2BE54(EnSyatekiDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->actor.speedXZ = 0.0f; this->actor.world = this->actor.home; @@ -398,7 +397,7 @@ s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnSyatekiDekunuts* this = THIS; - if ((limbIndex == OBJECT_DEKUNUTS_LIMB_03) && (this->unk_1F0 == 1)) { + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { rot->z += this->unk_1F2; } @@ -428,7 +427,7 @@ void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, &object_dekunuts_DL_001E50); + gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 4055dd6b8..50361894b 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -2,6 +2,7 @@ #define Z_EN_SYATEKI_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" #define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) #define EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) @@ -28,8 +29,8 @@ typedef struct EnSyatekiDekunuts { /* 0x1EE */ s16 unk_1EE; /* 0x1F0 */ s16 unk_1F0; /* 0x1F2 */ s16 unk_1F2; - /* 0x1F4 */ Vec3s jointTable[10]; - /* 0x230 */ Vec3s morphTable[10]; + /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 8ff08e32a..8edc05db3 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -541,7 +541,7 @@ void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + this->unk_30C; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2FC & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2FC & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BE0620(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index ada39da61..85baedbc8 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -65,11 +65,11 @@ Vec2s D_80BE5DD4[] = { }; Gfx* D_80BE5E24[] = { - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, - object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, }; f32 D_80BE5E74[] = { @@ -176,7 +176,7 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_144 = 250; this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; } else { - this->unk_148 = object_boss02_DL_007A88; + this->unk_148 = gRuinFragmentDL; this->unk_144 = 150; } } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { @@ -194,7 +194,7 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&child->actor, child->unk_19C); child->unk_148 = D_80BE5E24[i]; - if (child->unk_148 == object_boss02_DL_006FD0) { + if (child->unk_148 == gTwinmoldPyramidRuinDL) { child->actor.shape.rot.y = 0; } @@ -249,7 +249,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); - if (this->unk_148 == object_boss02_DL_007D18) { + if (this->unk_148 == gTwinmoldMajoraPillarDL) { this->collider.dim.radius = 65.0f * D_80BE5DD0; this->collider.dim.height = 380.0f * D_80BE5DD0; } else if (this->unk_1A0 == 0) { @@ -280,7 +280,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || (ac->id == ACTOR_BOSS_02)) { - if (this->unk_148 == object_boss02_DL_007D18) { + if (this->unk_148 == gTwinmoldMajoraPillarDL) { Math_Vec3f_Copy(&spB8, &this->actor.world.pos); spB8.y += D_80BE5DD0 * 300.0f; @@ -309,7 +309,8 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { spAC = 780.0f; this->unk_19C *= 1.5f; } - + // TODO: determine if unk_1A0 ever has a different value from these 3, which will cause UB from spAC + // being uninitialised this->actor.world.pos.y -= D_80BE5DD0 * spAC; Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); Math_Vec3f_Copy(&spB8, &this->actor.world.pos); @@ -366,11 +367,11 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { } Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->unk_148 == object_boss02_DL_006FD0) { + if (this->unk_148 == gTwinmoldPyramidRuinDL) { this->collider.dim.pos.y = this->actor.floorHeight; } - if ((this->unk_148 == object_boss02_DL_007D18) || (D_80BE5DD0 < 0.5f)) { + if ((this->unk_148 == gTwinmoldMajoraPillarDL) || (D_80BE5DD0 < 0.5f)) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } else { f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; 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 9f9bed14c..baa4adb89 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -486,7 +486,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } if (!(this->unk_3CE & 8) && !(this->unk_2CA & 0x10) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } return false; @@ -695,7 +695,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { func_80AEDE10(this, globalCtx); } else if (!(this->unk_2CA & 0x80)) { if (this->actor.xzDistToPlayer < 100.0f) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } } else { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index ea0e8ae44..7cf13c6af 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -320,6 +320,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") #endif @@ -580,7 +581,6 @@ s32 func_80A86DB8(EnTru* this) { if (this->skelAnime.curFrame < 57.0f) { if (DECR(this->unk_36C) == 0) { - this = this; this->unk_36C = Rand_S16Offset(8, 8); this->unk_36E = 2; } else { @@ -1130,7 +1130,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 5); } else { - this->unk_388 = 0; + this->unk_388 = EXCH_ITEM_NONE; } this->actionFunc = func_80A87FD0; @@ -1156,7 +1156,7 @@ void EnTru_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A86DB8(this); radius = this->collider.dim.worldSphere.radius + 30; - this->unk_388 = !(this->unk_34E & 0x80) ? 0 : 0; + this->unk_388 = !(this->unk_34E & 0x80) ? EXCH_ITEM_NONE : EXCH_ITEM_NONE; func_8013C964(&this->actor, globalCtx, radius, 20.0f, this->unk_388, this->unk_34E & 7); func_80A8697C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 0f91171fb..8759d3b86 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -99,9 +99,9 @@ static AnimationInfoS sAnimations[] = { { &gZoraWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -s8 D_8099F578[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; -s8 D_8099F58C[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_8099F59C[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s8 sBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; +s8 sParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +u8 sShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { s16 frameCount; @@ -310,8 +310,8 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp30 = { 400.0f, 0.0f, 0.0f }; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (D_8099F578[limbIndex] >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->unk_364[D_8099F578[limbIndex]]); + if (sBodyParts[limbIndex] >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } if (limbIndex == 15) { Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); @@ -336,9 +336,9 @@ static Gfx sTransparencyDlist[] = { void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8) * SQ(64)); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; - TexturePtr eyeTextures[] = { &gZoraEyeOpenTex, &gZoraEyeHalfTex, &gZoraEyeClosedTex }; + TexturePtr eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -354,14 +354,15 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, &this->actor, POLY_OPA_DISP); Matrix_InsertXRotation_s(0, 0); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8) * SQ(64); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter = 0; shadowTexIter++; } for (i = 0; i < 5; i++) { - func_8013CD64(this->unk_364, &this->actor.world.pos, shadowTex, i / 5.0f, 15, D_8099F59C, D_8099F58C); + SubS_GenShadowTex(this->bodyPartsPos, &this->actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->bodyPartsPos), sShadowSizes, sParentBodyParts); } - func_8013CF04(&this->actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 0b9f8dab1..155c947d4 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -30,7 +30,7 @@ typedef struct EnZo { /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; /* 0x0312 */ s16 limbRotY[20]; /* 0x033A */ s16 limbRotZ[20]; - /* 0x0364 */ Vec3f unk_364[15]; + /* 0x0364 */ Vec3f bodyPartsPos[15]; /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; /* 0x041E */ s16 eyeIndex; /* 0x0420 */ s16 blinkTimer; diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index dd57b99e4..14e25c57d 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -119,19 +119,16 @@ s32 func_80A35510(ObjBell* this, s32 arg1) { if (((arg1 == 0) && (this->unk_21C < 1000.0f)) || ((arg1 == 1) && (this->unk_21C < 4000.0f)) || (arg1 == 2)) { phi_a3 = true; - } else { - phi_a3 = phi_a3; } switch (arg1) { case 0: - this->unk_21C += this->unk_21C > 1000.0f ? 250.0f : 1000.0f; + this->unk_21C += ((this->unk_21C > 1000.0f) ? 250.0f : 1000.0f); break; case 1: - this->unk_21C += this->unk_21C > 3000.0f ? 750.0f : 3000.0f; + this->unk_21C += ((this->unk_21C > 3000.0f) ? 750.0f : 3000.0f); break; case 2: - if (1) {} this->unk_21C += 9000.0f; break; } diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 0d937d1c0..2d3a6f2d5 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -5,6 +5,7 @@ */ #include "z_obj_blockstop.h" +#include "overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,9 +14,9 @@ void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809466F0(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Blockstop_InitVars = { ACTOR_OBJ_BLOCKSTOP, ACTORCAT_PROP, @@ -28,12 +29,47 @@ const ActorInit Obj_Blockstop_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Init.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + } + this->actionFunc = ObjBlockstop_CheckForBlock; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809466F0.s") +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809467E8.s") + while (prop != NULL) { + if ((prop->id == ACTOR_OBJ_OSHIHIKI) && (fabsf(prop->world.pos.x - this->actor.world.pos.x) < 20.0f) && + (fabsf(prop->world.pos.z - this->actor.world.pos.z) < 20.0f) && + (fabsf(prop->world.pos.y - this->actor.world.pos.y) < 20.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Update.s") + s32 params = OBJOSHIHIKI_GET_F(prop); + if (params < 3) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = ObjBlockstop_TryPlayCutscene; + } + } + prop = prop->next; + } +} + +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetSwitch(globalCtx, this->actor.params); + if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + Actor_MarkForDeath(&this->actor); + return; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); +} + +void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 1d77cc257..a1d149f3d 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -5,6 +5,7 @@ */ #include "z_obj_dora.h" +#include "assets/objects/object_dora/object_dora.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,25 @@ void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjDora_SetupWait(ObjDora* this); +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx); +void ObjDora_SetupMoveGong(ObjDora* this); +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx); +s32 ObjDora_IsHalfHour(u16 time); +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx); + +typedef enum { + /* 0x0 */ DORA_HIT_NONE, + /* 0x1 */ DORA_HIT_LIGHT, + /* 0x2 */ DORA_HIT_STRONG +} ObjDoraHitStrength; + +typedef enum { + /* 0x0 */ DORA_DMGEFF_NONE, + /* 0xE */ DORA_DMGEFF_STRONG = 0xE, + /* 0xF */ DORA_DMGEFF_LIGHT +} ObjDoraDamageEffect; + const ActorInit Obj_Dora_InitVars = { ACTOR_OBJ_DORA, ACTORCAT_NPC, @@ -28,104 +47,306 @@ const ActorInit Obj_Dora_InitVars = { (ActorFunc)ObjDora_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B61310[6] = { +static ColliderTrisElementInit sTrisElementsInit[6] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -35.0f, 0.0f }, { 260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -185.0f, 0.0f }, { 260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -485.0f, 0.0f }, { 0.0f, -635.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -635.0f, 0.0f }, { -260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -485.0f, 0.0f }, { -260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -185.0f, 0.0f }, { 0.0f, -35.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B61478 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_TRIS, }, - 6, D_80B61310, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B61488 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xE), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(0, 0xF), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(0, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Horse trample */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Normal arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Hookshot */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron punch */ DMG_ENTRY(2, DORA_DMGEFF_STRONG), + /* Sword */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Goron pound */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Fire arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Ice arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Light arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Deku spin */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Deku bubble */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Zora punch */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Spin attack */ DMG_ENTRY(1, DORA_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(0, DORA_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B614A8 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + s32 i; + s32 j; + Vec3f vtx[3]; + s32 buf = 0; + s32 buff2 = 0; -extern ColliderTrisElementInit D_80B61310[6]; -extern ColliderTrisInit D_80B61478; -extern DamageTable D_80B61488; -extern CollisionCheckInfoInit2 D_80B614A8; + Actor_SetScale(&this->actor, 0.1f); + ActorShape_Init(&this->actor.shape, 0.0f, &ActorShadow_DrawCircle, 36.0f); -extern UNK_TYPE D_06004160; + this->gongRotation.x = 0; + this->gongRotation.z = 0; + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->lastGongHitType = DORA_HIT_NONE; + this->rupeeDropTimer = 0; + this->collisionCooldownTimer = 0; + this->unk3AA = 0; + this->gongForce.x = 0.0f; + this->gongForce.y = 0.0f; + this->gongForce.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Init.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Destroy.s") + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60C9C.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + ObjDora_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CB0.s") +void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CC0.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60D34.s") +void ObjDora_SetupWait(ObjDora* this) { + this->actionFunc = ObjDora_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60E54.s") +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60EE8.s") +void ObjDora_SetupMoveGong(ObjDora* this) { + if (this->lastGongHitType == DORA_HIT_LIGHT) { + this->gongForce.x = 2.0f; + this->gongForce.y = 5461.0f; + this->gongForce.z = 1820.0f; + } else { + this->gongForce.x = 4.0f; + this->gongForce.y = 12743.0f; + this->gongForce.z = 5461.0f; + } + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->actionFunc = ObjDora_MoveGong; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Update.s") +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Draw.s") + if ((this->gongForce.y < 182.0f) && (this->gongForce.z < 182.0f)) { + this->lastGongHitType = DORA_HIT_LIGHT; + ObjDora_SetupWait(this); + } + + Math_SmoothStepToF(&this->gongForce.x, 0, 0.2f, 0.2f, 0.1f); + Math_SmoothStepToF(&this->gongForce.y, 0, 0.5f, 54.0f, 18.0f); + Math_SmoothStepToF(&this->gongForce.z, 0, 0.5f, 54.0f, 18.0f); + this->gongAngle.x += 0x1555; + this->gongAngle.z += 0x238E; + this->gongRotation.x = Math_SinS(this->gongAngle.x) * this->gongForce.y; + this->gongRotation.z = Math_SinS(this->gongAngle.z) * this->gongForce.z; +} + +s32 ObjDora_IsHalfHour(u16 time) { + f32 timeHalfHour = time; + + timeHalfHour -= (CLOCK_TIME_F(0, 30) * (s32)(time / CLOCK_TIME_F(0, 30))); + if ((timeHalfHour < CLOCK_TIME_F(0, 1)) || (CLOCK_TIME_F(0, 29) < timeHalfHour)) { + return true; + } + + return false; +} + +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { + Actor* itemDrop; + u16 time; + + if (this->colliderTris.base.acFlags & AC_HIT) { + time = gSaveContext.save.time; + this->colliderTris.base.acFlags &= ~AC_HIT; + this->collisionCooldownTimer = 5; + + switch (this->actor.colChkInfo.damageEffect) { + case DORA_DMGEFF_STRONG: + case DORA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == DORA_DMGEFF_LIGHT) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_S); + this->lastGongHitType = DORA_HIT_LIGHT; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_L); + this->lastGongHitType = DORA_HIT_STRONG; + } + + func_800BC848(&this->actor, globalCtx, 5, 10); + ObjDora_SetupMoveGong(this); + + if ((ObjDora_IsHalfHour(time) == true) && (this->rupeeDropTimer == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + itemDrop = Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); + itemDrop->world.rot.y = this->actor.world.rot.y; + itemDrop->world.rot.y += (s32)(Rand_Centered() * 90.0f * (0x10000 / 360.0f)); + itemDrop->velocity.y = 5.0f; + itemDrop->gravity = -1.0f; + this->rupeeDropTimer = 40; + } + break; + } + } + + if (this->rupeeDropTimer > 0) { + this->rupeeDropTimer--; + } + + if (this->collisionCooldownTimer > 0) { + this->collisionCooldownTimer--; + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } +} + +void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + + this->actionFunc(this, globalCtx); + ObjDora_UpdateCollision(this, globalCtx); +} + +void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f position = { 0.0f, -61.5f, 0.0f }; + ObjDora* this = THIS; + f32 gongForceX; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->actionFunc == ObjDora_MoveGong) { + gongForceX = this->gongForce.x; + if ((globalCtx->state.frames % 2) != 0) { + gongForceX *= -1.0f; + } + + Matrix_StatePush(); + Matrix_InsertXRotation_s(this->gongRotation.x, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + + Matrix_InsertTranslation(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-position.x, -position.y, -position.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + + Matrix_StatePop(); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h index a40405b34..a2dbbea16 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -9,9 +9,16 @@ typedef void (*ObjDoraActionFunc)(struct ObjDora*, GlobalContext*); typedef struct ObjDora { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x248]; + /* 0x0144 */ ColliderTris colliderTris; + /* 0x0164 */ ColliderTrisElement colliderTrisElements[6]; /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ char unk_390[0x1C]; + /* 0x0390 */ Vec3f gongForce; + /* 0x039C */ Vec2s gongAngle; + /* 0x03A0 */ s16 lastGongHitType; + /* 0x03A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. + /* 0x03A6 */ s16 rupeeDropTimer; + /* 0x03A8 */ s16 collisionCooldownTimer; + /* 0x03AA */ s16 unk3AA; // Set but not used } ObjDora; // size = 0x3AC extern const ActorInit Obj_Dora_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index abd30b256..660e68b6d 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -198,6 +198,7 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* *arg2 = (s32)temp_f22 + arg0->unk_00[2]; } #else +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") #endif diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 6cf8e0751..d6a2df4cf 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -45,10 +45,10 @@ Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; -Gfx* D_80B666C0 = object_dora_DL_002080; -Gfx* D_80B666C4 = object_dora_DL_002180; -Gfx* D_80B666C8 = object_dora_DL_002380; -Gfx* D_80B666CC = object_dora_DL_002280; +Gfx* D_80B666C0 = gKendoKanbanTopRightDL; +Gfx* D_80B666C4 = gKendoKanbanTopLeftDL; +Gfx* D_80B666C8 = gKendoKanbanBottomRightDL; +Gfx* D_80B666CC = gKendoKanbanBottomLeftDL; Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; @@ -472,7 +472,7 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_30C == OBJKENDOKANBAN_F_0) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dora_DL_000180); + gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); } else { Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index c0ce7408e..2ff0e093e 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -6,6 +6,7 @@ #include "z_obj_nozoki.h" #include "objects/object_secom_obj/object_secom_obj.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10) diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 7bea97826..bfe1f24b1 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -241,10 +241,10 @@ void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, Colli } Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, this->dyna.actor.world.pos.z, - this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, - 0xFF32); + return Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, + this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, + this->dyna.actor.world.rot.z, 0xFF32); } void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index d13a3bb4d..95f0eb3a8 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -87,7 +87,7 @@ static InitChainEntry sInitChain[] = { * angle can differ from the target angle if the panel is in * the middle of rotating. */ -s32 ObjTokeidai_GetTargetSunMoonPanelRotation() { +s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void) { if (gSaveContext.save.isNight) { return 0x8000; } diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 9c5d22bac..9e36e5a2a 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -223,6 +223,7 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 return sp9C; } #else +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") #endif diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 5d67a3762..ddbb4547d 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = efae567d3917afa341bd843ba185b3bd66d57429 - parent = 22c6551083172f5c506aecf8c31ad761afbbd658 + commit = 87cb648b4311d20673452111edaf4d38a5290c28 + parent = 06412c070f0240eacfaa860eee99b9c723245b7f method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.cpp b/tools/ZAPD/ExporterTest/CollisionExporter.cpp index e00f5c1b0..87b9a05a2 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.cpp +++ b/tools/ZAPD/ExporterTest/CollisionExporter.cpp @@ -50,10 +50,10 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path o writer->Write(col->polygons[i].vtxA); writer->Write(col->polygons[i].vtxB); writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].a); - writer->Write(col->polygons[i].b); - writer->Write(col->polygons[i].c); - writer->Write(col->polygons[i].d); + writer->Write(col->polygons[i].normX); + writer->Write(col->polygons[i].normY); + writer->Write(col->polygons[i].normZ); + writer->Write(col->polygons[i].dist); } writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); diff --git a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj index 839d45102..5bdfc7aa6 100644 --- a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj +++ b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj @@ -1,160 +1,160 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {65608eb0-1a47-45ad-ab66-192fb64c762c} - ExporterTest - 10.0 - ExporterExample - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {65608eb0-1a47-45ad-ab66-192fb64c762c} + ExporterTest + 10.0 + ExporterExample + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj b/tools/ZAPD/ZAPD/ZAPD.vcxproj index 431abb73b..f3bb35a3f 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj @@ -1,343 +1,362 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} - ZAPD - 10.0 - ZAPD - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) - $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - $(IncludePath) - - - $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) - $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) - - - - Level3 - Disabled - true - true - stdcpp17 - stdc11 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - - - - - Level3 - Disabled - true - true - stdcpp17 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - stdc11 - MultiThreadedDebug - - - true - ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) - false - - + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} + ZAPD + 10.0 + ZAPD + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) + $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + $(IncludePath) + + + $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) + $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) + + + + Level3 + Disabled + true + true + stdcpp17 + stdc11 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + cd .. mkdir build\ZAPD -python3 ZAPD/genbuildinfo.py - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpplatest - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - + python ZAPD/genbuildinfo.py + + + + + Level3 + Disabled + true + true + stdcpp17 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + stdc11 + MultiThreadedDebug + + + true + ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) + false + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpplatest + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters index b8a7daaac..4de236fad 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters @@ -1,554 +1,566 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {02148456-5068-4613-8478-f10addc58e70} - - - {bcab3136-95ba-4839-833c-43d78ad6e335} - - - {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} - - - {6049c045-bc38-4221-b29e-ca6d4d8af4aa} - - - {490e3a08-047b-48d3-ab53-3a860a3b92aa} - - - {26c06845-8e8e-4b79-ad18-07c4f9c0f801} - - - {d45c420d-2378-47ac-92c5-80db9475c195} - - - {03cc56a2-e0e8-4167-80a0-98fb900a959a} - - - {73db0879-6df8-4f6a-8cc2-a1f836e9e796} - - - {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} - - - {7ee79d97-c6a8-4e82-93ef-37981f4d7838} - - - {85600275-99fe-491d-8189-bcc3dc1a8903} - - - {ba9990b0-1082-48bb-874c-6108534b5455} - - - {ce9d91b0-ba20-4296-bc2d-8630965bb392} - - - {730beb67-6d59-4849-9d9b-702c4a565fc0} - - - - - Source Files - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files - - - Source Files - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files - - - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries - - - Header Files\Libraries - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - - - Resource Files - - - any\any - - - NuGet - - - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {02148456-5068-4613-8478-f10addc58e70} + + + {bcab3136-95ba-4839-833c-43d78ad6e335} + + + {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} + + + {6049c045-bc38-4221-b29e-ca6d4d8af4aa} + + + {490e3a08-047b-48d3-ab53-3a860a3b92aa} + + + {26c06845-8e8e-4b79-ad18-07c4f9c0f801} + + + {d45c420d-2378-47ac-92c5-80db9475c195} + + + {03cc56a2-e0e8-4167-80a0-98fb900a959a} + + + {73db0879-6df8-4f6a-8cc2-a1f836e9e796} + + + {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} + + + {7ee79d97-c6a8-4e82-93ef-37981f4d7838} + + + {85600275-99fe-491d-8189-bcc3dc1a8903} + + + {ba9990b0-1082-48bb-874c-6108534b5455} + + + {ce9d91b0-ba20-4296-bc2d-8630965bb392} + + + {730beb67-6d59-4849-9d9b-702c4a565fc0} + + + + + Source Files + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries + + + Header Files\Libraries + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + + + Resource Files + + + any\any + + + NuGet + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index b6d9e50e5..d4f55d6c8 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -106,6 +106,7 @@ std::string ZArray::GetBodySourceCode() const case ZResourceType::Pointer: case ZResourceType::Scalar: case ZResourceType::Vertex: + case ZResourceType::CollisionPoly: output += resList.at(i)->GetBodySourceCode(); break; diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 0b04ca5c1..992332db7 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -61,18 +61,22 @@ void ZCollisionHeader::ParseRawData() currentPtr += vec.GetRawDataSize(); vertices.push_back(vec); } - + for (uint16_t i = 0; i < numPolygons; i++) - polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16))); + { + ZCollisionPoly poly(parent); + poly.SetRawDataIndex(polySegmentOffset + (i * 16)); + poly.ParseRawData(); + polygons.push_back(poly); + } uint16_t highestPolyType = 0; - for (PolygonEntry poly : polygons) + for (ZCollisionPoly poly : polygons) { if (poly.type > highestPolyType) highestPolyType = poly.type; } - for (uint16_t i = 0; i < highestPolyType + 1; i++) polygonTypes.push_back( BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); @@ -149,16 +153,13 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) for (size_t i = 0; i < polygons.size(); i++) { - declaration += StringHelper::Sprintf( - "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },", - polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC, - polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d); + declaration += StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str()); if (i + 1 < polygons.size()) declaration += "\n"; } parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly", + polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), StringHelper::Sprintf("%sPolygons", auxName.c_str()), polygons.size(), declaration); } @@ -254,18 +255,6 @@ size_t ZCollisionHeader::GetRawDataSize() const return 44; } -PolygonEntry::PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - a = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - b = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - c = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - d = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); -} - WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) { xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); diff --git a/tools/ZAPD/ZAPD/ZCollision.h b/tools/ZAPD/ZAPD/ZCollision.h index 222fd25f9..7481a8526 100644 --- a/tools/ZAPD/ZAPD/ZCollision.h +++ b/tools/ZAPD/ZAPD/ZCollision.h @@ -4,7 +4,9 @@ #include "ZResource.h" #include "ZRoom/ZRoom.h" #include "ZVector.h" +#include "ZCollisionPoly.h" +#if 0 class PolygonEntry { public: @@ -14,6 +16,7 @@ public: PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); }; +#endif class WaterBoxHeader { @@ -78,7 +81,7 @@ public: waterBoxSegmentOffset; std::vector vertices; - std::vector polygons; + std::vector polygons; std::vector polygonTypes; std::vector waterBoxes; CameraDataList* camData = nullptr; diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.cpp b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp new file mode 100644 index 000000000..eb2c14ab9 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp @@ -0,0 +1,76 @@ +#include "ZCollisionPoly.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly); + +ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent) +{ +} + +ZCollisionPoly::~ZCollisionPoly() +{ +} + +void ZCollisionPoly::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + + vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + + dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); +} + +void ZCollisionPoly::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4,GetRawDataSize(), GetSourceTypeName(), name.c_str(),GetBodySourceCode()); +} + +std::string ZCollisionPoly::GetBodySourceCode() const +{ + std::string declaration; + + declaration += StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}", type, vtxA, vtxB, vtxC, normX, normY, normZ, dist); + return declaration; +} + +std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); +} + + +ZResourceType ZCollisionPoly::GetResourceType() const +{ + return ZResourceType::CollisionPoly; +} + +size_t ZCollisionPoly::GetRawDataSize() const +{ + return 16; +} + +std::string ZCollisionPoly::GetSourceTypeName() const +{ + return "CollisionPoly"; +} + +bool ZCollisionPoly::DoesSupportArray() const +{ + return true; +} \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.h b/tools/ZAPD/ZAPD/ZCollisionPoly.h new file mode 100644 index 000000000..9596d2253 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.h @@ -0,0 +1,30 @@ +#pragma once + +#include "ZFile.h" +#include "ZResource.h" + + +class ZCollisionPoly : public ZResource +{ +public: + uint16_t type; + uint16_t vtxA, vtxB, vtxC; + uint16_t normX, normY, normZ; + uint16_t dist; + + ZCollisionPoly(ZFile* nParent); + ~ZCollisionPoly(); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + bool DoesSupportArray() const override; + + size_t GetRawDataSize() const override; +}; \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZResource.cpp b/tools/ZAPD/ZAPD/ZResource.cpp index 2dfe6d5ea..8825cc97b 100644 --- a/tools/ZAPD/ZAPD/ZResource.cpp +++ b/tools/ZAPD/ZAPD/ZResource.cpp @@ -247,6 +247,11 @@ offset_t ZResource::GetRawDataIndex() const return rawDataIndex; } +void ZResource::SetRawDataIndex(offset_t nRawDataIndex) +{ + rawDataIndex = nRawDataIndex; +} + std::string ZResource::GetBodySourceCode() const { return "ERROR"; diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index c65c3c31b..35984679c 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -31,6 +31,7 @@ enum class ZResourceType Background, Blob, CollisionHeader, + CollisionPoly, Cutscene, DisplayList, Limb, @@ -150,6 +151,8 @@ public: [[nodiscard]] const std::string& GetOutName() const; void SetOutName(const std::string& nName); [[nodiscard]] offset_t GetRawDataIndex() const; + void SetRawDataIndex(offset_t nRawDataIndex); + /** * The size of the current struct being extracted, not counting data referenced by it */ diff --git a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index ac82c24ca..646fa1274 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -11,6 +11,10 @@ #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#ifdef _MSC_VER +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + class BitConverter { public: diff --git a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj index 0a09666e0..c0ef260dd 100644 --- a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj +++ b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj @@ -1,168 +1,168 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {a2e01c3e-d647-45d1-9788-043debc1a908} - ZAPDUtils - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - MultiByte - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - Default - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a2e01c3e-d647-45d1-9788-043debc1a908} + ZAPDUtils + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + MultiByte + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + Default + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 81ea81063..879a2b351 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2658,7 +2658,7 @@ 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), - 0x8013AD6C:("func_8013AD6C",), + 0x8013AD6C:("SubS_InCsMode",), 0x8013AD9C:("func_8013AD9C",), 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), @@ -2676,9 +2676,9 @@ 0x8013C624:("func_8013C624",), 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), - 0x8013CC2C:("func_8013CC2C",), - 0x8013CD64:("func_8013CD64",), - 0x8013CF04:("func_8013CF04",), + 0x8013CC2C:("SubS_FillShadowTex",), + 0x8013CD64:("SubS_GenShadowTex",), + 0x8013CF04:("SubS_DrawShadowTex",), 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), @@ -2703,11 +2703,11 @@ 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("SubS_StartActorCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), - 0x8013E4B0:("func_8013E4B0",), - 0x8013E5CC:("func_8013E5CC",), + 0x8013E4B0:("SubS_ConstructPlane",), + 0x8013E5CC:("SubS_LineSegVsPlane",), 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), - 0x8013E7C0:("func_8013E7C0",), + 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), 0x8013E950:("func_8013E950",), 0x8013EC10:("func_8013EC10",), @@ -6071,33 +6071,33 @@ 0x808BEE38:("EnDekunuts_Draw",), 0x808BF220:("EnBbfall_Init",), 0x808BF318:("EnBbfall_Destroy",), - 0x808BF344:("func_808BF344",), - 0x808BF3B8:("func_808BF3B8",), - 0x808BF438:("func_808BF438",), - 0x808BF4B4:("func_808BF4B4",), - 0x808BF514:("func_808BF514",), - 0x808BF578:("func_808BF578",), - 0x808BF5AC:("func_808BF5AC",), - 0x808BF5E0:("func_808BF5E0",), - 0x808BF734:("func_808BF734",), - 0x808BF7A0:("func_808BF7A0",), - 0x808BF830:("func_808BF830",), - 0x808BF894:("func_808BF894",), - 0x808BF8DC:("func_808BF8DC",), - 0x808BFA18:("func_808BFA18",), - 0x808BFA3C:("func_808BFA3C",), - 0x808BFAB4:("func_808BFAB4",), - 0x808BFB4C:("func_808BFB4C",), - 0x808BFCCC:("func_808BFCCC",), - 0x808BFE58:("func_808BFE58",), - 0x808BFF8C:("func_808BFF8C",), - 0x808C00A0:("func_808C00A0",), - 0x808C013C:("func_808C013C",), - 0x808C0178:("func_808C0178",), - 0x808C01E0:("func_808C01E0",), + 0x808BF344:("EnBbfall_Freeze",), + 0x808BF3B8:("EnBbfall_Thaw",), + 0x808BF438:("EnBbfall_IsTouchingLava",), + 0x808BF4B4:("EnBbfall_PlaySfx",), + 0x808BF514:("EnBbfall_CheckForWall",), + 0x808BF578:("EnBbfall_EnableColliders",), + 0x808BF5AC:("EnBbfall_DisableColliders",), + 0x808BF5E0:("EnBbfall_SetupWaitForPlayer",), + 0x808BF734:("EnBbfall_WaitForPlayer",), + 0x808BF7A0:("EnBbfall_SetupEmerge",), + 0x808BF830:("EnBbfall_Emerge",), + 0x808BF894:("EnBbfall_SetupFly",), + 0x808BF8DC:("EnBbfall_Fly",), + 0x808BFA18:("EnBbfall_SetupSinkIntoLava",), + 0x808BFA3C:("EnBbfall_SinkIntoLava",), + 0x808BFAB4:("EnBbfall_SetupDown",), + 0x808BFB4C:("EnBbfall_Down",), + 0x808BFCCC:("EnBbfall_SetupDead",), + 0x808BFE58:("EnBbfall_Dead",), + 0x808BFF8C:("EnBbfall_SetupDamage",), + 0x808C00A0:("EnBbfall_Damage",), + 0x808C013C:("EnBbfall_SetupFrozen",), + 0x808C0178:("EnBbfall_Frozen",), + 0x808C01E0:("EnBbfall_UpdateDamage",), 0x808C03EC:("EnBbfall_Update",), - 0x808C07D4:("func_808C07D4",), - 0x808C080C:("func_808C080C",), + 0x808C07D4:("EnBbfall_OverrideLimbDraw",), + 0x808C080C:("EnBbfall_PostLimbDraw",), 0x808C0A04:("EnBbfall_Draw",), 0x808C1030:("ArmsHook_SetupAction",), 0x808C103C:("ArmsHook_Init",), @@ -7553,8 +7553,8 @@ 0x80946368:("func_80946368",), 0x80946400:("EnGe1_Draw",), 0x809466A0:("ObjBlockstop_Init",), - 0x809466F0:("func_809466F0",), - 0x809467E8:("func_809467E8",), + 0x809466F0:("ObjBlockstop_CheckForBlock",), + 0x809467E8:("ObjBlockstop_TryPlayCutscene",), 0x8094685C:("ObjBlockstop_Update",), 0x809468D0:("EnSda_Init",), 0x809468E0:("EnSda_Destroy",), @@ -9745,33 +9745,33 @@ 0x80A15D04:("EnGo_OverrideLimbDraw",), 0x80A15E38:("EnGo_TransfromLimbDraw",), 0x80A15FEC:("func_80A15FEC",), - 0x80A16D40:("func_80A16D40",), - 0x80A16D6C:("func_80A16D6C",), + 0x80A16D40:("EnRaf_ClearPixelTeeth",), + 0x80A16D6C:("EnRaf_ClearPixelPetal",), 0x80A16D90:("EnRaf_Init",), 0x80A17018:("EnRaf_Destroy",), - 0x80A17060:("func_80A17060",), - 0x80A1712C:("func_80A1712C",), - 0x80A171D8:("func_80A171D8",), - 0x80A17414:("func_80A17414",), - 0x80A17464:("func_80A17464",), - 0x80A17530:("func_80A17530",), - 0x80A175E4:("func_80A175E4",), - 0x80A17848:("func_80A17848",), - 0x80A178A0:("func_80A178A0",), - 0x80A179C8:("func_80A179C8",), - 0x80A17C6C:("func_80A17C6C",), - 0x80A17D14:("func_80A17D14",), - 0x80A17D54:("func_80A17D54",), - 0x80A17DDC:("func_80A17DDC",), - 0x80A17E1C:("func_80A17E1C",), - 0x80A18080:("func_80A18080",), - 0x80A180B4:("func_80A180B4",), + 0x80A17060:("EnRaf_ChangeAnimation",), + 0x80A1712C:("EnRaf_SetupIdle",), + 0x80A171D8:("EnRaf_Idle",), + 0x80A17414:("EnRaf_SetupGrab",), + 0x80A17464:("EnRaf_Grab",), + 0x80A17530:("EnRaf_SetupChew",), + 0x80A175E4:("EnRaf_Chew",), + 0x80A17848:("EnRaf_SetupThrow",), + 0x80A178A0:("EnRaf_Throw",), + 0x80A179C8:("EnRaf_Explode",), + 0x80A17C6C:("EnRaf_PostDetonation",), + 0x80A17D14:("EnRaf_SetupConvulse",), + 0x80A17D54:("EnRaf_Convulse",), + 0x80A17DDC:("EnRaf_SetupDissolve",), + 0x80A17E1C:("EnRaf_Dissolve",), + 0x80A18080:("EnRaf_SetupDormant",), + 0x80A180B4:("EnRaf_Dormant",), 0x80A181B4:("EnRaf_Update",), - 0x80A1859C:("func_80A1859C",), + 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("func_80A18A90",), - 0x80A18B8C:("func_80A18B8C",), - 0x80A18DA0:("func_80A18DA0",), + 0x80A18A90:("EnRaf_InitializeParticle",), + 0x80A18B8C:("EnRaf_UpdateParticles",), + 0x80A18DA0:("EnRaf_DrawParticles",), 0x80A19740:("ObjFunen_Init",), 0x80A19778:("ObjFunen_Draw",), 0x80A19910:("ObjRaillift_UpdatePosition",), @@ -13277,26 +13277,26 @@ 0x80B23F50:("ObjWind_Destroy",), 0x80B23F60:("ObjWind_Update",), 0x80B243C0:("ObjWind_Draw",), - 0x80B24630:("func_80B24630",), - 0x80B246F4:("func_80B246F4",), - 0x80B2478C:("func_80B2478C",), - 0x80B248B8:("func_80B248B8",), + 0x80B24630:("EnRacedog_ChangeAnimation",), + 0x80B246F4:("EnRacedog_UpdateCollision",), + 0x80B2478C:("EnRacedog_GetYRotation",), + 0x80B248B8:("EnRacedog_GetFloorRot",), 0x80B24930:("EnRacedog_Init",), 0x80B24BE8:("EnRacedog_Destroy",), - 0x80B24C14:("func_80B24C14",), - 0x80B24CB4:("func_80B24CB4",), - 0x80B24E14:("func_80B24E14",), - 0x80B24F08:("func_80B24F08",), - 0x80B251EC:("func_80B251EC",), - 0x80B252F8:("func_80B252F8",), - 0x80B2538C:("func_80B2538C",), - 0x80B25448:("func_80B25448",), - 0x80B25490:("func_80B25490",), - 0x80B255AC:("func_80B255AC",), - 0x80B256BC:("func_80B256BC",), + 0x80B24C14:("EnRacedog_RaceStart",), + 0x80B24CB4:("EnRacedog_Race",), + 0x80B24E14:("EnRacedog_UpdateTextId",), + 0x80B24F08:("EnRacedog_UpdateSpeed",), + 0x80B251EC:("EnRacedog_CalculateFinalStretchTargetSpeed",), + 0x80B252F8:("EnRacedog_UpdateRaceVariables",), + 0x80B2538C:("EnRacedog_CheckForFinish",), + 0x80B25448:("EnRacedog_UpdateRunAnimationPlaySpeed",), + 0x80B25490:("EnRacedog_IsOverFinishLine",), + 0x80B255AC:("EnRacedog_SpawnFloorDustRing",), + 0x80B256BC:("EnRacedog_PlayWalkSfx",), 0x80B25708:("EnRacedog_Update",), - 0x80B2583C:("func_80B2583C",), - 0x80B258D8:("func_80B258D8",), + 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), + 0x80B258D8:("EnRacedog_DrawSelectionArrow",), 0x80B25A74:("EnRacedog_OverrideLimbDraw",), 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), @@ -14278,7 +14278,7 @@ 0x80B6849C:("func_80B6849C",), 0x80B6D660:("BgSinkaiKabe_Init",), 0x80B6D9EC:("BgSinkaiKabe_Destroy",), - 0x80B6DA20:("func_80B6DA20",), + 0x80B6DA20:("BgSinkaiKabe_WaitForPlayer",), 0x80B6DB20:("BgSinkaiKabe_Update",), 0x80B6DBE0:("BgHakaCurtain_Init",), 0x80B6DC64:("BgHakaCurtain_Destroy",), @@ -14808,8 +14808,8 @@ 0x80B90E84:("EnMaYto_SetRomaniFaceExpression",), 0x80B90EC8:("EnMaYto_SetFaceExpression",), 0x80B90EF0:("EnMaYto_InitFaceExpression",), - 0x80B90F84:("EnMaYto_HasSpokeToPlayerToday",), - 0x80B91014:("EnMaYto_HasSpokeToPlayer",), + 0x80B90F84:("EnMaYto_HasSpokenToPlayerToday",), + 0x80B91014:("EnMaYto_HasSpokenToPlayer",), 0x80B9109C:("EnMaYto_SetTalkedFlag",), 0x80B9110C:("EnMaYto_Update",), 0x80B91154:("EnMaYto_OverrideLimbDraw",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 24720a884..02fc3e1ab 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -920,8 +920,8 @@ 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), - 0x801BC400:("gEnHyBodyPartsIndex","UNK_TYPE1","",0x1), - 0x801BC410:("gEnHyShadowSize","s32",[],0x10), + 0x801BC400:("gEnHyParentBodyParts","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSizes","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), @@ -1947,9 +1947,9 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("D_801C5D60","UNK_TYPE1","",0x1), - 0x801C5D80:("D_801C5D80","UNK_TYPE1","",0x1), - 0x801C5DB0:("D_801C5DB0","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowVtxDL","UNK_TYPE1","",0x1), + 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), 0x801C5DF0:("D_801C5DF0","UNK_TYPE1","",0x1), @@ -10863,10 +10863,10 @@ 0x80A16818:("jtbl_80A16818","UNK_PTR","",0x4), 0x80A18EC0:("En_Raf_InitVars","UNK_TYPE1","",0x1), 0x80A18EE0:("D_80A18EE0","UNK_TYPE1","",0x1), - 0x80A18F0C:("D_80A18F0C","UNK_TYPE1","",0x1), - 0x80A18F4C:("D_80A18F4C","UNK_TYPE1","",0x1), - 0x80A18F8C:("D_80A18F8C","UNK_TYPE1","",0x1), - 0x80A1918C:("D_80A1918C","UNK_TYPE1","",0x1), + 0x80A18F0C:("D_80A18F0C","u8","[0x40]",0x40), + 0x80A18F4C:("D_80A18F4C","u8","[0x40]",0x40), + 0x80A18F8C:("D_80A18F8C","u8","[0x200]",0x200), + 0x80A1918C:("D_80A1918C","u8","[0x200]",0x200), 0x80A1939C:("D_80A1939C","UNK_TYPE1","",0x1), 0x80A193BC:("D_80A193BC","UNK_TYPE4","",0x4), 0x80A193C8:("D_80A193C8","UNK_TYPE1","",0x1), @@ -10876,10 +10876,8 @@ 0x80A19400:("D_80A19400","UNK_TYPE4","",0x4), 0x80A1940C:("D_80A1940C","UNK_TYPE4","",0x4), 0x80A19418:("D_80A19418","UNK_TYPE2","",0x2), - 0x80A19420:("D_80A19420","UNK_TYPE1","",0x1), - 0x80A19438:("D_80A19438","UNK_TYPE1","",0x1), - 0x80A19444:("D_80A19444","UNK_TYPE1","",0x1), - 0x80A1945C:("D_80A1945C","UNK_TYPE1","",0x1), + 0x80A19420:("D_80A19420","Vec3f","[3]",0x24), + 0x80A19444:("D_80A19444","Vec3f","[3]",0x24), 0x80A19468:("D_80A19468","UNK_TYPE2","",0x2), 0x80A19474:("D_80A19474","UNK_TYPE1","",0x1), 0x80A194B0:("D_80A194B0","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index e5cf41071..c148efc57 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2172,7 +2172,7 @@ asm/non_matchings/code/z_snap/func_8013A530.s,func_8013A530,0x8013A530,0xA4 asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFlexLimb,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B -asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC +asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 @@ -2190,9 +2190,9 @@ asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 -asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E -asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 -asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 +asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E +asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 +asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 @@ -2217,11 +2217,11 @@ asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathin asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E -asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 -asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D +asm/non_matchings/code/z_sub_s/SubS_ConstructPlane.s,SubS_ConstructPlane,0x8013E4B0,0x47 +asm/non_matchings/code/z_sub_s/SubS_LineSegVsPlane.s,SubS_LineSegVsPlane,0x8013E5CC,0x1D asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E -asm/non_matchings/code/z_sub_s/func_8013E7C0.s,func_8013E7C0,0x8013E7C0,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 asm/non_matchings/code/z_sub_s/func_8013E950.s,func_8013E950,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD diff --git a/undefined_syms.txt b/undefined_syms.txt index bf08aa356..2ffe4ad8c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -685,10 +685,6 @@ D_06001A60 = 0x06001A60; D_06001B40 = 0x06001B40; D_06002CE0 = 0x06002CE0; -// ovl_Bg_Sinkai_Kabe - -D_06000048 = 0x06000048; - // ovl_Bg_Spout_Fire D_06000040 = 0x06000040; @@ -1016,12 +1012,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bbfall - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - // ovl_En_Bee D_0600005C = 0x0600005C; @@ -1447,15 +1437,6 @@ D_06004340 = 0x06004340; D_06001A80 = 0x06001A80; -// ovl_En_Raf - -D_06000108 = 0x06000108; -D_06000A64 = 0x06000A64; -D_060024E0 = 0x060024E0; -D_06002EF8 = 0x06002EF8; -D_060032F8 = 0x060032F8; -D_06003428 = 0x06003428; - // ovl_En_Rat D_06000174 = 0x06000174; @@ -1632,11 +1613,6 @@ D_06000F00 = 0x06000F00; D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dora - -D_06003FD0 = 0x06003FD0; -D_06004160 = 0x06004160; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0;