diff --git a/Makefile b/Makefile index 89eeb21d2..6394f8daa 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ MKLDSCRIPT := tools/buildtools/mkldscript YAZ0 := tools/buildtools/yaz0 ZAPD := tools/ZAPD/ZAPD.out FADO := tools/fado/fado.elf +MAKEYAR := tools/buildtools/makeyar OPTFLAGS := -O2 -g3 ASFLAGS := -march=vr4300 -32 -Iinclude @@ -184,9 +185,11 @@ C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard S_FILES := $(shell grep -F "build/asm" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') \ $(shell grep -F "build/data" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') BASEROM_FILES := $(shell grep -F "build/baserom" spec | sed 's/.*build\/// ; s/\.o\".*//') +ARCHIVES_O := $(shell grep -F ".yar.o" spec | sed 's/.*include "// ; s/\.o\".*/.o/') O_FILES := $(foreach f,$(S_FILES:.s=.o),build/$f) \ $(foreach f,$(C_FILES:.c=.o),build/$f) \ - $(foreach f,$(BASEROM_FILES),build/$f.o) + $(foreach f,$(BASEROM_FILES),build/$f.o) \ + $(ARCHIVES_O) OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | grep -o '[^"]*_reloc.o' ) @@ -303,6 +306,7 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py + python3 tools/decompress_yars.py assets: python3 extract_assets.py -j $(N_THREADS) @@ -344,6 +348,10 @@ build/assets/%.o: assets/%.c $(OBJCOPY_BIN) $(RM_MDEBUG) +build/assets/archives/%.yar.o: build/assets/archives/%.o + $(MAKEYAR) $< $(@:.yar.o=.yar.bin) $(@:.yar.o=.symbols.o) + $(OBJCOPY) -I binary -O elf32-big $(@:.yar.o=.yar.bin) $@ + build/baserom/%.o: baserom/% $(OBJCOPY) -I binary -O elf32-big $< $@ @@ -392,3 +400,6 @@ build/assets/%.jpg.inc.c: assets/%.jpg $(ZAPD) bren -eh -i $< -o $@ -include $(DEP_FILES) + +# Print target for debugging +print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true diff --git a/assets/xml/archives/icon_item_24_static.xml b/assets/xml/archives/icon_item_24_static.xml new file mode 100644 index 000000000..7b3b338a3 --- /dev/null +++ b/assets/xml/archives/icon_item_24_static.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/icon_item_static.xml b/assets/xml/archives/icon_item_static.xml new file mode 100644 index 000000000..3084ab2a5 --- /dev/null +++ b/assets/xml/archives/icon_item_static.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/item_name_static.xml b/assets/xml/archives/item_name_static.xml new file mode 100644 index 000000000..280d8862a --- /dev/null +++ b/assets/xml/archives/item_name_static.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/map_grand_static.xml b/assets/xml/archives/map_grand_static.xml new file mode 100644 index 000000000..d5d80bdd6 --- /dev/null +++ b/assets/xml/archives/map_grand_static.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/map_i_static.xml b/assets/xml/archives/map_i_static.xml new file mode 100644 index 000000000..dbb64185d --- /dev/null +++ b/assets/xml/archives/map_i_static.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/map_name_static.xml b/assets/xml/archives/map_name_static.xml new file mode 100644 index 000000000..980eb890e --- /dev/null +++ b/assets/xml/archives/map_name_static.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/archives/schedule_dma_static.xml b/assets/xml/archives/schedule_dma_static.xml new file mode 100644 index 000000000..f3b7ba834 --- /dev/null +++ b/assets/xml/archives/schedule_dma_static.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index acdcedb1d..93e5640b6 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -1,54 +1,83 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_snowwd.xml b/assets/xml/objects/object_snowwd.xml index c61d07beb..9bb2209d9 100644 --- a/assets/xml/objects/object_snowwd.xml +++ b/assets/xml/objects/object_snowwd.xml @@ -1,9 +1,9 @@  - - - - - + + + + + diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml index 0e5054c19..aa38c8533 100644 --- a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -7,7 +7,7 @@ - - + + diff --git a/docs/tools.md b/docs/tools.md index 5005f7f93..e190fe0a3 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -273,7 +273,7 @@ Probably the best of the Nintendo 64 texture viewing programs. It is quite simpl ### Z64Utils -Basically essential for convenient analysis of object files. Can analyse and display DisplayLists, some textures, skeletons, animations, and a few other resources. Download from . +Basically essential for convenient analysis of object files. Can analyse and display DisplayLists, some textures, skeletons, animations, and a few other resources. Download from . ## Retired tools diff --git a/include/functions.h b/include/functions.h index 967b6803c..6eab80b5a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -787,217 +787,6 @@ void Camera_SetTargetActor(Camera* camera, Actor* actor); f32 Camera_GetWaterYPos(Camera* camera); void func_800E0348(Camera* camera); -DamageTable* DamageTable_Get(s32 index); -void DamageTable_Clear(DamageTable* damageTable); -f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, u32* effect); -f32 CollisionCheck_ApplyBumperDefense(f32 damage, ColliderInfo* ac); -s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo); -s32 Collider_InitBase(PlayState* play, Collider* collider); -s32 Collider_DestroyBase(PlayState* play, Collider* collider); -s32 Collider_SetBaseToActor(PlayState* play, Collider* collider, ColliderInitToActor* src); -s32 Collider_SetBaseType1(PlayState* play, Collider* collider, Actor* actor, ColliderInitType1* src); -s32 Collider_SetBase(PlayState* play, Collider* collider, Actor* actor, ColliderInit* src); -void Collider_ResetATBase(PlayState* play, Collider* collider); -void Collider_ResetACBase(PlayState* play, Collider* collider); -void Collider_ResetOCBase(PlayState* play, Collider* collider); -s32 Collider_InitTouch(PlayState* play, ColliderTouch* touch); -s32 Collider_DestroyTouch(PlayState* play, ColliderTouch* touch); -s32 Collider_SetTouch(PlayState* play, ColliderTouch* touch, ColliderTouchInit* src); -void Collider_ResetATInfoUnk(PlayState* play, ColliderInfo* info); -s32 Collider_InitBump(PlayState* play, ColliderBump* bump); -s32 Collider_DestroyBump(PlayState* play, ColliderBump* bump); -s32 Collider_SetBump(PlayState* play, ColliderBump* bump, ColliderBumpInit* src); -s32 Collider_InitInfo(PlayState* play, ColliderInfo* info); -s32 Collider_DestroyInfo(PlayState* play, ColliderInfo* info); -s32 Collider_SetInfo(PlayState* play, ColliderInfo* info, ColliderInfoInit* src); -void Collider_ResetATInfo(PlayState* play, ColliderInfo* info); -void Collider_ResetACInfo(PlayState* play, ColliderInfo* info); -void Collider_ResetOCInfo(PlayState* play, ColliderInfo* info); -s32 Collider_InitJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim); -s32 Collider_DestroyJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim); -s32 Collider_SetJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src); -s32 Collider_InitJntSphElement(PlayState* play, ColliderJntSphElement* element); -s32 Collider_DestroyJntSphElement(PlayState* play, ColliderJntSphElement* element); -s32 Collider_SetJntSphElement(PlayState* play, ColliderJntSphElement* dest, ColliderJntSphElementInit* src); -s32 Collider_ResetJntSphElementAT(PlayState* play, ColliderJntSphElement* collider); -s32 Collider_ResetJntSphElementAC(PlayState* play, ColliderJntSphElement* collider); -s32 Collider_ResetJntSphElementOC(PlayState* play, ColliderJntSphElement* collider); -s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* collider); -s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* collider); -s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* collider); -s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* collider, ColliderJntSphInitToActor* src); -s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInitType1* src); -s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); -s32 Collider_InitAndSetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); -s32 Collider_ResetJntSphAT(PlayState* play, Collider* collider); -s32 Collider_ResetJntSphAC(PlayState* play, Collider* collider); -s32 Collider_ResetJntSphOC(PlayState* play, Collider* collider); -s32 Collider_InitCylinderDim(PlayState* play, Cylinder16* dim); -s32 Collider_DestroyCylinderDim(PlayState* play, Cylinder16* dim); -s32 Collider_SetCylinderDim(PlayState* play, Cylinder16* dim, Cylinder16* src); -s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* collider); -s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* collider); -s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* collider, ColliderCylinderInitToActor* src); -s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInitType1* src); -s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src); -s32 Collider_InitAndSetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src); -s32 Collider_ResetCylinderAT(PlayState* play, Collider* collider); -s32 Collider_ResetCylinderAC(PlayState* play, Collider* collider); -s32 Collider_ResetCylinderOC(PlayState* play, Collider* collider); -s32 Collider_InitTrisElementDim(PlayState* play, TriNorm* dim); -s32 Collider_DestroyTrisElementDim(PlayState* play, TriNorm* dim); -s32 Collider_SetTrisElementDim(PlayState* play, TriNorm* dim, ColliderTrisElementDimInit* src); -s32 Collider_InitTrisElement(PlayState* play, ColliderTrisElement* element); -s32 Collider_DestroyTrisElement(PlayState* play, ColliderTrisElement* element); -s32 Collider_SetTrisElement(PlayState* play, ColliderTrisElement* element, ColliderTrisElementInit* src); -s32 Collider_ResetTrisElementAT(PlayState* play, ColliderTrisElement* element); -s32 Collider_ResetTrisElementAC(PlayState* play, ColliderTrisElement* element); -s32 Collider_ResetTrisElementOC(PlayState* play, ColliderTrisElement* element); -s32 Collider_InitTris(PlayState* play, ColliderTris* tris); -s32 Collider_FreeTris(PlayState* play, ColliderTris* tris); -s32 Collider_DestroyTris(PlayState* play, ColliderTris* tris); -s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src); -s32 Collider_SetTris(PlayState* play, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* tris); -s32 Collider_InitAndSetTris(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements); -s32 Collider_ResetTrisAT(PlayState* play, Collider* collider); -s32 Collider_ResetTrisAC(PlayState* play, Collider* collider); -s32 Collider_ResetTrisOC(PlayState* play, Collider* collider); -s32 Collider_InitQuadDim(PlayState* play, ColliderQuadDim* dim); -s32 Collider_DestroyQuadDim(PlayState* play, ColliderQuadDim* dim); -s32 Collider_ResetQuadACDist(PlayState* play, ColliderQuadDim* dim); -void Collider_SetQuadMidpoints(ColliderQuadDim* dim); -s32 Collider_SetQuadDim(PlayState* play, ColliderQuadDim* dim, ColliderQuadDimInit* init); -s32 Collider_InitQuad(PlayState* play, ColliderQuad* collider); -s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* collider); -s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src); -s32 Collider_SetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src); -s32 Collider_InitAndSetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src); -s32 Collider_ResetQuadAT(PlayState* play, Collider* collider); -s32 Collider_ResetQuadAC(PlayState* play, Collider* collider); -s32 Collider_ResetQuadOC(PlayState* play, Collider* collider); -s32 Collider_QuadSetNearestAC(PlayState* play, ColliderQuad* quad, Vec3f* hitPos); -s32 Collider_InitSphere(PlayState* play, ColliderSphere* collider); -s32 Collider_DestroySphere(PlayState* play, ColliderSphere* collider); -s32 Collider_SetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src); -s32 Collider_InitAndSetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src); -s32 Collider_ResetSphereAT(PlayState* play, Collider* collider); -s32 Collider_ResetSphereAC(PlayState* play, Collider* collider); -s32 Collider_ResetSphereOC(PlayState* play, Collider* collider); -s32 Collider_InitLine(PlayState* play, OcLine* line); -s32 Collider_DestroyLine(PlayState* play, OcLine* line); -s32 Collider_SetLinePoints(PlayState* play, OcLine* line, Vec3f* a, Vec3f* b); -s32 Collider_SetLine(PlayState* play, OcLine* line, OcLine* src); -s32 Collider_ResetLineOC(PlayState* play, OcLine* line); -void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colCtxt); -s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); -s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colCtxt, OcLine* line); -s32 CollisionCheck_SkipTouch(ColliderInfo* info); -s32 CollisionCheck_SkipBump(ColliderInfo* info); -s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper); -void CollisionCheck_NoBlood(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_GreenBlood(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_WaterBurst(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_RedBlood(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_RedBloodUnused(PlayState* play, Collider* collider, Vec3f* v); -void CollisionCheck_HitSolid(PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos); -s32 CollisionCheck_SwordHitAudio(Collider* at, ColliderInfo* acInfo); -void CollisionCheck_HitEffects(PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, Vec3f* hitPos); -void CollisionCheck_SetBounce(Collider* at, Collider* ac); -s32 CollisionCheck_SetATvsAC(PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos); -void CollisionCheck_TrisAvgPoint(ColliderTrisElement* tri, Vec3f* avg); -void CollisionCheck_QuadAvgPoint(ColliderQuad* quad, Vec3f* avg); -void CollisionCheck_AC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_TrisVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_QuadVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsCylinder(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_AC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); -void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetQuadHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetSphereHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_SetHitEffects(PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_AC(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT); -void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colCtxt); -s32 CollisionCheck_GetMassType(u8 mass); -void CollisionCheck_SetOCvsOC(PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap); -void CollisionCheck_OC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -void CollisionCheck_OC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); -s32 CollisionCheck_SkipOC(Collider* collider); -s32 CollisionCheck_Incompatible(Collider* left, Collider* right); -void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colCtxt); -void CollisionCheck_InitInfo(CollisionCheckInfo* info); -void CollisionCheck_ResetDamage(CollisionCheckInfo* info); -void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init); -void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init); -void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init); -void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init); -void CollisionCheck_ApplyDamage(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, ColliderInfo* info); -void CollisionCheck_ApplyDamageJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_ApplyDamageSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); -void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colCtxt); -s32 CollisionCheck_LineOC_JntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC_Cyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC_Sphere(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOC(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions); -s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b); -s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions); -void Collider_UpdateCylinder(Actor* actor, ColliderCylinder* collider); -void Collider_SetCylinderPosition(ColliderCylinder* collider, Vec3s* pos); -void Collider_SetQuadVertices(ColliderQuad* collider, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d); -void Collider_SetTrisVertices(ColliderTris* collider, s32 index, Vec3f* a, Vec3f* b, Vec3f* c); -void Collider_SetTrisDim(PlayState* play, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* init); -void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider); -void Collider_UpdateSpheresElement(ColliderJntSph* collider, s32 index, Actor* actor); -void Collider_UpdateSphere(s32 limb, ColliderSphere* collider); -void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetal(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesMetalSound(PlayState* play, Vec3f* v, Vec3f* pos); -void CollisionCheck_SpawnShieldParticlesMetal2(PlayState* play, Vec3f* v); -void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* pos); -s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); void Actor_ContinueText(PlayState* play, Actor* actor, u16 textId); s32 Flags_GetEventChkInf(s32 flag); void Flags_SetEventChkInf(s32 flag); @@ -1011,14 +800,8 @@ void SaveContext_Init(void); void GetItem_Draw(PlayState* play, s16 drawId); -void SoundSource_InitAll(PlayState* play); -void SoundSource_UpdateAll(PlayState* play); -void SoundSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId); -void SoundSource_PlaySfxEachFrameAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId); u16 QuestHint_GetTatlTextId(PlayState* play); -u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet); - void func_800F4A10(PlayState* play); void KaleidoSetup_Update(PlayState* play); void KaleidoSetup_Init(PlayState* play); @@ -1075,10 +858,10 @@ void Environment_FillScreen(GraphicsContext* gfxCtx, u8 red, u8 green, u8 blue, void Environment_DrawSandstorm(PlayState* play, u8 sandstormState); s32 func_800FD2B4(PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 arg4); void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* param_4); -void func_800FD59C(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD5E0(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD654(PlayState* play, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD698(PlayState* play, s16 arg1, s16 arg2, f32 arg3); +void Environment_LerpAmbientColor(PlayState* play, Color_RGB8* to, f32 lerp); +void Environment_LerpDiffuseColor(PlayState* play, Color_RGB8* to, f32 lerp); +void Environment_LerpFogColor(PlayState* play, Color_RGB8* to, f32 lerp); +void Environment_LerpFog(PlayState* play, s16 fogNearTarget, s16 zFarTarget, f32 lerp); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); @@ -1355,51 +1138,6 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b); void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); -Gfx* Gfx_DrawTexRectRGBA16(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); -Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); -Gfx* Gfx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); -Gfx* Gfx_DrawTexQuadIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, u16 point); -Gfx* Gfx_DrawTexQuad4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, s16 textureHeight, u16 point); - -void Interface_StartTimer(s16 timerId, s16 seconds); -void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState); -void Interface_NewDay(PlayState* play, s32 day); -void Interface_SetHudVisibility(u16 hudVisibility); -void Interface_UpdateButtonsPart2(PlayState* play); -void Interface_SetSceneRestrictions(PlayState* play); -void Interface_InitMinigame(PlayState* play); -void Interface_LoadItemIconImpl(PlayState* play, u8 btn); -void Interface_LoadItemIcon(PlayState* play, u8 btn); -void Interface_UpdateButtonsAlt(PlayState* play, u16 flag); -u8 Item_Give(PlayState* play, u8 item); -u8 Item_CheckObtainability(u8 item); -void Inventory_DeleteItem(s16 item, s16 slot); -void Inventory_UnequipItem(s16 item); -s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem); -void Inventory_UpdateDeitySwordEquip(PlayState* play) ; -s32 Inventory_HasEmptyBottle(void); -s32 Inventory_HasItemInBottle(u8 item); -void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 btn); -s32 Inventory_ConsumeFairy(PlayState* play); -void Inventory_UpdateItem(PlayState* play, s16 slot, s16 item); -void Interface_SetAButtonDoAction(PlayState* play, u16 aButtonDoAction); -void Interface_SetBButtonDoAction(PlayState* play, s16 bButtonDoAction); -void Interface_SetTatlCall(PlayState* play, u16 tatlCallState); -void Interface_LoadBButtonDoActionLabel(PlayState* play, s16 bButtonDoAction); -s32 Health_ChangeBy(PlayState* play, s16 healthChange); -void Health_GiveHearts(s16 hearts); -void Rupees_ChangeBy(s16 rupeeChange); -void Inventory_ChangeAmmo(s16 item, s16 ammoChange); -void Magic_Add(PlayState* play, s16 magicToAdd); -void Magic_Reset(PlayState* play); -s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type); -void Interface_SetPerfectLetters(PlayState* play, s16 perfectLettersType); -void Interface_StartMoonCrash(PlayState* play); -void Interface_Draw(PlayState* play); -void Interface_Update(PlayState* play); -void Interface_Destroy(PlayState* play); -void Interface_Init(PlayState* play); - Path* Path_GetByIndex(PlayState* play, s16 index, s16 indexNone); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); @@ -1498,90 +1236,6 @@ void Inventory_SaveDekuPlaygroundHighScore(s16 timerId); void Inventory_IncrementSkullTokenCount(s16 sceneIndex); s16 Inventory_GetSkullTokenCount(s16 sceneIndex); void Inventory_SaveLotteryCodeGuess(PlayState* play); -s32 Object_Spawn(ObjectContext* objectCtx, s16 id); -void Object_InitBank(GameState* gameState, ObjectContext* objectCtx); -void Object_UpdateBank(ObjectContext* objectCtx); -s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId); -s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index); -void Object_LoadAll(ObjectContext* objectCtx); -void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id); -void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd); -void Scene_CommandActorList(PlayState* play, SceneCmd* cmd); -void Scene_CommandActorCutsceneCamList(PlayState* play, SceneCmd* cmd); -void Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd); -void Scene_CommandRoomList(PlayState* play, SceneCmd* cmd); -void Scene_CommandEntranceList(PlayState* play, SceneCmd* cmd); -void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd); -void Scene_CommandRoomBehavior(PlayState* play, SceneCmd* cmd); -void Scene_CommandMesh(PlayState* play, SceneCmd* cmd); -void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd); -void Scene_CommandLightList(PlayState* play, SceneCmd* cmd); -void Scene_CommandPathList(PlayState* play, SceneCmd* cmd); -void Scene_CommandTransiActorList(PlayState* play, SceneCmd* cmd); -void Door_InitContext(GameState* gameState, DoorContext* doorCtx); -void Scene_CommandEnvLightSettings(PlayState* play, SceneCmd* cmd); -void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex); -void Scene_CommandSkyboxSettings(PlayState* play, SceneCmd* cmd); -void Scene_CommandSkyboxDisables(PlayState* play, SceneCmd* cmd); -void Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd); -void Scene_CommandWindSettings(PlayState* play, SceneCmd* cmd); -void Scene_CommandExitList(PlayState* play, SceneCmd* cmd); -void Scene_Command09(PlayState* play, SceneCmd* cmd); -void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd); -void Scene_CommandEchoSetting(PlayState* play, SceneCmd* cmd); -void Scene_CommandAltHeaderList(PlayState* play, SceneCmd* cmd); -void Scene_CommandCutsceneScriptList(PlayState* play, SceneCmd* cmd); -void Scene_CommandCutsceneList(PlayState* play, SceneCmd* cmd); -void Scene_CommandMiniMap(PlayState* play, SceneCmd* cmd); -void Scene_Command1D(PlayState* play, SceneCmd* cmd); -void Scene_CommandMiniMapCompassInfo(PlayState* play, SceneCmd* cmd); -void Scene_CommandSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd); -void Scene_CommandAnimatedMaterials(PlayState* play, SceneCmd* cmd); -void Scene_SetExitFade(PlayState* play); -s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd); -u16 Entrance_Create(s32 scene, s32 spawn, s32 layer); -u16 Entrance_CreateFromSpawn(s32 spawn); -void Scene_Draw(PlayState* play); -void Scene_DrawConfigDefault(PlayState* play); -Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params); -void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params); -Gfx* AnimatedMat_TwoLayerTexScroll(PlayState* play, AnimatedMatTexScrollParams* params); -void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params); -void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor); -void AnimatedMat_DrawColor(PlayState* play, s32 segment, void* params); -s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm); -void AnimatedMat_DrawColorLerp(PlayState* play, s32 segment, void* params); -f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp); -u8 Scene_LagrangeInterpColor(s32 n, f32 x[], f32 fx[], f32 xp); -void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* params); -void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params); -void AnimatedMat_DrawMain(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags); -void AnimatedMat_Draw(PlayState* play, AnimatedMaterial* matAnim); -void AnimatedMat_DrawOpa(PlayState* play, AnimatedMaterial* matAnim); -void AnimatedMat_DrawXlu(PlayState* play, AnimatedMaterial* matAnim); -void AnimatedMat_DrawAlpha(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); -void AnimatedMat_DrawAlphaOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); -void AnimatedMat_DrawAlphaXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); -void AnimatedMat_DrawStep(PlayState* play, AnimatedMaterial* matAnim, u32 step); -void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* matAnim, u32 step); -void AnimatedMat_DrawStepXlu(PlayState* play, AnimatedMaterial* matAnim, u32 step); -void AnimatedMat_DrawAlphaStep(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); -void AnimatedMat_DrawAlphaStepOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); -void AnimatedMat_DrawAlphaStepXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); -void Scene_DrawConfigMatAnim(PlayState* play); -void Scene_DrawConfig3(PlayState* play); -void Scene_DrawConfig4(PlayState* play); -void Scene_DrawConfigDoNothing(PlayState* play); -void Scene_SetRenderModeXlu(PlayState* play, s32 index, u32 flags); -void Scene_SetCullFlag(PlayState* play, s32 index, u32 flags); -void Scene_DrawConfig5(PlayState* play); -void Scene_DrawConfigMatAnimManualStep(PlayState* play); -void Scene_DrawConfigGreatBayTemple(PlayState* play); -EntranceTableEntry* Entrance_GetTableEntry(u16 entrance); -s32 Entrance_GetSceneId(u16 entrance); -s32 Entrance_GetSceneIdAbsolute(u16 entrance); -s32 Entrance_GetSpawnNum(u16 entrance); -s32 Entrance_GetTransitionFlags(u16 entrance); s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output); diff --git a/include/global.h b/include/global.h index 9fa3ef7bc..193c2d90d 100644 --- a/include/global.h +++ b/include/global.h @@ -2,7 +2,6 @@ #define GLOBAL_H #include "z64.h" -#include "regs.h" #include "functions.h" #include "variables.h" #include "macros.h" diff --git a/include/macros.h b/include/macros.h index 6b54474b6..7924066b6 100644 --- a/include/macros.h +++ b/include/macros.h @@ -3,7 +3,6 @@ #include "libc/stdint.h" #include "ultra64/convert.h" -#include "z64.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 diff --git a/include/segment_symbols.h b/include/segment_symbols.h index d7c959d23..214970933 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -52,12 +52,12 @@ DECLARE_ROM_SEGMENT(map_i_static) DECLARE_ROM_SEGMENT(map_grand_static) DECLARE_ROM_SEGMENT(item_name_static) DECLARE_ROM_SEGMENT(map_name_static) -DECLARE_ROM_SEGMENT(icon_item_static_test) -DECLARE_ROM_SEGMENT(icon_item_static_old) -DECLARE_ROM_SEGMENT(icon_item_24_static_test) -DECLARE_ROM_SEGMENT(icon_item_24_static_old) -DECLARE_ROM_SEGMENT(schedule_dma_static_test) -DECLARE_ROM_SEGMENT(schedule_dma_static_old) +DECLARE_ROM_SEGMENT(icon_item_static_yar) +DECLARE_ROM_SEGMENT(icon_item_static_syms) +DECLARE_ROM_SEGMENT(icon_item_24_static_yar) +DECLARE_ROM_SEGMENT(icon_item_24_static_syms) +DECLARE_ROM_SEGMENT(schedule_dma_static_yar) +DECLARE_ROM_SEGMENT(schedule_dma_static_syms) DECLARE_ROM_SEGMENT(schedule_static) DECLARE_ROM_SEGMENT(story_static) DECLARE_ROM_SEGMENT(do_action_static) diff --git a/include/tables/bombers_notebook/person_table.h b/include/tables/bombers_notebook/person_table.h index 71771956b..e6ef49b27 100644 --- a/include/tables/bombers_notebook/person_table.h +++ b/include/tables/bombers_notebook/person_table.h @@ -9,23 +9,23 @@ * - Argument 4: Message id for the event meeting this person * - Argument 5: WeekEventFlag for the event meeting this person */ -/* 0x00 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMBERS, D_07009800, 0x21DD, BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS, 0x2147, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS) -/* 0x01 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJU, D_07000000, 0x21CA, BOMBERS_NOTEBOOK_EVENT_MET_ANJU, 0x2134, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJU) -/* 0x02 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAFEI, D_07000800, 0x21CB, BOMBERS_NOTEBOOK_EVENT_MET_KAFEI, 0x2135, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAFEI) -/* 0x03 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CURIOSITY_SHOP_MAN, D_07001000, 0x21CC, BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN, 0x2136, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN) -/* 0x04 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMB_SHOP_LADY, D_07001800, 0x21CD, BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY, 0x2137, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY) -/* 0x05 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROMANI, D_07002000, 0x21CE, BOMBERS_NOTEBOOK_EVENT_MET_ROMANI, 0x2138, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROMANI) -/* 0x06 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CREMIA, D_07002800, 0x21CF, BOMBERS_NOTEBOOK_EVENT_MET_CREMIA, 0x2139, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CREMIA) -/* 0x07 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MAYOR_DOTOUR, D_07003000, 0x21D0, BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR, 0x213A, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR) -/* 0x08 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MADAME_AROMA, D_07003800, 0x21D1, BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA, 0x213B, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA) -/* 0x09 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOTO, D_07004000, 0x21D2, BOMBERS_NOTEBOOK_EVENT_MET_TOTO, 0x213C, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOTO) -/* 0x0A */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN, D_07004800, 0x21D3, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN, 0x213D, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN) -/* 0x0B */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_POSTMAN, D_07005000, 0x21D4, BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN, 0x213E, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN) -/* 0x0C */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROSA_SISTERS, D_07005800, 0x21D5, BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS, 0x213F, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS) -/* 0x0D */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOILET_HAND, D_07006000, 0x21D6, BOMBERS_NOTEBOOK_EVENT_MET_TOLIET_HAND, 0x2140, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOILET_HAND) -/* 0x0E */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJUS_GRANDMOTHER, D_07006800, 0x21D7, BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER, 0x2141, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER) -/* 0x0F */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAMARO, D_07007000, 0x21D8, BOMBERS_NOTEBOOK_EVENT_MET_KAMARO, 0x2142, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAMARO) -/* 0x10 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GROG, D_07007800, 0x21D9, BOMBERS_NOTEBOOK_EVENT_MET_GROG, 0x2143, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GROG) -/* 0x11 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN_BROTHERS, D_07008000, 0x21DA, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS, 0x2144, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS) -/* 0x12 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_SHIRO, D_07008800, 0x21DB, BOMBERS_NOTEBOOK_EVENT_MET_SHIRO, 0x2145, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_SHIRO) -/* 0x13 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GURU_GURU, D_07009000, 0x21DC, BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU, 0x2146, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU) +/* 0x00 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMBERS, schedule_dma_static_yar_Blob_009800, 0x21DD, BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS, 0x2147, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS) +/* 0x01 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJU, schedule_dma_static_yar_Blob_000000, 0x21CA, BOMBERS_NOTEBOOK_EVENT_MET_ANJU, 0x2134, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJU) +/* 0x02 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAFEI, schedule_dma_static_yar_Blob_000800, 0x21CB, BOMBERS_NOTEBOOK_EVENT_MET_KAFEI, 0x2135, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAFEI) +/* 0x03 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CURIOSITY_SHOP_MAN, schedule_dma_static_yar_Blob_001000, 0x21CC, BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN, 0x2136, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN) +/* 0x04 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_BOMB_SHOP_LADY, schedule_dma_static_yar_Blob_001800, 0x21CD, BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY, 0x2137, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY) +/* 0x05 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROMANI, schedule_dma_static_yar_Blob_002000, 0x21CE, BOMBERS_NOTEBOOK_EVENT_MET_ROMANI, 0x2138, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROMANI) +/* 0x06 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_CREMIA, schedule_dma_static_yar_Blob_002800, 0x21CF, BOMBERS_NOTEBOOK_EVENT_MET_CREMIA, 0x2139, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CREMIA) +/* 0x07 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MAYOR_DOTOUR, schedule_dma_static_yar_Blob_003000, 0x21D0, BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR, 0x213A, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR) +/* 0x08 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_MADAME_AROMA, schedule_dma_static_yar_Blob_003800, 0x21D1, BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA, 0x213B, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA) +/* 0x09 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOTO, schedule_dma_static_yar_Blob_004000, 0x21D2, BOMBERS_NOTEBOOK_EVENT_MET_TOTO, 0x213C, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOTO) +/* 0x0A */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN, schedule_dma_static_yar_Blob_004800, 0x21D3, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN, 0x213D, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN) +/* 0x0B */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_POSTMAN, schedule_dma_static_yar_Blob_005000, 0x21D4, BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN, 0x213E, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN) +/* 0x0C */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ROSA_SISTERS, schedule_dma_static_yar_Blob_005800, 0x21D5, BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS, 0x213F, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS) +/* 0x0D */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_TOILET_HAND, schedule_dma_static_yar_Blob_006000, 0x21D6, BOMBERS_NOTEBOOK_EVENT_MET_TOLIET_HAND, 0x2140, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOILET_HAND) +/* 0x0E */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_ANJUS_GRANDMOTHER, schedule_dma_static_yar_Blob_006800, 0x21D7, BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER, 0x2141, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER) +/* 0x0F */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_KAMARO, schedule_dma_static_yar_Blob_007000, 0x21D8, BOMBERS_NOTEBOOK_EVENT_MET_KAMARO, 0x2142, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAMARO) +/* 0x10 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GROG, schedule_dma_static_yar_Blob_007800, 0x21D9, BOMBERS_NOTEBOOK_EVENT_MET_GROG, 0x2143, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GROG) +/* 0x11 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GORMAN_BROTHERS, schedule_dma_static_yar_Blob_008000, 0x21DA, BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS, 0x2144, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS) +/* 0x12 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_SHIRO, schedule_dma_static_yar_Blob_008800, 0x21DB, BOMBERS_NOTEBOOK_EVENT_MET_SHIRO, 0x2145, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_SHIRO) +/* 0x13 */ DEFINE_PERSON(BOMBERS_NOTEBOOK_PERSON_GURU_GURU, schedule_dma_static_yar_Blob_009000, 0x21DC, BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU, 0x2146, WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU) diff --git a/include/variables.h b/include/variables.h index 7cdf40e31..1886d3519 100644 --- a/include/variables.h +++ b/include/variables.h @@ -366,7 +366,7 @@ extern UNK_PTR D_801AE260[3]; // extern UNK_TYPE1 D_801AE48C; // extern UNK_TYPE1 D_801AE490; extern EffectSsOverlay gParticleOverlayTable[39]; -// extern FlagSetEntry sFlagEntries[]; + // extern s32 sEntryIndex; // extern u32 sCurrentBit; // extern s32 sTimer; @@ -377,36 +377,6 @@ extern BgCheckSceneSubdivisionEntry sSceneSubdivisionList[]; extern BgSpecialSceneMaxObjects sCustomDynapolyMem[]; // extern UNK_TYPE1 D_801B4708; -extern DamageTable sDamageTablePresets[23]; -extern f32 damageMultipliers[16]; -extern Collider defaultCollider; -extern ColliderTouch defaultColliderTouch; -extern ColliderBump defaultColliderBump; -extern ColliderInfo defaultColliderInfo; -extern ColliderJntSphElementDim defaultColliderJntSphElementDim; -extern Cylinder16 defaultColliderCylinderDim; -extern TriNorm defaultColliderTrisElementDim; -extern ColliderQuadDim defaultColliderQuadDim; -extern Vec3f defaultLinePoint; -extern ColChkResetFunc sATResetFuncs[COLSHAPE_MAX]; -extern ColChkResetFunc sACResetFuncs[COLSHAPE_MAX]; -extern ColChkResetFunc sOCResetFuncs[COLSHAPE_MAX]; -extern ColChkBloodFunc sBloodFuncs[6]; -extern HitInfo sHitInfo[14]; -extern ColChkApplyFunc sColChkApplyFuncs[COLSHAPE_MAX]; -extern ColChkVsFunc sACVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX]; -extern ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX]; -extern CollisionCheckInfo defaultColChkInfo; -extern ColChkApplyFunc sApplyDamageFuncs[COLSHAPE_MAX]; -extern ColChkLineFunc sOCLineCheckFuncs[COLSHAPE_MAX]; -extern EffectShieldParticleInit shieldParticleInitMetal; -extern EffectShieldParticleInit shieldParticleInitWood; -// extern UNK_TYPE4 D_801BB090; -// extern UNK_TYPE1 D_801BB094; -// extern UNK_TYPE1 D_801BB0DC; -// extern UNK_TYPE2 D_801BB0FC; -// extern UNK_TYPE1 D_801BB100; - extern u8 gOpeningEntranceIndex; extern ActorCutscene sGlobalCutsceneList[8]; @@ -2250,7 +2220,6 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F5730; // extern UNK_TYPE1 D_801F57B4; // extern UNK_TYPE1 D_801F5834; -// extern NmiBuff* gNMIBuffer; // extern UNK_TYPE1 sSkyboxDrawMatrix; // extern UNK_TYPE1 D_801F6AF0; diff --git a/include/z64.h b/include/z64.h index e9e564e4d..de3116f13 100644 --- a/include/z64.h +++ b/include/z64.h @@ -60,67 +60,12 @@ #include "z64schedule.h" #include "z64skin.h" #include "z64skybox.h" +#include "z64sound_source.h" #include "z64subs.h" #include "z64transition.h" #include "z64view.h" #include "regs.h" -#define Z_THREAD_ID_IDLE 1 -#define Z_THREAD_ID_SLOWLY 2 -#define Z_THREAD_ID_MAIN 3 -#define Z_THREAD_ID_GRAPH 4 -#define Z_THREAD_ID_SCHED 5 -#define Z_THREAD_ID_FLASHROM 13 -#define Z_THREAD_ID_DMAMGR 18 -#define Z_THREAD_ID_IRQMGR 19 - -#define Z_PRIORITY_SLOWLY 5 -#define Z_PRIORITY_GRAPH 9 -#define Z_PRIORITY_AUDIOMGR 11 -#define Z_PRIORITY_IDLE 12 -#define Z_PRIORITY_MAIN 12 -#define Z_PRIORITY_FLASHROM 13 -#define Z_PRIORITY_PADMGR 15 -#define Z_PRIORITY_SCHED 16 -#define Z_PRIORITY_DMAMGR 17 -#define Z_PRIORITY_IRQMGR 18 - -typedef enum { - /* -1 */ EQUIP_SLOT_NONE = -1, - /* 0 */ EQUIP_SLOT_B, - /* 1 */ EQUIP_SLOT_C_LEFT, - /* 2 */ EQUIP_SLOT_C_DOWN, - /* 3 */ EQUIP_SLOT_C_RIGHT, - /* 4 */ EQUIP_SLOT_A -} EquipSlot; - -typedef struct { - /* 0x0 */ s8 segment; - /* 0x2 */ s16 type; - /* 0x4 */ void* params; -} AnimatedMaterial; // size = 0x8 - -typedef struct { - /* 0x0 */ Vec3s pos; - /* 0x6 */ s16 unk_06; - /* 0x8 */ Gfx* opa; - /* 0xC */ Gfx* xlu; -} PolygonDlist2; // size = 0x10 - -typedef struct { - /* 0x0 */ u8 type; - /* 0x1 */ u8 num; // number of dlist entries - /* 0x4 */ void* start; - /* 0x8 */ void* end; -} PolygonType2; // size = 0xC - -typedef struct { - /* 0x00 */ u32 resetting; - /* 0x04 */ u32 resetCount; - /* 0x08 */ OSTime duration; - /* 0x10 */ OSTime resetTime; -} NmiBuff; // size >= 0x18 - typedef struct { /* 0x00 */ s32 requestType; /* 0x04 */ OSMesg response; @@ -162,14 +107,6 @@ typedef struct { /* 0x38 */ FaultDrawerCallback inputCallback; } FaultDrawer; // size = 0x3C -typedef struct { - /* 0x00 */ u8 countdown; - /* 0x01 */ u8 playSfxEachFrame; - /* 0x02 */ u16 sfxId; - /* 0x04 */ Vec3f worldPos; - /* 0x10 */ Vec3f projectedPos; -} SoundSource; // size = 0x1C - typedef void(*fault_update_input_func)(Input* input); typedef struct { @@ -411,12 +348,6 @@ typedef struct { struct PlayState; -typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*); -typedef void (*ColChkBloodFunc)(struct PlayState*, Collider*, Vec3f*); -typedef void (*ColChkApplyFunc)(struct PlayState*, CollisionCheckContext*, Collider*); -typedef void (*ColChkVsFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Collider*); -typedef s32 (*ColChkLineFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); - typedef struct { /* 0x000 */ IrqMgr* irqMgr; /* 0x004 */ SchedContext* sched; @@ -456,7 +387,7 @@ typedef struct PlayState { /* 0x00830 */ CollisionContext colCtx; /* 0x01CA0 */ ActorContext actorCtx; /* 0x01F24 */ CutsceneContext csCtx; - /* 0x01F78 */ SoundSource soundSources[16]; + /* 0x01F78 */ SoundSource soundSources[SOUND_SOURCE_COUNT]; /* 0x02138 */ EffFootmark footprintInfo[100]; /* 0x046B8 */ SramContext sramCtx; /* 0x046E0 */ SkyboxContext skyboxCtx; @@ -568,11 +499,6 @@ typedef struct { /* 0x14 */ Gfx* dList; } VisMono; // size = 0x18 -typedef struct { - /* 0x0 */ u8* value; - /* 0x4 */ const char* name; -} FlagSetEntry; // size = 0x8 - // TODO: Dedicated Header? #define FRAM_BASE_ADDRESS 0x08000000 // FRAM Base Address in Cart Memory #define FRAM_STATUS_REGISTER FRAM_BASE_ADDRESS // FRAM Base Address in Cart Memory diff --git a/include/z64actor.h b/include/z64actor.h index 3051f2c6e..e08a477e6 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -25,71 +25,17 @@ typedef void(*ActorFunc)(struct Actor* this, struct PlayState* play); typedef u16 (*NpcGetTextIdFunc)(struct PlayState*, struct Actor*); typedef s16 (*NpcUpdateTalkStateFunc)(struct PlayState*, struct Actor*); -typedef struct { +typedef struct PosRot { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3s rot; } PosRot; // size = 0x14 -typedef struct { - /* 0x00 */ u8 attack[32]; -} DamageTable; // size = 0x20 - -typedef struct { - /* 0x0 */ u8 health; - /* 0x2 */ s16 cylRadius; - /* 0x4 */ s16 cylHeight; - /* 0x6 */ u8 mass; -} CollisionCheckInfoInit; // size = 0x8 - -typedef struct { - /* 0x0 */ u8 health; - /* 0x2 */ s16 cylRadius; - /* 0x4 */ s16 cylHeight; - /* 0x6 */ s16 cylYShift; - /* 0x8 */ u8 mass; -} CollisionCheckInfoInit2; // size = 0xC - -typedef struct { - /* 0x00 */ DamageTable* damageTable; - /* 0x04 */ Vec3f displacement; - /* 0x10 */ s16 cylRadius; - /* 0x12 */ s16 cylHeight; - /* 0x14 */ s16 cylYShift; - /* 0x16 */ u8 mass; - /* 0x17 */ u8 health; - /* 0x18 */ u8 damage; - /* 0x19 */ u8 damageEffect; - /* 0x1A */ u8 atHitEffect; - /* 0x1B */ u8 acHitEffect; -} CollisionCheckInfo; // size = 0x1C - -typedef struct { - /* 0x00 */ s32 unk0; - /* 0x04 */ s32 unk4; - /* 0x08 */ f32 unk8; - /* 0x0C */ f32 unkC; - /* 0x10 */ f32 unk10; - /* 0x14 */ f32 unk14; - /* 0x18 */ f32 unk18; - /* 0x1C */ f32 unk1C; - /* 0x20 */ f32 unk20; - /* 0x24 */ f32 unk24; - /* 0x28 */ f32 unk28; - /* 0x2C */ f32 unk2C; - /* 0x30 */ s16 unk30; - /* 0x32 */ s16 unk32; - /* 0x34 */ s16 unk34; - /* 0x36 */ s16 unk36; - /* 0x38 */ s16 unk38; - /* 0x3A */ s16 unk3A; -} ActorEnTest20C; // size = 0x3C - typedef struct { /* 0x0 */ s16 unk_0; // frame? /* 0x2 */ Vec3s unk_2; // scale } struct_80124618; // size = 0x8 -typedef struct { +typedef struct ActorInit { /* 0x00 */ s16 id; /* 0x02 */ u8 type; /* 0x04 */ u32 flags; diff --git a/include/z64animation_legacy.h b/include/z64animation_legacy.h index 238939f74..44751f385 100644 --- a/include/z64animation_legacy.h +++ b/include/z64animation_legacy.h @@ -1,5 +1,5 @@ -#ifndef Z64_ANIMATION_LEGACY_H -#define Z64_ANIMATION_LEGACY_H +#ifndef Z64ANIMATION_LEGACY_H +#define Z64ANIMATION_LEGACY_H #include "ultra64.h" #include "z64math.h" diff --git a/include/z64collision_check.h b/include/z64collision_check.h index e5032584c..403ffa546 100644 --- a/include/z64collision_check.h +++ b/include/z64collision_check.h @@ -6,6 +6,7 @@ #include "unk.h" struct Actor; +struct PlayState; typedef struct { /* 0x00 */ struct Actor* actor; // Attached actor @@ -427,5 +428,250 @@ typedef enum { #define DMG_UNK_0x1E (1 << 0x1E) #define DMG_POWDER_KEG (1 << 0x1F) +typedef struct DamageTable { + /* 0x00 */ u8 attack[32]; +} DamageTable; // size = 0x20 + +typedef struct CollisionCheckInfoInit { + /* 0x0 */ u8 health; + /* 0x2 */ s16 cylRadius; + /* 0x4 */ s16 cylHeight; + /* 0x6 */ u8 mass; +} CollisionCheckInfoInit; // size = 0x8 + +typedef struct CollisionCheckInfoInit2 { + /* 0x0 */ u8 health; + /* 0x2 */ s16 cylRadius; + /* 0x4 */ s16 cylHeight; + /* 0x6 */ s16 cylYShift; + /* 0x8 */ u8 mass; +} CollisionCheckInfoInit2; // size = 0xC + +typedef struct CollisionCheckInfo { + /* 0x00 */ DamageTable* damageTable; + /* 0x04 */ Vec3f displacement; + /* 0x10 */ s16 cylRadius; + /* 0x12 */ s16 cylHeight; + /* 0x14 */ s16 cylYShift; + /* 0x16 */ u8 mass; + /* 0x17 */ u8 health; + /* 0x18 */ u8 damage; + /* 0x19 */ u8 damageEffect; + /* 0x1A */ u8 atHitEffect; + /* 0x1B */ u8 acHitEffect; +} CollisionCheckInfo; // size = 0x1C + + +DamageTable* DamageTable_Get(s32 index); +void DamageTable_Clear(DamageTable* damageTable); +f32 CollisionCheck_GetDamageAndEffectOnBumper(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, u32* effect); +f32 CollisionCheck_ApplyBumperDefense(f32 damage, ColliderInfo* ac); +s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo); +s32 Collider_InitBase(struct PlayState* play, Collider* collider); +s32 Collider_DestroyBase(struct PlayState* play, Collider* collider); +s32 Collider_SetBaseToActor(struct PlayState* play, Collider* collider, ColliderInitToActor* src); +s32 Collider_SetBaseType1(struct PlayState* play, Collider* collider, struct Actor* actor, ColliderInitType1* src); +s32 Collider_SetBase(struct PlayState* play, Collider* collider, struct Actor* actor, ColliderInit* src); +void Collider_ResetATBase(struct PlayState* play, Collider* collider); +void Collider_ResetACBase(struct PlayState* play, Collider* collider); +void Collider_ResetOCBase(struct PlayState* play, Collider* collider); +s32 Collider_InitTouch(struct PlayState* play, ColliderTouch* touch); +s32 Collider_DestroyTouch(struct PlayState* play, ColliderTouch* touch); +s32 Collider_SetTouch(struct PlayState* play, ColliderTouch* touch, ColliderTouchInit* src); +void Collider_ResetATInfoUnk(struct PlayState* play, ColliderInfo* info); +s32 Collider_InitBump(struct PlayState* play, ColliderBump* bump); +s32 Collider_DestroyBump(struct PlayState* play, ColliderBump* bump); +s32 Collider_SetBump(struct PlayState* play, ColliderBump* bump, ColliderBumpInit* src); +s32 Collider_InitInfo(struct PlayState* play, ColliderInfo* info); +s32 Collider_DestroyInfo(struct PlayState* play, ColliderInfo* info); +s32 Collider_SetInfo(struct PlayState* play, ColliderInfo* info, ColliderInfoInit* src); +void Collider_ResetATInfo(struct PlayState* play, ColliderInfo* info); +void Collider_ResetACInfo(struct PlayState* play, ColliderInfo* info); +void Collider_ResetOCInfo(struct PlayState* play, ColliderInfo* info); +s32 Collider_InitJntSphElementDim(struct PlayState* play, ColliderJntSphElementDim* dim); +s32 Collider_DestroyJntSphElementDim(struct PlayState* play, ColliderJntSphElementDim* dim); +s32 Collider_SetJntSphElementDim(struct PlayState* play, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src); +s32 Collider_InitJntSphElement(struct PlayState* play, ColliderJntSphElement* element); +s32 Collider_DestroyJntSphElement(struct PlayState* play, ColliderJntSphElement* element); +s32 Collider_SetJntSphElement(struct PlayState* play, ColliderJntSphElement* dest, ColliderJntSphElementInit* src); +s32 Collider_ResetJntSphElementAT(struct PlayState* play, ColliderJntSphElement* collider); +s32 Collider_ResetJntSphElementAC(struct PlayState* play, ColliderJntSphElement* collider); +s32 Collider_ResetJntSphElementOC(struct PlayState* play, ColliderJntSphElement* collider); +s32 Collider_InitJntSph(struct PlayState* play, ColliderJntSph* collider); +s32 Collider_FreeJntSph(struct PlayState* play, ColliderJntSph* collider); +s32 Collider_DestroyJntSph(struct PlayState* play, ColliderJntSph* collider); +s32 Collider_SetJntSphToActor(struct PlayState* play, ColliderJntSph* collider, ColliderJntSphInitToActor* src); +s32 Collider_SetJntSphAllocType1(struct PlayState* play, ColliderJntSph* sphereGroup, struct Actor* actor, ColliderJntSphInitType1* src); +s32 Collider_SetJntSph(struct PlayState* play, ColliderJntSph* sphereGroup, struct Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); +s32 Collider_InitAndSetJntSph(struct PlayState* play, ColliderJntSph* sphereGroup, struct Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements); +s32 Collider_ResetJntSphAT(struct PlayState* play, Collider* collider); +s32 Collider_ResetJntSphAC(struct PlayState* play, Collider* collider); +s32 Collider_ResetJntSphOC(struct PlayState* play, Collider* collider); +s32 Collider_InitCylinderDim(struct PlayState* play, Cylinder16* dim); +s32 Collider_DestroyCylinderDim(struct PlayState* play, Cylinder16* dim); +s32 Collider_SetCylinderDim(struct PlayState* play, Cylinder16* dim, Cylinder16* src); +s32 Collider_InitCylinder(struct PlayState* play, ColliderCylinder* collider); +s32 Collider_DestroyCylinder(struct PlayState* play, ColliderCylinder* collider); +s32 Collider_SetCylinderToActor(struct PlayState* play, ColliderCylinder* collider, ColliderCylinderInitToActor* src); +s32 Collider_SetCylinderType1(struct PlayState* play, ColliderCylinder* collider, struct Actor* actor, ColliderCylinderInitType1* src); +s32 Collider_SetCylinder(struct PlayState* play, ColliderCylinder* collider, struct Actor* actor, ColliderCylinderInit* src); +s32 Collider_InitAndSetCylinder(struct PlayState* play, ColliderCylinder* collider, struct Actor* actor, ColliderCylinderInit* src); +s32 Collider_ResetCylinderAT(struct PlayState* play, Collider* collider); +s32 Collider_ResetCylinderAC(struct PlayState* play, Collider* collider); +s32 Collider_ResetCylinderOC(struct PlayState* play, Collider* collider); +s32 Collider_InitTrisElementDim(struct PlayState* play, TriNorm* dim); +s32 Collider_DestroyTrisElementDim(struct PlayState* play, TriNorm* dim); +s32 Collider_SetTrisElementDim(struct PlayState* play, TriNorm* dim, ColliderTrisElementDimInit* src); +s32 Collider_InitTrisElement(struct PlayState* play, ColliderTrisElement* element); +s32 Collider_DestroyTrisElement(struct PlayState* play, ColliderTrisElement* element); +s32 Collider_SetTrisElement(struct PlayState* play, ColliderTrisElement* element, ColliderTrisElementInit* src); +s32 Collider_ResetTrisElementAT(struct PlayState* play, ColliderTrisElement* element); +s32 Collider_ResetTrisElementAC(struct PlayState* play, ColliderTrisElement* element); +s32 Collider_ResetTrisElementOC(struct PlayState* play, ColliderTrisElement* element); +s32 Collider_InitTris(struct PlayState* play, ColliderTris* tris); +s32 Collider_FreeTris(struct PlayState* play, ColliderTris* tris); +s32 Collider_DestroyTris(struct PlayState* play, ColliderTris* tris); +s32 Collider_SetTrisAllocType1(struct PlayState* play, ColliderTris* tris, struct Actor* actor, ColliderTrisInitType1* src); +s32 Collider_SetTris(struct PlayState* play, ColliderTris* triGroup, struct Actor* actor, ColliderTrisInit* src, ColliderTrisElement* tris); +s32 Collider_InitAndSetTris(struct PlayState* play, ColliderTris* tris, struct Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements); +s32 Collider_ResetTrisAT(struct PlayState* play, Collider* collider); +s32 Collider_ResetTrisAC(struct PlayState* play, Collider* collider); +s32 Collider_ResetTrisOC(struct PlayState* play, Collider* collider); +s32 Collider_InitQuadDim(struct PlayState* play, ColliderQuadDim* dim); +s32 Collider_DestroyQuadDim(struct PlayState* play, ColliderQuadDim* dim); +s32 Collider_ResetQuadACDist(struct PlayState* play, ColliderQuadDim* dim); +void Collider_SetQuadMidpoints(ColliderQuadDim* dim); +s32 Collider_SetQuadDim(struct PlayState* play, ColliderQuadDim* dim, ColliderQuadDimInit* init); +s32 Collider_InitQuad(struct PlayState* play, ColliderQuad* collider); +s32 Collider_DestroyQuad(struct PlayState* play, ColliderQuad* collider); +s32 Collider_SetQuadType1(struct PlayState* play, ColliderQuad* collider, struct Actor* actor, ColliderQuadInitType1* src); +s32 Collider_SetQuad(struct PlayState* play, ColliderQuad* collider, struct Actor* actor, ColliderQuadInit* src); +s32 Collider_InitAndSetQuad(struct PlayState* play, ColliderQuad* collider, struct Actor* actor, ColliderQuadInit* src); +s32 Collider_ResetQuadAT(struct PlayState* play, Collider* collider); +s32 Collider_ResetQuadAC(struct PlayState* play, Collider* collider); +s32 Collider_ResetQuadOC(struct PlayState* play, Collider* collider); +s32 Collider_QuadSetNearestAC(struct PlayState* play, ColliderQuad* quad, Vec3f* hitPos); +s32 Collider_InitSphere(struct PlayState* play, ColliderSphere* collider); +s32 Collider_DestroySphere(struct PlayState* play, ColliderSphere* collider); +s32 Collider_SetSphere(struct PlayState* play, ColliderSphere* collider, struct Actor* actor, ColliderSphereInit* src); +s32 Collider_InitAndSetSphere(struct PlayState* play, ColliderSphere* collider, struct Actor* actor, ColliderSphereInit* src); +s32 Collider_ResetSphereAT(struct PlayState* play, Collider* collider); +s32 Collider_ResetSphereAC(struct PlayState* play, Collider* collider); +s32 Collider_ResetSphereOC(struct PlayState* play, Collider* collider); +s32 Collider_InitLine(struct PlayState* play, OcLine* line); +s32 Collider_DestroyLine(struct PlayState* play, OcLine* line); +s32 Collider_SetLinePoints(struct PlayState* play, OcLine* line, Vec3f* a, Vec3f* b); +s32 Collider_SetLine(struct PlayState* play, OcLine* line, OcLine* src); +s32 Collider_ResetLineOC(struct PlayState* play, OcLine* line); +void CollisionCheck_InitContext(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_DestroyContext(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_ClearContext(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_EnableSAC(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_DisableSAC(struct PlayState* play, CollisionCheckContext* colCtxt); +s32 CollisionCheck_SetAT(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +s32 CollisionCheck_SetAT_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); +s32 CollisionCheck_SetAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +s32 CollisionCheck_SetAC_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); +s32 CollisionCheck_SetOC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +s32 CollisionCheck_SetOC_SAC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index); +s32 CollisionCheck_SetOCLine(struct PlayState* play, CollisionCheckContext* colCtxt, OcLine* line); +s32 CollisionCheck_SkipTouch(ColliderInfo* info); +s32 CollisionCheck_SkipBump(ColliderInfo* info); +s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper); +void CollisionCheck_NoBlood(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_BlueBlood(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_GreenBlood(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_WaterBurst(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_RedBlood(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_RedBloodUnused(struct PlayState* play, Collider* collider, Vec3f* v); +void CollisionCheck_HitSolid(struct PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos); +s32 CollisionCheck_SwordHitAudio(Collider* at, ColliderInfo* acInfo); +void CollisionCheck_HitEffects(struct PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, Vec3f* hitPos); +void CollisionCheck_SetBounce(Collider* at, Collider* ac); +s32 CollisionCheck_SetATvsAC(struct PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos); +void CollisionCheck_TrisAvgPoint(ColliderTrisElement* tri, Vec3f* avg); +void CollisionCheck_QuadAvgPoint(ColliderQuad* quad, Vec3f* avg); +void CollisionCheck_AC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_TrisVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_QuadVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsCylinder(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_AC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC); +void CollisionCheck_SetJntSphHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetCylHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetTrisHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetQuadHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetSphereHitFX(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_SetHitEffects(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_AC(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT); +void CollisionCheck_AT(struct PlayState* play, CollisionCheckContext* colCtxt); +s32 CollisionCheck_GetMassType(u8 mass); +void CollisionCheck_SetOCvsOC(struct PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap); +void CollisionCheck_OC_JntSphVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_JntSphVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_JntSphVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_CylVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_CylVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_CylVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_SphereVsJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_SphereVsCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +void CollisionCheck_OC_SphereVsSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r); +s32 CollisionCheck_SkipOC(Collider* collider); +s32 CollisionCheck_Incompatible(Collider* left, Collider* right); +void CollisionCheck_OC(struct PlayState* play, CollisionCheckContext* colCtxt); +void CollisionCheck_InitInfo(CollisionCheckInfo* info); +void CollisionCheck_ResetDamage(CollisionCheckInfo* info); +void CollisionCheck_SetInfoNoDamageTable(CollisionCheckInfo* info, CollisionCheckInfoInit* init); +void CollisionCheck_SetInfo(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit* init); +void CollisionCheck_SetInfo2(CollisionCheckInfo* info, DamageTable* damageTable, CollisionCheckInfoInit2* init); +void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, CollisionCheckInfoInit2* init); +void CollisionCheck_ApplyDamage(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, ColliderInfo* info); +void CollisionCheck_ApplyDamageJntSph(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageCyl(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageTris(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageQuad(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_ApplyDamageSphere(struct PlayState* play, CollisionCheckContext* colCtxt, Collider* collider); +void CollisionCheck_Damage(struct PlayState* play, CollisionCheckContext* colCtxt); +s32 CollisionCheck_LineOC_JntSph(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC_Cyl(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC_Sphere(struct PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOC(struct PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, struct Actor** exclusions, s32 numExclusions); +s32 CollisionCheck_LineOCCheckAll(struct PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b); +s32 CollisionCheck_LineOCCheck(struct PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, struct Actor** exclusions, s32 numExclusions); +void Collider_UpdateCylinder(struct Actor* actor, ColliderCylinder* collider); +void Collider_SetCylinderPosition(ColliderCylinder* collider, Vec3s* pos); +void Collider_SetQuadVertices(ColliderQuad* collider, Vec3f* a, Vec3f* b, Vec3f* c, Vec3f* d); +void Collider_SetTrisVertices(ColliderTris* collider, s32 index, Vec3f* a, Vec3f* b, Vec3f* c); +void Collider_SetTrisDim(struct PlayState* play, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* init); +void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider); +void Collider_UpdateSpheresElement(ColliderJntSph* collider, s32 index, struct Actor* actor); +void Collider_UpdateSphere(s32 limb, ColliderSphere* collider); +void CollisionCheck_SpawnRedBlood(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnWaterDroplets(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticles(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesMetal(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesMetalSound(struct PlayState* play, Vec3f* v, Vec3f* pos); +void CollisionCheck_SpawnShieldParticlesMetal2(struct PlayState* play, Vec3f* v); +void CollisionCheck_SpawnShieldParticlesWood(struct PlayState* play, Vec3f* v, Vec3f* pos); +s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); #endif diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 742398a31..83e9994f1 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -430,7 +430,7 @@ typedef enum { /* 0x1F6 */ CS_CMD_ACTOR_CUE_502, /* 0x1F7 */ CS_CMD_ACTOR_CUE_503, /* 0x1F8 */ CS_CMD_ACTOR_CUE_504, - /* 0x1F9 */ CS_CMD_ACTOR_CUE_505, + /* 0x1F9 */ CS_CMD_ACTOR_CUE_SOTCS, // Song of Time Cutscenes (Double SoT, Three-Day Reset SoT) /* 0x1FA */ CS_CMD_ACTOR_CUE_506, /* 0x1FB */ CS_CMD_ACTOR_CUE_507, /* 0x1FC */ CS_CMD_ACTOR_CUE_508, diff --git a/include/z64game.h b/include/z64game.h index c5551edc7..87dc80764 100644 --- a/include/z64game.h +++ b/include/z64game.h @@ -1,5 +1,5 @@ -#ifndef Z64_GAME_H -#define Z64_GAME_H +#ifndef Z64GAME_H +#define Z64GAME_H #include "ultra64.h" #include "libc/stdbool.h" diff --git a/include/z64interface.h b/include/z64interface.h index aac675a65..d768254e2 100644 --- a/include/z64interface.h +++ b/include/z64interface.h @@ -4,6 +4,15 @@ #include "ultra64.h" #include "z64view.h" +typedef enum { + /* -1 */ EQUIP_SLOT_NONE = -1, + /* 0 */ EQUIP_SLOT_B, + /* 1 */ EQUIP_SLOT_C_LEFT, + /* 2 */ EQUIP_SLOT_C_DOWN, + /* 3 */ EQUIP_SLOT_C_RIGHT, + /* 4 */ EQUIP_SLOT_A +} EquipSlot; + typedef enum { /* 0 */ A_BTN_STATE_0, /* 1 */ A_BTN_STATE_1, @@ -216,4 +225,49 @@ typedef struct { /* 0x344 */ size_t storySize; } InterfaceContext; // size = 0x348 +Gfx* Gfx_DrawTexRectRGBA16(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); +Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); +Gfx* Gfx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); +Gfx* Gfx_DrawTexQuadIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, u16 point); +Gfx* Gfx_DrawTexQuad4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, s16 textureHeight, u16 point); + +void Interface_StartTimer(s16 timerId, s16 seconds); +void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState); +void Interface_NewDay(struct PlayState* play, s32 day); +void Interface_SetHudVisibility(u16 hudVisibility); +void Interface_UpdateButtonsPart2(struct PlayState* play); +void Interface_SetSceneRestrictions(struct PlayState* play); +void Interface_InitMinigame(struct PlayState* play); +void Interface_LoadItemIconImpl(struct PlayState* play, u8 btn); +void Interface_LoadItemIcon(struct PlayState* play, u8 btn); +void Interface_UpdateButtonsAlt(struct PlayState* play, u16 flag); +u8 Item_Give(struct PlayState* play, u8 item); +u8 Item_CheckObtainability(u8 item); +void Inventory_DeleteItem(s16 item, s16 slot); +void Inventory_UnequipItem(s16 item); +s32 Inventory_ReplaceItem(struct PlayState* play, u8 oldItem, u8 newItem); +void Inventory_UpdateDeitySwordEquip(struct PlayState* play) ; +s32 Inventory_HasEmptyBottle(void); +s32 Inventory_HasItemInBottle(u8 item); +void Inventory_UpdateBottleItem(struct PlayState* play, u8 item, u8 btn); +s32 Inventory_ConsumeFairy(struct PlayState* play); +void Inventory_UpdateItem(struct PlayState* play, s16 slot, s16 item); +void Interface_SetAButtonDoAction(struct PlayState* play, u16 aButtonDoAction); +void Interface_SetBButtonDoAction(struct PlayState* play, s16 bButtonDoAction); +void Interface_SetTatlCall(struct PlayState* play, u16 tatlCallState); +void Interface_LoadBButtonDoActionLabel(struct PlayState* play, s16 bButtonDoAction); +s32 Health_ChangeBy(struct PlayState* play, s16 healthChange); +void Health_GiveHearts(s16 hearts); +void Rupees_ChangeBy(s16 rupeeChange); +void Inventory_ChangeAmmo(s16 item, s16 ammoChange); +void Magic_Add(struct PlayState* play, s16 magicToAdd); +void Magic_Reset(struct PlayState* play); +s32 Magic_Consume(struct PlayState* play, s16 magicToConsume, s16 type); +void Interface_SetPerfectLetters(struct PlayState* play, s16 perfectLettersType); +void Interface_StartMoonCrash(struct PlayState* play); +void Interface_Draw(struct PlayState* play); +void Interface_Update(struct PlayState* play); +void Interface_Destroy(struct PlayState* play); +void Interface_Init(struct PlayState* play); + #endif diff --git a/include/z64message.h b/include/z64message.h index 09c9c4e04..2a3810ff1 100644 --- a/include/z64message.h +++ b/include/z64message.h @@ -8,10 +8,24 @@ struct Actor; struct MessageTableEntry; struct OcarinaStaff; +struct PlayState; extern u16 sBombersNotebookEventMessages[BOMBERS_NOTEBOOK_EVENT_MAX]; extern u16 gBombersNotebookWeekEventFlags[BOMBERS_NOTEBOOK_EVENT_MAX]; +typedef enum FaceReactionSet { + /* 0x11 */ FACE_REACTION_SET_JIM = 0x11, + /* 0x12 */ FACE_REACTION_SET_BOMBERS, + /* 0x15 */ FACE_REACTION_SET_BOMBERS_HIDEOUT_GUARD = 0x15, + /* 0x2D */ FACE_REACTION_SET_TREASURE_CHEST_SHOP_GAL = 0x2D, + /* 0x2F */ FACE_REACTION_SET_CURIOSITY_SHOP_MAN = 0x2F, + /* 0x30 */ FACE_REACTION_SET_TOWN_SHOOTING_GALLERY_MAN, + /* 0x31 */ FACE_REACTION_SET_SWAMP_SHOOTING_GALLERY_MAN, + /* 0x36 */ FACE_REACTION_SET_PART_TIMER = 0x36 +} FaceReactionSet; + +u16 Text_GetFaceReaction(struct PlayState* play, FaceReactionSet reactionSet); + typedef enum TextState { /* 0 */ TEXT_STATE_NONE, /* 1 */ TEXT_STATE_1, diff --git a/include/z64ocarina.h b/include/z64ocarina.h index 3bb99cd62..7cfafde4f 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -32,6 +32,12 @@ typedef enum { /* 24 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX // anything larger than 24 is considered the long scarecrow's song } OcarinaSongId; +typedef enum OcarinaMode { + /* 0x18 */ OCARINA_MODE_APPLY_INV_SOT_FAST = 24, + /* 0x19 */ OCARINA_MODE_APPLY_INV_SOT_SLOW, + /* 0x1A */ OCARINA_MODE_APPLY_DOUBLE_SOT +} OcarinaMode; + typedef enum { /* 0 */ OCARINA_BTN_A, /* 1 */ OCARINA_BTN_C_DOWN, diff --git a/include/z64player.h b/include/z64player.h index f10984216..5982233b8 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -656,7 +656,7 @@ typedef enum PlayerCsMode { /* 0x3F */ PLAYER_CSMODE_63, /* 0x40 */ PLAYER_CSMODE_64, /* 0x41 */ PLAYER_CSMODE_65, - /* 0x42 */ PLAYER_CSMODE_66, + /* 0x42 */ PLAYER_CSMODE_66, // Look side-to-side with chin down /* 0x43 */ PLAYER_CSMODE_67, /* 0x44 */ PLAYER_CSMODE_68, /* 0x45 */ PLAYER_CSMODE_69, @@ -664,15 +664,15 @@ typedef enum PlayerCsMode { /* 0x47 */ PLAYER_CSMODE_71, /* 0x48 */ PLAYER_CSMODE_72, /* 0x49 */ PLAYER_CSMODE_73, - /* 0x4A */ PLAYER_CSMODE_74, + /* 0x4A */ PLAYER_CSMODE_74, // Give a big nod of approval /* 0x4B */ PLAYER_CSMODE_75, /* 0x4C */ PLAYER_CSMODE_76, /* 0x4D */ PLAYER_CSMODE_77, /* 0x4E */ PLAYER_CSMODE_78, /* 0x4F */ PLAYER_CSMODE_79, /* 0x50 */ PLAYER_CSMODE_80, - /* 0x51 */ PLAYER_CSMODE_81, - /* 0x52 */ PLAYER_CSMODE_82, + /* 0x51 */ PLAYER_CSMODE_81, // Look side-to-side with chin up + /* 0x52 */ PLAYER_CSMODE_82, // Close eyes and sway body in circles /* 0x53 */ PLAYER_CSMODE_83, /* 0x54 */ PLAYER_CSMODE_84, // Sucked by the moon /* 0x55 */ PLAYER_CSMODE_85, diff --git a/include/z64save.h b/include/z64save.h index a5587e681..4f5e8cf73 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1467,15 +1467,8 @@ typedef enum { * gSaveContext.eventInf */ -// gSaveContext.eventInf[0] is used to dog race information -// #define EVENTINF_00 0x00 -// #define EVENTINF_01 0x01 -// #define EVENTINF_02 0x02 -// #define EVENTINF_03 0x03 -// #define EVENTINF_04 0x04 -// #define EVENTINF_05 0x05 -// #define EVENTINF_06 0x06 -// #define EVENTINF_07 0x07 +// gSaveContext.eventInf[0] is used for dog race information (8 entries) +// EVENTINF_00 to EVENTINF_07 #define EVENTINF_10 0x10 #define EVENTINF_11 0x11 @@ -1492,7 +1485,8 @@ typedef enum { #define EVENTINF_24 0x24 #define EVENTINF_25 0x25 #define EVENTINF_26 0x26 -#define EVENTINF_27 0x27 +// "Dawn of ... day". Must be triggered with respawnFlag -4 or -99 +#define EVENTINF_TRIGGER_DAYTELOP 0x27 #define EVENTINF_30 0x30 // EVENTINF_31 is used to track if Player is within range of EnGakufu (2D Song Buttons Appearing on Wall) @@ -1536,11 +1530,14 @@ typedef enum { #define EVENTINF_65 0x65 #define EVENTINF_66 0x66 #define EVENTINF_67 0x67 -#define EVENTINF_70 0x70 -#define EVENTINF_71 0x71 -#define EVENTINF_72 0x72 -#define EVENTINF_73 0x73 -#define EVENTINF_74 0x74 + +// Tracks which ammo is lost during the three day reset +#define EVENTINF_THREEDAYRESET_LOST_RUPEES 0x70 +#define EVENTINF_THREEDAYRESET_LOST_BOMB_AMMO 0x71 +#define EVENTINF_THREEDAYRESET_LOST_NUT_AMMO 0x72 +#define EVENTINF_THREEDAYRESET_LOST_STICK_AMMO 0x73 +#define EVENTINF_THREEDAYRESET_LOST_ARROW_AMMO 0x74 + #define EVENTINF_75 0x75 #define EVENTINF_76 0x76 #define EVENTINF_77 0x77 diff --git a/include/z64scene.h b/include/z64scene.h index 5505f08e3..55c959b31 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -6,6 +6,9 @@ #include "z64cutscene.h" #include "unk.h" +struct GameState; +struct PlayState; + #define SPAWN_ROT_FLAGS(rotation, flags) (((rotation) << 7) | (flags)) typedef struct { @@ -459,6 +462,16 @@ typedef struct { /* 0x8 */ u8* textureIndexList; } AnimatedMatTexCycleParams; // size = 0xC +typedef struct { + /* 0x0 */ s8 segment; + /* 0x2 */ s16 type; + /* 0x4 */ void* params; +} AnimatedMaterial; // size = 0x8 + +// TODO: ZAPD +typedef RoomShapeCullableEntry PolygonDlist2; +typedef RoomShapeCullable PolygonType2; + typedef struct { /* 0x000 */ void* spaceStart; /* 0x004 */ void* spaceEnd; @@ -885,4 +898,89 @@ typedef enum { #define SCENE_CMD_MISC_SETTINGS SCENE_CMD_SET_REGION_VISITED #define SCENE_CMD_CUTSCENE_LIST SCENE_CMD_CUTSCENE_SCRIPT_LIST +s32 Object_Spawn(ObjectContext* objectCtx, s16 id); +void Object_InitBank(struct GameState* gameState, ObjectContext* objectCtx); +void Object_UpdateBank(ObjectContext* objectCtx); +s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId); +s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index); +void Object_LoadAll(ObjectContext* objectCtx); +void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id); +void Scene_CommandSpawnList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandActorList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandActorCutsceneCamList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandCollisionHeader(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandRoomList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandEntranceList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandSpecialFiles(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandRoomBehavior(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandMesh(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandObjectList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandLightList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandPathList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandTransiActorList(struct PlayState* play, SceneCmd* cmd); +void Door_InitContext(struct GameState* gameState, DoorContext* doorCtx); +void Scene_CommandEnvLightSettings(struct PlayState* play, SceneCmd* cmd); +void Scene_LoadAreaTextures(struct PlayState* play, s32 fileIndex); +void Scene_CommandSkyboxSettings(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandSkyboxDisables(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandTimeSettings(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandWindSettings(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandExitList(struct PlayState* play, SceneCmd* cmd); +void Scene_Command09(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandSoundSettings(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandEchoSetting(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandAltHeaderList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandCutsceneScriptList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandCutsceneList(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandMiniMap(struct PlayState* play, SceneCmd* cmd); +void Scene_Command1D(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandMiniMapCompassInfo(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandSetRegionVisitedFlag(struct PlayState* play, SceneCmd* cmd); +void Scene_CommandAnimatedMaterials(struct PlayState* play, SceneCmd* cmd); +void Scene_SetExitFade(struct PlayState* play); +s32 Scene_ExecuteCommands(struct PlayState* play, SceneCmd* sceneCmd); +u16 Entrance_Create(s32 scene, s32 spawn, s32 layer); +u16 Entrance_CreateFromSpawn(s32 spawn); +void Scene_Draw(struct PlayState* play); +void Scene_DrawConfigDefault(struct PlayState* play); +Gfx* AnimatedMat_TexScroll(struct PlayState* play, AnimatedMatTexScrollParams* params); +void AnimatedMat_DrawTexScroll(struct PlayState* play, s32 segment, void* params); +Gfx* AnimatedMat_TwoLayerTexScroll(struct PlayState* play, AnimatedMatTexScrollParams* params); +void AnimatedMat_DrawTwoTexScroll(struct PlayState* play, s32 segment, void* params); +void AnimatedMat_SetColor(struct PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor); +void AnimatedMat_DrawColor(struct PlayState* play, s32 segment, void* params); +s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm); +void AnimatedMat_DrawColorLerp(struct PlayState* play, s32 segment, void* params); +f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp); +u8 Scene_LagrangeInterpColor(s32 n, f32 x[], f32 fx[], f32 xp); +void AnimatedMat_DrawColorNonLinearInterp(struct PlayState* play, s32 segment, void* params); +void AnimatedMat_DrawTexCycle(struct PlayState* play, s32 segment, void* params); +void AnimatedMat_DrawMain(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags); +void AnimatedMat_Draw(struct PlayState* play, AnimatedMaterial* matAnim); +void AnimatedMat_DrawOpa(struct PlayState* play, AnimatedMaterial* matAnim); +void AnimatedMat_DrawXlu(struct PlayState* play, AnimatedMaterial* matAnim); +void AnimatedMat_DrawAlpha(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); +void AnimatedMat_DrawAlphaOpa(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); +void AnimatedMat_DrawAlphaXlu(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio); +void AnimatedMat_DrawStep(struct PlayState* play, AnimatedMaterial* matAnim, u32 step); +void AnimatedMat_DrawStepOpa(struct PlayState* play, AnimatedMaterial* matAnim, u32 step); +void AnimatedMat_DrawStepXlu(struct PlayState* play, AnimatedMaterial* matAnim, u32 step); +void AnimatedMat_DrawAlphaStep(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); +void AnimatedMat_DrawAlphaStepOpa(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); +void AnimatedMat_DrawAlphaStepXlu(struct PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step); +void Scene_DrawConfigMatAnim(struct PlayState* play); +void Scene_DrawConfig3(struct PlayState* play); +void Scene_DrawConfig4(struct PlayState* play); +void Scene_DrawConfigDoNothing(struct PlayState* play); +void Scene_SetRenderModeXlu(struct PlayState* play, s32 index, u32 flags); +void Scene_SetCullFlag(struct PlayState* play, s32 index, u32 flags); +void Scene_DrawConfig5(struct PlayState* play); +void Scene_DrawConfigMatAnimManualStep(struct PlayState* play); +void Scene_DrawConfigGreatBayTemple(struct PlayState* play); +EntranceTableEntry* Entrance_GetTableEntry(u16 entrance); +s32 Entrance_GetSceneId(u16 entrance); +s32 Entrance_GetSceneIdAbsolute(u16 entrance); +s32 Entrance_GetSpawnNum(u16 entrance); +s32 Entrance_GetTransitionFlags(u16 entrance); + #endif diff --git a/include/z64sound_source.h b/include/z64sound_source.h new file mode 100644 index 000000000..b841f8326 --- /dev/null +++ b/include/z64sound_source.h @@ -0,0 +1,24 @@ +#ifndef Z64SOUND_SOURCE_H +#define Z64SOUND_SOURCE_H + +#include "ultra64.h" +#include "z64math.h" + +struct PlayState; + +typedef struct { + /* 0x00 */ u8 countdown; + /* 0x01 */ u8 playSfxEachFrame; + /* 0x02 */ u16 sfxId; + /* 0x04 */ Vec3f worldPos; + /* 0x10 */ Vec3f projectedPos; +} SoundSource; // size = 0x1C + +#define SOUND_SOURCE_COUNT 16 + +void SoundSource_InitAll(struct PlayState* play); +void SoundSource_UpdateAll(struct PlayState* play); +void SoundSource_PlaySfxAtFixedWorldPos(struct PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId); +void SoundSource_PlaySfxEachFrameAtFixedWorldPos(struct PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId); + +#endif diff --git a/include/z64thread.h b/include/z64thread.h new file mode 100644 index 000000000..c0baba84f --- /dev/null +++ b/include/z64thread.h @@ -0,0 +1,24 @@ +#ifndef Z64THREAD_H +#define Z64THREAD_H + +#define Z_THREAD_ID_IDLE 1 +#define Z_THREAD_ID_SLOWLY 2 +#define Z_THREAD_ID_MAIN 3 +#define Z_THREAD_ID_GRAPH 4 +#define Z_THREAD_ID_SCHED 5 +#define Z_THREAD_ID_FLASHROM 13 +#define Z_THREAD_ID_DMAMGR 18 +#define Z_THREAD_ID_IRQMGR 19 + +#define Z_PRIORITY_SLOWLY 5 +#define Z_PRIORITY_GRAPH 9 +#define Z_PRIORITY_AUDIOMGR 11 +#define Z_PRIORITY_IDLE 12 +#define Z_PRIORITY_MAIN 12 +#define Z_PRIORITY_FLASHROM 13 +#define Z_PRIORITY_PADMGR 15 +#define Z_PRIORITY_SCHED 16 +#define Z_PRIORITY_DMAMGR 17 +#define Z_PRIORITY_IRQMGR 18 + +#endif diff --git a/spec b/spec index b1468144e..8d23d42dd 100644 --- a/spec +++ b/spec @@ -276,15 +276,17 @@ beginseg endseg beginseg - name "icon_item_static_old" + name "icon_item_static_syms" romalign 0x1000 - include "build/baserom/icon_item_static_old.o" + include "build/assets/archives/icon_item_static/icon_item_static_yar.symbols.o" + number 8 endseg beginseg - name "icon_item_24_static_old" + name "icon_item_24_static_syms" romalign 0x1000 - include "build/baserom/icon_item_24_static_old.o" + include "build/assets/archives/icon_item_24_static/icon_item_24_static_yar.symbols.o" + number 9 endseg beginseg @@ -329,43 +331,47 @@ endseg beginseg name "map_i_static" - include "build/baserom/map_i_static.o" + include "build/assets/archives/map_i_static/map_i_static.yar.o" endseg beginseg name "map_grand_static" - include "build/baserom/map_grand_static.o" + include "build/assets/archives/map_grand_static/map_grand_static.yar.o" endseg beginseg name "item_name_static" - include "build/baserom/item_name_static.o" + include "build/assets/archives/item_name_static/item_name_static.yar.o" endseg beginseg name "map_name_static" - include "build/baserom/map_name_static.o" + include "build/assets/archives/map_name_static/map_name_static.yar.o" endseg beginseg - name "icon_item_static_test" - include "build/baserom/icon_item_static_test.o" + name "icon_item_static_yar" + include "build/assets/archives/icon_item_static/icon_item_static_yar.yar.o" + number 8 endseg beginseg - name "icon_item_24_static_test" - include "build/baserom/icon_item_24_static_test.o" + name "icon_item_24_static_yar" + include "build/assets/archives/icon_item_24_static/icon_item_24_static_yar.yar.o" + number 9 endseg beginseg - name "schedule_dma_static_old" - include "build/baserom/schedule_dma_static_old.o" + name "schedule_dma_static_syms" + include "build/assets/archives/schedule_dma_static/schedule_dma_static_yar.symbols.o" + number 7 endseg beginseg - name "schedule_dma_static_test" + name "schedule_dma_static_yar" increment 0x1000 - include "build/baserom/schedule_dma_static_test.o" + include "build/assets/archives/schedule_dma_static/schedule_dma_static_yar.yar.o" + number 7 endseg beginseg @@ -1107,11 +1113,7 @@ beginseg name "ovl_En_Sw" compress include "build/src/overlays/actors/ovl_En_Sw/z_en_sw.o" - #ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_En_Sw/ovl_En_Sw_reloc.o" - #else - include "build/data/ovl_En_Sw/ovl_En_Sw.reloc.o" - #endif + include "build/src/overlays/actors/ovl_En_Sw/ovl_En_Sw_reloc.o" endseg beginseg @@ -3481,8 +3483,7 @@ beginseg name "ovl_En_Snowwd" compress include "build/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.o" - include "build/data/ovl_En_Snowwd/ovl_En_Snowwd.data.o" - include "build/data/ovl_En_Snowwd/ovl_En_Snowwd.reloc.o" + include "build/src/overlays/actors/ovl_En_Snowwd/ovl_En_Snowwd_reloc.o" endseg beginseg diff --git a/src/audio/lib/effects.c b/src/audio/lib/effects.c index 6ef8added..580b7fd22 100644 --- a/src/audio/lib/effects.c +++ b/src/audio/lib/effects.c @@ -10,7 +10,7 @@ void AudioEffects_SequenceChannelProcessSound(SequenceChannel* channel, s32 reca if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_SOFTEN)) { channelVolume = channel->seqPlayer->muteVolumeScale * channelVolume; } - channel->appliedVolume = channelVolume * channelVolume; + channel->appliedVolume = SQ(channelVolume); } if (channel->changes.s.pan) { diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c index 8016e9b6a..af9de1cd1 100644 --- a/src/audio/lib/load.c +++ b/src/audio/lib/load.c @@ -884,7 +884,6 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample // The first u32 in fontData is an offset to a list of offsets to the drums soundListOffset = fontData[0]; - if (1) {} // If the soundFont has drums if ((soundListOffset != 0) && (numDrums != 0)) { @@ -897,20 +896,23 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample soundOffset = ((Drum**)fontData[0])[i]; // Some drum data entries are empty, represented by an offset of 0 in the list of drum offsets - if (soundOffset != 0) { - soundOffset = RELOC_TO_RAM(soundOffset); - ((Drum**)fontData[0])[i] = drum = soundOffset; - - // The drum may be in the list multiple times and already relocated - if (!drum->isRelocated) { - AudioLoad_RelocateSample(&drum->tunedSample, fontDataStartAddr, sampleBankReloc); - - soundOffset = drum->envelope; - drum->envelope = RELOC_TO_RAM(soundOffset); - - drum->isRelocated = true; - } + if (soundOffset == 0) { + continue; } + soundOffset = RELOC_TO_RAM(soundOffset); + ((Drum**)fontData[0])[i] = drum = soundOffset; + + // The drum may be in the list multiple times and already relocated + if (drum->isRelocated) { + continue; + } + + AudioLoad_RelocateSample(&drum->tunedSample, fontDataStartAddr, sampleBankReloc); + + soundOffset = drum->envelope; + drum->envelope = RELOC_TO_RAM(soundOffset); + + drum->isRelocated = true; } } @@ -918,7 +920,6 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample // The second u32 in fontData is an offset to the first sound effect entry soundListOffset = fontData[1]; - if (1) {} // If the soundFont has sound effects if ((soundListOffset != 0) && (numSfx != 0)) { @@ -932,9 +933,11 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample soundEffect = (SoundEffect*)soundOffset; // Check for NULL (note: the pointer is guaranteed to be in fontData and can never be NULL) - if ((soundEffect != NULL) && (soundEffect->tunedSample.sample != NULL)) { - AudioLoad_RelocateSample(&soundEffect->tunedSample, fontDataStartAddr, sampleBankReloc); + if ((soundEffect == NULL) || (soundEffect->tunedSample.sample == NULL)) { + continue; } + + AudioLoad_RelocateSample(&soundEffect->tunedSample, fontDataStartAddr, sampleBankReloc); } } @@ -1643,9 +1646,11 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { case SEQUENCE_TABLE: AudioLoad_SetSeqLoadStatus(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); break; + case SAMPLE_TABLE: AudioLoad_SetSampleFontLoadStatusAndApplyCaches(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); break; + case FONT_TABLE: fontId = ASYNC_ID(retMsg); sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; @@ -1659,6 +1664,9 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &sampleBankReloc, true); break; + + default: + break; } doneMsg = asyncLoad->retMsg; @@ -2002,24 +2010,29 @@ s32 AudioLoad_GetSamplesForFont(s32 fontId, Sample** sampleSet) { for (i = 0; i < numDrums; i++) { Drum* drum = AudioPlayback_GetDrum(fontId, i); - if (1) {} - if (drum != NULL) { - numSamples = AudioLoad_AddToSampleSet(drum->tunedSample.sample, numSamples, sampleSet); + if (drum == NULL) { + continue; } + + numSamples = AudioLoad_AddToSampleSet(drum->tunedSample.sample, numSamples, sampleSet); } for (i = 0; i < numInstruments; i++) { Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, i); - if (instrument != NULL) { - if (instrument->normalRangeLo != 0) { - numSamples = AudioLoad_AddToSampleSet(instrument->lowPitchTunedSample.sample, numSamples, sampleSet); - } - if (instrument->normalRangeHi != 0x7F) { - numSamples = AudioLoad_AddToSampleSet(instrument->highPitchTunedSample.sample, numSamples, sampleSet); - } - numSamples = AudioLoad_AddToSampleSet(instrument->normalPitchTunedSample.sample, numSamples, sampleSet); + if (instrument == NULL) { + continue; } + + if (instrument->normalRangeLo != 0) { + numSamples = AudioLoad_AddToSampleSet(instrument->lowPitchTunedSample.sample, numSamples, sampleSet); + } + + if (instrument->normalRangeHi != 0x7F) { + numSamples = AudioLoad_AddToSampleSet(instrument->highPitchTunedSample.sample, numSamples, sampleSet); + } + + numSamples = AudioLoad_AddToSampleSet(instrument->normalPitchTunedSample.sample, numSamples, sampleSet); } // Should really also process sfx, but this method is never called diff --git a/src/audio/lib/playback.c b/src/audio/lib/playback.c index 678e01089..a626645c5 100644 --- a/src/audio/lib/playback.c +++ b/src/audio/lib/playback.c @@ -83,6 +83,9 @@ void AudioPlayback_InitSampleState(Note* note, NoteSampleState* sampleState, Not sampleState->bitField0.strongRight = stereoData.strongRight ^ strongRight; sampleState->bitField0.strongLeft = stereoData.strongLeft ^ strongLeft; break; + + default: + break; } } else if (gAudioCtx.soundMode == SOUNDMODE_MONO) { diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index 6a561992b..ed16c34e0 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -2,6 +2,7 @@ #include "global.h" #include "stack.h" #include "stackcheck.h" +#include "z64thread.h" StackEntry sBootStackInfo; OSThread sIdleThread; diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 6c63e2a70..f7c847449 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -3,6 +3,7 @@ #include "stack.h" #include "buffers.h" #include "stackcheck.h" +#include "z64thread.h" u8 D_80096B20 = 1; vu8 gViConfigUseDefault = 1; @@ -94,10 +95,12 @@ void Idle_InitVideo(void) { D_8009B290 = 2; gViConfigMode = osViModeNtscLan1; break; + case OS_TV_MPAL: D_8009B290 = 30; gViConfigMode = osViModeMpalLan1; break; + case OS_TV_PAL: D_8009B290 = 44; gViConfigMode = osViModeFpalLan1; diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index 1f1e94ab4..9a773f279 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -1,5 +1,6 @@ #include "global.h" #include "stackcheck.h" +#include "z64thread.h" vs32 gIrqMgrResetStatus = 0; volatile OSTime sIrqMgrResetTime = 0; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 00d894f74..71b7ae846 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -2,6 +2,7 @@ #include "global.h" #include "stack.h" #include "stackcheck.h" +#include "z64thread.h" u32 sDmaMgrDmaBuffSize = 0x2000; diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index a0dc21a50..c0e00b08b 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -1,5 +1,7 @@ #include "global.h" #include "interface/parameter_static/parameter_static.h" +#include "archives/icon_item_static/icon_item_static_yar.h" +#include "archives/icon_item_24_static/icon_item_24_static_yar.h" // Bit Flag array in which gBitFlags[n] is (1 << n) u32 gBitFlags[] = { @@ -95,139 +97,138 @@ u32 gGsFlagsShift[] = { 24, }; -// TODO: use symbols for these icon textures once textures are properly in C TexturePtr gItemIcons[] = { - 0x08000000, // ITEM_OCARINA - 0x08001000, // ITEM_BOW - 0x08002000, // ITEM_ARROW_FIRE - 0x08003000, // ITEM_ARROW_ICE - 0x08004000, // ITEM_ARROW_LIGHT - 0x08005000, // ITEM_OCARINA_FAIRY - 0x08006000, // ITEM_BOMB - 0x08007000, // ITEM_BOMBCHU - 0x08008000, // ITEM_STICK - 0x08009000, // ITEM_NUT - 0x0800A000, // ITEM_MAGIC_BEANS - 0x0800B000, // ITEM_SLINGSHOT - 0x0800C000, // ITEM_POWDER_KEG - 0x0800D000, // ITEM_PICTO_BOX - 0x0800E000, // ITEM_LENS - 0x0800F000, // ITEM_HOOKSHOT - 0x08010000, // ITEM_SWORD_GREAT_FAIRY - 0x08011000, // ITEM_LONGSHOT - 0x08012000, // ITEM_BOTTLE - 0x08013000, // ITEM_POTION_RED - 0x08014000, // ITEM_POTION_GREEN - 0x08015000, // ITEM_POTION_BLUE - 0x08016000, // ITEM_FAIRY - 0x08017000, // ITEM_DEKU_PRINCESS - 0x08018000, // ITEM_MILK_BOTTLE - 0x08019000, // ITEM_MILK_HALF - 0x0801A000, // ITEM_FISH - 0x0801B000, // ITEM_BUG - 0x0801C000, // ITEM_BLUE_FIRE - 0x0801D000, // ITEM_POE - 0x0801E000, // ITEM_BIG_POE - 0x0801F000, // ITEM_SPRING_WATER - 0x08020000, // ITEM_HOT_SPRING_WATER - 0x08021000, // ITEM_ZORA_EGG - 0x08022000, // ITEM_GOLD_DUST - 0x08023000, // ITEM_MUSHROOM - 0x08024000, // ITEM_SEAHORSE - 0x08025000, // ITEM_CHATEAU - 0x08026000, // ITEM_HYLIAN_LOACH - 0x08027000, // ITEM_OBABA_DRINK - 0x08028000, // ITEM_MOON_TEAR - 0x08029000, // ITEM_DEED_LAND - 0x0802A000, // ITEM_DEED_SWAMP - 0x0802B000, // ITEM_DEED_MOUNTAIN - 0x0802C000, // ITEM_DEED_OCEAN - 0x0802D000, // ITEM_ROOM_KEY - 0x0802E000, // ITEM_LETTER_MAMA - 0x0802F000, // ITEM_LETTER_TO_KAFEI - 0x08030000, // ITEM_PENDANT_OF_MEMORIES - 0x08031000, // ITEM_TINGLE_MAP - 0x08032000, // ITEM_MASK_DEKU - 0x08033000, // ITEM_MASK_GORON - 0x08034000, // ITEM_MASK_ZORA - 0x08035000, // ITEM_MASK_FIERCE_DEITY - 0x08036000, // ITEM_MASK_TRUTH - 0x08037000, // ITEM_MASK_KAFEIS_MASK - 0x08038000, // ITEM_MASK_ALL_NIGHT - 0x08039000, // ITEM_MASK_BUNNY - 0x0803A000, // ITEM_MASK_KEATON - 0x0803B000, // ITEM_MASK_GARO - 0x0803C000, // ITEM_MASK_ROMANI - 0x0803D000, // ITEM_MASK_CIRCUS_LEADER - 0x0803E000, // ITEM_MASK_POSTMAN - 0x0803F000, // ITEM_MASK_COUPLE - 0x08040000, // ITEM_MASK_GREAT_FAIRY - 0x08041000, // ITEM_MASK_GIBDO - 0x08042000, // ITEM_MASK_DON_GERO - 0x08043000, // ITEM_MASK_KAMARO - 0x08044000, // ITEM_MASK_CAPTAIN - 0x08045000, // ITEM_MASK_STONE - 0x08046000, // ITEM_MASK_BREMEN - 0x08047000, // ITEM_MASK_BLAST - 0x08048000, // ITEM_MASK_SCENTS - 0x08049000, // ITEM_MASK_GIANT - 0x0804A000, // ITEM_BOW_ARROW_FIRE - 0x0804B000, // ITEM_BOW_ARROW_ICE - 0x0804C000, // ITEM_BOW_ARROW_LIGHT - 0x0804D000, // ITEM_SWORD_KOKIRI - 0x0804E000, // ITEM_SWORD_RAZOR - 0x0804F000, // ITEM_SWORD_GILDED - 0x08050000, // ITEM_SWORD_DEITY - 0x08051000, // ITEM_SHIELD_HERO - 0x08052000, // ITEM_SHIELD_MIRROR - 0x08053000, // ITEM_QUIVER_30 - 0x08054000, // ITEM_QUIVER_40 - 0x08055000, // ITEM_QUIVER_50 - 0x08056000, // ITEM_BOMB_BAG_20 - 0x08057000, // ITEM_BOMB_BAG_30 - 0x08058000, // ITEM_BOMB_BAG_40 - 0x08059000, // ITEM_WALLET_DEFAULT - 0x0805A000, // ITEM_WALLET_ADULT - 0x0805B000, // ITEM_WALLET_GIANT - 0x0805C000, // ITEM_FISHING_ROD - 0x0805D000, // ITEM_REMAINS_ODOLWA - 0x0805E000, // ITEM_REMAINS_GOHT - 0x0805F000, // ITEM_REMAINS_GYORG - 0x08060000, // ITEM_REMAINS_TWINMOLD - 0x08062000, // ITEM_SONG_SONATA - 0x08062000, // ITEM_SONG_LULLABY - 0x08062000, // ITEM_SONG_NOVA - 0x08062000, // ITEM_SONG_ELEGY - 0x08062000, // ITEM_SONG_OATH - 0x08062000, // ITEM_SONG_SARIA - 0x08062000, // ITEM_SONG_TIME - 0x08062000, // ITEM_SONG_HEALING - 0x08062000, // ITEM_SONG_EPONA - 0x08062000, // ITEM_SONG_SOARING - 0x08062000, // ITEM_SONG_STORMS - 0x08062000, // ITEM_SONG_SUN - 0x08061000, // ITEM_BOMBERS_NOTEBOOK - 0x09000000, // ITEM_SKULL_TOKEN - 0x09000900, // ITEM_HEART_CONTAINER - 0x09001200, // ITEM_HEART_PIECE - 0x08062000, // - 0x08062000, // - 0x08062000, // ITEM_SONG_LULLABY_INTRO - 0x09003600, // ITEM_KEY_BOSS - 0x09004800, // ITEM_COMPASS - 0x09003F00, // ITEM_DUNGEON_MAP - 0x09005100, // ITEM_STRAY_FAIRIES - 0x09005A00, // ITEM_KEY_SMALL - 0x09006300, // ITEM_MAGIC_SMALL - 0x09006C00, // ITEM_MAGIC_LARGE - 0x08062180, // ITEM_HEART_PIECE_2 - 0x08062A80, // ITEM_INVALID_1 - 0x08063380, // ITEM_INVALID_2 - gOcarinaCUpTex, // ITEM_INVALID_3 - gOcarinaCDownTex, // ITEM_INVALID_4 - gOcarinaCLeftTex, // ITEM_INVALID_5 - gOcarinaCRightTex, // ITEM_INVALID_6 - gOcarinaATex, // ITEM_INVALID_7 + icon_item_static_yar_Blob_000000, // ITEM_OCARINA + icon_item_static_yar_Blob_001000, // ITEM_BOW + icon_item_static_yar_Blob_002000, // ITEM_ARROW_FIRE + icon_item_static_yar_Blob_003000, // ITEM_ARROW_ICE + icon_item_static_yar_Blob_004000, // ITEM_ARROW_LIGHT + icon_item_static_yar_Blob_005000, // ITEM_OCARINA_FAIRY + icon_item_static_yar_Blob_006000, // ITEM_BOMB + icon_item_static_yar_Blob_007000, // ITEM_BOMBCHU + icon_item_static_yar_Blob_008000, // ITEM_STICK + icon_item_static_yar_Blob_009000, // ITEM_NUT + icon_item_static_yar_Blob_00A000, // ITEM_MAGIC_BEANS + icon_item_static_yar_Blob_00B000, // ITEM_SLINGSHOT + icon_item_static_yar_Blob_00C000, // ITEM_POWDER_KEG + icon_item_static_yar_Blob_00D000, // ITEM_PICTO_BOX + icon_item_static_yar_Blob_00E000, // ITEM_LENS + icon_item_static_yar_Blob_00F000, // ITEM_HOOKSHOT + icon_item_static_yar_Blob_010000, // ITEM_SWORD_GREAT_FAIRY + icon_item_static_yar_Blob_011000, // ITEM_LONGSHOT + icon_item_static_yar_Blob_012000, // ITEM_BOTTLE + icon_item_static_yar_Blob_013000, // ITEM_POTION_RED + icon_item_static_yar_Blob_014000, // ITEM_POTION_GREEN + icon_item_static_yar_Blob_015000, // ITEM_POTION_BLUE + icon_item_static_yar_Blob_016000, // ITEM_FAIRY + icon_item_static_yar_Blob_017000, // ITEM_DEKU_PRINCESS + icon_item_static_yar_Blob_018000, // ITEM_MILK_BOTTLE + icon_item_static_yar_Blob_019000, // ITEM_MILK_HALF + icon_item_static_yar_Blob_01A000, // ITEM_FISH + icon_item_static_yar_Blob_01B000, // ITEM_BUG + icon_item_static_yar_Blob_01C000, // ITEM_BLUE_FIRE + icon_item_static_yar_Blob_01D000, // ITEM_POE + icon_item_static_yar_Blob_01E000, // ITEM_BIG_POE + icon_item_static_yar_Blob_01F000, // ITEM_SPRING_WATER + icon_item_static_yar_Blob_020000, // ITEM_HOT_SPRING_WATER + icon_item_static_yar_Blob_021000, // ITEM_ZORA_EGG + icon_item_static_yar_Blob_022000, // ITEM_GOLD_DUST + icon_item_static_yar_Blob_023000, // ITEM_MUSHROOM + icon_item_static_yar_Blob_024000, // ITEM_SEAHORSE + icon_item_static_yar_Blob_025000, // ITEM_CHATEAU + icon_item_static_yar_Blob_026000, // ITEM_HYLIAN_LOACH + icon_item_static_yar_Blob_027000, // ITEM_OBABA_DRINK + icon_item_static_yar_Blob_028000, // ITEM_MOON_TEAR + icon_item_static_yar_Blob_029000, // ITEM_DEED_LAND + icon_item_static_yar_Blob_02A000, // ITEM_DEED_SWAMP + icon_item_static_yar_Blob_02B000, // ITEM_DEED_MOUNTAIN + icon_item_static_yar_Blob_02C000, // ITEM_DEED_OCEAN + icon_item_static_yar_Blob_02D000, // ITEM_ROOM_KEY + icon_item_static_yar_Blob_02E000, // ITEM_LETTER_MAMA + icon_item_static_yar_Blob_02F000, // ITEM_LETTER_TO_KAFEI + icon_item_static_yar_Blob_030000, // ITEM_PENDANT_OF_MEMORIES + icon_item_static_yar_Blob_031000, // ITEM_TINGLE_MAP + icon_item_static_yar_Blob_032000, // ITEM_MASK_DEKU + icon_item_static_yar_Blob_033000, // ITEM_MASK_GORON + icon_item_static_yar_Blob_034000, // ITEM_MASK_ZORA + icon_item_static_yar_Blob_035000, // ITEM_MASK_FIERCE_DEITY + icon_item_static_yar_Blob_036000, // ITEM_MASK_TRUTH + icon_item_static_yar_Blob_037000, // ITEM_MASK_KAFEIS_MASK + icon_item_static_yar_Blob_038000, // ITEM_MASK_ALL_NIGHT + icon_item_static_yar_Blob_039000, // ITEM_MASK_BUNNY + icon_item_static_yar_Blob_03A000, // ITEM_MASK_KEATON + icon_item_static_yar_Blob_03B000, // ITEM_MASK_GARO + icon_item_static_yar_Blob_03C000, // ITEM_MASK_ROMANI + icon_item_static_yar_Blob_03D000, // ITEM_MASK_CIRCUS_LEADER + icon_item_static_yar_Blob_03E000, // ITEM_MASK_POSTMAN + icon_item_static_yar_Blob_03F000, // ITEM_MASK_COUPLE + icon_item_static_yar_Blob_040000, // ITEM_MASK_GREAT_FAIRY + icon_item_static_yar_Blob_041000, // ITEM_MASK_GIBDO + icon_item_static_yar_Blob_042000, // ITEM_MASK_DON_GERO + icon_item_static_yar_Blob_043000, // ITEM_MASK_KAMARO + icon_item_static_yar_Blob_044000, // ITEM_MASK_CAPTAIN + icon_item_static_yar_Blob_045000, // ITEM_MASK_STONE + icon_item_static_yar_Blob_046000, // ITEM_MASK_BREMEN + icon_item_static_yar_Blob_047000, // ITEM_MASK_BLAST + icon_item_static_yar_Blob_048000, // ITEM_MASK_SCENTS + icon_item_static_yar_Blob_049000, // ITEM_MASK_GIANT + icon_item_static_yar_Blob_04A000, // ITEM_BOW_ARROW_FIRE + icon_item_static_yar_Blob_04B000, // ITEM_BOW_ARROW_ICE + icon_item_static_yar_Blob_04C000, // ITEM_BOW_ARROW_LIGHT + icon_item_static_yar_Blob_04D000, // ITEM_SWORD_KOKIRI + icon_item_static_yar_Blob_04E000, // ITEM_SWORD_RAZOR + icon_item_static_yar_Blob_04F000, // ITEM_SWORD_GILDED + icon_item_static_yar_Blob_050000, // ITEM_SWORD_DEITY + icon_item_static_yar_Blob_051000, // ITEM_SHIELD_HERO + icon_item_static_yar_Blob_052000, // ITEM_SHIELD_MIRROR + icon_item_static_yar_Blob_053000, // ITEM_QUIVER_30 + icon_item_static_yar_Blob_054000, // ITEM_QUIVER_40 + icon_item_static_yar_Blob_055000, // ITEM_QUIVER_50 + icon_item_static_yar_Blob_056000, // ITEM_BOMB_BAG_20 + icon_item_static_yar_Blob_057000, // ITEM_BOMB_BAG_30 + icon_item_static_yar_Blob_058000, // ITEM_BOMB_BAG_40 + icon_item_static_yar_Blob_059000, // ITEM_WALLET_DEFAULT + icon_item_static_yar_Blob_05A000, // ITEM_WALLET_ADULT + icon_item_static_yar_Blob_05B000, // ITEM_WALLET_GIANT + icon_item_static_yar_Blob_05C000, // ITEM_FISHING_ROD + icon_item_static_yar_Blob_05D000, // ITEM_REMAINS_ODOLWA + icon_item_static_yar_Blob_05E000, // ITEM_REMAINS_GOHT + icon_item_static_yar_Blob_05F000, // ITEM_REMAINS_GYORG + icon_item_static_yar_Blob_060000, // ITEM_REMAINS_TWINMOLD + icon_item_static_yar_Blob_062000, // ITEM_SONG_SONATA + icon_item_static_yar_Blob_062000, // ITEM_SONG_LULLABY + icon_item_static_yar_Blob_062000, // ITEM_SONG_NOVA + icon_item_static_yar_Blob_062000, // ITEM_SONG_ELEGY + icon_item_static_yar_Blob_062000, // ITEM_SONG_OATH + icon_item_static_yar_Blob_062000, // ITEM_SONG_SARIA + icon_item_static_yar_Blob_062000, // ITEM_SONG_TIME + icon_item_static_yar_Blob_062000, // ITEM_SONG_HEALING + icon_item_static_yar_Blob_062000, // ITEM_SONG_EPONA + icon_item_static_yar_Blob_062000, // ITEM_SONG_SOARING + icon_item_static_yar_Blob_062000, // ITEM_SONG_STORMS + icon_item_static_yar_Blob_062000, // ITEM_SONG_SUN + icon_item_static_yar_Blob_061000, // ITEM_BOMBERS_NOTEBOOK + icon_item_24_static_yar_Blob_000000, // ITEM_SKULL_TOKEN + icon_item_24_static_yar_Blob_000900, // ITEM_HEART_CONTAINER + icon_item_24_static_yar_Blob_001200, // ITEM_HEART_PIECE + icon_item_static_yar_Blob_062000, // + icon_item_static_yar_Blob_062000, // + icon_item_static_yar_Blob_062000, // ITEM_SONG_LULLABY_INTRO + icon_item_24_static_yar_Blob_003600, // ITEM_KEY_BOSS + icon_item_24_static_yar_Blob_004800, // ITEM_COMPASS + icon_item_24_static_yar_Blob_003F00, // ITEM_DUNGEON_MAP + icon_item_24_static_yar_Blob_005100, // ITEM_STRAY_FAIRIES + icon_item_24_static_yar_Blob_005A00, // ITEM_KEY_SMALL + icon_item_24_static_yar_Blob_006300, // ITEM_MAGIC_SMALL + icon_item_24_static_yar_Blob_006C00, // ITEM_MAGIC_LARGE + icon_item_static_yar_Blob_062180, // ITEM_HEART_PIECE_2 + icon_item_static_yar_Blob_062A80, // ITEM_INVALID_1 + icon_item_static_yar_Blob_063380, // ITEM_INVALID_2 + gOcarinaCUpTex, // ITEM_INVALID_3 + gOcarinaCDownTex, // ITEM_INVALID_4 + gOcarinaCLeftTex, // ITEM_INVALID_5 + gOcarinaCRightTex, // ITEM_INVALID_6 + gOcarinaATex, // ITEM_INVALID_7 }; // Used to map item IDs to inventory slots diff --git a/src/code/flg_set.c b/src/code/flg_set.c index bb25818a6..f7c8c261e 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -12,6 +12,11 @@ #include "global.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" +typedef struct FlagSetEntry { + /* 0x0 */ u8* value; + /* 0x4 */ const char* name; +} FlagSetEntry; // size = 0x8 + static FlagSetEntry sFlagEntries[] = { { &gSaveContext.save.saveInfo.weekEventReg[0], "week_event_reg[0]" }, { &gSaveContext.save.saveInfo.weekEventReg[1], "week_event_reg[1]" }, diff --git a/src/code/main.c b/src/code/main.c index 186240489..3da3d25d7 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -9,6 +9,7 @@ #include "stack.h" #include "stackcheck.h" #include "system_heap.h" +#include "z64thread.h" extern OSMesgQueue sSiIntMsgQ; extern OSMesg sSiIntMsgBuf[1]; diff --git a/src/code/sched.c b/src/code/sched.c index c06eb41ba..29c558ea7 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,6 +1,7 @@ #include "prevent_bss_reordering.h" #include "global.h" #include "stackcheck.h" +#include "z64thread.h" #define RSP_DONE_MSG 667 #define RDP_DONE_MSG 668 diff --git a/src/code/sys_flashrom.c b/src/code/sys_flashrom.c index c2665741e..f2424b850 100644 --- a/src/code/sys_flashrom.c +++ b/src/code/sys_flashrom.c @@ -3,6 +3,7 @@ #include "stack.h" #include "stackcheck.h" #include "system_malloc.h" +#include "z64thread.h" OSMesgQueue sFlashromMesgQueue; OSMesg sFlashromMesg[1]; diff --git a/src/code/sys_slowly.c b/src/code/sys_slowly.c index 754c5d472..47170db62 100644 --- a/src/code/sys_slowly.c +++ b/src/code/sys_slowly.c @@ -8,9 +8,11 @@ * * @note: `argCount` must be set manually, as this file implements no way to configure it. */ + #include "slowly.h" #include "global.h" #include "stackcheck.h" +#include "z64thread.h" void Slowly_Main(SlowlyMgr* slowly) { slowly->status |= SLOWLY_STATUS_STARTED; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index b7f07d14d..f3f4043dd 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,4 +1,11 @@ #include "global.h" +#include "z64collision_check.h" + +typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*); +typedef void (*ColChkBloodFunc)(struct PlayState*, Collider*, Vec3f*); +typedef void (*ColChkApplyFunc)(struct PlayState*, CollisionCheckContext*, Collider*); +typedef void (*ColChkVsFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Collider*); +typedef s32 (*ColChkLineFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); Vec3f D_801EDE00; Vec3f D_801EDE10; diff --git a/src/code/z_eff_tire_mark.c b/src/code/z_eff_tire_mark.c index d14d6926c..55c15714e 100644 --- a/src/code/z_eff_tire_mark.c +++ b/src/code/z_eff_tire_mark.c @@ -80,7 +80,8 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f spAC->flags |= 1; } - if (spA8) {} // Necessary to match + //! FAKE: + if (spA8) {} spA8 = &this->elements[this->numElements]; spA8->flags = 0; diff --git a/src/code/z_face_reaction.c b/src/code/z_face_reaction.c index e6d985d65..0d2d632ab 100644 --- a/src/code/z_face_reaction.c +++ b/src/code/z_face_reaction.c @@ -43,15 +43,15 @@ static u16 sReactionTextIds[][PLAYER_MASK_GIANT - 1] = { /* 0x10 */ { 0 }, /* 0x11 */ { 0x0000, 0x236B, 0x0000, 0x0000, 0x236C, 0x0000, 0x0000, 0x236D, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x236E, 0x0000, 0x0000, 0x0000 }, + 0x0000, 0x0000, 0x0000, 0x236E, 0x0000, 0x0000, 0x0000 }, // FACE_REACTION_SET_JIM /* 0x12 */ { 0x2348, 0x2349, 0x234A, 0x0000, 0x234B, 0x2348, 0x234C, 0x2348, 0x234D, 0x234E, 0x2348, 0x2348, - 0x2348, 0x2348, 0x2348, 0x234F, 0x2348, 0x2348, 0x2350 }, + 0x2348, 0x2348, 0x2348, 0x234F, 0x2348, 0x2348, 0x2350 }, // FACE_REACTION_SET_BOMBERS /* 0x13 */ { 0 }, /* 0x14 */ { 0 }, /* 0x15 */ { 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357, 0x2356, 0x2358, 0x2359, 0x2356, 0x235A, - 0x2353, 0x235A, 0x235A, 0x235B, 0x2354, 0x2351, 0x235C }, + 0x2353, 0x235A, 0x235A, 0x235B, 0x2354, 0x2351, 0x235C }, // FACE_REACTION_SET_BOMBERS_HIDEOUT_GUARD /* 0x16 */ { 0 }, /* 0x17 */ { 0 }, /* 0x18 */ { 0 }, @@ -77,24 +77,24 @@ static u16 sReactionTextIds[][PLAYER_MASK_GIANT - 1] = { /* 0x2C */ { 0 }, /* 0x2D */ { 0x233B, 0x233C, 0x233D, 0x233E, 0x233F, 0x233B, 0x2340, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, - 0x2346, 0x233B, 0x2345, 0x2347, 0x233D, 0x233B, 0x233D }, + 0x2346, 0x233B, 0x2345, 0x2347, 0x233D, 0x233B, 0x233D }, // FACE_REACTION_SET_TREASURE_CHEST_SHOP_GAL /* 0x2E */ { 0 }, /* 0x2F */ { 0x2328, 0x2329, 0x232A, 0x232B, 0x2328, 0x2328, 0x232C, 0x2328, 0x232D, 0x232E, 0x2328, 0x2328, - 0x2328, 0x232F, 0x2330, 0x2331, 0x2332, 0x2333, 0x2328 }, + 0x2328, 0x232F, 0x2330, 0x2331, 0x2332, 0x2333, 0x2328 }, // FACE_REACTION_SET_CURIOSITY_SHOP_MAN /* 0x30 */ { 0x236F, 0x2370, 0x236F, 0x0000, 0x236F, 0x236F, 0x236F, 0x236F, 0x0000, 0x236F, 0x236F, 0x236F, - 0x236F, 0x236F, 0x2371, 0x2372, 0x236F, 0x236F, 0x236F }, + 0x236F, 0x236F, 0x2371, 0x2372, 0x236F, 0x236F, 0x236F }, // FACE_REACTION_SET_TOWN_SHOOTING_GALLERY_MAN /* 0x31 */ { 0x2373, 0x2374, 0x2373, 0x0000, 0x2373, 0x2373, 0x2373, 0x2373, 0x0000, 0x2375, 0x2376, 0x2373, - 0x2373, 0x2373, 0x2377, 0x2378, 0x2373, 0x2373, 0x2373 }, + 0x2373, 0x2373, 0x2377, 0x2378, 0x2373, 0x2373, 0x2373 }, // FACE_REACTION_SET_SWAMP_SHOOTING_GALLERY_MAN /* 0x32 */ { 0 }, /* 0x33 */ { 0 }, /* 0x34 */ { 0 }, /* 0x35 */ { 0 }, /* 0x36 */ { 0x0000, 0x2334, 0x0000, 0x0000, 0x0000, 0x0000, 0x2335, 0x0000, 0x2336, 0x2337, 0x0000, 0x0000, - 0x0000, 0x0000, 0x2338, 0x2339, 0x0000, 0x233A, 0x0000 }, + 0x0000, 0x0000, 0x2338, 0x2339, 0x0000, 0x233A, 0x0000 }, // FACE_REACTION_SET_PART_TIMER /* 0x37 */ { 0 }, /* 0x38 */ { 0 }, /* 0x39 */ { 0 }, @@ -178,7 +178,7 @@ static u16 sReactionTextIds[][PLAYER_MASK_GIANT - 1] = { }; // clang-format on -u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet) { +u16 Text_GetFaceReaction(PlayState* play, FaceReactionSet reactionSet) { if ((Player_GetMask(play) > PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) { return sReactionTextIds[reactionSet][Player_GetMask(play) - 1]; } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 2191498a3..9346af59a 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -90,13 +90,13 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD538.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD59C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpAmbientColor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD5E0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpDiffuseColor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD654.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpFogColor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FD698.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpFog.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/get_days_elapsed.s") diff --git a/src/code/z_nmi_buff.c b/src/code/z_nmi_buff.c index 205bd8d0f..eacfc5f46 100644 --- a/src/code/z_nmi_buff.c +++ b/src/code/z_nmi_buff.c @@ -3,6 +3,13 @@ #define COLD_RESET 0 #define NMI 1 +typedef struct { + /* 0x00 */ u32 resetting; + /* 0x04 */ u32 resetCount; + /* 0x08 */ OSTime duration; + /* 0x10 */ OSTime resetTime; +} NmiBuff; // size >= 0x18 + NmiBuff* gNMIBuffer; void Nmi_Init(void) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 28ba0d36e..ca655c70b 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2452,7 +2452,7 @@ void Interface_InitMinigame(PlayState* play) { void Interface_LoadItemIconImpl(PlayState* play, u8 btn) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - CmpDma_LoadFile(SEGMENT_ROM_START(icon_item_static_test), GET_CUR_FORM_BTN_ITEM(btn), + CmpDma_LoadFile(SEGMENT_ROM_START(icon_item_static_yar), GET_CUR_FORM_BTN_ITEM(btn), &interfaceCtx->iconItemSegment[(u32)btn * 0x1000], 0x1000); } @@ -6702,7 +6702,7 @@ void Interface_Update(PlayState* play) { case HUD_VISIBILITY_NONE: case HUD_VISIBILITY_NONE_ALT: case HUD_VISIBILITY_B: - dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer << 5); + dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer * 32); if (dimmingAlpha < 0) { dimmingAlpha = 0; } @@ -6733,7 +6733,7 @@ void Interface_Update(PlayState* play) { case HUD_VISIBILITY_B_MAGIC: case HUD_VISIBILITY_A_B: case HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP: - dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer << 5); + dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer * 32); if (dimmingAlpha < 0) { dimmingAlpha = 0; } @@ -6746,7 +6746,7 @@ void Interface_Update(PlayState* play) { break; case HUD_VISIBILITY_ALL: - dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer << 5); + dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer * 32); if (dimmingAlpha < 0) { dimmingAlpha = 0; } diff --git a/src/code/z_play.c b/src/code/z_play.c index 9063c9151..d86fd90d6 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -2090,8 +2090,8 @@ void Play_Init(GameState* thisx) { s32 scene; if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) { - if (CHECK_EVENTINF(EVENTINF_27)) { - CLEAR_EVENTINF(EVENTINF_27); + if (CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) { + CLEAR_EVENTINF(EVENTINF_TRIGGER_DAYTELOP); STOP_GAMESTATE(&this->state); SET_NEXT_GAMESTATE(&this->state, DayTelop_Init, sizeof(DayTelopState)); return; diff --git a/src/code/z_play_hireso.c b/src/code/z_play_hireso.c index b995028ca..24dcaca55 100644 --- a/src/code/z_play_hireso.c +++ b/src/code/z_play_hireso.c @@ -1,31 +1,7 @@ #include "global.h" #include "z64bombers_notebook.h" #include "interface/schedule_static/schedule_static.h" - -// TODO: Needs YAZ0 -// Segment 0x07 schedule_dma_static_test -extern TexturePtr D_07000000; -extern TexturePtr D_07000800; -extern TexturePtr D_07001000; -extern TexturePtr D_07001800; -extern TexturePtr D_07002000; -extern TexturePtr D_07002800; -extern TexturePtr D_07003000; -extern TexturePtr D_07003800; -extern TexturePtr D_07004000; -extern TexturePtr D_07004800; -extern TexturePtr D_07005000; -extern TexturePtr D_07005800; -extern TexturePtr D_07006000; -extern TexturePtr D_07006800; -extern TexturePtr D_07007000; -extern TexturePtr D_07007800; -extern TexturePtr D_07008000; -extern TexturePtr D_07008800; -extern TexturePtr D_07009000; -extern TexturePtr D_07009800; -extern TexturePtr D_0700AC00; -extern TexturePtr D_0700AEA0; +#include "archives/schedule_dma_static/schedule_dma_static_yar.h" #define BOMBERS_NOTEBOOK_ENTRY_SIZE 3 #define BOMBERS_NOTEBOOK_ENTRY_MAX 10 @@ -395,8 +371,8 @@ void BombersNotebook_DrawColumns(Gfx** gfxP) { TexturePtr sBombersNotebookEventIconTextures[] = { gBombersNotebookEntryIconExclamationPointTex, - &D_0700AC00, - &D_0700AEA0, + schedule_dma_static_yar_Blob_00AC00, + schedule_dma_static_yar_Blob_00AEA0, }; s16 sBombersNotebookEntryIconColors[][3] = { { 255, 255, 0 }, @@ -1163,8 +1139,8 @@ void BombersNotebook_Update(PlayState* play, BombersNotebook* this, Input* input s32 stickAdjY = input->rel.stick_y; s32 cursorEntryScan; - this->scheduleDmaSegmentStart = SEGMENT_ROM_START(schedule_dma_static_test); - this->scheduleDmaSegmentSize = SEGMENT_ROM_SIZE(schedule_dma_static_old); + this->scheduleDmaSegmentStart = SEGMENT_ROM_START(schedule_dma_static_yar); + this->scheduleDmaSegmentSize = SEGMENT_ROM_SIZE(schedule_dma_static_syms); this->scheduleSegmentStart = SEGMENT_ROM_START(schedule_static); this->scheduleSegmentSize = SEGMENT_ROM_SIZE(schedule_static); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 368b4509e..529458f83 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -526,7 +526,7 @@ void Scene_CommandSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { // SceneTableEntry Header Command 0x1A: Material Animations void Scene_CommandAnimatedMaterials(PlayState* play, SceneCmd* cmd) { - play->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment); + play->sceneMaterialAnims = Lib_SegmentedToVirtual(cmd->textureAnimations.segment); } /** @@ -536,38 +536,38 @@ void Scene_SetExitFade(PlayState* play) { play->transitionType = Entrance_GetTransitionFlags(play->nextEntrance) & 0x7F; } -void (*sSceneCmdHandlers[])(PlayState*, SceneCmd*) = { - Scene_CommandSpawnList, - Scene_CommandActorList, - Scene_CommandActorCutsceneCamList, - Scene_CommandCollisionHeader, - Scene_CommandRoomList, - Scene_CommandWindSettings, - Scene_CommandEntranceList, - Scene_CommandSpecialFiles, - Scene_CommandRoomBehavior, - Scene_Command09, - Scene_CommandMesh, - Scene_CommandObjectList, - Scene_CommandLightList, - Scene_CommandPathList, - Scene_CommandTransiActorList, - Scene_CommandEnvLightSettings, - Scene_CommandTimeSettings, - Scene_CommandSkyboxSettings, - Scene_CommandSkyboxDisables, - Scene_CommandExitList, - NULL, - Scene_CommandSoundSettings, - Scene_CommandEchoSetting, - Scene_CommandCutsceneScriptList, - Scene_CommandAltHeaderList, - Scene_CommandSetRegionVisitedFlag, - Scene_CommandAnimatedMaterials, - Scene_CommandCutsceneList, - Scene_CommandMiniMap, - Scene_Command1D, - Scene_CommandMiniMapCompassInfo, +void (*sSceneCmdHandlers[SCENE_CMD_MAX])(PlayState*, SceneCmd*) = { + Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST + Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST + Scene_CommandActorCutsceneCamList, // SCENE_CMD_ID_ACTOR_CUTSCENE_CAM_LIST + Scene_CommandCollisionHeader, // SCENE_CMD_ID_COL_HEADER + Scene_CommandRoomList, // SCENE_CMD_ID_ROOM_LIST + Scene_CommandWindSettings, // SCENE_CMD_ID_WIND_SETTINGS + Scene_CommandEntranceList, // SCENE_CMD_ID_ENTRANCE_LIST + Scene_CommandSpecialFiles, // SCENE_CMD_ID_SPECIAL_FILES + Scene_CommandRoomBehavior, // SCENE_CMD_ID_ROOM_BEHAVIOR + Scene_Command09, // SCENE_CMD_ID_UNK_09 + Scene_CommandMesh, // SCENE_CMD_ID_ROOM_SHAPE + Scene_CommandObjectList, // SCENE_CMD_ID_OBJECT_LIST + Scene_CommandLightList, // SCENE_CMD_ID_LIGHT_LIST + Scene_CommandPathList, // SCENE_CMD_ID_PATH_LIST + Scene_CommandTransiActorList, // SCENE_CMD_ID_TRANSI_ACTOR_LIST + Scene_CommandEnvLightSettings, // SCENE_CMD_ID_ENV_LIGHT_SETTINGS + Scene_CommandTimeSettings, // SCENE_CMD_ID_TIME_SETTINGS + Scene_CommandSkyboxSettings, // SCENE_CMD_ID_SKYBOX_SETTINGS + Scene_CommandSkyboxDisables, // SCENE_CMD_ID_SKYBOX_DISABLES + Scene_CommandExitList, // SCENE_CMD_ID_EXIT_LIST + NULL, // SCENE_CMD_ID_END + Scene_CommandSoundSettings, // SCENE_CMD_ID_SOUND_SETTINGS + Scene_CommandEchoSetting, // SCENE_CMD_ID_ECHO_SETTINGS + Scene_CommandCutsceneScriptList, // SCENE_CMD_ID_CUTSCENE_SCRIPT_LIST + Scene_CommandAltHeaderList, // SCENE_CMD_ID_ALTERNATE_HEADER_LIST + Scene_CommandSetRegionVisitedFlag, // SCENE_CMD_ID_SET_REGION_VISITED + Scene_CommandAnimatedMaterials, // SCENE_CMD_ID_ANIMATED_MATERIAL_LIST + Scene_CommandCutsceneList, // SCENE_CMD_ID_ACTOR_CUTSCENE_LIST + Scene_CommandMiniMap, // SCENE_CMD_ID_MINIMAP_INFO + Scene_Command1D, // SCENE_CMD_ID_UNUSED_1D + Scene_CommandMiniMapCompassInfo, // SCENE_CMD_ID_MINIMAP_COMPASS_ICON_INFO }; /** diff --git a/src/code/z_sound_source.c b/src/code/z_sound_source.c index 15ebd018a..4962f7072 100644 --- a/src/code/z_sound_source.c +++ b/src/code/z_sound_source.c @@ -1,11 +1,12 @@ #include "global.h" +#include "z64sound_source.h" void SoundSource_InitAll(PlayState* play) { SoundSource* sources = &play->soundSources[0]; s32 i; // clang-format off - for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { sources[i].countdown = 0; } + for (i = 0; i < SOUND_SOURCE_COUNT; i++) { sources[i].countdown = 0; } // clang-format on } @@ -13,7 +14,7 @@ void SoundSource_UpdateAll(PlayState* play) { SoundSource* source = &play->soundSources[0]; s32 i; - for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { + for (i = 0; i < SOUND_SOURCE_COUNT; i++) { if (source->countdown != 0) { if (DECR(source->countdown) == 0) { AudioSfx_StopByPos(&source->projectedPos); @@ -37,7 +38,7 @@ void SoundSource_Add(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId, s32 i; source = &play->soundSources[0]; - for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { + for (i = 0; i < SOUND_SOURCE_COUNT; i++) { if (source->countdown == 0) { break; } @@ -52,7 +53,7 @@ void SoundSource_Add(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId, } // If no sound source is available, replace the sound source with the smallest remaining countdown - if (i >= ARRAY_COUNT(play->soundSources)) { + if (i >= SOUND_SOURCE_COUNT) { source = backupSource; AudioSfx_StopByPos(&source->projectedPos); } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index fa690758c..f03d38e45 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -489,38 +489,38 @@ void Sram_SaveEndOfCycle(PlayState* play) { gSaveContext.eventInf[i] = 0; } - CLEAR_EVENTINF(EVENTINF_70); - CLEAR_EVENTINF(EVENTINF_71); - CLEAR_EVENTINF(EVENTINF_72); - CLEAR_EVENTINF(EVENTINF_73); - CLEAR_EVENTINF(EVENTINF_74); + CLEAR_EVENTINF(EVENTINF_THREEDAYRESET_LOST_RUPEES); + CLEAR_EVENTINF(EVENTINF_THREEDAYRESET_LOST_BOMB_AMMO); + CLEAR_EVENTINF(EVENTINF_THREEDAYRESET_LOST_NUT_AMMO); + CLEAR_EVENTINF(EVENTINF_THREEDAYRESET_LOST_STICK_AMMO); + CLEAR_EVENTINF(EVENTINF_THREEDAYRESET_LOST_ARROW_AMMO); if (gSaveContext.save.saveInfo.playerData.rupees != 0) { - SET_EVENTINF(EVENTINF_70); + SET_EVENTINF(EVENTINF_THREEDAYRESET_LOST_RUPEES); } if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { item = INV_CONTENT(ITEM_BOMB); if (AMMO(item) != 0) { - SET_EVENTINF(EVENTINF_71); + SET_EVENTINF(EVENTINF_THREEDAYRESET_LOST_BOMB_AMMO); } } if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { item = INV_CONTENT(ITEM_NUT); if (AMMO(item) != 0) { - SET_EVENTINF(EVENTINF_72); + SET_EVENTINF(EVENTINF_THREEDAYRESET_LOST_NUT_AMMO); } } if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { item = INV_CONTENT(ITEM_STICK); if (AMMO(item) != 0) { - SET_EVENTINF(EVENTINF_73); + SET_EVENTINF(EVENTINF_THREEDAYRESET_LOST_STICK_AMMO); } } if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { item = INV_CONTENT(ITEM_BOW); if (AMMO(item) != 0) { - SET_EVENTINF(EVENTINF_74); + SET_EVENTINF(EVENTINF_THREEDAYRESET_LOST_ARROW_AMMO); } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index d0d0f0c3c..10ad49d9b 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -320,6 +320,7 @@ void func_80B84610(BgDblueWaterfall* this, PlayState* play) { player->actor.world.pos.x += sp34.x; player->actor.world.pos.z += sp34.z; + //! FAKE: if (this && this && this) {} player->pushedSpeed = 8.0f; player->pushedYaw = this->actor.yawTowardsPlayer; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 66666b82b..f85015ea9 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -829,7 +829,7 @@ void func_80A9CE1C(BgHakuginPost* this, PlayState* play) { for (i = 0; i < D_80A9E028.count; i++) { collider = D_80A9E028.unk_0000[i].collider; - if ((collider != NULL) && (collider->base.acFlags & AT_HIT) && (D_80A9E028.unk_0000[i].unk_34 == 1)) { + if ((collider != NULL) && (collider->base.acFlags & AC_HIT) && (D_80A9E028.unk_0000[i].unk_34 == 1)) { temp_f2 = this->unk_16C; yDiff = ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y)); temp_f0 = temp_f2 + D_80A9E028.unk_0000[i].unk_14.y; @@ -853,7 +853,7 @@ void func_80A9CE1C(BgHakuginPost* this, PlayState* play) { for (i = 0; i < D_80A9E028.count; i++) { collider = D_80A9E028.unk_0000[i].collider; if (collider != NULL) { - collider->base.acFlags &= ~AT_HIT; + collider->base.acFlags &= ~AC_HIT; } } diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c index 6085a93a2..a09c0fb02 100644 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c +++ b/src/overlays/actors/ovl_Bg_Last_Bwall/z_bg_last_bwall.c @@ -225,8 +225,8 @@ void func_80C187E4(BgLastBwall* this) { } void func_80C187F8(BgLastBwall* this, PlayState* play) { - if (this->colliderTris.base.acFlags & 2) { - this->colliderTris.base.acFlags &= ~2; + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; Flags_SetSwitch(play, BGLASTBWALL_GET_SWITCHFLAGS(&this->dyna.actor)); func_80C1886C(this, play); } else { diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 30775584b..a5b3f91d6 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -521,7 +521,7 @@ void EnAm_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->enemyCollider.base); } CollisionCheck_SetAC(play, &play->colChkCtx, &this->interactCollider.base); - if (this->enemyCollider.base.atFlags & AC_ON) { + if (this->enemyCollider.base.atFlags & AT_ON) { this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(play, &play->colChkCtx, &this->enemyCollider.base); } 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 762141ed4..056ca97d5 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -688,21 +688,20 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, PlayState* play) { if (this->idleTimer < 8) { camYaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x4800; if (this->idleTimer < 5) { - unkTemp = (this->idleTimer << 0xC) - 0x4000; - // 1.4.0...1 is NOT 1.4, the rodata demands it - tempVec.y = (((Math_SinS(unkTemp) * 23.0f) + 40.0f) * 1.4000001f) + this->actor.world.pos.y; + unkTemp = (this->idleTimer * 0x1000) - 0x4000; + tempVec.y = (((Math_SinS(unkTemp) * 23.0f) + 40.0f) * (1400.0f * 0.001f)) + this->actor.world.pos.y; unkTemp2 = Math_CosS(unkTemp) * 32.2f; tempVec.x = (Math_SinS(camYaw) * unkTemp2) + this->actor.world.pos.x; tempVec.z = (Math_CosS(camYaw) * unkTemp2) + this->actor.world.pos.z; } else { - tempVec.y = this->actor.world.pos.y + ((40.0f + (15.0f * (this->idleTimer - 5))) * 1.4000001f); + tempVec.y = this->actor.world.pos.y + ((40.0f + (15.0f * (this->idleTimer - 5))) * (1400.0f * 0.001f)); tempVec.x = (Math_SinS(camYaw) * 32.2f) + this->actor.world.pos.x; tempVec.z = (Math_CosS(camYaw) * 32.2f) + this->actor.world.pos.z; } // not sure what we're turning this into, but its based on the timer - modifiedTimer = ((f32)((this->idleTimer * 10) + 80) * 1.4000001f); + modifiedTimer = ((this->idleTimer * 10) + 80) * (1400.0f * 0.001f); func_800B3030(play, &tempVec, &D_80B6506C, &gZeroVec3f, modifiedTimer, 0, 2); tempVec.x = (2.0f * this->actor.world.pos.x) - tempVec.x; tempVec.z = (2.0f * this->actor.world.pos.z) - tempVec.z; diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 55f7ff281..a600df6d2 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -295,11 +295,11 @@ void func_80C03AF4(EnBombers* this, PlayState* play) { break; } - if (!Text_GetFaceReaction(play, 0x12)) { + if (Text_GetFaceReaction(play, FACE_REACTION_SET_BOMBERS) == 0) { func_80C039A8(this, play); } else { this->unk_2A6 = TEXT_STATE_5; - this->actor.textId = Text_GetFaceReaction(play, 0x12); + this->actor.textId = Text_GetFaceReaction(play, FACE_REACTION_SET_BOMBERS); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 81e8723e0..c29916d3a 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -160,8 +160,8 @@ void func_80C04BA0(EnBombers2* this, PlayState* play) { } this->actor.textId = sTextIds[this->textIdIndex]; - if (Text_GetFaceReaction(play, 0x15) != 0) { - this->actor.textId = Text_GetFaceReaction(play, 0x15); + if (Text_GetFaceReaction(play, FACE_REACTION_SET_BOMBERS_HIDEOUT_GUARD) != 0) { + this->actor.textId = Text_GetFaceReaction(play, FACE_REACTION_SET_BOMBERS_HIDEOUT_GUARD); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -240,7 +240,7 @@ void func_80C04D8C(EnBombers2* this, PlayState* play) { return; } } - if (Text_GetFaceReaction(play, 0x15) != 0) { + if (Text_GetFaceReaction(play, FACE_REACTION_SET_BOMBERS_HIDEOUT_GUARD) != 0) { this->unk_28E = 0; Message_CloseTextbox(play); func_80C04B40(this); diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 229a1e695..ea5feeacd 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -379,8 +379,8 @@ void func_80BFEB64(EnBomjima* this, PlayState* play) { } } - if (Text_GetFaceReaction(play, 0x11) != 0) { - this->actor.textId = Text_GetFaceReaction(play, 0x11); + if (Text_GetFaceReaction(play, FACE_REACTION_SET_JIM) != 0) { + this->actor.textId = Text_GetFaceReaction(play, FACE_REACTION_SET_JIM); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -498,8 +498,8 @@ void func_80BFF174(EnBomjima* this, PlayState* play) { this->cutsceneEnded = true; } - if (Text_GetFaceReaction(play, 0x11) != 0) { - this->actor.textId = Text_GetFaceReaction(play, 0x11); + if (Text_GetFaceReaction(play, FACE_REACTION_SET_JIM) != 0) { + this->actor.textId = Text_GetFaceReaction(play, FACE_REACTION_SET_JIM); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -881,8 +881,8 @@ void func_80C00168(EnBomjima* this, PlayState* play) { func_80BFE32C(this, play, 0); func_80BFE67C(this, play); - if (Text_GetFaceReaction(play, 0x11) != 0) { - this->actor.textId = Text_GetFaceReaction(play, 0x11); + if (Text_GetFaceReaction(play, FACE_REACTION_SET_JIM) != 0) { + this->actor.textId = Text_GetFaceReaction(play, FACE_REACTION_SET_JIM); } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index 35e6d8437..bad5f5e0f 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -465,8 +465,8 @@ void EnCrow_Respawn(EnCrow* this, PlayState* play) { } void EnCrow_UpdateDamage(EnCrow* this, PlayState* play) { - if (this->collider.base.acFlags & AT_HIT) { - this->collider.base.acFlags &= ~AT_HIT; + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.elements->info); if (this->actor.colChkInfo.damageEffect == GUAY_DMGEFF_STUN) { diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 9b65ae2a6..5c3e33550 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -216,7 +216,7 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { s16 angleAdjustment; s16 targetAngle; - this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer << 9); + this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer * 0x200); EnElforg_ApproachTargetYPosition(this, homePos); xDifference = this->actor.world.pos.x - homePos->x; zDifference = this->actor.world.pos.z - homePos->z; @@ -245,7 +245,7 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { void EnElforg_MoveToTarget(EnElforg* this, Vec3f* targetPos) { s16 targetAngle; - this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer << 9); + this->actor.shape.yOffset += 100.0f * Math_SinS(this->timer * 0x200); EnElforg_ApproachTargetYPosition(this, targetPos); targetAngle = Math_Atan2S_XY(-(this->actor.world.pos.z - targetPos->z), -(this->actor.world.pos.x - targetPos->x)); @@ -273,7 +273,7 @@ void EnElforg_TrappedByBubble(EnElforg* this, PlayState* play) { EnElforg_InitializeParams(this); this->actionFunc = EnElforg_FreeFloating; } else { - this->actor.shape.yOffset += 10.0f * Math_SinS(this->timer << 9); + this->actor.shape.yOffset += 10.0f * Math_SinS(this->timer * 0x200); this->actor.world.pos = this->actor.parent->world.pos; this->actor.world.pos.y += 12.0f; } @@ -391,8 +391,8 @@ void EnElforg_CirclePlayer(EnElforg* this, PlayState* play) { distanceFromPlayer = 20.0f; } - this->actor.world.pos.x = (Math_SinS(this->timer << 12) * distanceFromPlayer) + playerActor->world.pos.x; - this->actor.world.pos.z = (Math_CosS(this->timer << 12) * distanceFromPlayer) + playerActor->world.pos.z; + this->actor.world.pos.x = (Math_SinS(this->timer * 0x1000) * distanceFromPlayer) + playerActor->world.pos.x; + this->actor.world.pos.z = (Math_CosS(this->timer * 0x1000) * distanceFromPlayer) + playerActor->world.pos.z; this->actor.world.pos.y = player->bodyPartsPos[PLAYER_BODYPART_WAIST].y; EnElforg_SpawnSparkles(this, play, 16); } diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 269866ff0..efccfb9d9 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -788,7 +788,7 @@ void EnFamos_Update(Actor* thisx, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->emblemCollider.base); } - if (this->collider2.base.atFlags & AC_ON) { + if (this->collider2.base.atFlags & AT_ON) { Collider_UpdateCylinder(&this->actor, &this->collider2); this->collider2.dim.pos.y = this->actor.floorHeight; CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index fd3b723d8..131b714d1 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -6,7 +6,6 @@ #include "z_en_firefly.h" #include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" -#include "objects/object_firefly/object_firefly.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000) @@ -134,8 +133,8 @@ void EnFirefly_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_Init(play, &this->skelAnime, &object_firefly_Skel_0018B8, &object_firefly_Anim_00017C, this->jointTable, - this->morphTable, 28); + SkelAnime_Init(play, &this->skelAnime, &gFireKeeseSkel, &gFireKeeseFlyAnim, this->jointTable, this->morphTable, + FIRE_KEESE_LIMB_MAX); Collider_InitAndSetSphere(play, &this->collider, &this->actor, &sSphereInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -340,7 +339,7 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { void EnFirefly_SetupFall(EnFirefly* this, PlayState* play) { this->timer = 40; this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, ANIMMODE_ONCE, 0.0f); + Animation_Change(&this->skelAnime, &gFireKeeseFlyAnim, 0.0f, 6.0f, 6.0f, ANIMMODE_ONCE, 0.0f); Actor_PlaySfx(&this->actor, NA_SE_EN_FFLY_DEAD); this->actor.flags |= ACTOR_FLAG_10; @@ -747,7 +746,7 @@ s32 EnFirefly_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 if (this->isInvisible && (play->actorCtx.lensMaskSize != LENS_MASK_ACTIVE_SIZE)) { *dList = NULL; - } else if (limbIndex == 1) { + } else if (limbIndex == FIRE_KEESE_LIMB_ROOT) { pos->y += 2300.0f; } return false; @@ -768,11 +767,11 @@ void EnFirefly_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* s32 pad; EnFirefly* this = THIS; - if ((this->currentType != KEESE_FIRE) && (limbIndex == 27)) { - gSPDisplayList((*gfx)++, object_firefly_DL_001678); + if ((this->currentType != KEESE_FIRE) && (limbIndex == FIRE_KEESE_LIMB_HEAD)) { + gSPDisplayList((*gfx)++, gKeeseRedEyesDL); } else if ((this->lastDrawnFrame != play->gameplayFrames) && ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && - ((limbIndex == 15) || (limbIndex == 21))) { + ((limbIndex == FIRE_KEESE_LIMB_LEFT_WING_END) || (limbIndex == FIRE_KEESE_LIMB_RIGHT_WING_END_ROOT))) { if (this->actionFunc != EnFirefly_Die) { Matrix_MultZero(&auraPos); auraPos.x += Rand_ZeroFloat(5.0f); @@ -781,7 +780,7 @@ void EnFirefly_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* auraScaleStep = -40; auraLife = 3; } else { - if (limbIndex == 15) { + if (limbIndex == FIRE_KEESE_LIMB_LEFT_WING_END) { auraPos.x = Math_SinS(9100 * this->timer) * this->timer + this->actor.world.pos.x; auraPos.z = Math_CosS(9100 * this->timer) * this->timer + this->actor.world.pos.z; } else { @@ -806,11 +805,11 @@ void EnFirefly_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* auraLife); } - if (limbIndex == 15) { + if (limbIndex == FIRE_KEESE_LIMB_LEFT_WING_END) { Matrix_MultZero(&this->limbPos[0]); - } else if (limbIndex == 21) { + } else if (limbIndex == FIRE_KEESE_LIMB_RIGHT_WING_END_ROOT) { Matrix_MultZero(&this->limbPos[1]); - } else if (limbIndex == 10) { + } else if (limbIndex == FIRE_KEESE_LIMB_BODY) { Matrix_MultZero(&this->limbPos[2]); } } diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index 6ac9fb008..429cec7c3 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -2,6 +2,7 @@ #define Z_EN_FIREFLY_H #include "global.h" +#include "objects/object_firefly/object_firefly.h" struct EnFirefly; @@ -27,8 +28,8 @@ typedef struct EnFirefly { /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; /* 0x192 */ s16 pitchTarget; - /* 0x194 */ Vec3s jointTable[28]; - /* 0x23C */ Vec3s morphTable[28]; + /* 0x194 */ Vec3s jointTable[FIRE_KEESE_LIMB_MAX]; + /* 0x23C */ Vec3s morphTable[FIRE_KEESE_LIMB_MAX]; /* 0x2E4 */ f32 maxAltitude; /* 0x2E8 */ f32 drawDmgEffAlpha; /* 0x2E8 */ f32 drawDmgEffScale; diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 71f980d47..00b54400d 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -401,7 +401,7 @@ void func_80932C98(EnFz* this, PlayState* play) { } if (this->unk_BCE != 0) { - if (ENFZ_GET_8000(&this->actor) && (this->collider1.base.atFlags & AC_HIT)) { + if (ENFZ_GET_8000(&this->actor) && (this->collider1.base.atFlags & AT_HIT)) { this->unk_BCD = 0; this->unk_BBC = 0.0f; this->collider1.base.acFlags &= ~AC_HIT; diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 1db4d7c5b..8697f5d74 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -534,8 +534,6 @@ void func_80B51510(EnGk* this, PlayState* play) { s32 pad; s32 cueChannel; - if (this) {} - if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_479)) { cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_479); @@ -577,6 +575,9 @@ void func_80B51510(EnGk* this, PlayState* play) { case 7: Flags_SetSwitch(play, ENGK_GET_3F00(&this->actor)); break; + + default: + break; } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_31A); } diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index 4294a8320..091525ce0 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -149,40 +149,41 @@ void func_80B22FA8(EnHanabiStruct* arg0, PlayState* play2) { gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); sp53 = 0xFF; - if (sp53) {} for (i = 0; i < 400; i++, arg0++) { - if (arg0->unk_00 == 1) { - Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&play->billboardMtxF); - if (arg0->unk_01 < 40) { - Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, - MTXMODE_APPLY); - } else { - Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); - } - Matrix_RotateZS(play->gameplayFrames * 4864, MTXMODE_APPLY); - - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (sp53 != arg0->unk_02) { - gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], - D_80B23C40[arg0->unk_02 + 2], 255); - - sp53 = arg0->unk_02; - } - - if (arg0->unk_01 < 6) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], - D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); - } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], - D_80B23C2C[arg0->unk_02 + 2], 255); - } - - gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); + if (arg0->unk_00 != 1) { + continue; } + + Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + if (arg0->unk_01 < 40) { + Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, + MTXMODE_APPLY); + } else { + Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); + } + Matrix_RotateZS(play->gameplayFrames * 4864, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (sp53 != arg0->unk_02) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], + D_80B23C40[arg0->unk_02 + 2], 255); + + sp53 = arg0->unk_02; + } + + if (arg0->unk_01 < 6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], 255); + } + + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } CLOSE_DISPS(gfxCtx); diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index 0217e8fa8..5079e1a57 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -315,7 +315,7 @@ void func_808DF088(EnHorseLinkChild* this, PlayState* play) { } else { phi_v0 = -1; } - sp32 += (phi_v0 << 0xE); + sp32 += (phi_v0 * 0x4000); } else { sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; } diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index fc8d3d201..70570ed96 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -621,7 +621,6 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) { this->unkCounter1A4 = 0; CutsceneManager_Stop(this->csIdList[0]); Actor_PlaySfx(&this->picto.actor, NA_SE_EN_YASE_DEAD); - if (this) {} this->unkState196 = 2; this->subCamId = SUB_CAM_ID_DONE; this->picto.actor.textId = 0x1647; @@ -944,7 +943,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) { if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.respawnFlag = -4; - SET_EVENTINF(EVENTINF_27); + SET_EVENTINF(EVENTINF_TRIGGER_DAYTELOP); } else { gSaveContext.save.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index ff7e4bb08..b0efd61e8 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -610,7 +610,7 @@ void EnKanban_Update(Actor* thisx, PlayState* play) { } } - Math_ApproachS(&this->actor.shape.rot.x, this->direction << 0xE, 1, 0x2000); + Math_ApproachS(&this->actor.shape.rot.x, this->direction * 0x4000, 1, 0x2000); } else { this->actor.shape.rot.y += this->spinVel.y; this->actor.shape.rot.x += this->direction * 0x7D0; diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index cfc3efdc0..fb7df013f 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -111,7 +111,7 @@ void func_80A5B160(EnKusa2* this, PlayState* play) { } for (i = 1; i < ARRAY_COUNT(this->unk_194); i++) { - temp_s1 = (i << 0xD) - 0x2000; + temp_s1 = (i * 0x2000) - 0x2000; if (this->unk_194[i] == NULL) { ptr = &this->unk_194[i]; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 4e9af5578..16e0acbe1 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -433,7 +433,7 @@ void EnMkk_Update(Actor* thisx, PlayState* play) { if (this->collider.base.atFlags & AT_ON) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if (this->collider.base.acFlags & AT_ON) { + if (this->collider.base.acFlags & AC_ON) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index bf3216fd5..f8673c307 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -80,7 +80,7 @@ void EnNutsball_Destroy(Actor* thisx, PlayState* play) { } void EnNutsball_InitColliderParams(EnNutsball* this) { - this->collider.base.atFlags &= ~AT_TYPE_ENEMY & ~AT_BOUNCED & ~AT_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_TYPE_ENEMY | AT_BOUNCED); this->collider.base.atFlags |= AT_TYPE_PLAYER; this->collider.info.toucher.dmgFlags = 0x400000; this->collider.info.toucher.damage = 2; diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 9d42424d9..9867cb963 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -536,7 +536,7 @@ void EnOsk_Draw(Actor* thisx, PlayState* play) { Matrix_Translate(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); - sp80.z = Math_SinS(play->gameplayFrames << 0xE); + sp80.z = Math_SinS(play->gameplayFrames * 0x4000); sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; Matrix_Scale(this->actor.scale.x * sp80.z, this->actor.scale.y * sp80.z, this->actor.scale.z * sp80.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 737161825..c08d9eee9 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1402,7 +1402,7 @@ void EnOssan_PartTimer_Init(EnOssan* this, PlayState* play) { u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play) { Player* player = GET_PLAYER(play); - u16 textId = Text_GetFaceReaction(play, 0x2F); + u16 textId = Text_GetFaceReaction(play, FACE_REACTION_SET_CURIOSITY_SHOP_MAN); if (textId != 0) { this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_START; @@ -1440,7 +1440,7 @@ u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, PlayState* play) { u16 EnOssan_PartTimer_GetWelcome(EnOssan* this, PlayState* play) { Player* player = GET_PLAYER(play); - u16 textId = Text_GetFaceReaction(play, 0x36); + u16 textId = Text_GetFaceReaction(play, FACE_REACTION_SET_PART_TIMER); if (textId != 0) { this->flags |= END_INTERACTION; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index df6d3708f..137829cf5 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -1146,21 +1146,22 @@ void func_80B5E1D8(PlayState* play, EnOtUnkStruct* arg1, s32 arg2) { POLY_OPA_DISP = Gfx_SetupDL66(POLY_OPA_DISP); for (i = 0; i < arg2; i++, arg1++) { - if (arg1->unk_00) { - if (!flag) { - gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000040); - flag = true; - if (play) {} - } - - Matrix_Translate(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); - Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); - - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000078); + if (arg1->unk_00 == 0) { + continue; } + + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000040); + flag = true; + } + + Matrix_Translate(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); + Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_ot_DL_000078); } CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index e5b4cabe3..c23fb3148 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -169,6 +169,9 @@ void EnOwl_Init(Actor* thisx, PlayState* play) { return; } break; + + default: + break; } this->unk_3DA = 0; @@ -335,6 +338,9 @@ void func_8095AD54(EnOwl* this, PlayState* play) { Message_ContinueTextbox(play, 0x7D3); this->actionFunc = func_8095ABF0; break; + + default: + break; } } } @@ -379,6 +385,9 @@ void func_8095AF2C(EnOwl* this, PlayState* play) { func_8095ACEC(this); this->actionFunc = func_8095ABF0; break; + + default: + break; } } @@ -625,6 +634,9 @@ void func_8095BA84(EnOwl* this, PlayState* play) { func_8019F230(); Message_ContinueTextbox(play, 0xBEF); break; + + default: + break; } break; @@ -633,14 +645,20 @@ void func_8095BA84(EnOwl* this, PlayState* play) { case 0: func_8019F208(); Message_ContinueTextbox(play, 0xBF4); - return; + break; case 1: func_8019F230(); Message_ContinueTextbox(play, 0xBF3); - return; + break; + + default: + break; } break; + + default: + break; } } break; @@ -703,9 +721,15 @@ void func_8095BA84(EnOwl* this, PlayState* play) { this->actionFlags |= 8; func_8095ACEC(this); break; + + default: + break; } } break; + + default: + break; } } @@ -897,168 +921,179 @@ void EnOwl_Update(Actor* thisx, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, UPDBGCHECKINFO_FLAG_4); Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - if (this->actor.update != NULL) { - if ((this->skelAnime1.animation == &object_owl_Anim_001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { - Actor_PlaySfx(&this->actor, NA_SE_EN_OWL_FLUTTER); + if (this->actor.update == NULL) { + return; + } + + if ((this->skelAnime1.animation == &object_owl_Anim_001ADC) && Animation_OnFrame(&this->skelAnime1, 4.0f)) { + Actor_PlaySfx(&this->actor, NA_SE_EN_OWL_FLUTTER); + } + + if (this->actionFlags & 2) { + this->eyeTexIndex = 2; + } else { + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); } - - if (this->actionFlags & 2) { - this->eyeTexIndex = 2; - } else { - if (DECR(this->blinkTimer) == 0) { - this->blinkTimer = Rand_S16Offset(60, 60); - } - this->eyeTexIndex = this->blinkTimer; - if (this->eyeTexIndex >= 3) { - this->eyeTexIndex = 0; - } + this->eyeTexIndex = this->blinkTimer; + if (this->eyeTexIndex >= 3) { + this->eyeTexIndex = 0; } + } - if (!(this->actionFlags & 8)) { - sp36 = 0; + if (!(this->actionFlags & 8)) { + sp36 = 0; - if (this->actionFlags & 0x10) { - switch (this->unk_408) { - case 0: - this->unk_408 = 1; - this->unk_409 = 6; - break; + if (this->actionFlags & 0x10) { + switch (this->unk_408) { + case 0: + this->unk_408 = 1; + this->unk_409 = 6; + break; - case 1: - this->unk_409--; - if (this->unk_409 != 0) { - sp36 = Math_CosS(this->unk_409 * 0x2000) * 0x1000; + case 1: + this->unk_409--; + if (this->unk_409 != 0) { + sp36 = Math_CosS(this->unk_409 * 0x2000) * 0x1000; + } else { + if (this->actionFlags & 2) { + this->unk_3DA = 0; } else { - if (this->actionFlags & 2) { - this->unk_3DA = 0; - } else { - this->unk_3DA = 0x20; - } - - if (this->actionFlags & 0x20) { - this->unk_3DA -= 4; - } else { - this->unk_3DA += 4; - } - this->unk_408++; + this->unk_3DA = 0x20; } if (this->actionFlags & 0x20) { - sp36 = -sp36; - } - break; - - case 2: - if (func_8095C510(this)) { - this->actionFlags &= ~0x10; - this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; - this->unk_408 = 0; - func_8095AB4C(this); - } - break; - } - } else { - if (this->unk_40A > 0) { - this->unk_40A--; - } else { - if (this->unk_408 == 0) { - if (Rand_ZeroOne() < 0.3f) { - this->unk_408 = 4; - this->unk_409 = 12; + this->unk_3DA -= 4; } else { - this->unk_408 = 1; - this->unk_409 = 4; + this->unk_3DA += 4; } - } - this->unk_409--; - - switch (this->unk_408) { - case 1: - sp36 = Math_SinS((-this->unk_409 * 0x1000) + 0x4000) * 5000.0f; - if (this->unk_409 <= 0) { - this->unk_409 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); - this->unk_408 = 2; - } - break; - - case 2: - sp36 = 0x1388; - if (this->unk_409 <= 0) { - this->unk_408 = 3; - this->unk_409 = 4; - } - break; - - case 3: - sp36 = Math_SinS(this->unk_409 * 0x1000) * 5000.0f; - if (this->unk_409 <= 0) { - this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; - this->unk_408 = 0; - func_8095AB4C(this); - } - break; - - case 4: - sp36 = Math_SinS(this->unk_409 * 0x2000) * 5000.0f; - if (this->unk_409 <= 0) { - this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; - this->unk_408 = 0; - func_8095AB4C(this); - } - break; + this->unk_408++; } if (this->actionFlags & 0x20) { sp36 = -sp36; } - } + break; - if (this->unk_40D > 0) { - this->unk_40D--; - } else { - this->unk_40C--; - switch (this->unk_40B) { - case 0: - this->unk_3DE = (-this->unk_40C * 0x5DC) + 0x1770; - if (this->unk_40C <= 0) { - this->unk_40B = 1; - this->unk_40C = (s8)(Rand_ZeroFloat(15.0f) + 5.0f); - } - break; + case 2: + if (func_8095C510(this)) { + this->actionFlags &= ~0x10; + this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; + this->unk_408 = 0; + func_8095AB4C(this); + } + break; - case 1: - this->unk_3DE = 0x1770; - if (this->unk_40C <= 0) { - this->unk_40B = 2; - this->unk_40C = 4; - } - break; - - case 2: - this->unk_3DE = this->unk_40C * 0x5DC; - if (this->unk_40C <= 0) { - this->unk_40B = 0; - this->unk_40C = 4; - this->unk_40D = (s32)Rand_ZeroFloat(40.0f) + 160; - } - break; + default: + break; + } + } else { + if (this->unk_40A > 0) { + this->unk_40A--; + } else { + if (this->unk_408 == 0) { + if (Rand_ZeroOne() < 0.3f) { + this->unk_408 = 4; + this->unk_409 = 12; + } else { + this->unk_408 = 1; + this->unk_409 = 4; } } + this->unk_409--; + + switch (this->unk_408) { + case 1: + sp36 = Math_SinS((-this->unk_409 * 0x1000) + 0x4000) * 5000.0f; + if (this->unk_409 <= 0) { + this->unk_409 = (s32)(Rand_ZeroFloat(15.0f) + 5.0f); + this->unk_408 = 2; + } + break; + + case 2: + sp36 = 0x1388; + if (this->unk_409 <= 0) { + this->unk_408 = 3; + this->unk_409 = 4; + } + break; + + case 3: + sp36 = Math_SinS(this->unk_409 * 0x1000) * 5000.0f; + if (this->unk_409 <= 0) { + this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; + this->unk_408 = 0; + func_8095AB4C(this); + } + break; + + case 4: + sp36 = Math_SinS(this->unk_409 * 0x2000) * 5000.0f; + if (this->unk_409 <= 0) { + this->unk_40A = (s32)Rand_ZeroFloat(20.0f) + 60; + this->unk_408 = 0; + func_8095AB4C(this); + } + break; + + default: + break; + } + + if (this->actionFlags & 0x20) { + sp36 = -sp36; + } } - if (sp36) {} - this->unk_3DC = (u16)((this->unk_3DA << 2) << 8) + sp36; - this->unk_3D8 = ABS(this->unk_3DC) >> 3; - } else { - this->unk_3DE = 0; - if (this->actionFlags & 2) { - this->unk_3DC = -0x8000; + if (this->unk_40D > 0) { + this->unk_40D--; } else { - this->unk_3DC = 0; - } + this->unk_40C--; + switch (this->unk_40B) { + case 0: + this->unk_3DE = (-this->unk_40C * 0x5DC) + 0x1770; + if (this->unk_40C <= 0) { + this->unk_40B = 1; + this->unk_40C = (s8)(Rand_ZeroFloat(15.0f) + 5.0f); + } + break; - this->unk_3D8 = ABS(this->unk_3DC) >> 3; + case 1: + this->unk_3DE = 0x1770; + if (this->unk_40C <= 0) { + this->unk_40B = 2; + this->unk_40C = 4; + } + break; + + case 2: + this->unk_3DE = this->unk_40C * 0x5DC; + if (this->unk_40C <= 0) { + this->unk_40B = 0; + this->unk_40C = 4; + this->unk_40D = (s32)Rand_ZeroFloat(40.0f) + 160; + } + break; + + default: + break; + } + } } + + if (sp36) {} + this->unk_3DC = (u16)((this->unk_3DA << 2) << 8) + sp36; + this->unk_3D8 = ABS(this->unk_3DC) >> 3; + } else { + this->unk_3DE = 0; + if (this->actionFlags & 2) { + this->unk_3DC = -0x8000; + } else { + this->unk_3DC = 0; + } + + this->unk_3D8 = ABS(this->unk_3DC) >> 3; } } @@ -1117,6 +1152,9 @@ s32 EnOwl_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p rot->y += (s16)(this->unk_3D8 * 1.5f); } break; + + default: + break; } return false; 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 d4e83a388..6b0dcd60a 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -628,13 +628,28 @@ s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { // 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 + // This is checking that the dog within the region defined by front and bottom lines like so: + // | + // X | Front + // | + // -------- + // Bottom frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); crossProductTemp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + //! @bug If any dog is precisely (with floating-point precision) on top of the line formed by the front points, + //! then frontPointsCrossProduct will be zero. This will cause this multiplication (and all future multiplications) + //! to be zero, which will make this function think the dog has crossed the finish line. The line formed by the + //! front points extends throughout the entire racetrack, so a dog can trigger this when they're not even close to + //! the actual finish line, causing them to finish the race incredibly early. if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } // crossProductTemp is positive if the dog is to the right of the line formed by the back points + // This is checking that the dog within the region defined by front and back lines like so: + // | | + // Back | X | Front + // | | frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); crossProductTemp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); if (frontPointsCrossProduct * crossProductTemp < 0.0f) { @@ -642,6 +657,12 @@ s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { } // crossProductTemp is positive if the dog is below the line formed by the top points + // This is checking that the dog within the region defined by front and top lines like so: + // Top + // -------- + // | + // X | Front + // | frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); crossProductTemp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); if (frontPointsCrossProduct * crossProductTemp < 0.0f) { diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.c b/src/overlays/actors/ovl_En_Slime/z_en_slime.c index 5e71d1a54..6675f6b45 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -1120,7 +1120,9 @@ void EnSlime_Update(Actor* thisx, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_ON) { Actor_MoveWithGravity(thisx); - Actor_UpdateBgCheckInfo(play, thisx, 20.0f, 35.0f, 40.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, thisx, 20.0f, 35.0f, 40.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | + UPDBGCHECKINFO_FLAG_10); } Collider_UpdateCylinder(thisx, &this->collider); diff --git a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c index 48a1cfea0..5823e728f 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c @@ -5,6 +5,7 @@ */ #include "z_en_snowwd.h" +#include "objects/object_snowwd/object_snowwd.h" #define FLAGS 0x00000000 @@ -17,7 +18,6 @@ void EnSnowwd_Draw(Actor* thisx, PlayState* play); void func_80AF76F0(EnSnowwd* this, PlayState* play); -#if 0 ActorInit En_Snowwd_InitVars = { ACTOR_EN_SNOWWD, ACTORCAT_PROP, @@ -30,25 +30,107 @@ ActorInit En_Snowwd_InitVars = { (ActorFunc)EnSnowwd_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AF7A90 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x0100020A, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x0100020A, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 60, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80AF7ABC = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80AF7A90; +Vec3f D_80AF7AC8 = { 0.0f, -4.0f, 0.0f }; -extern UNK_TYPE D_06001AA0; +Color_RGBA8 D_80AF7AD4 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowwd/EnSnowwd_Init.s") +Color_RGBA8 D_80AF7AD8 = { 200, 200, 220, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowwd/EnSnowwd_Destroy.s") +void EnSnowwd_Init(Actor* thisx, PlayState* play) { + EnSnowwd* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowwd/func_80AF76F0.s") + this->actor.home.rot.z = 0; + this->actor.home.rot.y = 0; + this->unk190 = 0; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 2000.0f; + this->actor.uncullZoneDownward = 2400.0f; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = func_80AF76F0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowwd/EnSnowwd_Update.s") +void EnSnowwd_Destroy(Actor* thisx, PlayState* play) { + EnSnowwd* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowwd/EnSnowwd_Draw.s") + Collider_DestroyCylinder(play, &this->collider); +} + +void func_80AF76F0(EnSnowwd* this, PlayState* play) { + s32 pad; + Actor* thisx = &this->actor; + f32 sp54; + Vec3f sp48; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfx(thisx, NA_SE_IT_REFLECTION_WOOD); + } + if (thisx->home.rot.y != 0) { + this->unk190 = 0x15; + thisx->home.rot.y = 0; + if (thisx->home.rot.z == 0) { + if (SNOWWD_GET_PARAM_F80(&this->actor) < 0x10) { + sp48 = thisx->world.pos; + sp48.y += 200.0f; + Item_DropCollectibleRandom(play, NULL, &sp48, SNOWWD_GET_PARAM_F80(&this->actor) * 0x10); + } + thisx->home.rot.z = 1; + } + } + if (thisx->xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(thisx, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + if (this->unk190 > 0) { + this->unk190--; + sp54 = Math_SinS((s16)((this->unk190 ^ 0xFFFF) * 0x3332)) * 250.0f; + thisx->shape.rot.x = (s16)(Math_CosS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * sp54); + thisx->shape.rot.z = (s16)(Math_SinS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * sp54); + sp48 = thisx->world.pos; + sp48.x += Rand_CenteredFloat(80.0f); + sp48.y += 100.0f + Rand_ZeroFloat(30.0f); + sp48.z += Rand_CenteredFloat(80.0f); + func_800B0EB0(play, &sp48, &D_80AF7AC8, &D_80AF7ABC, &D_80AF7AD4, &D_80AF7AD8, 200, 10, 20); + } +} + +void EnSnowwd_Update(Actor* thisx, PlayState* play) { + EnSnowwd* this = THIS; + + this->actionFunc(this, play); +} + +void EnSnowwd_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Gfx_SetupDL25_Opa(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gSnowTreeSnowLeavesTex)); + gSPDisplayList(POLY_OPA_DISP++, gSnowTreeDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h index a83e5d05a..d336cb252 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h @@ -3,13 +3,16 @@ #include "global.h" +#define SNOWWD_GET_PARAM_F80(thisx) (((thisx)->params & 0xF80) >> 7) + struct EnSnowwd; typedef void (*EnSnowwdActionFunc)(struct EnSnowwd*, PlayState*); typedef struct EnSnowwd { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x50]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ s16 unk190; /* 0x194 */ EnSnowwdActionFunc actionFunc; } EnSnowwd; // size = 0x198 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 ca15e4864..2f32734a4 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -358,7 +358,6 @@ s32 func_808D9440(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posResult, C return ret; } -#ifdef NON_MATCHING void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { CollisionPoly* spA4; CollisionPoly* spA0; @@ -412,7 +411,6 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { for (i = 0; i < 3; i++) { if (i == 0) { - if (this && this && this) {} sp84.x = sp90.x - (this->unk_350.x * temp_f20); sp84.y = sp90.y - (this->unk_350.y * temp_f20); sp84.z = sp90.z - (this->unk_350.z * temp_f20); @@ -433,6 +431,9 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { break; } } + + //! FAKE + if (i == 3) {} } func_808D93BC(this); @@ -448,10 +449,6 @@ void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4) { Actor_MoveWithoutGravity(&this->actor); } } -#else -void func_808D94D0(EnSw* this, PlayState* play, s32 arg2, s32 arg3, s16 arg4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") -#endif void func_808D9894(EnSw* this, Vec3f* vec) { Vec3f sp5C; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 0f3c8ecde..8ea2c8d22 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -10,6 +10,7 @@ #include "z_en_syateki_man.h" #include "overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h" #include "overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h" +#include "overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h" #include "overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_CANT_LOCK_ON) @@ -49,15 +50,10 @@ void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play); #define TALK_FLAG_SWAMP_HAS_SPOKEN_WITH_HUMAN (1 << 0) #define TALK_FLAG_SWAMP_HAS_EXPLAINED_THE_RULES (1 << 1) -#define OCTOROK_FLAG(color, row, column) (1 << ((row * 6) + (column * 2) + color)) -#define COLOR_RED 0 -#define COLOR_BLUE 1 -#define ROW_BACK 0 -#define ROW_CENTER 1 -#define ROW_FRONT 2 -#define COLUMN_LEFT 0 -#define COLUMN_CENTER 1 -#define COLUMN_RIGHT 2 +#define OCTO_FLAGS(type0, type1, type2, type3, type4, type5, type6, type7, type8) \ + (SG_OCTO_SET_FLAG(type0, 0) | SG_OCTO_SET_FLAG(type1, 1) | SG_OCTO_SET_FLAG(type2, 2) | \ + SG_OCTO_SET_FLAG(type3, 3) | SG_OCTO_SET_FLAG(type4, 4) | SG_OCTO_SET_FLAG(type5, 5) | \ + SG_OCTO_SET_FLAG(type6, 6) | SG_OCTO_SET_FLAG(type7, 7) | SG_OCTO_SET_FLAG(type8, 8)) ActorInit En_Syateki_Man_InitVars = { ACTOR_EN_SYATEKI_MAN, @@ -201,7 +197,7 @@ void EnSyatekiMan_Init(Actor* thisx, PlayState* play) { this->shootingGameState = SG_GAME_STATE_NONE; this->talkWaitTimer = 15; this->flagsIndex = 0; - this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; + this->perGameVar2.lastHitOctorokType = SG_OCTO_TYPE_NONE; this->octorokFlags = 0; this->dekuScrubFlags = 0; this->guayFlags = 0; @@ -270,7 +266,7 @@ void EnSyatekiMan_Swamp_Idle(EnSyatekiMan* this, PlayState* play) { u16 faceReactionTextId; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_MAN_ANIM_SWAMP_HEAD_SCRATCH_END); - faceReactionTextId = Text_GetFaceReaction(play, 0x31); + faceReactionTextId = Text_GetFaceReaction(play, FACE_REACTION_SET_SWAMP_SHOOTING_GALLERY_MAN); if (faceReactionTextId != 0) { Message_StartTextbox(play, faceReactionTextId, &this->actor); this->prevTextId = faceReactionTextId; @@ -596,7 +592,7 @@ void EnSyatekiMan_Town_StartIntroTextbox(EnSyatekiMan* this, PlayState* play) { void EnSyatekiMan_Town_Idle(EnSyatekiMan* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - u16 faceReactionTextId = Text_GetFaceReaction(play, 0x30); + u16 faceReactionTextId = Text_GetFaceReaction(play, FACE_REACTION_SET_TOWN_SHOOTING_GALLERY_MAN); if (faceReactionTextId != 0) { Message_StartTextbox(play, faceReactionTextId, &this->actor); @@ -1227,7 +1223,7 @@ void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play) { this->score = 0; this->flagsIndex = 0; this->perGameVar1.octorokState = SG_OCTO_STATE_INITIAL; - this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; + this->perGameVar2.lastHitOctorokType = SG_OCTO_TYPE_NONE; sGameStartTimer = 30; Interface_StartTimer(TIMER_ID_MINIGAME_1, 75); this->actor.draw = NULL; @@ -1240,62 +1236,67 @@ void EnSyatekiMan_Town_StartGame(EnSyatekiMan* this, PlayState* play) { * For each wave, these flags are used to control which Octoroks appear. */ static const s32 sOctorokFlagsPerWave[] = { - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + // clang-format off + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE), - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT), + OCTO_FLAGS(SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED), - OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER), + OCTO_FLAGS(SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT), + OCTO_FLAGS(SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED), - OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_BLUE), - OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER), + OCTO_FLAGS(SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED), - OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_CENTER, COLUMN_LEFT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_BLUE), - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_BLUE, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_BLUE, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_NONE), - OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_BLUE, ROW_FRONT, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_LEFT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_BLUE, SG_OCTO_TYPE_BLUE), - OCTOROK_FLAG(COLOR_RED, ROW_FRONT, COLUMN_CENTER) | OCTOROK_FLAG(COLOR_RED, ROW_CENTER, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_RIGHT) | OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_CENTER) | - OCTOROK_FLAG(COLOR_RED, ROW_BACK, COLUMN_LEFT), + OCTO_FLAGS(SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_RED, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE, + SG_OCTO_TYPE_NONE, SG_OCTO_TYPE_RED, SG_OCTO_TYPE_NONE), + // clang-format on }; void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { @@ -1323,16 +1324,16 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; } - if (this->perGameVar2.octorokHitType != SG_OCTO_HIT_TYPE_NONE) { - if (this->perGameVar2.octorokHitType == SG_OCTO_HIT_TYPE_BLUE) { + if (this->perGameVar2.lastHitOctorokType != SG_OCTO_TYPE_NONE) { + if (this->perGameVar2.lastHitOctorokType == SG_OCTO_TYPE_BLUE) { gSaveContext.timerTimeLimits[TIMER_ID_MINIGAME_1] -= SECONDS_TO_TIMER_PRECISE(2, 50); sModFromLosingTime = (sModFromLosingTime + 25) % 50; } - this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; + this->perGameVar2.lastHitOctorokType = SG_OCTO_TYPE_NONE; } - if (this->perGameVar1.octorokState == SG_OCTO_STATE_SPAWNING) { + if (this->perGameVar1.octorokState == SG_OCTO_STATE_APPEARING) { this->perGameVar1.octorokState++; } @@ -1340,10 +1341,10 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) { // that the player might have lost time from hitting Blue Octoroks, so we do something similar to // what was done with waveTimer above. if ((sModFromLosingTime == (timer % 50)) && (this->perGameVar1.octorokState >= SG_OCTO_STATE_INITIAL)) { - if (this->flagsIndex < 15) { + if (this->flagsIndex < ARRAY_COUNT(sOctorokFlagsPerWave)) { this->octorokFlags = sOctorokFlagsPerWave[this->flagsIndex++]; Actor_PlaySfx(&this->actor, NA_SE_SY_FOUND); - this->perGameVar1.octorokState = SG_OCTO_STATE_SPAWNING; + this->perGameVar1.octorokState = SG_OCTO_STATE_APPEARING; } } diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h index 468cb981c..28d19871b 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h @@ -22,18 +22,12 @@ typedef enum { } ShootingGalleryGameState; typedef enum { - /* 0 */ SG_OCTO_STATE_SPAWNING, - /* 1 */ SG_OCTO_STATE_SPAWNED, + /* 0 */ SG_OCTO_STATE_APPEARING, + /* 1 */ SG_OCTO_STATE_APPEARED, /* 70 */ SG_OCTO_STATE_INITIAL = 70, /* 80 */ SG_OCTO_STATE_HIDING = 80 } ShootingGalleryOctorokState; -typedef enum { - /* 0 */ SG_OCTO_HIT_TYPE_NONE, - /* 1 */ SG_OCTO_HIT_TYPE_RED, - /* 2 */ SG_OCTO_HIT_TYPE_BLUE -} ShootingGalleryoctorokHitType; - typedef enum { /* 0 */ SG_PATH_TYPE_CROW, /* 1 */ SG_PATH_TYPE_SCRUB_NORMAL, @@ -62,7 +56,7 @@ typedef struct EnSyatekiMan { } perGameVar1; /* 0x26E */ union { s16 bonusDekuScrubHitCounter; - s16 octorokHitType; + s16 lastHitOctorokType; } perGameVar2; /* 0x270 */ s16 talkWaitTimer; /* 0x272 */ s16 dekuScrubFlags; diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 5711b86fe..5673439cf 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -16,17 +16,17 @@ void EnSyatekiOkuta_Destroy(Actor* thisx, PlayState* play); void EnSyatekiOkuta_Update(Actor* thisx, PlayState* play); void EnSyatekiOkuta_Draw(Actor* thisx, PlayState* play); -void func_80A36260(EnSyatekiOkuta* this); -void func_80A362A8(EnSyatekiOkuta* this, PlayState* play); -void func_80A362F8(EnSyatekiOkuta* this); -void func_80A36350(EnSyatekiOkuta* this, PlayState* play); -void func_80A363B4(EnSyatekiOkuta* this, PlayState* play); -void func_80A36444(EnSyatekiOkuta* this); -void func_80A36488(EnSyatekiOkuta* this, PlayState* play); -void func_80A364C0(EnSyatekiOkuta* this); -void func_80A36504(EnSyatekiOkuta* this, PlayState* play); -void func_80A365EC(EnSyatekiOkuta* this, PlayState* play); -void func_80A36CB0(EnSyatekiOkuta* this); +void EnSyatekiOkuta_SetupAttachToShootingGalleryMan(EnSyatekiOkuta* this); +void EnSyatekiOkuta_AttachToShootingGalleryMan(EnSyatekiOkuta* this, PlayState* play); +void EnSyatekiOkuta_SetupDoNothing(EnSyatekiOkuta* this); +void EnSyatekiOkuta_DoNothing(EnSyatekiOkuta* this, PlayState* play); +void EnSyatekiOkuta_Appear(EnSyatekiOkuta* this, PlayState* play); +void EnSyatekiOkuta_SetupFloat(EnSyatekiOkuta* this); +void EnSyatekiOkuta_Float(EnSyatekiOkuta* this, PlayState* play); +void EnSyatekiOkuta_SetupHide(EnSyatekiOkuta* this); +void EnSyatekiOkuta_Hide(EnSyatekiOkuta* this, PlayState* play); +void EnSyatekiOkuta_Die(EnSyatekiOkuta* this, PlayState* play); +void EnSyatekiOkuta_UpdateHeadScale(EnSyatekiOkuta* this); ActorInit En_Syateki_Okuta_InitVars = { ACTOR_EN_SYATEKI_OKUTA, @@ -60,13 +60,23 @@ static ColliderCylinderInit sCylinderInit = { { 20, 40, -30, { 0, 0, 0 } }, }; +typedef enum { + /* 0 */ SG_OCTO_ANIM_SHOOT, // unused + /* 1 */ SG_OCTO_ANIM_DIE, + /* 2 */ SG_OCTO_ANIM_HIDE, + /* 3 */ SG_OCTO_ANIM_FLOAT, + /* 4 */ SG_OCTO_ANIM_APPEAR, + /* 5 */ SG_OCTO_ANIM_HIT, // unused + /* 6 */ SG_OCTO_ANIM_MAX +} ShootingGalleryOctorokAnimation; + static AnimationInfo sAnimationInfo[] = { - { &gOctorokShootAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &gOctorokDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &gOctorokHideAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &gOctorokFloatAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &gOctorokAppearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &gOctorokHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokShootAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, // SG_OCTO_ANIM_SHOOT + { &gOctorokDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, // SG_OCTO_ANIM_DIE + { &gOctorokHideAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, // SG_OCTO_ANIM_HIDE + { &gOctorokFloatAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, // SG_OCTO_ANIM_FLOAT + { &gOctorokAppearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, // SG_OCTO_ANIM_APPEAR + { &gOctorokHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, // SG_OCTO_ANIM_HIT }; #include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" @@ -76,16 +86,6 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; -Color_RGBA8 D_80A37B90 = { 255, 255, 255, 255 }; - -Color_RGBA8 D_80A37B94 = { 150, 150, 150, 255 }; - -Vec3f D_80A37B98 = { 0.0f, -0.5, 0.0f }; - -Color_RGBA8 D_80A37BA4 = { 255, 255, 255, 255 }; - -Color_RGBA8 D_80A37BA8 = { 150, 150, 150, 0 }; - void EnSyatekiOkuta_Init(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiOkuta* this = THIS; @@ -110,9 +110,9 @@ void EnSyatekiOkuta_Init(Actor* thisx, PlayState* play) { this->actor.world.pos.y = this->actor.home.pos.y = ySurface; } - this->unk_2A4 = 0; - this->unk_2AA = 0; - func_80A36260(this); + this->deathTimer = 0; + this->hitResultAlpha = 0; + EnSyatekiOkuta_SetupAttachToShootingGalleryMan(this); } void EnSyatekiOkuta_Destroy(Actor* thisx, PlayState* play) { @@ -121,30 +121,45 @@ void EnSyatekiOkuta_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, PlayState* play) { - func_800B0DE0(play, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); +/** + * Spawns the puff of smoke that appears when the Octorok disappears when it dies. + */ +void EnSyatekiOkuta_SpawnDust(Vec3f* pos, Vec3f* velocity, s16 scaleStep, PlayState* play) { + static Color_RGBA8 sDustPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sDustEnvColor = { 150, 150, 150, 255 }; + + func_800B0DE0(play, pos, velocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 400, scaleStep); } -void func_80A361B0(EnSyatekiOkuta* this, PlayState* play) { +/** + * Spawns the splash that appears when the Octorok appears from underwater, hides underwater, or dies. + */ +void EnSyatekiOkuta_SpawnSplash(EnSyatekiOkuta* this, PlayState* play) { EffectSsGSplash_Spawn(play, &this->actor.home.pos, NULL, NULL, 0, 800); } -s32 func_80A361F4(EnSyatekiOkuta* this) { - s32 temp_a0; - s32 temp_a1; - s32 temp_v1; +/* + * Returns true if this Octorok is hidden (in other words, if it's in the center + * column and has another Octorok in front of it), false otherwise. + */ +s32 EnSyatekiOkuta_IsHiddenByAnotherOctorok(EnSyatekiOkuta* this) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 index = SG_OCTO_GET_INDEX(&this->actor); - temp_v1 = EN_SYATEKI_OKUTA_GET_F(&this->actor); - if ((temp_v1 == 1) || (temp_v1 == 4)) { - temp_a0 = syatekiMan->octorokFlags; - temp_a1 = (temp_v1 * 2) + 6; - - if ((temp_a0 >> temp_a1) & 3) { + // Only the Octoroks in the center column can be obscured by another Octorok. The Octoroks in the + // left and right columns are always visible, since the player looks at them from an angle. + // Additionally, the Octorok in the front row is always visible, even if it's in the center column. + if ((index == SG_OCTO_INDEX_FOR_POS(SG_OCTO_ROW_BACK, SG_OCTO_COL_CENTER)) || + (index == SG_OCTO_INDEX_FOR_POS(SG_OCTO_ROW_CENTER, SG_OCTO_COL_CENTER))) { + // Checks to see if this Octorok is hidden by an Octorok immediately in front of it. + if (SG_OCTO_GET_TYPE(syatekiMan->octorokFlags, SG_OCTO_INDEX_DIRECTLY_IN_FRONT(index)) != SG_OCTO_TYPE_NONE) { return true; } - if ((temp_a1 == 8) && ((temp_a0 >> 0xE) & 3)) { + // If this Octorok is in the back row, it can also be hidden by an Octorok in the front row. + if ((index == SG_OCTO_INDEX_FOR_POS(SG_OCTO_ROW_BACK, SG_OCTO_COL_CENTER)) && + (SG_OCTO_GET_TYPE(syatekiMan->octorokFlags, SG_OCTO_INDEX_FOR_POS(SG_OCTO_ROW_FRONT, SG_OCTO_COL_CENTER)) != + SG_OCTO_TYPE_NONE)) { return true; } } @@ -152,142 +167,177 @@ s32 func_80A361F4(EnSyatekiOkuta* this) { return false; } -void func_80A36260(EnSyatekiOkuta* this) { +void EnSyatekiOkuta_SetupAttachToShootingGalleryMan(EnSyatekiOkuta* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); this->actor.draw = NULL; - this->actionFunc = func_80A362A8; + this->actionFunc = EnSyatekiOkuta_AttachToShootingGalleryMan; } -void func_80A362A8(EnSyatekiOkuta* this, PlayState* play) { +/** + * Checks every NPC actor in the scene to find the Shooting Gallery Man. Once it finds him, this will + * make him the parent to the Octorok. This is required because the Octoroks are normally spawned as + * part of the Town Shooting Gallery scene, so they don't have anything that links them to the Shooting + * Gallery Man, and the Octoroks need a pointer to him in order to access his Octorok flags. If this + * actor is spawned in a scene *without* the Shooting Gallery Man, its action function will never change + * from this function, and the Octorok will effectively do nothing. + */ +void EnSyatekiOkuta_AttachToShootingGalleryMan(EnSyatekiOkuta* this, PlayState* play) { Actor* actorIt = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (actorIt != NULL) { if (actorIt->id == ACTOR_EN_SYATEKI_MAN) { this->actor.parent = actorIt; - func_80A362F8(this); + EnSyatekiOkuta_SetupDoNothing(this); break; - } else { - actorIt = actorIt->next; } + + actorIt = actorIt->next; } } -void func_80A362F8(EnSyatekiOkuta* this) { +/** + * Stops the Octorok's animation, prevents it from drawing, and sets its action function to do nothing. + * The intention here is to stay in this action function doing nothing until the Shooting Gallery Man + * tells it to appear in EnSyatekiOkuta_CheckForSignal, at which point the action function will be changed. + */ +void EnSyatekiOkuta_SetupDoNothing(EnSyatekiOkuta* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); this->actor.draw = NULL; Actor_SetScale(&this->actor, 0.01f); - this->actionFunc = func_80A36350; + this->actionFunc = EnSyatekiOkuta_DoNothing; } -void func_80A36350(EnSyatekiOkuta* this, PlayState* play) { +void EnSyatekiOkuta_DoNothing(EnSyatekiOkuta* this, PlayState* play) { } -void func_80A36360(EnSyatekiOkuta* this) { +void EnSyatekiOkuta_SetupAppear(EnSyatekiOkuta* this) { this->actor.draw = EnSyatekiOkuta_Draw; - this->unk_2AA = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); - this->actionFunc = func_80A363B4; + this->hitResultAlpha = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, SG_OCTO_ANIM_APPEAR); + this->actionFunc = EnSyatekiOkuta_Appear; } -void func_80A363B4(EnSyatekiOkuta* this, PlayState* play) { +/** + * Jumps out of the water and starts floating. + */ +void EnSyatekiOkuta_Appear(EnSyatekiOkuta* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - if (func_80A361F4(this)) { + if (EnSyatekiOkuta_IsHiddenByAnotherOctorok(this)) { return; } - func_80A361B0(this, play); + + EnSyatekiOkuta_SpawnSplash(this, play); Actor_PlaySfx(&this->actor, NA_SE_EN_OCTAROCK_JUMP); } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A36444(this); + EnSyatekiOkuta_SetupFloat(this); } } -void func_80A36444(EnSyatekiOkuta* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); - this->actionFunc = func_80A36488; +void EnSyatekiOkuta_SetupFloat(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, SG_OCTO_ANIM_FLOAT); + this->actionFunc = EnSyatekiOkuta_Float; } -void func_80A36488(EnSyatekiOkuta* this, PlayState* play) { +/** + * Floats in place until the Shooting Gallery Man tells it to hide. + */ +void EnSyatekiOkuta_Float(EnSyatekiOkuta* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + // In practice, if the Octorok is floating, then the octorokState is either SG_OCTO_STATE_APPEARED or + // SG_OCTO_STATE_HIDING. Only the latter state is greater than SG_OCTO_STATE_INITIAL, so that's what + // this check is looking for. if (syatekiMan->perGameVar1.octorokState >= SG_OCTO_STATE_INITIAL) { - func_80A364C0(this); + EnSyatekiOkuta_SetupHide(this); } } -void func_80A364C0(EnSyatekiOkuta* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); - this->actionFunc = func_80A36504; +void EnSyatekiOkuta_SetupHide(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, SG_OCTO_ANIM_HIDE); + this->actionFunc = EnSyatekiOkuta_Hide; } -void func_80A36504(EnSyatekiOkuta* this, PlayState* play) { +/** + * Retreats underwater, then makes the Octorok do nothing until the Shooting Gallery Man tells it to appear again. + */ +void EnSyatekiOkuta_Hide(EnSyatekiOkuta* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 4.0f)) { - func_80A361B0(this, play); + EnSyatekiOkuta_SpawnSplash(this, play); Actor_PlaySfx(&this->actor, NA_SE_EN_DAIOCTA_LAND); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A362F8(this); + EnSyatekiOkuta_SetupDoNothing(this); } } -void func_80A3657C(EnSyatekiOkuta* this) { - this->unk_2A4 = 0; - this->unk_2AA = 300; - if (this->unk_2A6 == 1) { +void EnSyatekiOkuta_SetupDie(EnSyatekiOkuta* this) { + this->deathTimer = 0; + this->hitResultAlpha = 300; + if (this->type == SG_OCTO_TYPE_RED) { Actor_PlaySfx(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); - this->actionFunc = func_80A365EC; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, SG_OCTO_ANIM_DIE); + this->actionFunc = EnSyatekiOkuta_Die; } -void func_80A365EC(EnSyatekiOkuta* this, PlayState* play) { - Vec3f sp84; - Vec3f sp78; +/** + * Plays the death animation and slowly shrinks the Octorok. Also spawns various bubble and dust + * effects as it dies. Once the Octorok is finished with its death animation, this function will + * make it do nothing until the Shooting Gallery Man tells it to appear again. + */ +void EnSyatekiOkuta_Die(EnSyatekiOkuta* this, PlayState* play) { + static Vec3f sBubbleAccel = { 0.0f, -0.5, 0.0f }; + static Color_RGBA8 sBubblePrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sBubbleEnvColor = { 150, 150, 150, 0 }; + Vec3f velocity; + Vec3f pos; s32 pad; s32 i; - if (this->unk_2AA > 0) { - this->unk_2AA -= 15; + if (this->hitResultAlpha > 0) { + this->hitResultAlpha -= 15; } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->unk_2A4 == 0) { - sp78.x = this->actor.world.pos.x; - sp78.y = this->actor.world.pos.y + 40.0f; - sp78.z = this->actor.world.pos.z; - sp84.x = 0.0f; - sp84.y = -0.5f; - sp84.z = 0.0f; - func_80A36148(&sp78, &sp84, -20, play); + if (this->deathTimer == 0) { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 40.0f; + pos.z = this->actor.world.pos.z; + velocity.x = 0.0f; + velocity.y = -0.5f; + velocity.z = 0.0f; + EnSyatekiOkuta_SpawnDust(&pos, &velocity, -20, play); Actor_PlaySfx(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); } - this->unk_2A4++; + this->deathTimer++; } if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - func_80A361B0(this, play); + EnSyatekiOkuta_SpawnSplash(this, play); } - if (this->unk_2A4 < 3) { - Actor_SetScale(&this->actor, ((this->unk_2A4 * 0.25f) + 1.0f) * 0.01f); - } else if (this->unk_2A4 < 6) { - Actor_SetScale(&this->actor, (1.5f - ((this->unk_2A4 - 2) * 0.2333f)) * 0.01f); - } else if (this->unk_2A4 < 11) { - Actor_SetScale(&this->actor, (((this->unk_2A4 - 5) * 0.04f) + 0.8f) * 0.01f); + if (this->deathTimer < 3) { + Actor_SetScale(&this->actor, ((this->deathTimer * 0.25f) + 1.0f) * 0.01f); + } else if (this->deathTimer < 6) { + Actor_SetScale(&this->actor, (1.5f - ((this->deathTimer - 2) * 0.2333f)) * 0.01f); + } else if (this->deathTimer < 11) { + Actor_SetScale(&this->actor, (((this->deathTimer - 5) * 0.04f) + 0.8f) * 0.01f); } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.002f)) { SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_COMMON_WATER_MID); for (i = 0; i < 10; i++) { - sp84.x = (Rand_ZeroOne() - 0.5f) * 7.0f; - sp84.y = Rand_ZeroOne() * 7.0f; - sp84.z = (Rand_ZeroOne() - 0.5f) * 7.0f; - EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, - &D_80A37BA8, Rand_S16Offset(100, 50), 25, false); + velocity.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + velocity.y = Rand_ZeroOne() * 7.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &velocity, &sBubbleAccel, + &sBubblePrimColor, &sBubbleEnvColor, Rand_S16Offset(100, 50), 25, + false); } - func_80A362F8(this); + EnSyatekiOkuta_SetupDoNothing(this); } this->actor.scale.y = this->actor.scale.x; @@ -295,13 +345,17 @@ void func_80A365EC(EnSyatekiOkuta* this, PlayState* play) { } } -void func_80A368E0(EnSyatekiOkuta* this, PlayState* play) { +/** + * Adjusts the collider's dimensions and position based on a few different factors, like the Octorok's + * type, current scale and head scale, and current action. + */ +void EnSyatekiOkuta_UpdateCollision(EnSyatekiOkuta* this, PlayState* play) { this->collider.dim.height = - (sCylinderInit.dim.height - this->collider.dim.yShift) * this->unk_1D8.y * this->actor.scale.y * 100.0f; + (sCylinderInit.dim.height - this->collider.dim.yShift) * this->headScale.y * this->actor.scale.y * 100.0f; this->collider.dim.radius = sCylinderInit.dim.radius * this->actor.scale.x * 100.0f; - if (this->actionFunc == func_80A363B4) { - if ((this->unk_2A6 == 2) && func_80A361F4(this)) { + if (this->actionFunc == EnSyatekiOkuta_Appear) { + if ((this->type == SG_OCTO_TYPE_BLUE) && EnSyatekiOkuta_IsHiddenByAnotherOctorok(this)) { return; } @@ -310,7 +364,7 @@ void func_80A368E0(EnSyatekiOkuta* this, PlayState* play) { } } - if (this->unk_2A6 == 1) { + if (this->type == SG_OCTO_TYPE_RED) { this->collider.dim.radius += 10; this->collider.dim.height += 15; } @@ -322,8 +376,11 @@ void func_80A368E0(EnSyatekiOkuta* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80A36A90(EnSyatekiOkuta* this, PlayState* play) { - if ((this->actionFunc == func_80A365EC) || (this->actionFunc == func_80A36350)) { +/** + * Returns true if the Octorok has been hit, false otherwise. + */ +s32 EnSyatekiOkuta_CheckCollision(EnSyatekiOkuta* this, PlayState* play) { + if ((this->actionFunc == EnSyatekiOkuta_Die) || (this->actionFunc == EnSyatekiOkuta_DoNothing)) { return false; } @@ -332,22 +389,28 @@ s32 func_80A36A90(EnSyatekiOkuta* this, PlayState* play) { return true; } - func_80A368E0(this, play); + EnSyatekiOkuta_UpdateCollision(this, play); return false; } -void func_80A36AF8(EnSyatekiOkuta* this, PlayState* play) { +/** + * Checks to see if both the archery game and this Octorok are in the appropriate state to consider + * appearing. If the conditions are right, then the Shooting Gallery Man's Octorok flags determine + * what type this Octorok should be for the current wave; if the type is *not* SG_OCTO_TYPE_NONE, + * then this Octorok will set itself to the appropriate type and get ready to jump out of the water. + */ +void EnSyatekiOkuta_CheckForSignal(EnSyatekiOkuta* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - s16 temp_v1_2; + s16 type; - if ((this->actionFunc != func_80A36488) && (this->actionFunc != func_80A363B4) && + if ((this->actionFunc != EnSyatekiOkuta_Float) && (this->actionFunc != EnSyatekiOkuta_Appear) && (syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && - (syatekiMan->perGameVar1.octorokState == SG_OCTO_STATE_SPAWNING)) { - temp_v1_2 = (syatekiMan->octorokFlags >> (EN_SYATEKI_OKUTA_GET_F(&this->actor) * 2)) & 3; - if (temp_v1_2 > 0) { + (syatekiMan->perGameVar1.octorokState == SG_OCTO_STATE_APPEARING)) { + type = SG_OCTO_GET_TYPE(syatekiMan->octorokFlags, SG_OCTO_GET_INDEX(&this->actor)); + if (type > SG_OCTO_TYPE_NONE) { Actor_SetScale(&this->actor, 0.01f); - this->unk_2A6 = temp_v1_2; - func_80A36360(this); + this->type = type; + EnSyatekiOkuta_SetupAppear(this); } } } @@ -359,101 +422,108 @@ void EnSyatekiOkuta_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); - if (this->actionFunc != func_80A36350) { + if (this->actionFunc != EnSyatekiOkuta_DoNothing) { SkelAnime_Update(&this->skelAnime); } - func_80A36AF8(this, play); + EnSyatekiOkuta_CheckForSignal(this, play); - if (func_80A36A90(this, play)) { + if (EnSyatekiOkuta_CheckCollision(this, play)) { syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (this->unk_2A6 == 1) { + if (this->type == SG_OCTO_TYPE_RED) { Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); play->interfaceCtx.minigamePoints++; syatekiMan->score++; - syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_RED; + syatekiMan->perGameVar2.lastHitOctorokType = SG_OCTO_TYPE_RED; } else { Actor_PlaySfx(&this->actor, NA_SE_SY_ERROR); - syatekiMan->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_BLUE; + syatekiMan->perGameVar2.lastHitOctorokType = SG_OCTO_TYPE_BLUE; } - func_80A3657C(this); + EnSyatekiOkuta_SetupDie(this); } else { this->collider.base.acFlags &= ~AC_HIT; } - func_80A36CB0(this); + EnSyatekiOkuta_UpdateHeadScale(this); } -void func_80A36CB0(EnSyatekiOkuta* this) { +/** + * Adjusts the scale of the Octorok's head based on their current action and their current animation frame. + */ +void EnSyatekiOkuta_UpdateHeadScale(EnSyatekiOkuta* this) { f32 curFrame = this->skelAnime.curFrame; - if (this->actionFunc == func_80A363B4) { + if (this->actionFunc == EnSyatekiOkuta_Appear) { if (curFrame < 8.0f) { - this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + this->headScale.x = this->headScale.y = this->headScale.z = 1.0f; } else if (curFrame < 10.0f) { - this->unk_1D8.x = this->unk_1D8.z = 1.0f; - this->unk_1D8.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; + this->headScale.x = this->headScale.z = 1.0f; + this->headScale.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; } else if (curFrame < 14.0f) { - this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; - this->unk_1D8.y = 1.8f - ((curFrame - 9.0f) * 0.25f); + this->headScale.x = this->headScale.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; + this->headScale.y = 1.8f - ((curFrame - 9.0f) * 0.25f); } else { - this->unk_1D8.x = this->unk_1D8.z = 1.3f - ((curFrame - 13.0f) * 0.05f); - this->unk_1D8.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; + this->headScale.x = this->headScale.z = 1.3f - ((curFrame - 13.0f) * 0.05f); + this->headScale.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; } - } else if (this->actionFunc == func_80A36488) { - this->unk_1D8.x = this->unk_1D8.z = 1.0f; - this->unk_1D8.y = (Math_SinF((M_PI / 16) * curFrame) * 0.2f) + 1.0f; - } else if (this->actionFunc == func_80A36504) { + } else if (this->actionFunc == EnSyatekiOkuta_Float) { + this->headScale.x = this->headScale.z = 1.0f; + this->headScale.y = (Math_SinF((M_PI / 16) * curFrame) * 0.2f) + 1.0f; + } else if (this->actionFunc == EnSyatekiOkuta_Hide) { if (curFrame < 3.0f) { - this->unk_1D8.y = 1.0f; + this->headScale.y = 1.0f; } else if (curFrame < 4.0f) { - this->unk_1D8.y = (curFrame - 2.0f) + 1.0f; + this->headScale.y = (curFrame - 2.0f) + 1.0f; } else { - this->unk_1D8.y = 2.0f - ((curFrame - 3.0f) * 0.333f); + this->headScale.y = 2.0f - ((curFrame - 3.0f) * 0.333f); } - this->unk_1D8.x = this->unk_1D8.z = 1.0f; - } else if (this->actionFunc == func_80A365EC) { - curFrame += this->unk_2A4; + this->headScale.x = this->headScale.z = 1.0f; + } else if (this->actionFunc == EnSyatekiOkuta_Die) { + curFrame += this->deathTimer; if (curFrame >= 35.0f) { - this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + this->headScale.x = this->headScale.y = this->headScale.z = 1.0f; } else if (curFrame < 4.0f) { - this->unk_1D8.x = this->unk_1D8.z = 1.0f - (curFrame * 0.0666f); - this->unk_1D8.y = (curFrame * 0.1666f) + 1.0f; + this->headScale.x = this->headScale.z = 1.0f - (curFrame * 0.0666f); + this->headScale.y = (curFrame * 0.1666f) + 1.0f; } else if (curFrame < 25.0f) { - this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 4.0f) * 0.01f) + 0.8f; - this->unk_1D8.y = 1.5f - ((curFrame - 4.0f) * 0.025f); + this->headScale.x = this->headScale.z = ((curFrame - 4.0f) * 0.01f) + 0.8f; + this->headScale.y = 1.5f - ((curFrame - 4.0f) * 0.025f); } else if (curFrame < 27.0f) { - this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 24.0f) * 0.25f) + 1.0f; + this->headScale.x = this->headScale.y = this->headScale.z = ((curFrame - 24.0f) * 0.25f) + 1.0f; } else if (curFrame < 30.0f) { - this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.5f - ((curFrame - 26.0f) * 0.233f); + this->headScale.x = this->headScale.y = this->headScale.z = 1.5f - ((curFrame - 26.0f) * 0.233f); } else { - this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 29.0f) * 0.04f) + 0.8f; + this->headScale.x = this->headScale.y = this->headScale.z = ((curFrame - 29.0f) * 0.04f) + 0.8f; } } else { - this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + this->headScale.x = this->headScale.y = this->headScale.z = 1.0f; } } -s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { - if (this->actionFunc == func_80A363B4) { - arg2->y = 1.0f; - arg2->z = 1.0f; - arg2->x = (Math_SinF((M_PI / 16) * arg1) * 0.4f) + 1.0f; - } else if (this->actionFunc == func_80A365EC) { - if ((arg1 >= 35.0f) || (arg1 < 25.0f)) { +/** + * Returns true if the snout scale should be updated, false otherwise. The snout scale is returned via the scale + * parameter. + */ +s32 EnSyatekiOkuta_GetSnoutScale(EnSyatekiOkuta* this, f32 curFrame, Vec3f* scale) { + if (this->actionFunc == EnSyatekiOkuta_Appear) { + scale->y = 1.0f; + scale->z = 1.0f; + scale->x = (Math_SinF((M_PI / 16) * curFrame) * 0.4f) + 1.0f; + } else if (this->actionFunc == EnSyatekiOkuta_Die) { + if ((curFrame >= 35.0f) || (curFrame < 25.0f)) { return false; } - if (arg1 < 27.0f) { - arg2->z = 1.0f; - arg2->x = arg2->y = ((arg1 - 24.0f) * 0.5f) + 1.0f; - } else if (arg1 < 30.0f) { - arg2->z = (arg1 - 26.0f) * 0.333f + 1.0f; - arg2->x = arg2->y = 2.0f - (arg1 - 26.0f) * 0.333f; + if (curFrame < 27.0f) { + scale->z = 1.0f; + scale->x = scale->y = ((curFrame - 24.0f) * 0.5f) + 1.0f; + } else if (curFrame < 30.0f) { + scale->z = (curFrame - 26.0f) * 0.333f + 1.0f; + scale->x = scale->y = 2.0f - (curFrame - 26.0f) * 0.333f; } else { - arg2->z = 2.0f - ((arg1 - 29.0f) * 0.2f); - arg2->x = arg2->y = 1.0f; + scale->z = 2.0f - ((curFrame - 29.0f) * 0.2f); + scale->x = scale->y = 1.0f; } } else { return false; @@ -464,20 +534,20 @@ s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { s32 EnSyatekiOkuta_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { s32 pad; - Vec3f sp20; + Vec3f scale; f32 curFrame; EnSyatekiOkuta* this = THIS; curFrame = this->skelAnime.curFrame; - if (this->actionFunc == func_80A365EC) { - curFrame += this->unk_2A4; + if (this->actionFunc == EnSyatekiOkuta_Die) { + curFrame += this->deathTimer; } if (limbIndex == OCTOROK_LIMB_HEAD) { - sp20 = this->unk_1D8; - Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); - } else if ((limbIndex == OCTOROK_LIMB_SNOUT) && (func_80A370EC(this, curFrame, &sp20))) { - Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + scale = this->headScale; + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); + } else if ((limbIndex == OCTOROK_LIMB_SNOUT) && (EnSyatekiOkuta_GetSnoutScale(this, curFrame, &scale))) { + Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); } return false; @@ -489,7 +559,7 @@ void EnSyatekiOkuta_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL25_Opa(play->state.gfxCtx); - if (this->unk_2A6 == 1) { + if (this->type == SG_OCTO_TYPE_RED) { gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); } else { gSPSegment(POLY_OPA_DISP++, 0x08, gShootingGalleryOctorokBlueMaterialDL); @@ -497,20 +567,22 @@ void EnSyatekiOkuta_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, NULL, &this->actor); + + // Draw the circle or cross that appears when the player hits an Octorok Gfx_SetupDL25_Xlu(play->state.gfxCtx); - if (this->actionFunc == func_80A365EC) { + if (this->actionFunc == EnSyatekiOkuta_Die) { Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, this->actor.world.pos.z + 20.0f, MTXMODE_NEW); - if (this->unk_2AA >= 256) { + if (this->hitResultAlpha > 255) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); } else { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->unk_2AA); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->hitResultAlpha); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (this->unk_2A6 == 2) { + if (this->type == SG_OCTO_TYPE_BLUE) { gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCrossDL); } else { gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCircleDL); diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h index 0527354d0..72be15406 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h @@ -4,7 +4,39 @@ #include "global.h" #include "objects/object_okuta/object_okuta.h" -#define EN_SYATEKI_OKUTA_GET_F(thisx) ((thisx)->params & 0xF) +typedef enum { + /* 0 */ SG_OCTO_TYPE_NONE, + /* 1 */ SG_OCTO_TYPE_RED, + /* 2 */ SG_OCTO_TYPE_BLUE, + /* 3 */ SG_OCTO_TYPE_MAX +} ShootingGalleryOctorokType; + +typedef enum { + /* 0 */ SG_OCTO_ROW_BACK, + /* 1 */ SG_OCTO_ROW_CENTER, + /* 2 */ SG_OCTO_ROW_FRONT, + /* 3 */ SG_OCTO_ROW_MAX +} ShootingGalleryOctorokRow; + +typedef enum { + /* 0 */ SG_OCTO_COL_LEFT, + /* 1 */ SG_OCTO_COL_CENTER, + /* 2 */ SG_OCTO_COL_RIGHT, + /* 3 */ SG_OCTO_COL_MAX +} ShootingGalleryOctorokColumn; + +#define SG_OCTO_GET_INDEX(thisx) ((thisx)->params & 0xF) +#define SG_OCTO_INDEX_FOR_POS(row, column) (((row) * SG_OCTO_COL_MAX) + (column)) + +// This returns the index of the Octorok directly in front of the Octorok at the given index. In other words, it +// returns the index of the Octorok in the same column as the one with the given index, but one row ahead. It's +// assumed that this will only be used for Octoroks in the back or center row; it returns an invalid index for +// Octoroks in the front row. +#define SG_OCTO_INDEX_DIRECTLY_IN_FRONT(index) ((index) + SG_OCTO_COL_MAX) + +// Both of these macros assume that the Octorok types can fit in two bits, hence why the index is multiplied by 2. +#define SG_OCTO_GET_TYPE(octorokFlags, index) (((octorokFlags) >> ((index) * 2)) & SG_OCTO_TYPE_MAX) +#define SG_OCTO_SET_FLAG(type, index) ((type & SG_OCTO_TYPE_MAX) << ((index) * 2)) struct EnSyatekiOkuta; @@ -15,13 +47,13 @@ typedef struct EnSyatekiOkuta { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1DC */ Vec3f unk_1D8; + /* 0x1DC */ Vec3f headScale; /* 0x1E4 */ Vec3s jointTable[OCTOROK_LIMB_MAX]; /* 0x244 */ Vec3s morphTable[OCTOROK_LIMB_MAX]; - /* 0x2A4 */ s16 unk_2A4; - /* 0x2A6 */ s16 unk_2A6; + /* 0x2A4 */ s16 deathTimer; + /* 0x2A6 */ s16 type; /* 0x2A8 */ UNK_TYPE1 unk_2A8[0x2]; - /* 0x2AA */ s16 unk_2AA; + /* 0x2AA */ s16 hitResultAlpha; } EnSyatekiOkuta; // size = 0x2AC #endif // Z_EN_SYATEKI_OKUTA_H diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 1b23b58a5..4d3371a10 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -301,16 +301,16 @@ void EnTest4_Init(Actor* thisx, PlayState* play) { sCsIdList[0] = csId; if (csId >= 0) { - ActorCutscene* actorCutscene = CutsceneManager_GetCutsceneEntry(sCsIdList[0]); + ActorCutscene* csEntry = CutsceneManager_GetCutsceneEntry(sCsIdList[0]); SET_EVENTINF(EVENTINF_52); - sCsIdList[1] = actorCutscene->additionalCsId; + sCsIdList[1] = csEntry->additionalCsId; } else { CLEAR_EVENTINF(EVENTINF_52); sCsIdList[1] = sCsIdList[0]; } - if (sIsLoaded || (CHECK_EVENTINF(EVENTINF_27))) { + if (sIsLoaded || CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) { Actor_Kill(&this->actor); } else { sIsLoaded = true; @@ -418,7 +418,7 @@ void func_80A42AB8(EnTest4* this, PlayState* play) { } gSaveContext.respawnFlag = -4; - SET_EVENTINF(EVENTINF_27); + SET_EVENTINF(EVENTINF_TRIGGER_DAYTELOP); Actor_Kill(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 846d728dc..185e11dbd 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -18,30 +18,38 @@ void EnTest6_Destroy(Actor* thisx, PlayState* play2); void EnTest6_Update(Actor* thisx, PlayState* play); void EnTest6_Draw(Actor* thisx, PlayState* play); -struct EnTest6Struct; +struct SoTCsAmmoDrops; -typedef void (*EnTest6StructFunc)(EnTest6*, PlayState*, struct EnTest6Struct*); +typedef void (*SoTCsAmmoDropDrawFunc)(EnTest6*, PlayState*, struct SoTCsAmmoDrops*); -typedef struct EnTest6Struct { - /* 0x00 */ s32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ f32 unk_10; - /* 0x14 */ EnTest6StructFunc unk_14; -} EnTest6Struct; // size = 0x18 +typedef enum SoTCsAmmoDropType { + /* 0 */ SOTCS_AMMO_DROP_NONE, + /* 1 */ SOTCS_AMMO_DROP_ARROWS, + /* 2 */ SOTCS_AMMO_DROP_BOMB, + /* 3 */ SOTCS_AMMO_DROP_DEKU_NUT, + /* 4 */ SOTCS_AMMO_DROP_DEKU_STICK, + /* 5 */ SOTCS_AMMO_DROP_RUPEE_GREEN, + /* 6 */ SOTCS_AMMO_DROP_RUPEE_BLUE +} SoTCsAmmoDropType; -void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr); -void func_80A90FC0(EnTest6* this, PlayState* play, EnTest6Struct* ptr); +typedef struct SoTCsAmmoDrops { + /* 0x00 */ SoTCsAmmoDropType type; + /* 0x04 */ f32 scale; + /* 0x08 */ Vec3f pos; + /* 0x14 */ SoTCsAmmoDropDrawFunc draw; +} SoTCsAmmoDrops; // size = 0x18 + +void EnTest6_DrawAmmoDropDefault(EnTest6* this, PlayState* play, SoTCsAmmoDrops* ammoDrop); +void EnTest6_DrawAmmoDropRupee(EnTest6* this, PlayState* play, SoTCsAmmoDrops* ammoDrop); void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); -void func_80A9156C(EnTest6* this, PlayState* play); -void func_80A91690(EnTest6* this, PlayState* play); -void func_80A91760(EnTest6* this, PlayState* play); -void func_80A920C8(EnTest6* this, PlayState* play); -void func_80A92188(EnTest6* this, PlayState* play); -void func_80A92950(EnTest6* this, PlayState* play); +void EnTest6_StartCutscene(EnTest6* this, PlayState* play); +void EnTest6_SetupInvertedSoTCutscene(EnTest6* this, PlayState* play); +void EnTest6_InvertedSoTCutscene(EnTest6* this, PlayState* play); +void EnTest6_SetupDoubleSoTCutscene(EnTest6* this, PlayState* play); +void EnTest6_DoubleSoTCutscene(EnTest6* this, PlayState* play); +void EnTest6_SharedSoTCutscene(EnTest6* this, PlayState* play); -EnTest6Struct D_80A94910[12]; +SoTCsAmmoDrops sSoTCsAmmoDrops[12]; ActorInit En_Test6_InitVars = { ACTOR_EN_TEST6, @@ -55,7 +63,7 @@ ActorInit En_Test6_InitVars = { (ActorFunc)EnTest6_Draw, }; -CutsceneData D_80A93E80[] = { +CutsceneData sDoubleSoTCsCamData[] = { // Header CS_CAM_SPLINE(13, 424, 0, 100), @@ -108,106 +116,114 @@ CutsceneData D_80A93E80[] = { CS_CAM_END() }; -TexturePtr D_80A9402C[] = { - NULL, gDropArrows2Tex, gDropBombTex, gDropDekuNutTex, gDropDekuStickTex, gRupeeGreenTex, gRupeeBlueTex, +TexturePtr sSoTCsAmmoDropTextures[] = { + NULL, // SOTCS_AMMO_DROP_NONE + gDropArrows2Tex, // SOTCS_AMMO_DROP_ARROWS + gDropBombTex, // SOTCS_AMMO_DROP_BOMB + gDropDekuNutTex, // SOTCS_AMMO_DROP_DEKU_NUT + gDropDekuStickTex, // SOTCS_AMMO_DROP_DEKU_STICK + gRupeeGreenTex, // SOTCS_AMMO_DROP_RUPEE_GREEN + gRupeeBlueTex, // SOTCS_AMMO_DROP_RUPEE_BLUE }; -Color_RGB8 D_80A94048 = { 230, 230, 220 }; -Color_RGB8 D_80A9404C = { 120, 120, 100 }; -Color_RGB8 D_80A94050 = { 0, 0, 0 }; +typedef enum SoTCsDrawType { + /* 0 */ SOTCS_DRAW_DOUBLE_SOT, + /* 1 */ SOTCS_DRAW_RESET_CYCLE_SOT, + /* 2 */ SOTCS_DRAW_INVERTED_SOT, + /* 99 */ SOTCS_DRAW_TYPE_NONE = 99 +} SoTCsDrawType; -s16 D_80A94054 = 500; -s16 D_80A94058 = 1500; +#define SOTCS_AMMO_FLAG_RUPEE (1 << 0) +#define SOTCS_AMMO_FLAG_BOMB (1 << 1) +#define SOTCS_AMMO_FLAG_NUT (1 << 2) +#define SOTCS_AMMO_FLAG_ARROW (1 << 4) -static Vec3f sSubCamUp = { 0.0f, 1.0f, 0.0f }; - -Color_RGB8 D_80A94068 = { 225, 230, 225 }; -Color_RGB8 D_80A9406C = { 120, 120, 100 }; -Color_RGB8 D_80A94070 = { 0, 0, 0 }; - -s16 D_80A94074 = 940; -s16 D_80A94078 = 2000; - -void func_80A90730(EnTest6* this, PlayState* play) { +void EnTest6_SetupCutscene(EnTest6* this, PlayState* play) { s32 i; Player* player = GET_PLAYER(play); - s32 phi_s0; - f32 phi_f24; + s32 ammoFlags; + f32 yOffset; this->actor.home.pos = player->actor.world.pos; this->actor.home.rot = player->actor.shape.rot; - switch (ENTEST6_GET(&this->actor)) { - case ENTEST6_24: - case ENTEST6_25: - func_80A91690(this, play); + switch (SOTCS_GET_OCARINA_MODE(&this->actor)) { + case OCARINA_MODE_APPLY_INV_SOT_FAST: + case OCARINA_MODE_APPLY_INV_SOT_SLOW: + EnTest6_SetupInvertedSoTCutscene(this, play); CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); - return; + break; - case ENTEST6_26: - func_80A920C8(this, play); + case OCARINA_MODE_APPLY_DOUBLE_SOT: + EnTest6_SetupDoubleSoTCutscene(this, play); CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); - return; - } + break; - phi_s0 = 0; - phi_f24 = -900.0f; + default: // Setup "return to first day cutscene" + ammoFlags = 0; + yOffset = -900.0f; - if (CHECK_EVENTINF(EVENTINF_70)) { - for (i = 0; i < 6; i++) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; - } - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 6; - phi_s0 |= 1; - } + if (CHECK_EVENTINF(EVENTINF_THREEDAYRESET_LOST_RUPEES)) { + for (i = 0; i < 6; i++) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = + SOTCS_AMMO_DROP_RUPEE_GREEN; + } + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = + SOTCS_AMMO_DROP_RUPEE_GREEN; + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_RUPEE_BLUE; + ammoFlags |= SOTCS_AMMO_FLAG_RUPEE; + } - if (CHECK_EVENTINF(EVENTINF_74)) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; - if (!(phi_s0 & 1)) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; - } - phi_s0 |= 0x10; - } + if (CHECK_EVENTINF(EVENTINF_THREEDAYRESET_LOST_ARROW_AMMO)) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_ARROWS; + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_ARROWS; + if (!(ammoFlags & SOTCS_AMMO_FLAG_RUPEE)) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_ARROWS; + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_ARROWS; + } + ammoFlags |= SOTCS_AMMO_FLAG_ARROW; + } - if (CHECK_EVENTINF(EVENTINF_71)) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; - if (!(phi_s0 & 1)) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; - } - phi_s0 |= 2; - } + if (CHECK_EVENTINF(EVENTINF_THREEDAYRESET_LOST_BOMB_AMMO)) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_BOMB; + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_BOMB; + if (!(ammoFlags & SOTCS_AMMO_FLAG_RUPEE)) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_BOMB; + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_BOMB; + } + ammoFlags |= SOTCS_AMMO_FLAG_BOMB; + } - if (CHECK_EVENTINF(EVENTINF_72)) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; - if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; - } - phi_s0 |= 4; - } + if (CHECK_EVENTINF(EVENTINF_THREEDAYRESET_LOST_NUT_AMMO)) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_DEKU_NUT; + if (!(ammoFlags & (SOTCS_AMMO_FLAG_ARROW | SOTCS_AMMO_FLAG_BOMB | SOTCS_AMMO_FLAG_RUPEE))) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = + SOTCS_AMMO_DROP_DEKU_NUT; + } + ammoFlags |= SOTCS_AMMO_FLAG_NUT; + } - if (CHECK_EVENTINF(EVENTINF_73)) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; - if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { - D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; - } - } + if (CHECK_EVENTINF(EVENTINF_THREEDAYRESET_LOST_STICK_AMMO)) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = SOTCS_AMMO_DROP_DEKU_STICK; + if (!(ammoFlags & (SOTCS_AMMO_FLAG_ARROW | SOTCS_AMMO_FLAG_BOMB | SOTCS_AMMO_FLAG_RUPEE))) { + sSoTCsAmmoDrops[(s32)(Rand_ZeroOne() * ARRAY_COUNT(sSoTCsAmmoDrops))].type = + SOTCS_AMMO_DROP_DEKU_STICK; + } + } - for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { - D_80A94910[i].unk_08 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; - D_80A94910[i].unk_10 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; - D_80A94910[i].unk_0C = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + phi_f24; - D_80A94910[i].unk_04 = -10.0f; - if (D_80A94910[i].unk_00 < 5) { - D_80A94910[i].unk_14 = func_80A90D34; - } else { - D_80A94910[i].unk_14 = func_80A90FC0; - } - phi_f24 += 50.0f; + for (i = 0; i < ARRAY_COUNT(sSoTCsAmmoDrops); i++) { + sSoTCsAmmoDrops[i].pos.x = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + sSoTCsAmmoDrops[i].pos.z = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + sSoTCsAmmoDrops[i].pos.y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + yOffset; + sSoTCsAmmoDrops[i].scale = -10.0f; + if (sSoTCsAmmoDrops[i].type <= SOTCS_AMMO_DROP_DEKU_STICK) { + sSoTCsAmmoDrops[i].draw = EnTest6_DrawAmmoDropDefault; + } else { + sSoTCsAmmoDrops[i].draw = EnTest6_DrawAmmoDropRupee; + } + yOffset += 50.0f; + } + break; } } @@ -219,36 +235,38 @@ void EnTest6_DisableMotionBlur(void) { Play_DisableMotionBlur(); } -void func_80A90C54(PlayState* play, f32 arg1) { +void EnTest6_EnableWhiteFillScreen(PlayState* play, f32 alphaRatio) { play->envCtx.fillScreen = true; play->envCtx.screenFillColor[0] = 250; play->envCtx.screenFillColor[1] = 250; play->envCtx.screenFillColor[2] = 250; - play->envCtx.screenFillColor[3] = 255.0f * arg1; + play->envCtx.screenFillColor[3] = 255.0f * alphaRatio; } -void func_80A90D20(PlayState* play) { +void EnTest6_DisableWhiteFillScreen(PlayState* play) { play->envCtx.fillScreen = false; } -void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { +void EnTest6_DrawAmmoDropDefault(EnTest6* this, PlayState* play, SoTCsAmmoDrops* ammoDrop) { s32 pad; OPEN_DISPS(play->state.gfxCtx); - if (ptr->unk_00 != 0) { - Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); - Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); + if (ammoDrop->type != SOTCS_AMMO_DROP_NONE) { + Matrix_Translate(ammoDrop->pos.x * ammoDrop->scale, ammoDrop->pos.y, ammoDrop->pos.z * ammoDrop->scale, + MTXMODE_NEW); + Matrix_Scale(ammoDrop->scale * 0.02f, ammoDrop->scale * 0.02f, ammoDrop->scale * 0.02f, MTXMODE_APPLY); POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); POLY_OPA_DISP = Gfx_SetupDL66(POLY_OPA_DISP); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sSoTCsAmmoDropTextures[ammoDrop->type])); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); } - Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); - Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); + Matrix_Translate(ammoDrop->pos.x * ammoDrop->scale, ammoDrop->pos.y, ammoDrop->pos.z * ammoDrop->scale, + MTXMODE_NEW); + Matrix_Scale(2.0f * ammoDrop->scale, 2.0f * ammoDrop->scale, 2.0f * ammoDrop->scale, MTXMODE_APPLY); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_RotateZS(play->state.frames * 512, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); @@ -266,41 +284,43 @@ void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A90FC0(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { +void EnTest6_DrawAmmoDropRupee(EnTest6* this, PlayState* play, SoTCsAmmoDrops* ammoDrop) { s32 pad; Gfx* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); Gfx* gfx = gfxHead; - Hilite* sp70; - Vec3f sp64; + Hilite* hilite; + Vec3f ammoDropPos; - sp64.x = ptr->unk_08 * ptr->unk_04; - sp64.y = ptr->unk_0C; - sp64.z = ptr->unk_10 * ptr->unk_04; + ammoDropPos.x = ammoDrop->pos.x * ammoDrop->scale; + ammoDropPos.y = ammoDrop->pos.y; + ammoDropPos.z = ammoDrop->pos.z * ammoDrop->scale; - sp70 = func_800BCBF4(&sp64, play); + hilite = func_800BCBF4(&ammoDropPos, play); OPEN_DISPS(play->state.gfxCtx); if (gfxHead != NULL) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, - (sp70->h.y1 + 60) & 0xFFFF); + //! FAKE: & 0xFFFF + gDPSetTileSize(gfx++, 1, hilite->h.x1 & 0xFFFF, hilite->h.y1 & 0xFFFF, (hilite->h.x1 + 60) & 0xFFFF, + (hilite->h.y1 + 60) & 0xFFFF); gSPEndDisplayList(gfx++); gSPSegment(POLY_OPA_DISP++, 0x07, gfxHead); - Matrix_Translate(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); - Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); + Matrix_Translate(ammoDropPos.x, ammoDropPos.y, ammoDropPos.z, MTXMODE_NEW); + Matrix_Scale(ammoDrop->scale * 0.018f, ammoDrop->scale * 0.018f, ammoDrop->scale * 0.018f, MTXMODE_APPLY); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sSoTCsAmmoDropTextures[ammoDrop->type])); gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); } - Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); - Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); + Matrix_Translate(ammoDrop->pos.x * ammoDrop->scale, ammoDrop->pos.y, ammoDrop->pos.z * ammoDrop->scale, + MTXMODE_NEW); + Matrix_Scale(ammoDrop->scale * 2.5f, ammoDrop->scale * 2.5f, ammoDrop->scale * 2.5f, MTXMODE_APPLY); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_RotateZS(play->state.frames * 256, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); @@ -327,8 +347,9 @@ void EnTest6_Init(Actor* thisx, PlayState* play2) { EnTest6* this = THIS; s32 i; - if (((ENTEST6_GET(&this->actor) == ENTEST6_24) || (ENTEST6_GET(&this->actor) == ENTEST6_25) || - (ENTEST6_GET(&this->actor) == ENTEST6_26)) && + if (((SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_FAST) || + (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_SLOW) || + (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_DOUBLE_SOT)) && (play->playerCsIds[PLAYER_CS_ID_SONG_WARP] == CS_ID_NONE)) { Actor_Kill(&this->actor); return; @@ -340,12 +361,13 @@ void EnTest6_Init(Actor* thisx, PlayState* play2) { this->lights[i].node = LightContext_InsertLight(play, &play->lightCtx, &this->lights[i].info); } - this->unk_286 = 0; - this->cueId = 0; - this->unk_278 = 0; - this->unk_276 = 99; - func_80A90730(this, play); - EnTest6_SetupAction(this, func_80A9156C); + this->screenFillAlpha = 0; + this->cueId = SOTCS_CUEID_NONE; + this->invSoTClockYaw = 0; + this->drawType = SOTCS_DRAW_TYPE_NONE; + + EnTest6_SetupCutscene(this, play); + EnTest6_SetupAction(this, EnTest6_StartCutscene); } void EnTest6_Destroy(Actor* thisx, PlayState* play2) { @@ -356,17 +378,22 @@ void EnTest6_Destroy(Actor* thisx, PlayState* play2) { play->envCtx.lightSettings.ambientColor[0] = 0; play->envCtx.lightSettings.ambientColor[1] = 0; play->envCtx.lightSettings.ambientColor[2] = 0; + play->envCtx.lightSettings.diffuseColor1[0] = 0; play->envCtx.lightSettings.diffuseColor1[1] = 0; play->envCtx.lightSettings.diffuseColor1[2] = 0; + play->envCtx.lightSettings.diffuseColor2[0] = 0; play->envCtx.lightSettings.diffuseColor2[1] = 0; play->envCtx.lightSettings.diffuseColor2[2] = 0; + play->envCtx.lightSettings.fogColor[0] = 0; play->envCtx.lightSettings.fogColor[1] = 0; play->envCtx.lightSettings.fogColor[2] = 0; + play->envCtx.lightSettings.fogNear = 0; play->envCtx.lightSettings.zFar = 0; + play->envCtx.fillScreen = false; for (i = 0; i < ARRAY_COUNT(this->lights); i++) { @@ -374,50 +401,51 @@ void EnTest6_Destroy(Actor* thisx, PlayState* play2) { } } -void func_80A9156C(EnTest6* this, PlayState* play) { - switch (ENTEST6_GET(&this->actor)) { - case ENTEST6_24: - case ENTEST6_25: +void EnTest6_StartCutscene(EnTest6* this, PlayState* play) { + switch (SOTCS_GET_OCARINA_MODE(&this->actor)) { + case OCARINA_MODE_APPLY_INV_SOT_FAST: + case OCARINA_MODE_APPLY_INV_SOT_SLOW: if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); } else { CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); this->subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); - EnTest6_SetupAction(this, func_80A91760); + EnTest6_SetupAction(this, EnTest6_InvertedSoTCutscene); } break; - case ENTEST6_26: + case OCARINA_MODE_APPLY_DOUBLE_SOT: if (!CutsceneManager_IsNext(play->playerCsIds[PLAYER_CS_ID_SONG_WARP])) { CutsceneManager_Queue(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); } else { CutsceneManager_Start(play->playerCsIds[PLAYER_CS_ID_SONG_WARP], NULL); this->subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); - EnTest6_SetupAction(this, func_80A92188); + EnTest6_SetupAction(this, EnTest6_DoubleSoTCutscene); } break; default: gSaveContext.save.daysElapsed = 0; - gSaveContext.save.day = false; + gSaveContext.save.day = 0; gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; - EnTest6_SetupAction(this, func_80A92950); + EnTest6_SetupAction(this, EnTest6_SharedSoTCutscene); break; } } -void func_80A91690(EnTest6* this, PlayState* play) { - this->cueId = 90; - this->unk_27A = 100; - this->unk_286 = 0; - if (ENTEST6_GET(&this->actor) == ENTEST6_25) { +void EnTest6_SetupInvertedSoTCutscene(EnTest6* this, PlayState* play) { + this->cueId = SOTCS_CUEID_INV_INIT; + this->timer = 100; + this->screenFillAlpha = 0; + + if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_SLOW) { play_sound(NA_SE_SY_TIME_CONTROL_SLOW); - } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + } else if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_FAST) { play_sound(NA_SE_SY_TIME_CONTROL_NORMAL); } } -void func_80A916F0(EnTest6* this, PlayState* play) { +void EnTest6_StopInvertedSoTCutscene(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; @@ -429,216 +457,249 @@ void func_80A916F0(EnTest6* this, PlayState* play) { Actor_Kill(&this->actor); } -void func_80A91760(EnTest6* this, PlayState* play) { +Color_RGB8 sInvSoTCsFogColor = { 230, 230, 220 }; +Color_RGB8 sInvSoTCsAmbientColor = { 120, 120, 100 }; +Color_RGB8 sInvSoTCsDiffuseColor = { 0, 0, 0 }; +s16 sInvSoTCsFogNear = 500; +s16 sInvSoTCsZFar = 1500; + +void EnTest6_InvertedSoTCutscene(EnTest6* this, PlayState* play) { Input* input = CONTROLLER1(&play->state); - s16 temp_s0; + s16 clockYaw; Player* player = GET_PLAYER(play); Camera* mainCam; Vec3f subCamAt; Vec3f subCamEye; - Vec3f sp54; + Vec3f eyeNext; s32 i; - f32 sp4C; - Camera* subCam = Play_GetCamera(play, this->subCamId); + f32 temp; + Camera* subCam; + subCam = Play_GetCamera(play, this->subCamId); mainCam = Play_GetCamera(play, CAM_ID_MAIN); + // Update cutscene effects switch (this->cueId) { - case 90: - this->unk_276 = 2; - this->unk_15C = 0.0f; - this->unk_14C = 0.1f; - this->unk_282 = 0; - this->unk_278 = 0; - this->cueId = 91; + case SOTCS_CUEID_INV_INIT: + this->drawType = SOTCS_DRAW_INVERTED_SOT; + this->invSoTEnvLerp = 0.0f; + this->speed = 0.1f; + this->alpha = 0; + this->invSoTClockYaw = 0; + this->cueId = SOTCS_CUEID_INV_SETUP_CLOCKS; break; - case 91: - this->unk_15C += this->unk_14C; - func_800FD59C(play, &D_80A9404C, this->unk_15C); - func_800FD5E0(play, &D_80A94050, this->unk_15C); - func_800FD654(play, &D_80A94048, this->unk_15C); - func_800FD698(play, D_80A94054, D_80A94058, this->unk_15C); + case SOTCS_CUEID_INV_SETUP_CLOCKS: + this->invSoTEnvLerp += this->speed; + Environment_LerpAmbientColor(play, &sInvSoTCsAmbientColor, this->invSoTEnvLerp); + Environment_LerpDiffuseColor(play, &sInvSoTCsDiffuseColor, this->invSoTEnvLerp); + Environment_LerpFogColor(play, &sInvSoTCsFogColor, this->invSoTEnvLerp); + Environment_LerpFog(play, sInvSoTCsFogNear, sInvSoTCsZFar, this->invSoTEnvLerp); - if (this->unk_27A == 90) { - this->unk_282 = 0; - if (ENTEST6_GET(&this->actor) == ENTEST6_24) { - this->unk_27C = 0x200; - this->unk_150 = 0.0f; - sp4C = -100.0f; + if (this->timer == 90) { + this->alpha = 0; + if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_FAST) { + this->clockAngle = 0x200; + this->clockDist = 0.0f; + temp = -100.0f; } else { - this->unk_27C = 0x570; - this->unk_150 = 110.0f; - sp4C = 100.0f; + this->clockAngle = 0x570; + this->clockDist = 110.0f; + temp = 100.0f; } - this->unk_14C = 1.0f; + this->speed = 1.0f; - for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { - this->unk_20C[i].x = player->actor.world.pos.x; - this->unk_20C[i].y = player->actor.world.pos.y; - this->unk_20C[i].z = player->actor.world.pos.z; + for (i = 0; i < SOTCS_INV_NUM_CLOCKS; i++) { + this->invSoTClockPos[i].x = player->actor.world.pos.x; + this->invSoTClockPos[i].y = player->actor.world.pos.y; + this->invSoTClockPos[i].z = player->actor.world.pos.z; } - this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); - if (this->unk_254 != NULL) { - for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { - (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.x + - ((subCam->at.x - subCam->eye.x) * 0.2f); - (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + subCam->eye.y + - ((subCam->at.y - subCam->eye.y) * 0.2f) + sp4C; - (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.z + - ((subCam->at.z - subCam->eye.z) * 0.2f); + this->invSoTParticles = ZeldaArena_Malloc(sizeof(Vec3f) * SOTCS_NUM_PARTICLES); + if (this->invSoTParticles != NULL) { + for (i = 0; i < ARRAY_COUNT(this->invSoTParticles[0]); i++) { + (*this->invSoTParticles)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.x + + ((subCam->at.x - subCam->eye.x) * 0.2f); + (*this->invSoTParticles)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + subCam->eye.y + + ((subCam->at.y - subCam->eye.y) * 0.2f) + temp; + (*this->invSoTParticles)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + subCam->eye.z + + ((subCam->at.z - subCam->eye.z) * 0.2f); } } + EnTest6_EnableMotionBlur(120); Distortion_Request(DISTORTION_TYPE_SONG_OF_TIME); Distortion_SetDuration(80); + play->unk_18844 = true; - this->cueId = 95; + this->cueId = SOTCS_CUEID_INV_CLOCKS; } break; - case 95: - if (this->unk_27A > 80) { - this->unk_282 += 25; + case SOTCS_CUEID_INV_CLOCKS: + if (this->timer > 80) { + this->alpha += 25; } - if (this->unk_27A < 20) { - this->unk_282 -= 25; + if (this->timer < 20) { + this->alpha -= 25; } - func_800FD59C(play, &D_80A9404C, this->unk_15C); - func_800FD5E0(play, &D_80A94050, this->unk_15C); - func_800FD654(play, &D_80A94048, this->unk_15C); - func_800FD698(play, D_80A94054 + this->unk_282, D_80A94058 + this->unk_282, this->unk_15C); + Environment_LerpAmbientColor(play, &sInvSoTCsAmbientColor, this->invSoTEnvLerp); + Environment_LerpDiffuseColor(play, &sInvSoTCsDiffuseColor, this->invSoTEnvLerp); + Environment_LerpFogColor(play, &sInvSoTCsFogColor, this->invSoTEnvLerp); + Environment_LerpFog(play, sInvSoTCsFogNear + this->alpha, sInvSoTCsZFar + this->alpha, this->invSoTEnvLerp); - this->unk_278 -= this->unk_27C; - temp_s0 = this->unk_278; - if (ENTEST6_GET(&this->actor) == ENTEST6_24) { - this->unk_27C += 8; - this->unk_150 += this->unk_14C; + this->invSoTClockYaw -= this->clockAngle; + clockYaw = this->invSoTClockYaw; + + if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_FAST) { + this->clockAngle += 8; + this->clockDist += this->speed; } else { - this->unk_27C -= 8; - this->unk_150 -= this->unk_14C; + this->clockAngle -= 8; + this->clockDist -= this->speed; } - for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { - temp_s0 += 0x10000 / ARRAY_COUNT(this->unk_20C); - if (player) {} - this->unk_20C[i].x = (Math_SinS(temp_s0) * this->unk_150) + player->actor.world.pos.x; - this->unk_20C[i].y = player->actor.world.pos.y; - this->unk_20C[i].z = (Math_CosS(temp_s0) * this->unk_150) + player->actor.world.pos.z; + for (i = 0; i < SOTCS_INV_NUM_CLOCKS; i++) { + //! FAKE: + if (player != NULL) {} + + clockYaw += 0x10000 / SOTCS_INV_NUM_CLOCKS; + this->invSoTClockPos[i].x = player->actor.world.pos.x + (Math_SinS(clockYaw) * this->clockDist); + this->invSoTClockPos[i].y = player->actor.world.pos.y; + this->invSoTClockPos[i].z = player->actor.world.pos.z + (Math_CosS(clockYaw) * this->clockDist); } - if (this->unk_254 != NULL) { - for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { - (*this->unk_254)[i].x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); - if (ENTEST6_GET(&this->actor) == ENTEST6_24) { - (*this->unk_254)[i].y += 1.0f; + if (this->invSoTParticles != NULL) { + for (i = 0; i < ARRAY_COUNT(this->invSoTParticles[0]); i++) { + // Wiggle in the x-direction + (*this->invSoTParticles)[i].x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + + // Fall or rise depending on slow-down or speed-up + if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_FAST) { + // Rise up + (*this->invSoTParticles)[i].y += 1.0f; } else { - if (1) {} - (*this->unk_254)[i].y -= 1.0f; + // Fall down + (*this->invSoTParticles)[i].y -= 1.0f; } - (*this->unk_254)[i].z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + // Wiggle in the z-direction + (*this->invSoTParticles)[i].z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); } } - if (this->unk_27A == 10) { - this->unk_14C = 0.1f; + if (this->timer == 10) { + this->speed = 0.1f; EnTest6_DisableMotionBlur(); Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME); play->unk_18844 = false; - if (this->unk_254 != NULL) { - ZeldaArena_Free(this->unk_254); + if (this->invSoTParticles != NULL) { + ZeldaArena_Free(this->invSoTParticles); } - this->cueId = 99; + this->cueId = SOTCS_CUEID_INV_END; } break; - case 99: - this->unk_15C -= this->unk_14C; - func_800FD59C(play, &D_80A9404C, this->unk_15C); - func_800FD5E0(play, &D_80A94050, this->unk_15C); - func_800FD654(play, &D_80A94048, this->unk_15C); - func_800FD698(play, D_80A94054, D_80A94058, this->unk_15C); + case SOTCS_CUEID_INV_END: + this->invSoTEnvLerp -= this->speed; + Environment_LerpAmbientColor(play, &sInvSoTCsAmbientColor, this->invSoTEnvLerp); + Environment_LerpDiffuseColor(play, &sInvSoTCsDiffuseColor, this->invSoTEnvLerp); + Environment_LerpFogColor(play, &sInvSoTCsFogColor, this->invSoTEnvLerp); + Environment_LerpFog(play, sInvSoTCsFogNear, sInvSoTCsZFar, this->invSoTEnvLerp); + break; + + default: break; } - if (this->unk_286 != 0) { + // Update Player Cutscene Animation + if (this->screenFillAlpha != 0) { func_800B7298(play, NULL, PLAYER_CSMODE_WAIT); } else { - if (this->unk_27A == 90) { + if (this->timer == 90) { + // Look side-to-side but downwards, with chin down + // gPlayerAnim_al_elf_tobidasi func_800B7298(play, NULL, PLAYER_CSMODE_66); } - if (this->unk_27A == 70) { + if (this->timer == 70) { + // close eyes and sway body in circles + // gPlayerAnim_alink_yurayura func_800B7298(play, NULL, PLAYER_CSMODE_82); } - if (this->unk_27A == 30) { + if (this->timer == 30) { + // Look side-to-side but upwards, with chin up + // gPlayerAnim_alink_kyoro func_800B7298(play, NULL, PLAYER_CSMODE_81); } - if (this->unk_27A == 5) { + if (this->timer == 5) { + // Give a big nod of approval + // gPlayerAnim_al_yes func_800B7298(play, NULL, PLAYER_CSMODE_74); } } - if (this->unk_27A > 80) { - subCam->fov += (90.0f - subCam->fov) / (this->unk_27A - 80); - } else if (this->unk_27A > 60) { - sp4C = 1.0f / (this->unk_27A - 60); + // Update camera + if (this->timer > 80) { + subCam->fov += (90.0f - subCam->fov) / (this->timer - 80); + } else if (this->timer > 60) { + temp = 1.0f / (this->timer - 60); - subCamAt.x = subCam->at.x + ((player->actor.world.pos.x - subCam->at.x) * sp4C); - subCamAt.y = subCam->at.y + (((player->actor.focus.pos.y - subCam->at.y) - 20.0f) * sp4C); - subCamAt.z = subCam->at.z + ((player->actor.world.pos.z - subCam->at.z) * sp4C); + subCamAt.x = subCam->at.x + ((player->actor.world.pos.x - subCam->at.x) * temp); + subCamAt.y = subCam->at.y + (((player->actor.focus.pos.y - subCam->at.y) - 20.0f) * temp); + subCamAt.z = subCam->at.z + ((player->actor.world.pos.z - subCam->at.z) * temp); - sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + subCamAt.x; - sp54.y = subCamAt.y + 20.0f; - sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + subCamAt.z; - sp4C *= 0.75f; + eyeNext.x = subCamAt.x + (Math_SinS(player->actor.world.rot.y) * 80.0f); + eyeNext.y = subCamAt.y + 20.0f; + eyeNext.z = subCamAt.z + (Math_CosS(player->actor.world.rot.y) * 80.0f); + temp *= 0.75f; - VEC3F_LERPIMPDST(&subCamEye, &subCam->eye, &sp54, sp4C); + VEC3F_LERPIMPDST(&subCamEye, &subCam->eye, &eyeNext, temp); Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); - } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { - subCam->fov += (mainCam->fov - subCam->fov) / this->unk_27A; + } else if ((this->timer < 11) && (this->timer > 0)) { + subCam->fov += (mainCam->fov - subCam->fov) / this->timer; } - if (this->unk_286 != 0) { - func_80A90C54(play, this->unk_286 * 0.05f); + // Update white screen + if (this->screenFillAlpha != 0) { + EnTest6_EnableWhiteFillScreen(play, this->screenFillAlpha * 0.05f); subCam->fov += (mainCam->fov - subCam->fov) * 0.05f; - this->unk_286++; - if (this->unk_286 >= 20) { - this->unk_27A = 1; + this->screenFillAlpha++; + if (this->screenFillAlpha >= 20) { + this->timer = 1; } - } else if ((this->unk_27A <= 60) && (this->unk_27A > 40) && + } else if ((this->timer <= 60) && (this->timer > 40) && (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { - this->unk_286 = 1; - if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + this->screenFillAlpha = 1; + + if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_SLOW) { AudioSfx_StopById(NA_SE_SY_TIME_CONTROL_SLOW); - } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + } else if (SOTCS_GET_OCARINA_MODE(&this->actor) == OCARINA_MODE_APPLY_INV_SOT_FAST) { AudioSfx_StopById(NA_SE_SY_TIME_CONTROL_NORMAL); } } - if (DECR(this->unk_27A) == 0) { - func_80A916F0(this, play); + if (DECR(this->timer) == 0) { + EnTest6_StopInvertedSoTCutscene(this, play); play->msgCtx.ocarinaMode = 4; } } -void func_80A920C8(EnTest6* this, PlayState* play) { +void EnTest6_SetupDoubleSoTCutscene(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); - this->unk_27A = 120; - this->unk_286 = 0; - this->unk_160 = 0.0f; + this->timer = 120; + this->screenFillAlpha = 0; + this->doubleSoTEnvLerp = 0.0f; this->actor.home.pos = player->actor.world.pos; this->actor.home.rot = player->actor.shape.rot; } -void func_80A92118(EnTest6* this, PlayState* play) { +void EnTest6_StopDoubleSoTCutscene(EnTest6* this, PlayState* play) { Player* player = GET_PLAYER(play); player->actor.freezeTimer = 0; @@ -650,7 +711,15 @@ void func_80A92118(EnTest6* this, PlayState* play) { Actor_Kill(&this->actor); } -void func_80A92188(EnTest6* this, PlayState* play) { +static Vec3f sSubCamUp = { 0.0f, 1.0f, 0.0f }; + +Color_RGB8 sDoubleSoTCsFogColor = { 225, 230, 225 }; +Color_RGB8 sDoubleSoTCsAmbientColor = { 120, 120, 100 }; +Color_RGB8 sDoubleSoTCsDiffuseColor = { 0, 0, 0 }; +s16 sDoubleSoTCsFogNear = 940; +s16 sDoubleSoTCsZFar = 2000; + +void EnTest6_DoubleSoTCutscene(EnTest6* this, PlayState* play) { Input* input = CONTROLLER1(&play->state); Player* player = GET_PLAYER(play); Camera* subCam; @@ -658,55 +727,55 @@ void func_80A92188(EnTest6* this, PlayState* play) { s16 subCamId; s16 pad2; - if (this->unk_27A > 115) { - this->unk_160 += 0.2f; - func_80A90C54(play, this->unk_160); - } else if (this->unk_27A > 90) { - this->unk_160 -= 0.05f; - func_80A90C54(play, this->unk_160); - } else if (this->unk_27A == 90) { - this->unk_160 = 0.0f; - func_80A90D20(play); + if (this->timer > 115) { + this->doubleSoTEnvLerp += 0.2f; + EnTest6_EnableWhiteFillScreen(play, this->doubleSoTEnvLerp); + } else if (this->timer > 90) { + this->doubleSoTEnvLerp -= 0.05f; + EnTest6_EnableWhiteFillScreen(play, this->doubleSoTEnvLerp); + } else if (this->timer == 90) { + this->doubleSoTEnvLerp = 0.0f; + EnTest6_DisableWhiteFillScreen(play); } - if (this->unk_27A == 1) { - this->unk_160 = 0.0f; - func_80A90D20(play); - } else if (this->unk_27A < 17) { - this->unk_160 -= 0.06666666f; - func_80A90C54(play, this->unk_160); - } else if (this->unk_27A < 22) { - this->unk_160 += 0.2f; - func_80A90C54(play, this->unk_160); + if (this->timer == 1) { + this->doubleSoTEnvLerp = 0.0f; + EnTest6_DisableWhiteFillScreen(play); + } else if (this->timer < 17) { + this->doubleSoTEnvLerp -= 0.06666666f; + EnTest6_EnableWhiteFillScreen(play, this->doubleSoTEnvLerp); + } else if (this->timer < 22) { + this->doubleSoTEnvLerp += 0.2f; + EnTest6_EnableWhiteFillScreen(play, this->doubleSoTEnvLerp); } - if (this->unk_27A == 115) { - func_800FD59C(play, &D_80A9406C, 1.0f); - func_800FD5E0(play, &D_80A94070, 1.0f); - func_800FD654(play, &D_80A94068, 1.0f); - func_800FD698(play, D_80A94074, D_80A94078, 1.0f); + if (this->timer == 115) { + Environment_LerpAmbientColor(play, &sDoubleSoTCsAmbientColor, 1.0f); + Environment_LerpDiffuseColor(play, &sDoubleSoTCsDiffuseColor, 1.0f); + Environment_LerpFogColor(play, &sDoubleSoTCsFogColor, 1.0f); + Environment_LerpFog(play, sDoubleSoTCsFogNear, sDoubleSoTCsZFar, 1.0f); play->unk_18844 = true; } - if (this->unk_27A == 15) { - func_800FD59C(play, &D_80A9406C, 0.0f); - func_800FD5E0(play, &D_80A94070, 0.0f); - func_800FD654(play, &D_80A94068, 0.0f); - func_800FD698(play, D_80A94074, D_80A94078, 0.0f); + if (this->timer == 15) { + Environment_LerpAmbientColor(play, &sDoubleSoTCsAmbientColor, 0.0f); + Environment_LerpDiffuseColor(play, &sDoubleSoTCsDiffuseColor, 0.0f); + Environment_LerpFogColor(play, &sDoubleSoTCsFogColor, 0.0f); + Environment_LerpFog(play, sDoubleSoTCsFogNear, sDoubleSoTCsZFar, 0.0f); play->unk_18844 = false; } - if (this->unk_286 >= 20) { - func_800FD59C(play, &D_80A9406C, this->unk_160); - func_800FD5E0(play, &D_80A94070, this->unk_160); - func_800FD654(play, &D_80A94068, this->unk_160); - func_800FD698(play, D_80A94074, D_80A94078, this->unk_160); + if (this->screenFillAlpha >= 20) { + Environment_LerpAmbientColor(play, &sDoubleSoTCsAmbientColor, this->doubleSoTEnvLerp); + Environment_LerpDiffuseColor(play, &sDoubleSoTCsDiffuseColor, this->doubleSoTEnvLerp); + Environment_LerpFogColor(play, &sDoubleSoTCsFogColor, this->doubleSoTEnvLerp); + Environment_LerpFog(play, sDoubleSoTCsFogNear, sDoubleSoTCsZFar, this->doubleSoTEnvLerp); play->unk_18844 = false; } func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); - switch (this->unk_27A) { + switch (this->timer) { case 119: EnTest6_EnableMotionBlur(50); break; @@ -715,7 +784,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { EnTest6_EnableMotionBlur(20); Distortion_Request(DISTORTION_TYPE_SONG_OF_TIME); Distortion_SetDuration(90); - this->cueId = 2; + this->cueId = SOTCS_CUEID_DOUBLE_INIT; break; case 110: @@ -724,53 +793,56 @@ void func_80A92188(EnTest6* this, PlayState* play) { case 38: case 114: - this->cueId = 1; + this->cueId = SOTCS_CUEID_DOUBLE_WAIT; break; case 76: - this->cueId = 3; + this->cueId = SOTCS_CUEID_DOUBLE_CLOCKS_INWARD; break; case 61: EnTest6_EnableMotionBlur(150); - this->cueId = 4; + this->cueId = SOTCS_CUEID_DOUBLE_CLOCKS_SPIN; break; case 51: EnTest6_EnableMotionBlur(180); - this->cueId = 5; + this->cueId = SOTCS_CUEID_DOUBLE_CLOCKS_OUTWARD; break; case 14: case 15: EnTest6_EnableMotionBlur(50); Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME); - this->cueId = 0; + this->cueId = SOTCS_CUEID_NONE; break; case 1: EnTest6_DisableMotionBlur(); if (CHECK_EVENTINF(EVENTINF_52)) { - this->cueId = 9; + this->cueId = SOTCS_CUEID_DOUBLE_END; } break; + + default: + break; } - func_80A92950(this, play); + EnTest6_SharedSoTCutscene(this, play); - if (this->unk_27A == 115) { + if (this->timer == 115) { subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); subCam = Play_GetCamera(play, subCamId); this->subCamAt = subCam->at; this->subCamEye = subCam->eye; this->subCamFov = subCam->fov; - CutsceneCamera_Init(subCam, &this->unk_18C); + CutsceneCamera_Init(subCam, &this->csCamInfo); } - if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { - CutsceneCamera_UpdateSplines((u8*)D_80A93E80, &this->unk_18C); - } else if (this->unk_27A < 16) { + if ((this->timer <= 115) && (this->timer >= 16)) { + CutsceneCamera_UpdateSplines((u8*)sDoubleSoTCsCamData, &this->csCamInfo); + } else if (this->timer < 16) { subCamId = CutsceneManager_GetCurrentSubCamId(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]); Play_SetCameraAtEyeUp(play, subCamId, &this->subCamAt, &this->subCamEye, &sSubCamUp); @@ -778,7 +850,7 @@ void func_80A92188(EnTest6* this, PlayState* play) { Play_SetCameraRoll(play, subCamId, 0); } - switch (this->unk_27A) { + switch (this->timer) { case 116: player->actor.freezeTimer = 2; player->actor.shape.rot.x = 0; @@ -821,24 +893,27 @@ void func_80A92188(EnTest6* this, PlayState* play) { player->unk_AC0 = 0.0f; player->actor.shape.yOffset = 0.0f; break; + + default: + break; } - if ((this->unk_286 > 0) && (this->unk_286 < 20)) { - func_80A90C54(play, this->unk_286 * 0.05f); - this->unk_286++; - if (this->unk_286 >= 20) { - this->unk_27A = 15; - this->unk_160 = 0.9333333f; + if ((this->screenFillAlpha > 0) && (this->screenFillAlpha < 20)) { + EnTest6_EnableWhiteFillScreen(play, this->screenFillAlpha * 0.05f); + this->screenFillAlpha++; + if (this->screenFillAlpha >= 20) { + this->timer = 15; + this->doubleSoTEnvLerp = 0.9333333f; } - } else if ((this->unk_27A < 96) && (this->unk_27A > 50) && + } else if ((this->timer < 96) && (this->timer > 50) && (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { - this->unk_286 = 1; - this->unk_27A = 39; + this->screenFillAlpha = 1; + this->timer = 39; SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 20); } - if (DECR(this->unk_27A) == 0) { - func_80A92118(this, play); + if (DECR(this->timer) == 0) { + EnTest6_StopDoubleSoTCutscene(this, play); } } @@ -848,166 +923,171 @@ void EnTest6_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); } -void func_80A92950(EnTest6* this, PlayState* play) { +/** + * Processes two different cutscenes: + * return to "Dawn of the First Day" Cs, and Song of Double Time Cs + */ +void EnTest6_SharedSoTCutscene(EnTest6* this, PlayState* play) { s32 pad[2]; Player* player = GET_PLAYER(play); - f32 temp_f0; + f32 yDiff; s32 i; s32 cueChannel; - if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_505)) { - cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_505); + if (Cutscene_IsCueInChannel(play, CS_CMD_ACTOR_CUE_SOTCS)) { + cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_SOTCS); this->cueId = play->csCtx.actorCues[cueChannel]->id; switch (this->cueId) { - case 1: + case SOTCS_CUEID_DOUBLE_WAIT: break; - case 2: - this->unk_276 = 0; - this->unk_278 = 0; - this->unk_27C = 0; + case SOTCS_CUEID_DOUBLE_INIT: + this->drawType = SOTCS_DRAW_DOUBLE_SOT; + this->counter = 0; + this->clockAngle = 0; player->actor.shape.shadowDraw = NULL; if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_154 = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockSpeed = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { - this->unk_154 = 150.0f; + this->clockSpeed = 150.0f; } if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { - this->unk_280 = play->csCtx.actorCues[cueChannel]->startPos.y; + this->clockColorGray = play->csCtx.actorCues[cueChannel]->startPos.y; } else { - this->unk_280 = 38; + this->clockColorGray = 38; } if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { - this->unk_150 = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; + this->clockDist = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { - this->unk_150 = 480.0f; + this->clockDist = 480.0f; } break; - case 3: + case SOTCS_CUEID_DOUBLE_CLOCKS_INWARD: if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_154 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockSpeed += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { - this->unk_280 += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; + this->clockColorGray += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; } else { - this->unk_280 += 6; + this->clockColorGray += 6; } if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { - this->unk_158 = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; + this->clockRadialSpeed = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { - this->unk_158 = -32.0f; + this->clockRadialSpeed = -32.0f; } - this->unk_150 += this->unk_158; + this->clockDist += this->clockRadialSpeed; break; - case 4: + case SOTCS_CUEID_DOUBLE_CLOCKS_SPIN: if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_154 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockSpeed += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { - this->unk_280 += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; + this->clockColorGray += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; } else { - this->unk_280 -= 4; + this->clockColorGray -= 4; } break; - case 5: + case SOTCS_CUEID_DOUBLE_CLOCKS_OUTWARD: if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_154 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockSpeed += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { - this->unk_280 += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; + this->clockColorGray += (s16)play->csCtx.actorCues[cueChannel]->startPos.y; } else { - this->unk_280 -= 8; + this->clockColorGray -= 8; } if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { - this->unk_158 += (u32)play->csCtx.actorCues[cueChannel]->startPos.z; + this->clockRadialSpeed += (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { - this->unk_158 += 20.0f; + this->clockRadialSpeed += 20.0f; } - this->unk_150 += this->unk_158; - if (this->unk_150 > 3500.0f) { - this->unk_150 = 3500.0f; - this->cueId = 0; + this->clockDist += this->clockRadialSpeed; + if (this->clockDist > 3500.0f) { + this->clockDist = 3500.0f; + this->cueId = SOTCS_CUEID_NONE; } break; - case 6: - this->unk_276 = 1; - this->unk_278 = 0; - this->unk_27C = 0; + case SOTCS_CUEID_RESET_INIT: + this->drawType = SOTCS_DRAW_RESET_CYCLE_SOT; + this->counter = 0; + this->clockAngle = 0; player->actor.shape.shadowDraw = NULL; if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_154 = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockSpeed = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { - this->unk_154 = 100.0f; + this->clockSpeed = 100.0f; } if (play->csCtx.actorCues[cueChannel]->startPos.y != 0) { - this->unk_14C = (u32)play->csCtx.actorCues[cueChannel]->startPos.y; + this->speed = (u32)play->csCtx.actorCues[cueChannel]->startPos.y; } else { - this->unk_14C = 20.0f; + this->speed = 20.0f; } if (play->csCtx.actorCues[cueChannel]->startPos.z != 0) { - this->unk_150 = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; + this->clockDist = (u32)play->csCtx.actorCues[cueChannel]->startPos.z; } else { - this->unk_150 = 300.0f; + this->clockDist = 300.0f; } - this->unk_158 = 0.0f; + this->clockAccel = 0.0f; break; - case 7: + case SOTCS_CUEID_RESET_CLOCKS_SLOW_DOWN: if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_158 = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockAccel = (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { - this->unk_158 = -5.0f; + this->clockAccel = -5.0f; } - this->unk_154 += this->unk_158; + this->clockSpeed += this->clockAccel; break; - case 8: + case SOTCS_CUEID_RESET_CLOCKS_SPEED_UP: if (play->csCtx.actorCues[cueChannel]->startPos.x != 0) { - this->unk_158 += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; + this->clockAccel += (u32)play->csCtx.actorCues[cueChannel]->startPos.x; } else { - this->unk_158 += 2.0f; + this->clockAccel += 2.0f; } - this->unk_154 += this->unk_158; - if (this->unk_154 > 10000.0f) { - this->unk_154 = 10000.0f; - this->cueId = 0; + this->clockSpeed += this->clockAccel; + if (this->clockSpeed > 10000.0f) { + this->clockSpeed = 10000.0f; + this->cueId = SOTCS_CUEID_NONE; } break; - case 0: + case SOTCS_CUEID_NONE: default: - this->unk_276 = 99; + this->drawType = SOTCS_DRAW_TYPE_NONE; return; - case 9: - Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entrance & 0xFFFF), player->unk_3CE, - PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0, player->unk_3CC); - this->unk_276 = 99; + case SOTCS_CUEID_DOUBLE_END: + Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, ((void)0, gSaveContext.save.entrance), + player->unk_3CE, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0, + player->unk_3CC); + this->drawType = SOTCS_DRAW_TYPE_NONE; play->transitionTrigger = TRANS_TRIGGER_START; play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; play->transitionType = TRANS_TYPE_FADE_BLACK; if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { gSaveContext.respawnFlag = -0x63; - SET_EVENTINF(EVENTINF_27); + SET_EVENTINF(EVENTINF_TRIGGER_DAYTELOP); } else { gSaveContext.respawnFlag = 2; } @@ -1016,74 +1096,74 @@ void func_80A92950(EnTest6* this, PlayState* play) { } } else { switch (this->cueId) { - case 2: - this->unk_276 = 0; - this->unk_278 = 0; - this->unk_27C = 0; + case SOTCS_CUEID_DOUBLE_INIT: + this->drawType = SOTCS_DRAW_DOUBLE_SOT; + this->counter = 0; + this->clockAngle = 0; player->actor.shape.shadowDraw = NULL; - this->unk_280 = 38; - this->unk_154 = 150.0f; - this->unk_150 = 480.0f; + this->clockColorGray = 38; + this->clockSpeed = 150.0f; + this->clockDist = 480.0f; - case 1: + case SOTCS_CUEID_DOUBLE_WAIT: break; - case 3: - this->unk_158 = -32.0f; - this->unk_280 += 6; - this->unk_150 += -32.0f; + case SOTCS_CUEID_DOUBLE_CLOCKS_INWARD: + this->clockRadialSpeed = -32.0f; + this->clockColorGray += 6; + this->clockDist += -32.0f; break; - case 4: - this->unk_280 -= 4; + case SOTCS_CUEID_DOUBLE_CLOCKS_SPIN: + this->clockColorGray -= 4; break; - case 5: - this->unk_280 -= 8; - this->unk_158 += 20.0f; - this->unk_150 += this->unk_158; - if (this->unk_150 > 3500.0f) { - this->unk_150 = 3500.0f; - this->cueId = 0; + case SOTCS_CUEID_DOUBLE_CLOCKS_OUTWARD: + this->clockColorGray -= 8; + this->clockRadialSpeed += 20.0f; + this->clockDist += this->clockRadialSpeed; + if (this->clockDist > 3500.0f) { + this->clockDist = 3500.0f; + this->cueId = SOTCS_CUEID_NONE; } break; - case 6: - this->unk_276 = 1; - this->unk_278 = 0; - this->unk_27C = 0; + case SOTCS_CUEID_RESET_INIT: + this->drawType = SOTCS_DRAW_RESET_CYCLE_SOT; + this->counter = 0; + this->clockAngle = 0; player->actor.shape.shadowDraw = NULL; - this->unk_154 = 100.0f; - this->unk_14C = 20.0f; - this->unk_150 = 300.0f; - this->unk_158 = 0.0f; + this->clockSpeed = 100.0f; + this->speed = 20.0f; + this->clockDist = 300.0f; + this->clockAccel = 0.0f; break; - case 7: - this->unk_158 = -5.0f; - this->unk_154 += -5.0f; + case SOTCS_CUEID_RESET_CLOCKS_SLOW_DOWN: + this->clockAccel = -5.0f; + this->clockSpeed += -5.0f; break; - case 8: - this->unk_158 += 2.0f; - this->unk_154 += this->unk_158; - if (this->unk_154 > 10000.0f) { - this->unk_154 = 10000.0f; - this->cueId = 0; + case SOTCS_CUEID_RESET_CLOCKS_SPEED_UP: + this->clockAccel += 2.0f; + this->clockSpeed += this->clockAccel; + if (this->clockSpeed > 10000.0f) { + this->clockSpeed = 10000.0f; + this->cueId = SOTCS_CUEID_NONE; } break; - case 0: + case SOTCS_CUEID_NONE: default: - this->unk_276 = 99; + this->drawType = SOTCS_DRAW_TYPE_NONE; return; - case 9: + case SOTCS_CUEID_DOUBLE_END: if (gSaveContext.save.time > CLOCK_TIME(12, 0)) { - Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entrance & 0xFFFF), + Play_SetRespawnData(&play->state, RESPAWN_MODE_RETURN, ((void)0, gSaveContext.save.entrance), player->unk_3CE, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0, player->unk_3CC); - this->unk_276 = 99; + this->drawType = SOTCS_DRAW_TYPE_NONE; play->transitionTrigger = TRANS_TRIGGER_START; play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance; play->transitionType = TRANS_TYPE_FADE_BLACK; @@ -1094,229 +1174,246 @@ void func_80A92950(EnTest6* this, PlayState* play) { } } - if (this->unk_276 == 1) { - for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { - D_80A94910[i].unk_08 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); - D_80A94910[i].unk_10 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); - D_80A94910[i].unk_0C += 3.0f; + if (this->drawType == SOTCS_DRAW_RESET_CYCLE_SOT) { + for (i = 0; i < ARRAY_COUNT(sSoTCsAmmoDrops); i++) { + sSoTCsAmmoDrops[i].pos.x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + sSoTCsAmmoDrops[i].pos.z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + sSoTCsAmmoDrops[i].pos.y += 3.0f; - if (player->actor.world.pos.y < D_80A94910[i].unk_0C) { - temp_f0 = D_80A94910[i].unk_0C - player->actor.world.pos.y; - if (temp_f0 > 550.0f) { - temp_f0 = 1.0f; + if (player->actor.world.pos.y < sSoTCsAmmoDrops[i].pos.y) { + yDiff = sSoTCsAmmoDrops[i].pos.y - player->actor.world.pos.y; + if (yDiff > 550.0f) { + yDiff = 1.0f; } else { - temp_f0 = temp_f0 / 550.0f; + yDiff /= 550.0f; } - D_80A94910[i].unk_04 = SQ(temp_f0); + sSoTCsAmmoDrops[i].scale = SQ(yDiff); } else { - D_80A94910[i].unk_04 = -10.0f; + sSoTCsAmmoDrops[i].scale = -10.0f; } } } - this->unk_278++; + this->counter++; } -void func_80A93298(EnTest6* this, PlayState* play) { - s16 temp_s3; - s16 temp_s4; - f32 phi_f24; - s16 phi_s2; +/** + * Draws clocks in a double spiral above and below player + */ +void EnTest6_DrawThreeDayResetSoTCutscene(EnTest6* this, PlayState* play) { + s16 clock1Yaw; + s16 clock2Yaw; + s16 angle; s32 i; - f32 cos; - f32 sin; + Vec3f clockPos; OPEN_DISPS(play->state.gfxCtx); - this->unk_148 = POLY_OPA_DISP; - phi_f24 = 0.0f; + this->gfx = POLY_OPA_DISP; + clockPos.y = 0.0f; - temp_s3 = this->unk_27C; - temp_s4 = (s32)(Math_SinS(play->state.frames) * 12000.0f) + temp_s3 + 0x4E20; - phi_s2 = (play->state.frames & 0x3C) * 1024; - phi_s2 *= (this->unk_154 / 200.0f); - this->unk_27C += (s16)this->unk_154; - this->unk_27E = (s16)((this->unk_154 / 200.0f) * 256.0f); + clock1Yaw = this->clockAngle; + clock2Yaw = clock1Yaw + 0x4E20 + (s32)(0x2EE0 * Math_SinS(play->state.frames)); + // The `& 0x3C` ensures the angle only updates once every 4 frames + angle = (play->state.frames & 0x3C) * 1024; + angle *= this->clockSpeed / 200.0f; + this->clockAngle += (s16)this->clockSpeed; + this->clockRingRotZ = (s16)((this->clockSpeed / 200.0f) * 256.0f); - for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { - temp_s3 += 0x1000; - cos = Math_CosS(temp_s3) * this->unk_150; - sin = Math_SinS(temp_s3) * this->unk_150; - Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + // Draw 2 clocks per loop + for (i = 0; i < (SOTCS_RESET_NUM_CLOCKS / 2); i++) { + // Clock 1 + clock1Yaw += 0x1000; + clockPos.x = Math_CosS(clock1Yaw) * this->clockDist; + clockPos.z = Math_SinS(clock1Yaw) * this->clockDist; + Matrix_Translate(clockPos.x, clockPos.y, clockPos.z, MTXMODE_NEW); Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_RotateZS(phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(angle, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); - gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); - gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); - gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); + gSPMatrix(this->gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->gfx++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->gfx++, 255, 255, 255, 255); + gDPSetRenderMode(this->gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->gfx++, gSongOfTimeClockDL); - temp_s4 += 0x1000; - cos = Math_CosS(temp_s4) * this->unk_150; - sin = Math_SinS(temp_s4) * this->unk_150; - Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + // Clock 2 + clock2Yaw += 0x1000; + clockPos.x = Math_CosS(clock2Yaw) * this->clockDist; + clockPos.z = Math_SinS(clock2Yaw) * this->clockDist; + Matrix_Translate(clockPos.x, clockPos.y, clockPos.z, MTXMODE_NEW); Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_RotateZS(-phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(-angle, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); - gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); - gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); - gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); + gSPMatrix(this->gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->gfx++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->gfx++, 255, 255, 255, 255); + gDPSetRenderMode(this->gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->gfx++, gSongOfTimeClockDL); - phi_f24 -= this->unk_14C; - phi_s2 += this->unk_27E; + clockPos.y -= this->speed; + angle += this->clockRingRotZ; } - POLY_OPA_DISP = this->unk_148; + POLY_OPA_DISP = this->gfx; - for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { - if (D_80A94910[i].unk_04 > 0.0f) { - D_80A94910[i].unk_14(this, play, &D_80A94910[i]); + for (i = 0; i < ARRAY_COUNT(sSoTCsAmmoDrops); i++) { + if (sSoTCsAmmoDrops[i].scale > 0.0f) { + sSoTCsAmmoDrops[i].draw(this, play, &sSoTCsAmmoDrops[i]); } } CLOSE_DISPS(play->state.gfxCtx); } -void func_80A9369C(Actor* thisx, PlayState* play2) { - EnTest6* this = THIS; - PlayState* play = play2; - f32 temp_f20; - f32 temp_f22; - f32 phi_f26; - s16 phi_s2; - s16 sp78; +/** + * Draws clocks in a ring that spins around player + */ +void EnTest6_DrawDoubleSoTCutscene(EnTest6* this, PlayState* play) { + s32 pad1[2]; + Vec3f clockPos; + s16 clockRotX; + s16 clockNormalAngle; s32 i; Player* player = GET_PLAYER(play); - s32 pad; - - if (this) {} + s32 pad2; OPEN_DISPS(play->state.gfxCtx); - this->unk_148 = POLY_OPA_DISP; - this->unk_27C += (s16)this->unk_154; - this->unk_27E = this->unk_27C * 2; - sp78 = (play->state.frames & 0x3C) * 1024; - phi_s2 = this->unk_27C + 0x4000; + this->gfx = POLY_OPA_DISP; + this->clockAngle += (s16)this->clockSpeed; + this->clockRingRotZ = this->clockAngle * 2; + // The `& 0x3C` ensures the clock only turns once every 4 frames. + // Each turn rotates the clock 22.5 degrees (0x10000 / 64 * 4) + // clockNormalAngle = (play->state.frames & 0x3C) * ((0x10000 / 64 * 4) / 4); + clockNormalAngle = (play->state.frames & 0x3C) * (DEG_TO_BINANG(22.5f) / 4); + clockRotX = this->clockAngle + 0x4000; + + // All cases have the exact same code switch (player->transformation) { - default: - phi_f26 = player->actor.world.pos.y + 40.0f; - break; - case PLAYER_FORM_DEKU: - phi_f26 = player->actor.world.pos.y + 40.0f; + clockPos.x = player->actor.world.pos.y + 40.0f; break; case PLAYER_FORM_GORON: - phi_f26 = player->actor.world.pos.y + 40.0f; + clockPos.x = player->actor.world.pos.y + 40.0f; break; case PLAYER_FORM_ZORA: - phi_f26 = player->actor.world.pos.y + 40.0f; + clockPos.x = player->actor.world.pos.y + 40.0f; break; case PLAYER_FORM_FIERCE_DEITY: - phi_f26 = player->actor.world.pos.y + 40.0f; + clockPos.x = player->actor.world.pos.y + 40.0f; + break; + + default: + clockPos.x = player->actor.world.pos.y + 40.0f; break; } - for (i = 0; i < 51; i++) { - temp_f20 = Math_CosS(phi_s2) * this->unk_150; - temp_f22 = Math_SinS(phi_s2) * this->unk_150; - Matrix_RotateZS(this->unk_27E, MTXMODE_NEW); - Matrix_Translate(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + // Draw clocks + for (i = 0; i < SOTCS_DOUBLE_NUM_CLOCKS; i++) { + clockPos.y = Math_CosS(clockRotX) * this->clockDist; + clockPos.z = Math_SinS(clockRotX) * this->clockDist; + // Rotate the entire clock ring + Matrix_RotateZS(this->clockRingRotZ, MTXMODE_NEW); + + Matrix_Translate(clockPos.x, clockPos.y, clockPos.z, MTXMODE_APPLY); Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); - Matrix_RotateXS(phi_s2, MTXMODE_APPLY); - Matrix_RotateZS(sp78, MTXMODE_APPLY); + // Orient the clock so the plane it's drawn on also passes through player + Matrix_RotateXS(clockRotX, MTXMODE_APPLY); + // Rotate around the normal of the plane, so the clock plane does not change, + // the drawn shape is spun internally + Matrix_RotateZS(clockNormalAngle, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); - gDPSetEnvColor(this->unk_148++, 235, 238, 235, 255); - gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); - gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); + gSPMatrix(this->gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->gfx++, 0, 0xFF, this->clockColorGray, this->clockColorGray, this->clockColorGray, 255); + gDPSetEnvColor(this->gfx++, 235, 238, 235, 255); + gDPSetRenderMode(this->gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->gfx++, gSongOfTimeClockDL); - phi_s2 += 0x505; + clockRotX += 0x10000 / SOTCS_DOUBLE_NUM_CLOCKS; } Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, player->actor.world.pos.z); Lights_PointSetColorAndRadius(&this->lights[0].info, 100, 250, 100, 200); - POLY_OPA_DISP = this->unk_148; + POLY_OPA_DISP = this->gfx; CLOSE_DISPS(play->state.gfxCtx); } -void func_80A939E8(EnTest6* this, PlayState* play2) { +/** + * Draws clocks flat on the ground. + * Also draws black particles that raise or fall to indicate if time is speeding up or slowing down + */ +void EnTest6_DrawInvertedSoTCutscene(EnTest6* this, PlayState* play2) { PlayState* play = play2; Player* player = GET_PLAYER(play); - f32 temp_f20; + f32 flashScale; s32 i; OPEN_DISPS(play->state.gfxCtx); switch (this->cueId) { - case 91: - case 93: + case SOTCS_CUEID_INV_SETUP_CLOCKS: + case SOTCS_CUEID_INV_UNUSED: Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, player->actor.world.pos.z); - Lights_PointSetColorAndRadius(&this->lights[0].info, 245, 245, 200, this->unk_282); + Lights_PointSetColorAndRadius(&this->lights[0].info, 245, 245, 200, this->alpha); break; - case 95: - this->unk_148 = POLY_XLU_DISP; + case SOTCS_CUEID_INV_CLOCKS: + this->gfx = POLY_XLU_DISP; - for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { - Matrix_Translate(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + // Draw clocks + for (i = 0; i < ARRAY_COUNT(this->invSoTClockPos); i++) { + Matrix_Translate(this->invSoTClockPos[i].x, this->invSoTClockPos[i].y, this->invSoTClockPos[i].z, + MTXMODE_NEW); Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); Matrix_RotateXS(-0x4000, MTXMODE_APPLY); - Matrix_RotateZS(this->unk_278, MTXMODE_APPLY); + Matrix_RotateZS(this->invSoTClockYaw, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); - gDPSetEnvColor(this->unk_148++, 245, 245, 200, this->unk_282); - gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); - gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); + gSPMatrix(this->gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->gfx++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->gfx++, 245, 245, 200, this->alpha); + gDPSetRenderMode(this->gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gSPDisplayList(this->gfx++, gSongOfTimeClockDL); - POLY_XLU_DISP = this->unk_148; + POLY_XLU_DISP = this->gfx; } - if (this->unk_254 != NULL) { - for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { - temp_f20 = Rand_ZeroOne() * 0.0025f; - Matrix_Translate((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, MTXMODE_NEW); - Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + // Draw black particles + if (this->invSoTParticles != NULL) { + for (i = 0; i < SOTCS_NUM_PARTICLES; i++) { + flashScale = Rand_ZeroOne() * 0.0025f; + Matrix_Translate((*this->invSoTParticles)[i].x, (*this->invSoTParticles)[i].y, + (*this->invSoTParticles)[i].z, MTXMODE_NEW); + Matrix_Scale(flashScale, flashScale, flashScale, MTXMODE_APPLY); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); - gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->alpha >> 1); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->alpha); Gfx_SetupDL25_Xlu(play->state.gfxCtx); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZS(this->unk_278 + (i << 2), MTXMODE_APPLY); + Matrix_RotateZS(this->invSoTClockYaw + (i << 2), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } } + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, player->actor.world.pos.z); - Lights_PointSetColorAndRadius(&this->lights[0].info, 250, 250, 100, this->unk_282); + Lights_PointSetColorAndRadius(&this->lights[0].info, 250, 250, 100, this->alpha); break; - case 90: - case 92: - case 94: - case 96: - case 97: - case 98: - case 99: + case SOTCS_CUEID_INV_INIT: + case SOTCS_CUEID_INV_END: break; } @@ -1326,18 +1423,21 @@ void func_80A939E8(EnTest6* this, PlayState* play2) { void EnTest6_Draw(Actor* thisx, PlayState* play) { EnTest6* this = THIS; - if (this->cueId != 0) { - switch (this->unk_276) { - case 1: - func_80A93298(this, play); + if (this->cueId != SOTCS_CUEID_NONE) { + switch (this->drawType) { + case SOTCS_DRAW_RESET_CYCLE_SOT: + EnTest6_DrawThreeDayResetSoTCutscene(this, play); break; - case 0: - func_80A9369C(thisx, play); + case SOTCS_DRAW_DOUBLE_SOT: + EnTest6_DrawDoubleSoTCutscene(this, play); break; - case 2: - func_80A939E8(this, play); + case SOTCS_DRAW_INVERTED_SOT: + EnTest6_DrawInvertedSoTCutscene(this, play); + break; + + default: break; } } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index 2fe138ddb..726e23dc5 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -7,46 +7,71 @@ struct EnTest6; typedef void (*EnTest6ActionFunc)(struct EnTest6*, PlayState*); -#define ENTEST6_GET(thisx) ((thisx)->params) +#define SOTCS_GET_OCARINA_MODE(thisx) ((thisx)->params) -typedef enum { - /* 24 */ ENTEST6_24 = 24, - /* 25 */ ENTEST6_25, - /* 26 */ ENTEST6_26 -} EnTest6Param; +// CueIds are a mix of cues from external cutscenes and internal states + +typedef enum SoTCsCueId { + /* 0x00 */ SOTCS_CUEID_NONE, + /* 0x01 */ SOTCS_CUEID_DOUBLE_WAIT, + /* 0x02 */ SOTCS_CUEID_DOUBLE_INIT, + /* 0x03 */ SOTCS_CUEID_DOUBLE_CLOCKS_INWARD, + /* 0x04 */ SOTCS_CUEID_DOUBLE_CLOCKS_SPIN, + /* 0x05 */ SOTCS_CUEID_DOUBLE_CLOCKS_OUTWARD, + /* 0x06 */ SOTCS_CUEID_RESET_INIT, + /* 0x07 */ SOTCS_CUEID_RESET_CLOCKS_SLOW_DOWN, + /* 0x08 */ SOTCS_CUEID_RESET_CLOCKS_SPEED_UP, + /* 0x09 */ SOTCS_CUEID_DOUBLE_END, + /* 0x5A */ SOTCS_CUEID_INV_INIT = 90, + /* 0x5B */ SOTCS_CUEID_INV_SETUP_CLOCKS, + /* 0x5D */ SOTCS_CUEID_INV_UNUSED = 93, + /* 0x5F */ SOTCS_CUEID_INV_CLOCKS = 95, + /* 0x63 */ SOTCS_CUEID_INV_END = 99 +} SoTCsCueId; typedef struct { - /* 0x00 */ LightNode* node; - /* 0x04 */ LightInfo info; -} EnTest6Light; // size = 0x14 + /* 0x0 */ LightNode* node; + /* 0x4 */ LightInfo info; +} SoTCsLight; // size = 0x14 + +#define SOTCS_INV_NUM_CLOCKS 6 +#define SOTCS_DOUBLE_NUM_CLOCKS 51 +#define SOTCS_RESET_NUM_CLOCKS 128 +#define SOTCS_NUM_PARTICLES 64 typedef struct EnTest6 { /* 0x000 */ Actor actor; /* 0x144 */ EnTest6ActionFunc actionFunc; - /* 0x148 */ Gfx* unk_148; - /* 0x14C */ f32 unk_14C; - /* 0x150 */ f32 unk_150; - /* 0x154 */ f32 unk_154; - /* 0x158 */ f32 unk_158; - /* 0x15C */ f32 unk_15C; - /* 0x160 */ f32 unk_160; - /* 0x164 */ EnTest6Light lights[2]; - /* 0x18C */ CutsceneCamera unk_18C; - /* 0x20C */ Vec3f unk_20C[6]; - /* 0x254 */ Vec3f (*unk_254)[64]; + /* 0x148 */ Gfx* gfx; + /* 0x14C */ f32 speed; // Used for clock distance and lights + /* 0x150 */ f32 clockDist; // Radius from player + /* 0x154 */ f32 clockSpeed; + /* 0x158 */ union { + f32 clockRadialSpeed; // For double SoT cutscene + f32 clockAccel; // For reset SoT cutscene + }; + /* 0x15C */ f32 invSoTEnvLerp; + /* 0x160 */ f32 doubleSoTEnvLerp; + /* 0x164 */ SoTCsLight lights[2]; + /* 0x18C */ CutsceneCamera csCamInfo; + /* 0x20C */ Vec3f invSoTClockPos[SOTCS_INV_NUM_CLOCKS]; + /* 0x254 */ Vec3f (*invSoTParticles)[SOTCS_NUM_PARTICLES]; /* 0x258 */ Vec3f subCamAt; /* 0x264 */ Vec3f subCamEye; /* 0x270 */ f32 subCamFov; /* 0x274 */ s16 cueId; - /* 0x276 */ s16 unk_276; - /* 0x278 */ s16 unk_278; - /* 0x27A */ s16 unk_27A; - /* 0x27C */ s16 unk_27C; - /* 0x27E */ s16 unk_27E; - /* 0x280 */ s16 unk_280; - /* 0x282 */ s16 unk_282; + /* 0x276 */ s16 drawType; + /* 0x278 */ union { + s16 invSoTClockYaw; // For inverted SoT cutscene. + s16 counter; // For double/reset SoT cutscenes. Increments every frame, unused. + }; + /* 0x27A */ s16 timer; + /* 0x27C */ s16 clockAngle; + /* 0x27E */ s16 clockRingRotZ; // For double/reset SoT cutscenes + /* 0x280 */ s16 clockColorGray; // For double SoT cutscene + /* 0x282 */ s16 alpha; /* 0x284 */ s16 subCamId; - /* 0x286 */ s16 unk_286; + /* 0x286 */ s16 screenFillAlpha; // As a ratio, 20 is an alpha of 255 } EnTest6; // size = 0x288 #endif // Z_EN_TEST6_H diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index 2606331e2..fefe92672 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -364,14 +364,13 @@ void func_80AF14FC(PlayState* play2, EnTest7Struct2* arg1) { } temp_v0 = Matrix_NewMtx(play->state.gfxCtx); - if (temp_v0 != NULL) { - gSPMatrix(POLY_OPA_DISP++, temp_v0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_081628); + if (temp_v0 == NULL) { + continue; } + gSPMatrix(POLY_OPA_DISP++, temp_v0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_081628); } - if (ptr) {} - Matrix_Pop(); CLOSE_DISPS(play->state.gfxCtx); @@ -444,13 +443,13 @@ void func_80AF19A8(EnTest7* this, PlayState* play) { } void func_80AF1A2C(EnTest7* this, PlayState* play) { - Color_RGB8 sp34 = { 64, 0, 0 }; - Color_RGB8 sp30 = { 220, 220, 255 }; - f32 sp2C = this->unk_1E54 / 10.0f; + Color_RGB8 fogColor = { 64, 0, 0 }; + Color_RGB8 ambientColor = { 220, 220, 255 }; + f32 envLerp = this->unk_1E54 / 10.0f; - func_800FD59C(play, &sp30, sp2C); - func_800FD654(play, &sp34, sp2C); - func_800FD698(play, 2000, 4000, sp2C); + Environment_LerpAmbientColor(play, &ambientColor, envLerp); + Environment_LerpFogColor(play, &fogColor, envLerp); + Environment_LerpFog(play, 2000, 4000, envLerp); if (this->unk_1E54 >= 10) { Camera* subCam = @@ -611,9 +610,9 @@ void func_80AF2030(EnTest7* this, PlayState* play) { void func_80AF21E8(EnTest7* this, PlayState* play) { s32 sp2C = this->unk_1E54 - 100; - f32 sp1C; - Color_RGB8 sp24 = { 64, 0, 0 }; - Color_RGB8 sp20 = { 220, 220, 255 }; + f32 envLerp; + Color_RGB8 fogColor = { 64, 0, 0 }; + Color_RGB8 ambientColor = { 220, 220, 255 }; if (R_PLAY_FILL_SCREEN_ON) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_VANISH); @@ -624,10 +623,10 @@ void func_80AF21E8(EnTest7* this, PlayState* play) { R_PLAY_FILL_SCREEN_ALPHA = 0; } - sp1C = 1.0f - (sp2C / 10.0f); - func_800FD59C(play, &sp20, sp1C); - func_800FD654(play, &sp24, sp1C); - func_800FD698(play, 2000, 4000, sp1C); + envLerp = 1.0f - (sp2C / 10.0f); + Environment_LerpAmbientColor(play, &ambientColor, envLerp); + Environment_LerpFogColor(play, &fogColor, envLerp); + Environment_LerpFog(play, 2000, 4000, envLerp); if (this->unk_1E54 >= 110) { func_80AF082C(this, func_80AF2318); diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index b756d0f92..a86359610 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -4,7 +4,6 @@ * Description: Beaver Race Ring */ -#include "prevent_bss_reordering.h" #include "z_en_twig.h" #include "objects/object_twig/object_twig.h" diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 06893449e..dd1fa60e1 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -208,8 +208,8 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, PlayState* play) { // why are we getting player home rotation from the room data? doesnt player have home.rot.y? // especially because we are converting from deg to binang, but isnt home.rot.y already in binang?? - Play_SetRespawnData(&play->state, 0, entrance, play->setupEntranceList[playerSpawnIndex].room, - playerParams, &newRespawnPos, + Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, entrance, + play->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, DEG_TO_BINANG_ALT((playerActorEntry->rot.y >> 7) & 0x1FF)); func_80169EFC(&play->state); diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 435674539..208422b2f 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -1285,8 +1285,8 @@ void EnWiz_UpdateDamage(EnWiz* this, PlayState* play) { //! colliders are effectively disabled, this doesn't cause any problems in the final //! game, but it becomes an issue if the ghost colliders are enabled. this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; - this->ghostColliders.base.acFlags &= ~BUMP_HIT; - if (this->ghostPos[i].x != .0f || this->ghostPos[i].z != .0f) { + this->ghostColliders.base.acFlags &= ~AC_HIT; + if ((this->ghostPos[i].x != .0f) || (this->ghostPos[i].z != .0f)) { for (j = 0; j < 9; j++) { accel.x = 0.0f; accel.y = 1.0f; diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index e6fc7e776..12d06e487 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -573,7 +573,7 @@ void EnWizFire_Update(Actor* thisx, PlayState* play2) { DECR(this->steamSpawnTimer); DECR(this->poolTimer); - Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10.0f, UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); 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 4710b8908..fb219bfee 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -4,7 +4,6 @@ * Description: Sakon's Hideout Objects (Sun's Mask, doors, etc) */ -#include "prevent_bss_reordering.h" #include "z_obj_nozoki.h" #include "objects/object_secom_obj/object_secom_obj.h" 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 bf409e7dd..1cab193db 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -509,7 +509,7 @@ void ObjSwitch_FloorSwitchUp(ObjSwitch* this, PlayState* play) { if (OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR_RUSTY) { if (this->colliderTris.base.acFlags & AC_HIT) { - this->colliderTris.base.acFlags &= ~AT_HIT; + this->colliderTris.base.acFlags &= ~AC_HIT; ObjSwitch_TryPlayCutsceneInit(this, play, ObjSwitch_FloorSwitchPushDownInit, true); } else { CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index 7de628750..641d49f49 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -72,7 +72,7 @@ void OceffWipe2_Draw(Actor* thisx, PlayState* play) { vtxPtr = sEponaSongFrustumVtx; if (this->timer < 32) { - z = Math_SinS(this->timer << 9) * 1220.0f; + z = Math_SinS(this->timer * 0x200) * 1220.0f; } else { z = 1220.0f; } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index b90d87462..0670563c0 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -466,12 +466,12 @@ typedef struct { } ExplosiveInfo; // size = 0x4 typedef struct { - /* 0x0 */ Color_RGB8 unk_0; - /* 0x3 */ Color_RGB8 unk_3; - /* 0x6 */ Color_RGB8 unk_6; - /* 0xA */ s16 unk_A; - /* 0xC */ s16 unk_C; -} struct_8082F02C_arg1; // size = 0xE + /* 0x0 */ Color_RGB8 ambientColor; + /* 0x3 */ Color_RGB8 diffuseColor; + /* 0x6 */ Color_RGB8 fogColor; + /* 0xA */ s16 fogNear; + /* 0xC */ s16 zFar; +} PlayerEnvLighting; // size = 0xE typedef struct GetItemEntry { /* 0x0 */ u8 itemId; @@ -2714,11 +2714,11 @@ PlayerAnimationHeader* func_8082EFE4(Player* this) { } } -void func_8082F02C(PlayState* play, struct_8082F02C_arg1* arg1, f32 arg2) { - func_800FD59C(play, &arg1->unk_0, arg2); - func_800FD5E0(play, &arg1->unk_3, arg2); - func_800FD654(play, &arg1->unk_6, arg2); - func_800FD698(play, arg1->unk_A, arg1->unk_C, arg2); +void Player_LerpEnvLighting(PlayState* play, PlayerEnvLighting* lighting, f32 lerp) { + Environment_LerpAmbientColor(play, &lighting->ambientColor, lerp); + Environment_LerpDiffuseColor(play, &lighting->diffuseColor, lerp); + Environment_LerpFogColor(play, &lighting->fogColor, lerp); + Environment_LerpFog(play, lighting->fogNear, lighting->zFar, lerp); } /** @@ -2786,8 +2786,12 @@ void func_8082F164(Player* this, u16 button) { } } -struct_8082F02C_arg1 D_8085C98C = { - { 0, 0, 0 }, { 255, 255, 155 }, { 20, 20, 50 }, 940, 5000, +PlayerEnvLighting sZoraBarrierEnvLighting = { + { 0, 0, 0 }, // ambientColor + { 255, 255, 155 }, // diffuseColor + { 20, 20, 50 }, // fogColor + 940, // fogNear + 5000, // zFar }; // Run Zora Barrier @@ -2822,7 +2826,7 @@ void func_8082F1AC(PlayState* play, Player* this) { sp46 = play->gameplayFrames * 7000; sp44 = play->gameplayFrames * 14000; - func_8082F02C(play, &D_8085C98C, this->unk_B62 / 255.0f); + Player_LerpEnvLighting(play, &sZoraBarrierEnvLighting, this->unk_B62 / 255.0f); sp34 = Math_SinS(sp44) * 40.0f; sp40 = Math_CosS(sp44) * 40.0f; diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 6f207f8cd..c415d179e 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -2857,8 +2857,8 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->roll = -314.0f; pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); - size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + size0 = SEGMENT_ROM_SIZE(icon_item_static_syms); + CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_static_yar), pauseCtx->iconItemSegment, size0); gSegments[0x08] = VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); @@ -2869,8 +2869,8 @@ void KaleidoScope_Update(PlayState* play) { } pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); - size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); - CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, + size1 = SEGMENT_ROM_SIZE(icon_item_24_static_syms); + CmpDma_LoadAllFiles((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_yar), pauseCtx->iconItem24Segment, size1); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); @@ -3184,12 +3184,12 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItemSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); // Messed up ALIGN64 - size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + size0 = SEGMENT_ROM_SIZE(icon_item_static_syms); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_yar), pauseCtx->iconItemSegment, size0); pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); - size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); - CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); + size1 = SEGMENT_ROM_SIZE(icon_item_24_static_syms); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_24_static_yar), pauseCtx->iconItem24Segment, size1); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); size2 = SEGMENT_ROM_SIZE(icon_item_gameover_static); @@ -3432,8 +3432,8 @@ void KaleidoScope_Update(PlayState* play) { sPauseCursorRightX = 155; pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); - size0 = SEGMENT_ROM_SIZE(icon_item_static_old); - CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + size0 = SEGMENT_ROM_SIZE(icon_item_static_syms); + CmpDma_LoadAllFiles(SEGMENT_ROM_START(icon_item_static_yar), pauseCtx->iconItemSegment, size0); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); sInDungeonScene = false; diff --git a/tools/buildtools/.gitignore b/tools/buildtools/.gitignore index ecf2dd851..1119d9786 100644 --- a/tools/buildtools/.gitignore +++ b/tools/buildtools/.gitignore @@ -5,3 +5,4 @@ makeromfs mkldscript reloc_prereq yaz0 +makeyar diff --git a/tools/buildtools/Makefile b/tools/buildtools/Makefile index 6f34b5cfa..57c5d0542 100644 --- a/tools/buildtools/Makefile +++ b/tools/buildtools/Makefile @@ -1,6 +1,5 @@ -CC := gcc -CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2 -PROGRAMS := elf2rom makeromfs mkldscript reloc_prereq yaz0 +CFLAGS := -Wall -Wextra -Wpedantic -std=c99 -g -Os +PROGRAMS := elf2rom makeromfs mkldscript reloc_prereq yaz0 makeyar ifeq ($(shell command -v clang >/dev/null 2>&1; echo $$?),0) CC := clang @@ -8,15 +7,6 @@ else CC := gcc endif -LLD ?= 0 - -ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) - LLD := 1 -endif - -ifneq ($(LLD),0) - CFLAGS += -fuse-ld=lld -endif all: $(PROGRAMS) clean: @@ -27,6 +17,7 @@ makeromfs_SOURCES := makeromfs.c n64chksum.c util.c mkldscript_SOURCES := mkldscript.c spec.c util.c reloc_prereq_SOURCES := reloc_prereq.c spec.c util.c yaz0_SOURCES := yaz0tool.c yaz0.c util.c +makeyar_SOURCES := makeyar.c elf32.c yaz0.c util.c define COMPILE = $(1): $($1_SOURCES) diff --git a/tools/buildtools/elf32.c b/tools/buildtools/elf32.c index 7540406fb..64e6a9a1b 100644 --- a/tools/buildtools/elf32.c +++ b/tools/buildtools/elf32.c @@ -138,6 +138,7 @@ bool elf32_get_section(struct Elf32* e, struct Elf32_Section* sec, int secnum) { sec->flags = e->read32(sechdr + 0x08); sec->addr = e->read32(sechdr + 0x0C); sec->offset = e->read32(sechdr + 0x10); + sec->size = e->read32(sechdr + 0x14); sec->addralign = e->read32(sechdr + 0x20); sec->entsize = e->read32(sechdr + 0x24); return true; @@ -162,5 +163,8 @@ bool elf32_get_symbol(struct Elf32* e, struct Elf32_Symbol* sym, int symnum) { sym->name = strings + e->read32(symtab + symnum * 0x10); sym->value = e->read32(symtab + symnum * 0x10 + 4); + sym->size = e->read32(symtab + symnum * 0x10 + 8); + sym->st_type = symtab[symnum * 0x10 + 0xC] & 0xF; + sym->shndx = e->read16(symtab + symnum * 0x10 + 0xE); return true; } diff --git a/tools/buildtools/elf32.h b/tools/buildtools/elf32.h index 0dae635f2..f3de31358 100644 --- a/tools/buildtools/elf32.h +++ b/tools/buildtools/elf32.h @@ -3,6 +3,7 @@ #include #include +#include enum { ELF_MACHINE_NONE = 0, @@ -52,14 +53,31 @@ struct Elf32_Section { uint32_t type; uint32_t flags; uint32_t addr; + uint32_t size; uint32_t offset; uint32_t addralign; uint32_t entsize; }; +#define SHN_UNDEF 0 +#define SHN_ABS 0xFFF1 +#define SHN_COMMON 0xFFF2 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 +#define STT_NUM 7 + struct Elf32_Symbol { const char* name; uint32_t value; + uint32_t size; + uint8_t st_type; + uint16_t shndx; }; bool elf32_init(struct Elf32* e, const void* data, size_t size); diff --git a/tools/buildtools/makeyar.c b/tools/buildtools/makeyar.c new file mode 100644 index 000000000..6a241f6f5 --- /dev/null +++ b/tools/buildtools/makeyar.c @@ -0,0 +1,267 @@ +/* SPDX-FileCopyrightText: © 2023 ZeldaRET */ +/* SPDX-License-Identifier: MIT */ + +/** + * Program to generate compressed yar (Yaz0 ARchive) files. + * + * The program expects an .o elf file and outputs a raw yar binary file and a + * "symbols" elf. + * + * A yar file consists of multiple Yaz0 files compressed individually. The + * archive begins with a header of non-fixed size, which describes the + * location of each individual Yaz0 block within the archive itself. This + * header is followed by each Yaz0 file. + * + * The first word (a 4 byte group) of the header indicates the size in bytes of + * the header itself (also describes the offset of the first Yaz0 block). The + * rest of the header consists of words describing the offsets of each Yaz0 + * block relative to the end of the header, because the first Yaz0 + * block is omitted from the offsets in the header. + * + * Each Yaz0 block is 0xFF-padded to a multiple of 0x10 in size. + * + * The entire archive is 0-padded to a multiple of 0x10 in size. + * + * The program works by compressing each .data symbol in the input elf file as + * its own Yaz0 compressed file, appending them in order for the generated + * archive. Other elf sections are ignored for the resulting yar file. + * + * The program also outputs an elf file that's identical to the elf input, + * but with its .data section zero'ed out completely. This "symbols" elf can be + * used for referencing each symbol as the whole file were completely + * uncompressed. + */ + + +#include +#include +#include +#include +#include +#include + +#include "elf32.h" +#include "yaz0.h" +#include "util.h" + + +typedef struct Bytearray { + uint8_t *bytes; + size_t size; +} Bytearray; + +typedef struct SymbolList { + struct Elf32_Symbol *symbols; + size_t size; // allocated size + size_t len; // elements in the list +} SymbolList; + +typedef struct DataSection { + Bytearray data; + uint32_t dataOffset; + SymbolList symbols; +} DataSection; + + +void Bytearray_Init(Bytearray *bytearr, const uint8_t *bytes, size_t size) { + bytearr->bytes = malloc(size); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memcpy(bytearr->bytes, bytes, size); + bytearr->size = size; +} + +void Bytearray_InitValue(Bytearray *bytearr, uint8_t val, size_t count) { + bytearr->bytes = malloc(count * sizeof(uint8_t)); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memset(bytearr->bytes, val, count); + bytearr->size = count; +} + +void Bytearray_ExtendValue(Bytearray *bytearr, uint8_t val, size_t count) { + size_t newSize = bytearr->size + count; + + bytearr->bytes = realloc(bytearr->bytes, newSize); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memset(&bytearr->bytes[bytearr->size], val, count); + bytearr->size = newSize; +} + +void Bytearray_Extend(Bytearray *bytearr, const uint8_t *bytes, size_t size) { + size_t newSize = bytearr->size + size; + + bytearr->bytes = realloc(bytearr->bytes, newSize); + if (bytearr->bytes == NULL) { + util_fatal_error("memory error"); + } + + memcpy(&bytearr->bytes[bytearr->size], bytes, size); + bytearr->size = newSize; +} + +void Bytearray_Destroy(Bytearray *bytearr) { + free(bytearr->bytes); +} + +void SymbolList_Init(SymbolList *list, size_t initialAmount) { + list->symbols = malloc(initialAmount * sizeof(struct Elf32_Symbol)); + if (list->symbols == NULL) { + util_fatal_error("memory error"); + } + list->size = initialAmount; + list->len = 0; +} + +void SymbolList_Destroy(SymbolList *list) { + free(list->symbols); +} + +void DataSection_FromElf(DataSection *dst, const Bytearray *elfBytes){ + struct Elf32 elf; + size_t i; + int symIndex; + size_t dataShndx = 0; + + if (!elf32_init(&elf, elfBytes->bytes, elfBytes->size) || (elf.machine != ELF_MACHINE_MIPS)) { + util_fatal_error("not a valid 32-bit MIPS ELF file"); + } + + for (i = 0; i < elf.shnum; i++) { + struct Elf32_Section sec; + + if (!elf32_get_section(&elf, &sec, i)) { + util_fatal_error("invalid or corrupt ELF file"); + } + + if (strcmp(sec.name, ".data") == 0) { + dst->dataOffset = sec.offset; + Bytearray_Init(&dst->data, &elfBytes->bytes[sec.offset], sec.size); + dataShndx = i; + break; + } + } + + SymbolList_Init(&dst->symbols, elf.numsymbols); + for (symIndex = 0; symIndex < elf.numsymbols; symIndex++) { + struct Elf32_Symbol sym; + + if (!elf32_get_symbol(&elf, &sym, symIndex)) { + util_fatal_error("invalid or corrupt ELF file"); + } + + if (sym.shndx != dataShndx) { + continue; + } + if (sym.st_type != STT_OBJECT) { + continue; + } + + dst->symbols.symbols[dst->symbols.len++] = sym; + } +} + +void DataSection_Destroy(DataSection *dataSect) { + Bytearray_Destroy(&dataSect->data); + SymbolList_Destroy(&dataSect->symbols); +} + +#define ALIGN16(val) (((val) + 0xF) & ~0xF) + +void createArchive(Bytearray *archive, const DataSection *dataSect) { + uint32_t firstEntryOffset = (dataSect->symbols.len + 1) * sizeof(uint32_t); + size_t i; + size_t offset; + + // Fill with zeroes until the compressed data start + Bytearray_InitValue(archive, 0, firstEntryOffset); + + util_write_uint32_be(&archive->bytes[0], firstEntryOffset); + + offset = firstEntryOffset; + for (i = 0; i < dataSect->symbols.len; i++) { + const struct Elf32_Symbol *sym = &dataSect->symbols.symbols[i]; + size_t uncompressedSize = sym->size; + uint8_t *output = malloc(uncompressedSize * sizeof(uint8_t)); // assume compressed shouldn't be bigger than uncompressed + size_t compressedSize; + + output[0] = 'Y'; + output[1] = 'a'; + output[2] = 'z'; + output[3] = '0'; + util_write_uint32_be(&output[4], uncompressedSize); + memset(&output[8], 0, 8); + compressedSize = 0x10; + + assert(sym->value + uncompressedSize <= dataSect->data.size); + compressedSize += yaz0_encode(&dataSect->data.bytes[sym->value], &output[0x10], uncompressedSize); + + // Pad to 0x10 + while (compressedSize % 0x10 != 0) { + output[compressedSize++] = 0xFF; + } + + Bytearray_Extend(archive, output, compressedSize); + + if (i > 0) { + util_write_uint32_be(&archive->bytes[i * sizeof(uint32_t)], offset - firstEntryOffset); + } + + offset += compressedSize; + free(output); + } + + util_write_uint32_be(&archive->bytes[i * sizeof(uint32_t)], offset - firstEntryOffset); + + if (archive->size % 16 != 0) { + size_t extraPad = ALIGN16(archive->size) - archive->size; + + Bytearray_ExtendValue(archive, 0, extraPad); + } +} + + +int main(int argc, char *argv[]) { + const char *inPath; + const char *binPath; + const char *symPath; + Bytearray elfBytes; + DataSection dataSect; + Bytearray archive; + + if (argc != 4) { + fprintf(stderr, "%s in_file out_bin out_sym\n", argv[0]); + exit(1); + } + + inPath = argv[1]; + binPath = argv[2]; + symPath = argv[3]; + + elfBytes.bytes = util_read_whole_file(inPath, &elfBytes.size); + + DataSection_FromElf(&dataSect, &elfBytes); + + createArchive(&archive, &dataSect); + + // Write the compressed archive file as a raw binary + util_write_whole_file(binPath, archive.bytes, archive.size); + + // Zero out data + memset(&elfBytes.bytes[dataSect.dataOffset], 0, dataSect.data.size); + + util_write_whole_file(symPath, elfBytes.bytes, elfBytes.size); + + Bytearray_Destroy(&archive); + DataSection_Destroy(&dataSect); + Bytearray_Destroy(&elfBytes); + + return 0; +} diff --git a/tools/buildtools/yaz0.h b/tools/buildtools/yaz0.h index 97656aac5..50ac586bb 100644 --- a/tools/buildtools/yaz0.h +++ b/tools/buildtools/yaz0.h @@ -1,8 +1,6 @@ #ifndef YAZ0_H #define YAZ0_H -int yaz0_encode2(uint8_t* src, uint8_t* dest, int uncompressedSize); - void yaz0_decode(uint8_t* src, uint8_t* dst, int uncompressedSize); int yaz0_encode(uint8_t* src, uint8_t* dest, int srcSize); diff --git a/tools/decompress_yars.py b/tools/decompress_yars.py new file mode 100755 index 000000000..404a50c56 --- /dev/null +++ b/tools/decompress_yars.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: © 2023 ZeldaRET +# SPDX-License-Identifier: MIT + +# yar (Yaz0 ARchive) decompressor +# +# This program decompresses every raw yar binary file listed in +# `tools/filelists/{version}/archives.csv` to a corresponding +# `baserom/{file}.unarchive` raw file. +# +# It works by decompressing every Yaz0 block and appending them one by one into +# a new raw binary file so it can be processed normally by other tools. + + +from __future__ import annotations + +import argparse +import dataclasses +import libyaz0 +from pathlib import Path +import struct + + +PRINT_XML = False + +@dataclasses.dataclass +class ArchiveMeta: + start: int + end: int + + +def readFileAsBytearray(filepath: Path) -> bytearray: + with filepath.open(mode="rb") as f: + return bytearray(f.read()) + + +def readBytesAsWord(array_of_bytes: bytearray, offset: int) -> int: + return struct.unpack_from(f">I", array_of_bytes, offset)[0] + + +def getOffsetsList(archiveBytes: bytearray) -> list[ArchiveMeta]: + archivesOffsets: list[ArchiveMeta] = [] + + firstEntryOffset = readBytesAsWord(archiveBytes, 0) + firstEntrySize = readBytesAsWord(archiveBytes, 4) + + archivesOffsets.append(ArchiveMeta(firstEntryOffset, firstEntryOffset + firstEntrySize)) + + offset = 4 + while offset < firstEntryOffset - 4: + entry = readBytesAsWord(archiveBytes, offset) + nextEntry = readBytesAsWord(archiveBytes, offset + 4) + entryStart = entry + firstEntryOffset + entryEnd = nextEntry + firstEntryOffset + archivesOffsets.append(ArchiveMeta(entryStart, entryEnd)) + + offset += 4 + + return archivesOffsets + + +def extractArchive(archivePath: Path, outPath: Path): + archiveBytes = readFileAsBytearray(archivePath) + + if readBytesAsWord(archiveBytes, 0) == 0: + # Empty file, ignore it + return + + print(f"Extracting '{archivePath}' -> '{outPath}'") + archivesOffsets = getOffsetsList(archiveBytes) + + if PRINT_XML: + print('') + print(f' ') + + with outPath.open("wb") as out: + currentOffset = 0 + for meta in archivesOffsets: + decompressedBytes = libyaz0.decompress(archiveBytes[meta.start:meta.end]) + decompressedSize = len(decompressedBytes) + out.write(decompressedBytes) + + if PRINT_XML: + print(f' ') + + currentOffset += decompressedSize + + if PRINT_XML: + print(f' ') + print('') + + +def main(): + parser = argparse.ArgumentParser(description="MM archives extractor") + parser.add_argument("-v", "--version", help="version to process", default="mm.us.rev1") + parser.add_argument("--xml", help="Generate xml to stdout", action="store_true") + + args = parser.parse_args() + + global PRINT_XML + PRINT_XML = args.xml + + archivesCsvPath = Path(f"tools/filelists/{args.version}/archives.csv") + + with archivesCsvPath.open() as f: + for line in f: + archiveName = line.strip().split(",")[1] + archivePath = Path(f"baserom/{archiveName}") + + extractedPath = Path(str(archivePath) + ".unarchive") + extractArchive(archivePath, extractedPath) + +if __name__ == "__main__": + main() diff --git a/tools/disasm/dma_filenames.txt b/tools/disasm/dma_filenames.txt index aaa17ab6d..798a8b366 100644 --- a/tools/disasm/dma_filenames.txt +++ b/tools/disasm/dma_filenames.txt @@ -7,8 +7,8 @@ 'Audiotable', 'kanji', 'link_animetion', - 'icon_item_static_old', - 'icon_item_24_static_old', + 'icon_item_static_syms', + 'icon_item_24_static_syms', 'icon_item_field_static', 'icon_item_dungeon_static', 'icon_item_gameover_static', @@ -18,10 +18,10 @@ 'map_grand_static', 'item_name_static', 'map_name_static', - 'icon_item_static_test', - 'icon_item_24_static_test', - 'schedule_dma_static_old', - 'schedule_dma_static_test', + 'icon_item_static_yar', + 'icon_item_24_static_yar', + 'schedule_dma_static_syms', + 'schedule_dma_static_yar', 'schedule_static', 'story_static', 'do_action_static', diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7ffcecb0b..22589c105 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1751,10 +1751,10 @@ 0x800FC64C:("Environment_DrawSandstorm",), 0x800FD2B4:("func_800FD2B4",), 0x800FD538:("func_800FD538",), - 0x800FD59C:("func_800FD59C",), - 0x800FD5E0:("func_800FD5E0",), - 0x800FD654:("func_800FD654",), - 0x800FD698:("func_800FD698",), + 0x800FD59C:("Environment_LerpAmbientColor",), + 0x800FD5E0:("Environment_LerpDiffuseColor",), + 0x800FD654:("Environment_LerpFogColor",), + 0x800FD698:("Environment_LerpFog",), 0x800FD720:("get_days_elapsed",), 0x800FD730:("reset_days_elapsed",), 0x800FD740:("get_current_day",), @@ -4308,7 +4308,7 @@ 0x8082EF54:("func_8082EF54",), 0x8082EF9C:("func_8082EF9C",), 0x8082EFE4:("func_8082EFE4",), - 0x8082F02C:("func_8082F02C",), + 0x8082F02C:("Player_LerpEnvLighting",), 0x8082F09C:("Player_ResetCylinder",), 0x8082F0E4:("Player_SetCylinderForAttack",), 0x8082F164:("func_8082F164",), @@ -10217,27 +10217,27 @@ 0x80A35DDC:("ObjBell_Draw",), 0x80A35FF0:("EnSyatekiOkuta_Init",), 0x80A3611C:("EnSyatekiOkuta_Destroy",), - 0x80A36148:("func_80A36148",), - 0x80A361B0:("func_80A361B0",), - 0x80A361F4:("func_80A361F4",), - 0x80A36260:("func_80A36260",), - 0x80A362A8:("func_80A362A8",), - 0x80A362F8:("func_80A362F8",), - 0x80A36350:("func_80A36350",), - 0x80A36360:("func_80A36360",), - 0x80A363B4:("func_80A363B4",), - 0x80A36444:("func_80A36444",), - 0x80A36488:("func_80A36488",), - 0x80A364C0:("func_80A364C0",), - 0x80A36504:("func_80A36504",), - 0x80A3657C:("func_80A3657C",), - 0x80A365EC:("func_80A365EC",), - 0x80A368E0:("func_80A368E0",), - 0x80A36A90:("func_80A36A90",), - 0x80A36AF8:("func_80A36AF8",), + 0x80A36148:("EnSyatekiOkuta_SpawnDust",), + 0x80A361B0:("EnSyatekiOkuta_SpawnSplash",), + 0x80A361F4:("EnSyatekiOkuta_IsHiddenByAnotherOctorok",), + 0x80A36260:("EnSyatekiOkuta_SetupAttachToShootingGalleryMan",), + 0x80A362A8:("EnSyatekiOkuta_AttachToShootingGalleryMan",), + 0x80A362F8:("EnSyatekiOkuta_SetupDoNothing",), + 0x80A36350:("EnSyatekiOkuta_DoNothing",), + 0x80A36360:("EnSyatekiOkuta_SetupAppear",), + 0x80A363B4:("EnSyatekiOkuta_Appear",), + 0x80A36444:("EnSyatekiOkuta_SetupFloat",), + 0x80A36488:("EnSyatekiOkuta_Float",), + 0x80A364C0:("EnSyatekiOkuta_SetupHide",), + 0x80A36504:("EnSyatekiOkuta_Hide",), + 0x80A3657C:("EnSyatekiOkuta_SetupDie",), + 0x80A365EC:("EnSyatekiOkuta_Die",), + 0x80A368E0:("EnSyatekiOkuta_UpdateCollision",), + 0x80A36A90:("EnSyatekiOkuta_CheckCollision",), + 0x80A36AF8:("EnSyatekiOkuta_CheckForSignal",), 0x80A36B9C:("EnSyatekiOkuta_Update",), - 0x80A36CB0:("func_80A36CB0",), - 0x80A370EC:("func_80A370EC",), + 0x80A36CB0:("EnSyatekiOkuta_UpdateHeadScale",), + 0x80A370EC:("EnSyatekiOkuta_GetSnoutScale",), 0x80A37294:("EnSyatekiOkuta_OverrideLimbDraw",), 0x80A3735C:("EnSyatekiOkuta_Draw",), 0x80A37ED0:("ObjShutter_Init",), @@ -11338,28 +11338,28 @@ 0x80A90468:("EnTest5_Destroy",), 0x80A90478:("EnTest5_HandleBottleAction",), 0x80A905A4:("EnTest5_Update",), - 0x80A90730:("func_80A90730",), + 0x80A90730:("EnTest6_SetupCutscene",), 0x80A90C08:("EnTest6_EnableMotionBlur",), 0x80A90C34:("EnTest6_DisableMotionBlur",), - 0x80A90C54:("func_80A90C54",), - 0x80A90D20:("func_80A90D20",), - 0x80A90D34:("func_80A90D34",), - 0x80A90FC0:("func_80A90FC0",), + 0x80A90C54:("EnTest6_EnableWhiteFillScreen",), + 0x80A90D20:("EnTest6_DisableWhiteFillScreen",), + 0x80A90D34:("EnTest6_DrawAmmoDropDefault",), + 0x80A90FC0:("EnTest6_DrawAmmoDropRupee",), 0x80A91324:("EnTest6_SetupAction",), 0x80A91330:("EnTest6_Init",), 0x80A9149C:("EnTest6_Destroy",), - 0x80A9156C:("func_80A9156C",), - 0x80A91690:("func_80A91690",), - 0x80A916F0:("func_80A916F0",), - 0x80A91760:("func_80A91760",), - 0x80A920C8:("func_80A920C8",), - 0x80A92118:("func_80A92118",), - 0x80A92188:("func_80A92188",), + 0x80A9156C:("EnTest6_StartCutscene",), + 0x80A91690:("EnTest6_SetupInvertedSoTCutscene",), + 0x80A916F0:("EnTest6_StopInvertedSoTCutscene",), + 0x80A91760:("EnTest6_InvertedSoTCutscene",), + 0x80A920C8:("EnTest6_SetupDoubleSoTCutscene",), + 0x80A92118:("EnTest6_StopDoubleSoTCutscene",), + 0x80A92188:("EnTest6_DoubleSoTCutscene",), 0x80A9292C:("EnTest6_Update",), - 0x80A92950:("func_80A92950",), - 0x80A93298:("func_80A93298",), - 0x80A9369C:("func_80A9369C",), - 0x80A939E8:("func_80A939E8",), + 0x80A92950:("EnTest6_SharedSoTCutscene",), + 0x80A93298:("EnTest6_DrawThreeDayResetSoTCutscene",), + 0x80A9369C:("EnTest6_DrawDoubleSoTCutscene",), + 0x80A939E8:("EnTest6_DrawInvertedSoTCutscene",), 0x80A93DE8:("EnTest6_Draw",), 0x80A94A30:("func_80A94A30",), 0x80A94A64:("func_80A94A64",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b0cb52145..c508c464a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -903,11 +903,11 @@ 0x801BB050:("sDebugDisplayLight1","Lights1","",0x24), 0x801BB068:("D_801BB068","UNK_TYPE2","",0x2), 0x801BB08C:("D_801BB08C","UNK_TYPE1","",0x1), - 0x801BB090:("D_801BB090","UNK_TYPE4","",0x4), - 0x801BB094:("D_801BB094","UNK_TYPE1","",0x1), - 0x801BB0DC:("D_801BB0DC","UNK_TYPE1","",0x1), - 0x801BB0FC:("D_801BB0FC","UNK_TYPE2","",0x2), - 0x801BB100:("D_801BB100","UNK_TYPE1","",0x1), + 0x801BB090:("sDebugTextDrawFlags","UNK_TYPE4","",0x4), + 0x801BB094:("sDebugTextBuffer","UNK_TYPE1","",0x1), + 0x801BB0DC:("sDebugTextColors","UNK_TYPE1","",0x1), + 0x801BB0FC:("sDebugCamTextEntryCount","UNK_TYPE2","",0x2), + 0x801BB100:("sDebugCamTextColors","UNK_TYPE1","",0x1), 0x801BB124:("sCurTextId","UNK_TYPE2","",0x2), 0x801BB128:("sCurOcarinaAction","UNK_TYPE2","",0x2), 0x801BB12C:("gOpeningEntranceIndex","UNK_TYPE1","",0x1), @@ -1328,13 +1328,13 @@ 0x801C212C:("gSceneIdsPerRegion","SceneIdList","[]",0x252), 0x801C2380:("sSceneIdsPerTingleMap","u16","[]",0x90), 0x801C2410:("gPlayerFormItemRestrictions","UNK_TYPE1","",0x1), - 0x801C2650:("tatlMessageFiles","RomFile","[2]",0x10), + 0x801C2650:("naviQuestHintFiles","RomFile","[2]",0x10), 0x801C2660:("sceneTextureFiles","RomFile","[9]",0x48), - 0x801C26A8:("sceneHeaderFuncTable","scene_header_func","[31]",0x7c), + 0x801C26A8:("sSceneCmdHandlers","scene_header_func","[31]",0x7c), 0x801C2730:("gPlayerFormObjectIndices","s16","[5]",0xA), 0x801C273C:("gObjectTableSize","ObjectId","",0x4), 0x801C2740:("gObjectTable","RomFile","[643]",0x1418), - 0x801C3B60:("sSceneDrawDefaultDl","Gfx","[11]",0x58), + 0x801C3B60:("sSceneDrawDefaultDL","Gfx","[11]",0x58), 0x801C3BB8:("gSceneProcSceneDrawFuncs","SceneDrawConfigFunc","[8]",0x20), 0x801C3BD8:("gSceneProcDrawFuncs","scene_proc_draw_func","[6]",0x18), 0x801C3BF0:("D_801C3BF0","Gfx","[4]",0x20), @@ -4949,7 +4949,7 @@ 0x8085C928:("D_8085C928","UNK_TYPE1","",0x14), 0x8085C93C:("D_8085C93C","UNK_TYPE1","",0x1), 0x8085C96C:("D_8085C96C","UNK_TYPE1","",0x1), - 0x8085C98C:("D_8085C98C","UNK_TYPE1","",0x1), + 0x8085C98C:("sZoraBarrierEnvLighting","UNK_TYPE1","",0x1), 0x8085C99C:("sItemActionParams","UNK_TYPE1","",0x1), 0x8085C9F0:("D_8085C9F0","UNK_PTR","",0x4), 0x8085CB3C:("D_8085CB3C","UNK_PTR","",0x4), @@ -11207,11 +11207,11 @@ 0x80A37A88:("D_80A37A88","UNK_TYPE1","",0x1), 0x80A37B08:("D_80A37B08","UNK_TYPE1","",0x1), 0x80A37B88:("D_80A37B88","UNK_TYPE1","",0x1), - 0x80A37B90:("D_80A37B90","UNK_TYPE1","",0x1), - 0x80A37B94:("D_80A37B94","UNK_TYPE1","",0x1), - 0x80A37B98:("D_80A37B98","UNK_TYPE1","",0x1), - 0x80A37BA4:("D_80A37BA4","UNK_TYPE1","",0x1), - 0x80A37BA8:("D_80A37BA8","UNK_TYPE1","",0x1), + 0x80A37B90:("sDustPrimColor","UNK_TYPE1","",0x1), + 0x80A37B94:("sDustEnvColor","UNK_TYPE1","",0x1), + 0x80A37B98:("sBubbleAccel","UNK_TYPE1","",0x1), + 0x80A37BA4:("sBubblePrimColor","UNK_TYPE1","",0x1), + 0x80A37BA8:("sBubbleEnvColor","UNK_TYPE1","",0x1), 0x80A37BB0:("D_80A37BB0","f32","",0x4), 0x80A37BB4:("D_80A37BB4","f32","",0x4), 0x80A37BB8:("D_80A37BB8","f32","",0x4), @@ -12278,19 +12278,19 @@ 0x80A8FF6C:("D_80A8FF6C","f32","",0x4), 0x80A906E0:("En_Test5_InitVars","UNK_TYPE1","",0x1), 0x80A93E60:("En_Test6_InitVars","UNK_TYPE1","",0x1), - 0x80A93E80:("D_80A93E80","UNK_TYPE1","",0x1), - 0x80A9402C:("D_80A9402C","UNK_TYPE1","",0x1), - 0x80A94048:("D_80A94048","UNK_TYPE1","",0x1), - 0x80A9404C:("D_80A9404C","UNK_TYPE1","",0x1), - 0x80A94050:("D_80A94050","UNK_TYPE1","",0x1), - 0x80A94054:("D_80A94054","UNK_TYPE2","",0x2), - 0x80A94058:("D_80A94058","UNK_TYPE2","",0x2), + 0x80A93E80:("sDoubleSoTCsCamData","UNK_TYPE1","",0x1), + 0x80A9402C:("sSoTCsAmmoDropTextures","UNK_TYPE1","",0x1), + 0x80A94048:("sInvSoTCsFogColor","UNK_TYPE1","",0x1), + 0x80A9404C:("sInvSoTCsAmbientColor","UNK_TYPE1","",0x1), + 0x80A94050:("sInvSoTCsDiffuseColor","UNK_TYPE1","",0x1), + 0x80A94054:("sInvSoTCsFogNear","UNK_TYPE2","",0x2), + 0x80A94058:("sInvSoTCsZFar","UNK_TYPE2","",0x2), 0x80A9405C:("D_80A9405C","UNK_TYPE1","",0x1), - 0x80A94068:("D_80A94068","UNK_TYPE1","",0x1), - 0x80A9406C:("D_80A9406C","UNK_TYPE1","",0x1), - 0x80A94070:("D_80A94070","UNK_TYPE1","",0x1), - 0x80A94074:("D_80A94074","UNK_TYPE2","",0x2), - 0x80A94078:("D_80A94078","UNK_TYPE2","",0x2), + 0x80A94068:("sDoubleSoTCsFogColor","UNK_TYPE1","",0x1), + 0x80A9406C:("sDoubleSoTCsAmbientColor","UNK_TYPE1","",0x1), + 0x80A94070:("sDoubleSoTCsDiffuseColor","UNK_TYPE1","",0x1), + 0x80A94074:("sDoubleSoTCsFogNear","UNK_TYPE2","",0x2), + 0x80A94078:("sDoubleSoTCsZFar","UNK_TYPE2","",0x2), 0x80A94080:("D_80A94080","f32","",0x4), 0x80A94084:("D_80A94084","f32","",0x4), 0x80A94088:("D_80A94088","f32","",0x4), @@ -12321,7 +12321,7 @@ 0x80A94338:("jtbl_80A94338","UNK_PTR","",0x4), 0x80A94360:("D_80A94360","f32","",0x4), 0x80A94364:("D_80A94364","f32","",0x4), - 0x80A94910:("D_80A94910","UNK_TYPE4","",0x4), + 0x80A94910:("sSoTCsAmmoDrops","UNK_TYPE4","",0x4), 0x80A99010:("D_80A99010","UNK_TYPE4","",0x4), 0x80A990F0:("En_Az_InitVars","UNK_TYPE1","",0x1), 0x80A99110:("D_80A99110","UNK_TYPE1","",0x1), diff --git a/tools/extract_baserom.py b/tools/extract_baserom.py index 03d230e80..c631a6392 100755 --- a/tools/extract_baserom.py +++ b/tools/extract_baserom.py @@ -14,8 +14,8 @@ FILE_NAMES = [ 'Audiotable', 'kanji', 'link_animetion', - 'icon_item_static_old', - 'icon_item_24_static_old', + 'icon_item_static_syms', + 'icon_item_24_static_syms', 'icon_item_field_static', 'icon_item_dungeon_static', 'icon_item_gameover_static', @@ -25,10 +25,10 @@ FILE_NAMES = [ 'map_grand_static', 'item_name_static', 'map_name_static', - 'icon_item_static_test', - 'icon_item_24_static_test', - 'schedule_dma_static_old', - 'schedule_dma_static_test', + 'icon_item_static_yar', + 'icon_item_24_static_yar', + 'schedule_dma_static_syms', + 'schedule_dma_static_yar', 'schedule_static', 'story_static', 'do_action_static', diff --git a/tools/filelists/mm.us.rev1/all.csv b/tools/filelists/mm.us.rev1/all.csv index c23622330..7c98a7cf3 100644 --- a/tools/filelists/mm.us.rev1/all.csv +++ b/tools/filelists/mm.us.rev1/all.csv @@ -6,8 +6,8 @@ 5,Audiotable 6,kanji 7,link_animetion -8,icon_item_static_old -9,icon_item_24_static_old +8,icon_item_static_syms +9,icon_item_24_static_syms 10,icon_item_field_static 11,icon_item_dungeon_static 12,icon_item_gameover_static @@ -17,10 +17,10 @@ 16,map_grand_static 17,item_name_static 18,map_name_static -19,icon_item_static_test -20,icon_item_24_static_test -21,schedule_dma_static_old -22,schedule_dma_static_test +19,icon_item_static_yar +20,icon_item_24_static_yar +21,schedule_dma_static_syms +22,schedule_dma_static_yar 23,schedule_static 24,story_static 25,do_action_static diff --git a/tools/filelists/mm.us.rev1/archives.csv b/tools/filelists/mm.us.rev1/archives.csv index a0b758dfd..3053456d0 100644 --- a/tools/filelists/mm.us.rev1/archives.csv +++ b/tools/filelists/mm.us.rev1/archives.csv @@ -2,6 +2,6 @@ 16,map_grand_static 17,item_name_static 18,map_name_static -19,icon_item_static_test -20,icon_item_24_static_test -22,schedule_dma_static_test +19,icon_item_static_yar +20,icon_item_24_static_yar +22,schedule_dma_static_yar diff --git a/tools/filelists/mm.us.rev1/deleted.csv b/tools/filelists/mm.us.rev1/deleted.csv index 12e60f6ee..2fca3fbe8 100644 --- a/tools/filelists/mm.us.rev1/deleted.csv +++ b/tools/filelists/mm.us.rev1/deleted.csv @@ -1,3 +1,3 @@ -8,icon_item_static_old -9,icon_item_24_static_old -21,schedule_dma_static_old +8,icon_item_static_syms +9,icon_item_24_static_syms +21,schedule_dma_static_syms diff --git a/tools/progress.py b/tools/progress.py index 5a2958cd8..9096715aa 100755 --- a/tools/progress.py +++ b/tools/progress.py @@ -136,7 +136,6 @@ if not args.matching: # The order of this list should not change to prevent breaking the graph of the website # New stuff shall be appended at the end of the list assetsCategories = [ - "archives", "audio", "interface", "misc", @@ -148,6 +147,11 @@ assetsCategories = [ ] assetsTracker = dict() +# Assets that we don't have a proper way of tracking right now +ignoredAssets = { + "archives", +} + # Manual fixer for files that would be counted in wrong categories # "filename": "correctSection" fileSectionFixer = { @@ -203,12 +207,12 @@ for line in map_file: file_size = int(line_split[2], 16) obj_file = line_split[3].strip() objFileSplit = obj_file.split("/") + objFileName = objFileSplit[-1].split(".o")[0] fileData = {"name": obj_file, "vram": obj_vram, "size": file_size, "section": section, "symbols": []} mapFileList.append(fileData) if (section == ".text"): - objFileName = objFileSplit[-1].split(".o")[0] srcCat = obj_file.split("/")[2] if srcCat in srcCategoriesFixer: srcCat = srcCategoriesFixer[srcCat] @@ -229,6 +233,8 @@ for line in map_file: assetCat = obj_file.split("/")[2] if assetCat in assetsTracker: assetsTracker[assetCat]["currentSize"] += file_size + elif assetCat in ignoredAssets: + pass else: eprint(f"Found file '{obj_file}' in unknown asset category '{assetCat}'") eprint("I'll ignore this for now, but please fix it!") diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 66e48d74d..5f19bdc0d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1265,10 +1265,10 @@ asm/non_matchings/code/z_kankyo/Environment_FillScreen.s,Environment_FillScreen, asm/non_matchings/code/z_kankyo/Environment_DrawSandstorm.s,Environment_DrawSandstorm,0x800FC64C,0x31A asm/non_matchings/code/z_kankyo/func_800FD2B4.s,func_800FD2B4,0x800FD2B4,0xA1 asm/non_matchings/code/z_kankyo/func_800FD538.s,func_800FD538,0x800FD538,0x19 -asm/non_matchings/code/z_kankyo/func_800FD59C.s,func_800FD59C,0x800FD59C,0x11 -asm/non_matchings/code/z_kankyo/func_800FD5E0.s,func_800FD5E0,0x800FD5E0,0x1D -asm/non_matchings/code/z_kankyo/func_800FD654.s,func_800FD654,0x800FD654,0x11 -asm/non_matchings/code/z_kankyo/func_800FD698.s,func_800FD698,0x800FD698,0x22 +asm/non_matchings/code/z_kankyo/Environment_LerpAmbientColor.s,Environment_LerpAmbientColor,0x800FD59C,0x11 +asm/non_matchings/code/z_kankyo/Environment_LerpDiffuseColor.s,Environment_LerpDiffuseColor,0x800FD5E0,0x1D +asm/non_matchings/code/z_kankyo/Environment_LerpFogColor.s,Environment_LerpFogColor,0x800FD654,0x11 +asm/non_matchings/code/z_kankyo/Environment_LerpFog.s,Environment_LerpFog,0x800FD698,0x22 asm/non_matchings/code/z_kankyo/get_days_elapsed.s,get_days_elapsed,0x800FD720,0x4 asm/non_matchings/code/z_kankyo/reset_days_elapsed.s,reset_days_elapsed,0x800FD730,0x4 asm/non_matchings/code/z_kankyo/get_current_day.s,get_current_day,0x800FD740,0x4 diff --git a/undefined_syms.txt b/undefined_syms.txt index e586991ff..9dd07f623 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1098,32 +1098,6 @@ D_06000B70 = 0x06000B70; D_06000D60 = 0x06000D60; -// segment 0x07 - -D_07000000 = 0x07000000; -D_07000800 = 0x07000800; -D_07001000 = 0x07001000; -D_07001800 = 0x07001800; -D_07002000 = 0x07002000; -D_07002800 = 0x07002800; -D_07003000 = 0x07003000; -D_07003800 = 0x07003800; -D_07004000 = 0x07004000; -D_07004800 = 0x07004800; -D_07005000 = 0x07005000; -D_07005800 = 0x07005800; -D_07006000 = 0x07006000; -D_07006800 = 0x07006800; -D_07007000 = 0x07007000; -D_07007800 = 0x07007800; -D_07008000 = 0x07008000; -D_07008800 = 0x07008800; -D_07009000 = 0x07009000; -D_07009800 = 0x07009800; -D_0700AC00 = 0x0700AC00; -D_0700AEA0 = 0x0700AEA0; - - // segment 0x08 D_08000000 = 0x08000000;